Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 221912 Details for
Bug 372181
Working set support for Expressions View
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to platform (org.eclipse.debug.ui) for working set support for expressions
0001-working-set-for-expressions-first-cut.patch (text/plain), 58.05 KB, created by
Abeer Bagul
on 2012-10-04 12:48:44 EDT
(
hide
)
Description:
Patch to platform (org.eclipse.debug.ui) for working set support for expressions
Filename:
MIME Type:
Creator:
Abeer Bagul
Created:
2012-10-04 12:48:44 EDT
Size:
58.05 KB
patch
obsolete
>From c78910c7fbed8c62c7c781636357a25f7b3d1075 Mon Sep 17 00:00:00 2001 >From: Abeer Bagul <abeerbagul@gmail.com> >Date: Wed, 3 Oct 2012 17:16:00 +0530 >Subject: [PATCH] working set for expressions, first cut > >--- > org.eclipse.debug.ui/META-INF/MANIFEST.MF | 4 +- > .../icons/full/obj16/expression_workingset.gif | Bin 0 -> 403 bytes > org.eclipse.debug.ui/plugin.properties | 8 +- > org.eclipse.debug.ui/plugin.xml | 41 ++- > .../eclipse/debug/internal/ui/DebugUIPlugin.java | 4 + > .../internal/ui/expression/ExpressionFactory.java | 42 ++ > .../ExpressionPersistableElementAdapter.java | 41 ++ > ...ExpressionPersistableElementAdapterFactory.java | 40 ++ > .../workingset/ExpressionLabelProvider.java | 33 ++ > .../ExpressionWorkingSetElementAdapter.java | 53 +++ > .../workingset/ExpressionWorkingSetFilter.java | 80 ++++ > .../ExpressionWorkingSetFilterManager.java | 403 ++++++++++++++++++++ > .../workingset/ExpressionWorkingSetMessages.java | 37 ++ > .../ExpressionWorkingSetMessages.properties | 20 + > .../workingset/ExpressionWorkingSetPage.java | 238 ++++++++++++ > .../workingset/ExpressionWorkingSetsAction.java | 72 ++++ > .../workingset/IExpressionWorkingSetConstants.java | 25 ++ > .../elements/ExpressionManagerContentProvider.java | 47 +++- > .../ui/model/elements/IAddNewExpression.java | 26 ++ > 19 files changed, 1210 insertions(+), 4 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/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 83926ff..36164ac 100644 >--- a/org.eclipse.debug.ui/META-INF/MANIFEST.MF >+++ b/org.eclipse.debug.ui/META-INF/MANIFEST.MF >@@ -70,7 +70,9 @@ Export-Package: org.eclipse.debug.internal.ui; > org.eclipse.debug.ui.console, > org.eclipse.debug.ui.contexts, > org.eclipse.debug.ui.memory, >- org.eclipse.debug.ui.sourcelookup >+ org.eclipse.debug.ui.sourcelookup, >+ org.eclipse.debug.internal.ui.expression, >+ org.eclipse.debug.internal.ui.expression.workingset > Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", > org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)", > org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", >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 0000000000000000000000000000000000000000..a2fe68184bc09ecd312ad682ab4232544e64f976 >GIT binary patch >literal 403 >zcmZ?wbhEHb6krfwSgOll<d<g|m~9(YU>jCw7hYr+Q5+bR;1*jPmQfy>)1F#fy}3Yb >zeX0J&av(C;QfaWg#%O!3;qC_G{VgVk+Rcu3nIG>q@0+@~d)n%m^H;4}zjx)vqboNZ >zTea!P+O5adZ9TSW`=S3AOaEW3{eP?T|NUwIpDuaw;?4ipo3DQU|NrBm|6k9%{`LRQ >zfAWFiKNaVq)Wnk16ovB4k_?5Aj8p}8Pu~EAq)G+Hq}0?R1*gRH(i{fGpDc`A4E78< >z3_t+#I|EzCf%yd<I%2|{eHS?b)VgFGn3P#Ebfz&FYSpNjtu4q_d=j>};hDn)PiDOv >zT3K6}YHS*Qu38WjS;wHQqr;%7+1Sk5CfcB;6R57v&?mz(QN&(`jf+E4RW*>EOJTmS >zlaR{FRjXGDISD9l+_ZV4pcB8+&Rx5A@;mV<9z1mTAg?peiIb;Jc%OB4WUvMR_ruDY > >literal 0 >HcmV?d00001 > >diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties >index 7adbb70..40c5de4 100644 >--- a/org.eclipse.debug.ui/plugin.properties >+++ b/org.eclipse.debug.ui/plugin.properties >@@ -390,4 +390,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 db070de..169915a 100644 >--- a/org.eclipse.debug.ui/plugin.xml >+++ b/org.eclipse.debug.ui/plugin.xml >@@ -3131,7 +3131,7 @@ M4 = Platform-specific fourth key > </component> > <component > id="org.eclipse.debug.core.component" >- label="%debug.core.component.label"> >+ label="%debug.core.component.label">open > <bundle > consumed="true" > name="org.eclipse.debug.core"> >@@ -3139,4 +3139,43 @@ M4 = Platform-specific fourth key > </component> > </extension> > >+ <extension point="org.eclipse.ui.workingSets"> >+ <workingSet >+ id="org.eclipse.debug.ui.expressionWorkingSet" >+ name="%ExpressionWorkingSet.name" >+ description="%ExpressionWorkingSet.description" >+ icon="icons/full/obj16/expression_workingset.gif" >+ pageClass="org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetPage" >+ elementAdapterClass="org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetElementAdapter" >+ /> >+ </extension> >+ >+ <extension >+ point="org.eclipse.ui.viewActions"> >+ <viewContribution >+ targetID="org.eclipse.debug.ui.ExpressionView" >+ id="org.eclipse.debug.ui.expressionview.toolbar.workingset"> >+ <action >+ class="org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetsAction" >+ helpContextId="expression_working_sets_action_context" >+ id="org.eclipse.debug.ui.expressionView.toolbar.workingSets" >+ label="%ExpressionWorkingSet.manageAction.label" >+ menubarPath="additions" >+ style="push" >+ tooltip="%ExpressionWorkingSet.manageAction.tooltip"/> >+ </viewContribution> >+ </extension> >+ >+ <extension point="org.eclipse.core.runtime.adapters"> >+ <factory >+ class="org.eclipse.debug.internal.ui.expression.ExpressionPersistableElementAdapterFactory" >+ adaptableType="org.eclipse.debug.core.model.IExpression"> >+ <adapter type="org.eclipse.ui.IPersistableElement"/> >+ </factory> >+ </extension> >+ >+ <extension point="org.eclipse.ui.elementFactories"> >+ <factory id="org.eclipse.debug.ui.elementfactory.expressions" >+ class="org.eclipse.debug.internal.ui.expression.ExpressionFactory" /> >+ </extension> > </plugin> >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 963cd75..b50aa8a 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 >@@ -60,6 +60,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 +557,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/expression/ExpressionFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionFactory.java >new file mode 100644 >index 0000000..21c3326 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionFactory.java >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.ui.IElementFactory; >+import org.eclipse.ui.IMemento; >+ >+/** >+ * Factory to restore an expression from a memento. >+ * @since 3.9 >+ */ >+public class ExpressionFactory implements IElementFactory { >+ >+ public static final String ID = "org.eclipse.debug.ui.elementfactory.expressions"; //$NON-NLS-1$ >+ >+ public IAdaptable createElement(IMemento memento) { >+ String expressionText = memento.getString(ExpressionPersistableElementAdapter.TAG_EXPRESSION_TEXT); >+ if (expressionText != null) >+ { >+ IExpression[] expressions = DebugPlugin.getDefault().getExpressionManager().getExpressions(); >+ for (int i=0; i<expressions.length; i++) { >+ IExpression expr = expressions[i]; >+ if (expr.getExpressionText().equals(expressionText)) >+ return expr; >+ } >+ } >+ >+ return null; >+ } >+ >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapter.java >new file mode 100644 >index 0000000..243b2ee >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapter.java >@@ -0,0 +1,41 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression; >+ >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.IPersistableElement; >+ >+/** >+ * This adapter saves an expression to a memento. >+ * It also returns ID of ExpressionFactory which is used to create a factory object, >+ * which in turn will restore the expression from the memento >+ * @since 3.9 >+ */ >+public class ExpressionPersistableElementAdapter implements IPersistableElement { >+ >+ public static final String TAG_EXPRESSION_TEXT = "TAG_EXPRESSION_TEXT"; //$NON-NLS-1$ >+ >+ private IExpression fExpression; >+ >+ public ExpressionPersistableElementAdapter(IExpression expression) { >+ this.fExpression = expression; >+ } >+ >+ public void saveState(IMemento memento) { >+ memento.putString(TAG_EXPRESSION_TEXT, fExpression.getExpressionText()); >+ } >+ >+ public String getFactoryId() { >+ return ExpressionFactory.ID; >+ } >+ >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapterFactory.java >new file mode 100644 >index 0000000..74842b0 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/ExpressionPersistableElementAdapterFactory.java >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression; >+ >+import org.eclipse.core.runtime.IAdapterFactory; >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.ui.IPersistableElement; >+ >+/** >+ * Adapts an expression to IPersistableElement. >+ * The adapter will save the expression to a memento. >+ * >+ * @see ExpressionPersistableElementAdapter >+ * @see ExpressionFactory >+ * @since 3.9 >+ */ >+public class ExpressionPersistableElementAdapterFactory implements >+ IAdapterFactory { >+ >+ public Object getAdapter(Object adaptableObject, Class adapterType) { >+ if (adapterType == IPersistableElement.class) >+ if (adaptableObject instanceof IExpression) >+ return new ExpressionPersistableElementAdapter((IExpression) adaptableObject); >+ >+ return null; >+ } >+ >+ public Class[] getAdapterList() { >+ return new Class[] {IPersistableElement.class}; >+ } >+ >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionLabelProvider.java >new file mode 100644 >index 0000000..076ede5 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionLabelProvider.java >@@ -0,0 +1,33 @@ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * @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 0000000..5f21f5a >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetElementAdapter.java >@@ -0,0 +1,53 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+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; >+ >+/** >+ * @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 0000000..d82904c >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilter.java >@@ -0,0 +1,80 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+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.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerFilter; >+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 ViewerFilter { >+ >+ 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<selectedWorkingSets.length; i++) >+ { >+ IWorkingSet exprWorkingSet = selectedWorkingSets[i]; >+ IAdaptable[] workingSetElements = exprWorkingSet.getElements(); >+ for (int j=0; j<workingSetElements.length; j++) >+ { >+ IAdaptable workingSetElement = workingSetElements[j]; >+ IExpression workingSetExpression = (IExpression) workingSetElement.getAdapter(IExpression.class); >+ if (expression.getExpressionText().equals(workingSetExpression.getExpressionText())) >+ return true; >+ } >+ } >+ >+ return false; >+ } >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilterManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilterManager.java >new file mode 100644 >index 0000000..81ddde7 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetFilterManager.java >@@ -0,0 +1,403 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+import java.io.ByteArrayOutputStream; >+import java.io.IOException; >+import java.io.OutputStreamWriter; >+import java.io.StringReader; >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.internal.ui.DebugUIPlugin; >+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer; >+import org.eclipse.debug.internal.ui.views.expression.ExpressionView; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.viewers.ViewerFilter; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.IPartListener2; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IViewReference; >+import org.eclipse.ui.IWindowListener; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPartReference; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.IWorkingSetManager; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.WorkbenchException; >+import org.eclipse.ui.XMLMemento; >+import org.eclipse.ui.progress.WorkbenchJob; >+ >+/** >+ * Manages expression working set filters for all expression views in the workbench. >+ * <p> >+ * 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<windows.length; i++) { >+ IWorkbenchWindow window = windows[i]; >+ IViewReference[] viewRefs = window.getActivePage().getViewReferences(); >+ for (int j=0; j<viewRefs.length; j++) { >+ IViewReference viewRef = viewRefs[j]; >+ try { >+ if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(viewRef.getId())) >+ { >+ IViewPart expressionView = viewRef.getView(false); >+ if (expressionView != null) >+ applyFilter(expressionView, fworkingSetsMemento); >+ } >+ } >+ finally { >+ >+ } >+ } >+ } >+ return Status.OK_STATUS; >+ } >+ }.schedule(); >+ } >+ >+ private void applyFilter(IViewPart expressionView, XMLMemento workingSetsMemento) >+ { >+ String viewTitle = expressionView.getTitle(); >+ >+ List workingSets = new ArrayList(); >+ >+ if (workingSetsMemento != null) >+ { >+ IMemento[] viewMementos = workingSetsMemento.getChildren(ELEMENT_EXPRESSIONVIEW); >+ for (int i=0; i<viewMementos.length; i++) { >+ IMemento viewMemento = viewMementos[i]; >+ if (viewTitle.equals(viewMemento.getID())) { >+ IMemento[] workingsetMementos = viewMemento.getChildren(ELEMENT_WORKINGSET); >+ for (int j=0; j<workingsetMementos.length; j++) { >+ IMemento workingSetMemento = workingsetMementos[j]; >+ String workingSetName = workingSetMemento.getID(); >+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); >+ if (workingSet != null) >+ workingSets.add(workingSet); >+ } >+ >+ break; >+ } >+ } >+ } >+ >+ applyWorkingSets((ExpressionView) expressionView, (IWorkingSet[]) workingSets.toArray(new IWorkingSet[0])); >+ } >+ >+ private void initListeners() { >+ IWorkbench wb = PlatformUI.getWorkbench(); >+ >+ final IPartListener2 partListener = new IPartListener2() { >+ >+ public void partVisible(IWorkbenchPartReference partRef) {} >+ >+ public void partInputChanged(IWorkbenchPartReference partRef) {} >+ >+ public void partHidden(IWorkbenchPartReference partRef) {} >+ >+ public void partDeactivated(IWorkbenchPartReference partRef) {} >+ >+ public void partBroughtToTop(IWorkbenchPartReference partRef) {} >+ >+ public void partActivated(IWorkbenchPartReference partRef) {} >+ >+ public void partOpened(IWorkbenchPartReference partRef) { >+ if (partRef instanceof IViewReference) { >+ if (! partRef.getId().equals(IDebugUIConstants.ID_EXPRESSION_VIEW)) >+ return; >+ IViewPart part = ((IViewReference) partRef).getView(false); >+ if (part != null) >+ { >+ applyFilter(part, getMemento()); >+ } >+ } >+ } >+ >+ public void partClosed(IWorkbenchPartReference partRef) {} >+ }; >+ // subscribe to existing workbench window listener >+ IWorkbenchWindow[] windows = wb.getWorkbenchWindows(); >+ for (int i=0; i<windows.length; i++) { >+ IWorkbenchWindow ww = windows[i]; >+ ww.getPartService().addPartListener(partListener); >+ } >+ >+ // subscribe to new workbench window listener >+ wb.addWindowListener(new IWindowListener() { >+ >+ public void windowDeactivated(IWorkbenchWindow window) {} >+ >+ public void windowActivated(IWorkbenchWindow window) {} >+ >+ public void windowClosed(IWorkbenchWindow window) {} >+ >+ public void windowOpened(IWorkbenchWindow window) { >+ window.getPartService().addPartListener(partListener); >+ } >+ }); >+ >+ PlatformUI.getWorkbench().getWorkingSetManager().addPropertyChangeListener(this); >+ } >+ >+ private static XMLMemento getMemento() >+ { >+ IPreferenceStore prefStore = DebugUIPlugin.getDefault().getPreferenceStore(); >+ String workingSetsMementoRaw = prefStore.getString(PREF_WORKINGSETS); >+ workingSetsMementoRaw = workingSetsMementoRaw.trim(); >+ if (workingSetsMementoRaw.length() == 0) >+ return null; >+ XMLMemento workingSetsMemento = null; >+ try { >+ workingSetsMemento = XMLMemento.createReadRoot(new StringReader(workingSetsMementoRaw)); >+ } catch (WorkbenchException e) { >+ DebugUIPlugin.log(e); >+ } >+ return workingSetsMemento; >+ } >+ >+ public static void applyWorkingSets(ExpressionView exprView, IWorkingSet[] selectedWorkingSets) >+ { >+ ExpressionWorkingSetFilter workingSetFilter = getFilter(exprView); >+ >+ workingSetFilter.setSelectedWorkingSets(selectedWorkingSets); >+ >+ exprView.getViewer().refresh(); >+ >+ saveWorkingSets(exprView, selectedWorkingSets); >+ } >+ >+ private static ExpressionWorkingSetFilter getFilter(ExpressionView exprView) >+ { >+ ExpressionWorkingSetFilter workingSetFilter = null; >+ >+ ViewerFilter[] existingFilters = ((TreeModelViewer) exprView.getViewer()).getFilters(); >+ for (int i=0; i<existingFilters.length; i++) { >+ ViewerFilter existingFilter = existingFilters[i]; >+ if (existingFilter instanceof ExpressionWorkingSetFilter) >+ { >+ workingSetFilter = (ExpressionWorkingSetFilter) existingFilter; >+ break; >+ } >+ } >+ >+ if (workingSetFilter == null) >+ { >+ workingSetFilter = new ExpressionWorkingSetFilter(); >+ ((TreeModelViewer) exprView.getViewer()).addFilter(workingSetFilter); >+ } >+ >+ return workingSetFilter; >+ } >+ >+ private static ExpressionView[] getExpressionViews() >+ { >+ List expressionViews = new ArrayList(); >+ >+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); >+ for (int i=0; i<windows.length; i++) { >+ IWorkbenchWindow window = windows[i]; >+ IViewReference[] viewRefs = window.getActivePage().getViewReferences(); >+ for (int j=0; j<viewRefs.length; j++) { >+ IViewReference viewRef = viewRefs[j]; >+ if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(viewRef.getId())) { >+ IViewPart expressionView = viewRef.getView(false); >+ if (expressionView != null) >+ expressionViews.add(expressionView); >+ } >+ } >+ } >+ >+ return (ExpressionView[]) expressionViews.toArray(new ExpressionView[0]); >+ } >+ >+ public static IWorkingSet[] getWorkingSets(ExpressionView exprView) >+ { >+ ExpressionWorkingSetFilter workingSetFilter = getFilter(exprView); >+ if (workingSetFilter == null) >+ return null; >+ >+ return workingSetFilter.getSelectedWorkingSets(); >+ } >+ >+ private static void saveWorkingSets(ExpressionView exprView, IWorkingSet[] selectedWorkingSets) >+ { >+ String viewTitle = exprView.getTitle(); >+ >+ XMLMemento rootMemento = XMLMemento.createWriteRoot(ELEMENT_WORKINGSETS); >+ >+ XMLMemento savedMemento = getMemento(); >+ >+ if (savedMemento != null) { >+ IMemento[] viewMementos = savedMemento.getChildren(ELEMENT_EXPRESSIONVIEW); >+ for (int i=0; i<viewMementos.length; i++) { >+ IMemento savedViewMemento = viewMementos[i]; >+ if (!viewTitle.equals(savedViewMemento.getID())) >+ { >+ IMemento newViewMemento = rootMemento.createChild(ELEMENT_EXPRESSIONVIEW, savedViewMemento.getID()); >+ >+ IMemento[] savedWorkingSetMementos = savedViewMemento.getChildren(ELEMENT_WORKINGSET); >+ for (int j=0; j<savedWorkingSetMementos.length; j++) { >+ IMemento savedWorkingSetMemento = savedWorkingSetMementos[j]; >+ newViewMemento.createChild(ELEMENT_WORKINGSET, savedWorkingSetMemento.getID()); >+ } >+ } >+ } >+ } >+ >+ IMemento viewMemento = rootMemento.createChild(ELEMENT_EXPRESSIONVIEW, viewTitle); >+ >+ for (int i=0; i<selectedWorkingSets.length; i++) { >+ IWorkingSet workingSet = selectedWorkingSets[i]; >+ viewMemento.createChild(ELEMENT_WORKINGSET, workingSet.getName()); >+ } >+ >+ ByteArrayOutputStream mementoOutputStream = new ByteArrayOutputStream(); >+ try { >+ rootMemento.save(new OutputStreamWriter(mementoOutputStream)); >+ } catch (IOException e) { >+ DebugUIPlugin.log(e); >+ } >+ >+ String workingSetsMementoRaw = mementoOutputStream.toString(); >+ >+ IPreferenceStore prefStore = DebugUIPlugin.getDefault().getPreferenceStore(); >+ prefStore.setValue(PREF_WORKINGSETS, workingSetsMementoRaw); >+ } >+ >+// private static IWorkingSet[] getExpressionWorkingSets() >+// { >+// List expressionWorkingSets = new ArrayList(); >+// >+// IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); >+// IWorkingSet[] workingSets = workingSetManager.getWorkingSets(); >+// for (int i=0; i<workingSets.length; i++) { >+// IWorkingSet workingSet = workingSets[i]; >+// if (workingSet.getId().equals(IExpressionWorkingSetConstants.EXPRESSION_WORKINGSET_ID)) >+// { >+// expressionWorkingSets.add(workingSet); >+// } >+// } >+// >+// return (IWorkingSet[]) expressionWorkingSets.toArray(new IWorkingSet[0]); >+// } >+ >+ public void propertyChange(PropertyChangeEvent event) { >+ if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(event.getProperty())) >+ { >+ IWorkingSet removedWorkingSet = (IWorkingSet) event.getOldValue(); >+ >+ ExpressionView[] views = getExpressionViews(); >+ for (int i=0; i<views.length; i++) { >+ ExpressionView expressionView = views[i]; >+ IWorkingSet[] appliedWorkingSets = getWorkingSets(expressionView); >+ if (appliedWorkingSets == null) >+ continue; >+ if (appliedWorkingSets.length == 0) >+ continue; >+ >+ List remainingWorkingSets = new ArrayList(); >+ >+ boolean isRemoved = false; >+ for (int j=0; j<appliedWorkingSets.length; j++) { >+ IWorkingSet appliedWorkingSet = appliedWorkingSets[j]; >+ if (removedWorkingSet.getName().equals(appliedWorkingSet.getName())) >+ { >+ isRemoved = true; >+ continue; >+ } >+ remainingWorkingSets.add(appliedWorkingSet); >+ } >+ >+ if (isRemoved) >+ applyWorkingSets(expressionView, (IWorkingSet[]) remainingWorkingSets.toArray(new IWorkingSet[0])); >+ } >+ } >+ else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(event.getProperty())) >+ { >+ IWorkingSet changedWorkingSet = (IWorkingSet) event.getNewValue(); >+ >+ ExpressionView[] views = getExpressionViews(); >+ for (int i=0; i<views.length; i++) { >+ ExpressionView expressionView = views[i]; >+ IWorkingSet[] appliedWorkingSets = getWorkingSets(expressionView); >+ if (appliedWorkingSets == null) >+ continue; >+ if (appliedWorkingSets.length == 0) >+ continue; >+ >+ List remainingWorkingSets = new ArrayList(); >+ >+ boolean isChanged = false; >+ for (int j=0; j<appliedWorkingSets.length; j++) { >+ IWorkingSet appliedWorkingSet = appliedWorkingSets[j]; >+ if (changedWorkingSet.getName().equals(appliedWorkingSet.getName())) >+ { >+ isChanged = true; >+ } >+ remainingWorkingSets.add(appliedWorkingSet); >+ } >+ >+ if (isChanged) >+ applyWorkingSets(expressionView, (IWorkingSet[]) remainingWorkingSets.toArray(new IWorkingSet[0])); >+ } >+ } >+ >+ } >+ >+ >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.java >new file mode 100644 >index 0000000..a5ad8a2 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.java >@@ -0,0 +1,37 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * @since 3.9 >+ */ >+public class ExpressionWorkingSetMessages extends NLS >+{ >+ static >+ { >+ initializeMessages("org.eclipse.debug.internal.ui.expression.workingset.ExpressionWorkingSetMessages", //$NON-NLS-1$ >+ ExpressionWorkingSetMessages.class); >+ } >+ >+ public static String Page_Title; >+ public static String Page_Description; >+ >+ public static String WorkingSetName_label; >+ public static String Expressions_label; >+ public static String SelectAll; >+ public static String DeselectAll; >+ >+ public static String Error_whitespace; >+ public static String Error_emptyName; >+ public static String Error_nameExists; >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.properties >new file mode 100644 >index 0000000..ccde9fb >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetMessages.properties >@@ -0,0 +1,20 @@ >+############################################################################### >+# 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 >+############################################################################### >+ >+Page_Title=Expression Working Set >+Page_Description=Enter a working set name and select expressions. >+WorkingSetName_label=&Working set name: >+Expressions_label=&Expressions: >+SelectAll=Select &All >+DeselectAll=&Deselect All >+Error_whitespace=Working set name must not have leading or trailing whitespace >+Error_emptyName=Enter working set name >+Error_nameExists=A working set with that name already exists >\ No newline at end of file >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetPage.java >new file mode 100644 >index 0000000..fde6547 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetPage.java >@@ -0,0 +1,238 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.model.IExpression; >+import org.eclipse.debug.ui.IDebugUIConstants; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.ArrayContentProvider; >+import org.eclipse.jface.viewers.CheckboxTableViewer; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.IWorkingSetManager; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.IWorkingSetPage; >+ >+/** >+ * @since 3.9 >+ */ >+public class ExpressionWorkingSetPage extends WizardPage implements >+ IWorkingSetPage { >+ >+ private static final String PAGE_NAME = "expressionWorkingSetPage"; //$NON-NLS-1$ >+ >+ private Text txtWorkingSetName; >+ private CheckboxTableViewer expressionsViewer; >+ >+ private boolean isFirstCheck; >+ private IWorkingSet workingSet; >+ >+ public ExpressionWorkingSetPage() >+ { >+ super(PAGE_NAME, >+ ExpressionWorkingSetMessages.Page_Title, >+ null); >+ setDescription(ExpressionWorkingSetMessages.Page_Description); >+ isFirstCheck = true; >+ } >+ >+ public void createControl(Composite parent) >+ { >+ initializeDialogUnits(parent); >+ >+ Composite composite= new Composite(parent, SWT.NONE); >+ composite.setLayout(new GridLayout()); >+ composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ setControl(composite); >+ >+ Label label= new Label(composite, SWT.WRAP); >+ label.setText(ExpressionWorkingSetMessages.WorkingSetName_label); >+ GridData gd= new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); >+ label.setLayoutData(gd); >+ >+ txtWorkingSetName= new Text(composite, SWT.SINGLE | SWT.BORDER); >+ txtWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); >+ txtWorkingSetName.addModifyListener( >+ new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ validateInput(); >+ } >+ } >+ ); >+ txtWorkingSetName.setFocus(); >+ >+ label= new Label(composite, SWT.WRAP); >+ label.setText(ExpressionWorkingSetMessages.Expressions_label); >+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); >+ label.setLayoutData(gd); >+ >+ expressionsViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); >+ expressionsViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ expressionsViewer.setContentProvider(new ArrayContentProvider()); >+ expressionsViewer.setLabelProvider(new ExpressionLabelProvider()); >+ >+ // Add select / deselect all buttons >+ Composite buttonComposite = new Composite(composite, SWT.NONE); >+ buttonComposite.setLayout(new GridLayout(2, false)); >+ buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); >+ >+ Button selectAllButton = new Button(buttonComposite, SWT.PUSH); >+ selectAllButton.setText(ExpressionWorkingSetMessages.SelectAll); >+ selectAllButton.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent selectionEvent) { >+ expressionsViewer.getTable().selectAll(); >+ expressionsViewer.setCheckedElements( >+ ((IStructuredSelection) expressionsViewer.getSelection()).toArray()); >+ expressionsViewer.setGrayedElements(new Object[] {}); >+ expressionsViewer.getTable().deselectAll(); >+ validateInput(); >+ } >+ }); >+ Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); >+ deselectAllButton.setText(ExpressionWorkingSetMessages.DeselectAll); >+ deselectAllButton.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent selectionEvent) { >+ expressionsViewer.setCheckedElements(new Object[] {}); >+ validateInput(); >+ } >+ }); >+ >+ Dialog.applyDialogFont(composite); >+ >+ populateData(); >+ } >+ >+ private void populateData() >+ { >+ //get all expressions defined in the workspace >+ IExpression[] allExpressions = DebugPlugin.getDefault().getExpressionManager().getExpressions(); >+ expressionsViewer.setInput(allExpressions); >+ >+ IViewPart expressionView = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() >+ .findView(IDebugUIConstants.ID_EXPRESSION_VIEW); >+ >+ if (workingSet != null) >+ { >+ IAdaptable[] checkedExpressions = workingSet.getElements(); >+ expressionsViewer.setCheckedElements(checkedExpressions); >+ } >+ else >+ { >+ IStructuredSelection selection; >+ if (expressionView == null) { >+ selection = new StructuredSelection(); >+ } else { >+ selection = (IStructuredSelection)expressionView.getViewSite().getSelectionProvider().getSelection(); >+ } >+ List checkedExpressions = new ArrayList(); >+ Iterator it1 = selection.iterator(); >+ while (it1.hasNext()) >+ { >+ IExpression checkedExpr = (IExpression) DebugPlugin.getAdapter(it1.next(), IExpression.class); >+ if (checkedExpr != null) >+ checkedExpressions.add(checkedExpr); >+ } >+ >+ expressionsViewer.setCheckedElements(checkedExpressions.toArray()); >+ } >+ >+ if (workingSet != null) >+ txtWorkingSetName.setText(workingSet.getName()); >+ validateInput(); >+ >+ } >+ >+ public void finish() { >+ String workingSetName = txtWorkingSetName.getText(); >+ Object[] checkedElements = expressionsViewer.getCheckedElements(); >+ IExpression[] checkedExpressions = new IExpression[checkedElements.length]; >+ for (int i=0; i<checkedElements.length; i++) { >+ Object checkedElement = checkedElements[i]; >+ checkedExpressions[i] = (IExpression) checkedElement; >+ } >+ >+ if (workingSet == null) { >+ IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager(); >+ workingSet = workingSetManager.createWorkingSet(workingSetName, checkedExpressions); >+ } else { >+ workingSet.setName(workingSetName); >+ workingSet.setElements(checkedExpressions); >+ } >+ } >+ >+ public IWorkingSet getSelection() { >+ return workingSet; >+ } >+ >+ public void setSelection(IWorkingSet workingSet) { >+ Assert.isNotNull(workingSet, "Working set must not be null"); //$NON-NLS-1$ >+ this.workingSet = workingSet; >+ if (getContainer() != null && getShell() != null && txtWorkingSetName != null) { >+ isFirstCheck= false; >+ txtWorkingSetName.setText(workingSet.getName()); >+ validateInput(); >+ } >+ } >+ >+ /** >+ * validates the current input of the page to determine if the finish button can be enabled >+ */ >+ private void validateInput() { >+ String errorMessage= null; >+ String newText= txtWorkingSetName.getText(); >+ >+ if (! newText.equals(newText.trim())) >+ errorMessage = ExpressionWorkingSetMessages.Error_whitespace; >+ if (newText.equals("")) { //$NON-NLS-1$ >+ if (isFirstCheck) { >+ setPageComplete(false); >+ isFirstCheck= false; >+ return; >+ } >+ errorMessage = ExpressionWorkingSetMessages.Error_emptyName; >+ } >+ isFirstCheck = false; >+ if (errorMessage == null && (workingSet == null || newText.equals(workingSet.getName()) == false)) { >+ IWorkingSet[] workingSets= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets(); >+ for (int i= 0; i < workingSets.length; i++) { >+ if (newText.equals(workingSets[i].getName())) { >+ errorMessage = ExpressionWorkingSetMessages.Error_nameExists; >+ } >+ } >+ } >+ setErrorMessage(errorMessage); >+ setPageComplete(errorMessage == null); >+ } >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetsAction.java >new file mode 100644 >index 0000000..c7cdc83 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/ExpressionWorkingSetsAction.java >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+import org.eclipse.debug.internal.ui.views.expression.ExpressionView; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; >+ >+/** >+ * Opens the Working set wizard where user can define expression working sets. >+ * @since 3.9 >+ */ >+public class ExpressionWorkingSetsAction implements IViewActionDelegate, >+ IActionDelegate2 { >+ >+ private ExpressionView fView; >+ >+ public void run(IAction action) { >+ IWorkingSetSelectionDialog selectionDialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog( >+ PlatformUI.getWorkbench().getDisplay().getActiveShell(), >+ true, >+ new String[] {IExpressionWorkingSetConstants.EXPRESSION_WORKINGSET_ID}); >+ >+ selectionDialog.setSelection(ExpressionWorkingSetFilterManager.getWorkingSets(fView)); >+ >+ if (selectionDialog.open() != Window.OK) >+ return; >+ >+ IWorkingSet[] selectedWorkingSets = selectionDialog.getSelection(); >+ if (selectedWorkingSets == null) >+ return; >+ >+ ExpressionWorkingSetFilterManager.applyWorkingSets(fView, selectedWorkingSets); >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ >+ } >+ >+ public void init(IAction action) { >+ >+ } >+ >+ public void dispose() { >+ fView = null; >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void init(IViewPart view) { >+ fView = (ExpressionView) view; >+ } >+ >+} >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/IExpressionWorkingSetConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/IExpressionWorkingSetConstants.java >new file mode 100644 >index 0000000..c4d23d5 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/expression/workingset/IExpressionWorkingSetConstants.java >@@ -0,0 +1,25 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.expression.workingset; >+ >+/** >+ * @since 3.9 >+ */ >+public interface IExpressionWorkingSetConstants >+{ >+ /** >+ * Identifier for expression working set type. >+ * <br> >+ * Value is: <code>org.eclipse.cdt.dsf.ui.expressionWorkingSet</code> >+ * >+ */ >+ 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 ea88465..7467a35 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 >@@ -22,11 +22,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 +38,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 +53,28 @@ 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 { > >+ private String[] workingSetNames = null; >+ > public void update(ILabelUpdate[] updates) { >+ >+ workingSetNames = null; >+ > for (int i = 0; i < updates.length; i++) { >+ >+ if (i == 0) >+ { >+ 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<workingSets.length; j++) >+ { >+ workingSetNames[j] = workingSets[j].getName(); >+ } >+ } >+ > String[] columnIds = updates[i].getColumnIds(); > if (columnIds == null) { > updateLabel(updates[i], 0); >@@ -107,6 +130,20 @@ public class ExpressionManagerContentProvider extends ElementContentProvider { > DebugPlugin.getDefault().getExpressionManager().newWatchExpression(expressionText); > DebugPlugin.getDefault().getExpressionManager().addExpression(newExpression); > newExpression.setExpressionContext(getContext()); >+ >+ if (workingSetNames != null) >+ { >+ for (int i=0; i<workingSetNames.length; i++) >+ { >+ String workingSetName = workingSetNames[i]; >+ IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); >+ IAdaptable[] existingElements = workingSet.getElements(); >+ IAdaptable[] newElements = new IAdaptable[existingElements.length + 1]; >+ System.arraycopy(existingElements, 0, newElements, 0, existingElements.length); >+ newElements[newElements.length - 1] = newExpression; >+ workingSet.setElements(newElements); >+ } >+ } > } > } > >@@ -121,6 +158,14 @@ public class ExpressionManagerContentProvider extends ElementContentProvider { > return context; > } > >+ public String[] getWorkingSetNames() { >+ return workingSetNames; >+ } >+ >+ public void setWorkingSetNames(String[] workingSetNames) { >+ this.workingSetNames = workingSetNames; >+ } >+ > } > > private static final AddNewExpressionElement ADD_NEW_EXPRESSION_ELEMENT = new AddNewExpressionElement(); >diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/IAddNewExpression.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/IAddNewExpression.java >new file mode 100644 >index 0000000..bb086d9 >--- /dev/null >+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/IAddNewExpression.java >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * 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 >+ *******************************************************************************/ >+package org.eclipse.debug.internal.ui.model.elements; >+ >+/** >+ * Interface to be implemented by objects which represent the "Add new expression" node in Expressions view. >+ * An object which implements this interface will always be visible in the view, >+ * even if user has selected working sets to filter expressions visible in the view. >+ * <p> >+ * This interface records the working sets applied to the view. >+ * Any new expression will be added to all working sets. >+ */ >+public interface IAddNewExpression { >+ >+ public String[] getWorkingSetNames(); >+ >+ public void setWorkingSetNames(String[] workingSetNames); >+} >-- >1.7.5.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 372181
:
211378
|
211379
|
213745
| 221912 |
222396
|
228310