Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-07 17:55:48 -0500
committerEugene Tarassov2011-11-07 17:55:48 -0500
commitdef2f896111edab88f73a71beecf9c794a9b82ed (patch)
tree803d93d8fc0b2b4284f69fbc7fbdccc7459d6944
parent28881ad0ce19319d4e9470367faf2ddbe3859689 (diff)
parentc00b4a5d2579c71cd41e3baa51f23c4322ef8ea8 (diff)
downloadorg.eclipse.tcf-def2f896111edab88f73a71beecf9c794a9b82ed.tar.gz
org.eclipse.tcf-def2f896111edab88f73a71beecf9c794a9b82ed.tar.xz
org.eclipse.tcf-def2f896111edab88f73a71beecf9c794a9b82ed.zip
Merge branch 'master' of ssh://git.eclipse.org/gitroot/tcf/org.eclipse.tcf
-rw-r--r--python/src/tcf/services/local/LocatorService.py6
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.runtime/src/org/eclipse/tm/te/runtime/interfaces/workingsets/IWorkingSetElement.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.locator/src/org/eclipse/tm/te/tcf/locator/nodes/PeerModel.java47
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/IConfigurationPanel.java33
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/ILauncherDelegate.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/panels/AbstractConfigurationPanel.java50
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/icons/obj16/workingset.gifbin159 -> 906 bytes
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml24
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java84
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetNameIDs.java25
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewRoot.java39
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java63
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolder.java137
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderAdapterFactory.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderFactory.java36
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java104
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java46
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/AbstractWorkingSetWizardPage.java183
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/TargetWorkingSetPage.java95
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeArrayContentProvider.java62
27 files changed, 1076 insertions, 204 deletions
diff --git a/python/src/tcf/services/local/LocatorService.py b/python/src/tcf/services/local/LocatorService.py
index 8cff0c797..5d8f43bc2 100644
--- a/python/src/tcf/services/local/LocatorService.py
+++ b/python/src/tcf/services/local/LocatorService.py
@@ -185,13 +185,13 @@ class LocatorService(locator.LocatorService):
if not LocatorService.addr_request:
service._addr_cache_lock.wait(locator.DATA_RETENTION_PERIOD)
msec = int(time.time() * 1000)
- for a in LocatorService.addr_cache.values():
+ for host, a in LocatorService.addr_cache.items():
if a.time_stamp + locator.DATA_RETENTION_PERIOD * 10 < msec:
if a.used:
if itemSet is None: itemSet = set()
itemSet.add(a)
else:
- LocatorService.addr_cache.remove(a)
+ del LocatorService.addr_cache[host]
LocatorService.addr_request = False
if itemSet is not None:
for a in itemSet:
@@ -205,7 +205,7 @@ class LocatorService(locator.LocatorService):
a.address = None
else:
a.address = InetAddress(a.host, addr)
- a.time_stamp = time
+ a.time_stamp = msec
a.used = False
except Exception as x:
service._log("Unhandled exception in TCF discovery DNS lookup thread", x)
diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime/src/org/eclipse/tm/te/runtime/interfaces/workingsets/IWorkingSetElement.java b/target_explorer/plugins/org.eclipse.tm.te.runtime/src/org/eclipse/tm/te/runtime/interfaces/workingsets/IWorkingSetElement.java
index d5bfaf539..c95f859c6 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.runtime/src/org/eclipse/tm/te/runtime/interfaces/workingsets/IWorkingSetElement.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.runtime/src/org/eclipse/tm/te/runtime/interfaces/workingsets/IWorkingSetElement.java
@@ -18,4 +18,14 @@ import org.eclipse.core.runtime.IAdaptable;
*/
public interface IWorkingSetElement extends IAdaptable {
+ /**
+ * Returns the working set element id.
+ * <p>
+ * The working set element id must be unique and persisted through out multiple session. This id
+ * is used to identify the working set element at restarting the Target Explorer after a session
+ * shutdown.
+ *
+ * @return The working set element id.
+ */
+ public String getElementId();
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.locator/src/org/eclipse/tm/te/tcf/locator/nodes/PeerModel.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.locator/src/org/eclipse/tm/te/tcf/locator/nodes/PeerModel.java
index c655253aa..57d67b54a 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.locator/src/org/eclipse/tm/te/tcf/locator/nodes/PeerModel.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.locator/src/org/eclipse/tm/te/tcf/locator/nodes/PeerModel.java
@@ -30,6 +30,8 @@ import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
public class PeerModel extends PropertiesContainer implements IPeerModel, IWorkingSetElement {
// Reference to the parent locator model
private final ILocatorModel parentModel;
+ // Reference to the element id (cached for performance optimization)
+ private String elementId;
/**
* Constructor.
@@ -57,6 +59,10 @@ public class PeerModel extends PropertiesContainer implements IPeerModel, IWorki
// constructor.
setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
+ // Initialize the element id
+ elementId = peer.getID();
+ Assert.isNotNull(elementId);
+
// Enable change events
setChangeEventsEnabled(true);
}
@@ -86,13 +92,21 @@ public class PeerModel extends PropertiesContainer implements IPeerModel, IWorki
}
/* (non-Javadoc)
+ * @see org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement#getElementId()
+ */
+ @Override
+ public String getElementId() {
+ return elementId;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
*/
@Override
public Object getAdapter(final Class adapter) {
// NOTE: The getAdapter(...) method can be invoked from many place and
// many threads where we cannot control the calls. Therefore, this
- // method is the only one which is allowed to call from any thread.
+ // method is allowed be called from any thread.
final Object[] object = new Object[1];
if (Protocol.isDispatchThread()) {
object[0] = doGetAdapter(adapter);
@@ -157,6 +171,25 @@ public class PeerModel extends PropertiesContainer implements IPeerModel, IWorki
}
/* (non-Javadoc)
+ * @see org.eclipse.tm.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PeerModel) {
+ return getElementId().equals(((PeerModel)obj).getElementId());
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.runtime.properties.PropertiesContainer#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return getElementId().hashCode();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tm.te.runtime.properties.PropertiesContainer#getProperties()
*/
@Override
@@ -185,6 +218,11 @@ public class PeerModel extends PropertiesContainer implements IPeerModel, IWorki
protected void postSetProperties(Map<String, Object> properties) {
Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(properties);
+ Assert.isNotNull(getPeer());
+
+ // New properties applied. Update the element id
+ elementId = getPeer().getID();
+ Assert.isNotNull(elementId);
if (changeEventsEnabled()) {
final IModelListener[] listeners = parentModel.getListener();
@@ -209,6 +247,13 @@ public class PeerModel extends PropertiesContainer implements IPeerModel, IWorki
public void postSetProperty(String key, Object value, Object oldValue) {
Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(key);
+ Assert.isNotNull(getPeer());
+
+ // If the peer instance changed, update the element id
+ if (IPeerModelProperties.PROP_INSTANCE.equals(key)) {
+ elementId = getPeer().getID();
+ Assert.isNotNull(elementId);
+ }
// Notify registered listeners that the peer changed. Property
// changes for property slots ending with ".silent" are suppressed.
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java
index 9cf6e1a25..1b5ec1200 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.terminals.ui/src/org/eclipse/tm/te/tcf/terminals/ui/launcher/LauncherDelegate.java
@@ -22,7 +22,7 @@ import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tm.te.tcf.terminals.core.interfaces.launcher.ITerminalsLauncher;
import org.eclipse.tm.te.tcf.terminals.core.launcher.TerminalsLauncher;
import org.eclipse.tm.te.ui.controls.BaseDialogPageControl;
-import org.eclipse.tm.te.ui.controls.interfaces.IWizardConfigurationPanel;
+import org.eclipse.tm.te.ui.terminals.interfaces.IConfigurationPanel;
import org.eclipse.tm.te.ui.terminals.launcher.AbstractLauncherDelegate;
/**
@@ -34,7 +34,7 @@ public class LauncherDelegate extends AbstractLauncherDelegate {
* @see org.eclipse.tm.te.ui.terminals.interfaces.ILauncherDelegate#getPanel(org.eclipse.tm.te.ui.controls.BaseDialogPageControl)
*/
@Override
- public IWizardConfigurationPanel getPanel(BaseDialogPageControl parentControl) {
+ public IConfigurationPanel getPanel(BaseDialogPageControl parentControl) {
return null;
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/META-INF/MANIFEST.MF
index 7300e44e4..9a545e543 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/META-INF/MANIFEST.MF
@@ -30,9 +30,11 @@ Export-Package: org.eclipse.tm.te.ui.terminals.actions,
org.eclipse.tm.te.ui.terminals.internal;x-internal:=true,
org.eclipse.tm.te.ui.terminals.internal.dialogs;x-internal:=true,
org.eclipse.tm.te.ui.terminals.internal.handler;x-internal:=true,
+ org.eclipse.tm.te.ui.terminals.internal.tracing;x-internal:=true,
org.eclipse.tm.te.ui.terminals.launcher,
org.eclipse.tm.te.ui.terminals.manager,
org.eclipse.tm.te.ui.terminals.nls;x-internal:=true,
+ org.eclipse.tm.te.ui.terminals.panels,
org.eclipse.tm.te.ui.terminals.services,
org.eclipse.tm.te.ui.terminals.streams,
org.eclipse.tm.te.ui.terminals.tabs,
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/IConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/IConfigurationPanel.java
new file mode 100644
index 000000000..e9de5c79e
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/IConfigurationPanel.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.terminals.interfaces;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tm.te.ui.controls.interfaces.IWizardConfigurationPanel;
+
+/**
+ * Terminal launcher configuration panel.
+ */
+public interface IConfigurationPanel extends IWizardConfigurationPanel {
+
+ /**
+ * Set the selection to the configuration panel.
+ *
+ * @param selection The selection or <code>null</code>.
+ */
+ public void setSelection(ISelection selection);
+
+ /**
+ * Returns the selection associated with the configuration panel.
+ *
+ * @return The selection or <code>null</code>.
+ */
+ public ISelection getSelection();
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/ILauncherDelegate.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/ILauncherDelegate.java
index 3f13c44e1..f28f8bb4b 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/ILauncherDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/interfaces/ILauncherDelegate.java
@@ -14,7 +14,6 @@ import org.eclipse.tm.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tm.te.runtime.interfaces.extensions.IExecutableExtension;
import org.eclipse.tm.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tm.te.ui.controls.BaseDialogPageControl;
-import org.eclipse.tm.te.ui.controls.interfaces.IWizardConfigurationPanel;
/**
* Terminal launcher delegate.
@@ -48,7 +47,7 @@ public interface ILauncherDelegate extends IExecutableExtension {
* @param parentControl The parent control. Must not be <code>null</code>.
* @return The configuration panel instance or <code>null</code>
*/
- public IWizardConfigurationPanel getPanel(BaseDialogPageControl parentControl);
+ public IConfigurationPanel getPanel(BaseDialogPageControl parentControl);
/**
* Execute the terminal launch.
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java
index b842944e3..584d66e2b 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/internal/dialogs/LaunchTerminalSettingsDialog.java
@@ -36,13 +36,14 @@ import org.eclipse.tm.te.runtime.properties.PropertiesContainer;
import org.eclipse.tm.te.ui.controls.BaseDialogPageControl;
import org.eclipse.tm.te.ui.controls.BaseWizardConfigurationPanelControl;
import org.eclipse.tm.te.ui.controls.interfaces.IWizardConfigurationPanel;
-import org.eclipse.tm.te.ui.controls.panels.AbstractWizardConfigurationPanel;
import org.eclipse.tm.te.ui.jface.dialogs.CustomTrayDialog;
import org.eclipse.tm.te.ui.swt.SWTControlUtil;
import org.eclipse.tm.te.ui.terminals.help.IContextHelpIds;
+import org.eclipse.tm.te.ui.terminals.interfaces.IConfigurationPanel;
import org.eclipse.tm.te.ui.terminals.interfaces.ILauncherDelegate;
import org.eclipse.tm.te.ui.terminals.launcher.LauncherDelegateManager;
import org.eclipse.tm.te.ui.terminals.nls.Messages;
+import org.eclipse.tm.te.ui.terminals.panels.AbstractConfigurationPanel;
import org.eclipse.tm.te.ui.wizards.interfaces.ISharedDataWizardPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
@@ -91,7 +92,7 @@ public class LaunchTerminalSettingsDialog extends CustomTrayDialog {
/**
* An empty terminal settings panel.
*/
- protected class EmptySettingsPanel extends AbstractWizardConfigurationPanel {
+ protected class EmptySettingsPanel extends AbstractConfigurationPanel {
/**
* Constructor.
@@ -198,8 +199,11 @@ public class LaunchTerminalSettingsDialog extends CustomTrayDialog {
ILauncherDelegate delegate = label2delegate.get(terminalLabel);
Assert.isNotNull(delegate);
// Get the wizard configuration panel instance
- IWizardConfigurationPanel configPanel = delegate.getPanel(settings);
+ IConfigurationPanel configPanel = delegate.getPanel(settings);
if (configPanel == null) configPanel = new EmptySettingsPanel(settings);
+ // Push the selection to the configuration panel
+ Assert.isNotNull(configPanel);
+ configPanel.setSelection(getSelection());
// Add it
settings.addConfigurationPanel(terminalLabel, configPanel);
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/panels/AbstractConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/panels/AbstractConfigurationPanel.java
new file mode 100644
index 000000000..caa239469
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.terminals/src/org/eclipse/tm/te/ui/terminals/panels/AbstractConfigurationPanel.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.terminals.panels;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tm.te.ui.controls.BaseDialogPageControl;
+import org.eclipse.tm.te.ui.controls.panels.AbstractWizardConfigurationPanel;
+import org.eclipse.tm.te.ui.terminals.interfaces.IConfigurationPanel;
+
+/**
+ * Abstract terminal configuration panel implementation.
+ */
+public abstract class AbstractConfigurationPanel extends AbstractWizardConfigurationPanel implements IConfigurationPanel {
+ // The selection
+ private ISelection selection;
+
+ /**
+ * Constructor.
+ *
+ * @param parentControl The parent control. Must not be <code>null</code>!
+ */
+ public AbstractConfigurationPanel(BaseDialogPageControl parentControl) {
+ super(parentControl);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.terminals.interfaces.IConfigurationPanel#setSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.terminals.interfaces.IConfigurationPanel#getSelection()
+ */
+ @Override
+ public ISelection getSelection() {
+ return selection;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/icons/obj16/workingset.gif b/target_explorer/plugins/org.eclipse.tm.te.ui.views/icons/obj16/workingset.gif
index fbc00a9cc..549f74ced 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/icons/obj16/workingset.gif
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/icons/obj16/workingset.gif
Binary files differ
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
index 6189a4a70..ca842b0c3 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
@@ -53,6 +53,9 @@
<viewerContentBinding viewerId="org.eclipse.tm.te.ui.views.TargetExplorer">
<includes>
+ <contentExtension
+ isRoot="true"
+ pattern="org.eclipse.tm.te.ui.views.navigator.workingSets"/>
<contentExtension pattern="org.eclipse.tm.te.ui.views.navigator.*"/>
</includes>
</viewerContentBinding>
@@ -167,13 +170,32 @@
<!-- Working Set contributions -->
<extension point="org.eclipse.ui.workingSets">
<workingSet
+ elementAdapterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementAdapter"
icon="icons/obj16/workingset.gif"
id="org.eclipse.tm.te.ui.views.workingset"
name="%workingset.name"
- pageClass="org.eclipse.tm.te.ui.views.workingsets.pages.TargetWorkingSetPage">
+ pageClass="org.eclipse.tm.te.ui.views.workingsets.pages.TargetWorkingSetPage"
+ updaterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater">
</workingSet>
</extension>
+<!-- Element factories -->
+ <extension point="org.eclipse.ui.elementFactories">
+ <factory
+ class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolderFactory"
+ id="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolderFactory">
+ </factory>
+ </extension>
+
+<!-- Adapter factories -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolder"
+ class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolderAdapterFactory">
+ <adapter type="org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement"/>
+ </factory>
+ </extension>
+
<!-- Target Explorer menu contributions -->
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.tm.te.ui.views.TargetExplorer#Popup?after=group.properties">
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java
index d3a09b52c..95db12c91 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java
@@ -15,7 +15,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.tm.te.ui.views.activator.UIPlugin;
-import org.eclipse.tm.te.ui.views.internal.View;
+import org.eclipse.tm.te.ui.views.internal.ViewRoot;
import org.eclipse.tm.te.ui.views.nls.Messages;
import org.eclipse.tm.te.ui.views.workingsets.WorkingSetFilter;
import org.eclipse.tm.te.ui.views.workingsets.WorkingSetsContentProvider;
@@ -212,7 +212,7 @@ public class WorkingSetActionProvider extends CommonActionProvider {
viewer = (CommonViewer) site.getStructuredViewer();
contentService = site.getContentService();
filterService = (NavigatorFilterService) contentService.getFilterService();
- originalViewerInput = ((View)viewer.getCommonNavigator()).getRoot();
+ originalViewerInput = ViewRoot.getInstance();
extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
@@ -244,8 +244,7 @@ public class WorkingSetActionProvider extends CommonActionProvider {
if (workingSetName != null && workingSetName.length() > 0) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
workingSet = workingSetManager.getWorkingSet(workingSetName);
- } else if (PlatformUI.getPreferenceStore().getBoolean(
- IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) {
+ } else if (PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) {
// use the window set by default if the global preference is set
workingSet = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getAggregateWorkingSet();
}
@@ -256,11 +255,9 @@ public class WorkingSetActionProvider extends CommonActionProvider {
}
/* default */ void setWorkingSetFilter(IWorkingSet workingSet) {
- setWorkingSetFilter(workingSet, FIRST_TIME);
+ setWorkingSetFilter(workingSet, true);
}
- private static final boolean FIRST_TIME = true;
-
private void setWorkingSetFilter(IWorkingSet workingSet, boolean firstTime) {
WorkingSetFilter workingSetFilter = null;
ViewerFilter[] filters = viewer.getFilters();
@@ -274,7 +271,7 @@ public class WorkingSetActionProvider extends CommonActionProvider {
if (firstTime) {
filterService.addActiveFilterIds(new String[] { WORKING_SET_FILTER_ID });
filterService.updateViewer();
- setWorkingSetFilter(workingSet, !FIRST_TIME);
+ setWorkingSetFilter(workingSet, false);
return;
}
@@ -284,7 +281,7 @@ public class WorkingSetActionProvider extends CommonActionProvider {
UIPlugin.getDefault().getLog().log(status);
return;
}
- workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet);
+ workingSetFilter.setWorkingSet(emptyWorkingSet || !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) ? null : workingSet);
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java
new file mode 100644
index 000000000..f6c968273
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.events;
+
+import java.util.EventObject;
+
+import org.eclipse.tm.te.runtime.activator.CoreBundleActivator;
+import org.eclipse.tm.te.runtime.interfaces.tracing.ITraceIds;
+
+/**
+ * Target Explorer view viewer change event implementation.
+ */
+public class ViewerContentChangeEvent extends EventObject {
+ private static final long serialVersionUID = 7168841012111347036L;
+
+ private String eventId;
+
+ /**
+ * Event id used if elements got directly added to the viewer.
+ */
+ public static final String ADD = "add"; //$NON-NLS-1$
+
+ /**
+ * Event id used if elements got directly removed the viewer.
+ */
+ public static final String REMOVE = "remove"; //$NON-NLS-1$
+
+ /**
+ * Event id used if the viewer got refreshed.
+ */
+ public static final String REFRESH = "refresh"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param source The source object. Must not be <code>null</code>.
+ * @param eventId The event id. Must not be <code>null</code>.
+ *
+ * @exception IllegalArgumentException if eventId == null.
+ */
+ public ViewerContentChangeEvent(Object source, String eventId) {
+ super(source);
+
+ if (eventId == null) throw new IllegalArgumentException("null eventId"); //$NON-NLS-1$
+ this.eventId = eventId;
+ }
+
+ /**
+ * Returns the event id.
+ *
+ * @return The event id.
+ */
+ public final String getEventId() {
+ return eventId;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.EventObject#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder toString = new StringBuilder(getClass().getName());
+
+ String prefix = ""; //$NON-NLS-1$
+ // if tracing the event, formating them a little bit better readable.
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_EVENTS))
+ prefix = "\n\t\t"; //$NON-NLS-1$
+
+ toString.append(prefix + "{eventId="); //$NON-NLS-1$
+ toString.append(eventId);
+ toString.append("," + prefix + "source="); //$NON-NLS-1$ //$NON-NLS-2$
+ toString.append(source);
+ toString.append("}"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetNameIDs.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetNameIDs.java
new file mode 100644
index 000000000..598409bd4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetNameIDs.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.interfaces.workingsets;
+
+/**
+ * Name and IDs used by the working set implementation.
+ */
+public interface IWorkingSetNameIDs {
+
+ /** The element factory id.*/
+ String FACTORY_ID = "factoryId"; //$NON-NLS-1$
+
+ /** The attribute to store the working set element's id. */
+ String ATTR_ELEMENTID = "elementId"; //$NON-NLS-1$
+
+ /** The attribute to store the working set's name. */
+ String ATTR_WORKINGSET_NAME = "workingSetName"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
index fb5dce085..7324152b1 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
@@ -17,7 +17,6 @@ import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IToolBarManager;
@@ -25,6 +24,7 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tm.te.ui.views.activator.UIPlugin;
import org.eclipse.tm.te.ui.views.interfaces.IRoot;
@@ -41,6 +41,7 @@ import org.eclipse.ui.internal.navigator.framelist.FrameList;
import org.eclipse.ui.internal.navigator.framelist.TreeFrame;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonActionConstants;
@@ -51,9 +52,6 @@ import org.eclipse.ui.navigator.ICommonActionConstants;
*/
@SuppressWarnings("restriction")
public class View extends CommonNavigator {
- // The root object instance associated with this view instance
- private final IRoot root;
-
// The view root mode
private int rootMode = IUIConstants.MODE_NORMAL;
@@ -64,30 +62,9 @@ public class View extends CommonNavigator {
private String workingSetLabel;
/**
- * Target Explorer root node implementation
- */
- public static class Root extends PlatformObject implements IRoot {
- /**
- * Constructor.
- */
- public Root() {
- }
- }
-
- /**
* Constructor.
*/
public View() {
- root = new Root();
- }
-
- /**
- * Returns the root object.
- *
- * @return The root object.
- */
- public final IRoot getRoot() {
- return root;
}
/* (non-Javadoc)
@@ -95,7 +72,7 @@ public class View extends CommonNavigator {
*/
@Override
protected Object getInitialInput() {
- return root;
+ return ViewRoot.getInstance();
}
/**
@@ -141,6 +118,14 @@ public class View extends CommonNavigator {
}
/* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#createCommonViewerObject(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected CommonViewer createCommonViewerObject(Composite parent) {
+ return new ViewViewer(getViewSite().getId(), parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewRoot.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewRoot.java
new file mode 100644
index 000000000..f64218cd5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewRoot.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.internal;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.tm.te.ui.views.interfaces.IRoot;
+
+/**
+ * Target Explorer view root node implementation
+ */
+public class ViewRoot extends PlatformObject implements IRoot {
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static ViewRoot instance = new ViewRoot();
+ }
+
+ /**
+ * Returns the singleton view root instance.
+ */
+ public static ViewRoot getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /**
+ * Constructor.
+ */
+ /* default */ ViewRoot() {
+ }
+} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
new file mode 100644
index 000000000..735eaf8f5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.internal;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tm.te.runtime.events.EventManager;
+import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Target Explorer common viewer implementation.
+ */
+public class ViewViewer extends CommonViewer {
+
+ /**
+ * Constructor.
+ *
+ * @param viewerId
+ * An id tied to the extensions that is used to focus specific
+ * content to a particular instance of the Common Navigator
+ * @param parent
+ * A Composite parent to contain the actual SWT widget
+ * @param style
+ * A style mask that will be used to create the TreeViewer
+ * Composite.
+ */
+ public ViewViewer(String viewerId, Composite parent, int style) {
+ super(viewerId, parent, style);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#add(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void add(Object parentElement, Object[] childElements) {
+ super.add(parentElement, childElements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.ADD);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#remove(java.lang.Object[])
+ */
+ @Override
+ public void remove(Object[] elements) {
+ super.remove(elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void remove(Object parent, Object[] elements) {
+ super.remove(parent, elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object)
+ */
+ @Override
+ public void refresh(Object element) {
+ super.refresh(element);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object, boolean)
+ */
+ @Override
+ public void refresh(Object element, boolean updateLabels) {
+ super.refresh(element, updateLabels);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
+ EventManager.getInstance().fireEvent(event);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java
new file mode 100644
index 000000000..798684513
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementAdapter.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetElementAdapter;
+
+/**
+ * Working set element adapter implementation.
+ */
+public class WorkingSetElementAdapter implements IWorkingSetElementAdapter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetElementAdapter#adaptElements(org.eclipse.ui.IWorkingSet, org.eclipse.core.runtime.IAdaptable[])
+ */
+ @Override
+ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
+ List<IAdaptable> adapted = new ArrayList<IAdaptable>();
+
+ // All elements of a target explorer working set needs to
+ // be of type WorkingSetElementHolder
+ for (IAdaptable adaptable : elements) {
+ if (adaptable instanceof WorkingSetElementHolder) {
+ adapted.add(adaptable);
+ } else {
+ IWorkingSetElement element = null;
+ if (adaptable instanceof IWorkingSetElement) {
+ element = (IWorkingSetElement) adaptable;
+ } else {
+ element = (IWorkingSetElement) adaptable.getAdapter(IWorkingSetElement.class);
+ }
+ // Create the WorkingSetElementHolder for the element
+ if (element != null) {
+ WorkingSetElementHolder holder = new WorkingSetElementHolder(ws.getName(), element.getElementId());
+ holder.setElement(element);
+ adapted.add(holder);
+ }
+ }
+ }
+
+ return adapted.toArray(new IAdaptable[adapted.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetElementAdapter#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolder.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolder.java
new file mode 100644
index 000000000..3d4154356
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolder.java
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.tm.te.ui.views.interfaces.workingsets.IWorkingSetNameIDs;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * A WorkingSetElementHolder is a place holder for an {@link IWorkingSetElement}. It contains the
+ * working set element's id and its working set name that it belongs to. A WorkingSetElementHolder
+ * can only belong to one working set, while multiple WorkingSetElementHolder which have a same
+ * working set element's id. That means a working set element can be added to multiple working sets
+ * at the same time.
+ * <p>
+ * A WorkingSetElementHolder instance can be persisted and restored by an element factory.
+ */
+public final class WorkingSetElementHolder extends PlatformObject implements IPersistableElement {
+ // The working set element's id.
+ private String elementId;
+ // The working set's name that it belongs to.
+ private String wsName;
+ // The working set element
+ private IWorkingSetElement element;
+
+ /**
+ * Create an empty holder.
+ */
+ public WorkingSetElementHolder() {
+ }
+
+ /**
+ * Create an holder with a specified working set element's id and and a working set name.
+ *
+ * @param wsName The working set name.
+ * @param elementId The working set element's id.
+ */
+ public WorkingSetElementHolder(String wsName, String elementId) {
+ this.elementId = elementId;
+ this.wsName = wsName;
+ }
+
+ /**
+ * Set the working set element's id.
+ *
+ * @param id The working set element's id.
+ */
+ public void setElementId(String id) {
+ this.elementId = id;
+ }
+
+ /**
+ * Get the working set element's id.
+ *
+ * @return The working set element's id.
+ */
+ public String getElementId() {
+ return elementId;
+ }
+
+ /**
+ * Set the working set's name.
+ *
+ * @param name The working set name.
+ */
+ public void setWorkingSetName(String name) {
+ this.wsName = name;
+ }
+
+ /**
+ * Get the working set's name.
+ *
+ * @return The working set's name.
+ */
+ public String getWorkingSetName() {
+ return wsName;
+ }
+
+ /**
+ * Set the working set element.
+ *
+ * @param element The working set element.
+ */
+ public void setElement(IWorkingSetElement element) {
+ this.element = element;
+ }
+
+ /**
+ * Get the working set element.
+ *
+ * @return The working set element.
+ */
+ public IWorkingSetElement getElement() {
+ return element;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+ */
+ @Override
+ public String getFactoryId() {
+ return "org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolderFactory"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento memento) {
+ memento.putString(IWorkingSetNameIDs.FACTORY_ID, getFactoryId());
+ memento.putString(IWorkingSetNameIDs.ATTR_ELEMENTID, elementId);
+ memento.putString(IWorkingSetNameIDs.ATTR_WORKINGSET_NAME, wsName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IPersistableElement.class.equals(adapter)) {
+ return this;
+ }
+ if (IWorkingSetElement.class.equals(adapter)) {
+ return element;
+ }
+ return super.getAdapter(adapter);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderAdapterFactory.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderAdapterFactory.java
new file mode 100644
index 000000000..fe4104829
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderAdapterFactory.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+
+/**
+ * The adapter factory to adapt a working set element holder to a working set element.
+ */
+@SuppressWarnings("rawtypes")
+public class WorkingSetElementHolderAdapterFactory implements IAdapterFactory {
+ // The adapters.
+ private Class[] adapters = { IWorkingSetElement.class };
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof WorkingSetElementHolder) {
+ return ((WorkingSetElementHolder) adaptableObject).getAdapter(adapterType);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @Override
+ public Class[] getAdapterList() {
+ return adapters;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderFactory.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderFactory.java
new file mode 100644
index 000000000..a48657c4f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementHolderFactory.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.tm.te.ui.views.interfaces.workingsets.IWorkingSetNameIDs;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+
+/**
+ * A WorkingSetElementHolderFactory is an element factory used to create a working set element
+ * holder from a memento element.
+ */
+public class WorkingSetElementHolderFactory implements IElementFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public IAdaptable createElement(IMemento memento) {
+ WorkingSetElementHolder holder = new WorkingSetElementHolder();
+ String elementId = memento.getString(IWorkingSetNameIDs.ATTR_ELEMENTID);
+ holder.setElementId(elementId);
+ String workingSetName = memento.getString(IWorkingSetNameIDs.ATTR_WORKINGSET_NAME);
+ holder.setWorkingSetName(workingSetName);
+ return holder;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java
new file mode 100644
index 000000000..e8ec80b50
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.tm.te.runtime.events.EventManager;
+import org.eclipse.tm.te.ui.events.AbstractEventListener;
+import org.eclipse.tm.te.ui.views.ViewsUtil;
+import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
+import org.eclipse.tm.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetUpdater;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Working set element updater implementation.
+ */
+public class WorkingSetElementUpdater extends AbstractEventListener implements IWorkingSetUpdater, IExecutableExtension {
+ // List of working sets managed by this updater
+ private final List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
+ // The common viewer
+ private CommonViewer viewer = null;
+
+ /* (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 {
+ // Get the target explorer view instance
+ IWorkbenchPart part = ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
+ if (part instanceof CommonNavigator) viewer = ((CommonNavigator)part).getCommonViewer();
+
+ // Register ourself as ViewContentChangeEvent listener
+ EventManager.getInstance().addEventListener(this, ViewerContentChangeEvent.class, viewer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#add(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public void add(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ workingSets.add(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#remove(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean remove(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ return workingSets.remove(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#contains(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean contains(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ return workingSets.contains(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#dispose()
+ */
+ @Override
+ public void dispose() {
+ synchronized (workingSets) {
+ workingSets.clear();
+ }
+
+ // Remove ourself as event listener
+ EventManager.getInstance().removeEventListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (!(event instanceof ViewerContentChangeEvent) && viewer.equals(((ViewerContentChangeEvent)event).getSource())) {
+ return;
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java
index 4b6269df6..2a084c346 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java
@@ -9,11 +9,15 @@
*******************************************************************************/
package org.eclipse.tm.te.ui.views.workingsets;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.tm.te.runtime.model.interfaces.IContainerModelNode;
-import org.eclipse.tm.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.ui.IAggregateWorkingSet;
import org.eclipse.ui.IContainmentAdapter;
import org.eclipse.ui.IWorkingSet;
@@ -54,6 +58,10 @@ public class WorkingSetFilter extends ViewerFilter {
if (workingSet == null || (workingSet.isAggregateWorkingSet() && workingSet.isEmpty())) {
return true;
}
+ if (parentElement instanceof IAggregateWorkingSet) {
+ List<IWorkingSet> workingSets = Arrays.asList(((IAggregateWorkingSet)parentElement).getComponents());
+ if (workingSets.contains(element)) return true;
+ }
if (element != null) {
return isEnclosed(element);
}
@@ -107,38 +115,28 @@ public class WorkingSetFilter extends ViewerFilter {
* itself.
*
* @param element The element to test for enclosure by a working set element
- * @param workingSetElement The working set element
+ * @param workingSetElement The working set element. Must be not <code>null</code>.
*
* @return true if element is enclosed by a working set element and false otherwise.
*/
private boolean isEnclosedElement(Object element, IAdaptable workingSetElement) {
+ Assert.isNotNull(workingSetElement);
+
if (workingSetElement.equals(element)) {
return true;
}
- if (element instanceof IModelNode) {
- IContainerModelNode parent = ((IModelNode)element).getParent();
- while (parent != null && !workingSetElement.equals(parent)) {
- parent = parent.getParent();
- }
- if (parent != null && workingSetElement.equals(parent)) {
- return true;
- }
- }
-
- if (element != null) {
- IModelNode adapter = (IModelNode)workingSetElement.getAdapter(IModelNode.class);
- if (adapter != null) {
- if (element.equals(adapter)) {
+ if (element instanceof IWorkingSetElement) {
+ IWorkingSetElement wsElement = (IWorkingSetElement) element;
+ WorkingSetElementHolder holder = (WorkingSetElementHolder) workingSetElement.getAdapter(WorkingSetElementHolder.class);
+ if (holder != null) {
+ if (wsElement.equals(holder.getElement())) {
+ return true;
+ }
+ if (wsElement.getElementId().equals(holder.getElementId())) {
+ holder.setElement(wsElement);
return true;
}
- IContainerModelNode parent = adapter.getParent();
- while (parent != null && !element.equals(parent)) {
- parent = parent.getParent();
- }
- if (parent != null && element.equals(parent)) {
- return true;
- }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java
index 1ca650a12..bdf5c3f8f 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java
@@ -9,14 +9,20 @@
*******************************************************************************/
package org.eclipse.tm.te.ui.views.workingsets;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
import org.eclipse.tm.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tm.te.ui.views.internal.ViewRoot;
import org.eclipse.ui.IAggregateWorkingSet;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkingSet;
@@ -119,8 +125,30 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
return NO_CHILDREN;
}
- /* default */IAdaptable[] getWorkingSetElements(IWorkingSet workingSet) {
- return workingSet.getElements();
+ /* default */ IAdaptable[] getWorkingSetElements(IWorkingSet workingSet) {
+ Assert.isNotNull(workingSet);
+ List<IAdaptable> elements = new ArrayList<IAdaptable>();
+ for (IAdaptable candidate : workingSet.getElements()) {
+ if (candidate instanceof WorkingSetElementHolder) {
+ WorkingSetElementHolder holder = (WorkingSetElementHolder)candidate;
+ IWorkingSetElement element = holder.getElement();
+ // If the element is null, try to look up the element through the content provider
+ if (element == null) {
+ ITreeContentProvider contentProvider = (ITreeContentProvider)viewer.getContentProvider();
+ for (Object elementCandidate : contentProvider.getElements(ViewRoot.getInstance())) {
+ if (elementCandidate instanceof IWorkingSetElement && ((IWorkingSetElement)elementCandidate).getElementId().equals(holder.getElementId())) {
+ holder.setElement((IWorkingSetElement)elementCandidate);
+ element = holder.getElement();
+ break;
+ }
+ }
+ }
+ if (element != null) elements.add(element);
+ } else {
+ elements.add(candidate);
+ }
+ }
+ return elements.toArray(new IAdaptable[elements.size()]);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/AbstractWorkingSetWizardPage.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/AbstractWorkingSetWizardPage.java
index 3300335fe..64957c7c8 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/AbstractWorkingSetWizardPage.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/AbstractWorkingSetWizardPage.java
@@ -44,7 +44,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
import org.eclipse.tm.te.ui.views.nls.Messages;
+import org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolder;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
@@ -66,25 +68,32 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- return !fSelectedElements.contains(element);
+ return !selectedElements.contains(element);
}
}
- Text fWorkingSetName;
- TreeViewer fTree;
- TableViewer fTable;
- ITreeContentProvider fTreeContentProvider;
+ /* default */ Text workingSetNameControl;
+ /* default */ TreeViewer tree;
+ /* default */ TableViewer table;
+ /* default */ ITreeContentProvider treeContentProvider;
- boolean fFirstCheck;
- final HashSet<Object> fSelectedElements;
- IWorkingSet fWorkingSet;
+ /* default */ boolean firstCheck;
+ /* default */ final HashSet<Object> selectedElements;
+ /* default */ IWorkingSet workingSet;
+ /**
+ * Constructor.
+ *
+ * @param pageName
+ * @param title
+ * @param titleImage
+ */
protected AbstractWorkingSetWizardPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
- fSelectedElements = new HashSet<Object>();
- fFirstCheck = true;
+ selectedElements = new HashSet<Object>();
+ firstCheck = true;
}
/**
@@ -169,9 +178,9 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
label.setLayoutData(gd);
- fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER);
- fWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- fWorkingSetName.addModifyListener(new ModifyListener() {
+ workingSetNameControl = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ workingSetNameControl.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ workingSetNameControl.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
validateInput();
@@ -215,20 +224,20 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
createTree(leftComposite);
createTable(rightComposite);
- if (fWorkingSet != null)
- fWorkingSetName.setText(fWorkingSet.getName());
+ if (workingSet != null)
+ workingSetNameControl.setText(workingSet.getName());
initializeSelectedElements();
validateInput();
- fTable.setInput(fSelectedElements);
- fTable.refresh(true);
- fTree.refresh(true);
+ table.setInput(selectedElements);
+ table.refresh(true);
+ tree.refresh(true);
createButtonBar(centerComposite);
- fWorkingSetName.setFocus();
- fWorkingSetName.setSelection(0, fWorkingSetName.getText().length());
+ workingSetNameControl.setFocus();
+ workingSetNameControl.setSelection(0, workingSetNameControl.getText().length());
Dialog.applyDialogFont(composite);
}
@@ -239,15 +248,15 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
label.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
label.setText(Messages.TargetWorkingSetPage_workspace_content);
- fTree = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
- fTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ tree = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
+ tree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- fTree.addFilter(new AddedElementsFilter());
- fTree.setUseHashlookup(true);
+ tree.addFilter(new AddedElementsFilter());
+ tree.setUseHashlookup(true);
- configureTree(fTree);
+ configureTree(tree);
- fTreeContentProvider = (ITreeContentProvider) fTree.getContentProvider();
+ treeContentProvider = (ITreeContentProvider) tree.getContentProvider();
}
private void createButtonBar(Composite parent) {
@@ -257,24 +266,24 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
final Button addButton = new Button(parent, SWT.PUSH);
addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
addButton.setText(Messages.TargetWorkingSetPage_add_button);
- addButton.setEnabled(!fTree.getSelection().isEmpty());
+ addButton.setEnabled(!tree.getSelection().isEmpty());
final Button addAllButton = new Button(parent, SWT.PUSH);
addAllButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
addAllButton.setText(Messages.TargetWorkingSetPage_addAll_button);
- addAllButton.setEnabled(fTree.getTree().getItems().length > 0);
+ addAllButton.setEnabled(tree.getTree().getItems().length > 0);
final Button removeButton = new Button(parent, SWT.PUSH);
removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
removeButton.setText(Messages.TargetWorkingSetPage_remove_button);
- removeButton.setEnabled(!fTable.getSelection().isEmpty());
+ removeButton.setEnabled(!table.getSelection().isEmpty());
final Button removeAllButton = new Button(parent, SWT.PUSH);
removeAllButton.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
removeAllButton.setText(Messages.TargetWorkingSetPage_removeAll_button);
- removeAllButton.setEnabled(!fSelectedElements.isEmpty());
+ removeAllButton.setEnabled(!selectedElements.isEmpty());
- fTree.addSelectionChangedListener(new ISelectionChangedListener() {
+ tree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
addButton.setEnabled(!event.getSelection().isEmpty());
@@ -287,21 +296,21 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
addTreeSelection();
removeAllButton.setEnabled(true);
- addAllButton.setEnabled(fTree.getTree().getItems().length > 0);
+ addAllButton.setEnabled(tree.getTree().getItems().length > 0);
}
});
- fTree.addDoubleClickListener(new IDoubleClickListener() {
+ tree.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
addTreeSelection();
removeAllButton.setEnabled(true);
- addAllButton.setEnabled(fTree.getTree().getItems().length > 0);
+ addAllButton.setEnabled(tree.getTree().getItems().length > 0);
}
});
- fTable.addSelectionChangedListener(new ISelectionChangedListener() {
+ table.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
removeButton.setEnabled(!event.getSelection().isEmpty());
@@ -314,17 +323,17 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
removeTableSelection();
addAllButton.setEnabled(true);
- removeAllButton.setEnabled(!fSelectedElements.isEmpty());
+ removeAllButton.setEnabled(!selectedElements.isEmpty());
}
});
- fTable.addDoubleClickListener(new IDoubleClickListener() {
+ table.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
removeTableSelection();
addAllButton.setEnabled(true);
- removeAllButton.setEnabled(!fSelectedElements.isEmpty());
+ removeAllButton.setEnabled(!selectedElements.isEmpty());
}
});
@@ -334,12 +343,12 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
*/
@Override
public void widgetSelected(SelectionEvent e) {
- TreeItem[] items = fTree.getTree().getItems();
+ TreeItem[] items = tree.getTree().getItems();
for (int i = 0; i < items.length; i++) {
- fSelectedElements.add(items[i].getData());
+ selectedElements.add(items[i].getData());
}
- fTable.refresh();
- fTree.refresh();
+ table.refresh();
+ tree.refresh();
addAllButton.setEnabled(false);
removeAllButton.setEnabled(true);
@@ -352,10 +361,10 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
*/
@Override
public void widgetSelected(SelectionEvent e) {
- fSelectedElements.clear();
+ selectedElements.clear();
- fTable.refresh();
- fTree.refresh();
+ table.refresh();
+ tree.refresh();
removeAllButton.setEnabled(false);
addAllButton.setEnabled(true);
@@ -368,13 +377,13 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
* Moves selected elements in the tree into the table
*/
void addTreeSelection() {
- IStructuredSelection selection = (IStructuredSelection) fTree.getSelection();
- fSelectedElements.addAll(selection.toList());
+ IStructuredSelection selection = (IStructuredSelection) tree.getSelection();
+ selectedElements.addAll(selection.toList());
Object[] selectedElements = selection.toArray();
- fTable.add(selectedElements);
- fTree.remove(selectedElements);
- fTable.setSelection(selection);
- fTable.getControl().setFocus();
+ table.add(selectedElements);
+ tree.remove(selectedElements);
+ table.setSelection(selection);
+ table.getControl().setFocus();
validateInput();
}
@@ -382,20 +391,20 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
* Moves the selected elements in the table into the tree
*/
void removeTableSelection() {
- IStructuredSelection selection = (IStructuredSelection) fTable.getSelection();
- fSelectedElements.removeAll(selection.toList());
+ IStructuredSelection selection = (IStructuredSelection) table.getSelection();
+ selectedElements.removeAll(selection.toList());
Object[] selectedElements = selection.toArray();
- fTable.remove(selectedElements);
+ table.remove(selectedElements);
try {
- fTree.getTree().setRedraw(false);
+ tree.getTree().setRedraw(false);
for (int i = 0; i < selectedElements.length; i++) {
- fTree.refresh(fTreeContentProvider.getParent(selectedElements[i]), true);
+ tree.refresh(treeContentProvider.getParent(selectedElements[i]), true);
}
} finally {
- fTree.getTree().setRedraw(true);
+ tree.getTree().setRedraw(true);
}
- fTree.setSelection(selection);
- fTree.getControl().setFocus();
+ tree.setSelection(selection);
+ tree.getControl().setFocus();
validateInput();
}
@@ -404,20 +413,20 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
label.setText(Messages.TargetWorkingSetPage_workingSet_content);
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
- fTable = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
+ table = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- fTable.getControl().setLayoutData(gd);
+ table.getControl().setLayoutData(gd);
- fTable.setUseHashlookup(true);
+ table.setUseHashlookup(true);
- configureTable(fTable);
+ configureTable(table);
- fTable.setContentProvider(new IStructuredContentProvider() {
+ table.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
- return fSelectedElements.toArray();
+ return selectedElements.toArray();
}
@Override
@@ -436,7 +445,7 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
*/
@Override
public IWorkingSet getSelection() {
- return fWorkingSet;
+ return workingSet;
}
/*
@@ -445,10 +454,10 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
@Override
public void setSelection(IWorkingSet workingSet) {
Assert.isNotNull(workingSet, "Working set must not be null"); //$NON-NLS-1$
- fWorkingSet = workingSet;
- if (getContainer() != null && getShell() != null && fWorkingSetName != null) {
- fFirstCheck = false;
- fWorkingSetName.setText(fWorkingSet.getName());
+ this.workingSet = workingSet;
+ if (getContainer() != null && getShell() != null && workingSetNameControl != null) {
+ firstCheck = false;
+ workingSetNameControl.setText(workingSet.getName());
initializeSelectedElements();
validateInput();
}
@@ -459,44 +468,46 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
*/
@Override
public void finish() {
- String workingSetName = fWorkingSetName.getText();
+ String workingSetName = workingSetNameControl.getText();
List<IAdaptable> elements = new ArrayList<IAdaptable>();
- for (Object candidate : fSelectedElements) {
- if (candidate instanceof IAdaptable) {
- elements.add((IAdaptable)candidate);
+ for (Object candidate : selectedElements) {
+ if (candidate instanceof IWorkingSetElement) {
+ WorkingSetElementHolder holder = new WorkingSetElementHolder(workingSetName, ((IWorkingSetElement)candidate).getElementId());
+ holder.setElement((IWorkingSetElement)candidate);
+ elements.add(holder);
}
}
- if (fWorkingSet == null) {
+ if (workingSet == null) {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
- fWorkingSet = workingSetManager.createWorkingSet(workingSetName, elements.toArray(new IAdaptable[elements.size()]));
- fWorkingSet.setId(getPageId());
+ workingSet = workingSetManager.createWorkingSet(workingSetName, elements.toArray(new IAdaptable[elements.size()]));
+ workingSet.setId(getPageId());
} else {
- fWorkingSet.setName(workingSetName);
- fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
+ workingSet.setName(workingSetName);
+ workingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
}
}
void validateInput() {
String errorMessage = null;
String infoMessage = null;
- String newText = fWorkingSetName.getText();
+ String newText = workingSetNameControl.getText();
if (newText.equals(newText.trim()) == false)
errorMessage = Messages.TargetWorkingSetPage_warning_nameWhitespace;
if (newText.equals("")) { //$NON-NLS-1$
- if (fFirstCheck) {
+ if (firstCheck) {
setPageComplete(false);
- fFirstCheck = false;
+ firstCheck = false;
return;
}
errorMessage = Messages.TargetWorkingSetPage_warning_nameMustNotBeEmpty;
}
- fFirstCheck = false;
+ firstCheck = false;
- if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
+ if (errorMessage == null && (workingSet == null || newText.equals(workingSet.getName()) == false)) {
IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getAllWorkingSets();
for (int i = 0; i < workingSets.length; i++) {
if (newText.equals(workingSets[i].getName())) {
@@ -514,11 +525,11 @@ public abstract class AbstractWorkingSetWizardPage extends WizardPage implements
}
private boolean hasSelectedElement() {
- return !fSelectedElements.isEmpty();
+ return !selectedElements.isEmpty();
}
private void initializeSelectedElements() {
- fSelectedElements.addAll(Arrays.asList(getInitialWorkingSetElements(fWorkingSet)));
+ selectedElements.addAll(Arrays.asList(getInitialWorkingSetElements(workingSet)));
}
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/TargetWorkingSetPage.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/TargetWorkingSetPage.java
index d8b3fec7a..66ddc6e15 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/TargetWorkingSetPage.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/pages/TargetWorkingSetPage.java
@@ -9,36 +9,39 @@
*******************************************************************************/
package org.eclipse.tm.te.ui.views.workingsets.pages;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.tm.te.ui.trees.TreeArrayContentProvider;
+import org.eclipse.tm.te.ui.views.ViewsUtil;
import org.eclipse.tm.te.ui.views.activator.UIPlugin;
-import org.eclipse.tm.te.ui.views.interfaces.IRoot;
import org.eclipse.tm.te.ui.views.interfaces.IUIConstants;
import org.eclipse.tm.te.ui.views.interfaces.ImageConsts;
-import org.eclipse.tm.te.ui.views.internal.View;
+import org.eclipse.tm.te.ui.views.internal.ViewRoot;
import org.eclipse.tm.te.ui.views.nls.Messages;
+import org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementHolder;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.internal.navigator.NavigatorContentService;
-import org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider;
+import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.INavigatorContentService;
/**
* A target working set page is a wizard page used to configure a custom defined
* working set. This wizard is used in the configure working set action to edit
* the working sets used in the working set viewer.
- *
*/
-@SuppressWarnings("restriction")
public class TargetWorkingSetPage extends AbstractWorkingSetWizardPage {
- // The common navigator content service
+ // The target explorer view content service (Never dispose it in here!)
private INavigatorContentService contentService;
- // The root node
- private IRoot root;
// The initial selection
private IStructuredSelection initialSelection;
@@ -67,46 +70,29 @@ public class TargetWorkingSetPage extends AbstractWorkingSetWizardPage {
}
/* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.DialogPage#dispose()
- */
- @Override
- public void dispose() {
- if (contentService != null) { contentService.dispose(); contentService = null; }
- root = null;
- super.dispose();
- }
-
- /* (non-Javadoc)
* @see org.eclipse.tm.te.tcf.ui.internal.workingsets.AbstractWorkingSetWizardPage#configureTree(org.eclipse.jface.viewers.TreeViewer)
*/
@Override
protected void configureTree(TreeViewer tree) {
- // Construct and associate the navigator content service.
- // We have to simulate the common viewer here to get the content right.
- contentService = new NavigatorContentService(IUIConstants.ID_EXPLORER, tree);
+ // Get the content service from the Target Explorer view.
+ IWorkbenchPart part = ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
+ if (part instanceof CommonNavigator) {
+ contentService = ((CommonNavigator)part).getNavigatorContentService();
- tree.setContentProvider(new NavigatorContentServiceContentProvider((NavigatorContentService)contentService) {
- /* (non-Javadoc)
- * @see org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object anElementOrPath) {
- return false;
- }
- });
- tree.setLabelProvider(contentService.createCommonLabelProvider());
+ tree.setContentProvider(TreeArrayContentProvider.getInstance());
+ tree.setLabelProvider(contentService.createCommonLabelProvider());
- // Filter out everything not implementing IWorkingSetElement
- tree.addFilter(new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- return element instanceof IWorkingSetElement;
- }
- });
+ // Filter out everything not implementing IWorkingSetElement
+ tree.addFilter(new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ return element instanceof IWorkingSetElement;
+ }
+ });
- // Create the root node
- root = new View.Root();
- tree.setInput(root);
+ // Initialize the tree input
+ tree.setInput(contentService.createCommonContentProvider().getElements(ViewRoot.getInstance()));
+ }
}
/* (non-Javadoc)
@@ -126,10 +112,29 @@ public class TargetWorkingSetPage extends AbstractWorkingSetWizardPage {
if (workingSet == null) {
if (initialSelection == null)
return new IAdaptable[0];
-
- elements= initialSelection.toArray();
+ elements = initialSelection.toArray();
} else {
- elements= workingSet.getElements();
+ List<IWorkingSetElement> result = new ArrayList<IWorkingSetElement>();
+ for (IAdaptable adaptable : workingSet.getElements()) {
+ if (!(adaptable instanceof WorkingSetElementHolder)) continue;
+ WorkingSetElementHolder holder = (WorkingSetElementHolder) adaptable;
+ Assert.isNotNull(holder);
+ IWorkingSetElement element = holder.getElement();
+ // If the element is null, try to look up the element through the content provider
+ if (element == null) {
+ ITreeContentProvider contentProvider = (ITreeContentProvider)tree.getContentProvider();
+ for (Object candidate : contentProvider.getElements(tree.getInput())) {
+ if (candidate instanceof IWorkingSetElement && ((IWorkingSetElement)candidate).getElementId().equals(holder.getElementId())) {
+ holder.setElement((IWorkingSetElement)candidate);
+ element = holder.getElement();
+ break;
+ }
+ }
+ }
+
+ if (element != null) result.add(element);
+ }
+ elements = result.toArray();
}
return elements;
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeArrayContentProvider.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeArrayContentProvider.java
new file mode 100644
index 000000000..3361ceaab
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeArrayContentProvider.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.trees;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * This implementation of <code>ITreeContentProvider</code> handles
+ * the case where the viewer input is an unchanging array or collection of elements.
+ */
+public class TreeArrayContentProvider extends ArrayContentProvider implements ITreeContentProvider {
+
+ private static TreeArrayContentProvider instance;
+
+ /**
+ * Returns an instance of TreeArrayContentProvider. Since instances of this
+ * class do not maintain any state, they can be shared between multiple
+ * clients.
+ *
+ * @return an instance of TreeArrayContentProvider
+ */
+ public static TreeArrayContentProvider getInstance() {
+ synchronized(TreeArrayContentProvider.class) {
+ if (instance == null) {
+ instance = new TreeArrayContentProvider();
+ }
+ return instance;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return getElements(parentElement);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+}

Back to the top