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 140650 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/platform/instrumentation/ui/internal/control/provider/application/AgentControlProvider.java (-208 / +33 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 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-36 Link Here
11
 ***********************************************************************/
11
 ***********************************************************************/
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application;
12
package org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application;
13
13
14
import java.util.Iterator;
14
import org.eclipse.core.commands.IHandler;
15
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.hyades.trace.ui.ProfileEvent;
18
import org.eclipse.hyades.trace.ui.UIPlugin;
19
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
15
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
20
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
16
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
21
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
22
import org.eclipse.hyades.ui.extension.INavigatorContribution;
17
import org.eclipse.hyades.ui.extension.INavigatorContribution;
23
import org.eclipse.jface.resource.ImageDescriptor;
24
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
26
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
18
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
27
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
28
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
29
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractControlProvider;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractControlProvider;
30
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
31
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
32
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
33
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
22
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
23
import org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem;
24
import org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItemHandler;
25
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshOption;
26
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshOptionHandler;
27
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView;
28
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshViewHandler;
29
import org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem;
30
import org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItemHandler;
31
import org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction;
32
import org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateControlItemHandler;
34
import org.eclipse.tptp.trace.ui.provisional.control.provider.ProcessControlProvider.ProcessStateModifier;
33
import org.eclipse.tptp.trace.ui.provisional.control.provider.ProcessControlProvider.ProcessStateModifier;
35
34
36
/**
35
/**
Lines 40-53 Link Here
40
 */
39
 */
41
public class AgentControlProvider extends AbstractControlProvider {
40
public class AgentControlProvider extends AbstractControlProvider {
42
41
43
	/* The id of the contributed items */
44
	private static final String REFRESH_ITEM = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.refreshViews";
45
	private static final String REFRESH_OPTION = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.refreshOption";
46
	private static final String TERMINATE_ITEM = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.terminateAction";
47
	public static final String START_MONITORING = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.startMonitoring";
48
	public static final String PAUSE_MONITORING = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.stopMonitoring";
49
50
	
51
	/* The delete item */
42
	/* The delete item */
52
	private IControlItem delete;
43
	private IControlItem delete;
53
	
44
	
Lines 74-80 Link Here
74
	
65
	
75
	/* The agent state modifier */
66
	/* The agent state modifier */
76
	private IAgentStateModifier agentStateModifier;
67
	private IAgentStateModifier agentStateModifier;
77
68
	
69
	/* The handler for the actions */
70
	private IHandler handler; 
78
	/**
71
	/**
79
	 * Default constructor.
72
	 * Default constructor.
80
	 */
73
	 */
Lines 136-162 Link Here
136
    protected IControlItem createRefreshViewsControlItem() {
129
    protected IControlItem createRefreshViewsControlItem() {
137
    	if (refresh != null)
130
    	if (refresh != null)
138
    		return refresh;
131
    		return refresh;
139
    	
132
140
    	class RefreshView extends ControlItem
141
    	{    		
142
    		public RefreshView()
143
    		{
144
    			super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
145
    		}
146
    		
147
    		public void run()
148
    		{
149
    			if (input == null)
150
    				return;
151
    			
152
    			for (Iterator sources = input.iterator(); sources.hasNext();)
153
    			{					
154
    				ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
155
    				UIPlugin.getDefault().notifyProfileEventListener(event);
156
    			}
157
    		}
158
    	}
159
    	refresh = new RefreshView();
133
    	refresh = new RefreshView();
134
    	handler = new RefreshViewHandler(refresh);
135
    	refresh.setHandler(handler);
160
    	return refresh;
136
    	return refresh;
161
    }
137
    }
162
    
138
    
Lines 168-196 Link Here
168
    protected IControlItem createRefreshOptionControlItem() {
144
    protected IControlItem createRefreshOptionControlItem() {
169
    	if (refreshOption != null)
145
    	if (refreshOption != null)
170
    		return refreshOption;
146
    		return refreshOption;
171
    	
147
172
    	class RefreshOption extends ControlItem
173
    	{    		
174
    		public RefreshOption()
175
    		{
176
    			super (REFRESH_OPTION, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_OPTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_OPTIONS));
177
    		}
178
    		
179
    		/* This method is invoked when ever user clicks the 'Change Refresh Options' button.
180
    		 * It simply invokes the 'handleProfileEvent' method of PDProjectExplorer */
181
    		public void run()
182
    		{
183
    			if (input == null)
184
    				return;
185
    			
186
    			for (Iterator sources = input.iterator(); sources.hasNext();)
187
    			{					
188
    				ProfileEvent event = UIPlugin.getDefault().getRefreshOptionEvent(sources.next());
189
    				UIPlugin.getDefault().notifyProfileEventListener(event);
190
    			}
191
    		}
192
    	}
193
    	refreshOption = new RefreshOption();
148
    	refreshOption = new RefreshOption();
149
    	handler = new RefreshOptionHandler(refreshOption);
150
    	refreshOption.setHandler(handler);
194
    	return refreshOption;
151
    	return refreshOption;
195
    }
152
    }
196
    
153
    
Lines 199-273 Link Here
199
    	if (resumeItem != null)
156
    	if (resumeItem != null)
200
    		return resumeItem;
157
    		return resumeItem;
201
    	
158
    	
202
    	class ResumeControlItem extends AgentControlItem
159
    	resumeItem = new ResumeControlItem(getAgentStateModifier());
203
    	{		
160
    	handler = new ResumeControlItemHandler(resumeItem);
204
    		public ResumeControlItem()
161
    	resumeItem.setHandler(handler);
205
    		{
206
    			super(getAgentStateModifier(), START_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_RESUME, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_RESUME));
207
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
208
    		}
209
    		
210
			public void run()
211
			{
212
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
213
											
214
				try
215
				{
216
					/* Resume the agent */
217
					agentStateModifier.startMonitoring();
218
				} catch (CoreException e)
219
				{
220
					/* Display status */
221
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
222
				}				
223
			}
224
			
225
			public boolean isEnabled()
226
			{
227
				return getAgentStateModifier().canResume();
228
			}		
229
    	}
230
    	
231
    	
232
    	resumeItem = new ResumeControlItem();
233
    	return resumeItem;
162
    	return resumeItem;
234
    }
163
    }
235
    
164
    
236
    protected IControlItem createPauseMonitoringControlItem() {
165
    protected IControlItem createPauseMonitoringControlItem() {
237
    	if (pauseItem != null)
166
    	if (pauseItem != null)
238
    		return pauseItem;
167
    		return pauseItem;	
239
    	
240
    	class PauseControlItem extends AgentControlItem
241
    	{		
242
    		public PauseControlItem()
243
    		{
244
    			super(getAgentStateModifier(), PAUSE_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_PAUSE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_PAUSE));
245
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
246
    		}
247
    		
248
			public void run()
249
			{
250
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
251
											
252
				try
253
				{
254
					/* Pause the agent */					
255
					agentStateModifier.pauseMonitoring();
256
				} catch (CoreException e)
257
				{
258
					/* Display status */
259
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
260
				}				
261
			}
262
			
263
			public boolean isEnabled()
264
			{
265
				return getAgentStateModifier().canPause();
266
			}		
267
    	}
268
    	
168
    	
269
    	
169
    	pauseItem = new PauseControlItem(getAgentStateModifier());
270
    	pauseItem = new PauseControlItem();
170
    	handler = new PauseControlItemHandler(pauseItem);
171
    	pauseItem.setHandler(handler);
271
    	return pauseItem;
172
    	return pauseItem;
272
    }
173
    }
273
174
Lines 281-368 Link Here
281
	protected IControlItem createTerminateControlItem() {
182
	protected IControlItem createTerminateControlItem() {
282
		if (terminateItem != null)
183
		if (terminateItem != null)
283
			return terminateItem;
184
			return terminateItem;
284
			
185
						
285
		class TerminateAction extends ControlItem
186
		terminateItem = new TerminateAction(getProcessStateModifier());
286
		{
187
		handler = new TerminateControlItemHandler(terminateItem);
287
			public TerminateAction()
188
		terminateItem.setHandler(handler);
288
			{
289
				super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
290
				setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
291
			}
292
			
293
			public void run()
294
			{
295
				IProcessStateModifier processStateModifier = getProcessStateModifier();
296
											
297
				try
298
				{
299
					/* Terminate the process */
300
					processStateModifier.terminate();
301
				} catch (CoreException e)
302
				{
303
					/* Display status */
304
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
305
				}				
306
			}
307
			
308
			public boolean isEnabled()
309
			{
310
				return getProcessStateModifier().canTerminate();
311
			}
312
			
313
			public void setInput(StructuredSelection input)
314
			{
315
				getProcessStateModifier().setInput(input);
316
			}
317
			
318
			public IProcessStateModifier getStateModifier()
319
			{
320
				return getProcessStateModifier();
321
			}
322
			
323
			public boolean equals (Object o)
324
			{
325
				if (!(o instanceof TerminateAction))
326
					return false;
327
				
328
				return getProcessStateModifier() == ((TerminateAction)o).getStateModifier() && super.equals(o);
329
			}
330
331
		}
332
			
333
				
334
		terminateItem = new TerminateAction();
335
		return terminateItem;
189
		return terminateItem;
336
	}
190
	}
337
	
191
338
    private static class AgentControlItem extends ControlItem {
339
		private IAgentStateModifier stateModifier;
340
    	
341
    	public AgentControlItem (IAgentStateModifier stateModifier, String itemId, String groupName, String text, ImageDescriptor imageDescriptor)
342
    	{
343
    		super(itemId, groupName, text, imageDescriptor);
344
    		this.stateModifier = stateModifier;
345
    	}
346
    			
347
		public void setInput(StructuredSelection input)
348
		{
349
			stateModifier.setInput(input);
350
		}
351
	
352
		
353
		public IAgentStateModifier getStateModifier()
354
		{
355
			return stateModifier;
356
		}
357
		
358
		public boolean equals (Object o)
359
		{
360
			if (!(o instanceof AgentControlItem))
361
				return false;
362
			
363
			return stateModifier == ((AgentControlItem)o).getStateModifier() && super.equals(o);
364
		}
365
			
366
	}
367
192
368
}
193
}
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/TIAgentControlProvider.java (-50 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2007 2008 IBM Corporation, Intel Corporation.
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-17 Link Here
12
12
13
import java.util.Iterator;
13
import java.util.Iterator;
14
14
15
import org.eclipse.core.commands.IHandler;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
Lines 21-51 Link Here
21
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
22
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
22
import org.eclipse.hyades.models.hierarchy.TRCNode;
23
import org.eclipse.hyades.models.hierarchy.TRCNode;
23
import org.eclipse.hyades.trace.ui.ProfileEvent;
24
import org.eclipse.hyades.trace.ui.ProfileEvent;
24
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
25
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.osgi.util.NLS;
27
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
29
import org.eclipse.tptp.platform.execution.client.agent.ICollector;
28
import org.eclipse.tptp.platform.execution.client.agent.ICollector;
30
import org.eclipse.tptp.platform.execution.client.core.IAgentController;
29
import org.eclipse.tptp.platform.execution.client.core.IAgentController;
31
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
30
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
32
import org.eclipse.tptp.platform.jvmti.client.internal.TIMessages;
31
import org.eclipse.tptp.platform.jvmti.client.internal.TIMessages;
33
import org.eclipse.tptp.platform.jvmti.client.internal.TIPlugin;
32
import org.eclipse.tptp.platform.jvmti.client.internal.TIPlugin;
34
import org.eclipse.tptp.platform.jvmti.client.internal.TIUtility;
33
import org.eclipse.tptp.platform.jvmti.client.internal.TIUtility;
35
import org.eclipse.tptp.platform.jvmti.client.internal.actions.RunGCActionDelegate;
36
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
34
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
37
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIDelegateHelper;
35
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIDelegateHelper;
38
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate;
36
import org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate;
39
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
37
import org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem;
38
import org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItemHandler;
40
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
39
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
41
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
40
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
42
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider;
41
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider;
43
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
44
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
42
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
45
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
43
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
46
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
44
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
47
45
48
49
/**
46
/**
50
 * This is the TI agent control provider.  Its purpose is to modify the states that the TI agent
47
 * This is the TI agent control provider.  Its purpose is to modify the states that the TI agent
51
 * can be in (e.g. Pause/Resume/Detach/Attach).
48
 * can be in (e.g. Pause/Resume/Detach/Attach).
Lines 54-65 Link Here
54
 */
51
 */
55
public class TIAgentControlProvider extends AbstractAgentControlProvider
52
public class TIAgentControlProvider extends AbstractAgentControlProvider
56
{
53
{
57
    
58
    /** The id of the contributed items */
59
    private static final String RUNGC_ITEM = "org.eclipse.tptp.trace.jvmti.client.internal.popupMenu.RunGCAction";
60
	
61
    /** The runGC item */
54
    /** The runGC item */
62
    private IControlItem runGCControlItem;
55
    protected static IControlItem runGCControlItem;
56
	private IHandler handler;
63
57
64
    
58
    
65
    protected void initializeControlItems() {
59
    protected void initializeControlItems() {
Lines 79-124 Link Here
79
	if (runGCControlItem != null)
73
	if (runGCControlItem != null)
80
	    return runGCControlItem;
74
	    return runGCControlItem;
81
75
82
	runGCControlItem = new RunGCControlItem();
76
	runGCControlItem = new GCControlItem();
77
	handler = TIAgentToolbarControlProvider.garbageCollectionControlItem.getHandler();
78
	runGCControlItem.setHandler(handler); 
83
	return runGCControlItem;
79
	return runGCControlItem;
84
    }
80
    }
85
86
    static class RunGCControlItem extends ControlItem {
87
	
88
	private RunGCActionDelegate gcAction;
89
	
90
	public RunGCControlItem() {
91
	    super(RUNGC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
92
		    ControlMessages.CONTROL_ITEM_GC_ACTION,
93
		    TraceUIImages.INSTANCE.getImageDescriptor("c",
94
			    TraceUIImages.IMG_GC));
95
	    setDisabledImageDescriptor(TraceUIImages.INSTANCE
96
		    .getImageDescriptor("d", TraceUIImages.IMG_GC));
97
	    gcAction = new RunGCActionDelegate();
98
	}
99
100
	public void run() {
101
	    try {
102
		for (Iterator agents = input.iterator(); agents.hasNext();)
103
		    gcAction.doAction(agents.next());
104
105
	    } catch (Exception e) {
106
		LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e
107
			.getMessage(), e);
108
	    }
109
	}
110
111
	public boolean isEnabled() {
112
	    if (input == null || input.size() == 0)
113
		return false;
114
115
	    boolean isEnable = true;
116
	    for (Iterator agents = input.iterator(); isEnable
117
		    && agents.hasNext();)
118
		isEnable = isEnable && gcAction.isEnabledFor(agents.next());
119
	    return isEnable;
120
	}
121
    }
122
	
81
	
123
	public IAgentStateModifier getAgentStateModifier()
82
	public IAgentStateModifier getAgentStateModifier()
124
	{
83
	{
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/TIAgentToolbarControlProvider.java (-4 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006,2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2006, 2008 IBM Corporation, Intel Corporation.
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-20 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.platform.jvmti.client.internal.controlproviders;
11
package org.eclipse.tptp.platform.jvmti.client.internal.controlproviders;
12
12
13
import org.eclipse.core.commands.IHandler;
13
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
14
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
15
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIAgentControlProvider.TIAgentStateModifier;
16
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIAgentControlProvider.TIAgentStateModifier;
16
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIAgentControlProvider.RunGCControlItem;
17
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
17
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
18
import org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItemHandler;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
22
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
Lines 30-37 Link Here
30
{
32
{
31
	public static final String GC_TOOLBAR_ITEM = "org.eclipse.tptp.trace.jvmti.client.internal.monitorsview.toolbar.runGC";
33
	public static final String GC_TOOLBAR_ITEM = "org.eclipse.tptp.trace.jvmti.client.internal.monitorsview.toolbar.runGC";
32
34
33
	private IControlItem garbageCollectionControlItem;
35
	protected static IControlItem garbageCollectionControlItem;
34
36
37
	private IHandler handler;
35
38
36
	public IProcessStateModifier getProcessStateModifier()
39
	public IProcessStateModifier getProcessStateModifier()
37
	{		
40
	{		
Lines 52-61 Link Here
52
	if (garbageCollectionControlItem != null)
55
	if (garbageCollectionControlItem != null)
53
	    return garbageCollectionControlItem;
56
	    return garbageCollectionControlItem;
54
57
55
	garbageCollectionControlItem = makeToolbarReady(new RunGCControlItem(),
58
	garbageCollectionControlItem = makeToolbarReady(new GCControlItem(),
56
		GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
59
		GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
57
		TraceUIImages.INSTANCE.getImageDescriptor("d",
60
		TraceUIImages.INSTANCE.getImageDescriptor("d",
58
			TraceUIImages.IMG_GC));
61
			TraceUIImages.IMG_GC));
62
	handler = new GCControlItemHandler(garbageCollectionControlItem);
63
	garbageCollectionControlItem.setHandler(handler); 
59
	return garbageCollectionControlItem;
64
	return garbageCollectionControlItem;
60
    }
65
    }
61
}
66
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractAgentControlProvider.java (-145 / +22 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-23 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.viewers.StructuredSelection;
15
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
18
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
19
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
21
16
22
17
23
/**
18
/**
Lines 38-61 Link Here
38
 */
33
 */
39
public abstract class AbstractAgentControlProvider extends ProcessControlProvider 
34
public abstract class AbstractAgentControlProvider extends ProcessControlProvider 
40
{
35
{
41
	/** The id of the control items contributed */
42
	public static final String ATTACH_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.AttachAction";
43
	public static final String DETACH_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.DetachAction";
44
	public static final String START_MONITORING = "org.eclipse.hyades.trace.ui.internal.monitorsview.popupMenu.startMonitoring";
45
	public static final String PAUSE_MONITORING = "org.eclipse.hyades.trace.ui.internal.popupMenu.stopMonitoring";
46
	
47
	
48
	/** The attach control item */
36
	/** The attach control item */
49
	private IControlItem attachItem;
37
	protected IControlItem attachItem;
50
	
38
	
51
	/** The detach control item */
39
	/** The detach control item */
52
	private IControlItem detachItem;
40
	protected IControlItem detachItem;
53
	
41
	
54
	/** The resume control item */
42
	/** The resume control item */
55
	private IControlItem resumeItem;
43
	protected IControlItem resumeItem;
56
	
44
	
57
	/** The pause control item */
45
	/** The pause control item */
58
	private IControlItem pauseItem;
46
	protected IControlItem pauseItem;
47
	
48
	/** The handler for action items */
49
	private IHandler handler; 
59
	
50
	
60
	/**
51
	/**
61
	 * @see org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractLogicalItem.initializeControlItems()
52
	 * @see org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractLogicalItem.initializeControlItems()
Lines 90-126 Link Here
90
    	if (attachItem != null)
81
    	if (attachItem != null)
91
    		return attachItem;
82
    		return attachItem;
92
    	
83
    	
93
    	class AttachControlItem extends AgentControlItem
84
    	attachItem = new AttachControlItem(getAgentStateModifier());
94
    	{		
85
    	handler = new AttachControlItemHandler(attachItem);
95
    		public AttachControlItem()
86
    	attachItem.setHandler(handler);
96
    		{
97
    			super(getAgentStateModifier(), ATTACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_ATTACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
98
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_ATTACH_AGENT));
99
    		}
100
    		
101
			public void run()
102
			{
103
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
104
											
105
				try
106
				{
107
					/* attach to the agent */					
108
					agentStateModifier.attach();
109
				} catch (CoreException e)
110
				{
111
					/* Display status */
112
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
113
				}				
114
			}
115
			
116
			public boolean isEnabled()
117
			{
118
				return getAgentStateModifier().canAttach();
119
			}		
120
    	}
121
    	
122
    	
123
    	attachItem = new AttachControlItem();
124
    	return attachItem;
87
    	return attachItem;
125
    }
88
    }
126
    
89
    
Lines 129-165 Link Here
129
    	if (detachItem != null)
92
    	if (detachItem != null)
130
    		return detachItem;
93
    		return detachItem;
131
    	
94
    	
132
    	class DetachControlItem extends AgentControlItem
95
    	detachItem = new DetachControlItem(getAgentStateModifier());
133
    	{		
96
    	handler = new DetachControlItemHandler(detachItem);
134
    		public DetachControlItem()
97
    	detachItem.setHandler(handler);
135
    		{
136
    			super(getAgentStateModifier(), DETACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_DETACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
137
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DETACH_AGENT));
138
    		}
139
    		
140
			public void run()
141
			{
142
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
143
											
144
				try
145
				{
146
					/* detach the agent */					
147
					agentStateModifier.detach();
148
				} catch (CoreException e)
149
				{
150
					/* Display status */
151
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
152
				}				
153
			}
154
			
155
			public boolean isEnabled()
156
			{
157
				return getAgentStateModifier().canDetach();
158
			}		
159
    	}
160
    	
161
    	
162
    	detachItem = new DetachControlItem();
163
    	return detachItem;
98
    	return detachItem;
164
    }
99
    }
165
    
100
    
Lines 168-204 Link Here
168
    	if (resumeItem != null)
103
    	if (resumeItem != null)
169
    		return resumeItem;
104
    		return resumeItem;
170
    	
105
    	
171
    	class ResumeControlItem extends AgentControlItem
106
    	resumeItem = new ResumeControlItem(getAgentStateModifier());
172
    	{		
107
    	handler = AbstractAgentToolbarProvider.startMonitoring.getHandler();
173
    		public ResumeControlItem()
108
    	resumeItem.setHandler(handler);
174
    		{
175
    			super(getAgentStateModifier(), START_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_RESUME, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_RESUME));
176
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
177
    		}
178
    		
179
			public void run()
180
			{
181
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
182
											
183
				try
184
				{
185
					/* Resume the agent */
186
					agentStateModifier.startMonitoring();
187
				} catch (CoreException e)
188
				{
189
					/* Display status */
190
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
191
				}				
192
			}
193
			
194
			public boolean isEnabled()
195
			{
196
				return getAgentStateModifier().canResume();
197
			}		
198
    	}
199
    	
200
    	
201
    	resumeItem = new ResumeControlItem();
202
    	return resumeItem;
109
    	return resumeItem;
203
    }
110
    }
204
    
111
    
Lines 207-248 Link Here
207
    	if (pauseItem != null)
114
    	if (pauseItem != null)
208
    		return pauseItem;
115
    		return pauseItem;
209
    	
116
    	
210
    	class PauseControlItem extends AgentControlItem
117
    	pauseItem = new PauseControlItem(getAgentStateModifier());
211
    	{		
118
    	handler = AbstractAgentToolbarProvider.pauseMonitoring.getHandler();
212
    		public PauseControlItem()
119
    	pauseItem.setHandler(handler);
213
    		{
214
    			super(getAgentStateModifier(), PAUSE_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_PAUSE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_PAUSE));
215
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
216
    		}
217
    		
218
			public void run()
219
			{
220
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
221
											
222
				try
223
				{
224
					/* Pause the agent */					
225
					agentStateModifier.pauseMonitoring();
226
				} catch (CoreException e)
227
				{
228
					/* Display status */
229
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
230
				}				
231
			}
232
			
233
			public boolean isEnabled()
234
			{
235
				return getAgentStateModifier().canPause();
236
			}		
237
    	}
238
    	
239
    	
240
    	pauseItem = new PauseControlItem();
241
    	return pauseItem;
120
    	return pauseItem;
242
    }
121
    }
243
    
122
    
244
    
123
    protected static class AgentControlItem extends ControlItem
245
    private static class AgentControlItem extends ControlItem
246
    {
124
    {
247
		private IAgentStateModifier stateModifier;
125
		private IAgentStateModifier stateModifier;
248
    	
126
    	
Lines 272-276 Link Here
272
		}
150
		}
273
			
151
			
274
	}
152
	}
275
   
276
}
153
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ControlItem.java (-2 / +17 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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.tptp.trace.ui.provisional.control.provider;
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
13
14
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.jface.viewers.StructuredSelection;
Lines 27-44 Link Here
27
	
28
	
28
	private String groupName, text;	
29
	private String groupName, text;	
29
	protected StructuredSelection input;
30
	protected StructuredSelection input;
31
	protected IHandler handler;
30
	
32
	
31
	public ControlItem()
33
	public ControlItem()
32
	{
34
	{
33
		
35
		
34
	}
36
	}
35
		
37
	
38
	public IHandler getHandler() {
39
		return handler;
40
	}
41
	
42
	public void setHandler(IHandler actionHandler){
43
		handler = actionHandler;
44
	}
45
	
46
	public String getCommandID() {
47
		return super.getActionDefinitionId();
48
	}
49
	
36
	public ControlItem(String itemId, String groupName, String text, ImageDescriptor imageDescriptor)
50
	public ControlItem(String itemId, String groupName, String text, ImageDescriptor imageDescriptor)
37
	{
51
	{
38
		this.groupName = groupName;
52
		this.groupName = groupName;
39
		this.text = text;
53
		this.text = text;
40
		super.setImageDescriptor(imageDescriptor);
54
		super.setImageDescriptor(imageDescriptor);
41
		super.setId(itemId);
55
		super.setId(itemId);
56
		super.setActionDefinitionId(itemId); 
42
	}
57
	}
43
	
58
	
44
	
59
	
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/IControlItem.java (-1 / +28 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006 2008 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.tptp.trace.ui.provisional.control.provider;
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
13
14
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.viewers.StructuredSelection;
16
import org.eclipse.jface.viewers.StructuredSelection;
16
17
Lines 47-50 Link Here
47
	 * @param input The input of this control item.
48
	 * @param input The input of this control item.
48
	 */
49
	 */
49
	public void setInput (StructuredSelection input);
50
	public void setInput (StructuredSelection input);
51
52
	/**
53
	 * Sets the handler for this control item.  The handler should be of the 
54
	 * corresponding type as the action that is declared. (ex. PauseControlItem 
55
	 * has PauseControlItemHandler)
56
	 *  
57
	 * @param Handler for the IControlItem action.
58
	 */
59
	public void setHandler(IHandler actionHandler);
60
	
61
	/**
62
	 * Returns the handler for this control item.  The handler should be declared 
63
	 * ahead of time, or a <code>null</code> will be returned. 
64
	 *  
65
	 * @return Handler for the IControlItem action.
66
	 */
67
	public IHandler getHandler();
68
	
69
	/**
70
	 * Returns the Action Definition ID (aka Command ID) for this control item. The 
71
	 * default action definition id is null unless set previously using 
72
	 * "setActionDefinitionID(String id)."
73
	 *   
74
	 * @return actionDefinitionID of type String
75
	 */
76
	public String getCommandID(); 
50
}
77
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResourceItemControlProvider.java (-60 / +14 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-33 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
import java.util.Iterator;
13
import org.eclipse.core.commands.IHandler;
14
15
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
14
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
16
import org.eclipse.hyades.trace.ui.ProfileEvent;
17
import org.eclipse.hyades.trace.ui.UIPlugin;
15
import org.eclipse.hyades.trace.ui.UIPlugin;
18
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
16
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
19
import org.eclipse.hyades.trace.ui.internal.actions.OpenWizardAction;
17
import org.eclipse.hyades.trace.ui.internal.actions.OpenWizardAction;
20
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
18
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
21
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
22
import org.eclipse.hyades.trace.ui.internal.util.TraceMessages;
19
import org.eclipse.hyades.trace.ui.internal.util.TraceMessages;
23
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProcessWizard;
20
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProcessWizard;
24
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProfAgentWizard;
21
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProfAgentWizard;
25
import org.eclipse.hyades.ui.extension.INavigatorContribution;
22
import org.eclipse.hyades.ui.extension.INavigatorContribution;
26
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
27
import org.eclipse.tptp.trace.ui.internal.control.provider.ControlProviderManager;
23
import org.eclipse.tptp.trace.ui.internal.control.provider.ControlProviderManager;
28
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
24
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
29
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
30
31
25
32
26
33
/**
27
/**
Lines 43-52 Link Here
43
 */
37
 */
44
public class ResourceItemControlProvider extends LogicalItemControlProvider 
38
public class ResourceItemControlProvider extends LogicalItemControlProvider 
45
{
39
{
46
	/** The id of the contributed items */
47
	private static final String REFRESH_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.popupMenu.refreshViews";
48
	private static final String REFRESH_OPTION = "org.eclipse.hyades.trace.ui.internal.monitorsview.popupMenu.refreshOption";
49
	
50
	/** The delete item */
40
	/** The delete item */
51
	private IControlItem delete;
41
	private IControlItem delete;
52
	
42
	
Lines 54-69 Link Here
54
	private IControlItem save;
44
	private IControlItem save;
55
	
45
	
56
	/** The refresh view item */
46
	/** The refresh view item */
57
	private IControlItem refresh;
47
	protected static IControlItem refresh;
58
	
48
	
59
	/** The refresh option item */
49
	/** The refresh option item */
60
	private IControlItem refreshOption;
50
	protected static IControlItem refreshOption;
61
51
62
	/** The properties item */
52
	/** The properties item */
63
	private IControlItem properties;
53
	private IControlItem properties;
64
54
65
	/** The entity that this provider is affiliated to */
55
	/** The entity that this provider is affiliated to */
66
	private String entity;
56
	private String entity;
57
58
	private IHandler handler;
67
	
59
	
68
	public void initialize (String entity)
60
	public void initialize (String entity)
69
	{
61
	{
Lines 88-95 Link Here
88
    {
80
    {
89
    	if (delete != null && !isContextDifferent)
81
    	if (delete != null && !isContextDifferent)
90
    		return delete;
82
    		return delete;
91
    	
83
92
    	    	
93
    	delete = new ControlItemAdapter(INavigatorContribution.GROUP_DELETE, new DeleteAction(TraceControlItemManager.getNavigator()));
84
    	delete = new ControlItemAdapter(INavigatorContribution.GROUP_DELETE, new DeleteAction(TraceControlItemManager.getNavigator()));
94
    	return delete;
85
    	return delete;
95
    }
86
    }
Lines 100-106 Link Here
100
    	if (save != null && !isContextDifferent)
91
    	if (save != null && !isContextDifferent)
101
    		return save;
92
    		return save;
102
    	
93
    	
103
    	    	
104
    	save = new ControlItemAdapter(INavigatorContribution.GROUP_SAVE, new SaveAction(TraceControlItemManager.getNavigator()));
94
    	save = new ControlItemAdapter(INavigatorContribution.GROUP_SAVE, new SaveAction(TraceControlItemManager.getNavigator()));
105
    	return save;
95
    	return save;
106
    }
96
    }
Lines 110-136 Link Here
110
    {
100
    {
111
    	if (refresh != null)
101
    	if (refresh != null)
112
    		return refresh;
102
    		return refresh;
113
    	
103
114
    	class RefreshView extends ControlItem
115
    	{    		
116
    		public RefreshView()
117
    		{
118
    			super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
119
    		}
120
    		
121
    		public void run()
122
    		{
123
    			if (input == null)
124
    				return;
125
    			
126
    			for (Iterator sources = input.iterator(); sources.hasNext();)
127
    			{					
128
    				ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
129
    				UIPlugin.getDefault().notifyProfileEventListener(event);
130
    			}
131
    		}
132
    	}
133
    	refresh = new RefreshView();
104
    	refresh = new RefreshView();
105
    	handler = new RefreshViewHandler(refresh);
106
    	refresh.setHandler(handler);
134
    	return refresh;
107
    	return refresh;
135
    }
108
    }
136
    
109
    
Lines 143-172 Link Here
143
    protected IControlItem createRefreshOptionControlItem()
116
    protected IControlItem createRefreshOptionControlItem()
144
    {
117
    {
145
    	if (refreshOption != null)
118
    	if (refreshOption != null)
146
    		return refreshOption;
119
    		return refreshOption;	
147
    	
120
148
    	class RefreshOption extends ControlItem
149
    	{    		
150
    		public RefreshOption()
151
    		{
152
    			super (REFRESH_OPTION, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_OPTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_OPTIONS));
153
    		}
154
    		
155
    		/* This method is invoked when ever user clicks the 'Change Refresh Options' button.
156
    		 * It simply invokes the 'handleProfileEvent' method of PDProjectExplorer */
157
    		public void run()
158
    		{
159
    			if (input == null)
160
    				return;
161
    			
162
    			for (Iterator sources = input.iterator(); sources.hasNext();)
163
    			{					
164
    				ProfileEvent event = UIPlugin.getDefault().getRefreshOptionEvent(sources.next());
165
    				UIPlugin.getDefault().notifyProfileEventListener(event);
166
    			}
167
    		}
168
    	}
169
    	refreshOption = new RefreshOption();
121
    	refreshOption = new RefreshOption();
122
    	handler = new RefreshOptionHandler(refreshOption);
123
    	refreshOption.setHandler(handler);
170
    	return refreshOption;
124
    	return refreshOption;
171
    }
125
    }
172
    
126
    
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractProcessControlProvider.java (-64 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-23 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
13
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
18
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
19
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
21
14
22
/**
15
/**
23
 * Provides an abstract control provider for a process.  Subclasses are
16
 * Provides an abstract control provider for a process.  Subclasses are
Lines 28-38 Link Here
28
 */
21
 */
29
public abstract class AbstractProcessControlProvider extends ResourceItemControlProvider 
22
public abstract class AbstractProcessControlProvider extends ResourceItemControlProvider 
30
{
23
{
31
	/** The id of the contributed items */
32
	private static final String TERMINATE_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.TerminateAction";
33
	
34
	/** The terminate item */
24
	/** The terminate item */
35
	private IControlItem terminateItem;
25
	protected static IControlItem terminateItem;
26
	
27
	private IHandler handler; 
36
	
28
	
37
	/**
29
	/**
38
	 * Subclasses are expected to provide a process state modifier that 
30
	 * Subclasses are expected to provide a process state modifier that 
Lines 61-123 Link Here
61
     * Overwrite this method to modify the terminate control
53
     * Overwrite this method to modify the terminate control
62
     * item.
54
     * item.
63
     * 
55
     * 
64
     * @return Ther terminate control item
56
     * @return The terminate control item
65
     */
57
     */
66
	protected IControlItem createTerminateControlItem()
58
	protected IControlItem createTerminateControlItem()
67
	{
59
	{
68
		if (terminateItem != null)
60
		if (terminateItem != null)
69
			return terminateItem;
61
			return terminateItem;
70
			
71
		class TerminateAction extends ControlItem
72
		{
73
			public TerminateAction()
74
			{
75
				super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
76
				setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
77
			}
78
			
79
			public void run()
80
			{
81
				IProcessStateModifier processStateModifier = getProcessStateModifier();
82
											
83
				try
84
				{
85
					/* Terminate the process */
86
					processStateModifier.terminate();
87
				} catch (CoreException e)
88
				{
89
					/* Display status */
90
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
91
				}				
92
			}
93
			
94
			public boolean isEnabled()
95
			{
96
				return getProcessStateModifier().canTerminate();
97
			}
98
			
99
			public void setInput(StructuredSelection input)
100
			{
101
				getProcessStateModifier().setInput(input);
102
			}
103
			
104
			public IProcessStateModifier getStateModifier()
105
			{
106
				return getProcessStateModifier();
107
			}
108
			
109
			public boolean equals (Object o)
110
			{
111
				if (!(o instanceof TerminateAction))
112
					return false;
113
				
114
				return getProcessStateModifier() == ((TerminateAction)o).getStateModifier() && super.equals(o);
115
			}
116
117
		}
118
			
119
				
62
				
120
		terminateItem = new TerminateAction();
63
		terminateItem = new TerminateAction(getProcessStateModifier());
64
		handler = new TerminateControlItemHandler(terminateItem);
65
		terminateItem.setHandler(handler); 
121
		return terminateItem;
66
		return terminateItem;
122
	}
67
	}
123
}
68
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractAgentToolbarProvider.java (-8 / +19 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-15 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
import org.eclipse.core.commands.IHandler;
13
import org.eclipse.hyades.trace.ui.UIPlugin;
14
import org.eclipse.hyades.trace.ui.UIPlugin;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.jface.resource.ImageDescriptor;
Lines 24-40 Link Here
24
public abstract class AbstractAgentToolbarProvider extends AbstractAgentControlProvider
25
public abstract class AbstractAgentToolbarProvider extends AbstractAgentControlProvider
25
{   
26
{   
26
	/** The id of the contributed items */
27
	/** The id of the contributed items */
27
	public static final String START_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.startMonitoring";
28
	public static final String START_TOOLBAR_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem";
28
	public static final String PAUSE_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.stopMonitoring";
29
	public static final String PAUSE_TOOLBAR_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem";
29
	public static final String TERMINATE_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.terminate";
30
	public static final String TERMINATE_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.terminate";
30
	public static final String REFRESH_VIEW_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.refreshViews";
31
	public static final String REFRESH_VIEW_TOOLBAR_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.refreshViews";
31
	public static final String REFRESH_OPTIONS = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.refreshOptions";
32
	public static final String REFRESH_OPTIONS = "org.eclipse.hyades.trace.ui.internal.monitorsview.toolbar.refreshOptions";
32
	
33
	
33
	/** The start monitoring toolbar item */
34
	/** The start monitoring toolbar item */
34
	private IControlItem startMonitoring;
35
	protected static IControlItem startMonitoring;
35
	
36
	
36
	/** The pause monitoring toolbar item */
37
	/** The pause monitoring toolbar item */
37
	private IControlItem pauseMonitoring;
38
	protected static IControlItem pauseMonitoring;
38
	
39
	
39
	/** The terminate toolbar item */
40
	/** The terminate toolbar item */
40
	private IControlItem terminate;
41
	private IControlItem terminate;
Lines 45-50 Link Here
45
	/** The automatic refresh control item. Used */
46
	/** The automatic refresh control item. Used */
46
	private IControlItem automaticRefresh;
47
	private IControlItem automaticRefresh;
47
	
48
	
49
	/** hander for the action items */
50
	private IHandler handler;
51
	
48
    /**
52
    /**
49
     * @see AbstractControlProvider#initializeControlItems()
53
     * @see AbstractControlProvider#initializeControlItems()
50
     */
54
     */
Lines 69-75 Link Here
69
		if (startMonitoring != null)
73
		if (startMonitoring != null)
70
			return startMonitoring;
74
			return startMonitoring;
71
		
75
		
72
		startMonitoring = makeToolbarReady(super.createStartMonitoringControlItem(), START_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
76
		startMonitoring = makeToolbarReady(new ResumeControlItem(getAgentStateModifier()), START_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
77
		handler = new ResumeControlItemHandler(startMonitoring);
78
		startMonitoring.setHandler(handler);
73
		return startMonitoring;
79
		return startMonitoring;
74
    }
80
    }
75
	
81
	
Lines 84-91 Link Here
84
    {
90
    {
85
		if (pauseMonitoring != null)
91
		if (pauseMonitoring != null)
86
			return pauseMonitoring;
92
			return pauseMonitoring;
87
		pauseMonitoring = makeToolbarReady(super.createPauseMonitoringControlItem(), PAUSE_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
93
		pauseMonitoring = makeToolbarReady(new PauseControlItem(getAgentStateModifier()), PAUSE_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
88
		
94
		handler = new PauseControlItemHandler(pauseMonitoring);
95
		pauseMonitoring.setHandler(handler);
89
		return pauseMonitoring;
96
		return pauseMonitoring;
90
    }
97
    }
91
	
98
	
Lines 102-107 Link Here
102
			return terminate;
109
			return terminate;
103
		
110
		
104
		terminate = makeToolbarReady(super.createTerminateControlItem(), TERMINATE_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
111
		terminate = makeToolbarReady(super.createTerminateControlItem(), TERMINATE_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
112
		handler = terminateItem.getHandler();
113
		terminate.setHandler(handler);
105
		return terminate;
114
		return terminate;
106
    }
115
    }
107
	
116
	
Lines 118-123 Link Here
118
			return refreshView;
127
			return refreshView;
119
		
128
		
120
		refreshView = makeToolbarReady(super.createRefreshViewsControlItem(), REFRESH_VIEW_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_REFRESH_VIEWS));
129
		refreshView = makeToolbarReady(super.createRefreshViewsControlItem(), REFRESH_VIEW_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_REFRESH_VIEWS));
130
		handler = refresh.getHandler();
131
		refreshView.setHandler(handler);
121
		return refreshView;
132
		return refreshView;
122
    }
133
    }
123
	
134
	
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 53-58 Link Here
53
 org.eclipse.tptp.platform.common;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
53
 org.eclipse.tptp.platform.common;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
54
 org.eclipse.tptp.platform.common.ui;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
54
 org.eclipse.tptp.platform.common.ui;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
55
 org.eclipse.tptp.platform.common.ui.trace;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
55
 org.eclipse.tptp.platform.common.ui.trace;bundle-version="[4.3.0,5.0.0)";visibility:=reexport,
56
 org.eclipse.tptp.platform.execution;bundle-version="[4.3.0,5.0.0)"
56
 org.eclipse.tptp.platform.execution;bundle-version="[4.3.0,5.0.0)",
57
 org.eclipse.core.expressions;bundle-version="3.4.0"
57
Eclipse-LazyStart: true
58
Eclipse-LazyStart: true
58
Bundle-RequiredExecutionEnvironment: J2SE-1.4
59
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/PIAgentToolbarProvider.java (-4 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-19 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
11
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
12
12
13
import org.eclipse.core.commands.IHandler;
13
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
14
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
15
import org.eclipse.tptp.trace.ui.internal.control.provider.application.PIAgentControlProvider.GCControlItem;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.PIAgentControlProvider.HeapDumpControlItem;
17
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
16
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
17
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
Lines 36-42 Link Here
36
	private IControlItem dumpHeapControlItem;
35
	private IControlItem dumpHeapControlItem;
37
	
36
	
38
	/** The garbage collection control item */
37
	/** The garbage collection control item */
39
	private IControlItem garbageCollectionControlItem;
38
	protected static IControlItem garbageCollectionControlItem;
39
	
40
	private IHandler handler;
40
	
41
	
41
	
42
	
42
	public PIAgentToolbarProvider()
43
	public PIAgentToolbarProvider()
Lines 63-68 Link Here
63
			return garbageCollectionControlItem;
64
			return garbageCollectionControlItem;
64
		
65
		
65
		garbageCollectionControlItem = makeToolbarReady(new GCControlItem(), GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
66
		garbageCollectionControlItem = makeToolbarReady(new GCControlItem(), GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
67
		handler = new GCControlItemHandler(garbageCollectionControlItem);
68
		garbageCollectionControlItem.setHandler(handler);
66
		return garbageCollectionControlItem;
69
		return garbageCollectionControlItem;
67
	}
70
	}
68
	
71
	
Lines 72-77 Link Here
72
			return dumpHeapControlItem;
75
			return dumpHeapControlItem;
73
		
76
		
74
		dumpHeapControlItem = makeToolbarReady(new HeapDumpControlItem(), HEAP_DUMP_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
77
		dumpHeapControlItem = makeToolbarReady(new HeapDumpControlItem(), HEAP_DUMP_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
78
		handler = PIAgentControlProvider._dumpHeapControlItem.getHandler(); 
79
		dumpHeapControlItem.setHandler(handler);
75
		return dumpHeapControlItem;
80
		return dumpHeapControlItem;
76
	}
81
	}
77
82
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/PIAgentControlProvider.java (-91 / +18 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-23 Link Here
13
13
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.core.commands.IHandler;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.hyades.trace.ui.internal.actions.CollectObjRefAction;
18
import org.eclipse.hyades.trace.ui.internal.actions.NewSnapshotAction;
18
import org.eclipse.hyades.trace.ui.internal.actions.NewSnapshotAction;
19
import org.eclipse.hyades.trace.ui.internal.actions.RunGCAction;
20
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
21
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
22
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
23
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider;
Lines 35-54 Link Here
35
{	
33
{	
36
	/** The id of the contributed items */
34
	/** The id of the contributed items */
37
	private static final String RESET_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.NewSnapshot";
35
	private static final String RESET_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.NewSnapshot";
38
	private static final String HEAP_DUMP_ITEM = "org.eclipse.hyades.trace.ui.monitorsview.popupMenu.ObjRef";
39
	private static final String GC_ITEM = "org.eclipse.hyades.trace.ui.monitorsview.popupMenu.GC";
40
	
36
	
41
	/** The agent state modifier */
37
	/** The agent state modifier */
42
	private IAgentStateModifier agentStateModifier;
38
	private IAgentStateModifier agentStateModifier;
43
	
39
	
44
	/** The collect object reference control item */
40
	/** The collect object reference control item */
45
	private IControlItem dumpHeapControlItem;
41
	protected static IControlItem _dumpHeapControlItem;
46
	
42
	
47
	/** The garbage collection control item */
43
	/** The garbage collection control item */
48
	private IControlItem garbageCollectionControlItem;
44
	protected static IControlItem _garbageCollectionControlItem;
49
	
45
	
50
	/** The restart control item */
46
	/** The restart control item */
51
	private IControlItem restartControlItem;
47
	private IControlItem restartControlItem;
48
	
49
	private IHandler handler;
52
50
53
	
51
	
54
	public PIAgentControlProvider()
52
	public PIAgentControlProvider()
Lines 78-88 Link Here
78
	 */
76
	 */
79
	protected IControlItem createHeapDumpControlItem()
77
	protected IControlItem createHeapDumpControlItem()
80
	{
78
	{
81
		if (dumpHeapControlItem != null)
79
		if (_dumpHeapControlItem != null)
82
			return dumpHeapControlItem;
80
			return _dumpHeapControlItem;
83
		
81
		
84
		dumpHeapControlItem = new HeapDumpControlItem();		
82
		_dumpHeapControlItem = new HeapDumpControlItem();		
85
		return dumpHeapControlItem;
83
		handler = new HeapDumpControlItemHandler(_dumpHeapControlItem);
84
		_dumpHeapControlItem.setHandler(handler); 
85
		return _dumpHeapControlItem;
86
	}
86
	}
87
87
88
	
88
	
Lines 93-103 Link Here
93
	 */
93
	 */
94
	protected IControlItem createGCControlItem()
94
	protected IControlItem createGCControlItem()
95
	{
95
	{
96
		if (garbageCollectionControlItem != null)
96
		if (_garbageCollectionControlItem != null)
97
			return garbageCollectionControlItem;
97
			return _garbageCollectionControlItem;
98
		
98
		
99
		garbageCollectionControlItem = new GCControlItem();		
99
		_garbageCollectionControlItem = new GCControlItem();		
100
		return garbageCollectionControlItem;
100
		handler = PIAgentToolbarProvider.garbageCollectionControlItem.getHandler();
101
		_garbageCollectionControlItem.setHandler(handler); 
102
		return _garbageCollectionControlItem;
101
	}
103
	}
102
	
104
	
103
	
105
	
Lines 148-226 Link Here
148
		return restartControlItem;
150
		return restartControlItem;
149
	}
151
	}
150
	
152
	
151
	
152
	public static class HeapDumpControlItem extends ControlItem
153
	{
154
		CollectObjRefAction collectObjRef;
155
		public HeapDumpControlItem()
156
		{
157
			super(HEAP_DUMP_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_DUMP, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DUMP));
158
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
159
			collectObjRef = new CollectObjRefAction();
160
		}
161
		
162
		public void run()
163
		{
164
			try
165
			{
166
				for (Iterator agents = input.iterator(); agents.hasNext();)
167
					collectObjRef.doAction(agents.next());
168
			}
169
			catch (Exception e)
170
			{
171
				LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
172
			}
173
		}
174
		
175
		
176
		public boolean isEnabled()
177
		{
178
			if (input == null || input.size() == 0)
179
				return false;
180
			
181
			boolean isEnable = true;
182
			for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
183
				isEnable = isEnable && collectObjRef.isEnabledFor(agents.next());
184
			return isEnable;
185
		}
186
			
187
	}
188
	
189
	
190
	public static class GCControlItem extends ControlItem
191
	{
192
		private RunGCAction gcAction;
193
		public GCControlItem()
194
		{
195
			super(GC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_GC_ACTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_GC));
196
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
197
			gcAction = new RunGCAction();
198
		}
199
		
200
		public void run()
201
		{
202
			try
203
			{
204
				for (Iterator agents = input.iterator(); agents.hasNext();)
205
					gcAction.doAction(agents.next());
206
			}
207
			catch (Exception e)
208
			{
209
				LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
210
			}
211
		}
212
		
213
		
214
		public boolean isEnabled()
215
		{
216
			if (input == null || input.size() == 0)
217
				return false;
218
			
219
			boolean isEnable = true;
220
			for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
221
				isEnable = isEnable && gcAction.isEnabledFor(agents.next());
222
			return isEnable;
223
		}
224
			
225
	}
226
}
153
}
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/messages.properties (-7 / +7 lines)
Lines 14-28 Link Here
14
# NLS_ENCODING=UTF-8
14
# NLS_ENCODING=UTF-8
15
15
16
CONTROL_ITEM_TERMINATE				= Terminate
16
CONTROL_ITEM_TERMINATE				= Terminate
17
CONTROL_ITEM_REFRESH_VIEWS			= Refresh &Views
17
CONTROL_ITEM_REFRESH_VIEWS			= Refresh Views
18
CONTROL_ITEM_REFRESH_OPTION			= Change Refresh &Options
18
CONTROL_ITEM_REFRESH_OPTION			= Change Refresh Options
19
CONTROL_ITEM_ATTACH					= A&ttach to Agent
19
CONTROL_ITEM_ATTACH					= Attach to Agent
20
CONTROL_ITEM_DETACH					= Detach &from Agent
20
CONTROL_ITEM_DETACH					= Detach from Agent
21
CONTROL_ITEM_RESUME					= Start Monitoring
21
CONTROL_ITEM_RESUME					= Start Monitoring
22
CONTROL_ITEM_PAUSE					= Pause Monitoring 
22
CONTROL_ITEM_PAUSE					= Pause Monitoring 
23
CONTROL_ITEM_DUMP					= &Collect Object References
23
CONTROL_ITEM_DUMP					= Collect Object References
24
CONTROL_ITEM_GC_ACTION				= &Run Garbage Collection
24
CONTROL_ITEM_GC_ACTION				= Run Garbage Collection
25
CONTROL_ITEM_NEW_SNAPSHOT			= Reset &Data
25
CONTROL_ITEM_NEW_SNAPSHOT			= Reset Data
26
26
27
ERROR_PROCESS_TERMINATE				= An error occurred while attempting to terminate process: {0}
27
ERROR_PROCESS_TERMINATE				= An error occurred while attempting to terminate process: {0}
28
28
(-)plugin.xml (-1 / +135 lines)
Lines 1035-1040 Link Here
1035
			
1035
			
1036
			<entity type = "toolbar"
1036
			<entity type = "toolbar"
1037
			class = "org.eclipse.tptp.trace.ui.internal.control.provider.application.AgentDiscovererToolbarProvider"/>
1037
			class = "org.eclipse.tptp.trace.ui.internal.control.provider.application.AgentDiscovererToolbarProvider"/>
1038
		</control>
1038
		</control>  
1039
	</extension>
1039
	</extension>
1040
 <extension
1041
       point="org.eclipse.ui.contexts">
1042
    <context
1043
          id="org.eclipse.ui.TPTPMonitorContext"
1044
          name="%_ProfileContext">
1045
    </context>
1046
 </extension>
1047
	
1048
	<extension
1049
         point="org.eclipse.ui.commands">
1050
      <category
1051
            description="%_D1"
1052
            id="org.eclipse.hyades.trace.ui.ProfileActions"
1053
            name="%TRC_ITEMS">
1054
      </category>
1055
            <command
1056
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1057
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItemHandler"
1058
                  description="%_PauseD"
1059
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem"
1060
                  name="%_PAUSE">
1061
      </command>
1062
            <command
1063
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1064
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItemHandler"
1065
                  description="%_ResumeD"
1066
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"
1067
                  name="%_RESUME">
1068
            </command>
1069
            <command
1070
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1071
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItemHandler"
1072
                  description="%_AttachD"
1073
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem"
1074
                  name="%_ATTACH">
1075
            </command>
1076
            <command
1077
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1078
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItemHandler"
1079
                  description="%_DetachD"
1080
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem"
1081
                  name="%_DETACH">
1082
            </command>
1083
            <command
1084
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1085
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateControlItemHandler"
1086
                  description="%_TerminateD"
1087
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction"
1088
                  name="%_TERMINATE">
1089
            </command>
1090
            <command
1091
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1092
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshOptionHandler"
1093
                  id="org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption"
1094
                  name="%_RefreshOpD">
1095
            </command>
1096
            <command
1097
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1098
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshViewHandler"
1099
                  description="%_RefreshD"
1100
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView"
1101
                  name="%_REFRESH">
1102
            </command>
1103
            <command
1104
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1105
                  defaultHandler="org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItemHandler"
1106
                  description="%_RunGC"
1107
                  id="org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem"
1108
                  name="%_RunGCD">
1109
            </command>
1110
            <command
1111
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1112
                  defaultHandler="org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItemHandler"
1113
                  description="%_HeapDD"
1114
                  id="org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItem"
1115
                  name="%_HeapD">
1116
            </command>
1117
      </extension>
1118
	<extension point="org.eclipse.ui.bindings">
1119
      <key
1120
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem"
1121
            contextId="org.eclipse.ui.TPTPMonitorContext"
1122
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1123
            sequence="M1+M3+P">
1124
      </key>
1125
      <key
1126
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"
1127
            contextId="org.eclipse.ui.TPTPMonitorContext"
1128
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1129
            sequence="M1+M3+S">
1130
      </key>
1131
      <key
1132
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem"
1133
            contextId="org.eclipse.ui.TPTPMonitorContext"
1134
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1135
            sequence="M1+M3+A">
1136
      </key>
1137
      <key
1138
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem"
1139
            contextId="org.eclipse.ui.TPTPMonitorContext"
1140
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1141
            sequence="M1+M3+D">
1142
      </key>
1143
      <key
1144
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction"
1145
            contextId="org.eclipse.ui.TPTPMonitorContext"
1146
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1147
            sequence="M1+M3+T">
1148
      </key>
1149
      <key
1150
            commandId="org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption"
1151
            contextId="org.eclipse.ui.TPTPMonitorContext"
1152
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1153
            sequence="M1+M3+O">
1154
      </key>
1155
      <key
1156
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView"
1157
            contextId="org.eclipse.ui.TPTPMonitorContext"
1158
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1159
            sequence="M1+M3+R">
1160
      </key>
1161
      <key
1162
            commandId="org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem"
1163
            contextId="org.eclipse.ui.TPTPMonitorContext"
1164
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1165
            sequence="M1+M3+M2+G">
1166
      </key>
1167
      <key
1168
            commandId="org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItem"
1169
            contextId="org.eclipse.ui.TPTPMonitorContext"
1170
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1171
            sequence="M1+M3+H">
1172
      </key>
1173
    </extension>
1040
</plugin>
1174
</plugin>
(-)plugin.properties (-1 / +21 lines)
Lines 120-123 Link Here
120
ANALYSIS_TYPE_METHOD_COVERAGE	= Analyze the application Method Coverage. See what methods were executed.
120
ANALYSIS_TYPE_METHOD_COVERAGE	= Analyze the application Method Coverage. See what methods were executed.
121
121
122
EDIT_PROF_OPT					= Edit Profiling Options
122
EDIT_PROF_OPT					= Edit Profiling Options
123
EDIT_AGENT_DIS_TITLE	= Edit Agent Discoverer Options
123
EDIT_AGENT_DIS_TITLE	= Edit Agent Discoverer Options
124
_ProfileContext = TPTP Profiling View Context
125
TRC_ITEMS = Trace Action Items
126
_PAUSE = Pause Monitoring
127
_RESUME = Start Monitoring
128
_ATTACH = Attach to Agent
129
_DETACH = Detach from Agent
130
_TERMINATE = Terminate Monitoring Process
131
_REFRESH = Refresh Views
132
_D1 = Action Items available in Profiling View 
133
_PauseD = Stop Monitoring without detaching from Agent
134
_ResumeD = Start Monitoring 
135
_AttachD = Attach running process to Agent
136
_DetachD = Detach process from Agent
137
_TerminateD = Terminate process
138
_RefreshOpD = Refresh Option
139
_RefreshD = Refresh available views
140
_RunGC = Run Garbage Collection
141
_RunGCD = Run Garbage Collection
142
_HeapDD = Perform heap dump
143
_HeapD = Heap Dump
(-)src/org/eclipse/hyades/trace/internal/ui/PDProjectExplorer.java (-1 / +14 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 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 76-81 Link Here
76
import org.eclipse.ui.IViewPart;
76
import org.eclipse.ui.IViewPart;
77
import org.eclipse.ui.IWorkbenchPart;
77
import org.eclipse.ui.IWorkbenchPart;
78
import org.eclipse.ui.actions.ActionContext;
78
import org.eclipse.ui.actions.ActionContext;
79
import org.eclipse.ui.contexts.IContextService;
79
import org.eclipse.ui.plugin.AbstractUIPlugin;
80
import org.eclipse.ui.plugin.AbstractUIPlugin;
80
81
81
public class PDProjectExplorer extends Navigator  implements IProfileEventListener
82
public class PDProjectExplorer extends Navigator  implements IProfileEventListener
Lines 250-255 Link Here
250
		super(ID);
251
		super(ID);
251
		
252
		
252
		traceControlItemManager = new TraceControlItemManager(this);
253
		traceControlItemManager = new TraceControlItemManager(this);
254
//		traceControlItemManager.setSite(getSite());
253
		
255
		
254
		/* set project explorer to resource helper such that it can be notified dirty for save */
256
		/* set project explorer to resource helper such that it can be notified dirty for save */
255
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
257
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
Lines 273-280 Link Here
273
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
275
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
274
		UIPlugin.getDefault().addProfileEventListener(this);
276
		UIPlugin.getDefault().addProfileEventListener(this);
275
		
277
		
278
		activateContext();
279
		
276
		(new RefreshUI()).start();
280
		(new RefreshUI()).start();
277
	}
281
	}
282
	
283
	/*
284
	 *  Defines the context of the profiling view as "org.eclipse.ui.TPTPMonitorContext". 
285
	 *  Is used for Keybinding. 
286
	 */
287
	private void activateContext() {
288
		IContextService contextService = (IContextService) getSite().getService(IContextService.class);
289
		contextService.activateContext("org.eclipse.ui.TPTPMonitorContext");
290
	}
278
291
279
	/**
292
	/**
280
	 * Updates the action bar actions.
293
	 * Updates the action bar actions.
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/TraceControlItemManager.java (-3 / +18 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 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-32 Link Here
17
import org.eclipse.emf.common.util.EList;
17
import org.eclipse.emf.common.util.EList;
18
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
18
import org.eclipse.hyades.models.hierarchy.TRCAgentProxy;
19
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
19
import org.eclipse.hyades.models.hierarchy.TRCProcessProxy;
20
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
20
import org.eclipse.hyades.trace.internal.ui.PDProjectViewer;
21
import org.eclipse.hyades.trace.internal.ui.PDProjectViewer;
21
import org.eclipse.hyades.trace.ui.internal.navigator.ProfileDetailItem;
22
import org.eclipse.hyades.trace.ui.internal.navigator.ProfileDetailItem;
22
import org.eclipse.hyades.ui.extension.INavigatorItem;
23
import org.eclipse.hyades.ui.extension.INavigatorItem;
23
import org.eclipse.hyades.ui.internal.navigator.INavigator;
24
import org.eclipse.hyades.ui.internal.navigator.INavigator;
25
import org.eclipse.jface.commands.ActionHandler;
24
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.swt.widgets.Tree;
27
import org.eclipse.swt.widgets.Tree;
26
import org.eclipse.swt.widgets.TreeItem;
28
import org.eclipse.swt.widgets.TreeItem;
27
import org.eclipse.tptp.trace.ui.internal.launcher.core.AgentDeclarationManager;
29
import org.eclipse.tptp.trace.ui.internal.launcher.core.AgentDeclarationManager;
28
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
30
import org.eclipse.tptp.trace.ui.internal.launcher.core.AnalysisType;
31
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
29
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
32
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
33
import org.eclipse.ui.handlers.IHandlerService;
30
34
31
35
32
/**
36
/**
Lines 47-56 Link Here
47
	/** The tree of the profiling monitor view */
51
	/** The tree of the profiling monitor view */
48
	private Tree profilingMonitorTree;
52
	private Tree profilingMonitorTree;
49
	
53
	
54
	
50
	public TraceControlItemManager (INavigator navigator)
55
	public TraceControlItemManager (INavigator navigator)
51
	{
56
	{
52
		TraceControlItemManager.navigator = navigator;		
57
		TraceControlItemManager.navigator = navigator;		
53
	}
58
	}
59
	
54
60
55
	private IControlItem[] getContributedItems(byte containerType)
61
	private IControlItem[] getContributedItems(byte containerType)
56
	{
62
	{
Lines 86-93 Link Here
86
		if (orderedList != null)
92
		if (orderedList != null)
87
		{
93
		{
88
			controlItems = new IControlItem[orderedList.size()];
94
			controlItems = new IControlItem[orderedList.size()];
89
			for (int i = 0; i < controlItems.length; i++)
95
			for (int i = 0; i < controlItems.length; i++) {
90
				controlItems[i] = (IControlItem)controlSubset.get(orderedList.get(i));			
96
				controlItems[i] = (IControlItem)controlSubset.get(orderedList.get(i));
97
				
98
				/* Activates the handlers for all the action items */
99
				if (controlItems[i] instanceof ControlItem &&
100
						((ControlItem)controlItems[i]).getCommandID()!=null &&
101
						((ControlItem)controlItems[i]).getHandler()!=null ) {
102
					IHandlerService handlerService = (IHandlerService) (((PDProjectExplorer)navigator).getSite().getService(IHandlerService.class));
103
					handlerService.activateHandler(((ControlItem)controlItems[i]).getCommandID(),((ControlItem)controlItems[i]).getHandler());
104
				}
105
			}
91
		}
106
		}
92
		
107
		
93
		return controlItems;
108
		return controlItems;
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/HeapDumpControlItem.java (+59 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
12
13
import java.util.Iterator;
14
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.hyades.trace.ui.internal.actions.CollectObjRefAction;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
21
22
public class HeapDumpControlItem extends ControlItem
23
{
24
	CollectObjRefAction collectObjRef;
25
	private static final String HEAP_DUMP_ITEM = "org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItem";
26
	
27
	public HeapDumpControlItem()
28
	{
29
		super(HEAP_DUMP_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_DUMP, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DUMP));
30
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
31
		collectObjRef = new CollectObjRefAction();
32
	}
33
	
34
	public void run()
35
	{
36
		try
37
		{
38
			for (Iterator agents = input.iterator(); agents.hasNext();)
39
				collectObjRef.doAction(agents.next());
40
		}
41
		catch (Exception e)
42
		{
43
			LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
44
		}
45
	}
46
	
47
	
48
	public boolean isEnabled()
49
	{
50
		if (input == null || input.size() == 0)
51
			return false;
52
		
53
		boolean isEnable = true;
54
		for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
55
			isEnable = isEnable && collectObjRef.isEnabledFor(agents.next());
56
		return isEnable;
57
	}
58
		
59
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshViewHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class RefreshViewHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public RefreshViewHandler(IAction refreshView) {
27
		super();
28
		this.action = refreshView;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshOption.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import java.util.Iterator;
14
15
import org.eclipse.hyades.trace.ui.ProfileEvent;
16
import org.eclipse.hyades.trace.ui.UIPlugin;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
21
22
public class RefreshOption extends ControlItem {
23
24
	private static final String REFRESH_OPTION = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption";
25
	
26
	public RefreshOption()
27
	{
28
		super (REFRESH_OPTION, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_OPTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_OPTIONS));
29
	}
30
	
31
	/* This method is invoked when ever user clicks the 'Change Refresh Options' button.
32
	 * It simply invokes the 'handleProfileEvent' method of PDProjectExplorer */
33
	public void run()
34
	{
35
		if (input == null)
36
			return;
37
		
38
		for (Iterator sources = input.iterator(); sources.hasNext();)
39
		{					
40
			ProfileEvent event = UIPlugin.getDefault().getRefreshOptionEvent(sources.next());
41
			UIPlugin.getDefault().notifyProfileEventListener(event);
42
		}
43
	}
44
}
45
	
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/PauseControlItem.java (+54 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
16
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
17
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
18
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
20
21
public class PauseControlItem extends AgentControlItem {
22
	
23
	private static final String PAUSE_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem";
24
	private static IAgentStateModifier _agentStateModifier;
25
	
26
	public PauseControlItem(IAgentStateModifier agentStateModifier)
27
	{
28
		super(agentStateModifier, PAUSE_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_PAUSE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_PAUSE));
29
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
30
		_agentStateModifier = agentStateModifier; 
31
	}
32
	
33
	public void run()
34
	{
35
		IAgentStateModifier agentStateModifier = _agentStateModifier;
36
									
37
		try
38
		{
39
			/* Pause the agent */					
40
			if(isEnabled())
41
				agentStateModifier.pauseMonitoring();
42
		} catch (CoreException e)
43
		{
44
			/* Display status */
45
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
46
		}				
47
	}
48
	
49
	public boolean isEnabled()
50
	{
51
		return _agentStateModifier.canPause();
52
	}		
53
54
}
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/GCControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class GCControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public GCControlItemHandler(IAction gC) {
27
		super();
28
		this.action = gC;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/HeapDumpControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class HeapDumpControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public HeapDumpControlItemHandler(IAction heapDump) {
27
		super();
28
		this.action = heapDump;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AttachControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class AttachControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public AttachControlItemHandler(IAction attachAction) {
27
		super();
28
		this.action = attachAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AttachControlItem.java (+52 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class AttachControlItem extends AgentControlItem {
21
22
	private static final String ATTACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem";
23
	private IAgentStateModifier _agentStateModifier; 
24
	
25
	public AttachControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, ATTACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_ATTACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_ATTACH_AGENT));
29
		_agentStateModifier = agentStateModifier; 
30
	}
31
		
32
	public void run()
33
	{	
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
36
		try
37
		{
38
			/* attach to the agent */					
39
			if (isEnabled())
40
				agentStateModifier.attach();
41
		} catch (CoreException e)
42
		{
43
			/* Display status */
44
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
45
		}				
46
	}
47
		
48
	public boolean isEnabled()
49
	{
50
		return _agentStateModifier.canAttach();
51
	}			
52
}
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/GCControlItem.java (+58 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.internal.control.provider.application;
12
13
import java.util.Iterator;
14
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.hyades.trace.ui.internal.actions.RunGCAction;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
21
22
public class GCControlItem extends ControlItem {
23
24
		private RunGCAction gcAction;
25
		public static final String GC_ITEM = "org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem";
26
		
27
		public GCControlItem()
28
		{
29
			super(GC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_GC_ACTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_GC));
30
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
31
			gcAction = new RunGCAction();
32
		}
33
		
34
		public void run()
35
		{
36
			try
37
			{
38
				for (Iterator agents = input.iterator(); agents.hasNext();)
39
					gcAction.doAction(agents.next());
40
			}
41
			catch (Exception e)
42
			{
43
				LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
44
			}
45
		}
46
		
47
		
48
		public boolean isEnabled()
49
		{
50
			if (input == null || input.size() == 0)
51
				return false;
52
			
53
			boolean isEnable = true;
54
			for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
55
				isEnable = isEnable && gcAction.isEnabledFor(agents.next());
56
			return isEnable;
57
		}	
58
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/DetachControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class DetachControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public DetachControlItemHandler(IAction detachAction) {
27
		super();
28
		this.action = detachAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/TerminateAction.java (+71 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.jface.viewers.StructuredSelection;
16
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
17
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
18
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
19
20
public class TerminateAction extends ControlItem {
21
22
	private IProcessStateModifier _processStateModifier;
23
	private static final String TERMINATE_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction";
24
	
25
		public TerminateAction(IProcessStateModifier processStateModifier)
26
		{
27
			super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
28
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
29
			_processStateModifier = processStateModifier;
30
		}
31
		
32
		public void run()
33
		{
34
										
35
			try
36
			{
37
				/* Terminate the process */
38
				if(isEnabled())
39
					_processStateModifier.terminate();
40
			} catch (CoreException e)
41
			{
42
				/* Display status */
43
				LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
44
			}				
45
		}
46
		
47
		public boolean isEnabled()
48
		{
49
			return _processStateModifier.canTerminate();
50
		}
51
		
52
		public void setInput(StructuredSelection input)
53
		{
54
			_processStateModifier.setInput(input);
55
		}
56
		
57
		public IProcessStateModifier getStateModifier()
58
		{
59
			return _processStateModifier;
60
		}
61
		
62
		public boolean equals (Object o)
63
		{
64
			if (!(o instanceof TerminateAction))
65
				return false;
66
			
67
			return _processStateModifier == ((TerminateAction)o).getStateModifier() && super.equals(o);
68
		}
69
70
71
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshOptionHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class RefreshOptionHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public RefreshOptionHandler(IAction pauseAction) {
27
		super();
28
		this.action = pauseAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/TerminateControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class TerminateControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public TerminateControlItemHandler(IAction terminateAction) {
27
		super();
28
		this.action = terminateAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResumeControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class ResumeControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public ResumeControlItemHandler(IAction resumeAction) {
27
		super();
28
		this.action = resumeAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResumeControlItem.java (+53 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class ResumeControlItem extends AgentControlItem {
21
	
22
	private static String START_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"; 
23
	private IAgentStateModifier _agentStateModifier; 
24
25
	public ResumeControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, START_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_RESUME, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_RESUME));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
29
		_agentStateModifier = agentStateModifier;
30
	}
31
	
32
	public void run()
33
	{
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
									
36
		try
37
		{
38
			/* Resume the agent */
39
			if(isEnabled())
40
				agentStateModifier.startMonitoring();
41
		} catch (CoreException e)
42
		{
43
			/* Display status */
44
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
45
		}				
46
	}
47
	
48
	public boolean isEnabled()
49
	{
50
		return _agentStateModifier.canResume();
51
	}	
52
53
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshView.java (+41 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import java.util.Iterator;
14
15
import org.eclipse.hyades.trace.ui.ProfileEvent;
16
import org.eclipse.hyades.trace.ui.UIPlugin;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
20
21
public class RefreshView extends ControlItem {
22
 	
23
	private static final String REFRESH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView";
24
	
25
	public RefreshView()
26
	{
27
		super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
28
	}
29
		
30
	public void run()
31
	{
32
		if (input == null)
33
			return;
34
			
35
		for (Iterator sources = input.iterator(); sources.hasNext();)
36
		{					
37
			ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
38
			UIPlugin.getDefault().notifyProfileEventListener(event);
39
		}
40
	}
41
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/DetachControlItem.java (+54 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class DetachControlItem extends AgentControlItem {
21
22
	public static final String DETACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem";	
23
	private IAgentStateModifier _agentStateModifier; 
24
	
25
	public DetachControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, DETACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_DETACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DETACH_AGENT));
29
		_agentStateModifier = agentStateModifier; 
30
	}
31
		
32
	public void run()
33
	{	
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
		
36
		try
37
		{
38
			/* detach the agent */	
39
			if (isEnabled())
40
				agentStateModifier.detach();
41
		} catch (CoreException e)
42
		{
43
			/* Display status */
44
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
45
		}				
46
	}
47
		
48
	public boolean isEnabled()
49
	{
50
		return _agentStateModifier.canDetach();
51
	}		
52
53
	
54
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/PauseControlItemHandler.java (+43 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 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 - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
public class PauseControlItemHandler extends AbstractHandler {
22
23
	private IAction action;
24
	
25
	public PauseControlItemHandler(IAction refreshOptions) {
26
		super();
27
		this.action = refreshOptions;
28
	}
29
30
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
31
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
32
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
33
			action.setChecked(!action.isChecked());
34
		}
35
		try {
36
				action.runWithEvent(new Event());
37
		} catch (Exception e) {
38
			throw new ExecutionException("", e); //$NON-NLS-1$
39
		}
40
		
41
		return null;
42
	}
43
}

Return to bug 140650