|
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 |
} |