|
Lines 23-32
Link Here
|
| 23 |
import org.eclipse.ui.IViewPart; |
23 |
import org.eclipse.ui.IViewPart; |
| 24 |
import org.eclipse.ui.IWorkbenchPart; |
24 |
import org.eclipse.ui.IWorkbenchPart; |
| 25 |
|
25 |
|
| 26 |
/** |
|
|
| 27 |
* The control provider for the PI agent |
| 28 |
* @author Ali Mehregani |
| 29 |
*/ |
| 30 |
public class ManagedResourceAgentControlProvider extends AbstractAgentControlProvider |
26 |
public class ManagedResourceAgentControlProvider extends AbstractAgentControlProvider |
| 31 |
{ |
27 |
{ |
| 32 |
/** The id of the contributed items */ |
28 |
/** The id of the contributed items */ |
|
Lines 34-42
Link Here
|
| 34 |
private static final String REMOVE_ITEM = "org.eclipse.tptp.monitoring.managedagent.wsdm.internal.popupMenu.remove"; //$NON-NLS-1$ |
30 |
private static final String REMOVE_ITEM = "org.eclipse.tptp.monitoring.managedagent.wsdm.internal.popupMenu.remove"; //$NON-NLS-1$ |
| 35 |
|
31 |
|
| 36 |
/** The agent state modifier */ |
32 |
/** The agent state modifier */ |
| 37 |
private IControlItem connectControlItem; |
33 |
private ManagedAgentStateModifier agentStateModifier; |
| 38 |
private IControlItem removeControlItem; |
|
|
| 39 |
private IAgentStateModifier agentStateModifier; |
| 40 |
|
34 |
|
| 41 |
public ManagedResourceAgentControlProvider() |
35 |
public ManagedResourceAgentControlProvider() |
| 42 |
{ |
36 |
{ |
|
Lines 46-259
Link Here
|
| 46 |
|
40 |
|
| 47 |
protected void initializeControlItems() |
41 |
protected void initializeControlItems() |
| 48 |
{ |
42 |
{ |
| 49 |
addControlItem(createConnectControlItem()); |
43 |
//addControlItem(createConnectControlItem()); |
| 50 |
addControlItem(createRemoveControlItem()); |
44 |
addControlItem(createAttachControlItem()); |
|
|
45 |
addControlItem(createDetachControlItem()); |
| 51 |
} |
46 |
} |
| 52 |
|
47 |
|
| 53 |
|
|
|
| 54 |
// public IAgentStateModifier getAgentStateModifier() |
| 55 |
// { |
| 56 |
// return null; |
| 57 |
// if (stateModifier != null) |
| 58 |
// return stateModifier; |
| 59 |
// |
| 60 |
// stateModifier = new IAgentStateModifier() |
| 61 |
// { |
| 62 |
// |
| 63 |
// /** |
| 64 |
// * Display a message that indicates that the detach option |
| 65 |
// * has been invoked. |
| 66 |
// */ |
| 67 |
// public void detach() throws CoreException |
| 68 |
// { |
| 69 |
// showMessage("Detach option is invoked"); |
| 70 |
// } |
| 71 |
// |
| 72 |
// /** |
| 73 |
// * Display a message that indicates that the attach option |
| 74 |
// * has been invoked. |
| 75 |
// */ |
| 76 |
// public void attach() throws CoreException |
| 77 |
// { |
| 78 |
// showMessage("Attach option is invoked"); |
| 79 |
// } |
| 80 |
// |
| 81 |
// /** |
| 82 |
// * Display a message that indicates that the resume option |
| 83 |
// * has been invoked. |
| 84 |
// */ |
| 85 |
// public void startMonitoring() throws CoreException |
| 86 |
// { |
| 87 |
// showMessage("Resume option is invoked"); |
| 88 |
// } |
| 89 |
// |
| 90 |
// /** |
| 91 |
// * Display a message that indicates that the pause option |
| 92 |
// * has been invoked. |
| 93 |
// */ |
| 94 |
// public void pauseMonitoring() throws CoreException |
| 95 |
// { |
| 96 |
// showMessage("Pause option is invoked"); |
| 97 |
// } |
| 98 |
// |
| 99 |
// |
| 100 |
// /** |
| 101 |
// * Returning true will always ensure that teh attach |
| 102 |
// * option will always be enabled. |
| 103 |
// */ |
| 104 |
// public boolean canAttach() |
| 105 |
// { |
| 106 |
// return true; |
| 107 |
// } |
| 108 |
// |
| 109 |
// /** |
| 110 |
// * Returning true will always ensure that teh attach |
| 111 |
// * option will always be enabled. |
| 112 |
// */ |
| 113 |
// public boolean canDetach() |
| 114 |
// { |
| 115 |
// return true; |
| 116 |
// } |
| 117 |
// |
| 118 |
// /** |
| 119 |
// * Returning true will always ensure that teh attach |
| 120 |
// * option will always be enabled. |
| 121 |
// */ |
| 122 |
// public boolean canResume() |
| 123 |
// { |
| 124 |
// return true; |
| 125 |
// } |
| 126 |
// |
| 127 |
// /** |
| 128 |
// * Returning true will always ensure that teh attach |
| 129 |
// * option will always be enabled. |
| 130 |
// */ |
| 131 |
// public boolean canPause() |
| 132 |
// { |
| 133 |
// return true; |
| 134 |
// } |
| 135 |
// |
| 136 |
// public void setInput(StructuredSelection input) |
| 137 |
// { |
| 138 |
// } |
| 139 |
// |
| 140 |
// /** |
| 141 |
// * Opens a message dialog with the message passed in. |
| 142 |
// */ |
| 143 |
// private void showMessage(String message) |
| 144 |
// { |
| 145 |
// |
| 146 |
// } |
| 147 |
// }; |
| 148 |
// |
| 149 |
// return stateModifier; |
| 150 |
// } |
| 151 |
|
| 152 |
|
| 153 |
protected IControlItem createConnectControlItem() |
| 154 |
{ |
| 155 |
if (connectControlItem != null) |
| 156 |
return connectControlItem; |
| 157 |
|
| 158 |
connectControlItem = new ConnectControlItem(); |
| 159 |
return connectControlItem; |
| 160 |
} |
| 161 |
|
| 162 |
protected IControlItem createRemoveControlItem() |
| 163 |
{ |
| 164 |
if (removeControlItem != null) |
| 165 |
return removeControlItem; |
| 166 |
|
| 167 |
removeControlItem = new RemoveControlItem(); |
| 168 |
return removeControlItem; |
| 169 |
} |
| 170 |
|
| 171 |
public static class ConnectControlItem extends ControlItem |
| 172 |
{ |
| 173 |
//CollectObjRefAction collectObjRef; |
| 174 |
public ConnectControlItem() |
| 175 |
{ |
| 176 |
super(CONNECT_ITEM, Messages.getString("ManagedResourceAgentControlProvider.MANAGED_AGENT"), Messages.getString("ManagedResourceAgentControlProvider.CONNECT.UI."), TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_DUMP)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 177 |
//collectObjRef = new CollectObjRefAction(); |
| 178 |
|
| 179 |
IWorkbenchPart part = UIPlugin.getActiveWorkbenchWindow().getActivePage().getActivePart(); |
| 180 |
part = (part == null || !(part instanceof IViewPart)) ? part = UIPlugin.getDefault().getViewer() : part; |
| 181 |
/*if (part instanceof IViewPart) |
| 182 |
collectObjRef.init((IViewPart)part); |
| 183 |
*/ |
| 184 |
} |
| 185 |
|
| 186 |
public void run() |
| 187 |
{ |
| 188 |
try |
| 189 |
{ |
| 190 |
/*for (Iterator agents = input.iterator(); agents.hasNext();) |
| 191 |
collectObjRef.doAction(agents.next());*/ |
| 192 |
} |
| 193 |
catch (Exception e) |
| 194 |
{ |
| 195 |
LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e); //$NON-NLS-1$ |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
|
| 200 |
public boolean isEnabled() |
| 201 |
{ |
| 202 |
// if (input == null || input.size() == 0) |
| 203 |
// return false; |
| 204 |
|
| 205 |
boolean isEnable = true; |
| 206 |
/*for (Iterator agents = input.iterator(); isEnable && agents.hasNext();) |
| 207 |
isEnable = isEnable && collectObjRef.isEnabledFor(agents.next());*/ |
| 208 |
return isEnable; |
| 209 |
} |
| 210 |
|
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
public static class RemoveControlItem extends ControlItem |
| 215 |
{ |
| 216 |
//private RunGCAction gcAction; |
| 217 |
public RemoveControlItem() |
| 218 |
{ |
| 219 |
super(REMOVE_ITEM, CommonUITraceConstants.PROFILE_GC_GROUP, Messages.getString("ManagedResourceAgentControlProvider.REMOVE.UI."), TraceUIImages.INSTANCE.getImageDescriptor("c", TraceUIImages.IMG_GC)); //$NON-NLS-1$ //$NON-NLS-2$ |
| 220 |
//gcAction = new RunGCAction(); |
| 221 |
|
| 222 |
IWorkbenchPart part = UIPlugin.getActiveWorkbenchWindow().getActivePage().getActivePart(); |
| 223 |
part = (part == null || !(part instanceof IViewPart)) ? part = UIPlugin.getDefault().getViewer() : part; |
| 224 |
/*if (part instanceof IViewPart) |
| 225 |
gcAction.init((IViewPart)part); |
| 226 |
*/ |
| 227 |
} |
| 228 |
|
| 229 |
public void run() |
| 230 |
{ |
| 231 |
try |
| 232 |
{ |
| 233 |
/*for (Iterator agents = input.iterator(); agents.hasNext();) |
| 234 |
gcAction.doAction(agents.next());*/ |
| 235 |
} |
| 236 |
catch (Exception e) |
| 237 |
{ |
| 238 |
LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e); //$NON-NLS-1$ |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
public boolean isEnabled() |
| 244 |
{ |
| 245 |
if (input == null || input.size() == 0) |
| 246 |
return false; |
| 247 |
|
| 248 |
boolean isEnable = true; |
| 249 |
/*for (Iterator agents = input.iterator(); isEnable && agents.hasNext();) |
| 250 |
isEnable = isEnable && gcAction.isEnabledFor(agents.next());*/ |
| 251 |
return isEnable; |
| 252 |
} |
| 253 |
|
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
public IAgentStateModifier getAgentStateModifier() { |
48 |
public IAgentStateModifier getAgentStateModifier() { |
| 258 |
return agentStateModifier; |
49 |
return agentStateModifier; |
| 259 |
} |
50 |
} |