View | Details | Raw Unified | Return to bug 344023 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java (-3 / +3 lines)
Lines 64-70 public class VirtualFindAction extends Action implements IUpdate { Link Here
64
	
64
	
65
    private TreeModelViewer fClientViewer;
65
    private TreeModelViewer fClientViewer;
66
	
66
	
67
	private class VirtualViewerListener implements IViewerUpdateListener, ILabelUpdateListener {
67
	protected class VirtualViewerListener implements IViewerUpdateListener, ILabelUpdateListener {
68
	    
68
	    
69
	    private boolean fViewerUpdatesComplete = false;
69
	    private boolean fViewerUpdatesComplete = false;
70
	    private boolean fLabelUpdatesComplete = false;
70
	    private boolean fLabelUpdatesComplete = false;
Lines 150-156 public class VirtualFindAction extends Action implements IUpdate { Link Here
150
		fClientViewer = viewer;
150
		fClientViewer = viewer;
151
	}
151
	}
152
152
153
	private VirtualTreeModelViewer initVirtualViewer(TreeModelViewer clientViewer, VirtualViewerListener listener) {
153
	protected VirtualTreeModelViewer initVirtualViewer(TreeModelViewer clientViewer, VirtualViewerListener listener) {
154
        Object input = clientViewer.getInput();
154
        Object input = clientViewer.getInput();
155
        ModelDelta stateDelta = new ModelDelta(input, IModelDelta.NO_CHANGE);
155
        ModelDelta stateDelta = new ModelDelta(input, IModelDelta.NO_CHANGE);
156
        clientViewer.saveElementState(TreePath.EMPTY, stateDelta, IModelDelta.EXPAND);
156
        clientViewer.saveElementState(TreePath.EMPTY, stateDelta, IModelDelta.EXPAND);
Lines 169-175 public class VirtualFindAction extends Action implements IUpdate { Link Here
169
        return fVirtualViewer;
169
        return fVirtualViewer;
170
	}
170
	}
171
	
171
	
172
	private IPresentationContext makeVirtualPresentationContext(final IPresentationContext clientViewerContext) {
172
	protected IPresentationContext makeVirtualPresentationContext(final IPresentationContext clientViewerContext) {
173
	    return new PresentationContext(clientViewerContext.getId()) {
173
	    return new PresentationContext(clientViewerContext.getId()) {
174
	        
174
	        
175
	        {
175
	        {
(-)a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewActionProvider.java (+50 lines)
Added Link Here
1
/*****************************************************************
2
 * Copyright (c) 2011 Texas Instruments and others
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Texas Instruments - View action override (Bug 344023)
10
 *****************************************************************/
11
package org.eclipse.debug.internal.ui.viewers.model.provisional;
12
13
import org.eclipse.jface.action.IAction;
14
import org.eclipse.ui.texteditor.IUpdate;
15
16
17
/**
18
 * An interface that allows an implementation to provide (contribute) its own
19
 * action which is used to override an action for the same action id.
20
 * 
21
 * @since 3.8
22
 */
23
public interface IViewActionProvider {
24
	/**
25
	 * Get action for a given presentation context and action id. Implementation
26
	 * class can use presentation context to figure out the view part or view
27
	 * model (IVMProvider) which wants to provide (contribute) an action. Once
28
	 * the view part or view model is known, the dedicated action for the view
29
	 * can be figured out by the implementation, view model, or some other
30
	 * classes.
31
	 * @param presentationContext presentation context
32
	 * @param actionID action id
33
	 * @return action or null
34
	 */
35
	public IAction getAction(IPresentationContext presentationContext, String actionID);
36
	
37
	/**
38
	 * Get action for a given presentation context and action id. Implementation
39
	 * class can use presentation context to figure out the view part or view
40
	 * model (IVMProvider) which wants to provide (contribute) an action. Once
41
	 * the view part or view model is known, the dedicated action for the view
42
	 * can be figured out by the implementation, view model, or some other
43
	 * classes.
44
	 * @param presentationContext presentation context
45
	 * @param actionID action id
46
	 * @return action or null
47
	 */
48
	public IUpdate[] getUpdatables(IPresentationContext presentationContext);
49
50
}
(-)a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionView.java (-2 / +1 lines)
Lines 83-89 public class ExpressionView extends VariablesView { Link Here
83
	protected void fillContextMenu(IMenuManager menu) {
83
	protected void fillContextMenu(IMenuManager menu) {
84
		menu.add(new Separator(IDebugUIConstants.EMPTY_EXPRESSION_GROUP));
84
		menu.add(new Separator(IDebugUIConstants.EMPTY_EXPRESSION_GROUP));
85
		menu.add(new Separator(IDebugUIConstants.EXPRESSION_GROUP));
85
		menu.add(new Separator(IDebugUIConstants.EXPRESSION_GROUP));
86
		menu.add(getAction(VARIABLES_FIND_ELEMENT_ACTION));
86
		menu.add(getAction(FIND_ACTION));
87
        ChangeVariableValueAction changeValueAction = (ChangeVariableValueAction)getAction("ChangeVariableValue"); //$NON-NLS-1$
87
        ChangeVariableValueAction changeValueAction = (ChangeVariableValueAction)getAction("ChangeVariableValue"); //$NON-NLS-1$
88
        if (changeValueAction.isApplicable()) {
88
        if (changeValueAction.isApplicable()) {
89
            menu.add(changeValueAction); 
89
            menu.add(changeValueAction); 
Lines 128-134 public class ExpressionView extends VariablesView { Link Here
128
        } else {
128
        } else {
129
            setViewerInput(DebugPlugin.getDefault().getExpressionManager());
129
            setViewerInput(DebugPlugin.getDefault().getExpressionManager());
130
        }
130
        }
131
        updateAction(VARIABLES_FIND_ELEMENT_ACTION);
132
        updateAction(FIND_ACTION);
131
        updateAction(FIND_ACTION);
133
	}
132
	}
134
	
133
	
(-)a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/modules/ModulesView.java (-1 / +1 lines)
Lines 60-66 public class ModulesView extends VariablesView { Link Here
60
    protected void fillContextMenu( IMenuManager menu ) {
60
    protected void fillContextMenu( IMenuManager menu ) {
61
        menu.add( new Separator( IDebugUIConstants.EMPTY_MODULES_GROUP ) );
61
        menu.add( new Separator( IDebugUIConstants.EMPTY_MODULES_GROUP ) );
62
        menu.add( new Separator( IDebugUIConstants.MODULES_GROUP ) );
62
        menu.add( new Separator( IDebugUIConstants.MODULES_GROUP ) );
63
        menu.add(getAction(VARIABLES_FIND_ELEMENT_ACTION));
63
        menu.add(getAction(FIND_ACTION));
64
        menu.add(new Separator());
64
        menu.add(new Separator());
65
        IAction action = new AvailableDetailPanesAction(this);
65
        IAction action = new AvailableDetailPanesAction(this);
66
        if (isDetailPaneVisible() && action.isEnabled()) {
66
        if (isDetailPaneVisible() && action.isEnabled()) {
(-)a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java (-43 / +69 lines)
Lines 24-29 import java.io.ByteArrayOutputStream; Link Here
24
import java.io.IOException;
24
import java.io.IOException;
25
import java.io.InputStreamReader;
25
import java.io.InputStreamReader;
26
import java.io.OutputStreamWriter;
26
import java.io.OutputStreamWriter;
27
import java.util.HashMap;
28
import java.util.Iterator;
29
import java.util.Map;
27
30
28
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IProgressMonitor;
29
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.IStatus;
Lines 31-36 import org.eclipse.core.runtime.ListenerList; Link Here
31
import org.eclipse.core.runtime.Status;
34
import org.eclipse.core.runtime.Status;
32
import org.eclipse.core.runtime.jobs.Job;
35
import org.eclipse.core.runtime.jobs.Job;
33
import org.eclipse.debug.core.DebugException;
36
import org.eclipse.debug.core.DebugException;
37
import org.eclipse.debug.core.DebugPlugin;
34
import org.eclipse.debug.internal.ui.DebugUIPlugin;
38
import org.eclipse.debug.internal.ui.DebugUIPlugin;
35
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
39
import org.eclipse.debug.internal.ui.DelegatingModelPresentation;
36
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
40
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
Lines 49-54 import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; Link Here
49
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor;
53
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor;
50
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
54
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
51
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
55
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
56
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewActionProvider;
52
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor;
57
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor;
53
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
58
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
54
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
59
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
Lines 284-289 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
284
	 */
289
	 */
285
	private ViewerInputService fInputService;
290
	private ViewerInputService fInputService;
286
	
291
	
292
	private Map fGlobalActionMap = new HashMap();
293
	
287
	/**
294
	/**
288
	 * Viewer input requester used to update the viewer once the viewer input has been
295
	 * Viewer input requester used to update the viewer once the viewer input has been
289
	 * resolved.
296
	 * resolved.
Lines 333-359 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
333
	 * Sash weights for a specific detail pane type
340
	 * Sash weights for a specific detail pane type
334
	 */
341
	 */
335
	protected static final String DETAIL_PANE_TYPE = "DETAIL_PANE_TYPE"; //$NON-NLS-1$
342
	protected static final String DETAIL_PANE_TYPE = "DETAIL_PANE_TYPE"; //$NON-NLS-1$
336
	
343
		
337
	/**
338
	 * Key for "Find..." action.
339
	 */
340
	protected static final String VARIABLES_FIND_ELEMENT_ACTION = FIND_ACTION + ".Variables"; //$NON-NLS-1$
341
342
	/**
343
	 * Key for "Select All" action.
344
	 */
345
	protected static final String VARIABLES_SELECT_ALL_ACTION = SELECT_ALL_ACTION + ".Variables"; //$NON-NLS-1$
346
	
347
	/**
348
	 * Key for "Copy" action.
349
	 */
350
	protected static final String VARIABLES_COPY_ACTION = COPY_ACTION + ".Variables"; //$NON-NLS-1$	
351
	
352
	/**
353
	 * Key for "Paste" action.
354
	 */
355
	protected static final String VARIABLES_PASTE_ACTION = PASTE_ACTION + ".Variables"; //$NON-NLS-1$	
356
	
357
    /**
344
    /**
358
     * Visits deltas to determine if details should be displayed
345
     * Visits deltas to determine if details should be displayed
359
     */
346
     */
Lines 449-455 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
449
	 */
436
	 */
450
	protected void viewerInputUpdateComplete(IViewerInputUpdate update) {
437
	protected void viewerInputUpdateComplete(IViewerInputUpdate update) {
451
	    setViewerInput(update.getInputElement());
438
	    setViewerInput(update.getInputElement());
452
        updateAction(VARIABLES_FIND_ELEMENT_ACTION);
453
        updateAction(FIND_ACTION);
439
        updateAction(FIND_ACTION);
454
	}
440
	}
455
	
441
	
Lines 657-663 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
657
	protected String getDetailPanePreferenceKey() {
643
	protected String getDetailPanePreferenceKey() {
658
		return IDebugPreferenceConstants.VARIABLES_DETAIL_PANE_ORIENTATION;
644
		return IDebugPreferenceConstants.VARIABLES_DETAIL_PANE_ORIENTATION;
659
	}
645
	}
660
		
646
	
661
	/**
647
	/**
662
	 * Create and return the main tree viewer that displays variable.
648
	 * Create and return the main tree viewer that displays variable.
663
	 */
649
	 */
Lines 671-681 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
671
			public void focusGained(FocusEvent e) {
657
			public void focusGained(FocusEvent e) {
672
				fTreeHasFocus = true;
658
				fTreeHasFocus = true;
673
				fSelectionProvider.setActiveProvider(variablesViewer);
659
				fSelectionProvider.setActiveProvider(variablesViewer);
674
				setAction(SELECT_ALL_ACTION, getAction(VARIABLES_SELECT_ALL_ACTION));
660
				setGlobalActions();
675
				setAction(COPY_ACTION, getAction(VARIABLES_COPY_ACTION));
676
				setAction(PASTE_ACTION, getAction(VARIABLES_PASTE_ACTION));
677
				setAction(FIND_ACTION, getAction(VARIABLES_FIND_ELEMENT_ACTION));
678
				getViewSite().getActionBars().updateActionBars();
679
			}
661
			}
680
			
662
			
681
			public void focusLost(FocusEvent e){
663
			public void focusLost(FocusEvent e){
Lines 683-692 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
683
			    // This should allow toolbar actions to remain active when the view
665
			    // This should allow toolbar actions to remain active when the view
684
			    // is de-activated but still visible.
666
			    // is de-activated but still visible.
685
			    // Bug 316850.
667
			    // Bug 316850.
686
				setAction(SELECT_ALL_ACTION, null);
668
				clearGlobalActions();
687
				setAction(COPY_ACTION,null);
688
				setAction(FIND_ACTION, null);
689
				setAction(PASTE_ACTION, null);
690
				getViewSite().getActionBars().updateActionBars();
669
				getViewSite().getActionBars().updateActionBars();
691
			}
670
			}
692
		});
671
		});
Lines 708-715 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
708
		return variablesViewer;
687
		return variablesViewer;
709
	}
688
	}
710
689
711
	
690
	private void setGlobalActions() {
712
	
691
		for (Iterator entryItr = fGlobalActionMap.entrySet().iterator(); entryItr.hasNext();) {
692
			Map.Entry entry = (Map.Entry)entryItr.next();
693
			setAction((String)entry.getKey(), (IAction)entry.getValue());
694
		}
695
		getViewSite().getActionBars().updateActionBars();		
696
	}
697
698
	private void clearGlobalActions() {
699
		for (Iterator keyItr = fGlobalActionMap.keySet().iterator(); keyItr.hasNext();) {
700
			String id = (String)keyItr.next();
701
			setAction((String)keyItr.next(), null);
702
703
		}
704
		getViewSite().getActionBars().updateActionBars();		
705
	}
706
713
	/**
707
	/**
714
	 * Returns the active debug context for this view based on the view's 
708
	 * Returns the active debug context for this view based on the view's 
715
	 * site IDs.
709
	 * site IDs.
Lines 929-936 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
929
		setAction("ChangeVariableValue", action); //$NON-NLS-1$
923
		setAction("ChangeVariableValue", action); //$NON-NLS-1$
930
		
924
		
931
		action= new VirtualFindAction(getVariablesViewer());
925
		action= new VirtualFindAction(getVariablesViewer());
932
		setAction(VARIABLES_FIND_ELEMENT_ACTION, action);
926
		fGlobalActionMap.put(FIND_ACTION, action);
933
	} 	
927
	} 	
928
929
	public IAction getAction(String actionID) {
930
		Viewer viewer = getViewer();
931
		if (viewer != null) {
932
			IViewActionProvider actionProvider = (IViewActionProvider) DebugPlugin.getAdapter(
933
					viewer.getInput(), IViewActionProvider.class);
934
			if (actionProvider != null) {
935
				IAction action = actionProvider.getAction(getPresentationContext(), actionID);
936
				if (action != null) {
937
					return action;
938
				}
939
			}
940
		}
941
		return super.getAction(actionID);
942
	}
943
	
944
	public void updateObjects() {
945
		super.updateObjects();
946
		IViewActionProvider actionProvider = (IViewActionProvider) DebugPlugin.getAdapter(
947
				getViewer().getInput(), IViewActionProvider.class);
948
		if (actionProvider != null) {
949
			IUpdate[] inputUpdatables = actionProvider.getUpdatables(fPresentationContext);
950
			for (int i = 0; i < inputUpdatables.length; i++) {
951
				inputUpdatables[i].update();
952
			}
953
		}
954
		if (fTreeHasFocus) {
955
			setGlobalActions();
956
			getViewSite().getActionBars().updateActionBars();
957
		}
958
	}
934
	
959
	
935
	/* (non-Javadoc)
960
	/* (non-Javadoc)
936
	 * 
961
	 * 
Lines 940-947 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
940
	 */
965
	 */
941
	protected void createContextMenu(Control menuControl) {
966
	protected void createContextMenu(Control menuControl) {
942
		super.createContextMenu(menuControl);
967
		super.createContextMenu(menuControl);
943
		setAction(VARIABLES_COPY_ACTION, getAction(COPY_ACTION));
968
		fGlobalActionMap.put(COPY_ACTION, getAction(COPY_ACTION));
944
		setAction(VARIABLES_PASTE_ACTION, getAction(PASTE_ACTION));
969
		fGlobalActionMap.put(PASTE_ACTION, getAction(PASTE_ACTION));
945
	}
970
	}
946
971
947
	/**
972
	/**
Lines 1020-1029 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
1020
	* @param menu The menu to add the item to.
1045
	* @param menu The menu to add the item to.
1021
	*/
1046
	*/
1022
	protected void fillContextMenu(IMenuManager menu) {
1047
	protected void fillContextMenu(IMenuManager menu) {
1023
1024
		menu.add(new Separator(IDebugUIConstants.EMPTY_VARIABLE_GROUP));
1048
		menu.add(new Separator(IDebugUIConstants.EMPTY_VARIABLE_GROUP));
1025
		menu.add(new Separator(IDebugUIConstants.VARIABLE_GROUP));
1049
		menu.add(new Separator(IDebugUIConstants.VARIABLE_GROUP));
1026
		menu.add(getAction(VARIABLES_FIND_ELEMENT_ACTION));
1050
		menu.add(getAction(FIND_ACTION));
1027
		ChangeVariableValueAction changeValueAction = (ChangeVariableValueAction)getAction("ChangeVariableValue"); //$NON-NLS-1$
1051
		ChangeVariableValueAction changeValueAction = (ChangeVariableValueAction)getAction("ChangeVariableValue"); //$NON-NLS-1$
1028
		if (changeValueAction.isApplicable()) {
1052
		if (changeValueAction.isApplicable()) {
1029
		    menu.add(changeValueAction); 
1053
		    menu.add(changeValueAction); 
Lines 1181-1187 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
1181
	 * @param actionId the ID of the action to update
1205
	 * @param actionId the ID of the action to update
1182
	 */
1206
	 */
1183
	protected void updateAction(String actionId) {
1207
	protected void updateAction(String actionId) {
1184
		IAction action= getAction(actionId);
1208
		IAction action = (IAction)fGlobalActionMap.get(actionId);
1209
		if (action == null) {
1210
			action= getAction(actionId);
1211
		}
1185
		if (action instanceof IUpdate) {
1212
		if (action instanceof IUpdate) {
1186
			((IUpdate) action).update();
1213
			((IUpdate) action).update();
1187
		}
1214
		}
Lines 1365-1371 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
1365
		fVisitor.reset();
1392
		fVisitor.reset();
1366
		delta.accept(fVisitor);
1393
		delta.accept(fVisitor);
1367
		
1394
		
1368
		updateAction(VARIABLES_FIND_ELEMENT_ACTION);
1395
		updateAction(FIND_ACTION);
1369
        updateAction("CollapseAll");
1396
        updateAction("CollapseAll");
1370
	}
1397
	}
1371
1398
Lines 1381-1387 public class VariablesView extends AbstractDebugView implements IDebugContextLis Link Here
1381
				showViewer();
1408
				showViewer();
1382
			}
1409
			}
1383
			if (TreePath.EMPTY.equals(update.getElementPath())) {
1410
			if (TreePath.EMPTY.equals(update.getElementPath())) {
1384
			    updateAction(VARIABLES_FIND_ELEMENT_ACTION);
1411
			    updateAction(FIND_ACTION);
1385
			    updateAction("CollapseAll");
1412
			    updateAction("CollapseAll");
1386
			}
1413
			}
1387
		}
1414
		}
1388
- 

Return to bug 344023