Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2014-01-17 05:43:41 +0000
committerTobias Schwarz2014-01-17 08:46:36 +0000
commit94a2bf165fe61b3225d5df34584ad90c1fe8bd81 (patch)
tree19c8a0972463064447430b5728c8d193658cf9df
parent255d5a66b4efcc36dcc570e064b910ff20effa8a (diff)
downloadorg.eclipse.tcf-94a2bf165fe61b3225d5df34584ad90c1fe8bd81.tar.gz
org.eclipse.tcf-94a2bf165fe61b3225d5df34584ad90c1fe8bd81.tar.xz
org.eclipse.tcf-94a2bf165fe61b3225d5df34584ad90c1fe8bd81.zip
Target Explorer: toolbar rework
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java53
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/icons/etool16/delete.gifbin0 -> 351 bytes
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml197
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java404
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java98
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java120
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeCommandHandler.java83
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectableToolbarCommandHandler.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ContextSelectorToolbarContribution.java323
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteToolbarCommandHandler.java31
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OpenEditorToolbarCommandHandler.java36
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java106
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugToolbarCommandHandler.java31
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/DefaultContextSourceProvider.java108
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractNewConfigWizard.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java)22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewConfigWizard.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java)32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/widgets/ImageCombo.java1520
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractCommandHandler.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractEditorCommandHandler.java85
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractStepperCommandHandler.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ConnectableCommandHandler.java102
33 files changed, 2561 insertions, 990 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index 2dc9a96fa..c5dd3f92b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -176,10 +176,6 @@
id="org.eclipse.tcf.te.tcf.locator.waitForReadyStep"
class="org.eclipse.tcf.te.tcf.locator.steps.WaitForReadyStep"
label="%WaitForReadyStep.name"/>
- <step
- id="org.eclipse.tcf.te.tcf.locator.setAsDefaultContextStep"
- class="org.eclipse.tcf.te.tcf.locator.steps.SetAsDefaultContextStep"
- label="%SetAsDefaultContextStep.name"/>
</extension>
<!-- Step group contributions -->
@@ -202,7 +198,6 @@
</reference>
<reference id="org.eclipse.tcf.te.tcf.locator.startSimulatorStepGroup"/>
<reference id="org.eclipse.tcf.te.tcf.locator.waitForReadyStepGroup"/>
- <reference id="org.eclipse.tcf.te.tcf.locator.setAsDefaultContextStep"/>
<reference id="org.eclipse.tcf.te.core.setConnectStateStep">
<parameter name="state" value="connected" />
</reference>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java
deleted file mode 100644
index df40c6157..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.locator.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
-
-/**
- * Set the active context as default context.
- */
-public class SetAsDefaultContextStep extends AbstractPeerNodeStep {
-
- /**
- * Constructor.
- */
- public SetAsDefaultContextStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- IDefaultContextService selService = ServiceManager.getInstance().getService(IDefaultContextService.class);
- if (selService != null) {
- selService.setDefaultContext(getActivePeerModelContext(context, data, fullQualifiedId));
- }
-
- callback.done(this, Status.OK_STATUS);
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
index 8c3a4d302..2f8381049 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
@@ -33,8 +33,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
-Export-Package: org.eclipse.tcf.te.tcf.ui.actions,
- org.eclipse.tcf.te.tcf.ui.activator,
+Export-Package: org.eclipse.tcf.te.tcf.ui.activator,
org.eclipse.tcf.te.tcf.ui.controls,
org.eclipse.tcf.te.tcf.ui.dialogs,
org.eclipse.tcf.te.tcf.ui.editor,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/icons/etool16/delete.gif b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/icons/etool16/delete.gif
new file mode 100644
index 000000000..b6922ac11
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/icons/etool16/delete.gif
Binary files differ
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
index a55124653..5d193b48b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
@@ -55,10 +55,16 @@ preference.page.name = Logging
# ***** Command Contributions *****
-ToolbarAction.label=Target Connections
+ConfigurationsToolbarAction.label=Configurations
+
+command.new.label=New Configuration
+
+command.open.label=Open
+command.open.toolbar.tooltip=Open default configuration
command.delete.label=Delete
command.delete.tooltip=Delete the selected configuration
+command.delete.toolbar.tooltip=Delete default configuration
command.delete.mnemonic = D
command.rename.label=Rename
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index 07595935d..614e855e8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -26,6 +26,13 @@
</factory>
</extension>
+<!-- Source provider contributions -->
+ <extension point="org.eclipse.ui.services">
+ <sourceProvider provider="org.eclipse.tcf.te.tcf.ui.internal.DefaultContextSourceProvider">
+ <variable name="defaultContextSelection" priorityLevel="workbench"/>
+ </sourceProvider>
+ </extension>
+
<!-- Element factory contributions -->
<extension point="org.eclipse.ui.elementFactories">
<factory
@@ -54,7 +61,7 @@
class="org.eclipse.tcf.te.tcf.ui.internal.PropertyTester"
id="org.eclipse.tcf.te.tcf.ui.propertyTester.simulator"
namespace="org.eclipse.tcf.te.tcf.ui"
- properties="isValidSimulatorConfig"
+ properties="isValidSimulatorConfig,canDelete"
type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
</propertyTester>
</extension>
@@ -233,7 +240,7 @@
<wizard
canFinishEarly="true"
category="org.eclipse.tcf.te.tcf.ui.newWizards.category"
- class="org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard"
+ class="org.eclipse.tcf.te.tcf.ui.wizards.NewConfigWizard"
hasPages="true"
icon="icons/elcl16/newTarget_wiz.gif"
id="org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard"
@@ -281,24 +288,6 @@
</wizard>
</extension>
-<!-- actionSet contributions -->
- <extension point="org.eclipse.ui.actionSets">
- <actionSet
- id="org.eclipse.tcf.te.tcf.ui.launch.gettingStartedActionSet"
- label="Getting Started Action Set (Target Explorer)"
- visible="false">
- <action
- class="org.eclipse.tcf.te.tcf.ui.actions.ToolbarAction"
- helpContextId="org.eclipse.tcf.te.tcf.ui.command_ToolbarAction"
- icon="icons/obj16/peer.gif"
- id="org.eclipse.tcf.te.tcf.ui.ToolbarAction"
- label="%ToolbarAction.label"
- style="pulldown"
- toolbarPath="org.eclipse.debug.ui.launchActionSet/emptyLaunchGroup">
- </action>
- </actionSet>
- </extension>
-
<!-- Perspective contributions -->
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.tcf.te.ui.perspective">
@@ -512,39 +501,55 @@
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.OverviewEditorPage?after=group.delete">
<command commandId="org.eclipse.ui.edit.delete"/>
</menuContribution>
+
<menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.OverviewEditorPage?after=group.additions">
<command commandId="org.eclipse.tcf.te.ui.command.showIn.systemManagement"/>
</menuContribution>
- <!-- Status line trim area -->
- <menuContribution locationURI="toolbar:org.eclipse.ui.trim.status">
- <toolbar id="org.eclipse.tcf.te.tcf.ui.trim.status.activeconnection">
+ <!-- Main toolbar contribution -->
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?before=additions">
+ <toolbar id="org.eclipse.tcf.te.tcf.ui.toolbar">
+ <separator name="group.selector" visible="false"/>
<control
- class="org.eclipse.tcf.te.tcf.ui.controls.DefaultContextStatusTrimControl"
- id="org.eclipse.tcf.te.tcf.ui.trim.status.DefaultContextStatusTrimControl">
- <visibleWhen checkEnabled="false">
- <or>
- <test
- property="org.eclipse.tcf.te.runtime.preference"
- args="bundleId=org.eclipse.tcf.te.tcf.ui,key=te.tcf.ui.feature.statusbar.trim.defaultcontext.enable"
- value="true">
- </test>
- <test
- property="org.eclipse.tcf.te.core.hasEnvVar"
- args="trim.defaultcontext.enable"
- value="true">
- </test>
- </or>
- </visibleWhen>
- </control>
+ class="org.eclipse.tcf.te.tcf.ui.handler.ContextSelectorToolbarContribution"
+ id="org.eclipse.tcf.te.tcf.ui.ContextSelectorToolbarContribution"/>
+ <separator name="group.connect" visible="false"/>
+ <command commandId="org.eclipse.tcf.te.ui.toolbar.command.connect"/>
+ <command commandId="org.eclipse.tcf.te.ui.toolbar.command.disconnect"/>
+ <separator name="group.additions" visible="true"/>
</toolbar>
</menuContribution>
+ <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.ContextSelectorToolbarContribution?after=group.new">
+ <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.open"/>
+ <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.delete"/>
+ <command commandId="org.eclipse.tcf.te.ui.command.newWizards"
+ label="%command.new.label"/>
+ </menuContribution>
+
+ <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.ContextSelectorToolbarContribution?after=group.launch.rundebug">
+ <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug"/>
+ </menuContribution>
+
</extension>
<!-- Command contributions -->
<extension point="org.eclipse.ui.commands">
<command
+ id="org.eclipse.tcf.te.tcf.ui.toolbar.command.open"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.ui.command_Open"
+ name="%command.open.label"
+ description="%command.open.toolbar.tooltip">
+ </command>
+ <command
+ id="org.eclipse.tcf.te.tcf.ui.toolbar.command.delete"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.ui.command_Delete"
+ name="%command.delete.label"
+ description="%command.delete.toolbar.tooltip">
+ </command>
+ <command
id="org.eclipse.tcf.te.tcf.ui.command.debug"
categoryId="org.eclipse.tcf.te.ui.commands.category"
helpContextId="org.eclipse.tcf.te.tcf.ui.command_Debug"
@@ -558,11 +563,22 @@
name="%command.debug.label"
description="%command.debug.tooltip">
</command>
+ <command
+ id="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.tcf.ui.command_Debug"
+ name="%command.debug.label"
+ description="%command.debug.tooltip">
+ </command>
</extension>
<!-- Command image contributions -->
<extension point="org.eclipse.ui.commandImages">
<image
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.delete"
+ icon="icons/etool16/delete.gif">
+ </image>
+ <image
commandId="org.eclipse.tcf.te.tcf.ui.command.debug"
icon="icons/etool16/debug_exc.gif">
</image>
@@ -570,6 +586,10 @@
commandId="org.eclipse.tcf.te.tcf.ui.editor.command.debug"
icon="icons/etool16/debug_exc.gif">
</image>
+ <image
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug"
+ icon="icons/etool16/debug_exc.gif">
+ </image>
</extension>
<!-- Handler contributions -->
@@ -637,24 +657,24 @@
commandId="org.eclipse.tcf.te.tcf.ui.command.debug"
class="org.eclipse.tcf.te.tcf.ui.handler.StartDebugCommandHandler">
<activeWhen>
- <with variable="systemManagerViewSelection">
+ <with variable="selection">
<iterate operator="and" ifEmpty="false">
<instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
</iterate>
</with>
</activeWhen>
<enabledWhen>
- <with variable="systemManagerViewSelection">
- <count value="1"/>
+ <with variable="selection">
<iterate operator="and" ifEmpty="false">
<adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
<test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="RunControl"/>
<test property="org.eclipse.tcf.te.launch.core.isLaunched" value="false"/>
</adapt>
- </iterate>
+ </iterate>
</with>
</enabledWhen>
</handler>
+
<handler
commandId="org.eclipse.tcf.te.tcf.ui.editor.command.debug"
class="org.eclipse.tcf.te.tcf.ui.handler.StartDebugCommandHandler">
@@ -672,6 +692,94 @@
</with>
</enabledWhen>
</handler>
+
+ <handler
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.open"
+ class="org.eclipse.tcf.te.tcf.ui.handler.OpenEditorToolbarCommandHandler">
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </enabledWhen>
+ </handler>
+
+ <handler
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.delete"
+ class="org.eclipse.tcf.te.tcf.ui.handler.DeleteToolbarCommandHandler">
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <test property="org.eclipse.tcf.te.tcf.ui.canDelete" value="true"/>
+ </with>
+ </enabledWhen>
+ </handler>
+
+ <handler
+ commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug"
+ class="org.eclipse.tcf.te.tcf.ui.handler.StartDebugToolbarCommandHandler">
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <and>
+ <test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="RunControl"/>
+ <test property="org.eclipse.tcf.te.launch.core.isLaunched" value="false"/>
+ </and>
+ </with>
+ </enabledWhen>
+ </handler>
+
+ <handler commandId="org.eclipse.tcf.te.ui.toolbar.command.connect">
+ <class class="org.eclipse.tcf.te.tcf.ui.handler.ConnectableToolbarCommandHandler">
+ <parameter name="action" value="connect"/>
+ </class>
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <adapt type="org.eclipse.tcf.te.core.interfaces.IConnectable"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <adapt type="org.eclipse.tcf.te.core.interfaces.IConnectable">
+ <test forcePluginActivation="true"
+ property="org.eclipse.tcf.te.core.isConnectStateChangeActionAllowed"
+ value="connect"/>
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
+
+ <handler commandId="org.eclipse.tcf.te.ui.toolbar.command.disconnect">
+ <class class="org.eclipse.tcf.te.tcf.ui.handler.ConnectableToolbarCommandHandler">
+ <parameter name="action" value="disconnect"/>
+ </class>
+ <activeWhen>
+ <with variable="defaultContextSelection">
+ <adapt type="org.eclipse.tcf.te.core.interfaces.IConnectable"/>
+ </with>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="defaultContextSelection">
+ <adapt type="org.eclipse.tcf.te.core.interfaces.IConnectable">
+ <test forcePluginActivation="true"
+ property="org.eclipse.tcf.te.core.isConnectStateChangeActionAllowed"
+ value="disconnect"/>
+ </adapt>
+ </with>
+ </enabledWhen>
+ </handler>
</extension>
<!-- Tabbed properties view contributions -->
@@ -700,4 +808,5 @@
tab="org.eclipse.tcf.te.ui.views.propertyTab.locator.general"/>
</propertySections>
</extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java
deleted file mode 100644
index 313d6c3fb..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/AbstractPeerTypeToolbarAction.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.ui.actions;
-
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.tcf.protocol.Protocol;
-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.persistence.history.HistoryManager;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.model.ModelManager;
-import org.eclipse.tcf.te.tcf.ui.dialogs.PeerNodeSelectionDialog;
-import org.eclipse.tcf.te.ui.views.editor.EditorInput;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.wizards.IWizardDescriptor;
-
-/**
- * Abstract Target connections toolbar pull down menu action implementation.
- */
-public abstract class AbstractPeerTypeToolbarAction extends Action implements IActionDelegate2, IWorkbenchWindowPulldownDelegate2, IEventListener {
-
- IWorkbenchWindow window;
- IAction action;
-
- private Menu menuCtlParent;
- private Menu menuMenuParent;
-
- /* default */ final AtomicBoolean recreateMenuCtlParent = new AtomicBoolean();
- /* default */ final AtomicBoolean recreateMenuMenuParent = new AtomicBoolean();
-
- /**
- * Constructor.
- */
- public AbstractPeerTypeToolbarAction() {
- super();
- }
-
- protected abstract String getNewWizardId();
-
- protected abstract String getPeerTypeId();
-
- protected abstract String getNewActionLabel();
- protected abstract ImageDescriptor getNewActionImageDescriptor();
-
- protected abstract String getSelectExistingActionLabel();
- protected abstract ImageDescriptor getSelectExistingActionImageDescriptor();
- protected abstract String getSelectExistingDialogTitle();
- protected abstract String getSelectExistingDialogDescription();
- protected abstract ViewerFilter getSelectExistingDialogViewerFilter();
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void init(IWorkbenchWindow window) {
- this.window = window;
- EventManager.getInstance().addEventListener(this, ChangeEvent.class);
- if (action != null) {
- EventManager.getInstance().fireEvent(new ChangeEvent(HistoryManager.getInstance(), ChangeEvent.ID_CHANGED, getPeerTypeId(), getPeerTypeId()));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
- */
- @Override
- public void init(IAction action) {
- this.action = action;
- if (window != null) {
- EventManager.getInstance().fireEvent(new ChangeEvent(HistoryManager.getInstance(), ChangeEvent.ID_CHANGED, getPeerTypeId(), getPeerTypeId()));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#dispose()
- */
- @Override
- public void dispose() {
- window = null;
- EventManager.getInstance().removeEventListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
- */
- @Override
- public void eventFired(EventObject event) {
- if (event instanceof ChangeEvent) {
- ChangeEvent e = (ChangeEvent)event;
- if (e.getSource() instanceof HistoryManager && getPeerTypeId().equals(e.getNewValue())) {
- recreateMenuCtlParent.set(true);
- recreateMenuMenuParent.set(true);
- IPeerNode peerNode = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId()));
- if (action != null) {
- if (peerNode != null) {
- ILabelProvider labelProvider = getLabelProvider(peerNode);
- if (labelProvider != null) {
- action.setToolTipText("Open " + labelProvider.getText(peerNode)); //$NON-NLS-1$
- return;
- }
-
- }
- action.setToolTipText(null);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control)
- */
- @Override
- public Menu getMenu(Control parent) {
- if (menuCtlParent != null) {
- menuCtlParent.dispose();
- }
- menuCtlParent = new Menu(parent);
- fillMenu(menuCtlParent);
- initMenu(menuCtlParent, recreateMenuCtlParent);
- return menuCtlParent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu)
- */
- @Override
- public Menu getMenu(Menu parent) {
- if (menuMenuParent != null) {
- menuMenuParent.dispose();
- }
- menuMenuParent = new Menu(parent);
- fillMenu(menuMenuParent);
- initMenu(menuMenuParent, recreateMenuMenuParent);
- return menuMenuParent;
- }
-
- /**
- * Creates the menu for the action
- */
- private void initMenu(final Menu menu, final AtomicBoolean recreateMenu) {
- // Add listener to re-populate the menu each time
- // it is shown because of dynamic history list
- menu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- if (recreateMenu.get()) {
- Menu m = (Menu)e.widget;
- MenuItem[] items = m.getItems();
- for (MenuItem item : items) {
- item.dispose();
- }
- fillMenu(m);
- recreateMenu.set(false);
- }
- }
- });
- }
-
- private IPeerNode getPeerModel(final String peerId) {
- if (peerId != null) {
- final AtomicReference<IPeerNode> peerNode = new AtomicReference<IPeerNode>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- IPeerModel model = ModelManager.getPeerModel();
- Assert.isNotNull(model);
- peerNode.set(model.getService(IPeerModelLookupService.class).lkupPeerModelById(peerId));
- }
- };
-
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeAndWait(runnable);
- }
-
- return peerNode.get();
- }
-
- return null;
- }
-
- /**
- * Fills the drop-down menu with favorites and launch history
- *
- * @param menu the menu to fill
- */
- @SuppressWarnings("unused")
- protected void fillMenu(Menu menu) {
- int accelerator = 1;
- List<IPeerNode> peerNodes = new ArrayList<IPeerNode>();
- for (String id : HistoryManager.getInstance().getHistory(getPeerTypeId())) {
- IPeerNode peerNode = getPeerModel(id);
- if (peerNode != null && !peerNodes.contains(peerNode)) {
- peerNodes.add(peerNode);
- }
- }
- for (final IPeerNode peerNode: peerNodes) {
- ILabelProvider labelProvider = getLabelProvider(peerNode);
- String label = peerNode.getPeer().getName();
- if (labelProvider != null) {
- label = labelProvider.getText(peerNode);
- if (labelProvider instanceof ILabelDecorator) {
- label = ((ILabelDecorator)labelProvider).decorateText(label, peerNode);
- }
- }
- Action action = new Action(label) {
- @Override
- public void run() {
- // Get the active page
- IWorkbenchPage page = window.getActivePage();
- // Create the editor input object
- IEditorInput input = new EditorInput(peerNode);
- try {
- // Opens the configuration editor
- page.openEditor(input, IUIConstants.ID_EDITOR);
- }
- catch (PartInitException e) {
- }
- }
- };
- if (labelProvider != null) {
- action.setImageDescriptor(ImageDescriptor.createFromImage(labelProvider.getImage(peerNode)));
- }
- addToMenu(menu, action, accelerator);
- accelerator++;
- }
-
- // Separator between favorites and history
- if (accelerator > 1) {
- new MenuItem(menu, SWT.SEPARATOR);
- }
-
- action = new Action(getSelectExistingActionLabel()) {
- @Override
- public void run() {
- // Get the active page
- IWorkbenchPage page = window.getActivePage();
- // Create the agent selection dialog
- PeerNodeSelectionDialog dialog = new PeerNodeSelectionDialog(null) {
- @Override
- protected String getTitle() {
- return getSelectExistingDialogTitle();
- }
- @Override
- protected String getDefaultMessage() {
- return getSelectExistingDialogDescription();
- }
- @Override
- protected String getType() {
- return getPeerTypeId();
- }
- };
-
- // Open the dialog
- if (dialog.open() == Window.OK) {
- // Get the selected proxy from the dialog
- ISelection selection = dialog.getSelection();
- if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerNode) {
- // Create the editor input object
- IEditorInput input = new EditorInput(((IStructuredSelection)selection).getFirstElement());
- try {
- // Opens the configuration editor
- page.openEditor(input, IUIConstants.ID_EDITOR);
- }
- catch (PartInitException e) {
- }
- }
- }
- }
- };
- action.setImageDescriptor(getSelectExistingActionImageDescriptor());
- addToMenu(menu, action, -1);
-
- action = new Action(getNewActionLabel()) {
- @SuppressWarnings("restriction")
- @Override
- public void run() {
- IWizardDescriptor wizardDesc = NewWizardRegistry.getInstance().findWizard(getNewWizardId());
- new org.eclipse.ui.internal.actions.NewWizardShortcutAction(window, wizardDesc).run();
- }
- };
- action.setImageDescriptor(getNewActionImageDescriptor());
- addToMenu(menu, action, -1);
- }
-
- /**
- * Adds the given action to the specified menu with an accelerator specified
- * by the given number.
- *
- * @param menu the menu to add the action to
- * @param action the action to add
- * @param accelerator the number that should appear as an accelerator
- */
- protected void addToMenu(Menu menu, IAction action, int accelerator) {
- StringBuffer label= new StringBuffer();
- if (accelerator >= 0 && accelerator < 10) {
- //add the numerical accelerator
- label.append('&');
- label.append(accelerator);
- label.append(' ');
- }
- label.append(action.getText());
- action.setText(label.toString());
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(menu, -1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- @SuppressWarnings("restriction")
- @Override
- public void run(IAction action) {
- IPeerNode peerNode = getPeerModel(HistoryManager.getInstance().getFirst(getPeerTypeId()));
- if (peerNode != null) {
- // Get the active page
- IWorkbenchPage page = window.getActivePage();
- // Create the editor input object
- IEditorInput input = new EditorInput(peerNode);
- try {
- // Opens the configuration editor
- page.openEditor(input, IUIConstants.ID_EDITOR);
- }
- catch (PartInitException e) {
- }
- return;
- }
- IWizardDescriptor wizardDesc = NewWizardRegistry.getInstance().findWizard(getNewWizardId());
- new org.eclipse.ui.internal.actions.NewWizardShortcutAction(window, wizardDesc).run();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
- */
- @Override
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-
- /**
- * Get the label provider for a peer model node.
- *
- * @param peerNode The peer model node.
- * @return The label provider or <code>null</code>.
- */
- protected ILabelProvider getLabelProvider(IPeerNode peerNode) {
- ILabelProvider labelProvider = (ILabelProvider)peerNode.getAdapter(ILabelProvider.class);
- if (labelProvider == null) {
- labelProvider = (ILabelProvider)Platform.getAdapterManager().loadAdapter(peerNode, ILabelProvider.class.getName());
- }
- return labelProvider;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java
deleted file mode 100644
index 63960a6a9..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/actions/ToolbarAction.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.ui.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.tcf.te.tcf.core.interfaces.IPeerType;
-import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts;
-import org.eclipse.tcf.te.tcf.ui.navigator.filter.GenericFilter;
-import org.eclipse.tcf.te.tcf.ui.nls.Messages;
-
-/**
- * Generic target connections toolbar pull down menu action implementation.
- */
-public class ToolbarAction extends AbstractPeerTypeToolbarAction {
-
- public final static String WIZARD_ID = "org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard"; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getNewWizardId()
- */
- @Override
- protected String getNewWizardId() {
- return WIZARD_ID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getPeerTypeId()
- */
- @Override
- protected String getPeerTypeId() {
- return IPeerType.TYPE_GENERIC;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingActionLabel()
- */
- @Override
- protected String getSelectExistingActionLabel() {
- return Messages.ToolbarAction_selectPeer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingDialogTitle()
- */
- @Override
- protected String getSelectExistingDialogTitle() {
- return Messages.ToolbarAction_selectionDialog_title;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingDialogDescription()
- */
- @Override
- protected String getSelectExistingDialogDescription() {
- return Messages.ToolbarAction_selectionDialog_description;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingDialogViewerFilter()
- */
- @Override
- protected ViewerFilter getSelectExistingDialogViewerFilter() {
- return new GenericFilter();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getNewActionLabel()
- */
- @Override
- protected String getNewActionLabel() {
- return Messages.ContentProviderDelegate_newNode;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getNewActionImageDescriptor()
- */
- @Override
- protected ImageDescriptor getNewActionImageDescriptor() {
- return UIPlugin.getImageDescriptor(ImageConsts.NEW_PEER_NODE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.actions.AbstractPeerTypeToolbarAction#getSelectExistingActionImageDescriptor()
- */
- @Override
- protected ImageDescriptor getSelectExistingActionImageDescriptor() {
- return UIPlugin.getImageDescriptor(ImageConsts.PEER_NODE);
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java
deleted file mode 100644
index a54d1c42f..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/DefaultContextStatusTrimControl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.ui.controls;
-
-import java.util.EventObject;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.osgi.util.NLS;
-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.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-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.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
-import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
-import org.eclipse.tcf.te.tcf.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
-
-/**
- * Default context status bar trim control implementation.
- */
-public class DefaultContextStatusTrimControl extends WorkbenchWindowControlContribution implements IEventListener {
- /* default */ Text text = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createControl(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0; layout.marginWidth = 0;
- panel.setLayout(layout);
-
- text = new Text(panel, SWT.SINGLE | SWT.READ_ONLY);
- GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, true);
- layoutData.minimumWidth = SWTControlUtil.convertWidthInCharsToPixels(text, 25);
- text.setLayoutData(layoutData);
- text.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
- text.setToolTipText(Messages.DefaultContextStatusTrimControl_tooltip);
-
- String selected = ""; //$NON-NLS-1$
-
- IDefaultContextService service = ServiceManager.getInstance().getService(IDefaultContextService.class);
- if (service != null) {
- IPeerNode peerNode = service.getDefaultContext(null);
- if (peerNode != null) {
- IUIService uiService = ServiceManager.getInstance().getService(peerNode, IUIService.class);
- ILabelProviderDelegate delegate = uiService != null ? uiService.getDelegate(peerNode, ILabelProviderDelegate.class) : null;
- if (delegate == null) {
- ILabelProvider provider = (ILabelProvider)Platform.getAdapterManager().getAdapter(peerNode, ILabelProvider.class);
- if (provider instanceof ILabelProviderDelegate) {
- delegate = (ILabelProviderDelegate)provider;
- }
- }
- selected = NLS.bind(Messages.DefaultContextStatusTrimControl_label, delegate != null ? delegate.getText(peerNode) : peerNode.getName());
- }
- }
-
- text.setText(selected);
-
- // Register as listener to the selection service
- EventManager.getInstance().addEventListener(this, ChangeEvent.class, IDefaultContextService.class);
-
- return panel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ContributionItem#dispose()
- */
- @Override
- public void dispose() {
- // Remove ourself as listener
- EventManager.getInstance().removeEventListener(this);
-
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
- */
- @Override
- public void eventFired(EventObject event) {
- if (event.getSource() instanceof IDefaultContextService) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- getParent().update(true);
- }
- };
-
- PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.ContributionItem#isDynamic()
- */
- @Override
- public boolean isDynamic() {
- return true;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeCommandHandler.java
new file mode 100644
index 000000000..b0497cb0e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerNodeCommandHandler.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.handler;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.ui.handler.AbstractCommandHandler;
+
+/**
+ * Peer node command handler implementation.
+ */
+public abstract class AbstractPeerNodeCommandHandler extends AbstractCommandHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IStructuredSelection selection = getSelection(event);
+
+ List<IPeerNode> peerNodes = getPeerNodes(selection);
+
+ return internalExecute (event, selection, peerNodes);
+ }
+
+ /**
+ * @param selection
+ * @return
+ */
+ protected List<IPeerNode> getPeerNodes(IStructuredSelection selection) {
+ List<IPeerNode> peerNodes = new ArrayList<IPeerNode>();
+
+ Iterator<Object> it = selection.iterator();
+ while (it.hasNext()) {
+ Object element = it.next();
+ IPeerNode peerNode = getPeerNode(element);
+ if (peerNode != null && !peerNodes.contains(peerNode)) {
+ peerNodes.add(peerNode);
+ }
+ }
+
+ return peerNodes;
+ }
+
+ protected IPeerNode getPeerNode(Object element) {
+ IPeerNode peerNode = null;
+ if (element instanceof IPeerNode) {
+ peerNode = (IPeerNode)element;
+ }
+ else if (element instanceof IAdaptable) {
+ peerNode = (IPeerNode)((IAdaptable)element).getAdapter(IPeerNode.class);
+ }
+ if (peerNode == null) {
+ peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(element, IPeerNode.class);
+ }
+
+ return peerNode;
+ }
+
+ /**
+ * @param event
+ * @param selection
+ * @param peerNodes
+ * @return
+ */
+ protected abstract Object internalExecute(ExecutionEvent event, IStructuredSelection selection, List<IPeerNode> peerNodes);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectableToolbarCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectableToolbarCommandHandler.java
new file mode 100644
index 000000000..f2ef520d3
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ConnectableToolbarCommandHandler.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.tcf.te.ui.handler.ConnectableCommandHandler;
+
+/**
+ * ConnectableToolbarCommandHandler
+ */
+public class ConnectableToolbarCommandHandler extends ConnectableCommandHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractCommandHandler#getSelection(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected IStructuredSelection getSelection(ExecutionEvent event) {
+ return new StructuredSelection(ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ContextSelectorToolbarContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ContextSelectorToolbarContribution.java
new file mode 100644
index 000000000..342bd80da
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ContextSelectorToolbarContribution.java
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.ui.handler;
+
+import java.util.EventObject;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+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.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.events.TriggerCommandEvent;
+import org.eclipse.tcf.te.runtime.interfaces.events.IEventListener;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.tcf.te.tcf.locator.model.ModelManager;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.views.navigator.DelegatingLabelProvider;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.menus.IMenuService;
+import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
+
+/**
+ * Configurations control implementation.
+ */
+public class ContextSelectorToolbarContribution extends WorkbenchWindowControlContribution implements IEventListener, IPeerModelListener {
+
+ final MenuManager menuMgr;
+ private Menu menu = null;
+ private Composite panel = null;
+ private Composite mainPanel = null;
+ private Label image = null;
+ private Label text = null;
+ private Button button = null;
+
+ /**
+ * Constructor.
+ */
+ public ContextSelectorToolbarContribution() {
+ super();
+
+ menuMgr = new MenuManager();
+ menuMgr.markDirty();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createControl(final Composite parent) {
+ mainPanel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginRight = 2;
+ mainPanel.setLayout(layout);
+
+ panel = new Composite(mainPanel, SWT.BORDER);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ panel.setLayoutData(layoutData);
+ panel.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.marginLeft = 2;
+ layout.horizontalSpacing = 5;
+ layout.verticalSpacing = 0;
+ panel.setLayout(layout);
+
+ image = new Label(panel, SWT.NONE);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ image.setLayoutData(layoutData);
+ image.setBackground(panel.getBackground());
+ image.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (peerNode == null) {
+ TriggerCommandEvent event = new TriggerCommandEvent(this, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ EventManager.getInstance().fireEvent(event);
+ }
+ else {
+ onButtonClick();
+ }
+ }
+ });
+ text = new Label(panel, SWT.NONE);
+ text.setBackground(panel.getBackground());
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, true);
+ layoutData.minimumWidth = SWTControlUtil.convertWidthInCharsToPixels(text, 25);
+ text.setLayoutData(layoutData);
+ text.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseUp(MouseEvent e) {
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (peerNode == null) {
+ TriggerCommandEvent event = new TriggerCommandEvent(this, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ EventManager.getInstance().fireEvent(event);
+ }
+ else {
+ onButtonClick();
+ }
+ }
+ });
+
+ button = new Button(panel, SWT.ARROW | SWT.DOWN | SWT.FLAT);
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ button.setLayoutData(layoutData);
+ button.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (peerNode == null) {
+ TriggerCommandEvent event = new TriggerCommandEvent(this, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ EventManager.getInstance().fireEvent(event);
+ }
+ else {
+ onButtonClick();
+ }
+ }
+ });
+
+ EventManager.getInstance().addEventListener(this, ChangeEvent.class);
+ ModelManager.getPeerModel().addListener(this);
+
+ update();
+
+ return mainPanel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+
+ EventManager.getInstance().removeEventListener(this);
+ ModelManager.getPeerModel().removeListener(this);
+
+ image.dispose();
+ text.dispose();
+ menuMgr.dispose();
+
+ image = null;
+ text = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#update()
+ */
+ @Override
+ public void update() {
+ if (image != null && text != null) {
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (peerNode != null) {
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
+ image.setImage(labelProvider.decorateImage(labelProvider.getImage(peerNode), peerNode));
+ String fullName = labelProvider.getText(peerNode);
+ String name = fullName;
+ if (name.length() > 22 && name.length() >= 25) {
+ name = name.substring(0, 22) + "..."; //$NON-NLS-1$
+ }
+ text.setText(name);
+ image.setToolTipText(!fullName.equals(name) ? fullName : Messages.ContextSelectorToolbarContribution_tooltip_button);
+ text.setToolTipText(!fullName.equals(name) ? fullName : Messages.ContextSelectorToolbarContribution_tooltip_button);
+ button.setToolTipText(Messages.ContextSelectorToolbarContribution_tooltip_button);
+ }
+ else {
+ image.setImage(null);
+ text.setText(Messages.ContextSelectorToolbarContribution_label_new);
+ image.setToolTipText(Messages.ContextSelectorToolbarContribution_tooltip_new);
+ text.setToolTipText(null);
+ button.setToolTipText(Messages.ContextSelectorToolbarContribution_tooltip_new);
+ }
+ }
+ }
+
+ protected void onButtonClick() {
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (peerNode == null) {
+ TriggerCommandEvent event = new TriggerCommandEvent(this, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ EventManager.getInstance().fireEvent(event);
+ }
+ else {
+ createContextMenu(mainPanel);
+ Point point = mainPanel.toDisplay(mainPanel.getLocation());
+ menu.setLocation(point.x, point.y + mainPanel.getBounds().height);
+ menu.setVisible(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#isDynamic()
+ */
+ @Override
+ public boolean isDynamic() {
+ return true;
+ }
+
+ protected void createContextMenu(Composite panel) {
+ if (menuMgr.isDirty()) {
+ menuMgr.removeAll();
+ menuMgr.add(new Separator("group.launch")); //$NON-NLS-1$
+ menuMgr.add(new Separator("group.launch.rundebug")); //$NON-NLS-1$
+ menuMgr.add(new Separator("group.new")); //$NON-NLS-1$
+ menuMgr.add(new Separator("group.configurations")); //$NON-NLS-1$
+ IPeerNode defaultContext = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ for (final IPeerNode peerNode : ModelManager.getPeerModel().getPeerNodes()) {
+ if (peerNode == defaultContext) {
+ continue;
+ }
+ IAction action = new Action() {
+ private IPeerNode node = peerNode;
+ @Override
+ public void run() {
+ ServiceManager.getInstance().getService(IDefaultContextService.class).setDefaultContext(node);
+ getParent().update(true);
+ }
+ };
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
+ action.setText(labelProvider.getText(peerNode));
+ Image image = labelProvider.decorateImage(labelProvider.getImage(peerNode), peerNode);
+ action.setImageDescriptor(ImageDescriptor.createFromImage(image));
+ menuMgr.add(action);
+ }
+ final IMenuService service = (IMenuService) getWorkbenchWindow().getPartService().getActivePart().getSite().getService(IMenuService.class);
+ service.populateContributionManager(menuMgr, "menu:" + ContextSelectorToolbarContribution.this.getId()); //$NON-NLS-1$
+ }
+ menu = menuMgr.createContextMenu(panel);
+ }
+
+ /**
+ * Get the label provider for a peer model node.
+ *
+ * @param peerNode The peer model node.
+ * @return The label provider or <code>null</code>.
+ */
+ protected ILabelProvider getLabelProvider(IPeerNode peerNode) {
+ ILabelProvider labelProvider = (ILabelProvider)peerNode.getAdapter(ILabelProvider.class);
+ if (labelProvider == null) {
+ labelProvider = (ILabelProvider)Platform.getAdapterManager().loadAdapter(peerNode, ILabelProvider.class.getName());
+ }
+ return labelProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (event instanceof ChangeEvent) {
+ ChangeEvent changeEvent = (ChangeEvent)event;
+ IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ if (changeEvent.getSource() instanceof IDefaultContextService ||
+ (changeEvent.getSource() == peerNode &&
+ (IPeerNodeProperties.PROP_CONNECT_STATE.equals(changeEvent.getEventId()) || "properties".equals(changeEvent.getEventId())))) { //$NON-NLS-1$
+ menuMgr.markDirty();
+ ExecutorsUtil.executeInUI(new Runnable() {
+ @Override
+ public void run() {
+ getParent().update(true);
+ }
+ });
+ }
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
+ */
+ @Override
+ public void modelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
+ menuMgr.markDirty();
+ ExecutorsUtil.executeInUI(new Runnable() {
+ @Override
+ public void run() {
+ getParent().update(true);
+ }
+ });
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelDisposed(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ */
+ @Override
+ public void modelDisposed(IPeerModel model) {
+ }
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
index 4f351b13f..d49739a03 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
@@ -69,7 +69,7 @@ public class DeleteHandler extends AbstractHandler {
// Get the shell
shell = HandlerUtil.getActiveShell(event);
// Get the current selection
- ISelection selection = HandlerUtil.getCurrentSelection(event);
+ ISelection selection = getSelection(event);
// Delete the selection
if (selection != null) {
delete(selection, new Callback() {
@@ -86,6 +86,10 @@ public class DeleteHandler extends AbstractHandler {
return null;
}
+ protected ISelection getSelection(ExecutionEvent event) {
+ return HandlerUtil.getCurrentSelection(event);
+ }
+
/**
* Tests if this delete handler can delete the elements of the given
* selection.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteToolbarCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteToolbarCommandHandler.java
new file mode 100644
index 000000000..1bb0e0fbb
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteToolbarCommandHandler.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+
+/**
+ * DeleteToolbarCommandHandler
+ */
+public class DeleteToolbarCommandHandler extends DeleteHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler#getSelection(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected ISelection getSelection(ExecutionEvent event) {
+ return new StructuredSelection(ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OpenEditorToolbarCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OpenEditorToolbarCommandHandler.java
new file mode 100644
index 000000000..8baa8cdf2
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OpenEditorToolbarCommandHandler.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * OpenEditorToolbarCommandHandler
+ */
+public class OpenEditorToolbarCommandHandler extends OpenEditorHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.handler.OpenEditorHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ openEditorOnSelection(HandlerUtil.getActiveWorkbenchWindow(event),
+ new StructuredSelection(ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null)));
+
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java
index b53aaa320..88a76c57c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugCommandHandler.java
@@ -10,21 +10,14 @@
*/
package org.eclipse.tcf.te.tcf.ui.handler;
-import java.util.Iterator;
+import java.util.List;
-import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.tcf.te.runtime.callback.AsyncCallbackCollector;
import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
@@ -32,92 +25,37 @@ import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService;
import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.steps.StartDebuggerStep.IDelegate;
-import org.eclipse.tcf.te.ui.async.UICallbackInvocationDelegate;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.part.EditorPart;
/**
* Start debugger command handler implementation.
*/
-public class StartDebugCommandHandler extends AbstractHandler {
+public class StartDebugCommandHandler extends AbstractPeerNodeCommandHandler {
/* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ * @see org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerNodeCommandHandler#internalExecute(org.eclipse.core.commands.ExecutionEvent, org.eclipse.jface.viewers.IStructuredSelection, java.util.List)
*/
@Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // Get the active part
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- // Get the current selection
- ISelection selection = HandlerUtil.getCurrentSelection(event);
-
- // If the handler is invoked from an editor part, ignore the selection and
- // construct an artificial selection from the active editor input.
- if (part instanceof EditorPart) {
- IEditorInput input = ((EditorPart)part).getEditorInput();
- Object element = input != null ? input.getAdapter(Object.class) : null;
- if (element != null) {
- selection = new StructuredSelection(element);
- }
- }
-
- // If the selection is not empty, iterate over the selection and execute
- // the operation for each peer model node in the selection.
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- // Create the collector keeping track of the callbacks for each peer model
- // node within the selection
- final AsyncCallbackCollector collector = new AsyncCallbackCollector(new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- // Signal that all operations completed
- }
- }, new UICallbackInvocationDelegate());
-
- Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
- if (element instanceof IPeerNode) {
- startDebugger((IPeerNode)element, new AsyncCallbackCollector.SimpleCollectorCallback(collector));
- }
+ protected Object internalExecute(ExecutionEvent event, IStructuredSelection selection, List<IPeerNode> peerNodes) {
+ for (final IPeerNode peerNode : peerNodes) {
+ IDebugService dbgService = ServiceManager.getInstance().getService(peerNode, IDebugService.class, false);
+ if (dbgService != null) {
+ final IProgressMonitor monitor = new NullProgressMonitor();
+ IPropertiesContainer props = new PropertiesContainer();
+ dbgService.attach(peerNode, props, monitor, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ // Check if there is a delegate registered
+ IDelegateService service = ServiceManager.getInstance().getService(peerNode, IDelegateService.class, false);
+ IDelegate delegate = service != null ? service.getDelegate(peerNode, IDelegate.class) : null;
+
+ if (delegate != null) {
+ delegate.postAttachDebugger(peerNode, monitor, new Callback());
+ }
+ }
+ });
}
-
- // Mark the collector initialization done
- collector.initDone();
- }
+ }
return null;
}
-
- /**
- * Starts the debugger for the given peer model node.
- *
- * @param peerNode The peer model node. Must not be <code>null</code>.
- * @param callback The callback. Must not be <code>null</code>.
- */
- public void startDebugger(final IPeerNode peerNode, final ICallback callback) {
- Assert.isNotNull(peerNode);
- Assert.isNotNull(callback);
-
- IDebugService dbgService = ServiceManager.getInstance().getService(peerNode, IDebugService.class, false);
- if (dbgService != null) {
- final IProgressMonitor monitor = new NullProgressMonitor();
- IPropertiesContainer props = new PropertiesContainer();
- dbgService.attach(peerNode, props, monitor, new Callback() {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- // Check if there is a delegate registered
- IDelegateService service = ServiceManager.getInstance().getService(peerNode, IDelegateService.class, false);
- IDelegate delegate = service != null ? service.getDelegate(peerNode, IDelegate.class) : null;
-
- if (delegate != null) {
- delegate.postAttachDebugger(peerNode, monitor, callback);
- } else {
- callback.done(caller, status);
- }
- }
- });
- }
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugToolbarCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugToolbarCommandHandler.java
new file mode 100644
index 000000000..a83c52f04
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/StartDebugToolbarCommandHandler.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+
+/**
+ * StartDebugToolbarCommandHandler
+ */
+public class StartDebugToolbarCommandHandler extends StartDebugCommandHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.handler.AbstractCommandHandler#getSelection(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ protected IStructuredSelection getSelection(ExecutionEvent event) {
+ return new StructuredSelection(ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/DefaultContextSourceProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/DefaultContextSourceProvider.java
new file mode 100644
index 000000000..49a7f2b1c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/DefaultContextSourceProvider.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 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.ui.internal;
+
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+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.services.ServiceManager;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
+import org.eclipse.ui.AbstractSourceProvider;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.services.IEvaluationService;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ * Default context source provider implementation.
+ */
+public class DefaultContextSourceProvider extends AbstractSourceProvider implements IEventListener {
+
+ /**
+ * Source name identifying the System Manager view selection.
+ */
+ public static final String defaultContextSelectionName = "defaultContextSelection"; //$NON-NLS-1$
+
+ // The internal list of provided source names
+ private final static String[] PROVIDED_SOURCE_NAMES = {defaultContextSelectionName};
+
+ // The reference to the expression evaluation service
+ private IEvaluationService service = null;
+
+ private IPeerNode defaultContext = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.AbstractSourceProvider#initialize(org.eclipse.ui.services.IServiceLocator)
+ */
+ @Override
+ public void initialize(IServiceLocator locator) {
+ super.initialize(locator);
+
+ EventManager.getInstance().addEventListener(this, ChangeEvent.class);
+
+ defaultContext = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+
+ // Register the source provider with the expression evaluation service
+ if (locator.hasService(IEvaluationService.class)) {
+ service = (IEvaluationService)locator.getService(IEvaluationService.class);
+ if (service != null) service.addSourceProvider(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ EventManager.getInstance().removeEventListener(this);
+
+ // Unregister the source provider from the expression evaluation service
+ if (service != null) { service.removeSourceProvider(this); service = null; }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#getProvidedSourceNames()
+ */
+ @Override
+ public String[] getProvidedSourceNames() {
+ return PROVIDED_SOURCE_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#getCurrentState()
+ */
+ @Override
+ public Map getCurrentState() {
+ Map<String, Object> state = new HashMap<String, Object>();
+
+ state.put(defaultContextSelectionName, defaultContext != null ? defaultContext : IEvaluationContext.UNDEFINED_VARIABLE);
+
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (event instanceof ChangeEvent) {
+ ChangeEvent changeEvent = (ChangeEvent)event;
+ if (changeEvent.getSource() instanceof IDefaultContextService || changeEvent.getSource() == defaultContext) {
+ defaultContext = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null);
+ fireSourceChanged(ISources.WORKBENCH, defaultContextSelectionName, defaultContext != null ? defaultContext : IEvaluationContext.UNDEFINED_VARIABLE);
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
index f52a2153d..27194bb8b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
@@ -11,6 +11,7 @@ package org.eclipse.tcf.te.tcf.ui.internal;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
import org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler;
@@ -35,6 +36,10 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
return testSelection((IStructuredSelection)receiver, property, args, expectedValue);
}
+ if ("canDelete".equals(property)) { //$NON-NLS-1$
+ return testSelection(new StructuredSelection(receiver), property, args, expectedValue);
+ }
+
if ("isWizardId".equals(property) && receiver instanceof NewWizardNode) { //$NON-NLS-1$
return ((NewWizardNode)receiver).getWizardId().equals(expectedValue);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java
index d3953e411..aecb029d1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/services/DefaultContextService.java
@@ -24,10 +24,9 @@ import org.eclipse.tcf.te.runtime.events.ChangeEvent;
import org.eclipse.tcf.te.runtime.events.EventManager;
import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager;
import org.eclipse.tcf.te.runtime.services.AbstractService;
-import org.eclipse.tcf.te.tcf.core.interfaces.IPeerType;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
import org.eclipse.tcf.te.tcf.locator.model.ModelManager;
@@ -37,7 +36,7 @@ import org.eclipse.ui.PlatformUI;
/**
* Default context service implementation.
*/
-public class DefaultContextService extends AbstractService implements IDefaultContextService {
+public class DefaultContextService extends AbstractService implements IDefaultContextService, IPeerModelListener {
/**
* Part id: System Management view
@@ -48,6 +47,7 @@ public class DefaultContextService extends AbstractService implements IDefaultCo
* Constructor.
*/
public DefaultContextService() {
+ ModelManager.getPeerModel().addListener(this);
}
/* (non-Javadoc)
@@ -82,19 +82,6 @@ public class DefaultContextService extends AbstractService implements IDefaultCo
if (peerNode != null) {
HistoryManager.getInstance().add(getClass().getName(), peerNode.getPeerId());
EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_ADDED, peerNode, peerNode));
-
- final AtomicReference<String> type = new AtomicReference<String>();
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- type.set(peerNode.getPeer().getAttributes().get((IPeerNodeProperties.PROP_TYPE)));
- }
- });
- HistoryManager.getInstance().add(type.get() != null ? type.get() : IPeerType.TYPE_GENERIC, peerNode.getPeerId());
- }
- else {
- HistoryManager.getInstance().clear(getClass().getName());
- EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_REMOVED, null, null));
}
}
@@ -201,4 +188,23 @@ public class DefaultContextService extends AbstractService implements IDefaultCo
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
+ */
+ @Override
+ public void modelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
+ if (!added) {
+ IPeerNode defaultContext = getDefaultContext(null);
+ EventManager.getInstance().fireEvent(new ChangeEvent(this, ChangeEvent.ID_CHANGED, defaultContext, defaultContext));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IPeerModelListener#modelDisposed(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ */
+ @Override
+ public void modelDisposed(IPeerModel model) {
+ model.removeListener(this);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
index f9caaffb6..948e3d583 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/ContentProvider.java
@@ -70,7 +70,7 @@ public class ContentProvider implements ICommonContentProvider, ITreePathContent
// The current user filter id
private final static String CURRENT_USER_FILTER_ID = "org.eclipse.tcf.te.tcf.ui.navigator.PeersByCurrentUserFilter"; //$NON-NLS-1$
- private final NewWizardNode newConfigNode = new NewWizardNode("org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard", //$NON-NLS-1$
+ private final NewWizardNode newConfigNode = new NewWizardNode("org.eclipse.tcf.te.tcf.ui.wizards.NewConfigWizard", //$NON-NLS-1$
Messages.ContentProvider_newNode,
UIPlugin.getImage(ImageConsts.NEW_PEER_NODE), this);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index 5eac3d487..ad0948705 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -192,9 +192,9 @@ public class Messages extends NLS {
public static String AbstractConfigWizardPage_connect_label;
public static String AbstractConfigWizardPage_advancedButton_label;
- public static String ToolbarAction_selectPeer;
- public static String ToolbarAction_selectionDialog_title;
- public static String ToolbarAction_selectionDialog_description;
+ public static String ContextSelectorToolbarContribution_tooltip_new;
+ public static String ContextSelectorToolbarContribution_label_new;
+ public static String ContextSelectorToolbarContribution_tooltip_button;
public static String LoggingPreferencePage_label;
public static String LoggingPreferencePage_enabled_label;
@@ -240,9 +240,6 @@ public class Messages extends NLS {
public static String PeerImportWizardPage_overwriteDialog_message;
public static String PeerImportWizardPage_overwriteDialogToggle_message;
- public static String DefaultContextStatusTrimControl_label;
- public static String DefaultContextStatusTrimControl_tooltip;
-
public static String AbstractMapPropertiesSection_name_label;
public static String AbstractMapPropertiesSection_value_label;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
index d8b6798fa..694aaf395 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
@@ -149,9 +149,9 @@ AbstractConfigWizardPage_connect_label=Connect configuration on finish
AbstractConfigWizardPage_launchDbg_label=Start debugger after connection has been established
AbstractConfigWizardPage_advancedButton_label=Advanced...
-ToolbarAction_selectPeer=Select Existing Configuration...
-ToolbarAction_selectionDialog_title=Select Existing Configuration
-ToolbarAction_selectionDialog_description=Select an existing configuration.
+ContextSelectorToolbarContribution_tooltip_new=Click to create a new configuration
+ContextSelectorToolbarContribution_label_new=New Configuration...
+ContextSelectorToolbarContribution_tooltip_button=Click to see possible actions for the configuration\nor to change the default configuration.
# ***** Preference Pages *****
@@ -199,9 +199,6 @@ PeerImportWizardPage_overwrite_button=Overwrite existing configuration(s) withou
PeerImportWizardPage_overwriteDialog_message=The target ''{0}'' already exists. Do you want to overwrite it?
PeerImportWizardPage_overwriteDialogToggle_message=Remember my decision
-DefaultContextStatusTrimControl_label={0}
-DefaultContextStatusTrimControl_tooltip=Most recently used context
-
AbstractMapPropertiesSection_name_label=Name
AbstractMapPropertiesSection_value_label=Value
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractNewConfigWizard.java
index 87fc856c4..5b9747520 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractNewConfigWizard.java
@@ -24,15 +24,17 @@ import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations;
import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.tcf.ui.wizards.pages.AbstractConfigWizardPage;
+import org.eclipse.tcf.te.ui.wizards.AbstractWizard;
+import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
/**
* Abstract new configuration wizard implementation.
*/
-public abstract class AbstractConfigWizard extends NewTargetWizard {
+public abstract class AbstractNewConfigWizard extends AbstractWizard implements INewWizard {
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
@@ -54,19 +56,21 @@ public abstract class AbstractConfigWizard extends NewTargetWizard {
protected abstract String getWizardTitle();
/**
- * Returns the new configuration wizard page.
+ * Returns if or if not the wizard should open the editor
+ * on "Finish". The default is <code>true</code>.
*
- * @return The new configuration wizard page or <code>null</code>:
+ * @return <code>True</code> to open the editor, <code>false</code> otherwise.
*/
- protected abstract AbstractConfigWizardPage getConfigWizardPage();
+ protected boolean isOpenEditorOnPerformFinish() {
+ return true;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard#postPerformFinish(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
- */
- @Override
protected void postPerformFinish(final IPeerNode peerNode) {
Assert.isNotNull(peerNode);
+ // set new peer node as default context
+ ServiceManager.getInstance().getService(IDefaultContextService.class).setDefaultContext(peerNode);
+
// Determine if or if not to auto-connect the created connection.
boolean autoConnect = true;
// If set as system property, take the system property into account first
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewConfigWizard.java
index 4d1c27fa1..8a18bf096 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewTargetWizard.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/NewConfigWizard.java
@@ -43,15 +43,13 @@ import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
import org.eclipse.tcf.te.ui.swt.DisplayUtil;
import org.eclipse.tcf.te.ui.views.ViewsUtil;
import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.wizards.AbstractWizard;
import org.eclipse.tcf.te.ui.wizards.pages.AbstractWizardPage;
-import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
/**
* New peer wizard implementation.
*/
-public class NewTargetWizard extends AbstractWizard implements INewWizard {
+public class NewConfigWizard extends AbstractNewConfigWizard {
// Session wide new peer counter
private final static AtomicInteger counter = new AtomicInteger();
@@ -61,8 +59,6 @@ public class NewTargetWizard extends AbstractWizard implements INewWizard {
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
super.init(workbench, selection);
- // Set the window title
- setWindowTitle(Messages.NewTargetWizard_windowTitle);
}
/* (non-Javadoc)
@@ -203,25 +199,11 @@ public class NewTargetWizard extends AbstractWizard implements INewWizard {
return true;
}
- /**
- * Returns if or if not the wizard should open the editor
- * on "Finish". The default is <code>true</code>.
- *
- * @return <code>True</code> to open the editor, <code>false</code> otherwise.
- */
- protected boolean isOpenEditorOnPerformFinish() {
- return true;
- }
-
- /**
- * Called from {@link #performFinish()} after the configuration got created.
- * <p>
- * <b>Note:</b> The method is called from within the UI thread.
- *
- * @param peerNode The peer model node. Must not be <code>null</code>.
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.wizards.AbstractNewConfigWizard#getWizardTitle()
*/
- protected void postPerformFinish(IPeerNode peerNode) {
- // Do nothing
- }
-
+ @Override
+ protected String getWizardTitle() {
+ return Messages.NewTargetWizard_windowTitle;
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/widgets/ImageCombo.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/widgets/ImageCombo.java
new file mode 100644
index 000000000..c4a04054e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/widgets/ImageCombo.java
@@ -0,0 +1,1520 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.ui.swt.widgets;
+
+ import java.util.Arrays;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.accessibility.ACC;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlAdapter;
+import org.eclipse.swt.accessibility.AccessibleControlEvent;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.accessibility.AccessibleTextAdapter;
+import org.eclipse.swt.accessibility.AccessibleTextEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TypedListener;
+import org.eclipse.swt.widgets.Widget;
+
+ /**
+ * The ImageCombo class represents a selectable user interface object
+ * that combines a text field and a table and issues notification
+ * when an item is selected from the table.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER, READ_ONLY, FLAT</dd>
+ * <dt><b>Events:</b>
+ * <dd>Selection</dd>
+ * </dl>
+ */
+ public final class ImageCombo extends Composite {
+
+ Label image;
+ Text text;
+ Table table;
+ int visibleItemCount = 5;
+ Shell popup;
+ Button arrow;
+ boolean hasFocus;
+ Listener listener, filter;
+ Color foreground, background;
+ Font font;
+
+ /**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#READ_ONLY
+ * @see SWT#FLAT
+ * @see Widget#getStyle()
+ */
+ public ImageCombo (Composite parent, int style) {
+ super (parent, style = checkStyle (style));
+
+ int textStyle = SWT.SINGLE;
+ if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
+ if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
+ image = new Label (this, SWT.NONE);
+ text = new Text (this, textStyle);
+ int arrowStyle = SWT.ARROW | SWT.DOWN;
+ if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
+ arrow = new Button (this, arrowStyle);
+
+ listener = new Listener () {
+ @Override
+ public void handleEvent (Event event) {
+ if (popup == event.widget) {
+ popupEvent (event);
+ return;
+ }
+ if (text == event.widget) {
+ textEvent (event);
+ return;
+ }
+ if (table == event.widget) {
+ listEvent (event);
+ return;
+ }
+ if (arrow == event.widget) {
+ arrowEvent (event);
+ return;
+ }
+ if (ImageCombo.this == event.widget) {
+ comboEvent (event);
+ return;
+ }
+ if (getShell () == event.widget) {
+ handleFocus (SWT.FocusOut);
+ }
+ }
+ };
+ filter = new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ Shell shell = ((Control)event.widget).getShell ();
+ if (shell == ImageCombo.this.getShell ()) {
+ handleFocus (SWT.FocusOut);
+ }
+ }
+ };
+
+ int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
+ for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
+
+ int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn};
+ for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
+
+ int [] arrowEvents = {SWT.Selection, SWT.FocusIn};
+ for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
+
+ createPopup( -1);
+ initAccessible();
+ }
+ static int checkStyle (int style) {
+ int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+ return style & mask;
+ }
+ /**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+ public void add (String string, Image image) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table,SWT.NONE);
+ newItem.setText(string);
+ if (image != null) newItem.setImage(image);
+ }
+ /**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+ public void add (String string,Image image, int index) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TableItem newItem = new TableItem(this.table,SWT.NONE,index);
+ if (image != null) newItem.setImage(image);
+ }
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+ public void addModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+ }
+ /**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+ public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+ }
+ void arrowEvent (Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ handleFocus (SWT.FocusIn);
+ break;
+ }
+ case SWT.Selection: {
+ dropDown (!isDropped ());
+ break;
+ }
+ }
+ }
+ /**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list,
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
+ */
+ public void clearSelection () {
+ checkWidget ();
+ text.clearSelection ();
+ table.deselectAll ();
+ }
+ void comboEvent (Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (popup != null && !popup.isDisposed ()) {
+ table.removeListener (SWT.Dispose, listener);
+ popup.dispose ();
+ }
+ Shell shell = getShell ();
+ shell.removeListener (SWT.Deactivate, listener);
+ Display display = getDisplay ();
+ display.removeFilter (SWT.FocusIn, filter);
+ popup = null;
+ text = null;
+ table = null;
+ arrow = null;
+ break;
+ case SWT.Move:
+ dropDown (false);
+ break;
+ case SWT.Resize:
+ internalLayout (false);
+ break;
+ }
+ }
+
+ @Override
+ public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = 0, height = 0;
+ String[] items = getStringsFromTable();
+ int textWidth = 0;
+ GC gc = new GC (text);
+ int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
+ for (int i = 0; i < items.length; i++) {
+ textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
+ }
+ gc.dispose();
+ Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point listSize = table.computeSize (wHint, SWT.DEFAULT, changed);
+ int borderWidth = getBorderWidth ();
+
+ height = Math.max (hHint, Math.max (textSize.y, arrowSize.y) + 2*borderWidth);
+ width = Math.max (wHint, Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x));
+ return new Point (width, height);
+ }
+ void createPopup(int selectionIndex) {
+ // create shell and list
+ popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
+ int style = getStyle ();
+ int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+ if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
+ if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
+ // create a table instead of a list.
+ table = new Table (popup, listStyle);
+ if (font != null) table.setFont (font);
+ if (foreground != null) table.setForeground (foreground);
+ if (background != null) table.setBackground (background);
+
+ int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
+ for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
+ int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
+ for (int i=0; i<listEvents.length; i++) table.addListener (listEvents [i], listener);
+
+ if (selectionIndex != -1) table.setSelection (selectionIndex);
+ }
+ /**
+ * Deselects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void deselect (int index) {
+ checkWidget ();
+ table.deselect (index);
+ }
+ /**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
+ */
+ public void deselectAll () {
+ checkWidget ();
+ table.deselectAll ();
+ }
+ void dropDown (boolean drop) {
+ if (drop == isDropped ()) return;
+ if (!drop) {
+ popup.setVisible (false);
+ if (!isDisposed ()&& arrow.isFocusControl()) {
+// setFocus();
+ }
+ return;
+ }
+
+ if (getShell() != popup.getParent ()) {
+// TableItem[] items = table.getItems ();
+ int selectionIndex = table.getSelectionIndex ();
+ table.removeListener (SWT.Dispose, listener);
+ popup.dispose();
+ popup = null;
+ table = null;
+ createPopup (selectionIndex);
+ }
+
+ Point size = getSize ();
+ int itemCount = table.getItemCount ();
+ itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
+ int itemHeight = table.getItemHeight () * itemCount;
+ Point listSize = table.computeSize (SWT.DEFAULT, itemHeight, false);
+ table.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
+
+ int index = table.getSelectionIndex ();
+ if (index != -1) table.setTopIndex (index);
+ Display display = getDisplay ();
+ Rectangle listRect = table.getBounds ();
+ Rectangle parentRect = display.map (getParent (), null, getBounds ());
+ Point comboSize = getSize ();
+ Rectangle displayRect = getMonitor ().getClientArea ();
+ int width = Math.max (comboSize.x, listRect.width + 2);
+ int height = listRect.height + 2;
+ int x = parentRect.x;
+ int y = parentRect.y + comboSize.y;
+ if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
+ popup.setBounds (x, y, width, height);
+ popup.setVisible (true);
+ table.setFocus ();
+ }
+ /*
+ * Return the Label immediately preceding the receiver in the z-order,
+ * or null if none.
+ */
+ Label getAssociatedLabel () {
+ Control[] siblings = getParent ().getChildren ();
+ for (int i = 0; i < siblings.length; i++) {
+ if (siblings [i] == ImageCombo.this) {
+ if (i > 0 && siblings [i-1] instanceof Label) {
+ return (Label) siblings [i-1];
+ }
+ }
+ }
+ return null;
+ }
+ @Override
+ public Control [] getChildren () {
+ checkWidget();
+ return new Control [0];
+ }
+ /**
+ * Gets the editable state.
+ *
+ * @return whether or not the reciever is editable
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public boolean getEditable () {
+ checkWidget ();
+ return text.getEditable();
+ }
+ /**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public TableItem getItem (int index) {
+ checkWidget();
+ return this.table.getItem (index);
+ }
+ /**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getItemCount () {
+ checkWidget ();
+ return table.getItemCount ();
+ }
+ /**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getItemHeight () {
+ checkWidget ();
+ return table.getItemHeight ();
+ }
+ /**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver.
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public TableItem [] getItems () {
+ checkWidget ();
+ return table.getItems ();
+ }
+ char getMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != '&')) index++;
+ if (++index >= length) return '\0';
+ if (string.charAt (index) != '&') return string.charAt (index);
+ index++;
+ } while (index < length);
+ return '\0';
+ }
+
+ String [] getStringsFromTable()
+ {
+ String[] items = new String[this.table.getItems().length];
+ for (int i = 0, n = items.length; i < n; i++) {
+ items[i]=this.table.getItem(i).getText();
+ }
+ return items;
+ }
+ /**
+ * Returns a <code>Point</code> whose x coordinate is the start
+ * of the selection in the receiver's text field, and whose y
+ * coordinate is the end of the selection. The returned values
+ * are zero-relative. An "empty" selection as indicated by
+ * the the x and y coordinates having the same value.
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public Point getSelection () {
+ checkWidget ();
+ return text.getSelection ();
+ }
+ /**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getSelectionIndex () {
+ checkWidget ();
+ return table.getSelectionIndex ();
+ }
+ @Override
+ public int getStyle () {
+ int style = super.getStyle ();
+ style &= ~SWT.READ_ONLY;
+ if (!getEditable()) style |= SWT.READ_ONLY;
+ return style;
+ }
+ /**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public String getText () {
+ checkWidget ();
+ return text.getText ();
+ }
+ /**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getTextHeight () {
+ checkWidget ();
+ return text.getLineHeight ();
+ }
+ /**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ *
+ * @return the text limit
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int getTextLimit () {
+ checkWidget ();
+ return text.getTextLimit ();
+ }
+ /**
+ * Gets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @return the number of items that are visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public int getVisibleItemCount () {
+ checkWidget ();
+ return visibleItemCount;
+ }
+ void handleFocus (int type) {
+ if (isDisposed ()) return;
+ switch (type) {
+ case SWT.FocusIn: {
+ if (hasFocus) return;
+ if (getEditable ()) text.selectAll ();
+ hasFocus = true;
+ Shell shell = getShell ();
+ shell.removeListener (SWT.Deactivate, listener);
+ shell.addListener (SWT.Deactivate, listener);
+ Display display = getDisplay ();
+ display.removeFilter (SWT.FocusIn, filter);
+ display.addFilter (SWT.FocusIn, filter);
+ Event e = new Event ();
+ notifyListeners (SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ if (!hasFocus) return;
+ Control focusControl = getDisplay ().getFocusControl ();
+ if (focusControl == arrow || focusControl == table || focusControl == text) return;
+ hasFocus = false;
+ Shell shell = getShell ();
+ shell.removeListener(SWT.Deactivate, listener);
+ Display display = getDisplay ();
+ display.removeFilter (SWT.FocusIn, filter);
+ Event e = new Event ();
+ notifyListeners (SWT.FocusOut, e);
+ break;
+ }
+ }
+ }
+ /**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public int indexOf (String string) {
+ checkWidget ();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return Arrays.asList(getStringsFromTable()).indexOf (string);
+ }
+
+
+ void initAccessible() {
+ AccessibleAdapter accessibleAdapter = new AccessibleAdapter () {
+ @Override
+ public void getName (AccessibleEvent e) {
+ String name = null;
+ Label label = getAssociatedLabel ();
+ if (label != null) {
+ name = stripMnemonic (label.getText());
+ }
+ e.result = name;
+ }
+ @Override
+ public void getKeyboardShortcut(AccessibleEvent e) {
+ String shortcut = null;
+ Label label = getAssociatedLabel ();
+ if (label != null) {
+ String text = label.getText ();
+ if (text != null) {
+ char mnemonic = getMnemonic (text);
+ if (mnemonic != '\0') {
+ shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+ }
+ }
+ }
+ e.result = shortcut;
+ }
+ @Override
+ public void getHelp (AccessibleEvent e) {
+ e.result = getToolTipText ();
+ }
+ };
+ getAccessible ().addAccessibleListener (accessibleAdapter);
+ text.getAccessible ().addAccessibleListener (accessibleAdapter);
+ table.getAccessible ().addAccessibleListener (accessibleAdapter);
+
+ arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() {
+ @Override
+ public void getName (AccessibleEvent e) {
+ e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ @Override
+ public void getKeyboardShortcut (AccessibleEvent e) {
+ e.result = "Alt+Down Arrow"; //$NON-NLS-1$
+ }
+ @Override
+ public void getHelp (AccessibleEvent e) {
+ e.result = getToolTipText ();
+ }
+ });
+
+ getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() {
+ @Override
+ public void getCaretOffset (AccessibleTextEvent e) {
+ e.offset = text.getCaretPosition ();
+ }
+ });
+
+ getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() {
+ @Override
+ public void getChildAtPoint (AccessibleControlEvent e) {
+ Point testPoint = toControl (e.x, e.y);
+ if (getBounds ().contains (testPoint)) {
+ e.childID = ACC.CHILDID_SELF;
+ }
+ }
+
+ @Override
+ public void getLocation (AccessibleControlEvent e) {
+ Rectangle location = getBounds ();
+ Point pt = toDisplay (location.x, location.y);
+ e.x = pt.x;
+ e.y = pt.y;
+ e.width = location.width;
+ e.height = location.height;
+ }
+
+ @Override
+ public void getChildCount (AccessibleControlEvent e) {
+ e.detail = 0;
+ }
+
+ @Override
+ public void getRole (AccessibleControlEvent e) {
+ e.detail = ACC.ROLE_COMBOBOX;
+ }
+
+ @Override
+ public void getState (AccessibleControlEvent e) {
+ e.detail = ACC.STATE_NORMAL;
+ }
+
+ @Override
+ public void getValue (AccessibleControlEvent e) {
+ e.result = getText ();
+ }
+ });
+
+ text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () {
+ @Override
+ public void getRole (AccessibleControlEvent e) {
+ e.detail = getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
+ }
+ });
+
+ arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() {
+ @Override
+ public void getDefaultAction (AccessibleControlEvent e) {
+ e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ }
+ boolean isDropped () {
+ return popup.getVisible ();
+ }
+ @Override
+ public boolean isFocusControl () {
+ checkWidget();
+ if (text.isFocusControl () || arrow.isFocusControl () || table.isFocusControl () || popup.isFocusControl ()) {
+ return true;
+ }
+ return super.isFocusControl ();
+ }
+ void internalLayout (boolean changed) {
+ if (isDropped ()) dropDown (false);
+ Rectangle rect = getClientArea ();
+ int width = rect.width;
+ int height = rect.height;
+ Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
+ image.setBounds (0, 0, 20, height);
+ text.setBounds (20, 0, width - 20 - arrowSize.x, height);
+ arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+ }
+ void listEvent (Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (getShell () != popup.getParent ()) {
+// TableItem[] items = table.getItems ();
+ int selectionIndex = table.getSelectionIndex ();
+ popup = null;
+ table = null;
+ createPopup (selectionIndex);
+ }
+ break;
+ case SWT.FocusIn: {
+ handleFocus (SWT.FocusIn);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1) return;
+ dropDown (false);
+ break;
+ }
+ case SWT.Selection: {
+ int index = table.getSelectionIndex ();
+ if (index == -1) return;
+ image.setImage(table.getItem (index).getImage());
+ text.setText (table.getItem (index).getText());
+ if (getEditable())
+ text.selectAll ();
+ table.setSelection (index);
+ Event e = new Event ();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ e.doit = event.doit;
+ notifyListeners (SWT.Selection, e);
+ event.doit = e.doit;
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ESCAPE:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ event.doit = false;
+ break;
+ }
+ Event e = new Event ();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners (SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event ();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.KeyUp, e);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.ESC) {
+ // Escape key cancels popup list
+ dropDown (false);
+ }
+ if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
+ dropDown (false);
+ }
+ if (event.character == SWT.CR) {
+ // Enter causes default selection
+ dropDown (false);
+ Event e = new Event ();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.DefaultSelection, e);
+ }
+ // At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed ()) break;
+ Event e = new Event();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners(SWT.KeyDown, e);
+ break;
+
+ }
+ }
+ }
+
+ void popupEvent(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ // draw black rectangle around list
+ Rectangle listRect = table.getBounds();
+ Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+ event.gc.setForeground(black);
+ event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
+ break;
+ case SWT.Close:
+ event.doit = false;
+ dropDown (false);
+ break;
+ case SWT.Deactivate:
+ dropDown (false);
+ break;
+ }
+ }
+ @Override
+ public void redraw () {
+ super.redraw();
+ image.redraw();
+ text.redraw();
+ arrow.redraw();
+ if (popup.isVisible()) table.redraw();
+ }
+ @Override
+ public void redraw (int x, int y, int width, int height, boolean all) {
+ super.redraw(x, y, width, height, true);
+ }
+
+ /**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove (int index) {
+ checkWidget();
+ table.remove (index);
+ }
+ /**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove (int start, int end) {
+ checkWidget();
+ table.remove (start, end);
+ }
+ /**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument,
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void remove (String string) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ for (int i = 0, n = table.getItemCount(); i < n; i++) {
+ if (table.getItem(i).getText().equals(string)) {
+ index = i;
+ break;
+ }
+ }
+ remove(index);
+ }
+ /**
+ * Removes all of the items from the receiver's list and clear the
+ * contents of receiver's text field.
+ * <p>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void removeAll () {
+ checkWidget();
+ image.setImage(null);
+ text.setText (""); //$NON-NLS-1$
+ table.removeAll ();
+ }
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+ public void removeModifyListener (ModifyListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Modify, listener);
+ }
+ /**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+ public void removeSelectionListener (SelectionListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection,listener);
+ }
+ /**
+ * Selects the item at the given zero-relative index in the receiver's
+ * list. If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void select (int index) {
+ checkWidget();
+ if (index == -1) {
+ table.deselectAll ();
+ image.setImage(null);
+ text.setText (""); //$NON-NLS-1$
+ return;
+ }
+ if (0 <= index && index < table.getItemCount()) {
+ if (index != getSelectionIndex()) {
+ image.setImage(table.getItem (index).getImage());
+ text.setText (table.getItem (index).getText());
+ if (getEditable())
+ text.selectAll ();
+ table.select (index);
+ table.showSelection ();
+ }
+ }
+ }
+ @Override
+ public void setBackground (Color color) {
+ super.setBackground(color);
+ background = color;
+ if (image != null) image.setBackground(color);
+ if (text != null) text.setBackground(color);
+ if (table != null) table.setBackground(color);
+ if (arrow != null) arrow.setBackground(color);
+ }
+ /**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public void setEditable (boolean editable) {
+ checkWidget ();
+ text.setEditable(editable);
+ }
+ @Override
+ public void setEnabled (boolean enabled) {
+ super.setEnabled(enabled);
+ if (popup != null) popup.setVisible (false);
+ if (image != null) image.setEnabled(enabled);
+ if (text != null) text.setEnabled(enabled);
+ if (arrow != null) arrow.setEnabled(enabled);
+ }
+ @Override
+ public boolean setFocus () {
+ checkWidget();
+ return text.setFocus ();
+ }
+ @Override
+ public void setFont (Font font) {
+ super.setFont (font);
+ this.font = font;
+ text.setFont (font);
+ table.setFont (font);
+ internalLayout (true);
+ }
+ @Override
+ public void setForeground (Color color) {
+ super.setForeground(color);
+ foreground = color;
+ if (image != null) image.setForeground(color);
+ if (text != null) text.setForeground(color);
+ if (table != null) table.setForeground(color);
+ if (arrow != null) arrow.setForeground(color);
+ }
+ /**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument. This is equivalent
+ * to <code>remove</code>'ing the old item at the index, and then
+ * <code>add</code>'ing the new item at that index.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setItem (int index, String string, Image image) {
+ checkWidget();
+ remove(index);
+ add(string,image,index);
+ }
+ /**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setItems (String [] items) {
+ checkWidget ();
+ this.table.removeAll();
+ for (int i = 0, n = items.length; i < n; i++) {
+ add(items[i],null);
+ }
+ if (!getEditable ()) {
+ image.setImage(null);
+ text.setText (""); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note : No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ @Override
+ public void setLayout (Layout layout) {
+ checkWidget ();
+ return;
+ }
+ /**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection.
+ *
+ * @param selection a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setSelection (Point selection) {
+ checkWidget();
+ if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ text.setSelection (selection.x, selection.y);
+ }
+
+ /**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to
+ * display incorrectly.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setText (String string, Image icon) {
+ checkWidget();
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ for (int i = 0, n = table.getItemCount(); i < n; i++) {
+ if (table.getItem(i).getText().equals(string)) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ table.deselectAll ();
+ image.setImage(icon);
+ text.setText (string);
+ return;
+ }
+ image.setImage(icon);
+ text.setText (string);
+ if (getEditable())
+ text.selectAll ();
+ table.setSelection (index);
+ table.showSelection ();
+ }
+
+ /**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+ public void setTextLimit (int limit) {
+ checkWidget();
+ text.setTextLimit (limit);
+ }
+
+ @Override
+ public void setToolTipText (String string) {
+ checkWidget();
+ super.setToolTipText(string);
+ arrow.setToolTipText (string);
+ image.setToolTipText (string);
+ text.setToolTipText (string);
+ }
+
+ @Override
+ public void setVisible (boolean visible) {
+ super.setVisible(visible);
+ if (!visible) popup.setVisible(false);
+ }
+ /**
+ * Sets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @param count the new number of items to be visible
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+ public void setVisibleItemCount (int count) {
+ checkWidget ();
+ if (count < 0) return;
+ visibleItemCount = count;
+ }
+ String stripMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != '&')) index++;
+ if (++index >= length) return string;
+ if (string.charAt (index) != '&') {
+ return string.substring(0, index-1) + string.substring(index, length);
+ }
+ index++;
+ } while (index < length);
+ return string;
+ }
+ void textEvent (Event event) {
+ switch (event.type) {
+ case SWT.FocusIn: {
+ handleFocus (SWT.FocusIn);
+ break;
+ }
+ case SWT.KeyDown: {
+ if (event.character == SWT.CR) {
+ dropDown (false);
+ Event e = new Event ();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.DefaultSelection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed ()) break;
+
+ if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
+ event.doit = false;
+ if ((event.stateMask & SWT.ALT) != 0) {
+ boolean dropped = isDropped ();
+ if (getEditable())
+ text.selectAll ();
+ if (!dropped) setFocus ();
+ dropDown (!dropped);
+ break;
+ }
+
+ int oldIndex = getSelectionIndex ();
+ if (event.keyCode == SWT.ARROW_UP) {
+ select (Math.max (oldIndex - 1, 0));
+ } else {
+ select (Math.min (oldIndex + 1, getItemCount () - 1));
+ }
+ if (oldIndex != getSelectionIndex ()) {
+ Event e = new Event();
+ e.time = event.time;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.Selection, e);
+ }
+ //At this point the widget may have been disposed.
+ // If so, do not continue.
+ if (isDisposed ()) break;
+ }
+
+ Event e = new Event ();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.KeyDown, e);
+ break;
+ }
+ case SWT.KeyUp: {
+ Event e = new Event ();
+ e.time = event.time;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ e.stateMask = event.stateMask;
+ notifyListeners (SWT.KeyUp, e);
+ break;
+ }
+ case SWT.Modify: {
+ table.deselectAll ();
+ Event e = new Event ();
+ e.time = event.time;
+ notifyListeners (SWT.Modify, e);
+ break;
+ }
+ case SWT.MouseDown: {
+ if (event.button != 1) return;
+ if (getEditable ()) return;
+ boolean dropped = isDropped ();
+ text.selectAll ();
+ if (!dropped) setFocus ();
+ dropDown (!dropped);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1) return;
+ if (getEditable ()) return;
+ text.selectAll ();
+ break;
+ }
+ case SWT.Traverse: {
+ switch (event.detail) {
+ case SWT.TRAVERSE_RETURN:
+ case SWT.TRAVERSE_ARROW_PREVIOUS:
+ case SWT.TRAVERSE_ARROW_NEXT:
+ // The enter causes default selection and
+ // the arrow keys are used to manipulate the list contents so
+ // do not use them for traversal.
+ event.doit = false;
+ break;
+ }
+
+ Event e = new Event ();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.character = event.character;
+ e.keyCode = event.keyCode;
+ notifyListeners (SWT.Traverse, e);
+ event.doit = e.doit;
+ event.detail = e.detail;
+ break;
+ }
+ }
+ }
+ } \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
index 7d3e01360..274de1bfa 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
@@ -12,7 +12,7 @@
NewActionProvider_NewMenu_label=&New
NewActionProvider_NewWizardCommandAction_label=&Other...
-NewActionProvider_NewWizardCommandAction_tooltip=Open the New wizard
+NewActionProvider_NewWizardCommandAction_tooltip=Open the New Wizard
# ***** Command Handler *****
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
index cd03965d3..b9083255b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.properties
@@ -37,8 +37,8 @@ context.editor.description=The Target Explorer properties editor is active
# ***** Command contributions *****
command.category.name=Target Explorer Commands
-command.newWizards.name=New Target
-command.newWizards.description=Open the New target wizard
+command.newWizards.name=New
+command.newWizards.description=Open the New Wizard
command.refresh.name=Refresh
command.refresh.description=Refresh the selected configuration
@@ -48,9 +48,11 @@ command.showConsoleView.description=Shows the Console View
command.connect.name=Connect
command.connect.description=Connect the selected configuration
+command.connect.toolbar.description=Connect default configuration
command.disconnect.name=Disconnect
command.disconnect.description=Disconnect the selected configuration
+command.disconnect.toolbar.description=Disconnect default configuration
# ***** Status Handler *****
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
index 7ce4953c9..17160985f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/plugin.xml
@@ -71,6 +71,14 @@
</command>
<command
+ id="org.eclipse.tcf.te.ui.toolbar.command.connect"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.ui.command_Connect"
+ description="%command.connect.toolbar.description"
+ name="%command.connect.name">
+ </command>
+
+ <command
id="org.eclipse.tcf.te.ui.command.disconnect"
categoryId="org.eclipse.tcf.te.ui.commands.category"
helpContextId="org.eclipse.tcf.te.ui.command_Disconnect"
@@ -85,6 +93,14 @@
description="%command.disconnect.description"
name="%command.disconnect.name">
</command>
+
+ <command
+ id="org.eclipse.tcf.te.ui.toolbar.command.disconnect"
+ categoryId="org.eclipse.tcf.te.ui.commands.category"
+ helpContextId="org.eclipse.tcf.te.ui.command_Disconnect"
+ description="%command.disconnect.toolbar.description"
+ name="%command.disconnect.name">
+ </command>
</extension>
<!-- Command image contributions -->
@@ -100,6 +116,11 @@
icon="icons/elcl16/connect.gif">
</image>
<image
+ commandId="org.eclipse.tcf.te.ui.toolbar.command.connect"
+ disabledIcon="icons/dlcl16/connect.gif"
+ icon="icons/elcl16/connect.gif">
+ </image>
+ <image
commandId="org.eclipse.tcf.te.ui.command.disconnect"
disabledIcon="icons/dlcl16/disconnect.gif"
icon="icons/elcl16/disconnect.gif">
@@ -110,6 +131,11 @@
icon="icons/elcl16/disconnect.gif">
</image>
<image
+ commandId="org.eclipse.tcf.te.ui.toolbar.command.disconnect"
+ disabledIcon="icons/dlcl16/disconnect.gif"
+ icon="icons/elcl16/disconnect.gif">
+ </image>
+ <image
commandId="org.eclipse.tcf.te.ui.command.newWizards"
disabledIcon="icons/dlcl16/newtarget_wiz.gif"
icon="icons/elcl16/newtarget_wiz.gif">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractCommandHandler.java
new file mode 100644
index 000000000..3726e5d14
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractCommandHandler.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.ui.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Abstract command handler implementation.
+ */
+public abstract class AbstractCommandHandler extends AbstractHandler {
+
+ /**
+ * Get the Selection for this handler.
+ * @param event The execution event.
+ * @return The current selection.
+ */
+ protected IStructuredSelection getSelection(ExecutionEvent event) {
+ ISelection sel = HandlerUtil.getCurrentSelection(event);
+ if (sel instanceof IStructuredSelection) {
+ return (IStructuredSelection)sel;
+ }
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractEditorCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractEditorCommandHandler.java
deleted file mode 100644
index 50b30870f..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractEditorCommandHandler.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.ui.handler;
-
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog;
-import org.eclipse.tcf.te.ui.nls.Messages;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.part.EditorPart;
-
-/**
- * Connectable command handler implementation.
- */
-public abstract class AbstractEditorCommandHandler extends AbstractHandler implements IExecutableExtension {
-
- protected static final String PARAM_HANDLE_DIRTY = "handleDirty"; //$NON-NLS-1$
-
- protected boolean handleDirty = false;
-
- /* (non-Javadoc)
- * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- if (handleDirty(event)) {
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- if (part instanceof EditorPart) {
- if (((EditorPart)part).isDirty()) {
- int result = OptionalMessageDialog.openYesNoCancelDialog(
- HandlerUtil.getActiveShell(event),
- Messages.AbstractEditorCommandHandler_saveDialog_title,
- NLS.bind(Messages.AbstractEditorCommandHandler_saveDialog_message, ((EditorPart)part).getTitle()),
- null, null);
- switch (result) {
- case IDialogConstants.YES_ID:
- ((EditorPart)part).doSave(null);
- break;
- case IDialogConstants.CANCEL_ID:
- return null;
- }
- }
- }
- }
-
- return internalExecute(event);
- }
-
- protected abstract Object internalExecute(ExecutionEvent event) throws ExecutionException;
-
- protected boolean handleDirty(ExecutionEvent event) {
- return handleDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (data instanceof Map) {
- Map<?,?> dataMap = (Map<?,?>)data;
- if (dataMap.get(PARAM_HANDLE_DIRTY) instanceof String) {
- String value = dataMap.get(PARAM_HANDLE_DIRTY).toString().trim();
- this.handleDirty = Boolean.parseBoolean(value);
- }
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractStepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractStepperCommandHandler.java
index afefc5ffd..623defd08 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractStepperCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/AbstractStepperCommandHandler.java
@@ -16,9 +16,9 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -41,7 +41,7 @@ import org.eclipse.ui.part.EditorPart;
/**
* Stepper command handler implementation.
*/
-public abstract class AbstractStepperCommandHandler extends AbstractEditorCommandHandler {
+public abstract class AbstractStepperCommandHandler extends AbstractCommandHandler implements IExecutableExtension {
protected String operation = null;
protected String adaptTo = null;
@@ -52,12 +52,10 @@ public abstract class AbstractStepperCommandHandler extends AbstractEditorComman
public static final String PART_ID_PROJECT_VIEW = "org.eclipse.ui.navigator.ProjectExplorer"; //$NON-NLS-1$
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.handler.AbstractEditorCommandHandler#internalExecute(org.eclipse.core.commands.ExecutionEvent)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
- protected Object internalExecute(ExecutionEvent event) throws ExecutionException {
- Assert.isNotNull(operation);
-
+ public Object execute(ExecutionEvent event) throws ExecutionException {
IPropertiesContainer data = getData(event);
if (data == null) {
return null;
@@ -109,7 +107,8 @@ public abstract class AbstractStepperCommandHandler extends AbstractEditorComman
* @param event The event.
* @return The selection.
*/
- protected IStructuredSelection getSelection(ExecutionEvent event) {
+ @Override
+ protected IStructuredSelection getSelection(ExecutionEvent event) {
// Get the current selection
ISelection selection = HandlerUtil.getCurrentSelection(event);
@@ -164,7 +163,6 @@ public abstract class AbstractStepperCommandHandler extends AbstractEditorComman
*/
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.setInitializationData(config, propertyName, data);
if (data instanceof Map) {
Map<?,?> dataMap = (Map<?,?>)data;
if (dataMap.get("operation") instanceof String) { //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ConnectableCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ConnectableCommandHandler.java
index a5ef41047..3f40861bf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ConnectableCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/ConnectableCommandHandler.java
@@ -9,43 +9,109 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.handler;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.core.utils.ConnectStateHelper;
+import org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog;
+import org.eclipse.tcf.te.ui.nls.Messages;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
/**
* Connectable command handler implementation.
*/
-public class ConnectableCommandHandler extends AbstractEditorCommandHandler {
+public class ConnectableCommandHandler extends AbstractCommandHandler implements IExecutableExtension {
protected static final String PARAM_ACTION = "action"; //$NON-NLS-1$
+ protected static final String PARAM_HANDLE_DIRTY = "handleDirty"; //$NON-NLS-1$
protected int action = IConnectable.STATE_UNKNOWN;
+ protected boolean handleDirty = false;
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.handler.AbstractEditorCommandHandler#internalExecute(org.eclipse.core.commands.ExecutionEvent)
+ * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
- public Object internalExecute(ExecutionEvent event) throws ExecutionException {
- Assert.isTrue(action >= 0);
-
- Object element = null;
- if ("org.eclipse.tcf.te.ui.views.Editor".equals(HandlerUtil.getActiveEditorId(event))) { //$NON-NLS-1$
- element = HandlerUtil.getActiveEditorInput(event);
- } else {
- element = HandlerUtil.getCurrentSelection(event);
- if (element instanceof IStructuredSelection) element = ((IStructuredSelection)element).getFirstElement();
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+
+ List<IConnectable> connectables = getConnectables(selection);
+
+ if (handleDirty) {
+ for (IEditorReference ref : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) {
+ if (ref.isDirty()) {
+ try {
+ IConnectable connectable = getConnectable(ref.getEditorInput());
+ if (connectable != null && connectables.contains(connectable)) {
+ int result = OptionalMessageDialog.openYesNoCancelDialog(
+ HandlerUtil.getActiveShell(event),
+ Messages.AbstractEditorCommandHandler_saveDialog_title,
+ NLS.bind(Messages.AbstractEditorCommandHandler_saveDialog_message, ref.getTitle()),
+ null, null);
+ switch (result) {
+ case IDialogConstants.YES_ID:
+ ref.getEditor(true).doSave(null);
+ break;
+ case IDialogConstants.CANCEL_ID:
+ return null;
+ }
+ }
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ return internalExecute(event, selection, connectables);
+ }
+
+ public Object internalExecute(ExecutionEvent event, IStructuredSelection selection, List<IConnectable> connectables) {
+ for (IConnectable connectable : connectables) {
+ if (connectable.isConnectStateChangeAllowed(action)) {
+ connectable.changeConnectState(action, null, null);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the connectables out of the selection.
+ * @param selection The selection
+ * @return The connectables within the given selection.
+ */
+ protected List<IConnectable> getConnectables(IStructuredSelection selection) {
+ List<IConnectable> connectables = new ArrayList<IConnectable>();
+
+ Iterator<Object> it = selection.iterator();
+ while (it.hasNext()) {
+ Object element = it.next();
+ IConnectable connectable = getConnectable(element);
+ if (connectable != null && !connectables.contains(connectable)) {
+ connectables.add(connectable);
+ }
}
+
+ return connectables;
+ }
+
+ protected IConnectable getConnectable(Object element) {
IConnectable connectable = null;
if (element instanceof IConnectable) {
connectable = (IConnectable)element;
@@ -56,13 +122,8 @@ public class ConnectableCommandHandler extends AbstractEditorCommandHandler {
if (connectable == null) {
connectable = (IConnectable)Platform.getAdapterManager().getAdapter(element, IConnectable.class);
}
- if (connectable != null) {
- if (connectable.isConnectStateChangeAllowed(action)) {
- connectable.changeConnectState(action, null, null);
- }
- }
- return null;
+ return connectable;
}
/* (non-Javadoc)
@@ -70,13 +131,16 @@ public class ConnectableCommandHandler extends AbstractEditorCommandHandler {
*/
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.setInitializationData(config, propertyName, data);
if (data instanceof Map) {
Map<?,?> dataMap = (Map<?,?>)data;
if (dataMap.get(PARAM_ACTION) instanceof String) {
String stateStr = dataMap.get(PARAM_ACTION).toString().trim();
this.action = ConnectStateHelper.getConnectAction(stateStr);
}
+ if (dataMap.get(PARAM_HANDLE_DIRTY) instanceof String) {
+ String value = dataMap.get(PARAM_HANDLE_DIRTY).toString().trim();
+ this.handleDirty = Boolean.parseBoolean(value);
+ }
}
}
}

Back to the top