diff options
Diffstat (limited to 'target_explorer/plugins')
77 files changed, 5123 insertions, 1638 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml index 8504730de..8a1b0d5a8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/plugin.xml @@ -32,6 +32,13 @@ properties="launchMode,launchConfigTypeId"
type="org.eclipse.debug.core.ILaunch">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.tcf.te.launch.core.bindings.internal.PropertyTester"
+ id="org.eclipse.tcf.te.launch.core.PropertyTester"
+ namespace="org.eclipse.tcf.te.launch.core"
+ properties="isValidLaunchConfigType"
+ type="java.lang.Object">
+ </propertyTester>
</extension>
<!-- Launch Step contributions -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java index 1d55155a1..4439b2540 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/LaunchConfigTypeBindingsManager.java @@ -100,7 +100,7 @@ public class LaunchConfigTypeBindingsManager { ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
return (launchConfigType != null && launchConfigType.isPublic() &&
(selection.getLaunchMode() == null || launchConfigType.supportsMode(selection.getLaunchMode())) &&
- binding != null && binding.validate(selection) != EvaluationResult.FALSE);
+ binding != null && binding.validate(selection) == EvaluationResult.TRUE);
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java index 73df9b5aa..fb0d4ae68 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchConfigTypeBinding.java @@ -10,6 +10,8 @@ package org.eclipse.tcf.te.launch.core.bindings.internal;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.expressions.EvaluationContext;
@@ -191,8 +193,10 @@ public class LaunchConfigTypeBinding { for (Expression expression : expressions) {
// Set the default variable and "selection" is the selection context
EvaluationContext evalContext = new EvaluationContext(null, context);
- evalContext.addVariable("selection", context); //$NON-NLS-1$
- evalContext.addVariable("mode", mode); //$NON-NLS-1$
+ evalContext.addVariable("context", context.getContext()); //$NON-NLS-1$
+ evalContext.addVariable("selection", context.getSelections() != null ? Arrays.asList(context.getSelections()) : Collections.EMPTY_LIST); //$NON-NLS-1$
+ evalContext.addVariable("type", context.getType() != null ? context.getType() : ""); //$NON-NLS-1$ //$NON-NLS-2$
+ evalContext.addVariable("mode", mode != null ? mode : ""); //$NON-NLS-1$ //$NON-NLS-2$
// Allow plugin activation
evalContext.setAllowPluginActivation(true);
// Evaluate the expression
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java index 3d55f1c07..24c364e7a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/PropertyTester.java @@ -9,8 +9,17 @@ *******************************************************************************/
package org.eclipse.tcf.te.launch.core.bindings.internal;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunch;
+import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
+import org.eclipse.tcf.te.launch.core.selection.LaunchSelection;
+import org.eclipse.tcf.te.launch.core.selection.ProjectSelectionContext;
+import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext;
+import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNodeProvider;
/**
* Launch property tester.
@@ -23,11 +32,13 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester @Override
public boolean test(final Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof ILaunch) {
- if ("launchMode".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ if ("launchMode".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ if (receiver instanceof ILaunch) {
return ((ILaunch)receiver).getLaunchMode().equalsIgnoreCase((String)expectedValue);
}
- if ("launchConfigTypeid".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ }
+ else if ("launchConfigTypeid".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ if (receiver instanceof ILaunch) {
try {
return ((ILaunch)receiver).getLaunchConfiguration().getType().getIdentifier().equalsIgnoreCase((String)expectedValue);
}
@@ -35,6 +46,32 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester }
}
}
+ else if ("isValidLaunchConfigType".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
+ ISelectionContext selContext = null;
+ if (receiver instanceof IModelNodeProvider) {
+ selContext = new RemoteSelectionContext(((IModelNodeProvider)receiver).getModelNode(), true);
+ }
+ else if (receiver instanceof IProject) {
+ selContext = new ProjectSelectionContext((IProject)receiver, true);
+ }
+ else if (receiver instanceof IAdaptable) {
+ IProject project = (IProject)((IAdaptable)receiver).getAdapter(IProject.class);
+ if (project != null) {
+ selContext = new ProjectSelectionContext(project, true);
+ }
+ IModelNode modelNode = (IModelNode)((IAdaptable)receiver).getAdapter(IModelNode.class);
+ if (modelNode != null) {
+ selContext = new RemoteSelectionContext(modelNode, true);
+ }
+ }
+ if (selContext != null) {
+ return LaunchConfigTypeBindingsManager.getInstance().isValidLaunchConfigType(
+ (String)expectedValue,
+ new LaunchSelection(
+ (args != null && args.length > 0 ? args[0].toString() : null),
+ selContext));
+ }
+ }
return false;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/interfaces/IReferencedProjectItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/interfaces/IReferencedProjectItem.java index eac93701f..8411aeeee 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/interfaces/IReferencedProjectItem.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/interfaces/IReferencedProjectItem.java @@ -19,4 +19,14 @@ public interface IReferencedProjectItem extends IPropertiesContainer { public static final String PROPERTY_ENABLED = "enabled"; //$NON-NLS-1$
public static final String PROPERTY_PROJECT_NAME = "project_name"; //$NON-NLS-1$
+
+ /**
+ * Return <code>true</code> if the item is enabled.
+ */
+ public boolean isEnabled();
+
+ /**
+ * Return the project name.
+ */
+ public String getProjectName();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java index 22381c728..7ffb5d7de 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchManager.java @@ -10,7 +10,6 @@ package org.eclipse.tcf.te.launch.core.lm; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -34,7 +33,6 @@ import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute; import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; import org.eclipse.tcf.te.launch.core.nls.Messages; -import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate; /** * The Launch Manager is the management interface for the launch configuration storage layer. @@ -99,7 +97,7 @@ public class LaunchManager extends PlatformObject { */ public ILaunchConfigurationType getLaunchConfigType(String launchConfigTypeId, String launchMode) { ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager() - .getLaunchConfigurationType(launchConfigTypeId); + .getLaunchConfigurationType(launchConfigTypeId); if (launchConfigType != null && !launchConfigType.supportsMode(launchMode)) { launchConfigType = null; } @@ -217,38 +215,16 @@ public class LaunchManager extends PlatformObject { } ILaunchConfigurationWorkingCopy wc = null; if (launchConfig == null || !launchConfig.getType().getIdentifier() - .equals(launchConfigTypeId)) { + .equals(launchConfigTypeId)) { try { // create the launch configuration working copy instance wc = launchConfigType.newInstance(null, DebugPlugin - .getDefault() - .getLaunchManager() - .generateLaunchConfigurationName(launchSpec - .getLaunchConfigName())); + .getDefault() + .getLaunchManager() + .generateLaunchConfigurationName(launchSpec + .getLaunchConfigName())); // initialize the launch configuration working copy delegate.initLaunchConfigAttributes(wc, launchSpec); - // copy all additional attributes set in the launch spec to the working copy - ILaunchAttribute[] allAttributes = launchSpec.getAllAttributes(); - for (ILaunchAttribute attribute : allAttributes) { - if (!wc.hasAttribute(attribute.getKey())) { - Object value = attribute.getValue(); - if (value instanceof Boolean) { - DefaultPersistenceDelegate.setAttribute(wc, attribute.getKey(), ((Boolean) value).booleanValue()); - } - else if (value instanceof Integer) { - DefaultPersistenceDelegate.setAttribute(wc, attribute.getKey(), ((Integer) value).intValue()); - } - else if (value instanceof List<?>) { - DefaultPersistenceDelegate.setAttribute(wc, attribute.getKey(), (List<?>) value); - } - else if (value instanceof Map<?, ?>) { - DefaultPersistenceDelegate.setAttribute(wc, attribute.getKey(), (Map<?, ?>) value); - } - else if (value instanceof String) { - DefaultPersistenceDelegate.setAttribute(wc, attribute.getKey(), (String) value); - } - } - } // and save the launch configuration return wc.doSave(); } @@ -294,7 +270,7 @@ public class LaunchManager extends PlatformObject { } catch (CoreException e) { IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), - Messages.LaunchManager_error_deleteLaunchConfig, e); + Messages.LaunchManager_error_deleteLaunchConfig, e); Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java index 3905a4d54..4fd39ee2d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java @@ -10,6 +10,7 @@ package org.eclipse.tcf.te.launch.core.lm.delegates;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -25,18 +26,26 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.tcf.te.launch.core.activator.CoreBundleActivator;
import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager;
import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
+import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
import org.eclipse.tcf.te.launch.core.interfaces.tracing.ITraceIds;
import org.eclipse.tcf.te.launch.core.lm.LaunchConfigSorter;
import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchAttribute;
+import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate;
import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
import org.eclipse.tcf.te.launch.core.lm.interfaces.IReferencedProjectLaunchAttributes;
import org.eclipse.tcf.te.launch.core.nls.Messages;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectsPersistenceDelegate;
import org.eclipse.tcf.te.launch.core.preferences.IPreferenceKeys;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
/**
* Default launch manager delegate implementation.
@@ -168,12 +177,14 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements // for full validation.
// otherwise "not preferred" contexts are valid even if they are not for a give
// launch configuration type id.
+ boolean oldPref = selectionContext.isPreferredContext();
selectionContext.setIsPreferredContext(true);
if (LaunchConfigTypeBindingsManager
.getInstance()
.isValidLaunchConfigType(launchConfigTypeId, launchSelection.getLaunchMode(), selectionContext)) {
spec = addLaunchSpecAttributes(spec, launchConfigTypeId, selectionContext);
}
+ selectionContext.setIsPreferredContext(oldPref);
}
// If the number of selected contexts is 0, we have to call addLaunchSpecAttributes
@@ -618,17 +629,80 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements Assert.isNotNull(specValue);
Assert.isNotNull(confValue);
+ if (ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS.equals(attributeKey)) {
+ // get match of list objects
+ int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ // compare objects in the list when they are not already equal
+ if (match != FULL_MATCH) {
+ List<IModelNode> confItems = Arrays.asList(LaunchContextsPersistenceDelegate.decodeLaunchContexts(confValue.toString()));
+ IModelNode[] specItems = LaunchContextsPersistenceDelegate.decodeLaunchContexts(specValue.toString());
+ int i = 0;
+ for (IModelNode item : specItems) {
+ if (confItems.contains(item)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ // full match on first element in the spec list,
+ // otherwise partial match
+ match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH;
+ }
+ }
+ else if (match == FULL_MATCH) {
+ // reduce full to partial match when spec object wasn't found
+ match = PARTIAL_MATCH;
+ }
+ i++;
+ }
+ // reduce full to partial match when list size is not equal
+ // but all spec values where found in the configuration project list
+ if (match == FULL_MATCH && specItems.length != confItems.size()) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ return match;
+ }
+
+ if (IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS.equals(attributeKey)) {
+ // get match of list objects
+ int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ // compare objects in the list when they are not already equal
+ if (match != FULL_MATCH) {
+ List<IFileTransferItem> confItems = Arrays.asList(FileTransfersPersistenceDelegate.decodeFileTransferItems(confValue.toString()));
+ IFileTransferItem[] specItems = FileTransfersPersistenceDelegate.decodeFileTransferItems(specValue.toString());
+ int i = 0;
+ for (IFileTransferItem item : specItems) {
+ if (confItems.contains(item)) {
+ // spec object can be found in the configuration
+ if (match == NO_MATCH) {
+ // full match on first element in the spec list,
+ // otherwise partial match
+ match = (i == 0) ? FULL_MATCH : PARTIAL_MATCH;
+ }
+ }
+ else if (match == FULL_MATCH) {
+ // reduce full to partial match when spec object wasn't found
+ match = PARTIAL_MATCH;
+ }
+ i++;
+ }
+ // reduce full to partial match when list size is not equal
+ // but all spec values where found in the configuration project list
+ if (match == FULL_MATCH && specItems.length != confItems.size()) {
+ match = PARTIAL_MATCH;
+ }
+ }
+ return match;
+ }
+
if (IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS.equals(attributeKey)) {
// get match of list objects
int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
// compare objects in the list when they are not already equal
- if (match != FULL_MATCH && specValue instanceof List<?> && confValue instanceof List<?>) {
- List<?> specProject = (List<?>) specValue;
- List<?> confProject = (List<?>) confValue;
- match = (specProject.isEmpty() || confProject.isEmpty()) ? PARTIAL_MATCH : NO_MATCH;
- for (int i = 0; i < specProject.size(); i++) {
- Object specObject = specProject.get(i);
- if (specObject != null && confProject.contains(specObject)) {
+ if (match != FULL_MATCH) {
+ List<IReferencedProjectItem> confItems = Arrays.asList(ReferencedProjectsPersistenceDelegate.decodeReferencedProjectItems(confValue.toString()));
+ IReferencedProjectItem[] specItems = ReferencedProjectsPersistenceDelegate.decodeReferencedProjectItems(specValue.toString());
+ int i = 0;
+ for (IReferencedProjectItem item : specItems) {
+ if (confItems.contains(item)) {
// spec object can be found in the configuration
if (match == NO_MATCH) {
// full match on first element in the spec list,
@@ -640,10 +714,11 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements // reduce full to partial match when spec object wasn't found
match = PARTIAL_MATCH;
}
+ i++;
}
// reduce full to partial match when list size is not equal
// but all spec values where found in the configuration project list
- if (match == FULL_MATCH && specProject.size() != confProject.size()) {
+ if (match == FULL_MATCH && specItems.length != confItems.size()) {
match = PARTIAL_MATCH;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java index 41077646c..efb156188 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java @@ -24,4 +24,30 @@ public class ReferencedProjectItem extends PropertiesContainer implements IRefer public ReferencedProjectItem() {
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return getBooleanProperty(PROPERTY_ENABLED);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem#getProjectName()
+ */
+ @Override
+ public String getProjectName() {
+ return getStringProperty(PROPERTY_PROJECT_NAME);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof IReferencedProjectItem) {
+ return getProjectName().equals(((IReferencedProjectItem)obj).getProjectName());
+ }
+ return super.equals(obj);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java index ab2d0193e..46eb193b6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java @@ -15,6 +15,8 @@ import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext; * Abstract selection context implementation. */ public abstract class AbstractSelectionContext implements ISelectionContext { + // The context + protected final Object context; // The selection context type protected String type = null; // The selected objects @@ -25,11 +27,13 @@ public abstract class AbstractSelectionContext implements ISelectionContext { /** * Constructor. * + * @param The context object. * @param selections The selected objects or <code>null</code>. * @param isPreferred <code>True</code> to mark the selection context the preferred context, * <code>false</code> otherwise. */ - public AbstractSelectionContext(Object[] selections, boolean isPreferred) { + public AbstractSelectionContext(Object context, Object[] selections, boolean isPreferred) { + this.context = context; this.selections = selections != null ? selections : new Object[0]; this.isPreferred = isPreferred; } @@ -37,22 +41,32 @@ public abstract class AbstractSelectionContext implements ISelectionContext { /** * Constructor. * + * @param The context object. * @param type The selection context type or <code>null</code>. * @param selections The selected objects or <code>null</code>. * @param isPreferred <code>True</code> to mark the selection context the preferred context, * <code>false</code> otherwise. */ - public AbstractSelectionContext(String type, Object[] selections, boolean isPreferred) { + public AbstractSelectionContext(Object context, String type, Object[] selections, boolean isPreferred) { + this.context = context; this.type = type; this.selections = selections != null ? selections : new Object[0]; this.isPreferred = isPreferred; } /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext#getContext() + */ + @Override + public Object getContext() { + return context; + } + + /* (non-Javadoc) * @see org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext#getType() */ @Override - public String getType() { + public String getType() { return type; } @@ -60,7 +74,7 @@ public abstract class AbstractSelectionContext implements ISelectionContext { * @see org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext#getSelections() */ @Override - public Object[] getSelections() { + public Object[] getSelections() { return selections; } @@ -68,7 +82,7 @@ public abstract class AbstractSelectionContext implements ISelectionContext { * @see org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext#setIsPreferredContext(boolean) */ @Override - public void setIsPreferredContext(boolean isPreferred) { + public void setIsPreferredContext(boolean isPreferred) { this.isPreferred = isPreferred; } @@ -76,7 +90,7 @@ public abstract class AbstractSelectionContext implements ISelectionContext { * @see org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext#isPreferredContext() */ @Override - public boolean isPreferredContext() { + public boolean isPreferredContext() { return isPreferred; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/ProjectSelectionContext.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/ProjectSelectionContext.java index eb40a2e31..83e37ac6b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/ProjectSelectionContext.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/ProjectSelectionContext.java @@ -14,10 +14,8 @@ import org.eclipse.tcf.te.launch.core.selection.interfaces.IProjectSelectionCont /** * Project launch selection context implementation. -*/ + */ public class ProjectSelectionContext extends AbstractSelectionContext implements IProjectSelectionContext { - // The projectCtx context - private IProject projectCtx; /** * Constructor. @@ -27,7 +25,7 @@ public class ProjectSelectionContext extends AbstractSelectionContext implements * <code>false</code> otherwise. */ public ProjectSelectionContext(IProject project, boolean isPreferred) { - this(project, null, isPreferred); + this(project, new Object[]{project}, isPreferred); } /** @@ -39,8 +37,7 @@ public class ProjectSelectionContext extends AbstractSelectionContext implements * <code>false</code> otherwise. */ public ProjectSelectionContext(IProject project, Object[] selections, boolean isPreferred) { - super(selections, isPreferred); - this.projectCtx = project; + super(project, selections, isPreferred); } /* (non-Javadoc) @@ -48,7 +45,7 @@ public class ProjectSelectionContext extends AbstractSelectionContext implements */ @Override public IProject getProjectCtx() { - return projectCtx; + return (IProject)getContext(); } /* (non-Javadoc) @@ -58,8 +55,8 @@ public class ProjectSelectionContext extends AbstractSelectionContext implements public String toString() { StringBuffer toString = new StringBuffer(); - if (projectCtx != null) { - toString.append(projectCtx.getName()); + if (getProjectCtx() != null) { + toString.append(getProjectCtx().getName()); } toString.append(toString.length() > 0 ? " " : ""); //$NON-NLS-1$ //$NON-NLS-2$ toString.append(super.toString()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/RemoteSelectionContext.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/RemoteSelectionContext.java index b7f40337f..4065bb6b8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/RemoteSelectionContext.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/RemoteSelectionContext.java @@ -16,8 +16,6 @@ import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; * Step context selection context implementation. */ public class RemoteSelectionContext extends AbstractSelectionContext implements IRemoteSelectionContext { - // The step context - private IModelNode remoteCtx = null; /** * Constructor. @@ -27,7 +25,7 @@ public class RemoteSelectionContext extends AbstractSelectionContext implements * <code>false</code> otherwise. */ public RemoteSelectionContext(IModelNode remoteCtx, boolean isPreferred) { - this(remoteCtx, null, isPreferred); + this(remoteCtx, new Object[]{remoteCtx}, isPreferred); } /** @@ -39,8 +37,7 @@ public class RemoteSelectionContext extends AbstractSelectionContext implements * <code>false</code> otherwise. */ public RemoteSelectionContext(IModelNode remoteCtx, Object[] selections, boolean isPreferred) { - super(selections, isPreferred); - this.remoteCtx = remoteCtx; + super(remoteCtx, selections, isPreferred); } /* (non-Javadoc) @@ -48,7 +45,7 @@ public class RemoteSelectionContext extends AbstractSelectionContext implements */ @Override public IModelNode getRemoteCtx() { - return remoteCtx; + return (IModelNode)getContext(); } /* (non-Javadoc) @@ -58,8 +55,8 @@ public class RemoteSelectionContext extends AbstractSelectionContext implements public String toString() { StringBuffer toString = new StringBuffer(); - if (remoteCtx != null) { - toString.append(remoteCtx.toString()); + if (getContext() != null) { + toString.append(getContext().toString()); } toString.append(toString.length() > 0 ? " " : ""); //$NON-NLS-1$ //$NON-NLS-2$ toString.append(super.toString()); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/interfaces/ISelectionContext.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/interfaces/ISelectionContext.java index 67b4b5549..959510901 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/interfaces/ISelectionContext.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/interfaces/ISelectionContext.java @@ -15,6 +15,13 @@ package org.eclipse.tcf.te.launch.core.selection.interfaces; public interface ISelectionContext { /** + * Returns the context object of the selection. + * + * @return The context object. + */ + public Object getContext(); + + /** * Returns all selected objects within the selected context. * * @param An array containing all selected objects, or <code>null</code>. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF index 6e0156cc3..48b326eb0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF @@ -23,7 +23,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.tcf.te.ui.swt;bundle-version="1.0.0",
org.eclipse.tcf.te.ui.views;bundle-version="1.0.0",
org.eclipse.tcf.te.runtime.concurrent;bundle-version="1.0.0",
- org.eclipse.tcf.te.ui;bundle-version="1.0.0"
+ org.eclipse.tcf.te.ui;bundle-version="1.0.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200",
+ org.eclipse.tcf.te.runtime.statushandler;bundle-version="1.0.0",
+ org.eclipse.tcf.te.core;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
@@ -31,8 +34,15 @@ Export-Package: org.eclipse.tcf.te.launch.ui.activator;x-internal:=true, org.eclipse.tcf.te.launch.ui.help,
org.eclipse.tcf.te.launch.ui.interfaces,
org.eclipse.tcf.te.launch.ui.internal;x-internal:=true,
+ org.eclipse.tcf.te.launch.ui.internal.adapters,
+ org.eclipse.tcf.te.launch.ui.internal.handler,
+ org.eclipse.tcf.te.launch.ui.internal.properties,
+ org.eclipse.tcf.te.launch.ui.internal.viewer,
+ org.eclipse.tcf.te.launch.ui.model,
org.eclipse.tcf.te.launch.ui.nls;x-internal:=true,
+ org.eclipse.tcf.te.launch.ui.properties,
org.eclipse.tcf.te.launch.ui.selection,
org.eclipse.tcf.te.launch.ui.tabs,
+ org.eclipse.tcf.te.launch.ui.tabs.filetransfers,
org.eclipse.tcf.te.launch.ui.tabs.launchcontext,
- org.eclipse.tcf.te.launch.ui.tabs.projects
+ org.eclipse.tcf.te.launch.ui.tabs.refprojects
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/eview16/prop_ps.gif b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/eview16/prop_ps.gif Binary files differnew file mode 100644 index 000000000..d11c996e5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/eview16/prop_ps.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/obj16/root.gif b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/obj16/root.gif Binary files differnew file mode 100644 index 000000000..6b3911b24 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/obj16/root.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/ovr16/redX_ovr.gif b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/ovr16/redX_ovr.gif Binary files differnew file mode 100644 index 000000000..8fa687bb2 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/icons/ovr16/redX_ovr.gif diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties index bc88d7d94..5d48895b7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties @@ -25,3 +25,24 @@ command.attach.description=Attach to the selected Context command.detach.name=Detach Context Command command.detach.description=Detach from the selected Context + +# ***** Editor page Contributions ***** + +LauchEditorPage.name=Launches +LauchEditorPage.column.name=Launch Configurations + +ReferencedProjects.propertyTab.name=Referenced Projects +FileTransfers.propertyTab.name=File Transfers +General.propertyTab.name=General + +# ***** Menu Contributions ***** + +New.menu.name=New +Open.menu.name=Open +OpenAs.menu.name=Open As +Delete.menu.name=Delete +Delete.menu.mnemonic=D +Refresh.menu.name=Refresh +Refresh.menu.mnemonic=f +ShowIn.menu.name=Show In +Properties.menu.name=Properties diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml index 76c0adae0..1bc2f6b36 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml @@ -2,6 +2,297 @@ <?eclipse version="3.4"?>
<plugin>
+<!-- Adapter factory contributions -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.tcf.te.launch.ui.model.LaunchNode"
+ class="org.eclipse.tcf.te.launch.ui.internal.adapters.AdapterFactory">
+ <adapter type="org.eclipse.jface.viewers.ILabelProvider"/>
+ <adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate"/>
+ <adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate"/>
+ </factory>
+ </extension>
+
+<!-- Property tester contributions -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.launch.ui.internal.LaunchNodePropertyTester"
+ id="org.eclipse.tcf.te.launch.ui.propertytester.launchNode"
+ namespace="org.eclipse.tcf.te.launch.ui.model"
+ properties="isLaunchConfig, isLaunchConfigType"
+ type="org.eclipse.tcf.te.launch.ui.model.LaunchNode">
+ </propertyTester>
+ </extension>
+
+<!-- Editor page contributions -->
+ <extension point="org.eclipse.tcf.te.ui.views.editorPages">
+ <editorPage
+ class="org.eclipse.tcf.te.ui.views.editor.pages.TreeViewerExplorerEditorPage:org.eclipse.tcf.te.launch.ui.viewer.launches:Launches"
+ name="%LauchEditorPage.name"
+ id="org.eclipse.tcf.te.launch.ui.LaunchEditorPage">
+ </editorPage>
+ </extension>
+
+<!-- Viewer contributions -->
+ <extension point="org.eclipse.tcf.te.ui.viewers">
+ <viewer
+ id="org.eclipse.tcf.te.launch.ui.viewer.launches"
+ autoExpandLevel="2"
+ contentProvider="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeContentProvider"
+ helpId="org.eclipse.tcf.te.launch.ui.LaunchEditorPage"
+ menuId="org.eclipse.tcf.te.launch.ui.menu.launches">
+ <creation>
+ <style name="SWT.FULL_SELECTION"/>
+ <style name="SWT.SINGLE"/>
+ </creation>
+ </viewer>
+ <columnContribution viewerId="org.eclipse.tcf.te.launch.ui.viewer.launches">
+ <column
+ id="launchConfigurations"
+ labelProvider="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeLabelProvider"
+ name="%LauchEditorPage.column.name"
+ width="400">
+ </column>
+ </columnContribution>
+ </extension>
+
+<!-- Launches menu contributions -->
+ <extension point="org.eclipse.ui.menus">
+
+ <!-- Target explorer launches menu contributions -->
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.new">
+ <menu
+ id="org.eclipse.tcf.te.ui.views.View.menu.new"
+ label="%New.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.navigator.dynamic.new"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.NewLaunchConfigurationContributionItem">
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <or>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfigType"/>
+ </or>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </dynamic>
+ </menu>
+ </menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.launch">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.navigator.dynamic.launch"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.LaunchLaunchConfigurationContributionItem">
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </dynamic>
+ </menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.edit">
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.navigator.menu.open"
+ label="%Open.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.navigator.dynamic.open"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.OpenLaunchConfigurationContributionItem">
+ </dynamic>
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfigType"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </menu>
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.navigator.menu.openAs"
+ label="%OpenAs.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.navigator.dynamic.openAs"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.OpenLaunchConfigurationContributionItem">
+ </dynamic>
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </menu>
+ </menuContribution>
+
+ <!-- Launches editor page menu contributions -->
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.launch.ui.menu.launches">
+ <separator
+ name="group.new"
+ visible="true">
+ </separator>
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.menu.new"
+ label="%New.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.dynamic.new"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.NewLaunchConfigurationContributionItem">
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <or>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfigType"/>
+ </or>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </dynamic>
+ </menu>
+ <separator
+ name="group.showIn"
+ visible="true">
+ </separator>
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.menu.showIn"
+ label="%ShowIn.menu.name">
+ <command
+ commandId="org.eclipse.tcf.te.ui.views.command.ShowInProperties"
+ icon="icons/eview16/prop_ps.gif"
+ label="%Properties.menu.name"
+ style="push">
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <visibleWhen checkEnabled="true"/>
+ </menu>
+ <separator
+ name="group.launch"
+ visible="true">
+ </separator>
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.dynamic.launch"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.LaunchLaunchConfigurationContributionItem">
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </dynamic>
+ <separator
+ name="group.edit"
+ visible="true">
+ </separator>
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.menu.open"
+ label="%Open.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.dynamic.open"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.OpenLaunchConfigurationContributionItem">
+ </dynamic>
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfigType"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </menu>
+ <menu
+ id="org.eclipse.tcf.te.launch.ui.menu.openAs"
+ label="%OpenAs.menu.name">
+ <dynamic
+ id="org.eclipse.tcf.te.launch.ui.dynamic.openAs"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.OpenLaunchConfigurationContributionItem">
+ </dynamic>
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </menu>
+ <separator
+ name="group.delete"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ id="org.eclipse.tcf.te.launch.ui.commands.delete"
+ label="%Delete.menu.name"
+ mnemonic="%Delete.menu.mnemonic"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.ui.views.isDeletableElement"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <separator
+ name="group.refresh"
+ visible="true">
+ </separator>
+ <command
+ commandId="org.eclipse.tcf.te.ui.command.refresh"
+ id="org.eclipse.tcf.te.launch.ui.commands.refresh"
+ label="%Refresh.menu.name"
+ mnemonic="%Refresh.menu.mnemonic"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test property="org.eclipse.tcf.te.ui.views.isRefreshableElement"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
<!-- Command contributions -->
<extension point="org.eclipse.ui.commands">
<command
@@ -9,16 +300,13 @@ description="%command.showInDebugView.description"
helpContextId="org.eclipse.tcf.te.launch.command_ShowInDebugView"
id="org.eclipse.tcf.te.launch.command.showInDebugView"
- name="%command.showInDebugView.name">
- </command>
-
+ name="%command.showInDebugView.name"/>
<command
categoryId="org.eclipse.tcf.te.ui.commands.category"
description="%command.attach.description"
helpContextId="org.eclipse.tcf.te.launch.command_Attach"
id="org.eclipse.tcf.te.launch.command.attach"
name="%command.attach.name"/>
-
<command
categoryId="org.eclipse.tcf.te.ui.commands.category"
description="%command.detach.description"
@@ -27,21 +315,79 @@ name="%command.detach.name"/>
</extension>
+<!-- Command image contributions -->
<extension point="org.eclipse.ui.commandImages">
<image
commandId="org.eclipse.tcf.te.launch.command.showInDebugView"
- icon="platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_view.gif">
- </image>
+ icon="platform:/plugin/org.eclipse.debug.ui/icons/full/eview16/debug_view.gif"/>
<image
commandId="org.eclipse.tcf.te.launch.command.attach"
disabledIcon="icons/dlcl16/attach.gif"
- icon="icons/elcl16/attach.gif">
- </image>
+ icon="icons/elcl16/attach.gif"/>
<image
commandId="org.eclipse.tcf.te.launch.command.detach"
disabledIcon="icons/dlcl16/detach.gif"
- icon="icons/elcl16/detach.gif">
- </image>
+ icon="icons/elcl16/detach.gif"/>
</extension>
+<!-- Handler contributions -->
+ <extension point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.tcf.te.ui.views.handler.ShowInPropertiesHandler"
+ commandId="org.eclipse.tcf.te.ui.views.command.ShowInProperties">
+ <activeWhen>
+ <with variable="activePartId">
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ </with>
+ </activeWhen>
+ </handler>
+ </extension>
+
+<!-- Property tab contributions -->
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs contributorId="org.eclipse.tcf.te.ui">
+ <propertyTab
+ id="org.eclipse.tcf.te.launch.ui.propertytab.refprojects"
+ label="%ReferencedProjects.propertyTab.name"
+ category="org.eclipse.tcf.te"/>
+ <propertyTab
+ id="org.eclipse.tcf.te.launch.ui.propertytab.filetransfers"
+ label="%FileTransfers.propertyTab.name"
+ category="org.eclipse.tcf.te"/>
+ <propertyTab
+ id="org.eclipse.tcf.te.launch.ui.propertytab.general"
+ label="%General.propertyTab.name"
+ category="org.eclipse.tcf.te"/>
+ </propertyTabs>
+ </extension>
+
+<!-- Property section contributions -->
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.eclipse.tcf.te.ui">
+ <propertySection
+ id="org.eclipse.tcf.te.launch.ui.launchconfigtype"
+ class="org.eclipse.tcf.te.launch.ui.internal.properties.LaunchConfigTypePropertiesSection"
+ enablesFor="1"
+ filter="org.eclipse.tcf.te.launch.ui.internal.properties.LaunchConfigTypeFilter"
+ tab="org.eclipse.tcf.te.launch.ui.propertytab.general"/>
+ <propertySection
+ id="org.eclipse.tcf.te.launch.ui.launchcontext"
+ class="org.eclipse.tcf.te.launch.ui.internal.properties.LaunchContextPropertiesSection"
+ enablesFor="1"
+ filter="org.eclipse.tcf.te.launch.ui.internal.properties.LaunchContextFilter"
+ tab="org.eclipse.tcf.te.launch.ui.propertytab.general"/>
+ <propertySection
+ id="org.eclipse.tcf.te.launch.ui.propertysection.refprojetcs"
+ class="org.eclipse.tcf.te.launch.ui.internal.properties.RefProjectsPropertiesSection"
+ enablesFor="1"
+ filter="org.eclipse.tcf.te.launch.ui.internal.properties.RefProjectsFilter"
+ tab="org.eclipse.tcf.te.launch.ui.propertytab.refprojects"/>
+ <propertySection
+ id="org.eclipse.tcf.te.launch.ui.propertysection.filetransfers"
+ class="org.eclipse.tcf.te.launch.ui.internal.properties.FileTransferPropertiesSection"
+ enablesFor="1"
+ filter="org.eclipse.tcf.te.launch.ui.internal.properties.FileTransferFilter"
+ tab="org.eclipse.tcf.te.launch.ui.propertytab.filetransfers"/>
+ </propertySections>
+ </extension>
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java index f61e877f9..db814f47b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java @@ -17,6 +17,7 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.te.launch.ui.internal.ImageConsts;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -71,7 +72,7 @@ public class UIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
- public void start(BundleContext context) throws Exception {
+ public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@@ -80,7 +81,7 @@ public class UIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(BundleContext context) throws Exception {
plugin = null;
traceHandler = null;
super.stop(context);
@@ -98,6 +99,10 @@ public class UIPlugin extends AbstractUIPlugin { url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
registry.put(ImageConsts.ACTION_Refresh_Disabled, ImageDescriptor.createFromURL(url));
}
+ URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "root.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.OBJ_Launches_Root, ImageDescriptor.createFromURL(url));
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "redX_ovr.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.RED_X_OVR, ImageDescriptor.createFromURL(url));
}
/**
@@ -121,4 +126,26 @@ public class UIPlugin extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String key) {
return getDefault().getImageRegistry().getDescriptor(key);
}
+
+ /**
+ * Loads the image given by the specified image descriptor from the image
+ * registry. If the image has been loaded ones before already, the cached
+ * <code>Image</code> object instance is returned. Otherwise, the <code>
+ * Image</code> object instance will be created and cached before returned.
+ *
+ * @param descriptor The image descriptor.
+ * @return The corresponding <code>Image</code> object instance or <code>null</code>.
+ */
+ public static Image getSharedImage(AbstractImageDescriptor descriptor) {
+ ImageRegistry registry = getDefault().getImageRegistry();
+
+ String imageKey = descriptor.getDecriptorKey();
+ Image image = registry.get(imageKey);
+ if (image == null) {
+ registry.put(imageKey, descriptor);
+ image = registry.get(imageKey);
+ }
+
+ return image;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java index 26792aed1..4e49d0f15 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java @@ -20,35 +20,57 @@ public interface ImageConsts { * The root directory where to load the images from, relative to * the bundle directory. */ - public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ - - /** - * The directory where to load colored local toolbar images from, - * relative to the image root directory. - */ - public final static String IMAGE_DIR_CLCL = "clcl16/"; //$NON-NLS-1$ - - /** - * The directory where to load disabled local toolbar images from, - * relative to the image root directory. - */ - public final static String IMAGE_DIR_DLCL = "dlcl16/"; //$NON-NLS-1$ - - /** - * The directory where to load enabled local toolbar images from, - * relative to the image root directory. - */ - public final static String IMAGE_DIR_ELCL = "elcl16/"; //$NON-NLS-1$ - - // ***** The image constants ***** - - /** - * The key to access the refresh action image (enabled). - */ - public static final String ACTION_Refresh_Enabled = "RefreshAction_enabled"; //$NON-NLS-1$ - - /** - * The key to access the refresh action image (disabled). - */ - public static final String ACTION_Refresh_Disabled = "RefreshAction_disabled"; //$NON-NLS-1$ + public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ + + /** + * The directory where to load colored local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_CLCL = "clcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load disabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_DLCL = "dlcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load enabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_ELCL = "elcl16/"; //$NON-NLS-1$ + + /** + * The directory where to load model object images from, relative to the image root directory. + */ + public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$ + + /** + * The directory where to load object overlay images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_OVR = "ovr16/"; //$NON-NLS-1$ + + + // ***** The image constants ***** + + /** + * The key to access the refresh action image (enabled). + */ + public static final String ACTION_Refresh_Enabled = "RefreshAction_enabled"; //$NON-NLS-1$ + + /** + * The key to access the refresh action image (disabled). + */ + public static final String ACTION_Refresh_Disabled = "RefreshAction_disabled"; //$NON-NLS-1$ + + /** + * The key to access the launches tree root image. + */ + public static final String OBJ_Launches_Root = "OBJ_Launches_Root"; //$NON-NLS-1$ + + /** + * The key to access the target object red X overlay image. + */ + public static final String RED_X_OVR = "RedXOverlay"; //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java new file mode 100644 index 000000000..05a63065d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The property tester for a launch tree node. + */ +public class LaunchNodePropertyTester extends PropertyTester { + + /* + * (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ + @Override + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + if (receiver instanceof LaunchNode) { + LaunchNode node = (LaunchNode)receiver; + if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$ + if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) { + boolean isValue = expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier()); + return isValue; + } + } + else if (property.equals("isLaunchConfig")) { //$NON-NLS-1$ + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()); + } + } + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java new file mode 100644 index 000000000..dee7dcabe --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.adapters; + +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeLabelProvider; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate; +import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate; + +/** + * Adapter factory implementation. + */ +public class AdapterFactory implements IAdapterFactory { + // The adapter for ILabelProvider.class + private ILabelProvider labelProvider = new LaunchTreeLabelProvider(); + // The refresh handler delegate adapter + private IRefreshHandlerDelegate refreshDelegate = new RefreshHandlerDelegate(); + // The delete handler delegate adapter + private static IDeleteHandlerDelegate deleteDelegate = new DeleteHandlerDelegate(); + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) + */ + @Override + public Object getAdapter(Object adaptableObject, Class adapterType) { + if (adaptableObject instanceof LaunchNode) { + if (ILabelProvider.class.equals(adapterType)) { + return labelProvider; + } + if (IDeleteHandlerDelegate.class.equals(adapterType) && LaunchNode.TYPE_LAUNCH_CONFIG.equals(((LaunchNode)adaptableObject).getType())) { + return deleteDelegate; + } + if (IRefreshHandlerDelegate.class.equals(adapterType)) { + return refreshDelegate; + } + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() + */ + @Override + public Class[] getAdapterList() { + return new Class<?>[] { + ILabelProvider.class, + IDeleteHandlerDelegate.class, + IRefreshHandlerDelegate.class + }; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java new file mode 100644 index 000000000..0526616ea --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.adapters; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osgi.util.NLS; +import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.launch.ui.nls.Messages; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate; + +/** + * File System tree node delete handler delegate implementation. + */ +public class DeleteHandlerDelegate implements IDeleteHandlerDelegate { + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#canDelete(java.lang.Object) + */ + @Override + public boolean canDelete(Object element) { + if (element instanceof LaunchNode) { + LaunchNode node = (LaunchNode)element; + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && !node.getLaunchConfiguration().isReadOnly(); + } + return false; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#delete(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void delete(Object element, IPropertiesContainer state, final ICallback callback) { + Assert.isNotNull(element); + Assert.isNotNull(state); + + if (element instanceof LaunchNode) { + final LaunchNode node = (LaunchNode)element; + try { + if (MessageDialog.openQuestion( + UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), + Messages.DeleteHandlerDelegate_question_title, NLS.bind(Messages.DeleteHandlerDelegate_question_message, node.getLaunchConfiguration().getName()))) { + node.getLaunchConfiguration().delete(); + if (callback != null) { + callback.done(this, Status.OK_STATUS); + } + } + else { + if (callback != null) { + callback.done(this, Status.CANCEL_STATUS); + } + } + } + catch (Exception e) { + if (callback != null) { + callback.done(this, StatusHelper.getStatus(e)); + } + } + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java new file mode 100644 index 000000000..8165201d5 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.adapters; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.launch.ui.model.LaunchModel; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate; + +/** + * Launch tree node refresh handler delegate implementation. + */ +public class RefreshHandlerDelegate implements IRefreshHandlerDelegate { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate#canRefresh(java.lang.Object) + */ + @Override + public boolean canRefresh(Object element) { + if (element instanceof LaunchNode) { + return true; + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate#refresh(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void refresh(Object element, IPropertiesContainer state, ICallback callback) { + Assert.isNotNull(element); + Assert.isNotNull(state); + + if (canRefresh(element)) { + LaunchNode node = (LaunchNode) element; + LaunchModel model = LaunchModel.getLaunchModel(node.getRootModelNode()); + model.refresh(); + } + if (callback != null) { + callback.done(this, Status.OK_STATUS); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/LaunchLaunchConfigurationContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/LaunchLaunchConfigurationContributionItem.java new file mode 100644 index 000000000..894b18e22 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/LaunchLaunchConfigurationContributionItem.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.internal.handler; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.actions.LaunchAction; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.ui.ISources; +import org.eclipse.ui.actions.CompoundContributionItem; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.menus.IWorkbenchContribution; +import org.eclipse.ui.services.IServiceLocator; + +/** + * LaunchLaunchConfigurationContributionItem + */ +public class LaunchLaunchConfigurationContributionItem extends CompoundContributionItem implements IWorkbenchContribution { + + private boolean enabled = true; + + // Service locator to located the handler service. + private IServiceLocator serviceLocator; + + /** + * Constructor. + */ + public LaunchLaunchConfigurationContributionItem() { + super(); + } + + /** + * Constructor. + * @param id + */ + public LaunchLaunchConfigurationContributionItem(String id) { + super(id); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator) + */ + @Override + public void initialize(IServiceLocator serviceLocator) { + this.serviceLocator = serviceLocator; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.ContributionItem#isEnabled() + */ + @Override + public boolean isEnabled() { + return enabled; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() + */ + @Override + protected IContributionItem[] getContributionItems() { + // Get the selected node. + IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class); + IEvaluationContext state = service.getCurrentState(); + ISelection selection = (ISelection)state.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); + IStructuredSelection iss = (IStructuredSelection)selection; + Object obj = iss.getFirstElement(); + Assert.isTrue(obj instanceof LaunchNode); + LaunchNode node = (LaunchNode) obj; + List<IContributionItem> items = new ArrayList<IContributionItem>(); + if (node.getLaunchConfiguration() != null) { + try { + for (String mode : LaunchConfigHelper.getLaunchConfigTypeModes(node.getLaunchConfigurationType(), false)) { + ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode); + IAction action = new LaunchAction(node.getLaunchConfiguration(), mode); + action.setText(launchMode.getLabel()); + action.setImageDescriptor(DebugUITools.getLaunchGroup(node.getLaunchConfiguration(), mode).getImageDescriptor()); + action.setEnabled(node.isValidFor(mode)); + items.add(new ActionContributionItem(action)); + } + } + catch (Exception e) { + } + } + enabled = !items.isEmpty(); + return items.toArray(new IContributionItem[items.size()]); + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/NewLaunchConfigurationContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/NewLaunchConfigurationContributionItem.java new file mode 100644 index 000000000..0c20586d8 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/NewLaunchConfigurationContributionItem.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.internal.handler; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.ILaunchGroup; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; +import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection; +import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.launch.ui.selection.LaunchSelectionManager; +import org.eclipse.ui.ISources; +import org.eclipse.ui.actions.CompoundContributionItem; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.menus.IWorkbenchContribution; +import org.eclipse.ui.services.IServiceLocator; + +/** + * LaunchLaunchConfigurationContributionItem + */ +public class NewLaunchConfigurationContributionItem extends CompoundContributionItem implements IWorkbenchContribution { + + private boolean enabled = true; + + // Service locator to located the handler service. + private IServiceLocator serviceLocator; + + /** + * Constructor. + */ + public NewLaunchConfigurationContributionItem() { + super(); + } + + /** + * Constructor. + * @param id + */ + public NewLaunchConfigurationContributionItem(String id) { + super(id); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator) + */ + @Override + public void initialize(IServiceLocator serviceLocator) { + this.serviceLocator = serviceLocator; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.ContributionItem#isEnabled() + */ + @Override + public boolean isEnabled() { + return enabled; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() + */ + @Override + protected IContributionItem[] getContributionItems() { + // Get the selected node. + IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class); + IEvaluationContext state = service.getCurrentState(); + ISelection selection = (ISelection)state.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); + IStructuredSelection iss = (IStructuredSelection)selection; + Object obj = iss.getFirstElement(); + Assert.isTrue(obj instanceof LaunchNode); + final LaunchNode node = (LaunchNode) obj; + List<IContributionItem> items = new ArrayList<IContributionItem>(); + final ILaunchConfigurationType type = node.getLaunchConfigurationType(); + if (type != null) { + try { + for (String mode : LaunchConfigHelper.getLaunchConfigTypeModes(type, false)) { + ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(type, mode); + ILaunchSelection sel = LaunchSelectionManager.getInstance().getLaunchSelection(type, mode, LaunchSelectionManager.PART_ID_TE_VIEW); + final ILaunchSpecification launchSpec = delegate.getLaunchSpecification(type.getIdentifier(), sel); + final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(type.newInstance(null, "temp"), mode); //$NON-NLS-1$ + ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode); + IAction action = new Action() { + @Override + public void run() { + try { + ILaunchConfiguration config = LaunchManager.getInstance().createOrUpdateLaunchConfiguration(null, launchSpec); + DebugUITools.openLaunchConfigurationDialogOnGroup( + UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), + new StructuredSelection(config), + launchGroup.getIdentifier()); + } + catch (Exception e) { + e.printStackTrace(); + } + } + }; + action.setText(launchMode.getLabel() + " Configuration"); //$NON-NLS-1$ + action.setImageDescriptor(launchGroup.getImageDescriptor()); + items.add(new ActionContributionItem(action)); + } + } + catch (Exception e) { + } + } + + enabled = !items.isEmpty(); + return items.toArray(new IContributionItem[items.size()]); + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/OpenLaunchConfigurationContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/OpenLaunchConfigurationContributionItem.java new file mode 100644 index 000000000..d9548855b --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/OpenLaunchConfigurationContributionItem.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.internal.handler; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.expressions.IEvaluationContext; +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.ILaunchGroup; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper; +import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.ui.ISources; +import org.eclipse.ui.actions.CompoundContributionItem; +import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.menus.IWorkbenchContribution; +import org.eclipse.ui.services.IServiceLocator; + +/** + * LaunchLaunchConfigurationContributionItem + */ +public class OpenLaunchConfigurationContributionItem extends CompoundContributionItem implements IWorkbenchContribution { + + private boolean enabled = true; + + // Service locator to located the handler service. + private IServiceLocator serviceLocator; + + /** + * Constructor. + */ + public OpenLaunchConfigurationContributionItem() { + super(); + } + + /** + * Constructor. + * @param id + */ + public OpenLaunchConfigurationContributionItem(String id) { + super(id); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator) + */ + @Override + public void initialize(IServiceLocator serviceLocator) { + this.serviceLocator = serviceLocator; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.ContributionItem#isEnabled() + */ + @Override + public boolean isEnabled() { + return enabled; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() + */ + @Override + protected IContributionItem[] getContributionItems() { + // Get the selected node. + IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class); + IEvaluationContext state = service.getCurrentState(); + ISelection selection = (ISelection)state.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); + IStructuredSelection iss = (IStructuredSelection)selection; + Object obj = iss.getFirstElement(); + Assert.isTrue(obj instanceof LaunchNode); + final LaunchNode node = (LaunchNode) obj; + List<IContributionItem> items = new ArrayList<IContributionItem>(); + final ILaunchConfigurationType type = node.getLaunchConfigurationType(); + final ILaunchConfiguration config; + final boolean openConfig; + if (node.getLaunchConfiguration() != null) { + openConfig = true; + config = node.getLaunchConfiguration(); + } + else { + openConfig = false; + ILaunchConfiguration newConfig = null; + try { + newConfig = type.newInstance(null, "temp"); //$NON-NLS-1$ + } + catch (Exception e) { + } + config = newConfig; + } + if (type != null && config != null) { + try { + for (String mode : LaunchConfigHelper.getLaunchConfigTypeModes(type, false)) { + final ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(config, mode); + ILaunchMode launchMode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(mode); + IAction action = new Action() { + @Override + public void run() { + DebugUITools.openLaunchConfigurationDialogOnGroup( + UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), + new StructuredSelection(openConfig ? config : type), + launchGroup.getIdentifier()); + } + }; + action.setText(launchMode.getLabel() + " Configuration" + (openConfig ? "" : "s") + "..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + action.setImageDescriptor(launchGroup.getImageDescriptor()); + items.add(new ActionContributionItem(action)); + } + } + catch (Exception e) { + } + } + + enabled = !items.isEmpty(); + return items.toArray(new IContributionItem[items.size()]); + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java new file mode 100644 index 000000000..09ff00639 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferFilter.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.properties; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttributes; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The filter to filter out non launch configuration nodes. + */ +public class FileTransferFilter implements IFilter { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) + */ + @Override + public boolean select(Object toTest) { + if (toTest instanceof LaunchNode) { + LaunchNode node = (LaunchNode)toTest; + try { + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && + node.getLaunchConfiguration().getAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS, (String)null) != null; + } + catch (Exception e) { + } + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferPropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferPropertiesSection.java new file mode 100644 index 000000000..58ce13632 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/FileTransferPropertiesSection.java @@ -0,0 +1,147 @@ +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.internal.properties;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.launch.ui.properties.BaseTitledSection;
+import org.eclipse.tcf.te.launch.ui.tabs.filetransfers.FileTransferContentProvider;
+import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The property section to display the file transfer property of a launch configuration.
+ */
+public class FileTransferPropertiesSection extends BaseTitledSection {
+
+ protected static class FileTransferLabelProvider extends LabelProvider implements ITableLabelProvider {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return ((IFileTransferItem)element).getHostPath().toOSString();
+ case 1:
+ return (((IFileTransferItem)element).getDirection() == IFileTransferItem.TARGET_TO_HOST ?
+ Messages.FileTransferSection_toHost_text : Messages.FileTransferSection_toTarget_text);
+ case 2:
+ return ((IFileTransferItem)element).getTargetPath().toPortableString();
+ case 3:
+ return ((IFileTransferItem)element).getOptions();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ private IFileTransferItem[] items;
+ // The table control to display the properties.
+ private TableViewer viewer;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ Table table = getWidgetFactory().createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
+ table.setLayoutData(data);
+ TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.FileTransferSection_host_column);
+ column.setWidth(200);
+ column = new TableColumn(table, SWT.CENTER);
+ column.setWidth(30);
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.FileTransferSection_target_column);
+ column.setWidth(200);
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.FileTransferSection_options_column);
+ column.setWidth(100);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ viewer = new TableViewer(table);
+ viewer.setContentProvider(new FileTransferContentProvider());
+ viewer.setLabelProvider(new FileTransferLabelProvider());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ Assert.isTrue(input instanceof LaunchNode);
+ ILaunchConfiguration node = ((LaunchNode)input).getLaunchConfiguration();
+ List<IFileTransferItem> list = new ArrayList<IFileTransferItem>();
+ for (IFileTransferItem item : Arrays.asList(FileTransfersPersistenceDelegate.getFileTransfers(node))) {
+ if (item.isEnabled()) {
+ list.add(item);
+ }
+ }
+ items = list.toArray(new IFileTransferItem[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ viewer.setInput(items);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
+ */
+ @Override
+ protected String getText() {
+ return Messages.FileTransferSection_title;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java new file mode 100644 index 000000000..9a1a31f36 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypeFilter.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.properties; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The filter to filter out non launch configuration nodes. + */ +public class LaunchConfigTypeFilter implements IFilter { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) + */ + @Override + public boolean select(Object toTest) { + if (toTest instanceof LaunchNode) { + LaunchNode node = (LaunchNode)toTest; + try { + return LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType()); + } + catch (Exception e) { + } + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypePropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypePropertiesSection.java new file mode 100644 index 000000000..d5c86142b --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchConfigTypePropertiesSection.java @@ -0,0 +1,74 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.internal.properties;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.launch.ui.properties.BaseTitledSection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The property section to display the properties of a launch configuration.
+ */
+public class LaunchConfigTypePropertiesSection extends BaseTitledSection {
+ private String nameValue = ""; //$NON-NLS-1$
+
+ private Text name;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ name = createTextField(null, Messages.LaunchConfigType_label);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ Assert.isTrue(input instanceof LaunchNode);
+ ILaunchConfigurationType node = ((LaunchNode)input).getLaunchConfigurationType();
+
+ nameValue = node.getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ name.setText(nameValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
+ */
+ @Override
+ protected String getText() {
+ return Messages.LaunchConfigType_title;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java new file mode 100644 index 000000000..62606e928 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextFilter.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.properties; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The filter to filter out non launch configuration nodes. + */ +public class LaunchContextFilter implements IFilter { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) + */ + @Override + public boolean select(Object toTest) { + if (toTest instanceof LaunchNode) { + LaunchNode node = (LaunchNode)toTest; + try { + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && + node.getLaunchConfiguration().getAttribute(ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS, (String)null) != null; + } + catch (Exception e) { + } + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextPropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextPropertiesSection.java new file mode 100644 index 000000000..6a7dd6334 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/LaunchContextPropertiesSection.java @@ -0,0 +1,78 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.internal.properties;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.launch.ui.properties.BaseTitledSection;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The property section to display the properties of a launch configuration.
+ */
+public class LaunchContextPropertiesSection extends BaseTitledSection {
+ private String launchContextValue = ""; //$NON-NLS-1$
+
+ private Text launchContext;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ launchContext = createTextField(null, Messages.ContextSelectorSection_label);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ Assert.isTrue(input instanceof LaunchNode);
+ ILaunchConfiguration node = ((LaunchNode)input).getLaunchConfiguration();
+
+ IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(node);
+ launchContextValue = contexts != null && contexts.length > 0 ? ((ILabelProvider)contexts[0].getAdapter(ILabelProvider.class)).getText(contexts[0]) : ""; //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ launchContext.setText(launchContextValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
+ */
+ @Override
+ protected String getText() {
+ return Messages.ContextSelectorSection_title;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java new file mode 100644 index 000000000..a5db903b7 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsFilter.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.properties; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.tcf.te.launch.core.lm.interfaces.IReferencedProjectLaunchAttributes; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The filter to filter out non launch configuration nodes. + */ +public class RefProjectsFilter implements IFilter { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) + */ + @Override + public boolean select(Object toTest) { + if (toTest instanceof LaunchNode) { + LaunchNode node = (LaunchNode)toTest; + try { + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && + node.getLaunchConfiguration().getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)null) != null; + } + catch (Exception e) { + } + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsPropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsPropertiesSection.java new file mode 100644 index 000000000..7cd85ef09 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/properties/RefProjectsPropertiesSection.java @@ -0,0 +1,132 @@ +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.internal.properties;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
+import org.eclipse.tcf.te.launch.core.persistence.projects.ReferencedProjectsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.launch.ui.properties.BaseTitledSection;
+import org.eclipse.tcf.te.launch.ui.tabs.refprojects.RefProjectsContentProvider;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The property section to display the file transfer property of a launch configuration.
+ */
+public class RefProjectsPropertiesSection extends BaseTitledSection {
+
+ protected static class FileTransferLabelProvider extends LabelProvider implements ITableLabelProvider {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ */
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ */
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ switch (columnIndex) {
+ case 0:
+ return ((IReferencedProjectItem)element).getProjectName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ private IReferencedProjectItem[] items;
+ // The table control to display the properties.
+ private TableViewer viewer;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ Table table = getWidgetFactory().createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
+ table.setLayoutData(data);
+ TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ReferencedProjectsSection_name_column);
+ column.setWidth(200);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ viewer = new TableViewer(table);
+ viewer.setContentProvider(new RefProjectsContentProvider());
+ viewer.setLabelProvider(new FileTransferLabelProvider());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ Assert.isTrue(input instanceof LaunchNode);
+ ILaunchConfiguration node = ((LaunchNode)input).getLaunchConfiguration();
+ List<IReferencedProjectItem> list = new ArrayList<IReferencedProjectItem>();
+ for (IReferencedProjectItem item : Arrays.asList(ReferencedProjectsPersistenceDelegate.getReferencedProjects(node))) {
+ if (item.isEnabled()) {
+ list.add(item);
+ }
+ }
+ items = list.toArray(new IReferencedProjectItem[list.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ viewer.setInput(items);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
+ */
+ @Override
+ protected String getText() {
+ return Messages.ReferencedProjectsSection_title;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java new file mode 100644 index 000000000..4a11a1005 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.viewer; + +import java.util.EventObject; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.ITreeViewerListener; +import org.eclipse.jface.viewers.TreeExpansionEvent; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.tcf.te.launch.ui.model.LaunchModel; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.runtime.events.ChangeEvent; +import org.eclipse.tcf.te.runtime.events.EventManager; +import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.ui.trees.TreeContentProvider; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.navigator.ICommonContentExtensionSite; +import org.eclipse.ui.navigator.ICommonContentProvider; + +/** + * Launches content provider for the common navigator of Target Explorer. + */ +public class LaunchNavigatorContentProvider extends TreeContentProvider implements ICommonContentProvider, ITreeViewerListener, IEventListener { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) + */ + @Override + public Object getParent(Object element) { + if (element instanceof LaunchNode) { + LaunchNode node = (LaunchNode)element; + if (LaunchNode.TYPE_ROOT.equals(node.getType())) { + return node.getRootModelNode(); + } + + if (!isRootNodeVisible() && LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) { + return node.getRootModelNode(); + } + return ((LaunchNode)element).getParent(); + } + return null; + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + super.inputChanged(viewer, oldInput, newInput); + EventManager.getInstance().addEventListener(this, ChangeEvent.class); + this.viewer.addTreeListener(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.tcf.te.ui.trees.TreeContentProvider#dispose() + */ + @Override + public void dispose() { + super.dispose(); + EventManager.getInstance().removeEventListener(this); + this.viewer.removeTreeListener(this); + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) + */ + @Override + public Object[] getChildren(Object element) { + super.getChildren(element); + + if (element instanceof LaunchNode) { + return ((LaunchNode)element).getChildren(); + } + else if (element instanceof IModelNode) { + if (isRootNodeVisible()) { + return new Object[]{LaunchModel.getLaunchModel((IModelNode)element).getRoot()}; + } + return LaunchModel.getLaunchModel((IModelNode)element).getRoot().getChildren(); + } + return NO_ELEMENTS; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) + */ + @Override + public boolean hasChildren(Object element) { + if (element instanceof LaunchNode) { + return ((LaunchNode)element).hasChildren(); + } + else if (element instanceof IModelNode) { + return LaunchModel.getLaunchModel((IModelNode)element).getRoot().hasChildren(); + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite) + */ + @Override + public void init(ICommonContentExtensionSite config) { + Assert.isNotNull(config); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento) + */ + @Override + public void restoreState(IMemento aMemento) { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento) + */ + @Override + public void saveState(IMemento aMemento) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeViewerListener#treeCollapsed(org.eclipse.jface.viewers.TreeExpansionEvent) + */ + @Override + public void treeCollapsed(TreeExpansionEvent event) { + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ITreeViewerListener#treeExpanded(org.eclipse.jface.viewers.TreeExpansionEvent) + */ + @Override + public void treeExpanded(TreeExpansionEvent event) { + } + + /** + * If the root node of the tree is visible. + * + * @return true if it is visible. + */ + protected boolean isRootNodeVisible() { + return true; + } + + @Override + public void eventFired(EventObject event) { + if (event.getSource() instanceof LaunchModel) { + this.viewer.refresh(true); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNodeImageDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNodeImageDescriptor.java new file mode 100644 index 000000000..cbb99c614 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNodeImageDescriptor.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.internal.viewer; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.tcf.te.launch.ui.internal.ImageConsts; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; + +/** + * Launch node image descriptor implementation. + */ +public class LaunchNodeImageDescriptor extends AbstractImageDescriptor { + // the base image to decorate with overlays + private Image baseImage; + // the image size + private Point imageSize; + + // Flags representing the object states to decorate + private boolean isValid; + + /** + * Constructor. + */ + public LaunchNodeImageDescriptor(final ImageRegistry registry, final Image baseImage, final LaunchNode node) { + super(registry); + + this.baseImage = baseImage; + imageSize = new Point(baseImage.getImageData().width, baseImage.getImageData().height); + + // Determine the current object state to decorate + initialize(node); + + // build up the key for the image registry + defineKey(baseImage.hashCode()); + } + + /** + * Initialize the image descriptor from the launch node. + * + * @param node The launch node. Must not be <code>null</code>. + */ + protected void initialize(LaunchNode node) { + Assert.isNotNull(node); + + isValid = node.isValidFor(null); + } + + protected void defineKey(int hashCode) { + String key = "LaunchNodeID:" + //$NON-NLS-1$ + hashCode + ":" + //$NON-NLS-1$ + isValid; + + setDecriptorKey(key); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int) + */ + @Override + protected void drawCompositeImage(int width, int height) { + drawCentered(baseImage, width, height); + + if (!isValid) { + drawBottomRight(ImageConsts.RED_X_OVR); + } + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize() + */ + @Override + protected Point getSize() { + return imageSize; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ide.util.ui.AbstractImageDescriptor#getBaseImage() + */ + @Override + protected Image getBaseImage() { + return baseImage; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeContentProvider.java new file mode 100644 index 000000000..d808b0e49 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeContentProvider.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.viewer; + + +/** + * Launch tree content provider implementation. + */ +public class LaunchTreeContentProvider extends LaunchNavigatorContentProvider { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.launch.ui.controls.LaunchNavigatorContentProvider#isRootNodeVisible() + */ + @Override + protected boolean isRootNodeVisible() { + return false; + } +}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java new file mode 100644 index 000000000..7c534fdb2 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeLabelProvider.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.viewer; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.viewers.ILabelDecorator; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; +import org.eclipse.tcf.te.launch.ui.internal.ImageConsts; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; + +/** + * The label provider for the tree column "launchConfigurations". + */ +public class LaunchTreeLabelProvider extends LabelProvider implements ILabelDecorator { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) + */ + @Override + public String getText(Object element) { + if (element instanceof LaunchNode) { + return ((LaunchNode)element).getName(); + } + else if (element instanceof ILaunchConfigurationType) { + return ((ILaunchConfigurationType)element).getName(); + } + else if (element instanceof ILaunchConfiguration) { + return ((ILaunchConfiguration)element).getName(); + } + return super.getText(element); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) + */ + @Override + public Image getImage(Object element) { + if (element instanceof LaunchNode) { + Image image = null; + LaunchNode node = (LaunchNode)element; + if (LaunchNode.TYPE_ROOT.equals(node.getType())) { + image = UIPlugin.getImage(ImageConsts.OBJ_Launches_Root); + } + else if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) { + image = DebugUITools.getImage(node.getLaunchConfigurationType().getIdentifier()); + } + else if (LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType())) { + try { + image = DebugUITools.getImage(node.getLaunchConfiguration().getType().getIdentifier()); + } + catch (Exception e) { + } + } + if (image != null) { + return decorateImage(image, element); + } + } + return super.getImage(element); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object) + */ + @Override + public Image decorateImage(final Image image, final Object element) { + Image decoratedImage = null; + + if (image != null && element instanceof LaunchNode) { + AbstractImageDescriptor descriptor = new LaunchNodeImageDescriptor(UIPlugin.getDefault().getImageRegistry(), + image, + (LaunchNode)element); + decoratedImage = UIPlugin.getSharedImage(descriptor); + } + + return decoratedImage; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ILabelDecorator#decorateText(java.lang.String, java.lang.Object) + */ + @Override + public String decorateText(final String text, final Object element) { + return text; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeViewerSorter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeViewerSorter.java new file mode 100644 index 000000000..e80133bcb --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchTreeViewerSorter.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.launch.ui.internal.viewer; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; + +/** + * The common sorter for the launch contribution to the target explorer. + */ +public class LaunchTreeViewerSorter extends ViewerSorter { + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, + * java.lang.Object, java.lang.Object) + */ + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + if (e1 instanceof LaunchNode && e2 instanceof LaunchNode) { + return ((LaunchNode)e1).getName().compareTo(((LaunchNode)e2).getName()); + } + return super.compare(viewer, e1, e2); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java new file mode 100644 index 000000000..92692a2ef --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchModel.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationListener; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager; +import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; +import org.eclipse.tcf.te.launch.core.selection.LaunchSelection; +import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext; +import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; +import org.eclipse.tcf.te.runtime.events.ChangeEvent; +import org.eclipse.tcf.te.runtime.events.EventManager; +import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService; + +/** + * LaunchModel + */ +public final class LaunchModel { + + /* default */static final String LAUNCH_MODEL_KEY = UIPlugin.getUniqueIdentifier() + ".launch.root"; //$NON-NLS-1$ + + /** + * Get the file system model of the peer model. If it does not + * exist yet, create a new instance and store it. + * + * @param peerModel The peer model + * @return The file system model connected this peer model. + */ + public static LaunchModel getLaunchModel(final IModelNode modelNode) { + if (modelNode != null) { + IPropertiesAccessService service = ServiceManager.getInstance().getService(modelNode, IPropertiesAccessService.class); + LaunchModel model = service != null ? (LaunchModel)service.getProperty(modelNode, LAUNCH_MODEL_KEY) : (LaunchModel)modelNode.getProperty(LAUNCH_MODEL_KEY); + if (model == null) { + model = new LaunchModel(modelNode); + if (service != null) { + service.setProperty(modelNode, LAUNCH_MODEL_KEY, model); + } + else { + modelNode.setProperty(LAUNCH_MODEL_KEY, model); + } + } + return model; + } + return null; + } + + private final LaunchNode root; + + /** + * Constructor. + */ + private LaunchModel(IModelNode node) { + root = new LaunchNode(node); + refresh(); + DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(new ILaunchConfigurationListener() { + @Override + public void launchConfigurationRemoved(ILaunchConfiguration configuration) { + if (!configuration.isWorkingCopy()) { + if (refresh()) { + EventManager.getInstance().fireEvent(new ChangeEvent(LaunchModel.this, "launchRemoved", null, null)); //$NON-NLS-1$ + } + } + } + @Override + public void launchConfigurationChanged(ILaunchConfiguration configuration) { + if (!configuration.isWorkingCopy()) { + refresh(); + EventManager.getInstance().fireEvent(new ChangeEvent(LaunchModel.this, "launchChanged", null, null)); //$NON-NLS-1$ + } + } + @Override + public void launchConfigurationAdded(ILaunchConfiguration configuration) { + if (!configuration.isWorkingCopy()) { + if (refresh()) { + EventManager.getInstance().fireEvent(new ChangeEvent(LaunchModel.this, "launchAdded", null, null)); //$NON-NLS-1$ + } + } + } + }); + } + + public LaunchNode getRoot() { + return root; + } + + public boolean refresh() { + boolean changed = false; + IModelNode parent = root.getRootModelNode(); + String[] typeIds = LaunchConfigTypeBindingsManager.getInstance().getValidLaunchConfigTypes( + new LaunchSelection(null, new RemoteSelectionContext(parent, true))); + List<IModelNode> typeNodes = new ArrayList<IModelNode>(Arrays.asList(root.getChildren())); + for (String typeId : typeIds) { + ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId); + if (type.isPublic()) { + IModelNode typeNode = find(type, typeNodes); + if (typeNode != null) { + typeNodes.remove(typeNode); + } + else { + typeNode = new LaunchNode(type); + root.add(typeNode); + changed = true; + } + + ILaunchConfiguration[] configs; + try { + configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type); + } + catch (Exception e) { + configs = new ILaunchConfiguration[0]; + } + + List<IModelNode> configNodes = new ArrayList<IModelNode>(Arrays.asList(((IContainerModelNode)typeNode).getChildren())); + for (ILaunchConfiguration config : configs) { + IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(config); + if (parent != null && (contexts == null || Arrays.asList(contexts).contains(parent))) { + IModelNode configNode = find(config, configNodes); + if (configNode != null) { + configNodes.remove(configNode); + } + else { + configNode = new LaunchNode(config); + ((IContainerModelNode)typeNode).add(configNode); + changed = true; + } + } + } + for (IModelNode configToDelete : configNodes) { + ((IContainerModelNode)typeNode).remove(configToDelete, true); + changed = true; + } + } + for (IModelNode typeToDelete : typeNodes) { + root.remove(typeToDelete, true); + changed = true; + } + } + return changed; + } + + private IModelNode find(Object data, List<IModelNode> list) { + for (IModelNode candidate : list) { + if (candidate instanceof LaunchNode) { + if ((data instanceof LaunchNode && ((LaunchNode)candidate).equals(data)) || + (data instanceof ILaunchConfiguration && ((LaunchNode)candidate).equals(new LaunchNode((ILaunchConfiguration)data))) || + (data instanceof ILaunchConfigurationType && ((LaunchNode)candidate).equals(new LaunchNode((ILaunchConfigurationType)data)))) { + return candidate; + } + } + } + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java new file mode 100644 index 000000000..48f8f07eb --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/model/LaunchNode.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.model; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.tcf.te.launch.core.lm.LaunchConfigHelper; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; +import org.eclipse.tcf.te.runtime.model.ContainerModelNode; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; + +/** + * LaunchNode + */ +public class LaunchNode extends ContainerModelNode { + + public static final String TYPE_ROOT = "root"; //$NON-NLS-1$ + public static final String TYPE_LAUNCH_CONFIG_TYPE = "launchConfigType"; //$NON-NLS-1$ + public static final String TYPE_LAUNCH_CONFIG = "launchConfig"; //$NON-NLS-1$ + + private static final String PROPERTY_ROOT_MODEL_NODE = "modelNode"; //$NON-NLS-1$ + + private LaunchNode(String type) { + super(); + setProperty(IModelNode.PROPERTY_TYPE, type); + } + + public LaunchNode(IModelNode modelNode) { + this(TYPE_ROOT); + setProperty(PROPERTY_ROOT_MODEL_NODE, modelNode); + } + + public LaunchNode(ILaunchConfiguration config) { + this(TYPE_LAUNCH_CONFIG); + setProperty(TYPE_LAUNCH_CONFIG, config); + } + + public LaunchNode(ILaunchConfigurationType configType) { + this(TYPE_LAUNCH_CONFIG_TYPE); + setProperty(TYPE_LAUNCH_CONFIG_TYPE, configType); + } + + public String getType() { + return getStringProperty(IModelNode.PROPERTY_TYPE); + } + + public IModelNode getRootModelNode() { + IModelNode node = (IModelNode)getProperty(PROPERTY_ROOT_MODEL_NODE); + if (node == null && getParent() instanceof LaunchNode) { + return ((LaunchNode)getParent()).getRootModelNode(); + } + return node; + } + + public ILaunchConfiguration getLaunchConfiguration() { + if (TYPE_LAUNCH_CONFIG.equals(getType())) { + return (ILaunchConfiguration)getProperty(TYPE_LAUNCH_CONFIG); + } + return null; + } + + public ILaunchConfigurationType getLaunchConfigurationType() { + if (TYPE_LAUNCH_CONFIG.equals(getType())) { + return ((LaunchNode)getParent()).getLaunchConfigurationType(); + } + else if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) { + return (ILaunchConfigurationType)getProperty(TYPE_LAUNCH_CONFIG_TYPE); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.model.ModelNode#getName() + */ + @Override + public String getName() { + if (TYPE_ROOT.equals(getType())) { + return "Launches"; //$NON-NLS-1$ + } + else if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) { + return getLaunchConfigurationType().getName(); + } + else if (TYPE_LAUNCH_CONFIG.equals(getType())) { + return getLaunchConfiguration().getName(); + } + return super.getName(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof LaunchNode && getType() != null && getType().equals(((LaunchNode)obj).getType())) { + if (TYPE_LAUNCH_CONFIG_TYPE.equals(getType())) { + return getLaunchConfigurationType().equals(((LaunchNode)obj).getLaunchConfigurationType()); + } + else if (TYPE_LAUNCH_CONFIG.equals(getType())) { + return getLaunchConfiguration().equals(((LaunchNode)obj).getLaunchConfiguration()); + } + } + return super.equals(obj); + } + + public boolean isValidFor(String mode) { + if (TYPE_LAUNCH_CONFIG.equals(getType())) { + List<String> modes; + if (mode != null && mode.trim().length() > 0) { + modes = new ArrayList<String>(); + modes.add(mode); + } + else { + modes = Arrays.asList(LaunchConfigHelper.getLaunchConfigTypeModes(getLaunchConfigurationType(), false)); + } + for (String m : modes) { + ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(getLaunchConfigurationType(), m); + if (delegate != null) { + try { + delegate.validate(mode, getLaunchConfiguration()); + } + catch (Exception e) { + return false; + } + } + } + } + return true; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java index 53c040533..ffbecc2c6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java @@ -73,9 +73,13 @@ public class Messages extends NLS { public static String ContextSelectorControl_toolbar_refresh_tooltip;
+ public static String LaunchConfigType_title;
+ public static String LaunchConfigType_label;
+
public static String LaunchContextSelectorTab_name;
public static String ContextSelectorSection_title;
+ public static String ContextSelectorSection_label;
public static String RemoteContextSelectorControl_error_noContextSelected_single;
public static String RemoteContextSelectorControl_error_noContextSelected_multi;
@@ -84,14 +88,32 @@ public class Messages extends NLS { public static String ReferencedProjectsSection_title;
public static String ReferencedProjectsSection_description;
- public static String ReferencedProjectsSection_project_column;
+ public static String ReferencedProjectsSection_name_column;
public static String ReferencedProjectsSection_add_button;
public static String ReferencedProjectsSection_delete_button;
public static String ReferencedProjectsSection_up_button;
public static String ReferencedProjectsSection_down_button;
public static String ReferencedProjectsSection_addDialog_message;
- public static String LaunchEditorPage_title;
+ public static String FileTransferTab_name;
+
+ public static String FileTransferSection_title;
+ public static String FileTransferSection_description;
+ public static String FileTransferSection_host_column;
+ public static String FileTransferSection_target_column;
+ public static String FileTransferSection_options_column;
+ public static String FileTransferSection_add_button;
+ public static String FileTransferSection_edit_button;
+ public static String FileTransferSection_delete_button;
+ public static String FileTransferSection_up_button;
+ public static String FileTransferSection_down_button;
+ public static String FileTransferSection_toHost_text;
+ public static String FileTransferSection_toTarget_text;
+ public static String FileTransferSection_toHost_tooltip;
+ public static String FileTransferSection_toTarget_tooltip;
+ public static String LaunchEditorPage_title;
+ public static String DeleteHandlerDelegate_question_title;
+ public static String DeleteHandlerDelegate_question_message;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties index 63f510ad5..927fd462b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties @@ -9,7 +9,11 @@ LaunchContextSelectorTab_name=Main ContextSelectorControl_toolbar_refresh_tooltip=Refresh
+LaunchConfigType_title=Launch Configuration Type
+LaunchConfigType_label=Name:
+
ContextSelectorSection_title=Remote Context
+ContextSelectorSection_label=Name:
RemoteContextSelectorControl_error_noContextSelected_single=Please select a remote context.
RemoteContextSelectorControl_error_noContextSelected_multi=Please select one or more remote contexts.
@@ -18,11 +22,31 @@ ReferencedProjectsTab_name = Referenced Projects ReferencedProjectsSection_title = Referenced Projects
ReferencedProjectsSection_description = Referenced Projects
-ReferencedProjectsSection_project_column = Project
+ReferencedProjectsSection_name_column = Name
ReferencedProjectsSection_add_button = Add
ReferencedProjectsSection_delete_button = Delete
ReferencedProjectsSection_up_button = Up
ReferencedProjectsSection_down_button = Down
ReferencedProjectsSection_addDialog_message = Select projects that should be built before launch.
-LaunchEditorPage_title = Launches
\ No newline at end of file +FileTransferTab_name = File Transfers
+
+FileTransferSection_title = File Transfers
+FileTransferSection_description = File Transfers
+FileTransferSection_host_column = Host
+FileTransferSection_target_column = Target
+FileTransferSection_options_column = Options
+FileTransferSection_add_button = Add
+FileTransferSection_edit_button = Edit
+FileTransferSection_delete_button = Delete
+FileTransferSection_up_button = Up
+FileTransferSection_down_button = Down
+FileTransferSection_toHost_tooltip = Transfer from Target to Host
+FileTransferSection_toTarget_tooltip = Transfer from Host to Target
+FileTransferSection_toHost_text = <<
+FileTransferSection_toTarget_text = >>
+
+LaunchEditorPage_title = Launches
+
+DeleteHandlerDelegate_question_title = Question
+DeleteHandlerDelegate_question_message = Are you sure you want to delete ''{0}''?
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java new file mode 100644 index 000000000..feef64996 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java @@ -0,0 +1,254 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.properties;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.core.interfaces.IViewerInput;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNodeProvider;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The base section that displays a title in a title bar.
+ */
+public abstract class BaseTitledSection extends AbstractPropertySection implements PropertyChangeListener {
+
+ // The main composite used to create the section content.
+ protected Composite composite;
+
+ protected IViewerInput viewerInput;
+
+ // The input node.
+ protected IModelNodeProvider provider;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ if (this.viewerInput != null) {
+ this.viewerInput.removePropertyChangeListener(this);
+ }
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ if (input instanceof IAdaptable) {
+ this.viewerInput = (IViewerInput)((IAdaptable)input).getAdapter(IViewerInput.class);
+ if (this.viewerInput != null) {
+ this.viewerInput.addPropertyChangeListener(this);
+ }
+ }
+ if (this.viewerInput == null && input instanceof IModelNodeProvider) {
+ this.provider = (IModelNodeProvider) input;
+ IModelNode modelNode = this.provider.getModelNode();
+ this.viewerInput = (IViewerInput)modelNode.getAdapter(IViewerInput.class);
+ if (this.viewerInput != null) {
+ this.viewerInput.addPropertyChangeListener(this);
+ }
+ }
+ else {
+ this.provider = null;
+ this.viewerInput = null;
+ }
+ updateInput(provider);
+ }
+
+ /**
+ * Update the input node.
+ *
+ * @param input The input node.
+ */
+ protected void updateInput(IModelNodeProvider input) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeHidden()
+ */
+ @Override
+ public void aboutToBeHidden() {
+ if(this.viewerInput != null) {
+ this.viewerInput.removePropertyChangeListener(this);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ parent.setLayout(new FormLayout());
+
+ Section section = getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR);
+ section.setText(getText());
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, ITabbedPropertyConstants.HMARGIN);
+ data.right = new FormAttachment(100, -ITabbedPropertyConstants.HMARGIN);
+ data.top = new FormAttachment(0, 2 * ITabbedPropertyConstants.VMARGIN);
+ section.setLayoutData(data);
+
+ composite = getWidgetFactory().createComposite(parent);
+ FormLayout layout = new FormLayout();
+ layout.spacing = ITabbedPropertyConstants.HMARGIN;
+ composite.setLayout(layout);
+
+ data = new FormData();
+ data.left = new FormAttachment(0, 2 * ITabbedPropertyConstants.HMARGIN);
+ data.right = new FormAttachment(100, -2 * ITabbedPropertyConstants.HMARGIN);
+ data.top = new FormAttachment(section, ITabbedPropertyConstants.VSPACE);
+ data.bottom = new FormAttachment(100, 0);
+ composite.setLayoutData(data);
+ }
+
+ /**
+ * Create a label for the control using the specified text.
+ *
+ * @param control The control for which the label is created.
+ * @param text The label text.
+ */
+ protected void createLabel(Control control, String text) {
+ CLabel nameLabel = getWidgetFactory().createCLabel(composite, text);
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(control, -ITabbedPropertyConstants.HSPACE);
+ data.top = new FormAttachment(control, 0, SWT.CENTER);
+ nameLabel.setLayoutData(data);
+ }
+
+ /**
+ * Create a text field and a label with the specified label
+ * relative to the specified control.
+ *
+ * @param control The control relative to.
+ * @param label The text of the label.
+ * @return The new text created.
+ */
+ protected Text createTextField(Control control, String label) {
+ Text text = createText(control);
+ createLabel(text, label);
+ return text;
+ }
+
+ /**
+ * Create a wrap text field and a label with the specified label
+ * relative to the specified control.
+ *
+ * @param control The control relative to.
+ * @param label The text of the label.
+ * @return The new wrap text created.
+ */
+ protected Text createWrapTextField(Control control, String label) {
+ Text text = createWrapText(control);
+ createLabel(text, label);
+ return text;
+ }
+
+ /**
+ * Create a text field relative to the specified control.
+ *
+ * @param control The control to layout the new text field.
+ * @return The new text field created.
+ */
+ private Text createText(Control control) {
+ Text text = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
+ data.right = new FormAttachment(100, 0);
+ if (control == null) {
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ }
+ else {
+ data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
+ }
+ text.setLayoutData(data);
+ text.setEditable(false);
+ return text;
+ }
+
+ /**
+ * Create a wrap text field relative to the specified control.
+ *
+ * @param control The control to layout the new wrap text field.
+ * @return The new wrap text field created.
+ */
+ private Text createWrapText(Control control) {
+ Text text = getWidgetFactory().createText(composite, "", SWT.WRAP); //$NON-NLS-1$
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
+ data.right = new FormAttachment(100, 0);
+ if (control == null) {
+ data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
+ }
+ else {
+ data.top = new FormAttachment(control, ITabbedPropertyConstants.VSPACE);
+ }
+ data.width = 200;
+ text.setLayoutData(data);
+ text.setEditable(false);
+ return text;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ composite.layout();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource() == provider) {
+ updateInput(provider);
+ Display display = getPart().getSite().getShell().getDisplay();
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ refresh();
+ }
+ });
+ }
+ }
+
+ /**
+ * Get the text which is used as the title in the title bar of the section.
+ *
+ * @return A text string representing the section.
+ */
+ protected abstract String getText();
+}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/selection/LaunchSelectionManager.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/selection/LaunchSelectionManager.java index cf76b37f8..82aa88606 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/selection/LaunchSelectionManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/selection/LaunchSelectionManager.java @@ -37,6 +37,7 @@ import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext; import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
import org.eclipse.tcf.te.launch.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
import org.eclipse.tcf.te.launch.ui.nls.Messages;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNodeProvider;
@@ -144,7 +145,10 @@ public class LaunchSelectionManager { IModelNode remoteCtx = null;
IModelNode node = null;
- if (sel instanceof IModelNodeProvider) {
+ if (sel instanceof LaunchNode) {
+ node = ((LaunchNode)sel).getRootModelNode();
+ }
+ else if (sel instanceof IModelNodeProvider) {
node = ((IModelNodeProvider)sel).getModelNode();
} else if (sel instanceof IModelNode) {
node = (IModelNode)sel;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java new file mode 100644 index 000000000..b7e252f27 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferSection.java @@ -0,0 +1,551 @@ +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.launch.ui.tabs.filetransfers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
+import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection;
+import org.eclipse.tcf.te.ui.swt.listener.AbstractDecorationCellPaintListener;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * AbstractFileTransferSection
+ */
+public abstract class AbstractFileTransferSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
+
+ protected ControlDecoration controlDecoration;
+ protected IModelNode launchContext = null;
+
+ protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ * @param form
+ * @param parent
+ */
+ public AbstractFileTransferSection(IManagedForm form, Composite parent) {
+ super(form, parent, SWT.NONE, new String[]{
+ Messages.FileTransferSection_add_button,
+ Messages.FileTransferSection_edit_button,
+ Messages.FileTransferSection_delete_button,
+ null,
+ Messages.FileTransferSection_up_button,
+ Messages.FileTransferSection_down_button});
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ IFileTransferItem[] items = FileTransfersPersistenceDelegate.getFileTransfers(configuration);
+ getTablePart().getViewer().setInput(items);
+ if (items != null && items.length > 0) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(items[0]), true);
+ }
+ launchContext = LaunchContextsPersistenceDelegate.getFirstLaunchContext(configuration);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy wc) {
+ FileTransfersPersistenceDelegate.setFileTransfers(wc, (IFileTransferItem[])getTablePart().getViewer().getInput());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration configuration) {
+ return validateInputList();
+ }
+
+ protected abstract boolean validateInputList();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createClient(Section section, FormToolkit toolkit) {
+ Assert.isNotNull(section);
+ Assert.isNotNull(toolkit);
+
+ section.setText(Messages.FileTransferSection_title);
+ section.setDescription(Messages.FileTransferSection_description);
+
+ section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, true));
+
+ Composite client = createClientContainer(section, 2, toolkit);
+ client.setBackground(section.getBackground());
+
+ section.setClient(client);
+
+ createPartControl((Composite)section.getClient(), SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION, 2, toolkit);
+ }
+
+ @Override
+ protected TableViewer createTableViewer(Composite parent, int style) {
+ return new CheckboxTableViewer(new Table(parent, style | SWT.CHECK));
+ }
+
+ @Override
+ protected void configureTableViewer(TableViewer viewer) {
+ super.configureTableViewer(viewer);
+
+ ColumnViewerToolTipSupport.enableFor(viewer);
+
+ final Table table = viewer.getTable();
+
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new FileTransferCheckStateProvider());
+ ((CheckboxTableViewer)viewer).addCheckStateListener(new ICheckStateListener() {
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (event.getElement() instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)event.getElement();
+ item.setProperty(IFileTransferItem.PROPERTY_ENABLED, event.getChecked());
+ getManagedForm().dirtyStateChanged();
+ }
+ }
+ });
+
+ TableViewerColumn tvEnableCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colEnable = tvEnableCol.getColumn();
+ colEnable.setResizable(false);
+ tvEnableCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+ });
+
+ TableViewerColumn tvHostCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colHost = tvHostCol.getColumn();
+ colHost.setText(Messages.FileTransferSection_host_column);
+ colHost.setResizable(true);
+ tvHostCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
+ return invalid.get(IFileTransferItem.PROPERTY_HOST);
+ }
+ String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
+ return host != null ? new Path(host).toOSString() : host;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
+ return host != null ? new Path(host).toOSString() : host;
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableViewerColumn tvDirCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colDir = tvDirCol.getColumn();
+ colDir.setResizable(false);
+ colDir.setAlignment(SWT.CENTER);
+ tvDirCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
+ case IFileTransferItem.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_tooltip;
+ default:
+ return Messages.FileTransferSection_toTarget_tooltip;
+ }
+ }
+ return super.getToolTipText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
+ case IFileTransferItem.TARGET_TO_HOST:
+ return Messages.FileTransferSection_toHost_text;
+ default:
+ return Messages.FileTransferSection_toTarget_text;
+ }
+ }
+ return super.getText(element);
+ }
+ });
+ tvDirCol.setEditingSupport(new EditingSupport(tvDirCol.getViewer()) {
+ @Override
+ protected void setValue(Object element, Object value) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ item.setProperty(IFileTransferItem.PROPERTY_DIRECTION,
+ Boolean.parseBoolean(value.toString()) ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST);
+ getManagedForm().dirtyStateChanged();
+ getViewer().refresh();
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return new Boolean(item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION) != IFileTransferItem.TARGET_TO_HOST);
+ }
+ return null;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return new CheckboxCellEditor();
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+ });
+
+ TableViewerColumn tvTargetCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colTarget = tvTargetCol.getColumn();
+ colTarget.setText(Messages.FileTransferSection_target_column);
+ colTarget.setResizable(true);
+ tvTargetCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ return invalid.get(IFileTransferItem.PROPERTY_TARGET);
+ }
+ String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ return target != null ? new Path(target).toPortableString() : target;
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
+ return target != null ? new Path(target).toPortableString() : target;
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableViewerColumn tvOptionCol = new TableViewerColumn(viewer, SWT.NONE);
+ final TableColumn colOption = tvOptionCol.getColumn();
+ colOption.setText(Messages.FileTransferSection_options_column);
+ colOption.setResizable(true);
+ tvOptionCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public String getToolTipText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)element;
+ return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
+ }
+ return super.getText(element);
+ }
+ });
+
+ TableLayout tableLayout = new TableLayout();
+ tableLayout.addColumnData(new ColumnPixelData(30, true));
+ tableLayout.addColumnData(new ColumnPixelData(200, true));
+ tableLayout.addColumnData(new ColumnPixelData(30, true));
+ tableLayout.addColumnData(new ColumnPixelData(200, true));
+ tableLayout.addColumnData(new ColumnPixelData(100, true));
+ table.setLayout(tableLayout);
+ GridData data = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
+ table.setLayoutData(data);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ table.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int width = table.getSize().x - 4 - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth() - colTarget.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+ colHost.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int colWidth = colHost.getWidth();
+ if (colWidth < 100) {
+ event.doit = false;
+ colHost.setWidth(100);
+ colWidth = 100;
+ }
+ int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colDir.getWidth() - colTarget.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+ colTarget.addListener(SWT.Resize, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ int colWidth = colTarget.getWidth();
+ if (colWidth < 100) {
+ event.doit = false;
+ colTarget.setWidth(100);
+ colWidth = 100;
+ }
+ int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth();
+ colOption.setWidth(Math.max(width, 100));
+ }
+ });
+
+ @SuppressWarnings("unused")
+ AbstractDecorationCellPaintListener cpl = new AbstractDecorationCellPaintListener(table, 1, 3) {
+ @Override
+ protected int getDecorationState(Object data, int columnIndex) {
+ if (data instanceof IFileTransferItem) {
+ IFileTransferItem item = (IFileTransferItem)data;
+ if (item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED)) {
+ Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
+ if (invalid != null) {
+ switch (columnIndex) {
+ case 1:
+ if (invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
+ return STATE_ERROR;
+ }
+ break;
+ case 3:
+ if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
+ return STATE_ERROR;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return STATE_NONE;
+ }
+ };
+
+ viewer.setContentProvider(new FileTransferContentProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ initializeButtonsEnablement();
+ }
+ });
+
+ doCreateControlDecoration(table);
+ configureControlDecoration(getControlDecoration());
+ }
+
+ /**
+ * Creates a new instance of a {@link ControlDecoration} object associated with
+ * the given control. The method is called after the control has been created.
+ *
+ * @param control The control. Must not be <code>null</code>.
+ * @return The control decoration object instance.
+ */
+ public ControlDecoration doCreateControlDecoration(Control control) {
+ Assert.isNotNull(control);
+ controlDecoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
+ return controlDecoration;
+ }
+
+ /**
+ * Returns the control decoration.
+ *
+ * @return The control decoration instance or <code>null</code> if not yet created.
+ */
+ public final ControlDecoration getControlDecoration() {
+ return controlDecoration;
+ }
+
+ /**
+ * Configure the given control decoration.
+ *
+ * @param decoration The control decoration. Must not be <code>null</code>.
+ */
+ protected void configureControlDecoration(ControlDecoration decoration) {
+ Assert.isNotNull(decoration);
+ decoration.setShowOnlyOnFocus(false);
+ }
+
+ /**
+ * Updates the control decoration to represent the given message and message type.
+ * If the message is <code>null</code> or the message type is IMessageProvider.NONE,
+ * no decoration will be shown.
+ *
+ * @param message The message.
+ * @param messageType The message type.
+ */
+ public void updateControlDecoration(String message, int messageType) {
+ if (getControlDecoration() != null) {
+ // The description is the same as the message
+ getControlDecoration().setDescriptionText(message);
+
+ // The icon depends on the message type
+ FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
+
+ // Determine the id of the decoration to show
+ String decorationId = FieldDecorationRegistry.DEC_INFORMATION;
+ if (messageType == IMessageProvider.ERROR) {
+ decorationId = FieldDecorationRegistry.DEC_ERROR;
+ } else if (messageType == IMessageProvider.WARNING) {
+ decorationId = FieldDecorationRegistry.DEC_WARNING;
+ }
+
+ // Get the field decoration
+ FieldDecoration fieldDeco = registry.getFieldDecoration(decorationId);
+ if (fieldDeco != null) {
+ getControlDecoration().setImage(fieldDeco.getImage());
+ }
+
+ if (message == null || messageType == IMessageProvider.NONE) {
+ getControlDecoration().hide();
+ }
+ else {
+ getControlDecoration().show();
+ }
+ }
+ }
+
+ protected List<IFileTransferItem> getInputList() {
+ return new ArrayList<IFileTransferItem>(Arrays.asList((IFileTransferItem[])getTablePart().getViewer().getInput()));
+ }
+
+ protected void setInputList(List<IFileTransferItem> list) {
+ getTablePart().getViewer().setInput(list.toArray(new IFileTransferItem[list.size()]));
+ }
+
+ @Override
+ public void doubleClick(DoubleClickEvent event) {
+ onButtonEditClick();
+ }
+
+ @Override
+ protected void onButtonSelected(Button button) {
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ List<IFileTransferItem> list = getInputList();
+
+ switch (((Integer)button.getData()).intValue()) {
+ case 0: // Add
+ onButtonAddClick();
+ break;
+ case 1: // Edit
+ onButtonEditClick();
+ break;
+ case 2: // Delete
+ list.remove(selIndex);
+ setInputList(list);
+ if (!list.isEmpty()) {
+ ((TableViewer)getTablePart().getViewer()).setSelection(
+ new StructuredSelection(list.get(selIndex < list.size() ? selIndex : list.size()-1)), true);
+ }
+ break;
+ case 4: // Up
+ list.add(selIndex-1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex-1)), true);
+ break;
+ case 5: // Down
+ list.add(selIndex+1, list.remove(selIndex));
+ setInputList(list);
+ ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex+1)), true);
+ break;
+ }
+ validateInputList();
+ getManagedForm().dirtyStateChanged();
+ }
+
+ protected abstract void onButtonAddClick();
+
+ protected abstract void onButtonEditClick();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection#initializeButtonsEnablement()
+ */
+ @Override
+ protected void initializeButtonsEnablement() {
+ ISelection selection = ((TableViewer)getTablePart().getViewer()).getSelection();
+ boolean singleSelection = selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1;
+ int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
+ int count = ((TableViewer)getTablePart().getViewer()).getTable().getItemCount();
+
+ getTablePart().getButton(0).setEnabled(getTablePart().isEnabled());
+ getTablePart().getButton(1).setEnabled(getTablePart().isEnabled() && singleSelection);
+ getTablePart().getButton(2).setEnabled(getTablePart().isEnabled() && singleSelection);
+ getTablePart().getButton(4).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex > 0);
+ getTablePart().getButton(5).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex < count-1);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferTab.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferTab.java new file mode 100644 index 000000000..4130daf0c --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/AbstractFileTransferTab.java @@ -0,0 +1,76 @@ +/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.launch.ui.tabs.filetransfers;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
+import org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * File transfer launch configuration tab implementation.
+ */
+public abstract class AbstractFileTransferTab extends AbstractFormsLaunchConfigurationTab {
+ // References to the tab sub sections
+ private AbstractFileTransferSection section;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (section != null) { section.dispose(); section = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
+ */
+ @Override
+ protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ // Setup the main panel (using the table wrap layout)
+ Composite panel = toolkit.getFormToolkit().createComposite(parent);
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.makeColumnsEqualWidth = true;
+ layout.numColumns = 1;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ panel.setBackground(parent.getBackground());
+
+ section = createFileTransferSection(getManagedForm(), panel);
+ section.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
+ getManagedForm().addPart(section);
+ }
+
+ /**
+ * Create the transfer section.
+ * @param form
+ * @param panel
+ * @return
+ */
+ protected abstract AbstractFileTransferSection createFileTransferSection(IManagedForm form, Composite panel);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ @Override
+ public String getName() {
+ return Messages.FileTransferTab_name;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferCheckStateProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferCheckStateProvider.java new file mode 100644 index 000000000..70e1a2aa4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferCheckStateProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.tabs.filetransfers; + +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem; + +/** + * FileTransferCheckStateProvider + */ +public class FileTransferCheckStateProvider implements ICheckStateProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object) + */ + @Override + public boolean isGrayed(Object element) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object) + */ + @Override + public boolean isChecked(Object element) { + if (element instanceof IFileTransferItem) { + IFileTransferItem item = (IFileTransferItem)element; + return item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED); + } + return false; + } +}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferContentProvider.java new file mode 100644 index 000000000..bd1aa5c9a --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/filetransfers/FileTransferContentProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.tabs.filetransfers; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +public class FileTransferContentProvider implements IStructuredContentProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + @Override + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + viewer.refresh(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + @Override + public Object[] getElements(Object inputElement) { + return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0]; + } +}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsCheckStateProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsCheckStateProvider.java new file mode 100644 index 000000000..16730eb6e --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsCheckStateProvider.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.tabs.refprojects; + +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem; + +/** + * RefProjectsCheckStateProvider + */ +public class RefProjectsCheckStateProvider implements ICheckStateProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICheckStateProvider#isGrayed(java.lang.Object) + */ + @Override + public boolean isGrayed(Object element) { + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.ICheckStateProvider#isChecked(java.lang.Object) + */ + @Override + public boolean isChecked(Object element) { + if (element instanceof IReferencedProjectItem) { + IReferencedProjectItem item = (IReferencedProjectItem)element; + return item.getBooleanProperty(IReferencedProjectItem.PROPERTY_ENABLED); + } + return false; + } +}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsContentProvider.java new file mode 100644 index 000000000..9240be8d9 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsContentProvider.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.launch.ui.tabs.refprojects; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +/** + * RefProjectsContentProvider + */ +public class RefProjectsContentProvider implements IStructuredContentProvider { + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#dispose() + */ + @Override + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + viewer.refresh(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) + */ + @Override + public Object[] getElements(Object inputElement) { + return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0]; + } +}
\ No newline at end of file diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/projects/ReferencedProjectsSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java index 2ce55e296..aac159b06 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/projects/ReferencedProjectsSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjectsSection.java @@ -8,7 +8,7 @@ * Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.launch.ui.tabs.projects;
+package org.eclipse.tcf.te.launch.ui.tabs.refprojects;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,7 +30,6 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -67,9 +66,9 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section;
/**
- * ReferencedProjectsSection
+ * RefProjectsSection
*/
-public class ReferencedProjectsSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
+public class RefProjectsSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
private ControlDecoration controlDecoration;
@@ -80,7 +79,7 @@ public class ReferencedProjectsSection extends AbstractTableSection implements I * @param form
* @param parent
*/
- public ReferencedProjectsSection(IManagedForm form, Composite parent) {
+ public RefProjectsSection(IManagedForm form, Composite parent) {
super(form, parent, SWT.NONE, new String[]{
Messages.ReferencedProjectsSection_add_button,
Messages.ReferencedProjectsSection_delete_button,
@@ -165,20 +164,7 @@ public class ReferencedProjectsSection extends AbstractTableSection implements I final Table table = viewer.getTable();
- ((CheckboxTableViewer)viewer).setCheckStateProvider(new ICheckStateProvider() {
- @Override
- public boolean isGrayed(Object element) {
- return false;
- }
- @Override
- public boolean isChecked(Object element) {
- if (element instanceof IReferencedProjectItem) {
- IReferencedProjectItem item = (IReferencedProjectItem)element;
- return item.getBooleanProperty(IReferencedProjectItem.PROPERTY_ENABLED);
- }
- return false;
- }
- });
+ ((CheckboxTableViewer)viewer).setCheckStateProvider(new RefProjectsCheckStateProvider());
((CheckboxTableViewer)viewer).addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
@@ -202,7 +188,7 @@ public class ReferencedProjectsSection extends AbstractTableSection implements I TableViewerColumn tvProjectCol = new TableViewerColumn(viewer, SWT.NONE);
final TableColumn colProject = tvProjectCol.getColumn();
- colProject.setText(Messages.ReferencedProjectsSection_project_column);
+ colProject.setText(Messages.ReferencedProjectsSection_name_column);
colProject.setResizable(true);
tvProjectCol.setLabelProvider(new ColumnLabelProvider() {
@Override
@@ -268,19 +254,7 @@ public class ReferencedProjectsSection extends AbstractTableSection implements I }
};
- viewer.setContentProvider(new IStructuredContentProvider() {
- @Override
- public void dispose() {
- }
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- viewer.refresh();
- }
- @Override
- public Object[] getElements(Object inputElement) {
- return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0];
- }
- });
+ viewer.setContentProvider(new RefProjectsContentProvider());
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/projects/ReferencedProjetcsTab.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjetcsTab.java index d09b2dd78..e82549e09 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/projects/ReferencedProjetcsTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/refprojects/RefProjetcsTab.java @@ -7,7 +7,7 @@ * Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.launch.ui.tabs.projects;
+package org.eclipse.tcf.te.launch.ui.tabs.refprojects;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
@@ -22,9 +22,9 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout; /**
* Referenced projetcs launch configuration tab implementation.
*/
-public class ReferencedProjetcsTab extends AbstractFormsLaunchConfigurationTab {
+public class RefProjetcsTab extends AbstractFormsLaunchConfigurationTab {
// References to the tab sub sections
- private ReferencedProjectsSection section;
+ private RefProjectsSection section;
/* (non-Javadoc)
* @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#dispose()
@@ -52,7 +52,7 @@ public class ReferencedProjetcsTab extends AbstractFormsLaunchConfigurationTab { panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
panel.setBackground(parent.getBackground());
- section = new ReferencedProjectsSection(getManagedForm(), panel);
+ section = new RefProjectsSection(getManagedForm(), panel);
section.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
getManagedForm().addPart(section);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java index 5a4ef7f81..318ccc3ea 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java @@ -66,4 +66,18 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf public String getOptions() {
return getStringProperty(PROPERTY_OPTIONS);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof IFileTransferItem) {
+ return getHostPath().equals(((IFileTransferItem)obj).getHostPath()) &&
+ getTargetPath().equals(((IFileTransferItem)obj).getTargetPath()) &&
+ getDirection() == ((IFileTransferItem)obj).getDirection() &&
+ getOptions().equals(((IFileTransferItem)obj).getOptions());
+ }
+ return super.equals(obj);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java index f26b29b67..b842a62e4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java @@ -51,6 +51,16 @@ public interface IPropertiesAccessService extends IService { public Object getProperty(Object context, String key);
/**
+ * Set the property with the key with the given value.
+ *
+ * @param context The context to set the property to. Must not be <code>null</code>.
+ * @param key The property key. Must not be <code>null</code>.
+ * @param value The value to set.
+ * @return <code>true</code> if the value was set.
+ */
+ public boolean setProperty(Object context, String key, Object value);
+
+ /**
* Returns the direct parent node of the given context object.
*
* @param context The context to get the parent from. Must not be <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml index 78c065e5a..a1c88bf46 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml @@ -51,6 +51,19 @@ id="org.eclipse.tcf.te.tcf.launch.type.remote.app.stepGroup"
modes="run,debug">
</stepGroup>
+ <enablement>
+ <with variable="context">
+ <or>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.cdt.core.cnature">
+ </test>
+ </adapt>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </or>
+ </with>
+ </enablement>
</launchConfigTypeBinding>
</extension>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java index efb4dfbd3..8359fb62d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/lm/delegates/RemoteAppLaunchManagerDelegate.java @@ -16,7 +16,9 @@ import java.util.List; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.tcf.te.launch.core.exceptions.LaunchServiceException;
import org.eclipse.tcf.te.launch.core.interfaces.IReferencedProjectItem;
import org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate;
import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttributes;
@@ -45,6 +47,11 @@ import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes; @SuppressWarnings("restriction")
public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate {
+ private static final String[] MANDATORY_CONFIG_ATTRIBUTES = new String[] {
+ ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS,
+ IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE
+ };
+
/**
* Constructor.
*/
@@ -52,6 +59,9 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate super();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#initLaunchConfigAttributes(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification)
+ */
@Override
public void initLaunchConfigAttributes(ILaunchConfigurationWorkingCopy wc, ILaunchSpecification launchSpec) {
super.initLaunchConfigAttributes(wc, launchSpec);
@@ -64,12 +74,15 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate }
if (launchSpec.hasAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS)) {
wc.setAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS, (String)launchSpec.getAttribute(IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS).getValue());
- }
- if (launchSpec.hasAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS)) {
- wc.setAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)launchSpec.getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS).getValue());
+ if (launchSpec.hasAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS)) {
+ wc.setAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS, (String)launchSpec.getAttribute(IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS).getValue());
+ }
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#addLaunchSpecAttributes(org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, java.lang.String, org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext)
+ */
@Override
protected ILaunchSpecification addLaunchSpecAttributes(ILaunchSpecification launchSpec, String launchConfigTypeId, ISelectionContext selectionContext) {
launchSpec = super.addLaunchSpecAttributes(launchSpec, launchConfigTypeId, selectionContext);
@@ -119,12 +132,10 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate }
}
- if (added) {
- IReferencedProjectItem project = new ReferencedProjectItem();
- project.setProperty(IReferencedProjectItem.PROPERTY_ENABLED, true);
- project.setProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME, ((IProjectSelectionContext)selectionContext).getProjectCtx().getName());
- projects.add(project);
- }
+ IReferencedProjectItem project = new ReferencedProjectItem();
+ project.setProperty(IReferencedProjectItem.PROPERTY_ENABLED, true);
+ project.setProperty(IReferencedProjectItem.PROPERTY_PROJECT_NAME, ((IProjectSelectionContext)selectionContext).getProjectCtx().getName());
+ projects.add(project);
FileTransfersPersistenceDelegate.setFileTransfers(launchSpec, transfers.toArray(new IFileTransferItem[transfers.size()]));
ReferencedProjectsPersistenceDelegate.setReferencedProjects(launchSpec, projects.toArray(new IReferencedProjectItem[projects.size()]));
@@ -141,4 +152,87 @@ public class RemoteAppLaunchManagerDelegate extends DefaultLaunchManagerDelegate return launchSpec;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#validate(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
+ super.validate(launchMode, launchConfig);
+
+ String missingAttributes = null;
+ for (String attribute : MANDATORY_CONFIG_ATTRIBUTES) {
+ if (!isValidAttribute(attribute, launchConfig, launchMode)) {
+ missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ }
+ }
+ if (missingAttributes != null) {
+ throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#equals(java.lang.String, java.lang.Object, java.lang.Object, org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification, org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
+ */
+ @Override
+ protected int equals(String attributeKey, Object specValue, Object confValue, ILaunchSpecification launchSpec, ILaunchConfiguration launchConfig, String launchMode) {
+
+ if (IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE.equals(attributeKey)) {
+ // get match of object
+ int match = specValue.equals(confValue) ? FULL_MATCH : NO_MATCH;
+ // compare objects in the list when they are not already equal
+ if (match != FULL_MATCH) {
+ IPath confPath = new Path(confValue.toString());
+ IPath specPath = new Path(specValue.toString());
+
+ if (confPath.lastSegment().equals(specPath.lastSegment())) {
+ match = PARTIAL_MATCH;
+ }
+ else {
+ match = NO_MATCH;
+ }
+ }
+ return match;
+ }
+
+ return super.equals(attributeKey, specValue, confValue, launchSpec, launchConfig, launchMode);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#getNumAttributes()
+ */
+ @Override
+ protected int getNumAttributes() {
+ return 5;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.core.lm.delegates.DefaultLaunchManagerDelegate#getAttributeRanking(java.lang.String)
+ */
+ @Override
+ protected int getAttributeRanking(String attributeKey) {
+ if (ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS.equals(attributeKey)) {
+ return getNumAttributes() * 32;
+ }
+ else if (IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE.equals(attributeKey)) {
+ return getNumAttributes() * 16;
+ }
+ else if (IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS.equals(attributeKey)) {
+ return getNumAttributes() * 8;
+ }
+ else if (IFileTransferLaunchAttributes.ATTR_FILE_TRANSFERS.equals(attributeKey)) {
+ return getNumAttributes() * 4;
+ }
+ else if (IReferencedProjectLaunchAttributes.ATTR_REFERENCED_PROJECTS.equals(attributeKey)) {
+ return getNumAttributes() * 2;
+ }
+ else {
+ return 1;
+ }
+ }
+
+ @Override
+ protected int getFullMatchRanking() {
+ return 1;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF index 61f362e17..ce4723a7d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF @@ -26,7 +26,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", org.eclipse.tcf.te.runtime.services;bundle-version="1.0.0",
org.eclipse.tcf.te.tcf.ui;bundle-version="1.0.0",
org.eclipse.ui.navigator;bundle-version="3.5.101",
- org.eclipse.tcf.te.ui.views;bundle-version="1.0.0"
+ org.eclipse.tcf.te.ui.views;bundle-version="1.0.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties index f44373ee2..eed629c8a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.properties @@ -15,3 +15,7 @@ providerName = Eclipse.org - TCF Command.showInDebugView.name=Show In Debug View Command Command.showInDebugView.description=Show the selection in the Debug View. + +LauchTree.name=Launches + +LaunchShortcut.Remote.App.name=Remote Application diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml index ec6161642..313dc3002 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml @@ -2,6 +2,15 @@ <?eclipse version="3.4"?>
<plugin>
+<!-- Adapter factory contributions -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ class=""
+ adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+ </extension>
+
<!-- Launch configuration type contributions -->
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
@@ -11,6 +20,7 @@ </launchConfigurationTypeImage>
</extension>
+<!-- Launch configuration tab group contributions -->
<extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
class="org.eclipse.tcf.te.tcf.launch.ui.remote.app.LaunchConfigurationTabGroup"
@@ -18,13 +28,62 @@ type="org.eclipse.tcf.te.tcf.launch.type.remote.app">
</launchConfigurationTabGroup>
</extension>
+
+ <!-- Launch shortcut contributions -->
+ <extension point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ class="org.eclipse.tcf.te.tcf.launch.ui.remote.app.LaunchShortcut"
+ id="org.eclipse.tcf.te.tcf.launch.ui.launchshortcut.remote.app.run"
+ label="%LaunchShortcut.Remote.App.name"
+ icon="icons/obj16/remote_app.gif"
+ modes="run">
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.tcf.te.launch.core.isValidLaunchConfigType"
+ value="org.eclipse.tcf.te.tcf.launch.type.remote.app"
+ args="run"/>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ </shortcut>
+ <shortcut
+ class="org.eclipse.tcf.te.tcf.launch.ui.remote.app.LaunchShortcut"
+ id="org.eclipse.tcf.te.tcf.launch.ui.launchshortcut.remote.app.debug"
+ label="%LaunchShortcut.Remote.App.name"
+ icon="icons/obj16/remote_app.gif"
+ modes="debug">
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <test
+ property="org.eclipse.tcf.te.launch.core.isValidLaunchConfigType"
+ value="org.eclipse.tcf.te.tcf.launch.type.remote.app"
+ args="debug"/>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ </shortcut>
+ </extension>
<!-- Editor page binding contributions -->
-<!--
<extension point="org.eclipse.tcf.te.ui.views.editorPageBindings">
<editorPageBinding
- id="org.eclispe.tcf.te.tcf.launch.ui.editor.LaunchEditorPage"
- pageId="org.eclipse.tcf.te.launch.ui.editor.LaunchEditorPage"
+ id="org.eclipse.tcf.te.tcf.launch.ui.binding.LaunchEditorPage"
+ pageId="org.eclipse.tcf.te.launch.ui.LaunchEditorPage"
+ insertBefore="org.eclipse.tcf.te.tcf.filesystem.FSExplorerEditorPage"
insertAfter="org.eclipse.tcf.te.tcf.ui.OverviewEditorPage">
<enablement>
<with variable="activeEditorInput">
@@ -33,6 +92,51 @@ </enablement>
</editorPageBinding>
</extension>
--->
+
+<!-- Navigator viewer contributions -->
+ <extension point="org.eclipse.ui.navigator.viewer">
+ <viewerContentBinding viewerId="org.eclipse.tcf.te.ui.views.View">
+ <includes>
+ <contentExtension
+ pattern="org.eclipse.tcf.te.tcf.launch.ui.navigator.*"
+ isRoot="false"/>
+ </includes>
+ </viewerContentBinding>
+ </extension>
+
+<!-- Navigator content contributions -->
+ <extension point="org.eclipse.ui.navigator.navigatorContent">
+ <navigatorContent
+ id="org.eclipse.tcf.te.tcf.launch.ui.navigator.content"
+ name="%LauchTree.name"
+ activeByDefault="false"
+ contentProvider="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchNavigatorContentProvider"
+ labelProvider="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeLabelProvider"
+ priority="normal">
+ <triggerPoints>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </triggerPoints>
+ <possibleChildren>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ </possibleChildren>
+ <commonSorter
+ class="org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeViewerSorter">
+ </commonSorter>
+ </navigatorContent>
+ </extension>
+
+<!-- Property section contributions -->
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.eclipse.tcf.te.ui">
+ <propertySection
+ id="org.eclipse.tcf.te.tcf.launch.ui.propertytab.remote.app"
+ class="org.eclipse.tcf.te.tcf.launch.ui.remote.app.RemoteAppPropertiesSection"
+ enablesFor="1"
+ afterSection="org.eclipse.tcf.te.launch.ui.launchcontext"
+ filter="org.eclipse.tcf.te.tcf.launch.ui.remote.app.RemoteAppFilter"
+ tab="org.eclipse.tcf.te.launch.ui.propertytab.general">
+ </propertySection>
+ </propertySections>
+ </extension>
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/activator/UIPlugin.java index 583427796..ae2e90081 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/activator/UIPlugin.java @@ -66,7 +66,7 @@ public class UIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override
- public void start(BundleContext context) throws Exception {
+ public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@@ -75,7 +75,7 @@ public class UIPlugin extends AbstractUIPlugin { * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
- public void stop(BundleContext context) throws Exception {
+ public void stop(BundleContext context) throws Exception {
plugin = null;
traceHandler = null;
super.stop(context);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java index 795fa4596..f5b1c7be2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java @@ -31,26 +31,8 @@ public class Messages extends NLS { public static String LaunchConfigurationMainTabSection_title;
public static String LaunchConfigurationMainTabSection_processArguments_label;
-
- public static String ProcessImageSelectorControl_label;
- public static String ProcessImageSelectorControl_error_missingProcessImage;
-
- public static String FileTransferTab_name;
-
- public static String FileTransferSection_title;
- public static String FileTransferSection_description;
- public static String FileTransferSection_host_column;
- public static String FileTransferSection_target_column;
- public static String FileTransferSection_options_column;
- public static String FileTransferSection_add_button;
- public static String FileTransferSection_edit_button;
- public static String FileTransferSection_delete_button;
- public static String FileTransferSection_up_button;
- public static String FileTransferSection_down_button;
- public static String FileTransferSection_toHost_text;
- public static String FileTransferSection_toTarget_text;
- public static String FileTransferSection_toHost_tooltip;
- public static String FileTransferSection_toTarget_tooltip;
+ public static String LaunchConfigurationMainTabSection_processImage_label;
+ public static String LaunchConfigurationMainTabSection_error_missingProcessImage;
public static String AddEditFileTransferDialog_add_dialogTitle;
public static String AddEditFileTransferDialog_edit_dialogTitle;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties index 124bfe86b..02e1e8435 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties @@ -4,27 +4,9 @@ #
LaunchConfigurationMainTabSection_title = Process
+LaunchConfigurationMainTabSection_processImage_label = Image:
LaunchConfigurationMainTabSection_processArguments_label = Arguments:
-
-ProcessImageSelectorControl_label = Process Image:
-ProcessImageSelectorControl_error_missingProcessImage = Please select or enter a process image.
-
-FileTransferTab_name = File Transfers
-
-FileTransferSection_title = File Transfers
-FileTransferSection_description = File Transfers
-FileTransferSection_host_column = Host
-FileTransferSection_target_column = Target
-FileTransferSection_options_column = Options
-FileTransferSection_add_button = Add
-FileTransferSection_edit_button = Edit
-FileTransferSection_delete_button = Delete
-FileTransferSection_up_button = Up
-FileTransferSection_down_button = Down
-FileTransferSection_toHost_tooltip = Transfer from Target to Host
-FileTransferSection_toTarget_tooltip = Transfer from Host to Target
-FileTransferSection_toHost_text = <<
-FileTransferSection_toTarget_text = >>
+LaunchConfigurationMainTabSection_error_missingProcessImage = Please select or enter a process image.
AddEditFileTransferDialog_add_dialogTitle = Add
AddEditFileTransferDialog_edit_dialogTitle = Edit
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTab.java index 09dfd282c..86917c815 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTab.java @@ -1,50 +1,50 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab;
-import org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext.ContextSelectorSection;
-import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
-import org.eclipse.ui.forms.IManagedForm;
-
-/**
- * Remote application main launch tab implementation.
- */
-public class LaunchConfigurationMainTab extends AbstractContextSelectorTab {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab#doCreateContextSelectorSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected ContextSelectorSection doCreateContextSelectorSection(IManagedForm form, Composite panel) {
- return new ContextSelectorSection(form, panel);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab#doCreateAdditionalFormContent(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
- */
- @Override
- protected void doCreateAdditionalFormContent(IManagedForm form, Composite parent, CustomFormToolkit toolkit) {
- // Setup the main panel (using the table wrap layout)
- Composite panel = toolkit.getFormToolkit().createComposite(parent);
- GridLayout layout = new GridLayout(1, false);
- panel.setLayout(layout);
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- panel.setBackground(parent.getBackground());
-
- LaunchConfigurationMainTabSection section = new LaunchConfigurationMainTabSection(form, panel);
- section.getSection().setLayoutData(new GridData(GridData.FILL_BOTH));
- form.addPart(section);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab; +import org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext.ContextSelectorSection; +import org.eclipse.tcf.te.ui.forms.CustomFormToolkit; +import org.eclipse.ui.forms.IManagedForm; + +/** + * Remote application main launch tab implementation. + */ +public class LaunchConfigurationMainTab extends AbstractContextSelectorTab { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab#doCreateContextSelectorSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) + */ + @Override + protected ContextSelectorSection doCreateContextSelectorSection(IManagedForm form, Composite panel) { + return new ContextSelectorSection(form, panel); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab#doCreateAdditionalFormContent(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit) + */ + @Override + protected void doCreateAdditionalFormContent(IManagedForm form, Composite parent, CustomFormToolkit toolkit) { + // Setup the main panel (using the table wrap layout) + Composite panel = toolkit.getFormToolkit().createComposite(parent); + GridLayout layout = new GridLayout(1, false); + panel.setLayout(layout); + panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + panel.setBackground(parent.getBackground()); + + LaunchConfigurationMainTabSection section = new LaunchConfigurationMainTabSection(form, panel); + section.getSection().setLayoutData(new GridData(GridData.FILL_BOTH)); + form.addPart(section); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java index 971775257..c4d65d176 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationMainTabSection.java @@ -1,196 +1,196 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
-import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
-import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSOpenFileDialog;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
-import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * Remote application launch configuration main tab section implementation.
- */
-public class LaunchConfigurationMainTabSection extends AbstractSection implements ILaunchConfigurationTabFormPart {
-
- BaseEditBrowseTextControl processImage;
- BaseEditBrowseTextControl processArguments;
- IModelNode firstSelection = null;
-
- /**
- * Constructor.
- *
- * @param form The parent managed form. Must not be <code>null</code>.
- * @param parent The parent composite. Must not be <code>null</code>.
- */
- public LaunchConfigurationMainTabSection(IManagedForm form, Composite parent) {
- super(form, parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
- getSection().setBackground(parent.getBackground());
- createClient(getSection(), form.getToolkit());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
- */
- @Override
- protected void createClient(final Section section, FormToolkit toolkit) {
- Assert.isNotNull(section);
- Assert.isNotNull(toolkit);
-
- // Configure the section
- section.setText(Messages.LaunchConfigurationMainTabSection_title);
- section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false));
-
- // Create the section client
- Composite client = createClientContainer(section, 3, toolkit);
- Assert.isNotNull(client);
- section.setClient(client);
- client.setBackground(section.getBackground());
-
- // Create a toolbar for the section
- createSectionToolbar(section, toolkit);
-
- // Create the section sub controls
- processImage = new BaseEditBrowseTextControl(null) {
- @Override
- protected void onButtonControlSelected() {
- if (firstSelection != null) {
- FSOpenFileDialog dialog = new FSOpenFileDialog(section.getShell());
- dialog.setInput(firstSelection);
- if (dialog.open() == Window.OK) {
- Object candidate = dialog.getFirstResult();
- if (candidate instanceof FSTreeNode) {
- String absPath = ((FSTreeNode) candidate).getLocation();
- if (absPath != null) {
- processImage.setEditFieldControlText(absPath);
- }
- }
- }
- }
- }
- @Override
- public void modifyText(ModifyEvent e) {
- super.modifyText(e);
- getManagedForm().dirtyStateChanged();
- }
- };
- processImage.setEditFieldLabel(Messages.ProcessImageSelectorControl_label);
- processImage.setIsGroup(false);
- processImage.setHideBrowseButton(false);
- processImage.setAdjustBackgroundColor(true);
- processImage.setParentControlIsInnerPanel(true);
- processImage.setFormToolkit(toolkit);
- processImage.setupPanel(client);
- processImage.doCreateControlDecoration(processImage.getEditFieldControl());
-
- processArguments = new BaseEditBrowseTextControl(null) {
- @Override
- public void modifyText(ModifyEvent e) {
- super.modifyText(e);
- getManagedForm().dirtyStateChanged();
- }
- };
- processArguments.setEditFieldLabel(Messages.LaunchConfigurationMainTabSection_processArguments_label);
- processArguments.setIsGroup(false);
- processArguments.setHideBrowseButton(true);
- processArguments.setAdjustBackgroundColor(true);
- processArguments.setParentControlIsInnerPanel(true);
- processArguments.setFormToolkit(toolkit);
- processArguments.setupPanel(client);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
- */
- @Override
- public void initializeFrom(ILaunchConfiguration configuration) {
- Assert.isNotNull(configuration);
-
- if (processImage != null) {
- String image = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, ""); //$NON-NLS-1$
- processImage.setEditFieldControlText(image);
- }
-
- if (processArguments != null) {
- String arguments = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, ""); //$NON-NLS-1$
- processArguments.setEditFieldControlText(arguments);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
- */
- @Override
- public void performApply(ILaunchConfigurationWorkingCopy configuration) {
- Assert.isNotNull(configuration);
-
- if (processImage != null) {
- String image = processImage.getEditFieldControlText();
-
- if (image != null && image.trim().length() > 0) {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, image);
- } else {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
- }
- } else {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
- }
-
- if (processArguments != null) {
- String arguments = processArguments.getEditFieldControlText();
-
- if (arguments != null && arguments.trim().length() > 0) {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, arguments);
- } else {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
- }
- } else {
- DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
- }
- }
-
- @Override
- public boolean isValid(ILaunchConfiguration configuration) {
- firstSelection = null;
- IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(configuration);
- if (contexts != null && contexts.length > 0) {
- firstSelection = contexts[0];
- }
- processImage.getButtonControl().setEnabled(firstSelection != null);
-
- if (processImage.getEditFieldControlText().trim().length() > 0) {
- setMessage(null, IMessageProvider.NONE);
- }
- else {
- setMessage(Messages.ProcessImageSelectorControl_error_missingProcessImage, IMessageProvider.ERROR);
- }
- processImage.updateControlDecoration(getMessage(), getMessageType());
-
- return processImage.getEditFieldControlText().trim().length() > 0;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate; +import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; +import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSOpenFileDialog; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes; +import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; +import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl; +import org.eclipse.tcf.te.ui.forms.parts.AbstractSection; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.widgets.ExpandableComposite; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; + +/** + * Remote application launch configuration main tab section implementation. + */ +public class LaunchConfigurationMainTabSection extends AbstractSection implements ILaunchConfigurationTabFormPart { + + BaseEditBrowseTextControl processImage; + BaseEditBrowseTextControl processArguments; + IModelNode firstSelection = null; + + /** + * Constructor. + * + * @param form The parent managed form. Must not be <code>null</code>. + * @param parent The parent composite. Must not be <code>null</code>. + */ + public LaunchConfigurationMainTabSection(IManagedForm form, Composite parent) { + super(form, parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + getSection().setBackground(parent.getBackground()); + createClient(getSection(), form.getToolkit()); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) + */ + @Override + protected void createClient(final Section section, FormToolkit toolkit) { + Assert.isNotNull(section); + Assert.isNotNull(toolkit); + + // Configure the section + section.setText(Messages.LaunchConfigurationMainTabSection_title); + section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, false)); + + // Create the section client + Composite client = createClientContainer(section, 3, toolkit); + Assert.isNotNull(client); + section.setClient(client); + client.setBackground(section.getBackground()); + + // Create a toolbar for the section + createSectionToolbar(section, toolkit); + + // Create the section sub controls + processImage = new BaseEditBrowseTextControl(null) { + @Override + protected void onButtonControlSelected() { + if (firstSelection != null) { + FSOpenFileDialog dialog = new FSOpenFileDialog(section.getShell()); + dialog.setInput(firstSelection); + if (dialog.open() == Window.OK) { + Object candidate = dialog.getFirstResult(); + if (candidate instanceof FSTreeNode) { + String absPath = ((FSTreeNode) candidate).getLocation(); + if (absPath != null) { + processImage.setEditFieldControlText(absPath); + } + } + } + } + } + @Override + public void modifyText(ModifyEvent e) { + super.modifyText(e); + getManagedForm().dirtyStateChanged(); + } + }; + processImage.setEditFieldLabel(Messages.LaunchConfigurationMainTabSection_processImage_label); + processImage.setIsGroup(false); + processImage.setHideBrowseButton(false); + processImage.setAdjustBackgroundColor(true); + processImage.setParentControlIsInnerPanel(true); + processImage.setFormToolkit(toolkit); + processImage.setupPanel(client); + processImage.doCreateControlDecoration(processImage.getEditFieldControl()); + + processArguments = new BaseEditBrowseTextControl(null) { + @Override + public void modifyText(ModifyEvent e) { + super.modifyText(e); + getManagedForm().dirtyStateChanged(); + } + }; + processArguments.setEditFieldLabel(Messages.LaunchConfigurationMainTabSection_processArguments_label); + processArguments.setIsGroup(false); + processArguments.setHideBrowseButton(true); + processArguments.setAdjustBackgroundColor(true); + processArguments.setParentControlIsInnerPanel(true); + processArguments.setFormToolkit(toolkit); + processArguments.setupPanel(client); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + Assert.isNotNull(configuration); + + if (processImage != null) { + String image = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, ""); //$NON-NLS-1$ + processImage.setEditFieldControlText(image); + } + + if (processArguments != null) { + String arguments = DefaultPersistenceDelegate.getAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, ""); //$NON-NLS-1$ + processArguments.setEditFieldControlText(arguments); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + Assert.isNotNull(configuration); + + if (processImage != null) { + String image = processImage.getEditFieldControlText(); + + if (image != null && image.trim().length() > 0) { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, image); + } else { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null); + } + } else { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null); + } + + if (processArguments != null) { + String arguments = processArguments.getEditFieldControlText(); + + if (arguments != null && arguments.trim().length() > 0) { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, arguments); + } else { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null); + } + } else { + DefaultPersistenceDelegate.setAttribute(configuration, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null); + } + } + + @Override + public boolean isValid(ILaunchConfiguration configuration) { + firstSelection = null; + IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(configuration); + if (contexts != null && contexts.length > 0) { + firstSelection = contexts[0]; + } + processImage.getButtonControl().setEnabled(firstSelection != null); + + if (processImage.getEditFieldControlText().trim().length() > 0) { + setMessage(null, IMessageProvider.NONE); + } + else { + setMessage(Messages.LaunchConfigurationMainTabSection_error_missingProcessImage, IMessageProvider.ERROR); + } + processImage.updateControlDecoration(getMessage(), getMessageType()); + + return processImage.getEditFieldControlText().trim().length() > 0; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java index 2c8907775..3a494fa50 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchConfigurationTabGroup.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchConfigurationTabGroup;
-import org.eclipse.tcf.te.launch.ui.tabs.projects.ReferencedProjetcsTab;
-import org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer.FileTransferTab;
-
-/**
- * Remote application launch configuration tab group implementation.
- */
-public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchContextConfigurationTabGroup#createContextSelectorTab(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.util.List, java.lang.String)
- */
- @Override
- public void createContextSelectorTab(ILaunchConfigurationDialog dialog, List<ILaunchConfigurationTab> tabs, String mode) {
- Assert.isNotNull(tabs);
-
- ILaunchConfigurationTab tab = new LaunchConfigurationMainTab();
- tabs.add(tab);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchContextConfigurationTabGroup#createAdditionalTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.util.List, java.lang.String)
- */
- @Override
- public void createAdditionalTabs(ILaunchConfigurationDialog dialog, List<ILaunchConfigurationTab> tabs, String mode) {
-
- tabs.add(new FileTransferTab());
- tabs.add(new ReferencedProjetcsTab());
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app; + +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.ui.ILaunchConfigurationDialog; +import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchConfigurationTabGroup; +import org.eclipse.tcf.te.launch.ui.tabs.refprojects.RefProjetcsTab; +import org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer.FileTransferTab; + +/** + * Remote application launch configuration tab group implementation. + */ +public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchContextConfigurationTabGroup#createContextSelectorTab(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.util.List, java.lang.String) + */ + @Override + public void createContextSelectorTab(ILaunchConfigurationDialog dialog, List<ILaunchConfigurationTab> tabs, String mode) { + Assert.isNotNull(tabs); + + ILaunchConfigurationTab tab = new LaunchConfigurationMainTab(); + tabs.add(tab); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractLaunchContextConfigurationTabGroup#createAdditionalTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.util.List, java.lang.String) + */ + @Override + public void createAdditionalTabs(ILaunchConfigurationDialog dialog, List<ILaunchConfigurationTab> tabs, String mode) { + + tabs.add(new FileTransferTab()); + tabs.add(new RefProjetcsTab()); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchShortcut.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchShortcut.java new file mode 100644 index 000000000..2ba8721a4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/LaunchShortcut.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.launch.ui.remote.app; + +import org.eclipse.core.resources.IResource; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.ILaunchGroup; +import org.eclipse.debug.ui.ILaunchShortcut2; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchManagerDelegate; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; +import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection; +import org.eclipse.tcf.te.launch.ui.selection.LaunchSelectionManager; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; +import org.eclipse.tcf.te.tcf.launch.ui.activator.UIPlugin; +import org.eclipse.ui.IEditorPart; + +/** + * LaunchShortcut + */ +public class LaunchShortcut implements ILaunchShortcut2 { + + /** + * Constructor. + */ + public LaunchShortcut() { + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String) + */ + @Override + public void launch(ISelection selection, String mode) { + ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(ILaunchTypes.REMOTE_APPLICATION); + try { + ILaunchSelection launchSelection = LaunchSelectionManager.getInstance().getLaunchSelection(launchConfigType, mode, null); + ILaunchManagerDelegate delegate = LaunchManager.getInstance().getLaunchManagerDelegate(launchConfigType, mode); + if (delegate != null && launchSelection != null) { + // create an empty launch configuration specification to initialize all attributes with their default defaults. + ILaunchSpecification launchSpec = delegate.getLaunchSpecification(launchConfigType.getIdentifier(), launchSelection); + // initialize the new launch config. + // ignore validation result of launch spec - init as much attributes as possible + if (launchSpec != null) { + ILaunchConfiguration[] launchConfigs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(launchConfigType); + launchConfigs = delegate.getMatchingLaunchConfigurations(launchSpec, launchConfigs); + + ILaunchConfiguration config = launchConfigs != null && launchConfigs.length > 0 ? launchConfigs[0] : null; + config = LaunchManager.getInstance().createOrUpdateLaunchConfiguration(config, launchSpec); + + ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(config, mode); + DebugUITools.openLaunchConfigurationDialogOnGroup(UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), new StructuredSelection(config), launchGroup.getIdentifier()); + } + } + } + catch (Exception e) { + DebugUITools.openLaunchConfigurationDialogOnGroup(UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), null, null); + } + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String) + */ + @Override + public void launch(IEditorPart editor, String mode) { + launch((ISelection)null, mode); + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.jface.viewers.ISelection) + */ + @Override + public ILaunchConfiguration[] getLaunchConfigurations(ISelection selection) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchConfigurations(org.eclipse.ui.IEditorPart) + */ + @Override + public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.jface.viewers.ISelection) + */ + @Override + public IResource getLaunchableResource(ISelection selection) { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchShortcut2#getLaunchableResource(org.eclipse.ui.IEditorPart) + */ + @Override + public IResource getLaunchableResource(IEditorPart editorpart) { + return null; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java new file mode 100644 index 000000000..5fe9e5d2d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppFilter.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app; + +import org.eclipse.jface.viewers.IFilter; +import org.eclipse.tcf.te.launch.ui.model.LaunchNode; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; + +/** + * The filter to filter out non launch configuration nodes. + */ +public class RemoteAppFilter implements IFilter { + + /* + * (non-Javadoc) + * @see org.eclipse.jface.viewers.IFilter#select(java.lang.Object) + */ + @Override + public boolean select(Object toTest) { + if (toTest instanceof LaunchNode) { + LaunchNode node = (LaunchNode)toTest; + return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && + node.getLaunchConfigurationType().getIdentifier().equals(ILaunchTypes.REMOTE_APPLICATION); + } + return false; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java new file mode 100644 index 000000000..bab79e057 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/RemoteAppPropertiesSection.java @@ -0,0 +1,82 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.launch.ui.remote.app;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.properties.BaseTitledSection;
+import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
+import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * The property section to display the properties of a launch configuration.
+ */
+public class RemoteAppPropertiesSection extends BaseTitledSection {
+ private String processImageValue = ""; //$NON-NLS-1$
+ private String processArgsValue = ""; //$NON-NLS-1$
+
+
+ private Text processImage;
+ private Text processArgs;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
+ */
+ @Override
+ public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+
+ processImage = createTextField(null, Messages.LaunchConfigurationMainTabSection_processImage_label);
+ processArgs = createTextField(processImage, Messages.LaunchConfigurationMainTabSection_processArguments_label);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#setInput(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setInput(IWorkbenchPart part, ISelection selection) {
+ super.setInput(part, selection);
+ Assert.isTrue(selection instanceof IStructuredSelection);
+ Object input = ((IStructuredSelection) selection).getFirstElement();
+ Assert.isTrue(input instanceof LaunchNode);
+ ILaunchConfiguration node = ((LaunchNode)input).getLaunchConfiguration();
+ processImageValue = DefaultPersistenceDelegate.getAttribute(node, IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, ""); //$NON-NLS-1$
+ processArgsValue = DefaultPersistenceDelegate.getAttribute(node, IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, ""); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#refresh()
+ */
+ @Override
+ public void refresh() {
+ processImage.setText(new Path(processImageValue).toPortableString());
+ processArgs.setText(processArgsValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.tabbed.BaseTitledSection#getText()
+ */
+ @Override
+ protected String getText() {
+ return Messages.LaunchConfigurationMainTabSection_title;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java index 271b257f6..5de20945e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/AddEditFileTransferDialog.java @@ -1,296 +1,296 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer;
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem;
-import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSFolderSelectionDialog;
-import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSOpenFileDialog;
-import org.eclipse.tcf.te.tcf.launch.core.filetransfer.FileTransferItemValidator;
-import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-
-/**
- * AddEditFileTransferDialog
- */
-public class AddEditFileTransferDialog extends CustomTitleAreaDialog {
-
- final private IFileTransferItem item;
- final IModelNode launchContext;
-
- private BaseEditBrowseTextControl host;
- private BaseEditBrowseTextControl target;
- private BaseEditBrowseTextControl options;
-
- private Button toTarget;
- private Button toHost;
-
- private boolean modeNew = true;
-
-
- /**
- * Constructor.
- *
- * @param item The file transfer item to edit or <code>null</code> to create a new one.
- * @param shell The shell.
- * @param contextHelpId The context help id.
- */
- public AddEditFileTransferDialog(Shell shell, String contextHelpId, IFileTransferItem item, IModelNode launchContexts) {
- super(shell, contextHelpId);
-
- Assert.isNotNull(item);
-
- this.item = item;
- this.launchContext = launchContexts;
- this.modeNew = item.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- // Set dialog title and default message
- setDialogTitle(modeNew ? Messages.AddEditFileTransferDialog_add_dialogTitle : Messages.AddEditFileTransferDialog_edit_dialogTitle);
- setTitle(modeNew ? Messages.AddEditFileTransferDialog_add_title : Messages.AddEditFileTransferDialog_edit_title);
- setDefaultMessage(modeNew ? Messages.AddEditFileTransferDialog_add_message : Messages.AddEditFileTransferDialog_edit_message, IMessageProvider.INFORMATION);
-
- // Get the parent container composite
- Composite container = (Composite) super.createDialogArea(parent);
-
- // Create the inner panel
- Composite panel = new Composite(container, SWT.NULL);
- GridLayout layout = new GridLayout(2, false);
- layout.marginHeight = 0; layout.marginWidth = 0;
- panel.setLayout(layout);
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- @SuppressWarnings("unused")
- Label spacer = new Label(panel, SWT.NONE);
-
- toTarget = new Button(panel, SWT.RADIO);
- toTarget.setText(Messages.AddEditFileTransferDialog_toTarget_checkbox);
- toTarget.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- validate();
- }
- });
-
- spacer = new Label(panel, SWT.NONE);
-
- toHost = new Button(panel, SWT.RADIO);
- toHost.setText(Messages.AddEditFileTransferDialog_toHost_checkbox);
- toHost.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- validate();
- }
- });
-
- // Create the section sub controls
- host = new BaseEditBrowseTextControl(null) {
- @Override
- protected void onButtonControlSelected() {
- @SuppressWarnings("synthetic-access")
- int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
- if (direction == IFileTransferItem.HOST_TO_TARGET) {
- FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
- fileDialog.setFilterPath(getEditFieldControlText());
- fileDialog.setFileName(getEditFieldControlText());
- String file = fileDialog.open();
- if (file != null) {
- setEditFieldControlText(file);
- }
- }
- else {
- DirectoryDialog directoryDialog = new DirectoryDialog(getShell(), SWT.OPEN);
- directoryDialog.setFilterPath(getEditFieldControlText());
- String directory = directoryDialog.open();
- if (directory != null) {
- setEditFieldControlText(directory);
- }
- }
- }
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
- host.setEditFieldLabel(Messages.AddEditFileTransferDialog_host_label);
- host.setIsGroup(false);
- host.setHideBrowseButton(false);
- host.setAdjustBackgroundColor(true);
- host.setParentControlIsInnerPanel(true);
- host.setupPanel(panel);
- host.doCreateControlDecoration(host.getEditFieldControl());
-
- // Create the section sub controls
- target = new BaseEditBrowseTextControl(null) {
- @Override
- protected void onButtonControlSelected() {
- @SuppressWarnings("synthetic-access")
- int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
- ElementTreeSelectionDialog dialog = direction == IFileTransferItem.HOST_TO_TARGET ? new FSFolderSelectionDialog(getShell()) : new FSOpenFileDialog(getShell());
- dialog.setInput(getEditFieldControlText());
- dialog.setInput(launchContext);
- if (dialog.open() == Window.OK) {
- Object candidate = dialog.getFirstResult();
- if (candidate instanceof FSTreeNode) {
- String absPath = ((FSTreeNode) candidate).getLocation();
- if (absPath != null) {
- setEditFieldControlText(absPath);
- }
- }
- }
- }
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
- target.setEditFieldLabel(Messages.AddEditFileTransferDialog_target_label);
- target.setIsGroup(false);
- target.setHideBrowseButton(false);
- target.setAdjustBackgroundColor(true);
- target.setParentControlIsInnerPanel(true);
- target.setupPanel(panel);
- target.doCreateControlDecoration(target.getEditFieldControl());
-
- spacer = new Label(panel, SWT.NONE);
- spacer = new Label(panel, SWT.NONE);
-
- options = new BaseEditBrowseTextControl(null) {
- @Override
- public void modifyText(ModifyEvent e) {
- validate();
- }
- };
- options.setEditFieldLabel(Messages.AddEditFileTransferDialog_options_label);
- options.setIsGroup(false);
- options.setHideBrowseButton(true);
- options.setHasHistory(false);
- options.setAdjustBackgroundColor(true);
- options.setParentControlIsInnerPanel(true);
- options.setupPanel(panel);
- options.doCreateControlDecoration(target.getEditFieldControl());
-
- applyDialogFont(container);
-
- return container;
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
-
- restoreWidgetValues();
- validate();
-
- return control;
- }
-
- protected void validate() {
- IFileTransferItem wc = new FileTransferItem();
- saveWidgetValues(wc);
- Map<String,String> invalid = FileTransferItemValidator.validate(wc);
- boolean valid = true;
-
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
- host.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_HOST), IMessageProvider.ERROR);
- if (valid) {
- setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_HOST));
- }
- valid = false;
- }
- else {
- host.updateControlDecoration(null, IMessageProvider.NONE);
- }
-
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
- target.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_TARGET), IMessageProvider.ERROR);
- if (valid) {
- setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_TARGET));
- }
- valid = false;
- }
- else {
- target.updateControlDecoration(null, IMessageProvider.NONE);
- }
-
- if (valid) {
- setErrorMessage(null);
- }
-
- getButton(IDialogConstants.OK_ID).setEnabled(valid);
- }
-
- private void saveWidgetValues(IFileTransferItem wc) {
- wc.setProperty(IFileTransferItem.PROPERTY_HOST, new Path(host.getEditFieldControlText()).toPortableString());
- wc.setProperty(IFileTransferItem.PROPERTY_TARGET, new Path(target.getEditFieldControlText()).toPortableString());
- wc.setProperty(IFileTransferItem.PROPERTY_OPTIONS, options.getEditFieldControlText());
-
- int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST;
- wc.setProperty(IFileTransferItem.PROPERTY_DIRECTION, direction);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#restoreWidgetValues()
- */
- @Override
- protected void restoreWidgetValues() {
- String hostPath = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
- host.setEditFieldControlText(hostPath != null ? new Path(hostPath).toOSString() : ""); //$NON-NLS-1$
-
- String targetPath = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- target.setEditFieldControlText(targetPath != null ? new Path(targetPath).toPortableString() : ""); //$NON-NLS-1$
- target.getButtonControl().setEnabled(launchContext != null);
-
- String optionsString = item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
- options.setEditFieldControlText(optionsString != null ? optionsString : ""); //$NON-NLS-1$
-
- int direction = item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION);
- toTarget.setSelection(direction != IFileTransferItem.TARGET_TO_HOST);
- toHost.setSelection(direction == IFileTransferItem.TARGET_TO_HOST);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#saveWidgetValues()
- */
- @Override
- protected void saveWidgetValues() {
- saveWidgetValues(item);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer; + +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem; +import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem; +import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode; +import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSFolderSelectionDialog; +import org.eclipse.tcf.te.tcf.filesystem.ui.dialogs.FSOpenFileDialog; +import org.eclipse.tcf.te.tcf.launch.core.filetransfer.FileTransferItemValidator; +import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages; +import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl; +import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog; +import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; + +/** + * AddEditFileTransferDialog + */ +public class AddEditFileTransferDialog extends CustomTitleAreaDialog { + + final private IFileTransferItem item; + final IModelNode launchContext; + + private BaseEditBrowseTextControl host; + private BaseEditBrowseTextControl target; + private BaseEditBrowseTextControl options; + + private Button toTarget; + private Button toHost; + + private boolean modeNew = true; + + + /** + * Constructor. + * + * @param item The file transfer item to edit or <code>null</code> to create a new one. + * @param shell The shell. + * @param contextHelpId The context help id. + */ + public AddEditFileTransferDialog(Shell shell, String contextHelpId, IFileTransferItem item, IModelNode launchContexts) { + super(shell, contextHelpId); + + Assert.isNotNull(item); + + this.item = item; + this.launchContext = launchContexts; + this.modeNew = item.isEmpty(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea(Composite parent) { + // Set dialog title and default message + setDialogTitle(modeNew ? Messages.AddEditFileTransferDialog_add_dialogTitle : Messages.AddEditFileTransferDialog_edit_dialogTitle); + setTitle(modeNew ? Messages.AddEditFileTransferDialog_add_title : Messages.AddEditFileTransferDialog_edit_title); + setDefaultMessage(modeNew ? Messages.AddEditFileTransferDialog_add_message : Messages.AddEditFileTransferDialog_edit_message, IMessageProvider.INFORMATION); + + // Get the parent container composite + Composite container = (Composite) super.createDialogArea(parent); + + // Create the inner panel + Composite panel = new Composite(container, SWT.NULL); + GridLayout layout = new GridLayout(2, false); + layout.marginHeight = 0; layout.marginWidth = 0; + panel.setLayout(layout); + panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + @SuppressWarnings("unused") + Label spacer = new Label(panel, SWT.NONE); + + toTarget = new Button(panel, SWT.RADIO); + toTarget.setText(Messages.AddEditFileTransferDialog_toTarget_checkbox); + toTarget.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validate(); + } + }); + + spacer = new Label(panel, SWT.NONE); + + toHost = new Button(panel, SWT.RADIO); + toHost.setText(Messages.AddEditFileTransferDialog_toHost_checkbox); + toHost.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validate(); + } + }); + + // Create the section sub controls + host = new BaseEditBrowseTextControl(null) { + @Override + protected void onButtonControlSelected() { + @SuppressWarnings("synthetic-access") + int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST; + if (direction == IFileTransferItem.HOST_TO_TARGET) { + FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); + fileDialog.setFilterPath(getEditFieldControlText()); + fileDialog.setFileName(getEditFieldControlText()); + String file = fileDialog.open(); + if (file != null) { + setEditFieldControlText(file); + } + } + else { + DirectoryDialog directoryDialog = new DirectoryDialog(getShell(), SWT.OPEN); + directoryDialog.setFilterPath(getEditFieldControlText()); + String directory = directoryDialog.open(); + if (directory != null) { + setEditFieldControlText(directory); + } + } + } + @Override + public void modifyText(ModifyEvent e) { + validate(); + } + }; + host.setEditFieldLabel(Messages.AddEditFileTransferDialog_host_label); + host.setIsGroup(false); + host.setHideBrowseButton(false); + host.setAdjustBackgroundColor(true); + host.setParentControlIsInnerPanel(true); + host.setupPanel(panel); + host.doCreateControlDecoration(host.getEditFieldControl()); + + // Create the section sub controls + target = new BaseEditBrowseTextControl(null) { + @Override + protected void onButtonControlSelected() { + @SuppressWarnings("synthetic-access") + int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST; + ElementTreeSelectionDialog dialog = direction == IFileTransferItem.HOST_TO_TARGET ? new FSFolderSelectionDialog(getShell()) : new FSOpenFileDialog(getShell()); + dialog.setInput(getEditFieldControlText()); + dialog.setInput(launchContext); + if (dialog.open() == Window.OK) { + Object candidate = dialog.getFirstResult(); + if (candidate instanceof FSTreeNode) { + String absPath = ((FSTreeNode) candidate).getLocation(); + if (absPath != null) { + setEditFieldControlText(absPath); + } + } + } + } + @Override + public void modifyText(ModifyEvent e) { + validate(); + } + }; + target.setEditFieldLabel(Messages.AddEditFileTransferDialog_target_label); + target.setIsGroup(false); + target.setHideBrowseButton(false); + target.setAdjustBackgroundColor(true); + target.setParentControlIsInnerPanel(true); + target.setupPanel(panel); + target.doCreateControlDecoration(target.getEditFieldControl()); + + spacer = new Label(panel, SWT.NONE); + spacer = new Label(panel, SWT.NONE); + + options = new BaseEditBrowseTextControl(null) { + @Override + public void modifyText(ModifyEvent e) { + validate(); + } + }; + options.setEditFieldLabel(Messages.AddEditFileTransferDialog_options_label); + options.setIsGroup(false); + options.setHideBrowseButton(true); + options.setHasHistory(false); + options.setAdjustBackgroundColor(true); + options.setParentControlIsInnerPanel(true); + options.setupPanel(panel); + options.doCreateControlDecoration(target.getEditFieldControl()); + + applyDialogFont(container); + + return container; + } + + @Override + protected Control createContents(Composite parent) { + Control control = super.createContents(parent); + + restoreWidgetValues(); + validate(); + + return control; + } + + protected void validate() { + IFileTransferItem wc = new FileTransferItem(); + saveWidgetValues(wc); + Map<String,String> invalid = FileTransferItemValidator.validate(wc); + boolean valid = true; + + if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) { + host.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_HOST), IMessageProvider.ERROR); + if (valid) { + setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_HOST)); + } + valid = false; + } + else { + host.updateControlDecoration(null, IMessageProvider.NONE); + } + + if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) { + target.updateControlDecoration(invalid.get(IFileTransferItem.PROPERTY_TARGET), IMessageProvider.ERROR); + if (valid) { + setErrorMessage(invalid.get(IFileTransferItem.PROPERTY_TARGET)); + } + valid = false; + } + else { + target.updateControlDecoration(null, IMessageProvider.NONE); + } + + if (valid) { + setErrorMessage(null); + } + + getButton(IDialogConstants.OK_ID).setEnabled(valid); + } + + private void saveWidgetValues(IFileTransferItem wc) { + wc.setProperty(IFileTransferItem.PROPERTY_HOST, new Path(host.getEditFieldControlText()).toPortableString()); + wc.setProperty(IFileTransferItem.PROPERTY_TARGET, new Path(target.getEditFieldControlText()).toPortableString()); + wc.setProperty(IFileTransferItem.PROPERTY_OPTIONS, options.getEditFieldControlText()); + + int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST; + wc.setProperty(IFileTransferItem.PROPERTY_DIRECTION, direction); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#restoreWidgetValues() + */ + @Override + protected void restoreWidgetValues() { + String hostPath = item.getStringProperty(IFileTransferItem.PROPERTY_HOST); + host.setEditFieldControlText(hostPath != null ? new Path(hostPath).toOSString() : ""); //$NON-NLS-1$ + + String targetPath = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET); + target.setEditFieldControlText(targetPath != null ? new Path(targetPath).toPortableString() : ""); //$NON-NLS-1$ + target.getButtonControl().setEnabled(launchContext != null); + + String optionsString = item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS); + options.setEditFieldControlText(optionsString != null ? optionsString : ""); //$NON-NLS-1$ + + int direction = item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION); + toTarget.setSelection(direction != IFileTransferItem.TARGET_TO_HOST); + toHost.setSelection(direction == IFileTransferItem.TARGET_TO_HOST); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#saveWidgetValues() + */ + @Override + protected void saveWidgetValues() { + saveWidgetValues(item); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java index c177e3ddb..d9e65e802 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferSection.java @@ -1,619 +1,89 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.fieldassist.ControlDecoration;
-import org.eclipse.jface.fieldassist.FieldDecoration;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxCellEditor;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
-import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
-import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem;
-import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
-import org.eclipse.tcf.te.tcf.launch.core.filetransfer.FileTransferItemValidator;
-import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection;
-import org.eclipse.tcf.te.ui.swt.listener.AbstractDecorationCellPaintListener;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * FileTransferSection
- */
-public class FileTransferSection extends AbstractTableSection implements ILaunchConfigurationTabFormPart {
-
- private ControlDecoration controlDecoration;
- private IModelNode launchContext = null;
-
- protected static final String PROPERTY_VALIDATION_RESULT = "validation_result.transient"; //$NON-NLS-1$
-
- /**
- * Constructor.
- * @param form
- * @param parent
- */
- public FileTransferSection(IManagedForm form, Composite parent) {
- super(form, parent, SWT.NONE, new String[]{
- Messages.FileTransferSection_add_button,
- Messages.FileTransferSection_edit_button,
- Messages.FileTransferSection_delete_button,
- null,
- Messages.FileTransferSection_up_button,
- Messages.FileTransferSection_down_button});
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
- */
- @Override
- public void initializeFrom(ILaunchConfiguration configuration) {
- IFileTransferItem[] items = FileTransfersPersistenceDelegate.getFileTransfers(configuration);
- getTablePart().getViewer().setInput(items);
- if (items != null && items.length > 0) {
- ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(items[0]), true);
- }
- launchContext = LaunchContextsPersistenceDelegate.getFirstLaunchContext(configuration);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
- */
- @Override
- public void performApply(ILaunchConfigurationWorkingCopy wc) {
- FileTransfersPersistenceDelegate.setFileTransfers(wc, (IFileTransferItem[])getTablePart().getViewer().getInput());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration)
- */
- @Override
- public boolean isValid(ILaunchConfiguration configuration) {
- return validateInputList();
- }
-
- private boolean validateInputList() {
- List<IFileTransferItem> list = getInputList();
- boolean valid = true;
- for (IFileTransferItem item : list) {
- Map<String,String> invalid = item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED) ? FileTransferItemValidator.validate(item) : null;
- item.setProperty(PROPERTY_VALIDATION_RESULT, invalid);
- if (valid && invalid != null) {
- valid = false;
- setMessage(invalid.get(invalid.keySet().toArray()[0]), IMessageProvider.ERROR);
- }
- }
- return valid;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
- */
- @Override
- protected void createClient(Section section, FormToolkit toolkit) {
- Assert.isNotNull(section);
- Assert.isNotNull(toolkit);
-
- section.setText(Messages.FileTransferSection_title);
- section.setDescription(Messages.FileTransferSection_description);
-
- section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL, SWT.CENTER, true, true));
-
- Composite client = createClientContainer(section, 2, toolkit);
- client.setBackground(section.getBackground());
-
- section.setClient(client);
-
- createPartControl((Composite)section.getClient(), SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION, 2, toolkit);
- }
-
- @Override
- protected TableViewer createTableViewer(Composite parent, int style) {
- return new CheckboxTableViewer(new Table(parent, style | SWT.CHECK));
- }
-
- @Override
- protected void configureTableViewer(TableViewer viewer) {
- super.configureTableViewer(viewer);
-
- ColumnViewerToolTipSupport.enableFor(viewer);
-
- final Table table = viewer.getTable();
-
- ((CheckboxTableViewer)viewer).setCheckStateProvider(new ICheckStateProvider() {
- @Override
- public boolean isGrayed(Object element) {
- return false;
- }
- @Override
- public boolean isChecked(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- return item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED);
- }
- return false;
- }
- });
- ((CheckboxTableViewer)viewer).addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- if (event.getElement() instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)event.getElement();
- item.setProperty(IFileTransferItem.PROPERTY_ENABLED, event.getChecked());
- getManagedForm().dirtyStateChanged();
- }
- }
- });
-
- TableViewerColumn tvEnableCol = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn colEnable = tvEnableCol.getColumn();
- colEnable.setResizable(false);
- tvEnableCol.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- return null;
- }
- });
-
- TableViewerColumn tvHostCol = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn colHost = tvHostCol.getColumn();
- colHost.setText(Messages.FileTransferSection_host_column);
- colHost.setResizable(true);
- tvHostCol.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getToolTipText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
- return invalid.get(IFileTransferItem.PROPERTY_HOST);
- }
- String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
- return host != null ? new Path(host).toOSString() : host;
- }
- return super.getText(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- String host = item.getStringProperty(IFileTransferItem.PROPERTY_HOST);
- return host != null ? new Path(host).toOSString() : host;
- }
- return super.getText(element);
- }
- });
-
- TableViewerColumn tvDirCol = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn colDir = tvDirCol.getColumn();
- colDir.setResizable(false);
- colDir.setAlignment(SWT.CENTER);
- tvDirCol.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getToolTipText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
- case IFileTransferItem.TARGET_TO_HOST:
- return Messages.FileTransferSection_toHost_tooltip;
- default:
- return Messages.FileTransferSection_toTarget_tooltip;
- }
- }
- return super.getToolTipText(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- switch (item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION)) {
- case IFileTransferItem.TARGET_TO_HOST:
- return Messages.FileTransferSection_toHost_text;
- default:
- return Messages.FileTransferSection_toTarget_text;
- }
- }
- return super.getText(element);
- }
- });
- tvDirCol.setEditingSupport(new EditingSupport(tvDirCol.getViewer()) {
- @Override
- protected void setValue(Object element, Object value) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- item.setProperty(IFileTransferItem.PROPERTY_DIRECTION,
- Boolean.parseBoolean(value.toString()) ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST);
- getManagedForm().dirtyStateChanged();
- getViewer().refresh();
- }
- }
-
- @Override
- protected Object getValue(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- return new Boolean(item.getIntProperty(IFileTransferItem.PROPERTY_DIRECTION) != IFileTransferItem.TARGET_TO_HOST);
- }
- return null;
- }
-
- @Override
- protected CellEditor getCellEditor(Object element) {
- return new CheckboxCellEditor();
- }
-
- @Override
- protected boolean canEdit(Object element) {
- return true;
- }
- });
-
- TableViewerColumn tvTargetCol = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn colTarget = tvTargetCol.getColumn();
- colTarget.setText(Messages.FileTransferSection_target_column);
- colTarget.setResizable(true);
- tvTargetCol.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getToolTipText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
- if (invalid != null && invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
- return invalid.get(IFileTransferItem.PROPERTY_TARGET);
- }
- String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- return target != null ? new Path(target).toPortableString() : target;
- }
- return super.getText(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- String target = item.getStringProperty(IFileTransferItem.PROPERTY_TARGET);
- return target != null ? new Path(target).toPortableString() : target;
- }
- return super.getText(element);
- }
- });
-
- TableViewerColumn tvOptionCol = new TableViewerColumn(viewer, SWT.NONE);
- final TableColumn colOption = tvOptionCol.getColumn();
- colOption.setText(Messages.FileTransferSection_options_column);
- colOption.setResizable(true);
- tvOptionCol.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getToolTipText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
- }
- return super.getText(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)element;
- return item.getStringProperty(IFileTransferItem.PROPERTY_OPTIONS);
- }
- return super.getText(element);
- }
- });
-
- TableLayout tableLayout = new TableLayout();
- tableLayout.addColumnData(new ColumnPixelData(30, true));
- tableLayout.addColumnData(new ColumnPixelData(200, true));
- tableLayout.addColumnData(new ColumnPixelData(30, true));
- tableLayout.addColumnData(new ColumnPixelData(200, true));
- tableLayout.addColumnData(new ColumnPixelData(100, true));
- table.setLayout(tableLayout);
- GridData data = new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING);
- table.setLayoutData(data);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- table.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int width = table.getSize().x - 4 - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth() - colTarget.getWidth();
- colOption.setWidth(Math.max(width, 100));
- }
- });
- colHost.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int colWidth = colHost.getWidth();
- if (colWidth < 100) {
- event.doit = false;
- colHost.setWidth(100);
- colWidth = 100;
- }
- int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colDir.getWidth() - colTarget.getWidth();
- colOption.setWidth(Math.max(width, 100));
- }
- });
- colTarget.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int colWidth = colTarget.getWidth();
- if (colWidth < 100) {
- event.doit = false;
- colTarget.setWidth(100);
- colWidth = 100;
- }
- int width = table.getSize().x - 4 - colWidth - colEnable.getWidth() - colHost.getWidth() - colDir.getWidth();
- colOption.setWidth(Math.max(width, 100));
- }
- });
-
- @SuppressWarnings("unused")
- AbstractDecorationCellPaintListener cpl = new AbstractDecorationCellPaintListener(table, 1, 3) {
- @Override
- protected int getDecorationState(Object data, int columnIndex) {
- if (data instanceof IFileTransferItem) {
- IFileTransferItem item = (IFileTransferItem)data;
- if (item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED)) {
- Map<String,String> invalid = (Map<String,String>)item.getProperty(PROPERTY_VALIDATION_RESULT);
- if (invalid != null) {
- switch (columnIndex) {
- case 1:
- if (invalid.containsKey(IFileTransferItem.PROPERTY_HOST)) {
- return STATE_ERROR;
- }
- break;
- case 3:
- if (invalid.containsKey(IFileTransferItem.PROPERTY_TARGET)) {
- return STATE_ERROR;
- }
- break;
- }
- }
- }
- }
- return STATE_NONE;
- }
- };
-
- viewer.setContentProvider(new IStructuredContentProvider() {
- @Override
- public void dispose() {
- }
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- viewer.refresh();
- }
- @Override
- public Object[] getElements(Object inputElement) {
- return inputElement instanceof Object[] ? (Object[])inputElement : new Object[0];
- }
- });
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- initializeButtonsEnablement();
- }
- });
-
- doCreateControlDecoration(table);
- configureControlDecoration(getControlDecoration());
- }
-
- /**
- * Creates a new instance of a {@link ControlDecoration} object associated with
- * the given control. The method is called after the control has been created.
- *
- * @param control The control. Must not be <code>null</code>.
- * @return The control decoration object instance.
- */
- public ControlDecoration doCreateControlDecoration(Control control) {
- Assert.isNotNull(control);
- controlDecoration = new ControlDecoration(control, SWT.TOP | SWT.LEFT);
- return controlDecoration;
- }
-
- /**
- * Returns the control decoration.
- *
- * @return The control decoration instance or <code>null</code> if not yet created.
- */
- public final ControlDecoration getControlDecoration() {
- return controlDecoration;
- }
-
- /**
- * Configure the given control decoration.
- *
- * @param decoration The control decoration. Must not be <code>null</code>.
- */
- protected void configureControlDecoration(ControlDecoration decoration) {
- Assert.isNotNull(decoration);
- decoration.setShowOnlyOnFocus(false);
- }
-
- /**
- * Updates the control decoration to represent the given message and message type.
- * If the message is <code>null</code> or the message type is IMessageProvider.NONE,
- * no decoration will be shown.
- *
- * @param message The message.
- * @param messageType The message type.
- */
- public void updateControlDecoration(String message, int messageType) {
- if (getControlDecoration() != null) {
- // The description is the same as the message
- getControlDecoration().setDescriptionText(message);
-
- // The icon depends on the message type
- FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
-
- // Determine the id of the decoration to show
- String decorationId = FieldDecorationRegistry.DEC_INFORMATION;
- if (messageType == IMessageProvider.ERROR) {
- decorationId = FieldDecorationRegistry.DEC_ERROR;
- } else if (messageType == IMessageProvider.WARNING) {
- decorationId = FieldDecorationRegistry.DEC_WARNING;
- }
-
- // Get the field decoration
- FieldDecoration fieldDeco = registry.getFieldDecoration(decorationId);
- if (fieldDeco != null) {
- getControlDecoration().setImage(fieldDeco.getImage());
- }
-
- if (message == null || messageType == IMessageProvider.NONE) {
- getControlDecoration().hide();
- }
- else {
- getControlDecoration().show();
- }
- }
- }
-
- private List<IFileTransferItem> getInputList() {
- return new ArrayList<IFileTransferItem>(Arrays.asList((IFileTransferItem[])getTablePart().getViewer().getInput()));
- }
-
- private void setInputList(List<IFileTransferItem> list) {
- getTablePart().getViewer().setInput(list.toArray(new IFileTransferItem[list.size()]));
- }
-
- @Override
- public void doubleClick(DoubleClickEvent event) {
- onButtonEditClick();
- }
-
- @Override
- protected void onButtonSelected(Button button) {
- int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
- List<IFileTransferItem> list = getInputList();
-
- switch (((Integer)button.getData()).intValue()) {
- case 0: // Add
- onButtonAddClick();
- break;
- case 1: // Edit
- onButtonEditClick();
- break;
- case 2: // Delete
- list.remove(selIndex);
- setInputList(list);
- if (!list.isEmpty()) {
- ((TableViewer)getTablePart().getViewer()).setSelection(
- new StructuredSelection(list.get(selIndex < list.size() ? selIndex : list.size()-1)), true);
- }
- break;
- case 4: // Up
- list.add(selIndex-1, list.remove(selIndex));
- setInputList(list);
- ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex-1)), true);
- break;
- case 5: // Down
- list.add(selIndex+1, list.remove(selIndex));
- setInputList(list);
- ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(list.get(selIndex+1)), true);
- break;
- }
- validateInputList();
- getManagedForm().dirtyStateChanged();
- }
-
- private void onButtonAddClick() {
- int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
- List<IFileTransferItem> list = getInputList();
- IFileTransferItem item = new FileTransferItem();
- AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext);
- if (dialog.open() == Window.OK) {
- item.setProperty(IFileTransferItem.PROPERTY_ENABLED, true);
- list.add(selIndex != -1 ? selIndex : 0, item);
- setInputList(list);
- ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true);
- }
- }
-
- private void onButtonEditClick() {
- int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
-
- if (selIndex >= 0) {
- List<IFileTransferItem> list = getInputList();
- IFileTransferItem item = list.get(selIndex);
-
- AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext);
- if (dialog.open() == Window.OK) {
- list.set(selIndex, item);
- setInputList(list);
- ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.forms.parts.AbstractTableSection#initializeButtonsEnablement()
- */
- @Override
- protected void initializeButtonsEnablement() {
- ISelection selection = ((TableViewer)getTablePart().getViewer()).getSelection();
- boolean singleSelection = selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1;
- int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex();
- int count = ((TableViewer)getTablePart().getViewer()).getTable().getItemCount();
-
- getTablePart().getButton(0).setEnabled(getTablePart().isEnabled());
- getTablePart().getButton(1).setEnabled(getTablePart().isEnabled() && singleSelection);
- getTablePart().getButton(2).setEnabled(getTablePart().isEnabled() && singleSelection);
- getTablePart().getButton(4).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex > 0);
- getTablePart().getButton(5).setEnabled(getTablePart().isEnabled() && singleSelection && selIndex < count-1);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer; + +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection; +import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem; +import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem; +import org.eclipse.tcf.te.tcf.launch.core.filetransfer.FileTransferItemValidator; +import org.eclipse.ui.forms.IManagedForm; + +/** + * FileTransferSection + */ +public class FileTransferSection extends AbstractFileTransferSection { + + /** + * Constructor. + * @param form + * @param parent + */ + public FileTransferSection(IManagedForm form, Composite parent) { + super(form, parent); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection#validateInputList() + */ + @Override + protected boolean validateInputList() { + List<IFileTransferItem> list = getInputList(); + boolean valid = true; + for (IFileTransferItem item : list) { + Map<String,String> invalid = item.getBooleanProperty(IFileTransferItem.PROPERTY_ENABLED) ? FileTransferItemValidator.validate(item) : null; + item.setProperty(PROPERTY_VALIDATION_RESULT, invalid); + if (valid && invalid != null) { + valid = false; + setMessage(invalid.get(invalid.keySet().toArray()[0]), IMessageProvider.ERROR); + } + } + return valid; + } + + @Override + protected void onButtonAddClick() { + int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex(); + List<IFileTransferItem> list = getInputList(); + IFileTransferItem item = new FileTransferItem(); + AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext); + if (dialog.open() == Window.OK) { + item.setProperty(IFileTransferItem.PROPERTY_ENABLED, true); + list.add(selIndex != -1 ? selIndex : 0, item); + setInputList(list); + ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true); + } + } + + @Override + protected void onButtonEditClick() { + int selIndex = ((TableViewer)getTablePart().getViewer()).getTable().getSelectionIndex(); + + if (selIndex >= 0) { + List<IFileTransferItem> list = getInputList(); + IFileTransferItem item = list.get(selIndex); + + AddEditFileTransferDialog dialog = new AddEditFileTransferDialog(getSection().getShell(), null, item, launchContext); + if (dialog.open() == Window.OK) { + list.set(selIndex, item); + setInputList(list); + ((TableViewer)getTablePart().getViewer()).setSelection(new StructuredSelection(item), true); + } + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java index 44dcd4c76..d5a4e3528 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/filetransfer/FileTransferTab.java @@ -1,67 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab;
-import org.eclipse.tcf.te.tcf.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
-/**
- * File transfer launch configuration tab implementation.
- */
-public class FileTransferTab extends AbstractFormsLaunchConfigurationTab {
- // References to the tab sub sections
- private FileTransferSection section;
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#dispose()
- */
- @Override
- public void dispose() {
- if (section != null) { section.dispose(); section = null; }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
- */
- @Override
- protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
- Assert.isNotNull(parent);
- Assert.isNotNull(toolkit);
-
- // Setup the main panel (using the table wrap layout)
- Composite panel = toolkit.getFormToolkit().createComposite(parent);
- TableWrapLayout layout = new TableWrapLayout();
- layout.makeColumnsEqualWidth = true;
- layout.numColumns = 1;
- panel.setLayout(layout);
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- panel.setBackground(parent.getBackground());
-
- section = new FileTransferSection(getManagedForm(), panel);
- section.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
- getManagedForm().addPart(section);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
- */
- @Override
- public String getName() {
- return Messages.FileTransferTab_name;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app.filetransfer; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection; +import org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferTab; +import org.eclipse.ui.forms.IManagedForm; + +/** + * File transfer launch configuration tab implementation. + */ +public class FileTransferTab extends AbstractFileTransferTab { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferTab#createFileTransferSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) + */ + @Override + protected AbstractFileTransferSection createFileTransferSection(IManagedForm form, Composite panel) { + return new FileTransferSection(getManagedForm(), panel); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorControl.java index 74796aaa9..c0b49b183 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorControl.java @@ -1,86 +1,86 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext;
-
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.viewers.DecoratingLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl;
-import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
-import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IRoot;
-import org.eclipse.tcf.te.ui.views.internal.ViewRoot;
-
-/**
- * Locator model launch context selector control.
- */
-@SuppressWarnings("restriction")
-public class ContextSelectorControl extends AbstractContextSelectorControl {
-
- protected static class ContentProvider extends ContentProviderDelegate {
- private ITreeContentProvider catContentProvider = new org.eclipse.tcf.te.ui.views.navigator.ContentProviderDelegate();
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof IRoot) {
- return catContentProvider.getElements(inputElement);
- }
- return super.getElements(inputElement);
- }
- }
-
- protected static class LabelProvider extends LabelProviderDelegate {
- private ILabelProvider catLabelProvider = new org.eclipse.tcf.te.ui.views.navigator.LabelProviderDelegate();
- @Override
- public String getText(Object element) {
- if (element instanceof ICategory) {
- return catLabelProvider.getText(element);
- }
- return super.getText(element);
- }
- @Override
- public Image getImage(Object element) {
- if (element instanceof ICategory) {
- return catLabelProvider.getImage(element);
- }
- return super.getImage(element);
- }
- }
-
- /**
- * Constructor.
- * @param parentPage
- */
- public ContextSelectorControl(IDialogPage parentPage) {
- super(parentPage);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#getInitialViewerInput()
- */
- @Override
- protected Object getInitialViewerInput() {
- return ViewRoot.getInstance();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#doConfigureTreeContentAndLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- @Override
- protected void doConfigureTreeContentAndLabelProvider(TreeViewer viewer) {
- viewer.setContentProvider(new ContentProvider());
- LabelProvider labelProvider = new LabelProvider();
- viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ + +package org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext; + +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.DecoratingLabelProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl; +import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate; +import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate; +import org.eclipse.tcf.te.ui.views.interfaces.ICategory; +import org.eclipse.tcf.te.ui.views.interfaces.IRoot; +import org.eclipse.tcf.te.ui.views.internal.ViewRoot; + +/** + * Locator model launch context selector control. + */ +@SuppressWarnings("restriction") +public class ContextSelectorControl extends AbstractContextSelectorControl { + + protected static class ContentProvider extends ContentProviderDelegate { + private ITreeContentProvider catContentProvider = new org.eclipse.tcf.te.ui.views.navigator.ContentProviderDelegate(); + @Override + public Object[] getElements(Object inputElement) { + if (inputElement instanceof IRoot) { + return catContentProvider.getElements(inputElement); + } + return super.getElements(inputElement); + } + } + + protected static class LabelProvider extends LabelProviderDelegate { + private ILabelProvider catLabelProvider = new org.eclipse.tcf.te.ui.views.navigator.LabelProviderDelegate(); + @Override + public String getText(Object element) { + if (element instanceof ICategory) { + return catLabelProvider.getText(element); + } + return super.getText(element); + } + @Override + public Image getImage(Object element) { + if (element instanceof ICategory) { + return catLabelProvider.getImage(element); + } + return super.getImage(element); + } + } + + /** + * Constructor. + * @param parentPage + */ + public ContextSelectorControl(IDialogPage parentPage) { + super(parentPage); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#getInitialViewerInput() + */ + @Override + protected Object getInitialViewerInput() { + return ViewRoot.getInstance(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#doConfigureTreeContentAndLabelProvider(org.eclipse.jface.viewers.TreeViewer) + */ + @Override + protected void doConfigureTreeContentAndLabelProvider(TreeViewer viewer) { + viewer.setContentProvider(new ContentProvider()); + LabelProvider labelProvider = new LabelProvider(); + viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider)); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorSection.java index 98d225feb..e635b6170 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/remote/app/launchcontext/ContextSelectorSection.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl;
-import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection;
-import org.eclipse.ui.forms.IManagedForm;
-
-/**
- * Locator model context selector section implementation.
- */
-public class ContextSelectorSection extends AbstractContextSelectorSection {
-
- /**
- * Constructor.
- * @param form The managed form.
- * @param parent The parent composite.
- */
- public ContextSelectorSection(IManagedForm form, Composite parent) {
- super(form, parent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection#doCreateContextSelector()
- */
- @Override
- protected AbstractContextSelectorControl doCreateContextSelector() {
- return new ContextSelectorControl(null) {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#onCheckStateChanged(java.lang.Object, boolean)
- */
- @Override
- protected void onCheckStateChanged(Object element, boolean checked) {
- super.onCheckStateChanged(element, checked);
- getManagedForm().dirtyStateChanged();
- }
- };
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tcf.launch.ui.remote.app.launchcontext; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl; +import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection; +import org.eclipse.ui.forms.IManagedForm; + +/** + * Locator model context selector section implementation. + */ +public class ContextSelectorSection extends AbstractContextSelectorSection { + + /** + * Constructor. + * @param form The managed form. + * @param parent The parent composite. + */ + public ContextSelectorSection(IManagedForm form, Composite parent) { + super(form, parent); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection#doCreateContextSelector() + */ + @Override + protected AbstractContextSelectorControl doCreateContextSelector() { + return new ContextSelectorControl(null) { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#onCheckStateChanged(java.lang.Object, boolean) + */ + @Override + protected void onCheckStateChanged(Object element, boolean checked) { + super.onCheckStateChanged(element, checked); + getManagedForm().dirtyStateChanged(); + } + }; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java index e8a96f61c..e3800cccf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java @@ -12,6 +12,7 @@ package org.eclipse.tcf.te.tcf.locator.internal.services; import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
@@ -59,8 +60,12 @@ public class PropertiesAccessService extends AbstractService implements IPropert }
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
}
return !result.isEmpty() ? Collections.unmodifiableMap(result) : null;
@@ -85,11 +90,45 @@ public class PropertiesAccessService extends AbstractService implements IPropert }
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
}
- return value.get();
+ return value.get();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService#setProperty(java.lang.Object, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public boolean setProperty(final Object context, final String key, final Object value) {
+ Assert.isNotNull(context);
+ Assert.isNotNull(key);
+
+ final AtomicBoolean result = new AtomicBoolean();
+ if (context instanceof IPeerModel) {
+ final IPeerModel peerModel = (IPeerModel) context;
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ result.set(peerModel.setProperty(key, value));
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+ }
+
+ return result.get();
}
/* (non-Javadoc)
@@ -110,10 +149,14 @@ public class PropertiesAccessService extends AbstractService implements IPropert }
};
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
}
- return value.get();
+ return value.get();
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java index 3ffd81a65..20e8ba53f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java @@ -33,7 +33,7 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester if ("hasApplicableEditorBindings".equals(property)) { //$NON-NLS-1$ // Create a fake editor input object IEditorInput input = new EditorInput(receiver); - return expectedValue.equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0)); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0)); } if ("isRefreshableElement".equals(property)) { //$NON-NLS-1$ @@ -47,18 +47,22 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester refreshable = delegate != null; } - return expectedValue.equals(Boolean.valueOf(refreshable)); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(refreshable)); } if ("canRefresh".equals(property)) { //$NON-NLS-1$ // Test if the receiver can be refreshed IRefreshHandlerDelegate delegate = receiver instanceof IRefreshHandlerDelegate ? (IRefreshHandlerDelegate)receiver : null; - if (delegate == null) delegate = (IRefreshHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IRefreshHandlerDelegate.class.getName()); + if (delegate == null) { + delegate = (IRefreshHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IRefreshHandlerDelegate.class.getName()); + } boolean canRefresh = false; - if (delegate != null) canRefresh = delegate.canRefresh(receiver); + if (delegate != null) { + canRefresh = delegate.canRefresh(receiver); + } - return expectedValue.equals(Boolean.valueOf(canRefresh)); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(canRefresh)); } @@ -73,18 +77,22 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester deletable = delegate != null; } - return expectedValue.equals(Boolean.valueOf(deletable)); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(deletable)); } if ("canDelete".equals(property)) { //$NON-NLS-1$ // Test if the receiver can be deleted IDeleteHandlerDelegate delegate = receiver instanceof IDeleteHandlerDelegate ? (IDeleteHandlerDelegate)receiver : null; - if (delegate == null) delegate = (IDeleteHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IDeleteHandlerDelegate.class.getName()); + if (delegate == null) { + delegate = (IDeleteHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IDeleteHandlerDelegate.class.getName()); + } boolean canDelete = false; - if (delegate != null) canDelete = delegate.canDelete(receiver); + if (delegate != null) { + canDelete = delegate.canDelete(receiver); + } - return expectedValue.equals(Boolean.valueOf(canDelete)); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(canDelete)); } // ***** Categories related properties ***** @@ -96,17 +104,17 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester if ("isMyTargets".equals(property) && receiver instanceof ICategory) { //$NON-NLS-1$ String id = ((ICategory)receiver).getId(); - return expectedValue.equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_MY_TARGETS))); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_MY_TARGETS))); } if ("isFavorites".equals(property) && receiver instanceof ICategory) { //$NON-NLS-1$ String id = ((ICategory)receiver).getId(); - return expectedValue.equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_FAVORITES))); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_FAVORITES))); } if ("isNeighborhood".equals(property) && receiver instanceof ICategory) { //$NON-NLS-1$ String id = ((ICategory)receiver).getId(); - return expectedValue.equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_NEIGHBORHOOD))); + return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(id.equals(IUIConstants.ID_CAT_NEIGHBORHOOD))); } return false; |