Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-08 15:15:13 -0500
committerEugene Tarassov2011-11-08 15:15:13 -0500
commitb831d144a0f0bc6ed91fe2a603cd142f000862bb (patch)
treecae9a9a0c0734536317566ae0331fe8dbc8d4ec1
parent17518d356cbd8dff1fe80aa1ee4aceeed15b7cdd (diff)
parentab11a5e7041d5b9582de6c19abecce3dbe99d101 (diff)
downloadorg.eclipse.tcf-b831d144a0f0bc6ed91fe2a603cd142f000862bb.tar.gz
org.eclipse.tcf-b831d144a0f0bc6ed91fe2a603cd142f000862bb.tar.xz
org.eclipse.tcf-b831d144a0f0bc6ed91fe2a603cd142f000862bb.zip
Merge branch 'master' of ssh://git.eclipse.org/gitroot/tcf/org.eclipse.tcf
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.properties4
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml42
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/actions/WorkingSetActionProvider.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetIDs.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.properties2
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/OthersWorkingSetElementUpdater.java128
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetFilter.java84
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetSorter.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetViewerSorter.java39
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetsContentProvider.java56
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeViewerSorter.java (renamed from target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/Sorter.java)21
15 files changed, 363 insertions, 144 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
index 562c15aa8..66d16e752 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml
@@ -27,7 +27,7 @@
<instanceof value="org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel"/>
</enablement>
<commonSorter
- class="org.eclipse.tm.te.tcf.ui.internal.navigator.Sorter"
+ class="org.eclipse.tm.te.ui.trees.TreeViewerSorter"
id="org.eclipse.tm.te.tcf.ui.navigator.sorter"/>
<commonWizard
type="new"
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.properties
index dd8afed91..cd9aa991c 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.properties
@@ -37,6 +37,10 @@ filters.workingSet.description=Hides unselected working sets [not visible in UI]
workingsets.extension.name=Working Sets
workingset.name=Target Explorer
+workingset.description=Working set for Target Explorer elements.
+
+workingset.others.name=Other Targets
+workingset.others.description=Working set containing all elements not in any Target Explorer group.
# ***** Command and menu contributions *****
Command.open.name=Open
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 ca842b0c3..19c362c78 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
@@ -55,8 +55,8 @@
<includes>
<contentExtension
isRoot="true"
- pattern="org.eclipse.tm.te.ui.views.navigator.workingSets"/>
- <contentExtension pattern="org.eclipse.tm.te.ui.views.navigator.*"/>
+ pattern="org.eclipse.tm.te.ui.views.navigator.content.workingSets"/>
+ <contentExtension pattern="org.eclipse.tm.te.ui.views.navigator.filters.*"/>
</includes>
</viewerContentBinding>
@@ -71,6 +71,7 @@
</extension>
<extension point="org.eclipse.ui.navigator.navigatorContent">
+<!-- Default navigator action contibutions -->
<actionProvider
class="org.eclipse.tm.te.ui.views.actions.NewActionProvider"
id="org.eclipse.tm.te.ui.views.navigator.actions.NewActionProvider">
@@ -78,15 +79,7 @@
</enablement>
</actionProvider>
- <!-- Working Sets -->
- <commonFilter
- id="org.eclipse.tm.te.ui.views.navigator.filters.workingSet"
- name="%filters.workingSet.name"
- description="%filters.workingSet.description"
- class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetFilter"
- activeByDefault="false"
- visibleInUI="false">
- </commonFilter>
+<!-- Working Sets navigator action contributions -->
<actionProvider
class="org.eclipse.tm.te.ui.views.actions.WorkingSetActionProvider"
id="org.eclipse.tm.te.ui.views.navigator.actions.WorkingSetActions">
@@ -99,11 +92,22 @@
</or>
</enablement>
</actionProvider>
+
+<!-- Working Sets navigator content contributions -->
+ <commonFilter
+ id="org.eclipse.tm.te.ui.views.navigator.filters.workingSet"
+ name="%filters.workingSet.name"
+ description="%filters.workingSet.description"
+ class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetFilter"
+ activeByDefault="false"
+ visibleInUI="false">
+ </commonFilter>
+
<navigatorContent
activeByDefault="true"
contentProvider="org.eclipse.tm.te.ui.views.workingsets.WorkingSetsContentProvider"
icon="icons/obj16/workingsets.gif"
- id="org.eclipse.tm.te.ui.views.navigator.workingSets"
+ id="org.eclipse.tm.te.ui.views.navigator.content.workingSets"
labelProvider="org.eclipse.tm.te.ui.views.workingsets.WorkingSetsLabelProvider"
name="%workingsets.extension.name"
priority="higher">
@@ -114,8 +118,9 @@
<instanceof value="java.lang.Object"/>
</possibleChildren>
<commonSorter
- class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetSorter"
- id="org.eclipse.tm.te.ui.views.workingSets.sorter"/>
+ class="org.eclipse.tm.te.ui.views.workingsets.WorkingSetViewerSorter"
+ id="org.eclipse.tm.te.ui.views.navigator.content.workingSets.sorter">
+ </commonSorter>
</navigatorContent>
</extension>
@@ -170,6 +175,7 @@
<!-- Working Set contributions -->
<extension point="org.eclipse.ui.workingSets">
<workingSet
+ description="%workingset.description"
elementAdapterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementAdapter"
icon="icons/obj16/workingset.gif"
id="org.eclipse.tm.te.ui.views.workingset"
@@ -177,6 +183,14 @@
pageClass="org.eclipse.tm.te.ui.views.workingsets.pages.TargetWorkingSetPage"
updaterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater">
</workingSet>
+
+ <workingSet
+ description="%workingset.others.description"
+ icon="icons/obj16/workingset.gif"
+ id="org.eclipse.tm.te.ui.views.workingset.others"
+ name="%workingset.others.name"
+ updaterClass="org.eclipse.tm.te.ui.views.workingsets.OthersWorkingSetElementUpdater">
+ </workingSet>
</extension>
<!-- Element factories -->
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 95db12c91..687e02589 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
@@ -281,7 +281,7 @@ public class WorkingSetActionProvider extends CommonActionProvider {
UIPlugin.getDefault().getLog().log(status);
return;
}
- workingSetFilter.setWorkingSet(emptyWorkingSet || !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) ? null : workingSet);
+ workingSetFilter.setActive(extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS));
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetIDs.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetIDs.java
new file mode 100644
index 000000000..e61bc3b82
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/interfaces/workingsets/IWorkingSetIDs.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * Target Explorer working set ID constants.
+ */
+public interface IWorkingSetIDs {
+
+ /**
+ * Target Explorer working set id.
+ */
+ public final static String ID_WS_TARGET_EXPLORER = "org.eclipse.tm.te.ui.views.workingset"; //$NON-NLS-1$
+
+ /**
+ * Target Explorer "Others" working set id.
+ */
+ public final static String ID_WS_OTHERS = "org.eclipse.tm.te.ui.views.workingset.others"; //$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 7324152b1..ee63bffc2 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
@@ -31,6 +31,7 @@ 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.nls.Messages;
import org.eclipse.ui.IAggregateWorkingSet;
+import org.eclipse.ui.ILocalWorkingSetManager;
import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkingSet;
@@ -62,6 +63,11 @@ public class View extends CommonNavigator {
private String workingSetLabel;
/**
+ * The local working set manager instance.
+ */
+ private final ILocalWorkingSetManager localWorkingSetManager = PlatformUI.getWorkbench().createLocalWorkingSetManager();
+
+ /**
* Constructor.
*/
public View() {
@@ -117,6 +123,24 @@ public class View extends CommonNavigator {
return workingSetLabel;
}
+ /**
+ * Returns the local working set manager instance.
+ *
+ * @return The local working set manager instance.
+ */
+ public final ILocalWorkingSetManager getLocalWorkingSetManager() {
+ return localWorkingSetManager;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#dispose()
+ */
+ @Override
+ public void dispose() {
+ localWorkingSetManager.dispose();
+ super.dispose();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.navigator.CommonNavigator#createCommonViewerObject(org.eclipse.swt.widgets.Composite)
*/
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.java
index 5d7211f0f..8a89d50d0 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.java
@@ -44,6 +44,8 @@ public class Messages extends NLS {
public static String WorkingSetRootModeActionGroup_Target;
public static String WorkingSetRootModeActionGroup_Working_Set;
+ public static String WorkingSetContentProvider_others_name;
+
public static String PropertiesCommandHandler_error_initPartFailed;
public static String TargetWorkingSetPage_workingSet_name;
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.properties
index 8e722279b..0fcf4b7b0 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/nls/Messages.properties
@@ -22,6 +22,8 @@ WorkingSetRootModeActionGroup_Top_Level_Element=&Top Level Elements
WorkingSetRootModeActionGroup_Target=Targets
WorkingSetRootModeActionGroup_Working_Set=Working Sets
+WorkingSetContentProvider_others_name=Other Targets
+
# ***** Command Handler *****
PropertiesCommandHandler_error_initPartFailed=Failed to initialize the Target Explorer details editor.
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/OthersWorkingSetElementUpdater.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/OthersWorkingSetElementUpdater.java
new file mode 100644
index 000000000..afb8eb119
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/OthersWorkingSetElementUpdater.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.tm.te.ui.views.internal.ViewRoot;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * "Others" working set element updater.
+ */
+public class OthersWorkingSetElementUpdater extends WorkingSetElementUpdater {
+ // The reference to the "Others" working set
+ private IWorkingSet othersWorkingSet;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater#add(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public void add(IWorkingSet workingSet) {
+ Assert.isTrue(othersWorkingSet == null);
+ othersWorkingSet = workingSet;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater#remove(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean remove(IWorkingSet workingSet) {
+ Assert.isTrue(othersWorkingSet == workingSet);
+ othersWorkingSet = null;
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater#contains(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean contains(IWorkingSet workingSet) {
+ return othersWorkingSet == workingSet;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater#onUpdateWorkingSets(org.eclipse.ui.navigator.CommonViewer, org.eclipse.ui.IWorkingSet[])
+ */
+ @Override
+ protected void onUpdateWorkingSets(CommonViewer viewer, IWorkingSet[] workingsets) {
+ Assert.isNotNull(viewer);
+ Assert.isNotNull(workingsets);
+
+ // The list of elements not be contained by any other working set
+ List<WorkingSetElementHolder> otherElements = new ArrayList<WorkingSetElementHolder>();
+
+ // Get all (root) elements from the common viewer
+ Object[] elements = viewer.getNavigatorContentService().createCommonContentProvider().getElements(ViewRoot.getInstance());
+
+ // Get all working sets
+ IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSet[] allWorkingSets = manager.getAllWorkingSets();
+
+ // Loop the elements and check if they are contained in a working set
+ for (Object element : elements) {
+ if (!(element instanceof IWorkingSetElement)) continue;
+
+ boolean isContained = isContained((IWorkingSetElement)element, allWorkingSets);
+ if (!isContained) {
+ WorkingSetElementHolder holder = new WorkingSetElementHolder(othersWorkingSet.getName(), ((IWorkingSetElement)element).getElementId());
+ holder.setElement((IWorkingSetElement)element);
+ otherElements.add(holder);
+ }
+ }
+
+ othersWorkingSet.setElements(otherElements.toArray(new IAdaptable[otherElements.size()]));
+ }
+
+ /**
+ * Walks over the given working set list and checks if the element is contained in
+ * one of them.
+ *
+ * @param element The element. Must not be <code>null</code>.
+ * @param allWorkingSets The list of working sets. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the element is contained in at least one of the given working sets, <code>false</code> otherwise.
+ */
+ protected boolean isContained(IWorkingSetElement element, IWorkingSet[] allWorkingSets) {
+ Assert.isNotNull(element);
+ Assert.isNotNull(allWorkingSets);
+
+ boolean contained = false;
+
+ for (IWorkingSet workingSet : allWorkingSets) {
+ IAdaptable[] wsElements = workingSet.getElements();
+ for (IAdaptable wsElement : wsElements) {
+ if (!(wsElement instanceof WorkingSetElementHolder)) continue;
+
+ IWorkingSetElement candidate = ((WorkingSetElementHolder)wsElement).getElement();
+ String candidateId = ((WorkingSetElementHolder)wsElement).getElementId();
+
+ if (element.equals(candidate)) {
+ contained = true;
+ break;
+ } else if (candidate == null && element.getElementId().equals(candidateId)) {
+ contained = true;
+ ((WorkingSetElementHolder)wsElement).setElement(element);
+ break;
+ }
+ }
+ if (contained) break;
+ }
+
+ return contained;
+ }
+}
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
index e8ec80b50..7847a44ba 100644
--- 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
@@ -13,18 +13,15 @@ import java.util.ArrayList;
import java.util.EventObject;
import java.util.List;
+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.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;
/**
@@ -33,20 +30,14 @@ import org.eclipse.ui.navigator.CommonViewer;
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);
+ EventManager.getInstance().addEventListener(this, ViewerContentChangeEvent.class);
}
/* (non-Javadoc)
@@ -97,8 +88,28 @@ public class WorkingSetElementUpdater extends AbstractEventListener implements I
*/
@Override
public void eventFired(EventObject event) {
- if (!(event instanceof ViewerContentChangeEvent) && viewer.equals(((ViewerContentChangeEvent)event).getSource())) {
+ if (!(event instanceof ViewerContentChangeEvent) && !(((ViewerContentChangeEvent)event).getSource() instanceof CommonViewer)) {
return;
}
+
+ // Create a snapshot of the working sets
+ final IWorkingSet[] snapshot;
+ synchronized (workingSets) {
+ snapshot = workingSets.toArray(new IWorkingSet[workingSets.size()]);
+ }
+
+ // Update the working sets
+ onUpdateWorkingSets((CommonViewer)((ViewerContentChangeEvent)event).getSource(), snapshot);
+ }
+
+ /**
+ * Update the managed working sets based on the content of the given viewer.
+ *
+ * @param viewer The viewer. Must not be <code>null</code>.
+ * @param workingsets The working sets. Must not be <code>null</code>.
+ */
+ protected void onUpdateWorkingSets(CommonViewer viewer, IWorkingSet[] workingsets) {
+ Assert.isNotNull(viewer);
+ Assert.isNotNull(workingsets);
}
}
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 2a084c346..f122d0acc 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
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.IAdaptable;
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.views.interfaces.workingsets.IWorkingSetIDs;
import org.eclipse.ui.IAggregateWorkingSet;
import org.eclipse.ui.IContainmentAdapter;
import org.eclipse.ui.IWorkingSet;
@@ -26,27 +27,16 @@ import org.eclipse.ui.IWorkingSet;
* children of a working set element.
*/
public class WorkingSetFilter extends ViewerFilter {
- private IWorkingSet workingSet = null;
+ private boolean active = false;
- private IAdaptable[] cachedWorkingSet = null;
-
- /**
- * Returns the active working set the filter is working with.
- *
- * @return the active working set
- */
- public IWorkingSet getWorkingSet() {
- return workingSet;
- }
-
- /**
- * Sets the active working set.
- *
- * @param workingSet the working set the filter should work with
- */
- public void setWorkingSet(IWorkingSet workingSet) {
- this.workingSet = workingSet;
- }
+ /**
+ * Sets the working set filter active or inactive.
+ *
+ * @param active <code>True</code> to set the filter active, <code>false</code> to set the filter inactive.
+ */
+ public final void setActive(boolean active) {
+ this.active = active;
+ }
/**
* Determines if an element should be filtered out.
@@ -55,16 +45,20 @@ public class WorkingSetFilter extends ViewerFilter {
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- 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);
- }
+ if (active && parentElement instanceof IWorkingSet) {
+ if (((IWorkingSet)parentElement).isEmpty()) {
+ return true;
+ }
+ if (parentElement instanceof IAggregateWorkingSet) {
+ List<IWorkingSet> workingSets = Arrays.asList(((IAggregateWorkingSet)parentElement).getComponents());
+ if (workingSets.contains(element) || IWorkingSetIDs.ID_WS_OTHERS.equals(((IWorkingSet)element).getId())) {
+ return true;
+ }
+ }
+ if (element != null) {
+ return isEnclosed((IWorkingSet)parentElement, element);
+ }
+ }
return true;
}
@@ -77,14 +71,8 @@ public class WorkingSetFilter extends ViewerFilter {
* @param element The element to test for enclosure by a working set element
* @return true if element is enclosed by a working set element and false otherwise.
*/
- private boolean isEnclosed(Object element) {
- IAdaptable[] workingSetElements = cachedWorkingSet;
-
- // working set elements won't be cached if select is called
- // directly, outside filter. fixes bug 14500.
- if (workingSetElements == null) {
- workingSetElements = workingSet.getElements();
- }
+ private boolean isEnclosed(IWorkingSet workingSet, Object element) {
+ IAdaptable[] workingSetElements = workingSet.getElements();
for (int i = 0; i < workingSetElements.length; i++) {
IAdaptable workingSetElement = workingSetElements[i];
@@ -142,24 +130,4 @@ public class WorkingSetFilter extends ViewerFilter {
return false;
}
-
- /**
- * Filters out elements that are neither a parent nor a child of
- * a working set element.
- *
- * @see ViewerFilter#filter(Viewer, Object, Object[])
- */
- @Override
- public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
- Object[] result = null;
- if (workingSet != null) {
- cachedWorkingSet = workingSet.getElements();
- }
- try {
- result = super.filter(viewer, parent, elements);
- } finally {
- cachedWorkingSet = null;
- }
- return result;
- }
}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetSorter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetSorter.java
deleted file mode 100644
index b1336752d..000000000
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetSorter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * 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.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-/**
- * Working set sorter
- * <p>
- * Copied and adapted from <code>org.eclipse.ui.internal.navigator.workingsets.WorkingSetSorter</code>.
- */
-public class WorkingSetSorter extends ViewerSorter {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (viewer instanceof StructuredViewer) {
- ILabelProvider labelProvider = (ILabelProvider) ((StructuredViewer) viewer).getLabelProvider();
- String text1 = labelProvider.getText(e1);
- String text2 = labelProvider.getText(e2);
- if (text1 != null) {
- return text1.compareTo(text2);
- }
- }
- return -1;
- }
-
-}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetViewerSorter.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetViewerSorter.java
new file mode 100644
index 000000000..da2679143
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetViewerSorter.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.workingsets;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tm.te.ui.trees.TreeViewerSorter;
+import org.eclipse.tm.te.ui.views.interfaces.workingsets.IWorkingSetIDs;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * Working set viewer sorter implementation.
+ */
+public class WorkingSetViewerSorter extends TreeViewerSorter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.trees.TreeViewerSorter#doCompare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object, java.lang.String, int, int)
+ */
+ @Override
+ protected int doCompare(Viewer viewer, Object node1, Object node2, String sortColumn, int index, int inverter) {
+ if (node1 instanceof IWorkingSet && node2 instanceof IWorkingSet) {
+ // The "Others" working set will appear always at the bottom of the tree
+ if (IWorkingSetIDs.ID_WS_OTHERS.equals(((IWorkingSet)node1).getId())) {
+ return 1;
+ }
+ if (IWorkingSetIDs.ID_WS_OTHERS.equals(((IWorkingSet)node2).getId())) {
+ return -1;
+ }
+ }
+ return super.doCompare(viewer, node1, node2, sortColumn, index, inverter);
+ }
+
+}
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 bdf5c3f8f..fa7d4a658 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
@@ -10,6 +10,7 @@
package org.eclipse.tm.te.ui.views.workingsets;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -20,12 +21,19 @@ 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.events.EventManager;
import org.eclipse.tm.te.runtime.interfaces.workingsets.IWorkingSetElement;
+import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
import org.eclipse.tm.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tm.te.ui.views.interfaces.workingsets.IWorkingSetIDs;
+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.ui.IAggregateWorkingSet;
+import org.eclipse.ui.ILocalWorkingSetManager;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.navigator.NavigatorContentService;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.CommonViewer;
@@ -44,7 +52,7 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
/**
* The extension id for the WorkingSet extension.
*/
- public static final String EXTENSION_ID = "org.eclipse.tm.te.ui.views.navigator.workingSets"; //$NON-NLS-1$
+ public static final String EXTENSION_ID = "org.eclipse.tm.te.ui.views.navigator.content.workingSets"; //$NON-NLS-1$
/**
* A key used by the Extension State Model to keep track of whether top level Working Sets or
@@ -60,6 +68,8 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
private CommonNavigator targetExplorer;
private CommonViewer viewer;
+ private ILocalWorkingSetManager localWorkingSetManager;
+
private IPropertyChangeListener rootModeListener = new IPropertyChangeListener() {
/* (non-Javadoc)
@@ -84,25 +94,49 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
viewer = (CommonViewer) cs.getViewer();
targetExplorer = viewer.getCommonNavigator();
+ localWorkingSetManager = targetExplorer instanceof View ? ((View)targetExplorer).getLocalWorkingSetManager() : PlatformUI.getWorkbench().createLocalWorkingSetManager();
+
extensionStateModel = config.getExtensionStateModel();
extensionStateModel.addPropertyChangeListener(rootModeListener);
+
updateRootMode();
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
*/
@Override
- public void restoreState(IMemento aMemento) {
+ public void restoreState(IMemento memento) {
+ // We can call the local working set manager restoreState(memento) method
+ // only as long the working set manager is empty
+ if (localWorkingSetManager.getWorkingSets().length == 0) {
+ localWorkingSetManager.restoreState(memento);
+
+ IWorkingSet old = localWorkingSetManager.getWorkingSet("Others"); //$NON-NLS-1$
+ if (old != null) localWorkingSetManager.removeWorkingSet(old);
+
+ // Create the "Others" working set if not restored from the memento
+ IWorkingSet others = localWorkingSetManager.getWorkingSet(Messages.WorkingSetContentProvider_others_name);
+ if (others == null) {
+ others = localWorkingSetManager.createWorkingSet(Messages.WorkingSetContentProvider_others_name, new IAdaptable[0]);
+ others.setId(IWorkingSetIDs.ID_WS_OTHERS);
+ localWorkingSetManager.addWorkingSet(others);
+ } else {
+ others.setId(IWorkingSetIDs.ID_WS_OTHERS);
+ }
+ }
+
+ // Trigger an update of the "Others" working set
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(viewer, ViewerContentChangeEvent.REFRESH);
+ EventManager.getInstance().fireEvent(event);
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
* @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
*/
@Override
- public void saveState(IMemento aMemento) {
+ public void saveState(IMemento memento) {
+ localWorkingSetManager.saveState(memento);
}
/* (non-Javadoc)
@@ -115,11 +149,15 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
if (workingSet.isAggregateWorkingSet() && targetExplorer != null) {
switch (targetExplorer.getRootMode()) {
case IUIConstants.MODE_WORKING_SETS:
- return ((IAggregateWorkingSet) workingSet).getComponents();
+ List<IWorkingSet> allWorkingSets = new ArrayList<IWorkingSet>();
+ allWorkingSets.addAll(Arrays.asList(((IAggregateWorkingSet) workingSet).getComponents()));
+ allWorkingSets.addAll(Arrays.asList(localWorkingSetManager.getWorkingSets()));
+ return allWorkingSets.toArray(new IWorkingSet[allWorkingSets.size()]);
case IUIConstants.MODE_NORMAL:
return getWorkingSetElements(workingSet);
}
}
+
return getWorkingSetElements(workingSet);
}
return NO_CHILDREN;
@@ -183,6 +221,8 @@ public class WorkingSetsContentProvider implements ICommonContentProvider {
public void dispose() {
helper = null;
extensionStateModel.removePropertyChangeListener(rootModeListener);
+ // If we have create the local working set manager, we have to dispose it
+ if (!(targetExplorer instanceof View)) localWorkingSetManager.dispose();
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/Sorter.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeViewerSorter.java
index fe88b4728..9fad1ced0 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/navigator/Sorter.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/trees/TreeViewerSorter.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tm.te.tcf.ui.internal.navigator;
+package org.eclipse.tm.te.ui.trees;
import java.util.Arrays;
import java.util.regex.Matcher;
@@ -25,8 +25,7 @@ import org.eclipse.swt.widgets.Tree;
/**
* Common sorter implementation.
*/
-public class Sorter extends TreePathViewerSorter {
- private final ILabelProvider labelProvider = new LabelProviderDelegate();
+public class TreeViewerSorter extends TreePathViewerSorter {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
@@ -34,7 +33,7 @@ public class Sorter extends TreePathViewerSorter {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
- return doCompare(e1, e2, doGetSortColumnLabel(viewer), doGetSortColumnIndex(viewer) , doDetermineInverter(viewer));
+ return doCompare(viewer, e1, e2, doGetSortColumnLabel(viewer), doGetSortColumnIndex(viewer) , doDetermineInverter(viewer));
}
return super.compare(viewer, e1, e2);
}
@@ -42,14 +41,15 @@ public class Sorter extends TreePathViewerSorter {
/**
* Returns the text to compare for the given node and column index.
*
+ * @param viewer The viewer or <code>null</code>.
* @param node The node or <code>null</code>.
* @param index The column index or <code>-1</code>.
*
* @return The text for the given node and column index or <code>null</code>.
*/
- protected String doGetText(Object node, int index) {
- if (node != null) {
- return labelProvider.getText(node);
+ protected String doGetText(Viewer viewer, Object node, int index) {
+ if (node != null && doGetLabelProvider(viewer) != null) {
+ return doGetLabelProvider(viewer).getText(node);
}
return null;
}
@@ -118,6 +118,7 @@ public class Sorter extends TreePathViewerSorter {
/**
* Compare the given model nodes by the given sort column and inverter.
*
+ * @param viewer The viewer or <code>null</code>.
* @param node1 The first node or <code>null</code>.
* @param node2 The second node or <code>null</code>.
* @param sortColumn The sort column text or <code>null</code>.
@@ -126,14 +127,14 @@ public class Sorter extends TreePathViewerSorter {
*
* @return The compare result.
*/
- protected int doCompare(Object node1, Object node2, String sortColumn, int index, int inverter) {
+ protected int doCompare(Viewer viewer, Object node1, Object node2, String sortColumn, int index, int inverter) {
if (node1 == null && node2 == null) return 0;
if (node1 != null && node2 == null) return 1;
if (node1 == null && node2 != null) return -1;
// Get the labels
- String text1 = doGetText(node1, index);
- String text2 = doGetText(node2, index);
+ String text1 = doGetText(viewer, node1, index);
+ String text2 = doGetText(viewer, node2, index);
// The tree sorts not strictly alphabetical. First comes entries starting with numbers,
// second entries starting with uppercase and than all the rest. Additional, if a label contains

Back to the top