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 / +29 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;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItemHandler;
31
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
32
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
22
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
33
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
23
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
24
import org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem;
25
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshOption;
26
import org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView;
27
import org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem;
28
import org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction;
34
import org.eclipse.tptp.trace.ui.provisional.control.provider.ProcessControlProvider.ProcessStateModifier;
29
import org.eclipse.tptp.trace.ui.provisional.control.provider.ProcessControlProvider.ProcessStateModifier;
35
30
36
/**
31
/**
Lines 40-53 Link Here
40
 */
35
 */
41
public class AgentControlProvider extends AbstractControlProvider {
36
public class AgentControlProvider extends AbstractControlProvider {
42
37
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 */
38
	/* The delete item */
52
	private IControlItem delete;
39
	private IControlItem delete;
53
	
40
	
Lines 74-80 Link Here
74
	
61
	
75
	/* The agent state modifier */
62
	/* The agent state modifier */
76
	private IAgentStateModifier agentStateModifier;
63
	private IAgentStateModifier agentStateModifier;
77
64
	
65
	/* The handler for the actions */
66
	private IHandler handler; 
78
	/**
67
	/**
79
	 * Default constructor.
68
	 * Default constructor.
80
	 */
69
	 */
Lines 136-162 Link Here
136
    protected IControlItem createRefreshViewsControlItem() {
125
    protected IControlItem createRefreshViewsControlItem() {
137
    	if (refresh != null)
126
    	if (refresh != null)
138
    		return refresh;
127
    		return refresh;
139
    	
128
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();
129
    	refresh = new RefreshView();
130
    	handler = new ControlItemHandler(refresh);
131
    	refresh.setHandler(handler);
160
    	return refresh;
132
    	return refresh;
161
    }
133
    }
162
    
134
    
Lines 168-196 Link Here
168
    protected IControlItem createRefreshOptionControlItem() {
140
    protected IControlItem createRefreshOptionControlItem() {
169
    	if (refreshOption != null)
141
    	if (refreshOption != null)
170
    		return refreshOption;
142
    		return refreshOption;
171
    	
143
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();
144
    	refreshOption = new RefreshOption();
145
    	handler = new ControlItemHandler(refreshOption);
146
    	refreshOption.setHandler(handler);
194
    	return refreshOption;
147
    	return refreshOption;
195
    }
148
    }
196
    
149
    
Lines 199-273 Link Here
199
    	if (resumeItem != null)
152
    	if (resumeItem != null)
200
    		return resumeItem;
153
    		return resumeItem;
201
    	
154
    	
202
    	class ResumeControlItem extends AgentControlItem
155
    	resumeItem = new ResumeControlItem(getAgentStateModifier());
203
    	{		
156
    	handler = new ControlItemHandler(resumeItem);
204
    		public ResumeControlItem()
157
    	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;
158
    	return resumeItem;
234
    }
159
    }
235
    
160
    
236
    protected IControlItem createPauseMonitoringControlItem() {
161
    protected IControlItem createPauseMonitoringControlItem() {
237
    	if (pauseItem != null)
162
    	if (pauseItem != null)
238
    		return pauseItem;
163
    		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
    	
164
    	
269
    	
165
    	pauseItem = new PauseControlItem(getAgentStateModifier());
270
    	pauseItem = new PauseControlItem();
166
    	handler = new ControlItemHandler(pauseItem);
167
    	pauseItem.setHandler(handler);
271
    	return pauseItem;
168
    	return pauseItem;
272
    }
169
    }
273
170
Lines 281-368 Link Here
281
	protected IControlItem createTerminateControlItem() {
178
	protected IControlItem createTerminateControlItem() {
282
		if (terminateItem != null)
179
		if (terminateItem != null)
283
			return terminateItem;
180
			return terminateItem;
284
			
181
						
285
		class TerminateAction extends ControlItem
182
		terminateItem = new TerminateAction(getProcessStateModifier());
286
		{
183
		handler = new ControlItemHandler(terminateItem);
287
			public TerminateAction()
184
		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;
185
		return terminateItem;
336
	}
186
	}
337
	
187
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
188
368
}
189
}
(-)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 ControlItemHandler(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 ControlItemHandler(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 ControlItemHandler(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 ControlItemHandler(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 ControlItemHandler(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 ControlItemHandler(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 ControlItemHandler(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 (-5 / +11 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-20 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;
17
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItemHandler;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.StandardAgentStateModifier;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.StandardAgentStateModifier;
Lines 33-42 Link Here
33
	private IAgentStateModifier agentStateModifier;
33
	private IAgentStateModifier agentStateModifier;
34
	
34
	
35
	/** The collect object reference control item */
35
	/** The collect object reference control item */
36
	private IControlItem dumpHeapControlItem;
36
	protected static IControlItem dumpHeapControlItem;
37
	
37
	
38
	/** The garbage collection control item */
38
	/** The garbage collection control item */
39
	private IControlItem garbageCollectionControlItem;
39
	protected static IControlItem garbageCollectionControlItem;
40
	
41
	private IHandler handler;
40
	
42
	
41
	
43
	
42
	public PIAgentToolbarProvider()
44
	public PIAgentToolbarProvider()
Lines 63-68 Link Here
63
			return garbageCollectionControlItem;
65
			return garbageCollectionControlItem;
64
		
66
		
65
		garbageCollectionControlItem = makeToolbarReady(new GCControlItem(), GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
67
		garbageCollectionControlItem = makeToolbarReady(new GCControlItem(), GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
68
		handler = new ControlItemHandler(garbageCollectionControlItem);
69
		garbageCollectionControlItem.setHandler(handler);
66
		return garbageCollectionControlItem;
70
		return garbageCollectionControlItem;
67
	}
71
	}
68
	
72
	
Lines 72-77 Link Here
72
			return dumpHeapControlItem;
76
			return dumpHeapControlItem;
73
		
77
		
74
		dumpHeapControlItem = makeToolbarReady(new HeapDumpControlItem(), HEAP_DUMP_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
78
		dumpHeapControlItem = makeToolbarReady(new HeapDumpControlItem(), HEAP_DUMP_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
79
		handler = new ControlItemHandler(dumpHeapControlItem); 
80
		dumpHeapControlItem.setHandler(handler);
75
		return dumpHeapControlItem;
81
		return dumpHeapControlItem;
76
	}
82
	}
77
83
(-)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 = PIAgentToolbarProvider.dumpHeapControlItem.getHandler();
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 / +126 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.ControlItemHandler"
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.ControlItemHandler"
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.ControlItemHandler"
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.ControlItemHandler"
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.ControlItemHandler"
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.ControlItemHandler"
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.ControlItemHandler"
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.provisional.control.provider.ControlItemHandler"
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.provisional.control.provider.ControlItemHandler"
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
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1122
            sequence="M1+M3+P">
1123
      </key>
1124
      <key
1125
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"
1126
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1127
            sequence="M1+M3+S">
1128
      </key>
1129
      <key
1130
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem"
1131
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1132
            sequence="M1+M3+A">
1133
      </key>
1134
      <key
1135
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem"
1136
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1137
            sequence="M1+M3+D">
1138
      </key>
1139
      <key
1140
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction"
1141
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1142
            sequence="M1+M3+T">
1143
      </key>
1144
      <key
1145
            commandId="org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption"
1146
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1147
            sequence="M1+M3+O">
1148
      </key>
1149
      <key
1150
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView"
1151
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1152
            sequence="M1+M3+R">
1153
      </key>
1154
      <key
1155
            commandId="org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem"
1156
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1157
            sequence="M1+M3+M2+G">
1158
      </key>
1159
      <key
1160
            commandId="org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItem"
1161
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1162
            sequence="M1+M3+M2+O">
1163
      </key>
1164
    </extension>
1040
</plugin>
1165
</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 / +13 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 250-255 Link Here
250
		super(ID);
250
		super(ID);
251
		
251
		
252
		traceControlItemManager = new TraceControlItemManager(this);
252
		traceControlItemManager = new TraceControlItemManager(this);
253
//		traceControlItemManager.setSite(getSite());
253
		
254
		
254
		/* set project explorer to resource helper such that it can be notified dirty for save */
255
		/* set project explorer to resource helper such that it can be notified dirty for save */
255
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
256
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
Lines 273-280 Link Here
273
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
274
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
274
		UIPlugin.getDefault().addProfileEventListener(this);
275
		UIPlugin.getDefault().addProfileEventListener(this);
275
		
276
		
277
//		activateContext();
278
		
276
		(new RefreshUI()).start();
279
		(new RefreshUI()).start();
277
	}
280
	}
281
	
282
	/*
283
	 *  Defines the context of the profiling view as "org.eclipse.ui.TPTPMonitorContext". 
284
	 *  Is used for Keybinding. 
285
	 */
286
//	private void activateContext() {
287
//		IContextService contextService = (IContextService) getSite().getService(IContextService.class);
288
//		contextService.activateContext("org.eclipse.ui.TPTPMonitorContext");
289
//	}
278
290
279
	/**
291
	/**
280
	 * Updates the action bar actions.
292
	 * 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 (+64 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
/**
23
 * The Action class that creates the Heap Dump (or Collect Object References) 
24
 * Item for the PI Agent. 
25
 * 
26
 */
27
public class HeapDumpControlItem extends ControlItem
28
{
29
	CollectObjRefAction collectObjRef;
30
	private static final String HEAP_DUMP_ITEM = "org.eclipse.tptp.trace.ui.internal.control.provider.application.HeapDumpControlItem";
31
	
32
	public HeapDumpControlItem()
33
	{
34
		super(HEAP_DUMP_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_DUMP, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DUMP));
35
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DUMP));
36
		collectObjRef = new CollectObjRefAction();
37
	}
38
	
39
	public void run()
40
	{
41
		try
42
		{
43
			for (Iterator agents = input.iterator(); agents.hasNext();)
44
				collectObjRef.doAction(agents.next());
45
		}
46
		catch (Exception e)
47
		{
48
			LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
49
		}
50
	}
51
	
52
	
53
	public boolean isEnabled()
54
	{
55
		if (input == null || input.size() == 0)
56
			return false;
57
		
58
		boolean isEnable = true;
59
		for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
60
			isEnable = isEnable && collectObjRef.isEnabledFor(agents.next());
61
		return isEnable;
62
	}
63
		
64
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshOption.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 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
/**
23
 * An Action class that is referenced when the user requests to view or 
24
 * modify Refresh Options. This class opens a new window and provides the
25
 * user with the ability to modify refresh options and set refresh defaults
26
 * for the profiling session. 
27
 * 
28
 */
29
public class RefreshOption extends ControlItem {
30
31
	private static final String REFRESH_OPTION = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption";
32
	
33
	public RefreshOption()
34
	{
35
		super (REFRESH_OPTION, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_OPTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_OPTIONS));
36
	}
37
	
38
	/* This method is invoked when ever user clicks the 'Change Refresh Options' button.
39
	 * It simply invokes the 'handleProfileEvent' method of PDProjectExplorer */
40
	public void run()
41
	{
42
		if (input == null)
43
			return;
44
		
45
		for (Iterator sources = input.iterator(); sources.hasNext();)
46
		{					
47
			ProfileEvent event = UIPlugin.getDefault().getRefreshOptionEvent(sources.next());
48
			UIPlugin.getDefault().notifyProfileEventListener(event);
49
		}
50
	}
51
}
52
	
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/PauseControlItem.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
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
/**
22
 * An Action class that is referenced when a Pause Control Item needs 
23
 * to be created. Pause Control Item stops monitoring a running process 
24
 *  without detaching it from the agent in the profiling view. 
25
 */
26
public class PauseControlItem extends AgentControlItem {
27
	
28
	private static final String PAUSE_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem";
29
	private static IAgentStateModifier _agentStateModifier;
30
	
31
	public PauseControlItem(IAgentStateModifier agentStateModifier)
32
	{
33
		super(agentStateModifier, PAUSE_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_PAUSE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_PAUSE));
34
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
35
		_agentStateModifier = agentStateModifier; 
36
	}
37
	
38
	public void run()
39
	{
40
		IAgentStateModifier agentStateModifier = _agentStateModifier;
41
									
42
		try
43
		{
44
			/* Pause the agent */					
45
			if(isEnabled())
46
				agentStateModifier.pauseMonitoring();
47
		} catch (CoreException e)
48
		{
49
			/* Display status */
50
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
51
		}				
52
	}
53
	
54
	public boolean isEnabled()
55
	{
56
		return _agentStateModifier.canPause();
57
	}		
58
59
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ControlItemHandler.java (+51 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.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.swt.widgets.Event;
18
19
/**
20
 * A Handler class that is referenced when a Handler needs to be set for 
21
 * any Action item of type IControl Item. 
22
 * 
23
 * This creates handlers for the 
24
 * actions in the current profiling view, and it is recommended that new 
25
 * handler classes be created if some of the handler properties or the 
26
 * method's functions need to be changed. 
27
 */
28
public class ControlItemHandler extends AbstractHandler {
29
30
	private IAction action;
31
	
32
	public ControlItemHandler(IAction actionItem) {
33
		super();
34
		this.action = actionItem;
35
		
36
	}
37
38
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
39
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
40
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
41
			action.setChecked(!action.isChecked());
42
		}
43
		try {
44
				action.runWithEvent(new Event());
45
		} catch (Exception e) {
46
			throw new ExecutionException("", e); //$NON-NLS-1$
47
		}
48
		
49
		return null;
50
	}
51
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResumeControlItem.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.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
/**
21
 * An Action class that is referenced when an Start Control Item needs 
22
 * to be created. Start Control Item starts or resumes monitoring of a 
23
 * running process that is attached to the agent in the profiling view. 
24
 */
25
public class ResumeControlItem extends AgentControlItem {
26
	
27
	private static String START_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"; 
28
	private IAgentStateModifier _agentStateModifier; 
29
30
	public ResumeControlItem(IAgentStateModifier agentStateModifier)
31
	{
32
		super(agentStateModifier, START_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_RESUME, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_RESUME));
33
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
34
		_agentStateModifier = agentStateModifier;
35
	}
36
	
37
	public void run()
38
	{
39
		IAgentStateModifier agentStateModifier = _agentStateModifier;
40
									
41
		try
42
		{
43
			/* Resume the agent */
44
			if(isEnabled())
45
				agentStateModifier.startMonitoring();
46
		} catch (CoreException e)
47
		{
48
			/* Display status */
49
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
50
		}				
51
	}
52
	
53
	public boolean isEnabled()
54
	{
55
		return _agentStateModifier.canResume();
56
	}	
57
58
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshView.java (+46 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
/**
22
 * An Action class that is referenced when an Refresh View Item needs 
23
 * to be created. Refresh View regenerates open profiling views with 
24
 * updated data displayed.
25
 */
26
public class RefreshView extends ControlItem {
27
 	
28
	private static final String REFRESH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView";
29
	
30
	public RefreshView()
31
	{
32
		super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
33
	}
34
		
35
	public void run()
36
	{
37
		if (input == null)
38
			return;
39
			
40
		for (Iterator sources = input.iterator(); sources.hasNext();)
41
		{					
42
			ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
43
			UIPlugin.getDefault().notifyProfileEventListener(event);
44
		}
45
	}
46
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AttachControlItem.java (+57 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
/**
21
 * An Action class that is referenced when an Attach Control Item needs 
22
 * to be created. Attach Control Item attaches a running process to the
23
 * agent in the profiling view. 
24
 */
25
public class AttachControlItem extends AgentControlItem {
26
27
	private static final String ATTACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem";
28
	private IAgentStateModifier _agentStateModifier; 
29
	
30
	public AttachControlItem(IAgentStateModifier agentStateModifier)
31
	{
32
		super(agentStateModifier, ATTACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_ATTACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
33
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_ATTACH_AGENT));
34
		_agentStateModifier = agentStateModifier; 
35
	}
36
		
37
	public void run()
38
	{	
39
		IAgentStateModifier agentStateModifier = _agentStateModifier;
40
41
		try
42
		{
43
			/* attach to the agent */					
44
			if (isEnabled())
45
				agentStateModifier.attach();
46
		} catch (CoreException e)
47
		{
48
			/* Display status */
49
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
50
		}				
51
	}
52
		
53
	public boolean isEnabled()
54
	{
55
		return _agentStateModifier.canAttach();
56
	}			
57
}
(-)src/org/eclipse/tptp/trace/ui/internal/control/provider/application/GCControlItem.java (+63 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
/**
23
 * The Action class that creates the Run garbage Collection Item for the PI 
24
 * Agent. 
25
 * 
26
 */
27
public class GCControlItem extends ControlItem {
28
29
		private RunGCAction gcAction;
30
		public static final String GC_ITEM = "org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem";
31
		
32
		public GCControlItem()
33
		{
34
			super(GC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, ControlMessages.CONTROL_ITEM_GC_ACTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_GC));
35
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_GC));
36
			gcAction = new RunGCAction();
37
		}
38
		
39
		public void run()
40
		{
41
			try
42
			{
43
				for (Iterator agents = input.iterator(); agents.hasNext();)
44
					gcAction.doAction(agents.next());
45
			}
46
			catch (Exception e)
47
			{
48
				LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e);
49
			}
50
		}
51
		
52
		
53
		public boolean isEnabled()
54
		{
55
			if (input == null || input.size() == 0)
56
				return false;
57
			
58
			boolean isEnable = true;
59
			for (Iterator agents = input.iterator(); isEnable && agents.hasNext();)
60
				isEnable = isEnable && gcAction.isEnabledFor(agents.next());
61
			return isEnable;
62
		}	
63
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/TerminateAction.java (+76 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
/**
21
 * An Action class that is referenced when an Terminate Control Item needs 
22
 * to be created. Terminate Control Item stops monitoring and detaches a 
23
 * running process from the agent in the profiling view. 
24
 */
25
public class TerminateAction extends ControlItem {
26
27
	private IProcessStateModifier _processStateModifier;
28
	private static final String TERMINATE_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction";
29
	
30
		public TerminateAction(IProcessStateModifier processStateModifier)
31
		{
32
			super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
33
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
34
			_processStateModifier = processStateModifier;
35
		}
36
		
37
		public void run()
38
		{
39
										
40
			try
41
			{
42
				/* Terminate the process */
43
				if(isEnabled())
44
					_processStateModifier.terminate();
45
			} catch (CoreException e)
46
			{
47
				/* Display status */
48
				LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
49
			}				
50
		}
51
		
52
		public boolean isEnabled()
53
		{
54
			return _processStateModifier.canTerminate();
55
		}
56
		
57
		public void setInput(StructuredSelection input)
58
		{
59
			_processStateModifier.setInput(input);
60
		}
61
		
62
		public IProcessStateModifier getStateModifier()
63
		{
64
			return _processStateModifier;
65
		}
66
		
67
		public boolean equals (Object o)
68
		{
69
			if (!(o instanceof TerminateAction))
70
				return false;
71
			
72
			return _processStateModifier == ((TerminateAction)o).getStateModifier() && super.equals(o);
73
		}
74
75
76
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/DetachControlItem.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.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
/**
21
 * An Action class that is referenced when an Detach Control Item needs 
22
 * to be created. Detach Control Item detaches a running process from the
23
 * agent in the profiling view. 
24
 */
25
public class DetachControlItem extends AgentControlItem {
26
27
	public static final String DETACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem";	
28
	private IAgentStateModifier _agentStateModifier; 
29
	
30
	public DetachControlItem(IAgentStateModifier agentStateModifier)
31
	{
32
		super(agentStateModifier, DETACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_DETACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
33
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DETACH_AGENT));
34
		_agentStateModifier = agentStateModifier; 
35
	}
36
		
37
	public void run()
38
	{	
39
		IAgentStateModifier agentStateModifier = _agentStateModifier;
40
		
41
		try
42
		{
43
			/* detach the agent */	
44
			if (isEnabled())
45
				agentStateModifier.detach();
46
		} catch (CoreException e)
47
		{
48
			/* Display status */
49
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
50
		}				
51
	}
52
		
53
	public boolean isEnabled()
54
	{
55
		return _agentStateModifier.canDetach();
56
	}		
57
58
	
59
}
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/TIAgentControlProvider.java (-49 / +6 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;
40
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
37
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherMessages;
41
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
38
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
42
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider;
39
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;
40
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
45
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
41
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
46
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
42
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
47
43
48
49
/**
44
/**
50
 * This is the TI agent control provider.  Its purpose is to modify the states that the TI agent
45
 * 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).
46
 * can be in (e.g. Pause/Resume/Detach/Attach).
Lines 54-65 Link Here
54
 */
49
 */
55
public class TIAgentControlProvider extends AbstractAgentControlProvider
50
public class TIAgentControlProvider extends AbstractAgentControlProvider
56
{
51
{
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 */
52
    /** The runGC item */
62
    private IControlItem runGCControlItem;
53
    protected static IControlItem runGCControlItem;
54
	private IHandler handler;
63
55
64
    
56
    
65
    protected void initializeControlItems() {
57
    protected void initializeControlItems() {
Lines 80-124 Link Here
80
	    return runGCControlItem;
72
	    return runGCControlItem;
81
73
82
	runGCControlItem = new RunGCControlItem();
74
	runGCControlItem = new RunGCControlItem();
75
	handler = TIAgentToolbarControlProvider.garbageCollectionControlItem.getHandler();
76
	runGCControlItem.setHandler(handler); 
83
	return runGCControlItem;
77
	return runGCControlItem;
84
    }
78
    }
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
	
79
	
123
	public IAgentStateModifier getAgentStateModifier()
80
	public IAgentStateModifier getAgentStateModifier()
124
	{
81
	{
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/TIAgentToolbarControlProvider.java (-3 / +7 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-21 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.provisional.control.provider.AbstractAgentToolbarProvider;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItemHandler;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
22
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
Lines 30-37 Link Here
30
{
31
{
31
	public static final String GC_TOOLBAR_ITEM = "org.eclipse.tptp.trace.jvmti.client.internal.monitorsview.toolbar.runGC";
32
	public static final String GC_TOOLBAR_ITEM = "org.eclipse.tptp.trace.jvmti.client.internal.monitorsview.toolbar.runGC";
32
33
33
	private IControlItem garbageCollectionControlItem;
34
	protected static IControlItem garbageCollectionControlItem;
34
35
36
	private IHandler handler;
35
37
36
	public IProcessStateModifier getProcessStateModifier()
38
	public IProcessStateModifier getProcessStateModifier()
37
	{		
39
	{		
Lines 56-61 Link Here
56
		GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
58
		GC_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
57
		TraceUIImages.INSTANCE.getImageDescriptor("d",
59
		TraceUIImages.INSTANCE.getImageDescriptor("d",
58
			TraceUIImages.IMG_GC));
60
			TraceUIImages.IMG_GC));
61
	handler = new ControlItemHandler(garbageCollectionControlItem);
62
	garbageCollectionControlItem.setHandler(handler); 
59
	return garbageCollectionControlItem;
63
	return garbageCollectionControlItem;
60
    }
64
    }
61
}
65
}
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/RunGCControlItem.java (+55 lines)
Added Link Here
1
package org.eclipse.tptp.platform.jvmti.client.internal.controlproviders;
2
3
import java.util.Iterator;
4
5
import org.eclipse.core.runtime.IStatus;
6
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
7
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
8
import org.eclipse.tptp.platform.jvmti.client.internal.actions.RunGCActionDelegate;
9
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
10
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
11
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
12
13
/**
14
 * The Action class that creates the Run garbage Collection Item for the TI 
15
 * Agent. 
16
 * 
17
 */
18
public class RunGCControlItem extends ControlItem {
19
	
20
	private static String RUNGC_ITEM = "org.eclipse.tptp.trace.ui.internal.control.provider.application.GCControlItem";
21
	
22
	private RunGCActionDelegate gcAction;
23
	
24
	public RunGCControlItem() {
25
	    super(RUNGC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
26
		    ControlMessages.CONTROL_ITEM_GC_ACTION,
27
		    TraceUIImages.INSTANCE.getImageDescriptor("c",
28
			    TraceUIImages.IMG_GC));
29
	    setDisabledImageDescriptor(TraceUIImages.INSTANCE
30
		    .getImageDescriptor("d", TraceUIImages.IMG_GC));
31
	    gcAction = new RunGCActionDelegate();
32
	}
33
34
	public void run() {
35
	    try {
36
		for (Iterator agents = input.iterator(); agents.hasNext();)
37
		    gcAction.doAction(agents.next());
38
39
	    } catch (Exception e) {
40
		LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e
41
			.getMessage(), e);
42
	    }
43
	}
44
45
	public boolean isEnabled() {
46
	    if (input == null || input.size() == 0)
47
		return false;
48
49
	    boolean isEnable = true;
50
	    for (Iterator agents = input.iterator(); isEnable
51
		    && agents.hasNext();)
52
		isEnable = isEnable && gcAction.isEnabledFor(agents.next());
53
	    return isEnable;
54
	}
55
}

Return to bug 140650