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/jvmti/client/internal/controlproviders/TIAgentControlProvider.java (-42 / +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 44-49 Link Here
44
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
45
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
45
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
46
import org.eclipse.tptp.trace.ui.provisional.control.provider.IControlItem;
46
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
47
import org.eclipse.tptp.trace.ui.provisional.control.provider.IProcessStateModifier;
48
import org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateControlItemHandler;
47
49
48
50
49
/**
51
/**
Lines 54-65 Link Here
54
 */
56
 */
55
public class TIAgentControlProvider extends AbstractAgentControlProvider
57
public class TIAgentControlProvider extends AbstractAgentControlProvider
56
{
58
{
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 */
59
    /** The runGC item */
62
    private IControlItem runGCControlItem;
60
    private IControlItem runGCControlItem;
61
	private IHandler handler;
63
62
64
    
63
    
65
    protected void initializeControlItems() {
64
    protected void initializeControlItems() {
Lines 80-124 Link Here
80
	    return runGCControlItem;
79
	    return runGCControlItem;
81
80
82
	runGCControlItem = new RunGCControlItem();
81
	runGCControlItem = new RunGCControlItem();
82
	handler = new RunGCControlItemHandler(runGCControlItem);
83
	runGCControlItem.setHandler(handler); 
83
	return runGCControlItem;
84
	return runGCControlItem;
84
    }
85
    }
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
	
86
	
123
	public IAgentStateModifier getAgentStateModifier()
87
	public IAgentStateModifier getAgentStateModifier()
124
	{
88
	{
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/TIAgentToolbarControlProvider.java (-1 lines)
Lines 13-19 Link Here
13
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
13
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
14
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
14
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
15
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIAgentControlProvider.TIAgentStateModifier;
15
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;
16
import org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.TIProcessControlProvider.TIProcessStateModifier;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
17
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentToolbarProvider;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier;
(-)plugin.xml (+21 lines)
Lines 311-314 Link Here
311
			</entity>
311
			</entity>
312
		</control>
312
		</control>
313
	</extension>
313
	</extension>
314
 <extension
315
       point="org.eclipse.ui.commands">
316
    <category
317
          id="org.eclipse.hyades.trace.ui.ProfileActions"
318
          name="Trace Action Items">
319
    </category>
320
    <command
321
          categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
322
          defaultHandler="org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.RunGCControlItemHandler"
323
          id="org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.RunGCControlItem"
324
          name="Run Garbage Collection">
325
    </command>
326
 </extension>
327
 <extension
328
       point="org.eclipse.ui.bindings">
329
    <key
330
          commandId="org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.RunGCControlItem"
331
          schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
332
          sequence="M1+M3+M2+G">
333
    </key>
334
 </extension>
314
</plugin>
335
</plugin>
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/RunGCControlItem.java (+60 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.platform.jvmti.client.internal.controlproviders;
12
13
import java.util.Iterator;
14
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
17
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
18
import org.eclipse.tptp.platform.jvmti.client.internal.actions.RunGCActionDelegate;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
20
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
21
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
22
23
public class RunGCControlItem extends ControlItem {
24
25
		private RunGCActionDelegate gcAction;
26
		private static final String RUNGC_ITEM = "org.eclipse.tptp.platform.jvmti.client.internal.controlproviders.RunGCControlItem";
27
		
28
		
29
		public RunGCControlItem() {
30
		    super(RUNGC_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP,
31
			    ControlMessages.CONTROL_ITEM_GC_ACTION,
32
			    TraceUIImages.INSTANCE.getImageDescriptor("c",
33
				    TraceUIImages.IMG_GC));
34
		    setDisabledImageDescriptor(TraceUIImages.INSTANCE
35
			    .getImageDescriptor("d", TraceUIImages.IMG_GC));
36
		    gcAction = new RunGCActionDelegate();
37
		}
38
39
		public void run() {
40
		    try {
41
			for (Iterator agents = input.iterator(); agents.hasNext();)
42
			    gcAction.doAction(agents.next());
43
44
		    } catch (Exception e) {
45
			LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e
46
				.getMessage(), e);
47
		    }
48
		}
49
50
		public boolean isEnabled() {
51
		    if (input == null || input.size() == 0)
52
			return false;
53
54
		    boolean isEnable = true;
55
		    for (Iterator agents = input.iterator(); isEnable
56
			    && agents.hasNext();)
57
			isEnable = isEnable && gcAction.isEnabledFor(agents.next());
58
		    return isEnable;
59
		}
60
}
(-)src/org/eclipse/tptp/platform/jvmti/client/internal/controlproviders/RunGCControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.platform.jvmti.client.internal.controlproviders;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class RunGCControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public RunGCControlItemHandler(IAction runGC) {
27
		super();
28
		this.action = runGC;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResourceItemControlProvider.java (-60 / +12 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-33 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
import java.util.Iterator;
13
import org.eclipse.core.commands.IHandler;
14
15
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
14
import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer;
16
import org.eclipse.hyades.trace.ui.ProfileEvent;
17
import org.eclipse.hyades.trace.ui.UIPlugin;
15
import org.eclipse.hyades.trace.ui.UIPlugin;
18
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
16
import org.eclipse.hyades.trace.ui.internal.actions.DeleteAction;
19
import org.eclipse.hyades.trace.ui.internal.actions.OpenWizardAction;
17
import org.eclipse.hyades.trace.ui.internal.actions.OpenWizardAction;
20
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
18
import org.eclipse.hyades.trace.ui.internal.actions.SaveAction;
21
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
22
import org.eclipse.hyades.trace.ui.internal.util.TraceMessages;
19
import org.eclipse.hyades.trace.ui.internal.util.TraceMessages;
23
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProcessWizard;
20
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProcessWizard;
24
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProfAgentWizard;
21
import org.eclipse.hyades.trace.ui.internal.wizard.OpenProfAgentWizard;
25
import org.eclipse.hyades.ui.extension.INavigatorContribution;
22
import org.eclipse.hyades.ui.extension.INavigatorContribution;
26
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
27
import org.eclipse.tptp.trace.ui.internal.control.provider.ControlProviderManager;
23
import org.eclipse.tptp.trace.ui.internal.control.provider.ControlProviderManager;
28
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
24
import org.eclipse.tptp.trace.ui.internal.control.provider.TraceControlItemManager;
29
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
30
31
25
32
26
33
/**
27
/**
Lines 43-52 Link Here
43
 */
37
 */
44
public class ResourceItemControlProvider extends LogicalItemControlProvider 
38
public class ResourceItemControlProvider extends LogicalItemControlProvider 
45
{
39
{
46
	/** The id of the contributed items */
47
	private static final String REFRESH_ITEM = "org.eclipse.hyades.trace.ui.internal.monitorsview.popupMenu.refreshViews";
48
	private static final String REFRESH_OPTION = "org.eclipse.hyades.trace.ui.internal.monitorsview.popupMenu.refreshOption";
49
	
50
	/** The delete item */
40
	/** The delete item */
51
	private IControlItem delete;
41
	private IControlItem delete;
52
	
42
	
Lines 54-69 Link Here
54
	private IControlItem save;
44
	private IControlItem save;
55
	
45
	
56
	/** The refresh view item */
46
	/** The refresh view item */
57
	private IControlItem refresh;
47
	protected static IControlItem refresh;
58
	
48
	
59
	/** The refresh option item */
49
	/** The refresh option item */
60
	private IControlItem refreshOption;
50
	protected static IControlItem refreshOption;
61
51
62
	/** The properties item */
52
	/** The properties item */
63
	private IControlItem properties;
53
	private IControlItem properties;
64
54
65
	/** The entity that this provider is affiliated to */
55
	/** The entity that this provider is affiliated to */
66
	private String entity;
56
	private String entity;
57
58
	private IHandler handler;
67
	
59
	
68
	public void initialize (String entity)
60
	public void initialize (String entity)
69
	{
61
	{
Lines 88-95 Link Here
88
    {
80
    {
89
    	if (delete != null && !isContextDifferent)
81
    	if (delete != null && !isContextDifferent)
90
    		return delete;
82
    		return delete;
91
    	
83
92
    	    	
93
    	delete = new ControlItemAdapter(INavigatorContribution.GROUP_DELETE, new DeleteAction(TraceControlItemManager.getNavigator()));
84
    	delete = new ControlItemAdapter(INavigatorContribution.GROUP_DELETE, new DeleteAction(TraceControlItemManager.getNavigator()));
94
    	return delete;
85
    	return delete;
95
    }
86
    }
Lines 100-106 Link Here
100
    	if (save != null && !isContextDifferent)
91
    	if (save != null && !isContextDifferent)
101
    		return save;
92
    		return save;
102
    	
93
    	
103
    	    	
104
    	save = new ControlItemAdapter(INavigatorContribution.GROUP_SAVE, new SaveAction(TraceControlItemManager.getNavigator()));
94
    	save = new ControlItemAdapter(INavigatorContribution.GROUP_SAVE, new SaveAction(TraceControlItemManager.getNavigator()));
105
    	return save;
95
    	return save;
106
    }
96
    }
Lines 110-136 Link Here
110
    {
100
    {
111
    	if (refresh != null)
101
    	if (refresh != null)
112
    		return refresh;
102
    		return refresh;
113
    	
103
114
    	class RefreshView extends ControlItem
115
    	{    		
116
    		public RefreshView()
117
    		{
118
    			super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
119
    		}
120
    		
121
    		public void run()
122
    		{
123
    			if (input == null)
124
    				return;
125
    			
126
    			for (Iterator sources = input.iterator(); sources.hasNext();)
127
    			{					
128
    				ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
129
    				UIPlugin.getDefault().notifyProfileEventListener(event);
130
    			}
131
    		}
132
    	}
133
    	refresh = new RefreshView();
104
    	refresh = new RefreshView();
105
    	handler = new RefreshViewHandler(refresh);
106
    	refresh.setHandler(handler);
134
    	return refresh;
107
    	return refresh;
135
    }
108
    }
136
    
109
    
Lines 143-171 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();
170
    	return refreshOption;
122
    	return refreshOption;
171
    }
123
    }
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractProcessControlProvider.java (-64 / +9 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
2
 * Copyright (c) 2006, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-23 Link Here
10
 **********************************************************************/
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
12
13
13
import org.eclipse.core.commands.IHandler;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
16
import org.eclipse.jface.viewers.StructuredSelection;
17
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
18
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
19
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
20
21
14
22
/**
15
/**
23
 * Provides an abstract control provider for a process.  Subclasses are
16
 * Provides an abstract control provider for a process.  Subclasses are
Lines 28-38 Link Here
28
 */
21
 */
29
public abstract class AbstractProcessControlProvider extends ResourceItemControlProvider 
22
public abstract class AbstractProcessControlProvider extends ResourceItemControlProvider 
30
{
23
{
31
	/** The id of the contributed items */
32
	private static final String TERMINATE_ITEM = "org.eclipse.hyades.trace.ui.internal.popupMenu.TerminateAction";
33
	
34
	/** The terminate item */
24
	/** The terminate item */
35
	private IControlItem terminateItem;
25
	protected static IControlItem terminateItem;
26
	
27
	private IHandler handler; 
36
	
28
	
37
	/**
29
	/**
38
	 * Subclasses are expected to provide a process state modifier that 
30
	 * Subclasses are expected to provide a process state modifier that 
Lines 61-123 Link Here
61
     * Overwrite this method to modify the terminate control
53
     * Overwrite this method to modify the terminate control
62
     * item.
54
     * item.
63
     * 
55
     * 
64
     * @return Ther terminate control item
56
     * @return The terminate control item
65
     */
57
     */
66
	protected IControlItem createTerminateControlItem()
58
	protected IControlItem createTerminateControlItem()
67
	{
59
	{
68
		if (terminateItem != null)
60
		if (terminateItem != null)
69
			return terminateItem;
61
			return terminateItem;
70
			
71
		class TerminateAction extends ControlItem
72
		{
73
			public TerminateAction()
74
			{
75
				super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
76
				setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
77
			}
78
			
79
			public void run()
80
			{
81
				IProcessStateModifier processStateModifier = getProcessStateModifier();
82
											
83
				try
84
				{
85
					/* Terminate the process */
86
					processStateModifier.terminate();
87
				} catch (CoreException e)
88
				{
89
					/* Display status */
90
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
91
				}				
92
			}
93
			
94
			public boolean isEnabled()
95
			{
96
				return getProcessStateModifier().canTerminate();
97
			}
98
			
99
			public void setInput(StructuredSelection input)
100
			{
101
				getProcessStateModifier().setInput(input);
102
			}
103
			
104
			public IProcessStateModifier getStateModifier()
105
			{
106
				return getProcessStateModifier();
107
			}
108
			
109
			public boolean equals (Object o)
110
			{
111
				if (!(o instanceof TerminateAction))
112
					return false;
113
				
114
				return getProcessStateModifier() == ((TerminateAction)o).getStateModifier() && super.equals(o);
115
			}
116
117
		}
118
			
119
				
62
				
120
		terminateItem = new TerminateAction();
63
		terminateItem = new TerminateAction(getProcessStateModifier());
64
		handler = new TerminateControlItemHandler(terminateItem);
65
		terminateItem.setHandler(handler); 
121
		return terminateItem;
66
		return terminateItem;
122
	}
67
	}
123
}
68
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractAgentControlProvider.java (-142 / +26 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-50 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
	private IControlItem attachItem;
50
	
38
	
Lines 52-61 Link Here
52
	private IControlItem detachItem;
40
	private IControlItem detachItem;
53
	
41
	
54
	/** The resume control item */
42
	/** The resume control item */
55
	private IControlItem resumeItem;
43
	protected static IControlItem resumeItem;
56
	
44
	
57
	/** The pause control item */
45
	/** The pause control item */
58
	private IControlItem pauseItem;
46
	protected static IControlItem pauseItem;
47
	
48
	/** The handler for action items */
49
	private IHandler handler; 
59
	
50
	
60
	/**
51
	/**
61
	 * @see org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractLogicalItem.initializeControlItems()
52
	 * @see org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractLogicalItem.initializeControlItems()
Lines 90-126 Link Here
90
    	if (attachItem != null)
81
    	if (attachItem != null)
91
    		return attachItem;
82
    		return attachItem;
92
    	
83
    	
93
    	class AttachControlItem extends AgentControlItem
84
    	attachItem = new AttachControlItem(getAgentStateModifier());
94
    	{		
85
    	handler = new AttachControlItemHandler(attachItem);
95
    		public AttachControlItem()
86
    	attachItem.setHandler(handler);
96
    		{
97
    			super(getAgentStateModifier(), ATTACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_ATTACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
98
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_ATTACH_AGENT));
99
    		}
100
    		
101
			public void run()
102
			{
103
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
104
											
105
				try
106
				{
107
					/* attach to the agent */					
108
					agentStateModifier.attach();
109
				} catch (CoreException e)
110
				{
111
					/* Display status */
112
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
113
				}				
114
			}
115
			
116
			public boolean isEnabled()
117
			{
118
				return getAgentStateModifier().canAttach();
119
			}		
120
    	}
121
    	
122
    	
123
    	attachItem = new AttachControlItem();
124
    	return attachItem;
87
    	return attachItem;
125
    }
88
    }
126
    
89
    
Lines 129-165 Link Here
129
    	if (detachItem != null)
92
    	if (detachItem != null)
130
    		return detachItem;
93
    		return detachItem;
131
    	
94
    	
132
    	class DetachControlItem extends AgentControlItem
95
    	detachItem = new DetachControlItem(getAgentStateModifier());
133
    	{		
96
    	handler = new DetachControlItemHandler(detachItem);
134
    		public DetachControlItem()
97
    	detachItem.setHandler(handler);
135
    		{
136
    			super(getAgentStateModifier(), DETACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_DETACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
137
    			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DETACH_AGENT));
138
    		}
139
    		
140
			public void run()
141
			{
142
				IAgentStateModifier agentStateModifier = getAgentStateModifier();
143
											
144
				try
145
				{
146
					/* detach the agent */					
147
					agentStateModifier.detach();
148
				} catch (CoreException e)
149
				{
150
					/* Display status */
151
					LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
152
				}				
153
			}
154
			
155
			public boolean isEnabled()
156
			{
157
				return getAgentStateModifier().canDetach();
158
			}		
159
    	}
160
    	
161
    	
162
    	detachItem = new DetachControlItem();
163
    	return detachItem;
98
    	return detachItem;
164
    }
99
    }
165
    
100
    
Lines 168-204 Link Here
168
    	if (resumeItem != null)
103
    	if (resumeItem != null)
169
    		return resumeItem;
104
    		return resumeItem;
170
    	
105
    	
171
    	class ResumeControlItem extends AgentControlItem
106
    	resumeItem = new ResumeControlItem(getAgentStateModifier());
172
    	{		
107
    	handler = new ResumeControlItemHandler(resumeItem);
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 = new PauseControlItemHandler(pauseItem);
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
    
123
    public IControlItem getCreatedPauseControlItem()
124
    {
125
    	if (pauseItem != null)
126
    		return pauseItem;
127
    	return createPauseMonitoringControlItem();
128
    }
244
    
129
    
245
    private static class AgentControlItem extends ControlItem
130
    protected static class AgentControlItem extends ControlItem
246
    {
131
    {
247
		private IAgentStateModifier stateModifier;
132
		private IAgentStateModifier stateModifier;
248
    	
133
    	
Lines 272-276 Link Here
272
		}
157
		}
273
			
158
			
274
	}
159
	}
275
   
276
}
160
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AbstractAgentToolbarProvider.java (-2 / +13 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 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 70-75 Link Here
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(super.createStartMonitoringControlItem(), START_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
77
		handler = resumeItem.getHandler(); 
78
		startMonitoring.setHandler(handler);
73
		return startMonitoring;
79
		return startMonitoring;
74
    }
80
    }
75
	
81
	
Lines 85-91 Link Here
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(super.createPauseMonitoringControlItem(), PAUSE_TOOLBAR_ITEM, CommonUITraceConstants.PROFILE_MONITOR_GROUP, TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
88
		
94
		handler = pauseItem.getHandler(); 
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
	
(-)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
}
(-)plugin.xml (-1 / +101 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="TPTP Profiling View Context">
1045
    </context>
1046
 </extension>
1047
	
1048
	<extension
1049
         point="org.eclipse.ui.commands">
1050
      <category
1051
            name="Trace Action Items"
1052
            id="org.eclipse.hyades.trace.ui.ProfileActions">
1053
      </category>
1054
            <command
1055
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1056
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItemHandler"
1057
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem"
1058
                  name="Pause Monitoring">
1059
      </command>
1060
            <command
1061
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1062
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItemHandler"
1063
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"
1064
                  name="Start Monitoring">
1065
            </command>
1066
            <command
1067
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1068
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItemHandler"
1069
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem"
1070
                  name="Attach to Agent">
1071
            </command>
1072
            <command
1073
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1074
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItemHandler"
1075
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem"
1076
                  name="Detach from Agent">
1077
            </command>
1078
            <command
1079
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1080
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateControlItemHandler"
1081
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction"
1082
                  name="Terminate Monitoring Process">
1083
            </command>
1084
         <!--   <command
1085
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1086
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshOptionHandler"
1087
                  id="org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption"
1088
                  name="Refresh Option">
1089
            </command>        -->
1090
            <command
1091
                  categoryId="org.eclipse.hyades.trace.ui.ProfileActions"
1092
                  defaultHandler="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshViewHandler"
1093
                  id="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView"
1094
                  name="Refresh Views">
1095
            </command>
1096
      </extension>
1097
	<extension point="org.eclipse.ui.bindings">
1098
      <key
1099
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem"
1100
            contextId="org.eclipse.ui.TPTPMonitorContext"
1101
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1102
            sequence="M1+M3+M2+P">
1103
      </key>
1104
      <key
1105
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"
1106
            contextId="org.eclipse.ui.TPTPMonitorContext"
1107
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1108
            sequence="M1+M3+M2+S">
1109
      </key>
1110
      <key
1111
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem"
1112
            contextId="org.eclipse.ui.TPTPMonitorContext"
1113
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1114
            sequence="M1+M3+M2+A">
1115
      </key>
1116
      <key
1117
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem"
1118
            contextId="org.eclipse.ui.TPTPMonitorContext"
1119
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1120
            sequence="M1+M3+M2+D">
1121
      </key>
1122
      <key
1123
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction"
1124
            contextId="org.eclipse.ui.TPTPMonitorContext"
1125
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1126
            sequence="M1+M3+M2+T">
1127
      </key>
1128
     <!-- <key
1129
            commandId="org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption"
1130
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1131
            sequence="M1+M3+M2+O">
1132
      </key>-->
1133
      <key
1134
            commandId="org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView"
1135
            contextId="org.eclipse.ui.TPTPMonitorContext"
1136
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1137
            sequence="M1+M3+M2+R">
1138
      </key>   
1139
    </extension>
1040
</plugin>
1140
</plugin>
(-)src/org/eclipse/hyades/trace/internal/ui/PDProjectExplorer.java (+10 lines)
Lines 76-81 Link Here
76
import org.eclipse.ui.IViewPart;
76
import org.eclipse.ui.IViewPart;
77
import org.eclipse.ui.IWorkbenchPart;
77
import org.eclipse.ui.IWorkbenchPart;
78
import org.eclipse.ui.actions.ActionContext;
78
import org.eclipse.ui.actions.ActionContext;
79
import org.eclipse.ui.contexts.IContextService;
79
import org.eclipse.ui.plugin.AbstractUIPlugin;
80
import org.eclipse.ui.plugin.AbstractUIPlugin;
80
81
81
public class PDProjectExplorer extends Navigator  implements IProfileEventListener
82
public class PDProjectExplorer extends Navigator  implements IProfileEventListener
Lines 250-255 Link Here
250
		super(ID);
251
		super(ID);
251
		
252
		
252
		traceControlItemManager = new TraceControlItemManager(this);
253
		traceControlItemManager = new TraceControlItemManager(this);
254
//		traceControlItemManager.setSite(getSite());
253
		
255
		
254
		/* set project explorer to resource helper such that it can be notified dirty for save */
256
		/* set project explorer to resource helper such that it can be notified dirty for save */
255
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
257
		Object ue = HierarchyResourceSetImpl.getInstance().getUnresolvedException();
Lines 273-280 Link Here
273
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
275
		UIPlugin.getDefault().addSelectionProvider(getViewer(), this);		
274
		UIPlugin.getDefault().addProfileEventListener(this);
276
		UIPlugin.getDefault().addProfileEventListener(this);
275
		
277
		
278
		activateContext();
279
		
276
		(new RefreshUI()).start();
280
		(new RefreshUI()).start();
277
	}
281
	}
282
	
283
284
	private void activateContext() {
285
		IContextService contextService = (IContextService) getSite().getService(IContextService.class);
286
		contextService.activateContext("org.eclipse.ui.TPTPMonitorContext");
287
	}
278
288
279
	/**
289
	/**
280
	 * Updates the action bar actions.
290
	 * Updates the action bar actions.
(-)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/TraceControlItemManager.java (-2 / +17 lines)
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
				if (controlItems[i] instanceof ControlItem &&
99
						((ControlItem)controlItems[i]).getCommandID()!=null &&
100
						((ControlItem)controlItems[i]).getHandler()!=null ) {
101
					IHandlerService handlerService = (IHandlerService) (((PDProjectExplorer)navigator).getSite().getService(IHandlerService.class));
102
//					ActionHandler handler = new ActionHandler(controlItems[i]);
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/provisional/control/provider/RefreshOption.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import java.util.Iterator;
14
15
import org.eclipse.hyades.trace.ui.ProfileEvent;
16
import org.eclipse.hyades.trace.ui.UIPlugin;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
20
import org.eclipse.tptp.trace.ui.provisional.control.provider.ControlItem;
21
22
public class RefreshOption extends ControlItem {
23
24
	private static final String REFRESH_OPTION = "org.eclipse.tptp.platform.instrumentation.ui.internal.control.provider.application.RefreshOption";
25
	
26
	public RefreshOption()
27
	{
28
		super (REFRESH_OPTION, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_OPTION, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_OPTIONS));
29
	}
30
	
31
	/* This method is invoked when ever user clicks the 'Change Refresh Options' button.
32
	 * It simply invokes the 'handleProfileEvent' method of PDProjectExplorer */
33
	public void run()
34
	{
35
		if (input == null)
36
			return;
37
		
38
		for (Iterator sources = input.iterator(); sources.hasNext();)
39
		{					
40
			ProfileEvent event = UIPlugin.getDefault().getRefreshOptionEvent(sources.next());
41
			UIPlugin.getDefault().notifyProfileEventListener(event);
42
		}
43
	}
44
}
45
	
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshViewHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class RefreshViewHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public RefreshViewHandler(IAction refreshView) {
27
		super();
28
		this.action = refreshView;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/PauseControlItem.java (+54 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
16
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
17
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
18
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
19
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
20
21
public class PauseControlItem extends AgentControlItem {
22
	
23
	private static final String PAUSE_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.PauseControlItem";
24
	private static IAgentStateModifier _agentStateModifier;
25
	
26
	public PauseControlItem(IAgentStateModifier agentStateModifier)
27
	{
28
		super(agentStateModifier, PAUSE_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_PAUSE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_PAUSE));
29
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_PAUSE));
30
		_agentStateModifier = agentStateModifier; 
31
	}
32
	
33
	public void run()
34
	{
35
		IAgentStateModifier agentStateModifier = _agentStateModifier;
36
									
37
		try
38
		{
39
			/* Pause the agent */					
40
			if(isEnabled())
41
				agentStateModifier.pauseMonitoring();
42
		} catch (CoreException e)
43
		{
44
			/* Display status */
45
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
46
		}				
47
	}
48
	
49
	public boolean isEnabled()
50
	{
51
		return _agentStateModifier.canPause();
52
	}		
53
54
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AttachControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class AttachControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public AttachControlItemHandler(IAction attachAction) {
27
		super();
28
		this.action = attachAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/AttachControlItem.java (+52 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class AttachControlItem extends AgentControlItem {
21
22
	private static final String ATTACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.AttachControlItem";
23
	private IAgentStateModifier _agentStateModifier; 
24
	
25
	public AttachControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, ATTACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_ATTACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_ATTACH_AGENT));
29
		_agentStateModifier = agentStateModifier; 
30
	}
31
		
32
	public void run()
33
	{
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
										
36
		try
37
		{
38
			/* attach to the agent */					
39
			if (isEnabled())
40
				agentStateModifier.attach();
41
		} catch (CoreException e)
42
		{
43
			/* Display status */
44
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
45
		}				
46
	}
47
		
48
	public boolean isEnabled()
49
	{
50
		return _agentStateModifier.canAttach();
51
	}			
52
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/TerminateAction.java (+71 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.jface.viewers.StructuredSelection;
16
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
17
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
18
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
19
20
public class TerminateAction extends ControlItem {
21
22
	private IProcessStateModifier _processStateModifier;
23
	private static final String TERMINATE_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.TerminateAction";
24
	
25
		public TerminateAction(IProcessStateModifier processStateModifier)
26
		{
27
			super (TERMINATE_ITEM, CommonUITraceConstants.PROFILE_TERMINATE_GROUP, ControlMessages.CONTROL_ITEM_TERMINATE, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_TERMINATE));
28
			setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_TERMINATE));
29
			_processStateModifier = processStateModifier;
30
		}
31
		
32
		public void run()
33
		{
34
										
35
			try
36
			{
37
				/* Terminate the process */
38
				if(isEnabled())
39
					_processStateModifier.terminate();
40
			} catch (CoreException e)
41
			{
42
				/* Display status */
43
				LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
44
			}				
45
		}
46
		
47
		public boolean isEnabled()
48
		{
49
			return _processStateModifier.canTerminate();
50
		}
51
		
52
		public void setInput(StructuredSelection input)
53
		{
54
			_processStateModifier.setInput(input);
55
		}
56
		
57
		public IProcessStateModifier getStateModifier()
58
		{
59
			return _processStateModifier;
60
		}
61
		
62
		public boolean equals (Object o)
63
		{
64
			if (!(o instanceof TerminateAction))
65
				return false;
66
			
67
			return _processStateModifier == ((TerminateAction)o).getStateModifier() && super.equals(o);
68
		}
69
70
71
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/DetachControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class DetachControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public DetachControlItemHandler(IAction detachAction) {
27
		super();
28
		this.action = detachAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/TerminateControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class TerminateControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public TerminateControlItemHandler(IAction terminateAction) {
27
		super();
28
		this.action = terminateAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResumeControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class ResumeControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public ResumeControlItemHandler(IAction resumeAction) {
27
		super();
28
		this.action = resumeAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/ResumeControlItem.java (+53 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class ResumeControlItem extends AgentControlItem {
21
	
22
	private static String START_MONITORING = "org.eclipse.tptp.trace.ui.provisional.control.provider.ResumeControlItem"; 
23
	private IAgentStateModifier _agentStateModifier; 
24
25
	public ResumeControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, START_MONITORING, CommonUITraceConstants.PROFILE_MONITOR_GROUP, ControlMessages.CONTROL_ITEM_RESUME, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_RESUME));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_RESUME));
29
		_agentStateModifier = agentStateModifier;
30
	}
31
	
32
	public void run()
33
	{
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
									
36
		try
37
		{
38
			/* Resume the agent */
39
			if(isEnabled())
40
				agentStateModifier.startMonitoring();
41
		} catch (CoreException e)
42
		{
43
			/* Display status */
44
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
45
		}				
46
	}
47
	
48
	public boolean isEnabled()
49
	{
50
		return _agentStateModifier.canResume();
51
	}	
52
53
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/RefreshView.java (+41 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import java.util.Iterator;
14
15
import org.eclipse.hyades.trace.ui.ProfileEvent;
16
import org.eclipse.hyades.trace.ui.UIPlugin;
17
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
18
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
19
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
20
21
public class RefreshView extends ControlItem {
22
 	
23
	private static final String REFRESH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.RefreshView";
24
	
25
	public RefreshView()
26
	{
27
		super (REFRESH_ITEM, CommonUITraceConstants.PROFILE_REFRESH_GROUP, ControlMessages.CONTROL_ITEM_REFRESH_VIEWS, TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_REFRESH_VIEWS));
28
	}
29
		
30
	public void run()
31
	{
32
		if (input == null)
33
			return;
34
			
35
		for (Iterator sources = input.iterator(); sources.hasNext();)
36
		{					
37
			ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(sources.next());
38
			UIPlugin.getDefault().notifyProfileEventListener(event);
39
		}
40
	}
41
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/DetachControlItem.java (+53 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
package org.eclipse.tptp.trace.ui.provisional.control.provider;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.hyades.trace.ui.internal.core.TraceUIImages;
15
import org.eclipse.tptp.platform.common.ui.trace.internal.CommonUITraceConstants;
16
import org.eclipse.tptp.trace.ui.internal.control.provider.application.ControlMessages;
17
import org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility;
18
import org.eclipse.tptp.trace.ui.provisional.control.provider.AbstractAgentControlProvider.AgentControlItem;
19
20
public class DetachControlItem extends AgentControlItem {
21
22
	public static final String DETACH_ITEM = "org.eclipse.tptp.trace.ui.provisional.control.provider.DetachControlItem";	
23
	private IAgentStateModifier _agentStateModifier; 
24
	
25
	public DetachControlItem(IAgentStateModifier agentStateModifier)
26
	{
27
		super(agentStateModifier, DETACH_ITEM, CommonUITraceConstants.PROFILE_ATTACH_GROUP, ControlMessages.CONTROL_ITEM_DETACH,  TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DETACH_AGENT));
28
		setDisabledImageDescriptor(TraceUIImages.INSTANCE.getImageDescriptor("d", TraceUIImages.IMG_DETACH_AGENT));
29
		_agentStateModifier = agentStateModifier; 
30
	}
31
		
32
	public void run()
33
	{
34
		IAgentStateModifier agentStateModifier = _agentStateModifier;
35
										
36
		try
37
		{
38
			/* detach the agent */					
39
			agentStateModifier.detach();
40
		} catch (CoreException e)
41
		{
42
			/* Display status */
43
			LauncherUtility.openMessageWithDetail(e.getStatus().getSeverity(), "", e.getMessage(), e);
44
		}				
45
	}
46
		
47
	public boolean isEnabled()
48
	{
49
		return _agentStateModifier.canDetach();
50
	}		
51
52
	
53
}
(-)src/org/eclipse/tptp/trace/ui/provisional/control/provider/PauseControlItemHandler.java (+45 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors: 
9
 * IBM - Initial API and implementation
10
 **********************************************************************/
11
12
package org.eclipse.tptp.trace.ui.provisional.control.provider;
13
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.swt.widgets.Event;
19
20
21
22
public class PauseControlItemHandler extends AbstractHandler {
23
24
	private IAction action;
25
	
26
	public PauseControlItemHandler(IAction pauseAction) {
27
		super();
28
		this.action = pauseAction;
29
		
30
	}
31
32
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
33
		if ((action.getStyle() == IAction.AS_CHECK_BOX)
34
				|| (action.getStyle() == IAction.AS_RADIO_BUTTON)) {
35
			action.setChecked(!action.isChecked());
36
		}
37
		try {
38
				action.runWithEvent(new Event());
39
		} catch (Exception e) {
40
			throw new ExecutionException("", e); //$NON-NLS-1$
41
		}
42
		
43
		return null;
44
	}
45
}

Return to bug 140650