diff options
author | Pawel Piech | 2013-03-11 19:05:53 +0000 |
---|---|---|
committer | Pawel Piech | 2013-03-11 19:05:53 +0000 |
commit | b7053c11ba5d798ba237dc3dd66553dd88691c12 (patch) | |
tree | b10d8915e9a0e5906614bca02bc1267f9db5eb1d | |
parent | 54b29436993ccb175c0818b82d531f12d99de8c8 (diff) | |
download | eclipse.platform.debug-b7053c11ba5d798ba237dc3dd66553dd88691c12.tar.gz eclipse.platform.debug-b7053c11ba5d798ba237dc3dd66553dd88691c12.tar.xz eclipse.platform.debug-b7053c11ba5d798ba237dc3dd66553dd88691c12.zip |
Revert "Bug 372181 - Working set support for Expressions View"
This reverts commit faf798e1240cdf437166b53f7dd3fcb5cc7e84ef.
6 files changed, 158 insertions, 203 deletions
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index ce197ff4e..6f83288f9 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties @@ -399,9 +399,7 @@ debug.ui.component.label = Platform Debug UI 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 -expressionWorkingSet.autoSelectAction.label=&Auto Select Working Sets -expressionWorkingSet.autoSelectAction.tooltip=Automatically select Working Sets based on view input
\ No newline at end of file +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 7ba2988ae..15a24ea3b 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -3169,8 +3169,8 @@ M4 = Platform-specific fourth key <extension point="org.eclipse.ui.workingSets"> <workingSet id="org.eclipse.debug.ui.expressionWorkingSet" - name="%expressionWorkingSet.name" - description="%expressionWorkingSet.description" + name="%ExpressionWorkingSet.name" + description="%ExpressionWorkingSet.description" icon="icons/full/obj16/expression_workingset.gif" pageClass="org.eclipse.debug.internal.ui.views.expression.ExpressionWorkingSetPage" elementAdapterClass="org.eclipse.debug.internal.ui.views.expression.ExpressionWorkingSetElementAdapter" @@ -3183,21 +3183,13 @@ M4 = Platform-specific fourth key targetID="org.eclipse.debug.ui.ExpressionView" id="org.eclipse.debug.ui.expressionview.toolbar.workingset"> <action - class="org.eclipse.debug.internal.ui.actions.expressions.AutoSelectWorkingSetsAction" - helpContextId="expression_auto_select_working_sets_action_context" - id="org.eclipse.debug.ui.expressionView.toolbar.autoSelectWorkingSets" - label="%expressionWorkingSet.autoSelectAction.label" - menubarPath="additions" - style="toggle" - tooltip="%expressionWorkingSet.autoSelectAction.tooltip"/> - <action class="org.eclipse.debug.internal.ui.actions.expressions.ExpressionWorkingSetsAction" helpContextId="expression_working_sets_action_context" id="org.eclipse.debug.ui.expressionView.toolbar.workingSets" - label="%expressionWorkingSet.manageAction.label" + label="%ExpressionWorkingSet.manageAction.label" menubarPath="additions" style="push" - tooltip="%expressionWorkingSet.manageAction.tooltip"/> + tooltip="%ExpressionWorkingSet.manageAction.tooltip"/> </viewContribution> </extension> diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AutoSelectWorkingSetsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AutoSelectWorkingSetsAction.java deleted file mode 100644 index 393dad206..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/AutoSelectWorkingSetsAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.actions.expressions; - - -import org.eclipse.debug.internal.ui.views.expression.ExpressionView; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * Open a watch expression dialog and add the created watch expression to the - * expression view. - */ -public class AutoSelectWorkingSetsAction extends WatchExpressionAction implements IViewActionDelegate { - - IViewPart fView; - - /** - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - fView = view; - super.init(view); - } - - /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - if (fView instanceof ExpressionView) { - ((ExpressionView)fView).setAutoSelectWoringSets(action.isChecked()); - } - } - - /** - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - if (fView instanceof ExpressionView) { - boolean autoSelect = ((ExpressionView)fView).isAutoSelectWorkingSets(); - if (!action.isChecked() == autoSelect) { - action.setChecked(autoSelect); - } - } - } - -} 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 72ab37aab..6d9fa0336 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 @@ -117,6 +117,7 @@ public class ExpressionManagerContentProvider extends ElementContentProvider { String expressionText = DefaultLabelProvider.encodeEsacpedChars((String)value); IWatchExpression newExpression= DebugPlugin.getDefault().getExpressionManager().newWatchExpression(expressionText); + DebugPlugin.getDefault().getExpressionManager().addExpression(newExpression); newExpression.setExpressionContext(getContext()); //if any working sets are applied to this view, @@ -137,10 +138,6 @@ public class ExpressionManagerContentProvider extends ElementContentProvider { workingSet.setElements(newElements); } } - // Add the new expression to the expression manager only after - // working sets are updated. Otherwise, the viewer may filter - // out the new expression. - DebugPlugin.getDefault().getExpressionManager().addExpression(newExpression); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionMementoService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionMementoService.java new file mode 100644 index 000000000..dec5c1af7 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionMementoService.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River - Pawel Piech - NPE when closing the Variables view (Bug 213719) + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.expression; + +import org.eclipse.debug.internal.ui.viewers.model.ViewerAdapterService; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider; +import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate; + +/** + */ +public class ExpressionMementoService { + + /** + * An input object which will yield a null input element. + * + * @since 3.6 + */ + public final static Object NULL_INPUT = new IViewerInputProvider() { + public void update(IViewerInputUpdate update) { + update.setInputElement(null); + update.done(); + } + }; + + // previous update request, cancelled when a new request comes in + private ExpressionElementCompareRequest[] fPendingRequests = null; + + private int fOutstandingRequestCount = 0; + + private IElementCompareRequestor fRequestor = null; + + private ITreeModelViewer fViewer; + + /** + * Constructs a viewer input service for the given requester and presentation context. + * + * @param viewer for which inputs are required + * @param requestor client requesting viewer inputs + */ + public ExpressionMementoService(ITreeModelViewer viewer, IElementCompareRequestor requestor) { + fRequestor = requestor; + fViewer = viewer; + } + + /** + * Resolves a viewer input derived from the given source object. + * Reports the result to the given this service's requester. A requester may be called back + * in the same or thread, or asynchronously in a different thread. Cancels any previous + * incomplete request from this service's requester. + * + * @param source source from which to derive a viewer input + */ + public void compareInputMementos(Object source, IElementCompareRequest[] requests) { + IElementMementoProvider provdier = ViewerAdapterService.getMementoProvider(source); + synchronized (this) { + // cancel any pending update + //cancelPendingUpdates(); + fOutstandingRequestCount = requests.length; + fPendingRequests = new ExpressionElementCompareRequest[requests.length]; + for (int i = 0; i < requests.length; i++) { + fPendingRequests[i] = new ExpressionElementCompareRequest( + fViewer.getPresentationContext(), requests[i].getElement(), requests[i].getMemento(), null) + { + public void done() { + if (!isCanceled()) { + synchronized(ExpressionMementoService.this) { + fOutstandingRequestCount--; + if (fOutstandingRequestCount == 0) { + fRequestor.elementCompareComplete(fPendingRequests); + fPendingRequests = null; + } + } + } + } + + }; + } + } + if (provdier == null) { + for (int i = 0; i < requests.length; i++) { + fPendingRequests[i].setEqual(false); + fPendingRequests[i].done(); + } + } else { + provdier.compareElements(fPendingRequests); + } + } + + private synchronized void cancelPendingUpdates() { + if (fPendingRequests != null) { + for (int i = 0; i < fPendingRequests.length; i++) { + fPendingRequests[i].cancel(); + } + } + fPendingRequests = null; + } + + /** + * Disposes this viewer input service, canceling any pending jobs. + */ + public synchronized void dispose() { + cancelPendingUpdates(); + } +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java index 4185c798e..e6228b0c5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java @@ -13,11 +13,6 @@ package org.eclipse.debug.internal.ui.views.expression; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -77,7 +72,6 @@ import org.eclipse.ui.IWorkbenchCommandConstants; 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.actions.ActionFactory; @@ -86,16 +80,13 @@ import org.eclipse.ui.actions.ActionFactory; * pane. */ public class ExpressionView extends VariablesView { - - // The preference name for autoselect working sets toggle - private static final String PREF_WORKINGSETS_AUTOSELECT = DebugUIPlugin.getUniqueIdentifier() + ".workingSetAutoselect"; //$NON-NLS-1$ - - // The preference name for saving fWorkingSets + + /** + * the preference name for the view part of the sash form + * @since 3.9 + */ private static final String PREF_ELEMENT_WORKINGSET = DebugUIPlugin.getUniqueIdentifier() + ".workingSet"; //$NON-NLS-1$ - // The preference name for saving fWorkingSetMementos. - private static final String PREF_ELEMENT_WORKINGSET_MEMENTOS = DebugUIPlugin.getUniqueIdentifier() + ".workingSetMementos"; //$NON-NLS-1$ - private static final IWorkingSet[] EMPTY_WORKING_SETS = new IWorkingSet[0]; private PasteWatchExpressionsAction fPasteAction; @@ -103,7 +94,7 @@ public class ExpressionView extends VariablesView { private IWorkingSet[] fWorkingSets; - private boolean fAutoSelectnWorkingSets = true; + private boolean fAutoSelectWorkingSets = true; private Map fWorkingSetMementos = new LinkedHashMap(); @@ -162,7 +153,7 @@ public class ExpressionView extends VariablesView { super.contextActivated(new StructuredSelection(DebugPlugin.getDefault().getExpressionManager())); } else { super.contextActivated(selection); - if (fAutoSelectnWorkingSets) { + if (fAutoSelectWorkingSets) { Object element = ((IStructuredSelection)selection).getFirstElement(); compareElementMementos(element); } @@ -185,16 +176,6 @@ public class ExpressionView extends VariablesView { updateAction(FIND_ACTION); } - public void setAutoSelectWoringSets(boolean autoSelect) { - if (fAutoSelectnWorkingSets != autoSelect) { - fAutoSelectnWorkingSets = autoSelect; - } - } - - public boolean isAutoSelectWorkingSets() { - return fAutoSelectnWorkingSets; - } - public void elementCompareComplete(String[] workingSetNames) { IWorkingSetManager mgr = PlatformUI.getWorkbench().getWorkingSetManager(); List workingSetList = new ArrayList(); @@ -333,109 +314,39 @@ public class ExpressionView extends VariablesView { public Viewer createViewer(Composite parent) { TreeModelViewer viewer = (TreeModelViewer)super.createViewer(parent); - - initWorkingSets(); - initWorkingSetMementos(); - getWorkingSetFilter(viewer).setSelectedWorkingSets(fWorkingSets); - updateWorkingSetsProperty(viewer.getPresentationContext()); - - return viewer; - } - - private String[] loadWorkingSetNames(IMemento memento) { - IMemento[] workingsets = memento.getChildren(PREF_ELEMENT_WORKINGSET); - if (workingsets != null) { - List list = new ArrayList(); - for (int j=0; j<workingsets.length; j++) { - list.add(workingsets[j].getID()); - } - return (String[])list.toArray(new String[list.size()]); - } - return new String[0]; - } - - private void initWorkingSets() { - String[] workingSetNames = loadWorkingSetNames(getMemento()); - List list = new ArrayList(); - for (int j = 0; j < workingSetNames.length; j++) { - IWorkingSet workingsetObject = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetNames[j]); - if (workingsetObject != null) { - list.add(workingsetObject); - } - } - fWorkingSets = (IWorkingSet[]) list.toArray(new IWorkingSet[list.size()]); - } - - private void initWorkingSetMementos() { - IMemento[] workingsetMementos = getMemento().getChildren(PREF_ELEMENT_WORKINGSET_MEMENTOS); + + IMemento[] workingsetMementos = getMemento().getChildren(PREF_ELEMENT_WORKINGSET); if (workingsetMementos != null) { + List list = new ArrayList(); for (int j=0; j<workingsetMementos.length; j++) { - String[] workingSetNames = loadWorkingSetNames(workingsetMementos[j]); - String string = workingsetMementos[j].getID(); - if(string.length() > 0 && workingSetNames != null) { - ByteArrayInputStream bin = new ByteArrayInputStream(string.getBytes()); - InputStreamReader reader = new InputStreamReader(bin); - try { - XMLMemento workingSetsKey = XMLMemento.createReadRoot(reader); - fWorkingSetMementos.put(workingSetsKey, workingSetNames); - } catch (WorkbenchException e) { - } finally { - try { - reader.close(); - bin.close(); - } catch (IOException e){} - } - } + IMemento workingSetMemento = workingsetMementos[j]; + String workingSetName = workingSetMemento.getID(); + IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); + if (workingSet != null) + list.add(workingSet); } + fWorkingSets = (IWorkingSet[]) list.toArray(new IWorkingSet[list.size()]); + } else { + fWorkingSets = EMPTY_WORKING_SETS; } - } - - public void saveViewerState(IMemento memento) { - super.saveViewerState(memento); - - memento.putBoolean(PREF_WORKINGSETS_AUTOSELECT, fAutoSelectnWorkingSets); - if (!fAutoSelectnWorkingSets) { - saveWorkingSets(memento, getWorkingSetNames()); - } - saveWorkingSetMementos(memento); - } + getWorkingSetFilter(viewer).setSelectedWorkingSets(fWorkingSets); + updateWorkingSetsProperty(viewer.getPresentationContext()); - private void saveWorkingSets(IMemento memento, String[] workingSetNames) { - for (int i=0; i<workingSetNames.length; i++) { - memento.createChild(PREF_ELEMENT_WORKINGSET, workingSetNames[i]); - } - } - - private void saveWorkingSetMementos(IMemento memento) { - for (Iterator itr = fWorkingSetMementos.entrySet().iterator(); itr.hasNext();) { - Map.Entry entry = (Map.Entry)itr.next(); - String keyMementoString = getMenentoString((XMLMemento)entry.getKey()); - IMemento workingSetsForElementMemento = memento.createChild(PREF_ELEMENT_WORKINGSET_MEMENTOS, keyMementoString); - saveWorkingSets(workingSetsForElementMemento, (String[])entry.getValue()); - } + return viewer; } - private String getMenentoString(XMLMemento memento) { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - OutputStreamWriter writer = new OutputStreamWriter(bout); - - try { - memento.save(writer); - return bout.toString(); - } catch (IOException e) { - } finally { - try { - writer.close(); - bout.close(); - } catch (IOException e) { - } + public void saveViewerState(IMemento memento) { + super.saveViewerState(memento); + + + for (int i=0; i<fWorkingSets.length; i++) { + memento.createChild(PREF_ELEMENT_WORKINGSET, fWorkingSets[i].getName()); } - return null; } - + public void applyWorkingSets(IWorkingSet[] selectedWorkingSets) { doApplyWorkingSets(selectedWorkingSets); - saveWorkingSetsForInput(); + saveWorkingSetsMemento(); } private void doApplyWorkingSets(IWorkingSet[] selectedWorkingSets) { @@ -446,7 +357,7 @@ public class ExpressionView extends VariablesView { getViewer().refresh(); } - private void saveWorkingSetsForInput() { + private void saveWorkingSetsMemento() { if (fPendingMementoRequest != null) { fPendingMementoRequest.cancel(); } @@ -524,11 +435,9 @@ public class ExpressionView extends VariablesView { // cancel any pending update cancelPendingCompareRequests(); - if (!requests.isEmpty()) { - fPendingCompareRequests = requests; - provdier.compareElements((IElementCompareRequest[]) - fPendingCompareRequests.toArray(new IElementCompareRequest[fPendingCompareRequests.size()]) ); - } + fPendingCompareRequests = requests; + provdier.compareElements((IElementCompareRequest[]) + fPendingCompareRequests.toArray(new IElementCompareRequest[fPendingCompareRequests.size()]) ); } else { doApplyWorkingSets(EMPTY_WORKING_SETS); } |