From c958779d1cc310491ca2d8b6960fa8633ed0474f Mon Sep 17 00:00:00 2001
From: Abeer Bagul
Date: Wed, 16 Jan 2013 20:50:32 -0800
Subject: Bug 372181 - Working set support for Expressions View
Initial contribution.
---
org.eclipse.debug.ui/META-INF/MANIFEST.MF | 2 +
.../icons/full/obj16/expression_workingset.gif | Bin 0 -> 403 bytes
org.eclipse.debug.ui/plugin.properties | 8 +-
org.eclipse.debug.ui/plugin.xml | 58 +++
.../eclipse/debug/internal/ui/DebugUIPlugin.java | 5 +
.../ui/actions/expressions/ActionMessages.java | 23 ++
.../actions/expressions/ActionMessages.properties | 11 +
.../expressions/AssignWorkingSetsAction.java | 268 ++++++++++++++
.../internal/ui/expression/ExpressionFactory.java | 42 +++
.../ExpressionPersistableElementAdapter.java | 41 +++
...ExpressionPersistableElementAdapterFactory.java | 40 ++
.../workingset/ExpressionLabelProvider.java | 48 +++
.../ExpressionWorkingSetElementAdapter.java | 57 +++
.../workingset/ExpressionWorkingSetFilter.java | 85 +++++
.../ExpressionWorkingSetFilterManager.java | 405 +++++++++++++++++++++
.../workingset/ExpressionWorkingSetMessages.java | 34 ++
.../ExpressionWorkingSetMessages.properties | 20 +
.../workingset/ExpressionWorkingSetPage.java | 241 ++++++++++++
.../workingset/ExpressionWorkingSetsAction.java | 72 ++++
.../workingset/IExpressionWorkingSetConstants.java | 25 ++
.../elements/ExpressionManagerContentProvider.java | 49 ++-
.../ui/model/elements/IAddNewExpression.java | 20 +
22 files changed, 1551 insertions(+), 3 deletions(-)
create mode 100644 org.eclipse.debug.ui/icons/full/obj16/expression_workingset.gif
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.properties
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AssignWorkingSetsAction.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionFactory.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapter.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapterFactory.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionLabelProvider.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetElementAdapter.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilter.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilterManager.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.properties
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetPage.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetsAction.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/IExpressionWorkingSetConstants.java
create mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/IAddNewExpression.java
diff --git a/org.eclipse.debug.ui/META-INF/MANIFEST.MF b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
index d5bbbaa64..e1abac46d 100644
--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF
@@ -28,6 +28,8 @@ Export-Package: org.eclipse.debug.internal.ui;
org.eclipse.debug.internal.ui.contextlaunching;x-internal:=true,
org.eclipse.debug.internal.ui.contexts;x-internal:=true,
org.eclipse.debug.internal.ui.elements.adapters;x-friends:="org.eclipse.jdt.debug.ui",
+ org.eclipse.debug.internal.ui.expression;x-internal:=true,
+ org.eclipse.debug.internal.ui.expression.workingset;x-internal:=true,
org.eclipse.debug.internal.ui.importexport.breakpoints;x-internal:=true,
org.eclipse.debug.internal.ui.importexport.launchconfigurations;x-internal:=true,
org.eclipse.debug.internal.ui.launchConfigurations;x-friends:="org.eclipse.debug.tests",
diff --git a/org.eclipse.debug.ui/icons/full/obj16/expression_workingset.gif b/org.eclipse.debug.ui/icons/full/obj16/expression_workingset.gif
new file mode 100644
index 000000000..a2fe68184
Binary files /dev/null and b/org.eclipse.debug.ui/icons/full/obj16/expression_workingset.gif differ
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties
index 5b40f4e70..2a491ddce 100644
--- a/org.eclipse.debug.ui/plugin.properties
+++ b/org.eclipse.debug.ui/plugin.properties
@@ -393,4 +393,10 @@ console.out.label= Standard out
console.in.label= Standard in
console.err.label= Standard error
debug.ui.component.label = Platform Debug UI
-debug.core.component.label = Platform Debug Core
\ No newline at end of file
+debug.core.component.label = Platform Debug Core
+
+# Expression working set
+ExpressionWorkingSet.name=Expression
+ExpressionWorkingSet.description=A working set that contains expressions
+ExpressionWorkingSet.manageAction.label=&Working Sets...
+ExpressionWorkingSet.manageAction.tooltip=Manage Working Sets
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml
index 8dfbcd935..ce52c69fc 100644
--- a/org.eclipse.debug.ui/plugin.xml
+++ b/org.eclipse.debug.ui/plugin.xml
@@ -11,6 +11,7 @@
IBM Corporation - initial API and implementation
Patrick Chuong (Texas Instruments) - Improve usability of the breakpoint view (Bug 238956)
Patrick Chuong (Texas Instruments) - Move debug toolbar actions to main window (Bug 332784)
+ Abeer Bagul (Tensilica) - Working set support for Expressions view (Bug 372181)
-->
@@ -1229,6 +1230,24 @@
id="org.eclipse.debug.ui.actions.ConvertToWatchExpression">
+
@@ -3147,4 +3166,43 @@ M4 = Platform-specific fourth key
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index 963cd7551..5893e5b85 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -10,6 +10,7 @@
* Sascha Radike - bug 56642
* Martin Oberhuber (Wind River) - [327446] Avoid unnecessary wait-for-build dialog.
* Mohamed Hussein - bug 381175
+ * Abeer Bagul (Tensilica) - Working set support for Expressions view (Bug 372181)
*******************************************************************************/
package org.eclipse.debug.internal.ui;
@@ -60,6 +61,7 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager;
+import org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetFilterManager;
import org.eclipse.debug.internal.ui.launchConfigurations.ClosedProjectFilter;
import org.eclipse.debug.internal.ui.launchConfigurations.DeletedProjectFilter;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationEditDialog;
@@ -556,6 +558,9 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ILaunchListener,
// start the breakpoint organizer manager
BreakpointOrganizerManager.getDefault();
+
+ //start the expression workingset manager
+ ExpressionWorkingSetFilterManager.getInstance().init();
getLaunchConfigurationManager().startup();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.java
new file mode 100644
index 000000000..7c6c49684
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tensilica 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:
+ * Abeer Bagul (Tensilica) - initial API and implementation (bug 372181)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions.expressions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ActionMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.actions.expressions.ActionMessages"; //$NON-NLS-1$
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
+ }
+
+ public static String AssignWorkingSetsAction_0;
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.properties
new file mode 100644
index 000000000..c19069cd8
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/ActionMessages.properties
@@ -0,0 +1,11 @@
+###############################################################################
+# Copyright (c) 2012 Tensilica 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:
+# Abeer Bagul (Tensilica) - initial API and implementation (bug 372181)
+###############################################################################
+AssignWorkingSetsAction_0=Create working set...
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AssignWorkingSetsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AssignWorkingSetsAction.java
new file mode 100644
index 000000000..090262338
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AssignWorkingSetsAction.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tensilica 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:
+ * Abeer Bagul (Tensilica) - initial API and implementation (bug 372181)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions.expressions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.model.IWatchExpression;
+import org.eclipse.debug.internal.ui.expression.workingset.IExpressionWorkingSetConstants;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetNewWizard;
+
+/**
+ * Shows a submenu which lists all expression working sets.
+ * User can select any of the working sets in the submenu to assign
+ * selected expressions to this working set.
+ *
+ * The submenu also contains a menuitem "Create working set..."
+ * which opens the Add New Expression Working Set dialog.
+ */
+public class AssignWorkingSetsAction extends WatchExpressionAction {
+
+ /*
+ * Represents a checkable expression workingset menuitem
+ *
+ * When user checks this menuitem, expressions selected in the view
+ * will be added to this working set.
+ */
+ private class SelectWorkingSetAction extends Action {
+
+ private IWorkingSet workingSet;
+
+ SelectWorkingSetAction(IWorkingSet workingSet) {
+ super(workingSet.getName(), AS_CHECK_BOX);
+ this.workingSet = workingSet;
+ }
+
+ public void run() {
+ IWatchExpression[] selectedExpressions = getSelectedExpressions();
+ if (isChecked()) {
+ //add all selected expressions to the workingset
+ //ignore if any selected expression is already in the working set
+ List newExpressions = new ArrayList();
+ newExpressions.addAll(Arrays.asList(workingSet.getElements()));
+
+ IAdaptable[] existingExpressions = workingSet.getElements();
+
+ for (int i=0; i
+ * Returns the text of an expression to display in the checklist.
+ *
+ * @since 3.9
+ */
+public class ExpressionLabelProvider extends BaseLabelProvider implements ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (element instanceof IExpression)
+ {
+ if (columnIndex == 0)
+ return DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_EXPRESSION);
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof IExpression)
+ {
+ if (columnIndex == 0)
+ return ((IExpression) element).getExpressionText();
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetElementAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetElementAdapter.java
new file mode 100644
index 000000000..5a9906395
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetElementAdapter.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tensilica 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:
+ * Abeer Bagul (Tensilica Inc) - initial API and implementation (Bug 372181)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.expression.workingset;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetElementAdapter;
+
+/**
+ * Consulted by workbench pull down actions that add/remove selected elements to/from
+ * working sets. Allows expression working sets to select which elements are applicable
+ * for adding/removing.
+ *
+ * @since 3.9
+ */
+public class ExpressionWorkingSetElementAdapter implements
+ IWorkingSetElementAdapter {
+
+ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
+ for (int i = 0; i < elements.length; i++) {
+ IExpression expression = (IExpression)DebugPlugin.getAdapter(elements[i], IExpression.class);
+ if (expression != null) {
+ return selectExpressions(elements);
+ }
+ }
+ return elements;
+ }
+
+ private IAdaptable[] selectExpressions(IAdaptable[] elements) {
+ List expressions = new ArrayList(elements.length);
+ for (int i = 0; i < elements.length; i++) {
+ IExpression expression = (IExpression)DebugPlugin.getAdapter(elements[i], IExpression.class);
+ if (expression != null) {
+ expressions.add(expression);
+ }
+ }
+ return (IAdaptable[]) expressions.toArray(new IAdaptable[expressions.size()]);
+ }
+
+ public void dispose() {
+
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilter.java
new file mode 100644
index 000000000..d169b6388
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilter.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tensilica 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:
+ * Abeer Bagul (Tensilica Inc) - initial API and implementation (Bug 372181)
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.expression.workingset;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.internal.ui.model.elements.IAddNewExpression;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewerFilter;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * Holds a list of working sets selected for an instance of Expression view,
+ * and filters in only those expressions which are part of the selected working sets.
+ * If no working sets are selected for a view, it filters in all expressions.
+ *
+ * This filter always allows the "Add new expression" node.
+ * @since 3.9
+ */
+public class ExpressionWorkingSetFilter extends TreeModelViewerFilter {
+
+ private IWorkingSet[] selectedWorkingSets;
+
+ public IWorkingSet[] getSelectedWorkingSets() {
+ return selectedWorkingSets;
+ }
+
+ public void setSelectedWorkingSets(IWorkingSet[] selectedWorkingSets) {
+ this.selectedWorkingSets = selectedWorkingSets;
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+
+ if (selectedWorkingSets == null)
+ return true;
+
+ if (selectedWorkingSets.length == 0)
+ return true;
+
+ if (element instanceof IAddNewExpression)
+ return true;
+
+ if (element instanceof IAdaptable)
+ {
+ IExpression expressionToFilter = (IExpression) ((IAdaptable) element).getAdapter(IExpression.class);
+ if (expressionToFilter != null)
+ {
+ return isInWorkingSet(expressionToFilter);
+ }
+ }
+
+ return false;
+ }
+
+ private boolean isInWorkingSet(IExpression expression)
+ {
+ for (int i=0; i
+ * It saves info about which working sets are applied to each expression view,
+ * and restores the info and filter when an expression view is opened.
+ *
+ * @since 3.9
+ */
+public class ExpressionWorkingSetFilterManager implements IPropertyChangeListener
+{
+
+ private static final String PREF_WORKINGSETS = "expressionWorkingSets"; //$NON-NLS-1$
+ private static final String ELEMENT_WORKINGSETS = "expressionWorkingsets"; //$NON-NLS-1$
+ private static final String ELEMENT_EXPRESSIONVIEW = "expressionView"; //$NON-NLS-1$
+ private static final String ELEMENT_WORKINGSET = "workingSet"; //$NON-NLS-1$
+
+ private static ExpressionWorkingSetFilterManager INSTANCE;
+
+ private static boolean fInitialized = false;
+
+ private ExpressionWorkingSetFilterManager()
+ {
+
+ }
+
+ synchronized public static ExpressionWorkingSetFilterManager getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ExpressionWorkingSetFilterManager();
+ }
+ return INSTANCE;
+ }
+
+ synchronized public void init() {
+ if (fInitialized) return;
+ fInitialized = true;
+
+ initListeners();
+
+ final XMLMemento fworkingSetsMemento = getMemento();
+
+ new WorkbenchJob("Initializing expression view working sets") { //$NON-NLS-1$
+ { setSystem(true); }
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i=0; i
+ * Value is: org.eclipse.cdt.dsf.ui.expressionWorkingSet
+ *
+ */
+ public static final String EXPRESSION_WORKINGSET_ID = "org.eclipse.debug.ui.expressionWorkingSet"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java
index ea8846544..227b6fefa 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionManagerContentProvider.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Wind Rvier Systems - added support for columns (bug 235646)
+ * Abeer Bagul (Tensilica) - Working set support for Expressions view (bug 372181)
*******************************************************************************/
package org.eclipse.debug.internal.ui.model.elements;
@@ -22,11 +23,13 @@ import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.internal.ui.DebugUIMessages;
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetFilterManager;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
+import org.eclipse.debug.internal.ui.views.expression.ExpressionView;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.resource.JFaceResources;
@@ -36,6 +39,9 @@ import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
/**
* Default content provider for the expression manager.
@@ -48,10 +54,33 @@ public class ExpressionManagerContentProvider extends ElementContentProvider {
*
* @since 3.6
*/
- private static class AddNewExpressionElement implements IElementLabelProvider, IElementEditor, ICellModifier {
+ private static class AddNewExpressionElement implements IElementLabelProvider, IElementEditor, ICellModifier, IAddNewExpression {
+ /* Record the working sets applied to this view (none if null).
+ * When a new expression is created, add it to applied working sets.
+ */
+ private String[] workingSetNames = null;
+
public void update(ILabelUpdate[] updates) {
+
+ workingSetNames = null;
+
for (int i = 0; i < updates.length; i++) {
+
+ if (i == 0)
+ {
+ //from the presentation context, find out the list of
+ //working sets applied to this view.
+ IWorkbenchPart expressionView = updates[i].getPresentationContext().getPart();
+ IWorkingSet[] workingSets = ExpressionWorkingSetFilterManager.getWorkingSets((ExpressionView) expressionView);
+ if (workingSets.length > 0)
+ workingSetNames = new String[workingSets.length];
+ for (int j=0; j