Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2013-03-11 15:06:27 -0400
committerPawel Piech2013-03-11 15:06:27 -0400
commitd08c4f116a729cd3e24cf0d753cc7d435b70e9d7 (patch)
tree5bf6a2b71dd8f48a1f32c5c97c99cbc89656bd46
parentb7053c11ba5d798ba237dc3dd66553dd88691c12 (diff)
downloadeclipse.platform.debug-d08c4f116a729cd3e24cf0d753cc7d435b70e9d7.tar.gz
eclipse.platform.debug-d08c4f116a729cd3e24cf0d753cc7d435b70e9d7.tar.xz
eclipse.platform.debug-d08c4f116a729cd3e24cf0d753cc7d435b70e9d7.zip
Revert "Bug 372181 - Working set support for Expressions View"
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementCompareRequest.java46
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementMementoRequest.java89
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionMementoService.java116
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java142
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/IElementCompareRequestor.java18
5 files changed, 9 insertions, 402 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementCompareRequest.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementCompareRequest.java
deleted file mode 100644
index 09a699626..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementCompareRequest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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 Systems - Fix for viewer state save/restore [188704]
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.ui.IMemento;
-
-/**
- * @since 3.3
- */
-public class ExpressionElementCompareRequest extends ExpressionElementMementoRequest implements IElementCompareRequest {
-
- private boolean fEqual;
-
- public ExpressionElementCompareRequest(ExpressionView view, IPresentationContext context, Object element, IMemento memento, String[] workingSets) {
- super(view, context, element, memento, workingSets);
- }
- public void setEqual(boolean equal) {
- fEqual = equal;
- }
-
- public boolean isEqual() {
- return fEqual;
- }
-
- protected void performFinished() {
- fView.compareRequestFinished(ExpressionElementCompareRequest.this);
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("IElementCompareRequest: "); //$NON-NLS-1$
- buf.append(getElement());
- return buf.toString();
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementMementoRequest.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementMementoRequest.java
deleted file mode 100644
index 646277175..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionElementMementoRequest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 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 Systems - Fix for viewer state save/restore [188704]
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import org.eclipse.debug.internal.core.commands.Request;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IMemento;
-
-/**
- * @since 3.3
- */
-public class ExpressionElementMementoRequest extends Request implements IElementMementoRequest {
-
- final ExpressionView fView;
- final IPresentationContext fContext;
- final Object fElement;
- IMemento fMemento;
- final String[] fWorkingSets;
-
- public ExpressionElementMementoRequest(ExpressionView view, IPresentationContext context, Object element, IMemento memento, String[] workingSets) {
- fView = view;
- fContext = context;
- fElement = element;
- fWorkingSets = workingSets;
- fMemento = memento;
- }
-
- public Object getElement() {
- return fElement;
- }
-
- public TreePath getElementPath() {
- return TreePath.EMPTY;
- }
-
- public IMemento getMemento() {
- return fMemento;
- }
-
- public Object getViewerInput() {
- return fElement;
- }
-
- public void done() {
- Display display = fView.getSite().getShell().getDisplay();
- if (display == null || display.isDisposed()) return;
-
- if (display.getThread() != Thread.currentThread()) {
- display.asyncExec(new Runnable() {
- public void run() {
- performFinished();
- }
- });
- } else {
- performFinished();
- }
- }
-
- protected void performFinished() {
- fView.mementoRequestFinished(this);
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("IElementCompareRequest: "); //$NON-NLS-1$
- buf.append(getElement());
- return buf.toString();
- }
-
- public IPresentationContext getPresentationContext() {
- return fContext;
- }
-
- public String[] getWorkingSets() {
- return fWorkingSets;
- }
-}
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
deleted file mode 100644
index dec5c1af7..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionMementoService.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * 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 e6228b0c5..8a9cbc0c3 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
@@ -14,12 +14,7 @@ package org.eclipse.debug.internal.ui.views.expression;
import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
@@ -34,10 +29,6 @@ import org.eclipse.debug.internal.ui.actions.expressions.EditWatchExpressinInPla
import org.eclipse.debug.internal.ui.actions.expressions.PasteWatchExpressionsAction;
import org.eclipse.debug.internal.ui.actions.variables.ChangeVariableValueAction;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
-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.IElementMementoRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
@@ -55,7 +46,6 @@ import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -70,9 +60,7 @@ import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.XMLMemento;
import org.eclipse.ui.actions.ActionFactory;
/**
@@ -87,21 +75,12 @@ public class ExpressionView extends VariablesView {
*/
private static final String PREF_ELEMENT_WORKINGSET = DebugUIPlugin.getUniqueIdentifier() + ".workingSet"; //$NON-NLS-1$
- private static final IWorkingSet[] EMPTY_WORKING_SETS = new IWorkingSet[0];
private PasteWatchExpressionsAction fPasteAction;
private EditWatchExpressinInPlaceAction fEditInPlaceAction;
private IWorkingSet[] fWorkingSets;
- private boolean fAutoSelectWorkingSets = true;
-
- private Map fWorkingSetMementos = new LinkedHashMap();
-
- private Set fPendingCompareRequests;
-
- private ExpressionElementMementoRequest fPendingMementoRequest;
-
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getHelpContextId()
*/
@@ -153,10 +132,6 @@ public class ExpressionView extends VariablesView {
super.contextActivated(new StructuredSelection(DebugPlugin.getDefault().getExpressionManager()));
} else {
super.contextActivated(selection);
- if (fAutoSelectWorkingSets) {
- Object element = ((IStructuredSelection)selection).getFirstElement();
- compareElementMementos(element);
- }
}
if (isAvailable() && isVisible()) {
updateAction("ContentAssist"); //$NON-NLS-1$
@@ -176,18 +151,6 @@ public class ExpressionView extends VariablesView {
updateAction(FIND_ACTION);
}
- public void elementCompareComplete(String[] workingSetNames) {
- IWorkingSetManager mgr = PlatformUI.getWorkbench().getWorkingSetManager();
- List workingSetList = new ArrayList();
- for (int j = 0; j < workingSetNames.length; j++) {
- IWorkingSet workingSet = mgr.getWorkingSet(workingSetNames[j]);
- if (workingSet != null) {
- workingSetList.add(workingSet);
- }
- }
- doApplyWorkingSets((IWorkingSet[])workingSetList.toArray(new IWorkingSet[workingSetList.size()]));
- }
-
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.views.variables.VariablesView#getDetailPanePreferenceKey()
*/
@@ -230,8 +193,6 @@ public class ExpressionView extends VariablesView {
public void dispose() {
fEditInPlaceAction.dispose();
- cancelPendingCompareRequests();
- if (fPendingMementoRequest != null) fPendingMementoRequest.cancel();
super.dispose();
}
@@ -315,20 +276,16 @@ public class ExpressionView extends VariablesView {
public Viewer createViewer(Composite parent) {
TreeModelViewer viewer = (TreeModelViewer)super.createViewer(parent);
+ List list = new ArrayList();
IMemento[] workingsetMementos = getMemento().getChildren(PREF_ELEMENT_WORKINGSET);
- if (workingsetMementos != null) {
- List list = new ArrayList();
- 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)
- list.add(workingSet);
- }
- fWorkingSets = (IWorkingSet[]) list.toArray(new IWorkingSet[list.size()]);
- } else {
- fWorkingSets = EMPTY_WORKING_SETS;
+ 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)
+ list.add(workingSet);
}
+ fWorkingSets = (IWorkingSet[]) list.toArray(new IWorkingSet[list.size()]);
getWorkingSetFilter(viewer).setSelectedWorkingSets(fWorkingSets);
updateWorkingSetsProperty(viewer.getPresentationContext());
@@ -345,52 +302,11 @@ public class ExpressionView extends VariablesView {
}
public void applyWorkingSets(IWorkingSet[] selectedWorkingSets) {
- doApplyWorkingSets(selectedWorkingSets);
- saveWorkingSetsMemento();
- }
-
- private void doApplyWorkingSets(IWorkingSet[] selectedWorkingSets) {
fWorkingSets = selectedWorkingSets;
TreeModelViewer viewer = (TreeModelViewer)getViewer();
getWorkingSetFilter(viewer).setSelectedWorkingSets(fWorkingSets);
updateWorkingSetsProperty(viewer.getPresentationContext());
- getViewer().refresh();
- }
-
- private void saveWorkingSetsMemento() {
- if (fPendingMementoRequest != null) {
- fPendingMementoRequest.cancel();
- }
- Object element = getDebugContextElement();
- IElementMementoProvider provider = ViewerAdapterService.getMementoProvider(element);
- if (provider == null) return;
-
- XMLMemento expressionMemento = XMLMemento.createWriteRoot("EXPRESSION_WORKING_SETS_MEMENTO"); //$NON-NLS-1$
- fPendingMementoRequest = new ExpressionElementMementoRequest(
- this, getPresentationContext(), getDebugContextElement(), expressionMemento, getWorkingSetNames());
- provider.encodeElements(new IElementMementoRequest[] { fPendingMementoRequest });
- }
-
- void mementoRequestFinished(ExpressionElementMementoRequest request) {
- if (!request.isCanceled()) {
- fWorkingSetMementos.put(request.getMemento(), request.getWorkingSets());
- }
- }
-
- private String[] getWorkingSetNames() {
- String[] names = new String[fWorkingSets.length];
- for (int i = 0; i < fWorkingSets.length; i++) {
- names[i] = fWorkingSets[i].getName();
- }
- return names;
- }
-
- private Object getDebugContextElement() {
- ISelection selection = getDebugContext();
- if (selection == null || selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
- return DebugPlugin.getDefault().getExpressionManager();
- }
- return ((IStructuredSelection)selection).getFirstElement();
+ getViewer().refresh();
}
private void updateWorkingSetsProperty(IPresentationContext presentationContext) {
@@ -423,44 +339,4 @@ public class ExpressionView extends VariablesView {
return workingSetFilter;
}
- private void compareElementMementos(Object source) {
- IElementMementoProvider provdier = ViewerAdapterService.getMementoProvider(source);
- if (provdier != null) {
- Set requests = new HashSet(fWorkingSetMementos.size() * 4/3);
- for (Iterator itr = fWorkingSetMementos.entrySet().iterator(); itr.hasNext();) {
- Map.Entry entry = (Map.Entry)itr.next();
- requests.add( new ExpressionElementCompareRequest(
- this, getPresentationContext(), source, (IMemento)entry.getKey(), (String[])entry.getValue()) );
- }
-
- // cancel any pending update
- cancelPendingCompareRequests();
- fPendingCompareRequests = requests;
- provdier.compareElements((IElementCompareRequest[])
- fPendingCompareRequests.toArray(new IElementCompareRequest[fPendingCompareRequests.size()]) );
- } else {
- doApplyWorkingSets(EMPTY_WORKING_SETS);
- }
- }
-
- void compareRequestFinished(final ExpressionElementCompareRequest request) {
- if (fPendingCompareRequests != null && fPendingCompareRequests.remove(request)) {
- if (!request.isCanceled() && request.isEqual()) {
- elementCompareComplete(request.getWorkingSets());
- cancelPendingCompareRequests();
- } else if (fPendingCompareRequests.isEmpty()) {
- elementCompareComplete(new String[0]);
- fPendingCompareRequests = null;
- }
- }
- }
-
- private void cancelPendingCompareRequests() {
- if (fPendingCompareRequests == null) return;
- for (Iterator itr = fPendingCompareRequests.iterator(); itr.hasNext();) {
- ((IElementCompareRequest)itr.next()).cancel();
- }
- fPendingCompareRequests = null;
- }
-
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/IElementCompareRequestor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/IElementCompareRequestor.java
deleted file mode 100644
index 1939b4323..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/IElementCompareRequestor.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.views.expression;
-
-
-/**
- */
-public interface IElementCompareRequestor {
- public void elementCompareComplete(final ExpressionElementCompareRequest[] requests);
-}

Back to the top