Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 284363 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/debug/internal/ui/commands/actions/DropToFrameCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAllAction.java (+1 lines)
Lines 18-23 Link Here
18
import org.eclipse.debug.internal.ui.DebugPluginImages;
18
import org.eclipse.debug.internal.ui.DebugPluginImages;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
21
import org.eclipse.debug.ui.actions.DebugCommandAction;
21
import org.eclipse.jface.resource.ImageDescriptor;
22
import org.eclipse.jface.resource.ImageDescriptor;
22
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jface.viewers.StructuredSelection;
24
import org.eclipse.jface.viewers.StructuredSelection;
(-)ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java (-31 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 *  Copyright (c) 2004, 2008 IBM Corporation and others.
2
 *  Copyright (c) 2004, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
Lines 20-25 Link Here
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
21
import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate;
21
import org.eclipse.debug.internal.ui.actions.RelaunchActionDelegate;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
22
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
23
import org.eclipse.debug.ui.actions.DebugCommandAction;
23
import org.eclipse.debug.ui.contexts.DebugContextEvent;
24
import org.eclipse.debug.ui.contexts.DebugContextEvent;
24
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelection;
Lines 30-66 Link Here
30
 */
31
 */
31
public class TerminateAndRelaunchAction extends DebugCommandAction {
32
public class TerminateAndRelaunchAction extends DebugCommandAction {
32
	
33
	
33
	class Participant implements ICommandParticipant {
34
    public void postExecute(IRequest request, final Object[] targets) {
34
		
35
        if (request.getStatus() == null || request.getStatus().isOK()) {
35
		private Object[] fTargets;
36
            DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
36
37
                public void run() {
37
		public Participant(Object[] targets) {
38
                    // Must be run in the UI thread since the launch can require
38
			fTargets = targets;
39
                    // prompting to proceed
39
		}
40
                    for (int i = 0; i < targets.length; i++) {
40
41
                        ILaunch launch = RelaunchActionDelegate.getLaunch(targets[i]);
41
		/* (non-Javadoc)
42
                        RelaunchActionDelegate.relaunch(launch.getLaunchConfiguration(), launch.getLaunchMode());
42
		 * @see org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant#requestDone(org.eclipse.debug.core.commands.IRequest)
43
                    }
43
		 */
44
                }
44
		public void requestDone(IRequest request) {
45
            }); 
45
			if (request.getStatus() == null || request.getStatus().isOK()) {
46
        }
46
				DebugUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
47
    }
47
		            public void run() {
48
		                // Must be run in the UI thread since the launch can require
49
		                // prompting to proceed
50
		            	for (int i = 0; i < fTargets.length; i++) {
51
		            		ILaunch launch = RelaunchActionDelegate.getLaunch(fTargets[i]);
52
		            		RelaunchActionDelegate.relaunch(launch.getLaunchConfiguration(), launch.getLaunchMode());
53
						}
54
		            }
55
		        });	
56
			}
57
		}
58
		
59
	}
60
48
61
	protected ICommandParticipant getCommandParticipant(Object[] targets) {
62
		return new Participant(targets);
63
	}
64
49
65
	protected Class getCommandType() {
50
	protected Class getCommandType() {
66
		return ITerminateHandler.class;
51
		return ITerminateHandler.class;
(-)ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandAction.java (-269 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.debug.internal.ui.commands.actions;
13
14
import org.eclipse.debug.ui.DebugUITools;
15
import org.eclipse.debug.ui.contexts.DebugContextEvent;
16
import org.eclipse.debug.ui.contexts.IDebugContextListener;
17
import org.eclipse.debug.ui.contexts.IDebugContextService;
18
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.IWorkbenchWindow;
25
import org.eclipse.ui.PlatformUI;
26
27
/**
28
 * Abstract base class for actions performing debug commands
29
 *
30
 * @since 3.3
31
 */
32
public abstract class DebugCommandAction extends Action implements IDebugContextListener {
33
34
	/**
35
	 * The window this action is working for.
36
	 */
37
    private IWorkbenchWindow fWindow;
38
    
39
    /**
40
     * The part this action is working for, or <code>null</code> if global to
41
     * a window.
42
     */
43
    private IWorkbenchPart fPart;
44
    
45
    /**
46
     * Command service.
47
     */
48
    private DebugCommandService fUpdateService;
49
    
50
    /**
51
     * Delegate this action is working for or <code>null</code> if none.
52
     */
53
    private DebugCommandActionDelegate fDelegate;
54
55
    /**
56
     * Constructor
57
     */
58
    public DebugCommandAction() {
59
        super();
60
        String helpContextId = getHelpContextId();
61
        if (helpContextId != null)
62
            PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId);
63
        setEnabled(false);
64
    }
65
66
	/**
67
     * Set the current delegate
68
     * @param delegate
69
     */
70
    public void setDelegate(DebugCommandActionDelegate delegate) {
71
        fDelegate = delegate;
72
    }
73
74
    /**
75
     * Executes this action on the given target object
76
     * 
77
     * @param target the target to perform the action on
78
     */
79
    protected boolean execute(Object[] targets) {
80
    	return fUpdateService.executeCommand(getCommandType(), targets, getCommandParticipant(targets));
81
    }
82
    
83
    /**
84
     * Creates and returns the command participant or <code>null</code>.
85
     * 
86
     * @return command participant to use on command completion
87
     */
88
    protected ICommandParticipant getCommandParticipant(Object[] targets) {
89
    	return null;
90
    }
91
    
92
    /**
93
     * Returns the command type this action executes.
94
     * 
95
     * @return command class.
96
     */
97
    abstract protected Class getCommandType();  
98
99
    /**
100
     * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
101
     */
102
    public void debugContextChanged(DebugContextEvent event) {
103
    	fUpdateService.postUpdateCommand(getCommandType(), this);
104
	}
105
106
    /**
107
     * @see org.eclipse.jface.action.Action#setEnabled(boolean)
108
     */
109
    public void setEnabled(boolean enabled) {
110
        super.setEnabled(enabled);
111
        if (fDelegate != null) {
112
            fDelegate.setEnabled(enabled);
113
        }
114
    }
115
116
    /**
117
     * Initializes this action for a specific part.
118
     * 
119
     * @param part workbench part
120
     */
121
    public void init(IWorkbenchPart part) {
122
        fPart = part;
123
        fWindow = part.getSite().getWorkbenchWindow();
124
        fUpdateService = DebugCommandService.getService(fWindow);
125
        IDebugContextService service = getDebugContextService();
126
		String partId = part.getSite().getId();
127
		service.addDebugContextListener(this, partId);
128
        ISelection activeContext = service.getActiveContext(partId);
129
        if (activeContext != null) {
130
        	fUpdateService.updateCommand(getCommandType(), this);
131
        } else {
132
        	setEnabled(getInitialEnablement());
133
        }
134
    }
135
    
136
    /**
137
     * Initializes the context action
138
     * @param window the window
139
     */
140
    public void init(IWorkbenchWindow window) {
141
        fWindow = window;
142
        fUpdateService = DebugCommandService.getService(fWindow);
143
        IDebugContextService contextService = getDebugContextService();
144
		contextService.addDebugContextListener(this);
145
        ISelection activeContext = contextService.getActiveContext();
146
        if (activeContext != null) {
147
        	fUpdateService.updateCommand(getCommandType(), this);
148
        } else {
149
        	setEnabled(getInitialEnablement());
150
        }
151
    }
152
    
153
    /**
154
     * Returns whether this action should be enabled when initialized
155
     * and there is no active debug context.
156
     * 
157
     * @return false, by default
158
     */
159
    protected boolean getInitialEnablement() {
160
    	return false;
161
    }
162
163
    /**
164
     * Returns the most recent selection
165
     * 
166
     * @return structured selection
167
     */
168
    protected ISelection getContext() {
169
		if (fPart != null) {
170
			getDebugContextService().getActiveContext(fPart.getSite().getId());
171
    	}
172
        return getDebugContextService().getActiveContext();
173
    }
174
175
    /*
176
     * (non-Javadoc)
177
     * @see org.eclipse.jface.action.Action#run()
178
     */
179
    public void run() {
180
        ISelection selection = getContext();
181
        if (selection instanceof IStructuredSelection && isEnabled()) {
182
            IStructuredSelection ss = (IStructuredSelection) selection;
183
            boolean enabled = execute(ss.toArray());
184
            // disable the action according to the command
185
            setEnabled(enabled);
186
        }
187
    }
188
189
    /*
190
     * (non-Javadoc)
191
     * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
192
     */
193
    public void runWithEvent(Event event) {
194
        run();
195
    }
196
197
    /**
198
     * Clean up when removing
199
     */
200
    public void dispose() {
201
        IDebugContextService service = getDebugContextService();
202
        if (fPart != null) {
203
        	service.removeDebugContextListener(this, fPart.getSite().getId());
204
        } else {
205
            service.removeDebugContextListener(this);
206
        }
207
        fWindow = null;
208
        fPart = null;
209
    }
210
    
211
    /**
212
     * Returns the context service this action linked to.
213
     * @return
214
     */
215
    protected IDebugContextService getDebugContextService() {
216
    	return DebugUITools.getDebugContextManager().getContextService(fWindow);
217
    }
218
219
    /**
220
     * @return The help context id for this action
221
     */ 
222
    public abstract String getHelpContextId();
223
224
    /*
225
     * (non-Javadoc)
226
     * @see org.eclipse.jface.action.Action#getId()
227
     */
228
    public abstract String getId();
229
230
    /*
231
     * (non-Javadoc)
232
     * @see org.eclipse.jface.action.Action#getText()
233
     */
234
    public abstract String getText();
235
236
    /*
237
     * (non-Javadoc)
238
     * @see org.eclipse.jface.action.Action#getToolTipText()
239
     */
240
    public abstract String getToolTipText();
241
242
    /*
243
     * (non-Javadoc)
244
     * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
245
     */
246
    public abstract ImageDescriptor getDisabledImageDescriptor();
247
248
    /*
249
     * (non-Javadoc)
250
     * @see org.eclipse.jface.action.Action#getHoverImageDescriptor()
251
     */
252
    public abstract ImageDescriptor getHoverImageDescriptor();
253
254
    /*
255
     * (non-Javadoc)
256
     * @see org.eclipse.jface.action.Action#getImageDescriptor()
257
     */
258
    public abstract ImageDescriptor getImageDescriptor();
259
    
260
    /**
261
     * Returns the delegate associated with this action or <code>null</code>
262
     * if none.
263
     * 
264
     * @return delegate or <code>null</code>
265
     */
266
    protected DebugCommandActionDelegate getDelegate() {
267
    	return fDelegate;
268
    }
269
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/UpdateActionsRequest.java (-3 / +2 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.debug.core.commands.IEnabledStateRequest;
13
import org.eclipse.debug.core.commands.IEnabledStateRequest;
14
import org.eclipse.debug.internal.core.commands.DebugCommandRequest;
14
import org.eclipse.debug.internal.core.commands.DebugCommandRequest;
15
import org.eclipse.jface.action.IAction;
16
15
17
/**
16
/**
18
 * Boolean collector that collects boolean results from a number of voters.
17
 * Boolean collector that collects boolean results from a number of voters.
Lines 23-32 Link Here
23
 */
22
 */
24
public class UpdateActionsRequest extends DebugCommandRequest implements IEnabledStateRequest {
23
public class UpdateActionsRequest extends DebugCommandRequest implements IEnabledStateRequest {
25
	
24
	
26
	private IAction[] fActions;
25
	private IEnabledTarget[] fActions;
27
	private boolean fEnabled = false;
26
	private boolean fEnabled = false;
28
	
27
	
29
	public UpdateActionsRequest(Object[] elements, IAction[] actions) {
28
	public UpdateActionsRequest(Object[] elements, IEnabledTarget[] actions) {
30
		super(elements);
29
		super(elements);
31
		fActions = actions;
30
		fActions = actions;
32
	}
31
	}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersCommandActionDelegate.java (-9 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-18 Link Here
12
package org.eclipse.debug.internal.ui.commands.actions;
12
package org.eclipse.debug.internal.ui.commands.actions;
13
13
14
import org.eclipse.debug.ui.DebugUITools;
14
import org.eclipse.debug.ui.DebugUITools;
15
import org.eclipse.ui.IWorkbenchWindow;
15
import org.eclipse.jface.action.IAction;
16
16
17
/**
17
/**
18
 * Toggle step filters action delegate.
18
 * Toggle step filters action delegate.
Lines 29-39 Link Here
29
        setAction(new ToggleStepFiltersAction());
29
        setAction(new ToggleStepFiltersAction());
30
    }
30
    }
31
31
32
	/**
32
    public void init(IAction action) {
33
	 * @see org.eclipse.debug.internal.ui.commands.actions.DebugCommandActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
33
        super.init(action);
34
	 */
34
        action.setChecked(DebugUITools.isUseStepFilters());
35
	public void init(IWorkbenchWindow window) {
35
    }
36
		super.init(window);
37
		setChecked(DebugUITools.isUseStepFilters());
38
	}
39
}
36
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandActionDelegate.java (-51 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
11
12
package org.eclipse.debug.internal.ui.commands.actions;
12
package org.eclipse.debug.internal.ui.commands.actions;
13
13
14
import org.eclipse.debug.ui.actions.DebugCommandAction;
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.swt.widgets.Event;
17
import org.eclipse.swt.widgets.Event;
Lines 21-27 Link Here
21
/**
22
/**
22
 * Abstract base class for debug action delegates performing debug commands.
23
 * Abstract base class for debug action delegates performing debug commands.
23
 * 
24
 * 
24
 * @since 3.3
25
 * @since 3.3.
25
 */
26
 */
26
public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 {
27
public abstract class DebugCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 {
27
28
Lines 30-56 Link Here
30
	 */
31
	 */
31
	private DebugCommandAction fDebugAction;
32
	private DebugCommandAction fDebugAction;
32
    
33
    
33
    /**
34
	protected void setAction(DebugCommandAction action) {
34
     * The underlying action for this delegate
35
	    fDebugAction = action;
35
     */
36
    private IAction fWindowAction;
37
    
38
    /**
39
     * Whether this action has been initialized before it has been run
40
     * (ensures enablement state is up to date when lazily instantiated)
41
     */
42
    private boolean fInitialized = false;
43
44
	public DebugCommandActionDelegate() {
45
	}
36
	}
46
37
	
47
	/*
38
	/*
48
     * (non-Javadoc)
39
     * (non-Javadoc)
49
     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
40
     * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
50
	 */
41
	 */
51
	public void dispose() {
42
	public void dispose() {
52
        fDebugAction.dispose();
43
        fDebugAction.dispose();
53
54
	}
44
	}
55
45
56
    /*
46
    /*
Lines 58-64 Link Here
58
     * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
48
     * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
59
     */
49
     */
60
    public void init(IAction action) {
50
    public void init(IAction action) {
61
        fWindowAction = action;
51
        fDebugAction.setActionProxy(action);
62
    }
52
    }
63
    
53
    
64
    /*
54
    /*
Lines 74-87 Link Here
74
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
64
     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
75
     */
65
     */
76
	public void run(IAction action) {
66
	public void run(IAction action) {
77
		synchronized (this) {
78
			if (!fInitialized) {
79
				try {
80
					wait();
81
				} catch (InterruptedException e) {
82
				}
83
			}			
84
		}
85
        fDebugAction.run();
67
        fDebugAction.run();
86
	}
68
	}
87
69
Lines 105-134 Link Here
105
	protected DebugCommandAction getAction() {
87
	protected DebugCommandAction getAction() {
106
		return fDebugAction;
88
		return fDebugAction;
107
	}
89
	}
108
    
109
    protected void setAction(DebugCommandAction action) {
110
        fDebugAction = action;
111
        action.setDelegate(this);
112
    }
113
114
    public void setEnabled(boolean enabled) {
115
    	synchronized (this) {
116
	    	if (!fInitialized) {
117
	    		fInitialized = true;
118
	    		notifyAll();
119
	    	}
120
    	}
121
        fWindowAction.setEnabled(enabled);
122
    }
123
    
124
    public void setChecked(boolean checked) {
125
    	fWindowAction.setChecked(checked);
126
    }
127
    
128
    protected IAction getWindowAction()
129
    {
130
    	return fWindowAction;
131
    }
132
    
133
    
134
}
90
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java (-36 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 20-25 Link Here
20
import org.eclipse.debug.internal.ui.DebugPluginImages;
20
import org.eclipse.debug.internal.ui.DebugPluginImages;
21
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
21
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
22
import org.eclipse.debug.internal.ui.actions.ActionMessages;
22
import org.eclipse.debug.internal.ui.actions.ActionMessages;
23
import org.eclipse.debug.ui.actions.DebugCommandAction;
23
import org.eclipse.jface.resource.ImageDescriptor;
24
import org.eclipse.jface.resource.ImageDescriptor;
24
25
25
/**
26
/**
Lines 29-66 Link Here
29
 */
30
 */
30
public class TerminateAndRemoveAction extends DebugCommandAction {
31
public class TerminateAndRemoveAction extends DebugCommandAction {
31
32
32
    
33
    class TerminateAndRemoveParticipant implements ICommandParticipant {
34
        private Object[] fElements;
35
        
36
        TerminateAndRemoveParticipant(Object[] elements) {
37
            fElements = elements;
38
        }
39
        
40
		/* (non-Javadoc)
41
		 * @see org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant#requestDone(org.eclipse.debug.core.commands.IRequest)
42
		 */
43
		public void requestDone(IRequest request) {
44
			IStatus status = request.getStatus();
45
			if(status == null || status.isOK()) {
46
				for (int i = 0; i < fElements.length; i++) {
47
					Object element = fElements[i];
48
	                ILaunch launch= null;
49
	                if (element instanceof ILaunch) {
50
	                    launch= (ILaunch) element;
51
	                } else if (element instanceof IDebugElement) {
52
	                    launch= ((IDebugElement) element).getLaunch();
53
	                } else if (element instanceof IProcess) {
54
	                    launch= ((IProcess) element).getLaunch();
55
	                }   
56
	                if (launch != null)
57
	                    DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);					
58
				}
59
            }
60
		}
61
        
62
    }
63
64
    public String getText() {
33
    public String getText() {
65
        return ActionMessages.TerminateAndRemoveAction_0;
34
        return ActionMessages.TerminateAndRemoveAction_0;
66
    }
35
    }
Lines 93-101 Link Here
93
		return ITerminateHandler.class;
62
		return ITerminateHandler.class;
94
	}
63
	}
95
64
96
	protected ICommandParticipant getCommandParticipant(Object[] targets) {
65
    protected void requestDone(Object[] elements, IRequest request) {
97
		return new TerminateAndRemoveParticipant(targets);
66
        IStatus status = request.getStatus();
98
	}
67
        if(status == null || status.isOK()) {
68
            for (int i = 0; i < elements.length; i++) {
69
                Object element = elements[i];
70
                ILaunch launch= null;
71
                if (element instanceof ILaunch) {
72
                    launch= (ILaunch) element;
73
                } else if (element instanceof IDebugElement) {
74
                    launch= ((IDebugElement) element).getLaunch();
75
                } else if (element instanceof IProcess) {
76
                    launch= ((IProcess) element).getLaunch();
77
                }   
78
                if (launch != null)
79
                    DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);                   
80
            }
81
        }
82
    }
99
83
100
    
84
    
101
}
85
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/TerminateCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ActionsUpdater.java (-4 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.commands.actions;
11
package org.eclipse.debug.internal.ui.commands.actions;
12
12
13
import org.eclipse.jface.action.IAction;
14
13
15
/**
14
/**
16
 * Collects votes from handler update requests.
15
 * Collects votes from handler update requests.
Lines 20-32 Link Here
20
 */
19
 */
21
public class ActionsUpdater {
20
public class ActionsUpdater {
22
	
21
	
23
	private IAction[] fActions;
22
	private IEnabledTarget[] fActions;
24
	private int fNumVoters;
23
	private int fNumVoters;
25
	private int fNumOfVotes = 0;
24
	private int fNumOfVotes = 0;
26
	private boolean fDone = false;
25
	private boolean fDone = false;
27
	private boolean fEnabled = true;
26
	private boolean fEnabled = true;
28
	
27
	
29
	public ActionsUpdater(IAction[] actions, int numVoters) {
28
	public ActionsUpdater(IEnabledTarget[] actions, int numVoters) {
30
		fActions = actions;
29
		fActions = actions;
31
		fNumVoters = numVoters;
30
		fNumVoters = numVoters;
32
	}
31
	}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ToggleStepFiltersAction.java (-4 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 19-25 Link Here
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
19
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
20
import org.eclipse.debug.internal.ui.actions.ActionMessages;
21
import org.eclipse.debug.ui.DebugUITools;
21
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.debug.ui.actions.DebugCommandAction;
22
import org.eclipse.debug.ui.contexts.DebugContextEvent;
23
import org.eclipse.debug.ui.contexts.DebugContextEvent;
24
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.resource.ImageDescriptor;
24
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.ui.IWorkbenchPart;
27
import org.eclipse.ui.IWorkbenchPart;
Lines 166-174 Link Here
166
		if (event.getProperty().equals(StepFilterManager.PREF_USE_STEP_FILTERS)) {
168
		if (event.getProperty().equals(StepFilterManager.PREF_USE_STEP_FILTERS)) {
167
			boolean checked = DebugUITools.isUseStepFilters();
169
			boolean checked = DebugUITools.isUseStepFilters();
168
			setChecked(checked);
170
			setChecked(checked);
169
			DebugCommandActionDelegate delegate = getDelegate();
171
			IAction action = getActionProxy();
170
			if (delegate != null) {
172
			if (action != null) {
171
				delegate.setChecked(checked);
173
				action.setChecked(checked);
172
			}
174
			}
173
		}		
175
		}		
174
	}
176
	}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/StepOverCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.DebugPluginImages;
16
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
17
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.internal.ui.actions.ActionMessages;
18
import org.eclipse.debug.ui.actions.DebugCommandAction;
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
19
20
20
/**
21
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ICommandParticipant.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-21 Link Here
15
/**
15
/**
16
 * Adds function to a command on completion.
16
 * Adds function to a command on completion.
17
 *
17
 *
18
 * @since 3.3
18
 * @since 3.3.
19
 */
19
 */
20
public interface ICommandParticipant {
20
public interface ICommandParticipant {
21
	
21
	
(-)ui/org/eclipse/debug/internal/ui/commands/actions/ResumeCommandActionDelegate.java (-6 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-27 Link Here
11
11
12
package org.eclipse.debug.internal.ui.commands.actions;
12
package org.eclipse.debug.internal.ui.commands.actions;
13
13
14
import org.eclipse.debug.ui.actions.DebugCommandAction;
15
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.swt.widgets.Event;
18
import org.eclipse.ui.IActionDelegate2;
19
import org.eclipse.ui.IWorkbenchWindow;
20
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
21
14
/**
22
/**
15
 * Resume action delegate.
23
 * Resume action delegate.
16
 * 
24
 * 
17
 * @since 3.3
25
 * @since 3.3
18
 */
26
 */
19
public class ResumeCommandActionDelegate extends DebugCommandActionDelegate {
27
public class ResumeCommandActionDelegate implements IWorkbenchWindowActionDelegate, IActionDelegate2 {
20
28
21
    public ResumeCommandActionDelegate() {
29
    private DebugCommandAction fDebugAction = new ResumeCommandAction();
22
        super();
30
    
23
        setAction(new ResumeCommandAction());
31
    public void dispose() {
32
        fDebugAction.dispose();
24
    }
33
    }
25
34
26
    
35
    public void init(IWorkbenchWindow window) {
36
        fDebugAction.init(window);
37
    }
38
39
    public void run(IAction action) {
40
        fDebugAction.run();
41
    }
42
43
    public void selectionChanged(IAction action, ISelection selection) {
44
        // do nothing
45
    }
46
47
    public void init(IAction action) {
48
        fDebugAction.setActionProxy(action);
49
        
50
    }
51
52
    public void runWithEvent(IAction action, Event event) {
53
        run(action);
54
    }
27
}
55
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/StepIntoCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/DisconnectCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.IDebugUIConstants;
17
import org.eclipse.debug.ui.IDebugUIConstants;
18
import org.eclipse.debug.ui.actions.DebugCommandAction;
18
import org.eclipse.jface.resource.ImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
19
/**
20
/**
20
 * Disconnect action.
21
 * Disconnect action.
(-)ui/org/eclipse/debug/internal/ui/commands/actions/DebugCommandService.java (-6 / +5 lines)
Lines 24-30 Link Here
24
import org.eclipse.debug.ui.contexts.DebugContextEvent;
24
import org.eclipse.debug.ui.contexts.DebugContextEvent;
25
import org.eclipse.debug.ui.contexts.IDebugContextListener;
25
import org.eclipse.debug.ui.contexts.IDebugContextListener;
26
import org.eclipse.debug.ui.contexts.IDebugContextService;
26
import org.eclipse.debug.ui.contexts.IDebugContextService;
27
import org.eclipse.jface.action.Action;
28
import org.eclipse.jface.action.IAction;
27
import org.eclipse.jface.action.IAction;
29
import org.eclipse.jface.viewers.ISelection;
28
import org.eclipse.jface.viewers.ISelection;
30
import org.eclipse.jface.viewers.IStructuredSelection;
29
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 111-117 Link Here
111
	 * @param commandType
110
	 * @param commandType
112
	 * @param monitor
111
	 * @param monitor
113
	 */
112
	 */
114
	public void postUpdateCommand(Class commandType, Action action) {
113
	public void postUpdateCommand(Class commandType, IEnabledTarget action) {
115
		synchronized (fCommandUpdates) {
114
		synchronized (fCommandUpdates) {
116
			Job.getJobManager().cancel(commandType);
115
			Job.getJobManager().cancel(commandType);
117
			List actions = (List) fCommandUpdates.get(commandType);
116
			List actions = (List) fCommandUpdates.get(commandType);
Lines 129-139 Link Here
129
	 * @param commandType
128
	 * @param commandType
130
	 * @param requestMonitor
129
	 * @param requestMonitor
131
	 */
130
	 */
132
	public void updateCommand(Class commandType, IAction action) {
131
	public void updateCommand(Class commandType, IEnabledTarget action) {
133
		ISelection context = fContextService.getActiveContext();
132
		ISelection context = fContextService.getActiveContext();
134
		if (context instanceof IStructuredSelection && !context.isEmpty()) {
133
		if (context instanceof IStructuredSelection && !context.isEmpty()) {
135
			Object[] elements = ((IStructuredSelection)context).toArray();
134
			Object[] elements = ((IStructuredSelection)context).toArray();
136
			updateCommand(commandType, elements, new IAction[]{action});
135
			updateCommand(commandType, elements, new IEnabledTarget[]{action});
137
		} else {
136
		} else {
138
			action.setEnabled(false);
137
			action.setEnabled(false);
139
		}
138
		}
Lines 152-158 Link Here
152
				Entry entry = (Entry) iterator.next();
151
				Entry entry = (Entry) iterator.next();
153
				Class commandType = (Class)entry.getKey();
152
				Class commandType = (Class)entry.getKey();
154
				List actions = (List) entry.getValue();
153
				List actions = (List) entry.getValue();
155
				updateCommand(commandType, elements, (IAction[]) actions.toArray(new IAction[actions.size()]));
154
				updateCommand(commandType, elements, (IEnabledTarget[]) actions.toArray(new IEnabledTarget[actions.size()]));
156
			}
155
			}
157
		} else {
156
		} else {
158
			Iterator iterator = commands.values().iterator();
157
			Iterator iterator = commands.values().iterator();
Lines 174-180 Link Here
174
	 * @param elements elements to update for
173
	 * @param elements elements to update for
175
	 * @param monitor status monitor
174
	 * @param monitor status monitor
176
	 */
175
	 */
177
	private void updateCommand(Class handlerType, Object[] elements, IAction[] actions) {
176
	private void updateCommand(Class handlerType, Object[] elements, IEnabledTarget[] actions) {
178
		if (elements.length == 1) {
177
		if (elements.length == 1) {
179
			// usual case - one element
178
			// usual case - one element
180
			Object element = elements[0];
179
			Object element = elements[0];
(-)ui/org/eclipse/debug/internal/ui/commands/actions/StepReturnCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)ui/org/eclipse/debug/internal/ui/commands/actions/SuspendCommandAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
14
import org.eclipse.debug.internal.ui.DebugPluginImages;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
15
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
16
import org.eclipse.debug.internal.ui.actions.ActionMessages;
17
import org.eclipse.debug.ui.actions.DebugCommandAction;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.resource.ImageDescriptor;
18
19
19
/**
20
/**
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true
4
Bundle-SymbolicName: org.eclipse.debug.ui; singleton:=true
5
Bundle-Version: 3.5.100.qualifier
5
Bundle-Version: 3.6.0.qualifier
6
Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin
6
Bundle-Activator: org.eclipse.debug.internal.ui.DebugUIPlugin
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 59-65 Link Here
59
 org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
59
 org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
60
 org.eclipse.ui.console;bundle-version="[3.4.0,4.0.0)",
60
 org.eclipse.ui.console;bundle-version="[3.4.0,4.0.0)",
61
 org.eclipse.help;bundle-version="[3.4.0,4.0.0)",
61
 org.eclipse.help;bundle-version="[3.4.0,4.0.0)",
62
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
62
 org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)";visibility:=reexport,
63
 org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
63
 org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
64
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
64
 org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)",
65
 org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
65
 org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
(-)ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java (-1 / +1 lines)
Lines 41-47 Link Here
41
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
41
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
42
import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction;
42
import org.eclipse.debug.internal.ui.actions.AddToFavoritesAction;
43
import org.eclipse.debug.internal.ui.actions.EditLaunchConfigurationAction;
43
import org.eclipse.debug.internal.ui.actions.EditLaunchConfigurationAction;
44
import org.eclipse.debug.internal.ui.commands.actions.DebugCommandAction;
45
import org.eclipse.debug.internal.ui.commands.actions.DisconnectCommandAction;
44
import org.eclipse.debug.internal.ui.commands.actions.DisconnectCommandAction;
46
import org.eclipse.debug.internal.ui.commands.actions.DropToFrameCommandAction;
45
import org.eclipse.debug.internal.ui.commands.actions.DropToFrameCommandAction;
47
import org.eclipse.debug.internal.ui.commands.actions.ResumeCommandAction;
46
import org.eclipse.debug.internal.ui.commands.actions.ResumeCommandAction;
Lines 72-77 Link Here
72
import org.eclipse.debug.ui.DebugUITools;
71
import org.eclipse.debug.ui.DebugUITools;
73
import org.eclipse.debug.ui.IDebugModelPresentation;
72
import org.eclipse.debug.ui.IDebugModelPresentation;
74
import org.eclipse.debug.ui.IDebugUIConstants;
73
import org.eclipse.debug.ui.IDebugUIConstants;
74
import org.eclipse.debug.ui.actions.DebugCommandAction;
75
import org.eclipse.debug.ui.contexts.AbstractDebugContextProvider;
75
import org.eclipse.debug.ui.contexts.AbstractDebugContextProvider;
76
import org.eclipse.debug.ui.contexts.DebugContextEvent;
76
import org.eclipse.debug.ui.contexts.DebugContextEvent;
77
import org.eclipse.debug.ui.contexts.IDebugContextListener;
77
import org.eclipse.debug.ui.contexts.IDebugContextListener;
(-)ui/org/eclipse/debug/ui/actions/DebugCommandAction.java (+343 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.debug.ui.actions;
13
14
import org.eclipse.debug.core.IRequest;
15
import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService;
16
import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant;
17
import org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget;
18
import org.eclipse.debug.ui.DebugUITools;
19
import org.eclipse.debug.ui.contexts.DebugContextEvent;
20
import org.eclipse.debug.ui.contexts.IDebugContextListener;
21
import org.eclipse.debug.ui.contexts.IDebugContextService;
22
import org.eclipse.jface.action.Action;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.IStructuredSelection;
27
import org.eclipse.swt.widgets.Event;
28
import org.eclipse.ui.IWorkbenchPart;
29
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.PlatformUI;
31
32
/**
33
 * Abstract base class for re-targeting actions which delegate execution to 
34
 * {@link org.eclipse.debug.core.commands.IDebugCommandHandler} handlers.  
35
 * The specific type of <code>IDebugCommandHandler</code> is determined by the 
36
 * abstract {@link #getCommandType()} method.    
37
 * <p>
38
 * This base class is an action which can be instantiated directly by views, 
39
 * etc.  In order to contribute an action using an extension point, a class 
40
 * implementing {@link org.eclipse.ui.IActionDelegate} should be created first.
41
 * The delegate should then use a <code>DebugCommandAction</code> to implement 
42
 * the needed functionality. The IActionDelegate must use {@link #setActionProxy(IAction)}
43
 * specifying the workbench's action that is a proxy to the action delegate. This
44
 * way, the workbench action can be updated visually as needed.<br>
45
 * Note: <code>IDebugCommandHandler</code> command typically act on the active
46
 * debug context as opposed to the active selection in view or window.  The 
47
 * action delegate should ignore the active window selection, and instead allow 
48
 * the <code>DebugCommandAction</code> to update itself based on the active 
49
 * debug context. 
50
 * </p>
51
 * <p>
52
 * Clients may subclass this class.
53
 * </p>
54
 * @see org.eclipse.debug.core.commands.IDebugCommandHandler
55
 * @since 3.6
56
 */
57
public abstract class DebugCommandAction extends Action implements IDebugContextListener {
58
59
    private boolean fInitialized = false;
60
    
61
	/**
62
	 * The window this action is working for.
63
	 */
64
    private IWorkbenchWindow fWindow;
65
    
66
    /**
67
     * The part this action is working for, or <code>null</code> if global to
68
     * a window.
69
     */
70
    private IWorkbenchPart fPart;
71
    
72
    /**
73
     * Command service.
74
     */
75
    private DebugCommandService fUpdateService;
76
    
77
    /**
78
     * Delegate this action is working for or <code>null</code> if none.
79
     */
80
    private IAction fAction;
81
82
    private IEnabledTarget fEnabledTarget = new IEnabledTarget() {
83
        public void setEnabled(boolean enabled) {
84
            DebugCommandAction.this.setEnabled(enabled);
85
        }
86
    };
87
    
88
    /**
89
     * Constructor
90
     */
91
    public DebugCommandAction() {
92
        super();
93
        String helpContextId = getHelpContextId();
94
        if (helpContextId != null)
95
            PlatformUI.getWorkbench().getHelpSystem().setHelp(this, helpContextId);
96
        setEnabled(false);
97
    }
98
99
	/**
100
     * Sets the current workbench action that is a proxy to an {@link org.eclipse.ui.IActionDelegate}
101
     * that is using this action to perform its actual work. This only needs to be called when
102
     * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its
103
     * function.
104
     * 
105
     * @param action workbench proxy action
106
     */
107
    public void setActionProxy(IAction action) {
108
        fAction = action;
109
        fAction.setEnabled(isEnabled());
110
    }
111
112
    /**
113
     * Executes this action on the given target object
114
     * 
115
     * @param target the target to perform the action on
116
     */
117
    private boolean execute(final Object[] targets) {
118
    	return fUpdateService.executeCommand(
119
    	    getCommandType(), targets, 
120
    	    new ICommandParticipant() {
121
    	        public void requestDone(org.eclipse.debug.core.IRequest request) {
122
    	            DebugCommandAction.this.postExecute(request, targets);
123
    	        }    	      
124
    	    });
125
    }
126
        
127
    /**
128
     * This method is called after the completion of the execution of this 
129
     * command.  Extending classes may override this method to perform additional
130
     * operation after command execution. 
131
     * 
132
     * @param request The completed request object which was given to the 
133
     * debug command handler.
134
     * @param targets Objects which were the targets of this action
135
     */
136
    protected void postExecute(IRequest request, Object[] targets) {
137
        // do nothing by default
138
    }
139
    
140
    /**
141
     * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} 
142
     * command handler that type this action executes.
143
     * 
144
     * @return command class.
145
     * 
146
     * @see org.eclipse.debug.core.commands.IDebugCommandHandler
147
     */
148
    abstract protected Class getCommandType();  
149
150
    /**
151
     * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
152
     */
153
    public void debugContextChanged(DebugContextEvent event) {
154
    	fUpdateService.postUpdateCommand(getCommandType(), fEnabledTarget);
155
	}
156
157
    /**
158
     * @see org.eclipse.jface.action.Action#setEnabled(boolean)
159
     */
160
    public void setEnabled(boolean enabled) {
161
        synchronized (this) {
162
            if (!fInitialized) {
163
                fInitialized = true;
164
                notifyAll();
165
            }
166
        }        
167
        super.setEnabled(enabled);
168
        if (fAction != null) {
169
            fAction.setEnabled(enabled);
170
        }
171
    }
172
173
    /**
174
     * Initializes this action for a specific part.
175
     * 
176
     * @param part workbench part
177
     */
178
    public void init(IWorkbenchPart part) {
179
        fPart = part;
180
        fWindow = part.getSite().getWorkbenchWindow();
181
        fUpdateService = DebugCommandService.getService(fWindow);
182
        IDebugContextService service = getDebugContextService();
183
		String partId = part.getSite().getId();
184
		service.addDebugContextListener(this, partId);
185
        ISelection activeContext = service.getActiveContext(partId);
186
        if (activeContext != null) {
187
        	fUpdateService.updateCommand(getCommandType(), fEnabledTarget);
188
        } else {
189
        	setEnabled(getInitialEnablement());
190
        }
191
    }
192
    
193
    /**
194
     * Initializes the context action
195
     * @param window the window
196
     */
197
    public void init(IWorkbenchWindow window) {
198
        fWindow = window;
199
        fUpdateService = DebugCommandService.getService(fWindow);
200
        IDebugContextService contextService = getDebugContextService();
201
		contextService.addDebugContextListener(this);
202
        ISelection activeContext = contextService.getActiveContext();
203
        if (activeContext != null) {
204
        	fUpdateService.updateCommand(getCommandType(), fEnabledTarget);
205
        } else {
206
        	setEnabled(getInitialEnablement());
207
        }
208
    }
209
    
210
    /**
211
     * Returns whether this action should be enabled when initialized
212
     * and there is no active debug context. By default, <code>false</code>
213
     * is returned.
214
     * 
215
     * @return initial enabled state when there is no active context.
216
     */
217
    protected boolean getInitialEnablement() {
218
    	return false;
219
    }
220
221
    /**
222
     * Returns the context this action operates on as a selection.
223
     * 
224
     * @return the context this action operates on
225
     */
226
    private ISelection getContext() {
227
		if (fPart != null) {
228
			getDebugContextService().getActiveContext(fPart.getSite().getId());
229
    	}
230
        return getDebugContextService().getActiveContext();
231
    }
232
233
    /*
234
     * (non-Javadoc)
235
     * @see org.eclipse.jface.action.Action#run()
236
     */
237
    public void run() {
238
        synchronized (this) {
239
            if (!fInitialized) {
240
                try {
241
                    wait();
242
                } catch (InterruptedException e) {
243
                }
244
            }           
245
        }        
246
        
247
        ISelection selection = getContext();
248
        if (selection instanceof IStructuredSelection && isEnabled()) {
249
            IStructuredSelection ss = (IStructuredSelection) selection;
250
            boolean enabled = execute(ss.toArray());
251
            // disable the action according to the command
252
            setEnabled(enabled);
253
        }
254
    }
255
256
    /*
257
     * (non-Javadoc)
258
     * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
259
     */
260
    public void runWithEvent(Event event) {
261
        run();
262
    }
263
264
    /**
265
     * Clean up when removing
266
     */
267
    public void dispose() {
268
        IDebugContextService service = getDebugContextService();
269
        if (fPart != null) {
270
        	service.removeDebugContextListener(this, fPart.getSite().getId());
271
        } else {
272
            service.removeDebugContextListener(this);
273
        }
274
        fWindow = null;
275
        fPart = null;
276
    }
277
    
278
    /**
279
     * Returns the context service this action linked to. By default, this actions is
280
     * associated with the context service for the window this action is operating in.
281
     * 
282
     * @return associated context service
283
     */
284
    protected IDebugContextService getDebugContextService() {
285
    	return DebugUITools.getDebugContextManager().getContextService(fWindow);
286
    }
287
288
    /**
289
     * Returns the help context id for this action or <code>null</code> if none.
290
     * 
291
     * @return The help context id for this action or <code>null</code>
292
     */ 
293
    public abstract String getHelpContextId();
294
295
    /*
296
     * (non-Javadoc)
297
     * @see org.eclipse.jface.action.Action#getId()
298
     */
299
    public abstract String getId();
300
301
    /*
302
     * (non-Javadoc)
303
     * @see org.eclipse.jface.action.Action#getText()
304
     */
305
    public abstract String getText();
306
307
    /*
308
     * (non-Javadoc)
309
     * @see org.eclipse.jface.action.Action#getToolTipText()
310
     */
311
    public abstract String getToolTipText();
312
313
    /*
314
     * (non-Javadoc)
315
     * @see org.eclipse.jface.action.Action#getDisabledImageDescriptor()
316
     */
317
    public abstract ImageDescriptor getDisabledImageDescriptor();
318
319
    /*
320
     * (non-Javadoc)
321
     * @see org.eclipse.jface.action.Action#getHoverImageDescriptor()
322
     */
323
    public abstract ImageDescriptor getHoverImageDescriptor();
324
325
    /*
326
     * (non-Javadoc)
327
     * @see org.eclipse.jface.action.Action#getImageDescriptor()
328
     */
329
    public abstract ImageDescriptor getImageDescriptor();
330
    
331
    /**
332
     * Returns the workbench proxy associated with this action or <code>null</code>
333
     * if none. This is the workbench proxy to an {@link org.eclipse.ui.IActionDelegate}
334
     * that is using this action to perform its actual work. This is only used when
335
     * an {@link org.eclipse.ui.IActionDelegate} is using one of these actions to perform its
336
     * function.
337
     * 
338
     * @return workbench proxy action or <code>null</code>
339
     */
340
    protected IAction getActionProxy() {
341
    	return fAction;
342
    }
343
}
(-)ui/org/eclipse/debug/internal/ui/commands/actions/IEnabledTarget.java (+18 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Wind River Systems 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
 *     Wind River Systems - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.ui.commands.actions;
12
13
/**
14
 * 
15
 */
16
public interface IEnabledTarget {
17
    public void setEnabled(boolean enabled);
18
}
(-)ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java (+279 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation 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
 *     Wind River Systems - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.debug.ui.actions;
13
14
import java.util.Iterator;
15
import java.util.Map;
16
import java.util.WeakHashMap;
17
18
import org.eclipse.core.commands.AbstractHandler;
19
import org.eclipse.core.commands.ExecutionEvent;
20
import org.eclipse.core.commands.ExecutionException;
21
import org.eclipse.core.commands.HandlerEvent;
22
import org.eclipse.core.expressions.IEvaluationContext;
23
import org.eclipse.debug.core.IRequest;
24
import org.eclipse.debug.internal.ui.commands.actions.DebugCommandService;
25
import org.eclipse.debug.internal.ui.commands.actions.ICommandParticipant;
26
import org.eclipse.debug.internal.ui.commands.actions.IEnabledTarget;
27
import org.eclipse.debug.ui.DebugUITools;
28
import org.eclipse.debug.ui.contexts.DebugContextEvent;
29
import org.eclipse.debug.ui.contexts.IDebugContextListener;
30
import org.eclipse.debug.ui.contexts.IDebugContextService;
31
import org.eclipse.jface.viewers.ISelection;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.ISources;
34
import org.eclipse.ui.IWindowListener;
35
import org.eclipse.ui.IWorkbenchWindow;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.handlers.HandlerUtil;
38
39
/**
40
 * Abstract base class for re-targeting command framework handlers, which 
41
 * delegate execution to {@link org.eclipse.debug.core.commands.IDebugCommandHandler} 
42
 * handlers. The specific type of <code>IDebugCommandHandler</code> is 
43
 * determined by the abstract {@link #getCommandType()} method.    
44
 * 
45
 * <p> Note: This class is not an implementation of the <code>IDebugCommandHandler</code>
46
 * interface, which was somewhat unfortunately named.  <code>IDebugCommandHandler</code> 
47
 * is an interface that used only by the debugger plug-ins.  This class implements 
48
 * {@link org.eclipse.core.commands.IHandler} interface and is to be used with the 
49
 * platform commands framework. </p>
50
 * 
51
 * <p>
52
 * Clients may subclass this class.
53
 * </p>
54
 * @see org.eclipse.debug.core.commands.IDebugCommandHandler
55
 * @see org.eclipse.core.commands.IHandler
56
 *
57
 * @since 3.6
58
 */
59
public abstract class DebugCommandHandler extends AbstractHandler {
60
61
    /**
62
     * The DebugCommandService is able to evaluate the command handler 
63
     * enablement in each workbench window separately, however the workbench
64
     * command framework uses only a single handler instance for all windows.
65
     * This IEnabledTarget implementation tracks enablement of the command
66
     * for a given window.  When the handler enablement is tested, the 
67
     * currently active window is used to determine which enabled target 
68
     * to use.  
69
     */
70
    private class EnabledTarget implements IEnabledTarget, IDebugContextListener {
71
        boolean fEnabled = getInitialEnablement();
72
        IWorkbenchWindow fWindow;
73
        
74
        EnabledTarget(IWorkbenchWindow window) {
75
            fWindow = window;
76
            DebugCommandService.getService(fWindow).updateCommand(getCommandType(), this);
77
            getContextService(fWindow).addDebugContextListener(this);
78
        }
79
        
80
        public void setEnabled(boolean enabled) {
81
            boolean oldEnabled = fEnabled;
82
            fEnabled = enabled;
83
            if (fEnabled != oldEnabled && fCurrentEnabledTarget == this) {
84
                fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false));
85
            }
86
        }
87
        
88
        public void debugContextChanged(DebugContextEvent event) {
89
            DebugCommandService.getService(fWindow).postUpdateCommand(getCommandType(), this);
90
        }
91
        
92
        void dispose() {
93
            if (isDisposed()) {
94
                return;
95
            }
96
            getContextService(fWindow).removeDebugContextListener(this);
97
            fWindow = null;
98
        }
99
        
100
        boolean isDisposed() {
101
            return fWindow == null;
102
        }
103
    }
104
105
    /**
106
     * Window listener is used to make sure that the handler enablement 
107
     * is updated when the active workbench window is changed.
108
     */
109
    private IWindowListener fWindowListener =  new IWindowListener() {
110
        
111
        public void windowOpened(IWorkbenchWindow w) {
112
        }
113
    
114
        public void windowDeactivated(IWorkbenchWindow w) {
115
        }
116
    
117
        public void windowClosed(IWorkbenchWindow w) {
118
            EnabledTarget enabledTarget = (EnabledTarget)fEnabledTargetsMap.get(w);
119
            if (enabledTarget != null) {
120
                enabledTarget.dispose();
121
            }
122
        }
123
    
124
        public void windowActivated(IWorkbenchWindow w) {
125
            fCurrentEnabledTarget = (EnabledTarget)fEnabledTargetsMap.get(w);
126
            fireHandlerChanged(new HandlerEvent(DebugCommandHandler.this, true, false));
127
        }
128
    };
129
    
130
    /**
131
     * Map of enabled targets keyed by workbench window.
132
     */
133
    private Map fEnabledTargetsMap = new WeakHashMap();
134
135
    /**
136
     * The current enabled target, based on the active
137
     * workbench window.
138
     */
139
    private EnabledTarget fCurrentEnabledTarget = null;
140
    
141
    /**
142
      * The constructor adds the handler as the 
143
     */
144
    public DebugCommandHandler() {
145
        super();
146
        PlatformUI.getWorkbench().addWindowListener(fWindowListener);
147
    }
148
    
149
    /* (non-Javadoc)
150
     * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
151
     */
152
    public void setEnabled(Object evaluationContext) {
153
        // This method is called with the current evaluation context
154
        // just prior to the isEnabled() being called.  Check the active
155
        // window and update the current enabled target based on it 
156
        fCurrentEnabledTarget = null;
157
        
158
        if (!(evaluationContext instanceof IEvaluationContext)) {
159
            return;
160
        }
161
        IEvaluationContext context = (IEvaluationContext) evaluationContext;
162
        Object _window = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
163
        if (_window instanceof IWorkbenchWindow) {
164
            IWorkbenchWindow window = (IWorkbenchWindow)_window;
165
            fCurrentEnabledTarget = getEnabledTarget(window);
166
        }
167
    }
168
    
169
    /* (non-Javadoc)
170
     * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
171
     */
172
    public boolean isEnabled() {
173
        if (fCurrentEnabledTarget == null) {
174
            return false;
175
        }
176
        return fCurrentEnabledTarget.fEnabled;
177
    }
178
    
179
    private EnabledTarget getEnabledTarget(IWorkbenchWindow window) {
180
        EnabledTarget target = (EnabledTarget)fEnabledTargetsMap.get(window);
181
        if (target == null) {
182
            target = new EnabledTarget(window);
183
            fEnabledTargetsMap.put(window, target);
184
        }
185
        return target;
186
    }
187
    
188
    /* (non-Javadoc)
189
     * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
190
     */
191
    public Object execute(ExecutionEvent event) throws ExecutionException {
192
        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
193
        if (window == null) {
194
            throw new ExecutionException("No active workbench window.");
195
        }
196
        fCurrentEnabledTarget = getEnabledTarget(window);
197
198
        ISelection selection = getContextService(window).getActiveContext();
199
        if (selection instanceof IStructuredSelection && isEnabled()) {
200
            IStructuredSelection ss = (IStructuredSelection) selection;
201
            boolean enabledAfterExecute = execute(window, ss.toArray());
202
            
203
            // enable/disable the action according to the command
204
            fCurrentEnabledTarget.setEnabled(enabledAfterExecute);
205
        }
206
207
        return null;
208
    }
209
    
210
    private IDebugContextService getContextService(IWorkbenchWindow window) {
211
        return DebugUITools.getDebugContextManager().getContextService(window);
212
    }
213
    
214
    /**
215
     * Executes this action on the given target object
216
     * 
217
     * @param target the target to perform the action on
218
     */
219
    private boolean execute(IWorkbenchWindow window, final Object[] targets) {
220
        DebugCommandService service = DebugCommandService.getService(window); 
221
    	return service.executeCommand(
222
    	    getCommandType(), targets, 
223
            new ICommandParticipant() {
224
                public void requestDone(org.eclipse.debug.core.IRequest request) {
225
                    DebugCommandHandler.this.postExecute(request, targets);
226
                }             
227
            });
228
    }
229
230
    /**
231
     * This method is called after the completion of the execution of this 
232
     * command.  Extending classes may override this method to perform additional
233
     * operation after command execution. 
234
     * 
235
     * @param request The completed request object which was given the the 
236
     * debug command handler.
237
     * @param targets Objects which were the targets of this action
238
     */
239
    protected void postExecute(IRequest request, Object[] targets) {
240
        // do nothing by default
241
    }
242
243
    /**
244
     * Returns the {@link org.eclipse.debug.core.commands.IDebugCommandHandler} 
245
     * command handler that type this action executes.
246
     * 
247
     * @return command class.
248
     * 
249
     * @see org.eclipse.debug.core.commands.IDebugCommandHandler
250
     */
251
    abstract protected Class getCommandType();  
252
253
    
254
    /**
255
     * Returns whether this action should be enabled when initialized
256
     * and there is no active debug context.
257
     * 
258
     * @return false, by default
259
     */
260
    protected boolean getInitialEnablement() {
261
    	return false;
262
    }
263
264
265
    /**
266
     * Clean up when removing
267
     */
268
    public void dispose() {
269
        PlatformUI.getWorkbench().removeWindowListener(fWindowListener);        
270
        for (Iterator itr = fEnabledTargetsMap.values().iterator(); itr.hasNext();) {
271
            EnabledTarget target = (EnabledTarget)itr.next();
272
            if (!target.isDisposed()) {
273
                target.dispose();
274
            }
275
        }
276
        fEnabledTargetsMap.clear();
277
        fCurrentEnabledTarget = null;
278
    }
279
}
(-)core/org/eclipse/debug/internal/core/commands/ResumeCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IResumeHandler;
15
import org.eclipse.debug.core.commands.IResumeHandler;
15
import org.eclipse.debug.core.model.ISuspendResume;
16
import org.eclipse.debug.core.model.ISuspendResume;
16
17
Lines 30-38 Link Here
30
	}
31
	}
31
	
32
	
32
	/* (non-Javadoc)
33
	/* (non-Javadoc)
33
	 * @see org.eclipse.debug.internal.core.commands.SuspendCommand#getUpdateJobFamily()
34
	 * @see org.eclipse.debug.internal.core.commands.SuspendCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
34
	 */
35
	 */
35
	protected Object getUpdateJobFamily() {
36
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
36
		return IResumeHandler.class;
37
		return IResumeHandler.class;
37
	}
38
	}
38
39
(-)core/org/eclipse/debug/internal/core/commands/TerminateCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.ITerminateHandler;
15
import org.eclipse.debug.core.commands.ITerminateHandler;
15
import org.eclipse.debug.core.model.ITerminate;
16
import org.eclipse.debug.core.model.ITerminate;
16
17
Lines 34-42 Link Here
34
	}
35
	}
35
36
36
	/* (non-Javadoc)
37
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
38
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
38
	 */
39
	 */
39
	protected Object getUpdateJobFamily() {
40
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
40
		return ITerminateHandler.class;
41
		return ITerminateHandler.class;
41
	}
42
	}
42
}
43
}
(-)core/org/eclipse/debug/internal/core/commands/StepOverCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IStepOverHandler;
15
import org.eclipse.debug.core.commands.IStepOverHandler;
15
import org.eclipse.debug.core.model.IStep;
16
import org.eclipse.debug.core.model.IStep;
16
17
Lines 34-42 Link Here
34
	}
35
	}
35
36
36
	/* (non-Javadoc)
37
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
38
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
38
	 */
39
	 */
39
	protected Object getUpdateJobFamily() {
40
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
40
		return IStepOverHandler.class;
41
		return IStepOverHandler.class;
41
	}
42
	}
42
43
(-)core/org/eclipse/debug/internal/core/commands/DisconnectCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IDisconnectHandler;
15
import org.eclipse.debug.core.commands.IDisconnectHandler;
15
import org.eclipse.debug.core.model.IDisconnect;
16
import org.eclipse.debug.core.model.IDisconnect;
16
17
Lines 40-48 Link Here
40
	}
41
	}
41
42
42
	/* (non-Javadoc)
43
	/* (non-Javadoc)
43
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
44
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
44
	 */
45
	 */
45
	protected Object getUpdateJobFamily() {
46
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
46
		return IDisconnectHandler.class;
47
		return IDisconnectHandler.class;
47
	}
48
	}
48
}
49
}
(-)core/org/eclipse/debug/internal/core/commands/StepCommand.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.debug.core.IRequest;
19
import org.eclipse.debug.core.IRequest;
20
import org.eclipse.debug.core.commands.AbstractDebugCommand;
20
import org.eclipse.debug.core.commands.IEnabledStateRequest;
21
import org.eclipse.debug.core.commands.IEnabledStateRequest;
21
import org.eclipse.debug.core.model.IStackFrame;
22
import org.eclipse.debug.core.model.IStackFrame;
22
import org.eclipse.debug.core.model.IStep;
23
import org.eclipse.debug.core.model.IStep;
Lines 26-32 Link Here
26
 * 
27
 * 
27
 * @since 3.3
28
 * @since 3.3
28
 */
29
 */
29
public abstract class StepCommand extends DebugCommand {
30
public abstract class StepCommand extends AbstractDebugCommand {
30
31
31
	protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException {
32
	protected void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException {
32
		for (int i = 0; i < targets.length; i++) {
33
		for (int i = 0; i < targets.length; i++) {
(-)core/org/eclipse/debug/internal/core/commands/StepIntoCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IStepIntoHandler;
15
import org.eclipse.debug.core.commands.IStepIntoHandler;
15
import org.eclipse.debug.core.model.IStep;
16
import org.eclipse.debug.core.model.IStep;
16
17
Lines 30-38 Link Here
30
	}
31
	}
31
32
32
	/* (non-Javadoc)
33
	/* (non-Javadoc)
33
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
34
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
34
	 */
35
	 */
35
	protected Object getUpdateJobFamily() {
36
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
36
		return IStepIntoHandler.class;
37
		return IStepIntoHandler.class;
37
	}
38
	}
38
39
(-)core/org/eclipse/debug/internal/core/commands/StepReturnCommand.java (-2 / +4 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IStepReturnHandler;
15
import org.eclipse.debug.core.commands.IStepReturnHandler;
15
import org.eclipse.debug.core.model.IStep;
16
import org.eclipse.debug.core.model.IStep;
16
17
Lines 29-38 Link Here
29
		((IStep)target).stepReturn();
30
		((IStep)target).stepReturn();
30
	}
31
	}
31
32
33
32
	/* (non-Javadoc)
34
	/* (non-Javadoc)
33
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
35
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
34
	 */
36
	 */
35
	protected Object getUpdateJobFamily() {
37
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
36
		return IStepReturnHandler.class;
38
		return IStepReturnHandler.class;
37
	}
39
	}
38
40
(-)core/org/eclipse/debug/internal/core/commands/SuspendCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.ISuspendHandler;
15
import org.eclipse.debug.core.commands.ISuspendHandler;
15
import org.eclipse.debug.core.model.ISuspendResume;
16
import org.eclipse.debug.core.model.ISuspendResume;
16
17
Lines 34-42 Link Here
34
	}
35
	}
35
36
36
	/* (non-Javadoc)
37
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
38
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
38
	 */
39
	 */
39
	protected Object getUpdateJobFamily() {
40
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
40
		return ISuspendHandler.class;
41
		return ISuspendHandler.class;
41
	}
42
	}
42
}
43
}
(-)core/org/eclipse/debug/internal/core/commands/StepFiltersCommand.java (-2 / +3 lines)
Lines 13-18 Link Here
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.DebugPlugin;
14
import org.eclipse.debug.core.DebugPlugin;
15
import org.eclipse.debug.core.ILaunch;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.commands.IDebugCommandRequest;
16
import org.eclipse.debug.core.commands.IStepFiltersHandler;
17
import org.eclipse.debug.core.commands.IStepFiltersHandler;
17
import org.eclipse.debug.core.model.IDebugElement;
18
import org.eclipse.debug.core.model.IDebugElement;
18
import org.eclipse.debug.core.model.IDebugTarget;
19
import org.eclipse.debug.core.model.IDebugTarget;
Lines 90-98 Link Here
90
	}
91
	}
91
	
92
	
92
	/* (non-Javadoc)
93
	/* (non-Javadoc)
93
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
94
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
94
	 */
95
	 */
95
	protected Object getUpdateJobFamily() {
96
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
96
		return IStepFiltersHandler.class;
97
		return IStepFiltersHandler.class;
97
	}	
98
	}	
98
}
99
}
(-)core/org/eclipse/debug/internal/core/commands/DropToFrameCommand.java (-2 / +3 lines)
Lines 11-16 Link Here
11
package org.eclipse.debug.internal.core.commands;
11
package org.eclipse.debug.internal.core.commands;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.commands.IDebugCommandRequest;
14
import org.eclipse.debug.core.commands.IDropToFrameHandler;
15
import org.eclipse.debug.core.commands.IDropToFrameHandler;
15
import org.eclipse.debug.core.model.IDropToFrame;
16
import org.eclipse.debug.core.model.IDropToFrame;
16
17
Lines 40-48 Link Here
40
	}
41
	}
41
42
42
	/* (non-Javadoc)
43
	/* (non-Javadoc)
43
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#getUpdateJobFamily()
44
	 * @see org.eclipse.debug.core.commands.AbstractDebugCommand#getEnabledStateJobFamily(org.eclipse.debug.core.commands.IDebugCommandRequest)
44
	 */
45
	 */
45
	protected Object getUpdateJobFamily() {
46
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
46
		return IDropToFrameHandler.class;
47
		return IDropToFrameHandler.class;
47
	}
48
	}
48
}
49
}
(-)core/org/eclipse/debug/internal/core/commands/DebugCommand.java (-324 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.internal.core.commands;
12
13
import java.util.LinkedHashSet;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
20
import org.eclipse.core.runtime.jobs.IJobChangeListener;
21
import org.eclipse.core.runtime.jobs.ISchedulingRule;
22
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.IRequest;
25
import org.eclipse.debug.core.commands.IDebugCommandHandler;
26
import org.eclipse.debug.core.commands.IDebugCommandRequest;
27
import org.eclipse.debug.core.commands.IEnabledStateRequest;
28
import org.eclipse.debug.internal.core.DebugOptions;
29
30
/**
31
 * Common function for standard debug commands.
32
 * 
33
 * @since 3.3
34
 *
35
 */
36
public abstract class DebugCommand implements IDebugCommandHandler {
37
	
38
	/**
39
	 * Job to update enabled state of action.
40
	 */
41
	class UpdateJob extends Job implements IJobChangeListener {
42
		
43
		/**
44
		 * The request to update
45
		 */
46
		private IEnabledStateRequest request;
47
		
48
		/**
49
		 * Whether this job has been run
50
		 */
51
		private boolean run = false;
52
		
53
		/**
54
		 * Creates a new job to update the specified request
55
		 * 
56
		 * @param stateRequest
57
		 */
58
		UpdateJob(IEnabledStateRequest stateRequest) {
59
			super(getEnablementTaskName());
60
			request = stateRequest;
61
			setSystem(true);
62
			setRule(createUpdateSchedulingRule(request));
63
			getJobManager().addJobChangeListener(this);
64
		}
65
		
66
		protected IStatus run(IProgressMonitor monitor) {
67
			run = true;
68
			if (DebugOptions.DEBUG_COMMANDS) {
69
				System.out.print("can execute command: " + DebugCommand.this); //$NON-NLS-1$
70
			}
71
			if (monitor.isCanceled()) {
72
				if (DebugOptions.DEBUG_COMMANDS) {
73
					System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$
74
				}
75
				request.cancel();
76
			}
77
			Object[] elements = request.getElements();
78
			Object[] targets = new Object[elements.length];
79
			if (!request.isCanceled()) {
80
				for (int i = 0; i < elements.length; i++) {
81
					targets[i] = getTarget(elements[i]);
82
					if (targets[i] == null) {
83
						request.setEnabled(false);
84
						request.cancel();
85
						if (DebugOptions.DEBUG_COMMANDS) {
86
							System.out.println(" >> false (no adapter)"); //$NON-NLS-1$
87
						}
88
					}
89
				}
90
				if (monitor.isCanceled()) {
91
					request.cancel();
92
				}
93
			}
94
			if (!request.isCanceled()) {
95
				targets = coalesce(targets);
96
				monitor.beginTask(getEnablementTaskName(), targets.length);
97
				try {
98
					boolean executable = isExecutable(targets, monitor, request);
99
					if (DebugOptions.DEBUG_COMMANDS) {
100
						System.out.println(" >> " + executable); //$NON-NLS-1$
101
					}
102
					request.setEnabled(executable);
103
				} catch (CoreException e) {
104
					request.setStatus(e.getStatus());
105
					request.setEnabled(false);
106
					if (DebugOptions.DEBUG_COMMANDS) {
107
						System.out.println(" >> ABORTED"); //$NON-NLS-1$
108
						System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
109
					}
110
				}
111
			}
112
			monitor.setCanceled(request.isCanceled());
113
			request.done();
114
			monitor.done();
115
			return Status.OK_STATUS;
116
		}
117
		
118
		/* (non-Javadoc)
119
		 * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
120
		 */
121
		public boolean belongsTo(Object family) {
122
			return getUpdateJobFamily().equals(family);
123
		}
124
125
		public void aboutToRun(IJobChangeEvent event) {
126
		}
127
128
		public void awake(IJobChangeEvent event) {
129
		}
130
131
		public void done(IJobChangeEvent event) {
132
			if (event.getJob() == this) {
133
				if (!run) {
134
					request.cancel();
135
					request.done();
136
					if (DebugOptions.DEBUG_COMMANDS) {
137
						System.out.println(" >> *CANCELED* <<" + DebugCommand.this); //$NON-NLS-1$
138
					}
139
				}
140
				getJobManager().removeJobChangeListener(this);
141
			}
142
		}
143
144
		public void running(IJobChangeEvent event) {
145
		}
146
147
		public void scheduled(IJobChangeEvent event) {
148
		}
149
150
		public void sleeping(IJobChangeEvent event) {
151
		}
152
				
153
	}
154
	
155
	/**
156
	 * Scheduling rule to serialize commands on an object
157
	 */
158
   class SerialPerObjectRule implements ISchedulingRule {
159
160
		private Object fObject = null;
161
162
		public SerialPerObjectRule(Object lock) {
163
			fObject = lock;
164
		}
165
166
		/*
167
		 * (non-Javadoc)
168
		 * 
169
		 * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
170
		 */
171
		public boolean contains(ISchedulingRule rule) {
172
			return rule == this;
173
		}
174
175
		/*
176
		 * (non-Javadoc)
177
		 * 
178
		 * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
179
		 */
180
		public boolean isConflicting(ISchedulingRule rule) {
181
			if (rule instanceof SerialPerObjectRule) {
182
				SerialPerObjectRule vup = (SerialPerObjectRule) rule;
183
				return fObject == vup.fObject;
184
			}
185
			return false;
186
		}
187
188
	}
189
   
190
	public boolean execute(final IDebugCommandRequest request) {
191
		Job job = new Job(getExecuteTaskName()) {
192
			protected IStatus run(IProgressMonitor monitor) {
193
				if (DebugOptions.DEBUG_COMMANDS) {
194
					System.out.println("execute: " + DebugCommand.this); //$NON-NLS-1$
195
				}
196
				Object[] elements = request.getElements();
197
				Object[] targets = new Object[elements.length];
198
				for (int i = 0; i < elements.length; i++) {
199
					targets[i]= getTarget(elements[i]);
200
				}
201
				targets = coalesce(targets);
202
				monitor.beginTask(getExecuteTaskName(), targets.length);
203
				try {
204
					doExecute(targets, monitor, request);
205
				} catch (CoreException e) {
206
					request.setStatus(e.getStatus());
207
					if (DebugOptions.DEBUG_COMMANDS) {
208
						System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
209
					}
210
				}
211
				request.done();
212
				monitor.setCanceled(request.isCanceled());
213
				monitor.done();
214
				return Status.OK_STATUS;
215
			}
216
		};
217
		job.setSystem(true);
218
		job.schedule();
219
		return isRemainEnabled();
220
	}	
221
	
222
	/**
223
	 * Returns whether this command should remain enabled after execution is invoked.
224
	 * 
225
	 * @return whether to remain enabled
226
	 */
227
	protected boolean isRemainEnabled() {
228
		return false;
229
	}
230
	
231
	public void canExecute(final IEnabledStateRequest request) {
232
		Job job = new UpdateJob(request);
233
		job.schedule();
234
	}
235
	
236
	/**
237
	 * Returns the name to use for jobs and progress monitor task names when checking
238
	 * enabled state.
239
	 * 
240
	 * @return task name
241
	 */
242
	protected String getEnablementTaskName() {
243
		// this is a system job name and does not need to be NLS'd
244
		return "Check Debug Command"; //$NON-NLS-1$
245
	}
246
	
247
	/**
248
	 * Returns the name to use for jobs and progress monitor task names when executing
249
	 * a debug command
250
	 * 
251
	 * @return task name
252
	 */
253
	protected String getExecuteTaskName() {
254
		// this is a system job name and does not need to be NLS'd
255
		return "Execute Debug Command"; //$NON-NLS-1$
256
	}	
257
258
	/**
259
	 * Executes the actual operation.
260
	 * 
261
	 * @param targets objects to perform on
262
	 * @param request request
263
	 */
264
	protected abstract void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException;
265
266
	/**
267
	 * Returns whether this command is executable.
268
	 * 
269
	 * @param targets objects to check command for
270
	 * @param monitor progress monitor
271
	 * @param request request
272
	 * @return whether this command can be executed
273
	 */
274
	protected abstract boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException;
275
	
276
	/**
277
	 * Returns the appropriate command adapter from the given object.
278
	 * 
279
	 * @param element object to obtain adapter from
280
	 * @return adapter
281
	 */
282
	protected abstract Object getTarget(Object element); 
283
	
284
	/**
285
	 * Returns an adapter of the specified type for the given object or <code>null</code>
286
	 * if none. The object itself is returned if it is an instance of the specified type.
287
	 * 
288
	 * @param element element to retrieve adapter for
289
	 * @param type adapter type
290
	 * @return adapter or <code>null</code>
291
	 */
292
	protected Object getAdapter(Object element, Class type) {
293
    	return DebugPlugin.getAdapter(element, type);	
294
	}	
295
	
296
	/**
297
	 * Scheduling rule for updating command enabled state.
298
	 * 
299
	 * @return scheduling rule or <code>null</code>
300
	 */
301
	protected ISchedulingRule createUpdateSchedulingRule(IDebugCommandRequest request) {
302
		return new SerialPerObjectRule(request.getElements()[0]);
303
	}
304
	
305
	private Object[] coalesce(Object[] objects) {
306
		if (objects.length == 1) {
307
			return objects;
308
		} else {
309
			LinkedHashSet set = new LinkedHashSet(objects.length);
310
			for (int i = 0; i < objects.length; i++) {
311
				set.add(objects[i]);
312
			}
313
			return set.toArray();
314
		}
315
	}
316
	
317
	/**
318
	 * Returns the job family for this command's "can execute" job.
319
	 * 
320
	 * @return the job family for this command's "can execute" job
321
	 */
322
	protected abstract Object getUpdateJobFamily();
323
	
324
}
(-)core/org/eclipse/debug/internal/core/commands/ForEachCommand.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.IRequest;
15
import org.eclipse.debug.core.IRequest;
16
import org.eclipse.debug.core.commands.AbstractDebugCommand;
16
import org.eclipse.debug.core.commands.IEnabledStateRequest;
17
import org.eclipse.debug.core.commands.IEnabledStateRequest;
17
18
18
/**
19
/**
Lines 20-26 Link Here
20
 * 
21
 * 
21
 * @since 3.3
22
 * @since 3.3
22
 */
23
 */
23
public abstract class ForEachCommand extends DebugCommand {
24
public abstract class ForEachCommand extends AbstractDebugCommand {
24
25
25
	/* (non-Javadoc)
26
	/* (non-Javadoc)
26
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#doExecute(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.debug.core.IRequest)
27
	 * @see org.eclipse.debug.internal.core.commands.DebugCommand#doExecute(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.debug.core.IRequest)
(-)core/org/eclipse/debug/core/commands/IDebugCommandHandler.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 66-72 Link Here
66
	 * given request. Errors can reported by setting an appropriate status
66
	 * given request. Errors can reported by setting an appropriate status
67
	 * on the given request. A request can be canceled by this handler or the caller. 
67
	 * on the given request. A request can be canceled by this handler or the caller. 
68
	 * A <code>null</code> status is equivalent to an OK status. When a request is
68
	 * A <code>null</code> status is equivalent to an OK status. When a request is
69
	 * complete, has encountered an error, or cancelled, implementations must call
69
	 * complete, has encountered an error, or canceled, implementations must call
70
	 * <code>done()</code> on the given collector.
70
	 * <code>done()</code> on the given collector.
71
	 * </p>
71
	 * </p>
72
	 * <p>
72
	 * <p>
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
4
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
5
Bundle-Version: 3.5.100.qualifier
5
Bundle-Version: 3.6.0.qualifier
6
Bundle-ClassPath: .
6
Bundle-ClassPath: .
7
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
7
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
8
Bundle-Vendor: %providerName
8
Bundle-Vendor: %providerName
(-)buildnotes_platform-debug.html (+10 lines)
Lines 11-16 Link Here
11
11
12
<h2>Summary of API changes in 3.6</h2>
12
<h2>Summary of API changes in 3.6</h2>
13
13
14
<h3>DebugCommandAction base class</h3>
15
<p><strong>What is affected:</strong>
16
<ul>
17
  <li>Class addition: <code>org.eclipse.debug.ui.actions.DebugCommandAction</code> </li>
18
  <li>Class addition: <code>org.eclipse.debug.ui.actions.DebugCommandHandler</code> </li>
19
</ul>
20
</p>
21
<p><strong>Description:</strong>The <code>IDebugCommandHandler</code> interface allows debugger to implement debug action handlers which execute asynchronously.  Most of the debugger actions user this interface to communicate with the debug model.  However, debuggers which need to add their own asynchronous actions had to duplicate the debug framework actions which invoke the <code>IDebugCommandHandler</code> handlers.  <code>DebugCommandAction</code> and <code>DebugCommandHandler</code> are base classes which can be extended by debuggers to implement new types of actions with asynchronous execution handlers.</p>
22
<p><strong>Action required:</strong> This is a backwards compatible change. No action required. </p>
23
14
<p>&nbsp;</p>
24
<p>&nbsp;</p>
15
</body>
25
</body>
16
</html>
26
</html>
(-)core/org/eclipse/debug/core/commands/AbstractDebugCommand.java (+408 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.debug.core.commands;
12
13
import java.util.LinkedHashSet;
14
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
20
import org.eclipse.core.runtime.jobs.IJobChangeListener;
21
import org.eclipse.core.runtime.jobs.ISchedulingRule;
22
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.IRequest;
25
import org.eclipse.debug.internal.core.DebugOptions;
26
27
/**
28
 * Abstract implementation of a debug command handler. Handles {@link IDebugCommandRequest}
29
 * and {@link IEnabledStateRequest} updates asynchronously using jobs.
30
 * <p>
31
 * Clients may subclass this class.
32
 * </p>
33
 * @since 3.6
34
 */
35
public abstract class AbstractDebugCommand implements IDebugCommandHandler {
36
	
37
	/**
38
	 * Job to update enabled state of action.
39
	 */
40
	private class UpdateJob extends Job implements IJobChangeListener {
41
		
42
		/**
43
		 * The request to update
44
		 */
45
		private IEnabledStateRequest request;
46
		
47
		/**
48
		 * Whether this job has been run
49
		 */
50
		private boolean run = false;
51
		
52
		/**
53
		 * Creates a new job to update the specified request
54
		 * 
55
		 * @param stateRequest
56
		 */
57
		UpdateJob(IEnabledStateRequest stateRequest) {
58
			super(getEnabledStateTaskName());
59
			request = stateRequest;
60
			setSystem(true);
61
			setRule(getEnabledStateSchedulingRule(request));
62
			getJobManager().addJobChangeListener(this);
63
		}
64
		
65
		/* (non-Javadoc)
66
		 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
67
		 */
68
		protected IStatus run(IProgressMonitor monitor) {
69
			run = true;
70
			if (DebugOptions.DEBUG_COMMANDS) {
71
				System.out.print("can execute command: " + AbstractDebugCommand.this); //$NON-NLS-1$
72
			}
73
			if (monitor.isCanceled()) {
74
				if (DebugOptions.DEBUG_COMMANDS) {
75
					System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$
76
				}
77
				request.cancel();
78
			}
79
			Object[] elements = request.getElements();
80
			Object[] targets = new Object[elements.length];
81
			if (!request.isCanceled()) {
82
				for (int i = 0; i < elements.length; i++) {
83
					targets[i] = getTarget(elements[i]);
84
					if (targets[i] == null) {
85
						request.setEnabled(false);
86
						request.cancel();
87
						if (DebugOptions.DEBUG_COMMANDS) {
88
							System.out.println(" >> false (no adapter)"); //$NON-NLS-1$
89
						}
90
					}
91
				}
92
				if (monitor.isCanceled()) {
93
					request.cancel();
94
				}
95
			}
96
			if (!request.isCanceled()) {
97
				targets = coalesce(targets);
98
				monitor.beginTask(getEnabledStateTaskName(), targets.length);
99
				try {
100
					boolean executable = isExecutable(targets, monitor, request);
101
					if (DebugOptions.DEBUG_COMMANDS) {
102
						System.out.println(" >> " + executable); //$NON-NLS-1$
103
					}
104
					request.setEnabled(executable);
105
				} catch (CoreException e) {
106
					request.setStatus(e.getStatus());
107
					request.setEnabled(false);
108
					if (DebugOptions.DEBUG_COMMANDS) {
109
						System.out.println(" >> ABORTED"); //$NON-NLS-1$
110
						System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
111
					}
112
				}
113
			}
114
			monitor.setCanceled(request.isCanceled());
115
			request.done();
116
			monitor.done();
117
			return Status.OK_STATUS;
118
		}
119
		
120
		/* (non-Javadoc)
121
		 * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
122
		 */
123
		public boolean belongsTo(Object family) {
124
			Object myFamily = getEnabledStateJobFamily(request);
125
			if (myFamily != null) {
126
				return myFamily.equals(family);
127
			}
128
			return false;
129
		}
130
131
		public void aboutToRun(IJobChangeEvent event) {
132
		}
133
134
		public void awake(IJobChangeEvent event) {
135
		}
136
137
		public void done(IJobChangeEvent event) {
138
			if (event.getJob() == this) {
139
				if (!run) {
140
					request.cancel();
141
					request.done();
142
					if (DebugOptions.DEBUG_COMMANDS) {
143
						System.out.println(" >> *CANCELED* <<" + AbstractDebugCommand.this); //$NON-NLS-1$
144
					}
145
				}
146
				getJobManager().removeJobChangeListener(this);
147
			}
148
		}
149
150
		public void running(IJobChangeEvent event) {
151
		}
152
153
		public void scheduled(IJobChangeEvent event) {
154
		}
155
156
		public void sleeping(IJobChangeEvent event) {
157
		}
158
				
159
	}
160
	
161
	/**
162
	 * Scheduling rule to serialize commands on an object
163
	 */
164
   private class SerialPerObjectRule implements ISchedulingRule {
165
166
		private Object fObject = null;
167
168
		public SerialPerObjectRule(Object lock) {
169
			fObject = lock;
170
		}
171
172
		/*
173
		 * (non-Javadoc)
174
		 * 
175
		 * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
176
		 */
177
		public boolean contains(ISchedulingRule rule) {
178
			return rule == this;
179
		}
180
181
		/*
182
		 * (non-Javadoc)
183
		 * 
184
		 * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
185
		 */
186
		public boolean isConflicting(ISchedulingRule rule) {
187
			if (rule instanceof SerialPerObjectRule) {
188
				SerialPerObjectRule vup = (SerialPerObjectRule) rule;
189
				return fObject == vup.fObject;
190
			}
191
			return false;
192
		}
193
194
	}
195
   
196
	/* (non-Javadoc)
197
	 * @see org.eclipse.debug.core.commands.IDebugCommandHandler#execute(org.eclipse.debug.core.commands.IDebugCommandRequest)
198
	 */
199
	public boolean execute(final IDebugCommandRequest request) {
200
		Job job = new Job(getExecuteTaskName()) {
201
			protected IStatus run(IProgressMonitor monitor) {
202
				if (DebugOptions.DEBUG_COMMANDS) {
203
					System.out.println("execute: " + AbstractDebugCommand.this); //$NON-NLS-1$
204
				}
205
				Object[] elements = request.getElements();
206
				Object[] targets = new Object[elements.length];
207
				for (int i = 0; i < elements.length; i++) {
208
					targets[i]= getTarget(elements[i]);
209
				}
210
				targets = coalesce(targets);
211
				monitor.beginTask(getExecuteTaskName(), targets.length);
212
				try {
213
					doExecute(targets, monitor, request);
214
				} catch (CoreException e) {
215
					request.setStatus(e.getStatus());
216
					if (DebugOptions.DEBUG_COMMANDS) {
217
						System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
218
					}
219
				}
220
				request.done();
221
				monitor.setCanceled(request.isCanceled());
222
				monitor.done();
223
				return Status.OK_STATUS;
224
			}
225
			public boolean belongsTo(Object family) {
226
				Object jobFamily = getExecuteJobFamily(request);
227
				if (jobFamily != null) {
228
					return jobFamily.equals(family);
229
				}
230
				return false;
231
			}
232
		};
233
		job.setSystem(true);
234
		job.setRule(getExecuteSchedulingRule(request));
235
		job.schedule();
236
		return isRemainEnabled(request);
237
	}	
238
	
239
	/**
240
	 * Returns whether this command should remain enabled after starting execution of the specified request.
241
	 * 
242
	 * @param request the request being executed
243
	 * @return whether to remain enabled while executing the request
244
	 */
245
	protected boolean isRemainEnabled(IDebugCommandRequest request) {
246
		return false;
247
	}
248
	
249
	/* (non-Javadoc)
250
	 * @see org.eclipse.debug.core.commands.IDebugCommandHandler#canExecute(org.eclipse.debug.core.commands.IEnabledStateRequest)
251
	 */
252
	public void canExecute(final IEnabledStateRequest request) {
253
		Job job = new UpdateJob(request);
254
		job.schedule();
255
	}
256
	
257
	/**
258
	 * Returns the name to use for a job and progress monitor task names when performing
259
	 * an {@link IEnabledStateRequest}.
260
	 * 
261
	 * @return task name
262
	 */
263
	protected String getEnabledStateTaskName() {
264
		// this is a system job name and does not need to be NLS'd
265
		return "Check Debug Command"; //$NON-NLS-1$
266
	}
267
	
268
	/**
269
	 * Returns the name to use for jobs and progress monitor task names when executing
270
	 * an {@link IDebugCommandRequest}.
271
	 * 
272
	 * @return task name
273
	 */
274
	protected String getExecuteTaskName() {
275
		// this is a system job name and does not need to be NLS'd
276
		return "Execute Debug Command"; //$NON-NLS-1$
277
	}	
278
279
	/**
280
	 * Executes this command synchronously on the specified targets, reporting progress. This method
281
	 * is called by a job. If an exception is thrown, the calling job will set the associated status
282
	 * on the request object. The calling job also calls #done() on the request object after this method
283
	 * is called, and sets a cancel status on the progress monitor if the request is canceled. 
284
	 * <p>
285
	 * Handlers must override this method.
286
	 * </p>
287
	 * @param targets objects to perform this command on
288
	 * @param monitor progress monitor
289
	 * @param request can be used to cancel this command
290
	 * @exception CoreException if this handler fails to perform the request
291
	 */
292
	protected abstract void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException;
293
294
	/**
295
	 * Returns whether this command is executable on the specified targets, reporting progress. This method
296
	 * is called by a job. If an exception is thrown, the calling job will set the associated status
297
	 * on the request object and report that this command is not enabled. The calling job also calls #done()
298
	 * on the request object after this method is called, and sets a cancel status on the progress monitor if
299
	 * the request is canceled. Enabled state is set to <code>false</code> if the request is canceled. 
300
	 * <p>
301
	 * Handlers must override this method.
302
	 * </p>
303
	 * @param targets objects to check command enabled state for
304
	 * @param monitor progress monitor
305
	 * @param request can be used to cancel this update request
306
	 * @return whether this command can be executed for the given targets
307
	 */
308
	protected abstract boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException;
309
	
310
	/**
311
	 * Returns the appropriate target for this command handler for the given object.
312
	 * This method is called to map each element in a command request to the target
313
	 * object that is used in {@link #doExecute(Object[], IProgressMonitor, IRequest)}
314
	 * and {@link #isExecutable(Object[], IProgressMonitor, IEnabledStateRequest)}.
315
	 * The target may be the element itself, or some other object. Allows for redirection.
316
	 * <p>
317
	 * Clients must override this method.
318
	 * </p>
319
	 * @param element element from a {@link IDebugCommandRequest} 
320
	 * @return associated target object for execution or enabled state update. Cannot return <code>null</code>.
321
	 */
322
	protected abstract Object getTarget(Object element); 
323
	
324
	/**
325
	 * Convenience method to return an adapter of the specified type for the given object or <code>null</code>
326
	 * if none.
327
	 * 
328
	 * @param element element to retrieve adapter for
329
	 * @param type adapter type
330
	 * @return adapter or <code>null</code>
331
	 * @see {@link DebugPlugin#getAdapter(Object, Class)}
332
	 */
333
	protected Object getAdapter(Object element, Class type) {
334
    	return DebugPlugin.getAdapter(element, type);	
335
	}	
336
	
337
	/**
338
	 * Returns a scheduling rule for this command's {@link IEnabledStateRequest} update job
339
	 * or <code>null</code> if none. By default a rule is created to serialize
340
	 * jobs on the first element in the request.
341
	 * <p>
342
	 * Clients may override this method as required.
343
	 * </p>
344
	 * @param request request that a scheduling rule is required for
345
	 * @return scheduling rule or <code>null</code>
346
	 */
347
	protected ISchedulingRule getEnabledStateSchedulingRule(IDebugCommandRequest request) {
348
		return new SerialPerObjectRule(request.getElements()[0]);
349
	}
350
	
351
	/**
352
	 * Returns a scheduling rule for this command's {@link IDebugCommandRequest} execute job
353
	 * or <code>null</code> if none. By default, execution jobs have no scheduling rule.
354
	 * <p>
355
	 * Clients may override this method as required.
356
	 * </p>
357
	 * @param request request that a scheduling rule is required for
358
	 * @return scheduling rule or <code>null</code>
359
	 */
360
	protected ISchedulingRule getExecuteSchedulingRule(IDebugCommandRequest request) {
361
		return null;
362
	}
363
	
364
	/**
365
	 * Returns the job family for the this command's {@link IEnabledStateRequest} update job
366
	 * or <code>null</code> if none. The default implementation returns <code>null</code>.
367
	 * <p>
368
	 * Clients may override this method as required.
369
	 * </p>
370
	 * @param request request the job family is required for
371
	 * @return job family object or <code>null</code> if none
372
	 */
373
	protected Object getEnabledStateJobFamily(IDebugCommandRequest request) {
374
		return null;
375
	}	
376
	
377
	/**
378
	 * Returns the job family for the this command's {@link IDebugCommandRequest} execute job
379
	 * or <code>null</code> if none. The default implementation returns <code>null</code>.
380
	 * <p>
381
	 * Clients may override this method as required.
382
	 * </p>
383
	 * @param request request the job family is required for
384
	 * @return job family object or <code>null</code> if none
385
	 */
386
	protected Object getExecuteJobFamily(IDebugCommandRequest request) {
387
		return null;
388
	}	
389
	
390
	/**
391
	 * Returns an array of objects with duplicates removed, if any.
392
	 * 
393
	 * @param objects array of objects
394
	 * @return array of object in same order with duplicates removed, if any.
395
	 */
396
	private Object[] coalesce(Object[] objects) {
397
		if (objects.length == 1) {
398
			return objects;
399
		} else {
400
			LinkedHashSet set = new LinkedHashSet(objects.length);
401
			for (int i = 0; i < objects.length; i++) {
402
				set.add(objects[i]);
403
			}
404
			return set.toArray();
405
		}
406
	}
407
	
408
}

Return to bug 284363