Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 65979 Details for
Bug 171287
Managed Agent Explorer does not Call the StopMonitoring Method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Restricts context menu items to attach and detach - calls agent detach and removes agent
171287.patch (text/plain), 14.36 KB, created by
Balan Subramanian
on 2007-05-04 18:55:52 EDT
(
hide
)
Description:
Restricts context menu items to attach and detach - calls agent detach and removes agent
Filename:
MIME Type:
Creator:
Balan Subramanian
Created:
2007-05-04 18:55:52 EDT
Size:
14.36 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.monitoring.managedagent >Index: src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedResourceAgentControlProvider.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.managedagent/src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedResourceAgentControlProvider.java,v >retrieving revision 1.8 >diff -u -r1.8 ManagedResourceAgentControlProvider.java >--- src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedResourceAgentControlProvider.java 19 Apr 2007 14:15:34 -0000 1.8 >+++ src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedResourceAgentControlProvider.java 4 May 2007 22:55:22 -0000 >@@ -23,10 +23,6 @@ > import org.eclipse.ui.IViewPart; > import org.eclipse.ui.IWorkbenchPart; > >-/** >- * The control provider for the PI agent >- * @author Ali Mehregani >- */ > public class ManagedResourceAgentControlProvider extends AbstractAgentControlProvider > { > /** The id of the contributed items */ >@@ -34,9 +30,7 @@ > private static final String REMOVE_ITEM = "org.eclipse.tptp.monitoring.managedagent.wsdm.internal.popupMenu.remove"; //$NON-NLS-1$ > > /** The agent state modifier */ >- private IControlItem connectControlItem; >- private IControlItem removeControlItem; >- private IAgentStateModifier agentStateModifier; >+ private ManagedAgentStateModifier agentStateModifier; > > public ManagedResourceAgentControlProvider() > { >@@ -46,214 +40,11 @@ > > protected void initializeControlItems() > { >- addControlItem(createConnectControlItem()); >- addControlItem(createRemoveControlItem()); >+ //addControlItem(createConnectControlItem()); >+ addControlItem(createAttachControlItem()); >+ addControlItem(createDetachControlItem()); > } > >- >-// public IAgentStateModifier getAgentStateModifier() >-// { >-// return null; >-// if (stateModifier != null) >-// return stateModifier; >-// >-// stateModifier = new IAgentStateModifier() >-// { >-// >-// /** >-// * Display a message that indicates that the detach option >-// * has been invoked. >-// */ >-// public void detach() throws CoreException >-// { >-// showMessage("Detach option is invoked"); >-// } >-// >-// /** >-// * Display a message that indicates that the attach option >-// * has been invoked. >-// */ >-// public void attach() throws CoreException >-// { >-// showMessage("Attach option is invoked"); >-// } >-// >-// /** >-// * Display a message that indicates that the resume option >-// * has been invoked. >-// */ >-// public void startMonitoring() throws CoreException >-// { >-// showMessage("Resume option is invoked"); >-// } >-// >-// /** >-// * Display a message that indicates that the pause option >-// * has been invoked. >-// */ >-// public void pauseMonitoring() throws CoreException >-// { >-// showMessage("Pause option is invoked"); >-// } >-// >-// >-// /** >-// * Returning true will always ensure that teh attach >-// * option will always be enabled. >-// */ >-// public boolean canAttach() >-// { >-// return true; >-// } >-// >-// /** >-// * Returning true will always ensure that teh attach >-// * option will always be enabled. >-// */ >-// public boolean canDetach() >-// { >-// return true; >-// } >-// >-// /** >-// * Returning true will always ensure that teh attach >-// * option will always be enabled. >-// */ >-// public boolean canResume() >-// { >-// return true; >-// } >-// >-// /** >-// * Returning true will always ensure that teh attach >-// * option will always be enabled. >-// */ >-// public boolean canPause() >-// { >-// return true; >-// } >-// >-// public void setInput(StructuredSelection input) >-// { >-// } >-// >-// /** >-// * Opens a message dialog with the message passed in. >-// */ >-// private void showMessage(String message) >-// { >-// >-// } >-// }; >-// >-// return stateModifier; >-// } >- >- >- protected IControlItem createConnectControlItem() >- { >- if (connectControlItem != null) >- return connectControlItem; >- >- connectControlItem = new ConnectControlItem(); >- return connectControlItem; >- } >- >- protected IControlItem createRemoveControlItem() >- { >- if (removeControlItem != null) >- return removeControlItem; >- >- removeControlItem = new RemoveControlItem(); >- return removeControlItem; >- } >- >- public static class ConnectControlItem extends ControlItem >- { >- //CollectObjRefAction collectObjRef; >- public ConnectControlItem() >- { >- 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$ >- //collectObjRef = new CollectObjRefAction(); >- >- IWorkbenchPart part = UIPlugin.getActiveWorkbenchWindow().getActivePage().getActivePart(); >- part = (part == null || !(part instanceof IViewPart)) ? part = UIPlugin.getDefault().getViewer() : part; >- /*if (part instanceof IViewPart) >- collectObjRef.init((IViewPart)part); >- */ >- } >- >- public void run() >- { >- try >- { >- /*for (Iterator agents = input.iterator(); agents.hasNext();) >- collectObjRef.doAction(agents.next());*/ >- } >- catch (Exception e) >- { >- LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e); //$NON-NLS-1$ >- } >- } >- >- >- public boolean isEnabled() >- { >-// if (input == null || input.size() == 0) >-// return false; >- >- boolean isEnable = true; >- /*for (Iterator agents = input.iterator(); isEnable && agents.hasNext();) >- isEnable = isEnable && collectObjRef.isEnabledFor(agents.next());*/ >- return isEnable; >- } >- >- } >- >- >- public static class RemoveControlItem extends ControlItem >- { >- //private RunGCAction gcAction; >- public RemoveControlItem() >- { >- 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$ >- //gcAction = new RunGCAction(); >- >- IWorkbenchPart part = UIPlugin.getActiveWorkbenchWindow().getActivePage().getActivePart(); >- part = (part == null || !(part instanceof IViewPart)) ? part = UIPlugin.getDefault().getViewer() : part; >- /*if (part instanceof IViewPart) >- gcAction.init((IViewPart)part); >- */ >- } >- >- public void run() >- { >- try >- { >- /*for (Iterator agents = input.iterator(); agents.hasNext();) >- gcAction.doAction(agents.next());*/ >- } >- catch (Exception e) >- { >- LauncherUtility.openMessageWithDetail(IStatus.ERROR, "", e.getMessage(), e); //$NON-NLS-1$ >- } >- } >- >- >- public boolean isEnabled() >- { >- if (input == null || input.size() == 0) >- return false; >- >- boolean isEnable = true; >- /*for (Iterator agents = input.iterator(); isEnable && agents.hasNext();) >- isEnable = isEnable && gcAction.isEnabledFor(agents.next());*/ >- return isEnable; >- } >- >- } >- >- > public IAgentStateModifier getAgentStateModifier() { > return agentStateModifier; > } >Index: src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedAgentStateModifier.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.managedagent/src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedAgentStateModifier.java,v >retrieving revision 1.2 >diff -u -r1.2 ManagedAgentStateModifier.java >--- src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedAgentStateModifier.java 26 Mar 2007 12:35:38 -0000 1.2 >+++ src/org/eclipse/tptp/monitoring/managedagent/internal/ManagedAgentStateModifier.java 4 May 2007 22:55:22 -0000 >@@ -12,22 +12,83 @@ > package org.eclipse.tptp.monitoring.managedagent.internal; > > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.hyades.internal.execution.local.control.Agent; >+import org.eclipse.hyades.internal.execution.local.control.InactiveAgentException; >+import org.eclipse.hyades.internal.execution.local.control.InactiveProcessException; >+import org.eclipse.hyades.loaders.util.LoadersUtils; >+import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; >+import org.eclipse.hyades.models.hierarchy.impl.TRCAgentProxyImpl; >+import org.eclipse.hyades.trace.internal.ui.PDProjectExplorer; >+import org.eclipse.hyades.trace.ui.ProfileEvent; >+import org.eclipse.hyades.trace.ui.UIPlugin; >+import org.eclipse.hyades.trace.ui.internal.util.PDCoreUtil; > import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.swt.widgets.Display; > import org.eclipse.tptp.trace.ui.provisional.control.provider.IAgentStateModifier; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.part.ViewPart; > > public class ManagedAgentStateModifier implements IAgentStateModifier { >+ TRCAgentProxy _agentProxy = null; >+ Agent _agent = null; >+ >+ private static final String PROFILING_MONITORS_VIEW_ID = PDProjectExplorer.ID; > > public void attach() throws CoreException { >- System.out.println("Attach called!"); >+ try { >+ _agent.attach(); >+ } catch (InactiveAgentException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } catch (InactiveProcessException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ >+ public void detach() throws CoreException { >+ try { >+ _agent.detach(); >+ LoadersUtils.deregisterAgentInstance(_agentProxy); >+ //DeleteUtil.deleteAgent(_agentProxy, false, false, false, ""); >+ refreshView(); >+ } catch (Exception e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ >+ private void refreshView(){ >+ Display d = Display.getDefault(); >+ d.asyncExec(new Runnable(){ >+ public void run(){ >+ final ProfileEvent event = UIPlugin.getDefault().getProfileEvent(); >+ event.setSource(_agent); >+ event.setType(ProfileEvent.START_MONITOR); >+ UIPlugin.getDefault().notifyProfileEventListener(event); >+ } >+ }); >+ >+ >+ IWorkbench workbench= UIPlugin.getDefault().getWorkbench(); >+ IWorkbenchWindow window= workbench.getActiveWorkbenchWindow(); >+ IWorkbenchPage page= window.getActivePage(); >+ ViewPart view = (ViewPart) page.findView(PROFILING_MONITORS_VIEW_ID); > } > > public boolean canAttach() { >- // TODO Auto-generated method stub >+ if(_agent!=null){ >+ return !_agent.isAttached(); >+ } > return false; > } > > public boolean canDetach() { >- // TODO Auto-generated method stub >+ if(_agent!=null){ >+ return _agent.isAttached(); >+ } > return false; > } > >@@ -41,10 +102,6 @@ > return false; > } > >- public void detach() throws CoreException { >- // TODO Auto-generated method stub >- >- } > > public void pauseMonitoring() throws CoreException { > // TODO Auto-generated method stub >@@ -52,7 +109,15 @@ > } > > public void setInput(StructuredSelection arg0) { >- System.out.println("Input set to "+arg0); >+ try{ >+ _agentProxy = (TRCAgentProxyImpl) arg0.getFirstElement(); >+ }catch(Exception e){ >+ e.printStackTrace(); >+ _agentProxy = null; >+ } >+ if(_agentProxy!=null){ >+ _agent = getAgent(_agentProxy); >+ } > > } > >@@ -60,5 +125,37 @@ > // TODO Auto-generated method stub > > } >- >+ >+ private Agent getAgent(TRCAgentProxy proxy){ >+ Object instance = LoadersUtils.locateAgentInstance(proxy); >+ if (instance != null && instance instanceof Agent){ >+ return (Agent) instance; >+ }else{ >+ return null; >+ } >+ /*try >+ { >+ TRCProcessProxy process = proxy.getProcessProxy(); >+ String hostName = process.getNode().getName(); >+ Node node = PDCoreUtil.profileConnect(hostName, String >+ .valueOf(process.getNode().getPort())); >+ if (node == null) >+ { >+ return null; >+ } >+ >+ >+ >+ if (instance == null) >+ { >+ instance = PDCoreUtil.getAgentInstance(hostName, process >+ .getNode().getPort(), proxy); >+ } >+ >+ >+ }catch(Exception e){ >+ e.printStackTrace(); >+ return null; >+ }*/ >+ } > } >Index: src/org/eclipse/tptp/monitoring/managedagent/provisional/ManagedResourceAgent.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.managedagent/src/org/eclipse/tptp/monitoring/managedagent/provisional/ManagedResourceAgent.java,v >retrieving revision 1.6 >diff -u -r1.6 ManagedResourceAgent.java >--- src/org/eclipse/tptp/monitoring/managedagent/provisional/ManagedResourceAgent.java 21 Mar 2007 21:30:12 -0000 1.6 >+++ src/org/eclipse/tptp/monitoring/managedagent/provisional/ManagedResourceAgent.java 4 May 2007 22:55:22 -0000 >@@ -98,9 +98,15 @@ > public void setMonitored(boolean isMonitored) { } > public void setAttached(boolean isAttached) { } > public void startMonitoring(DataProcessor processor) throws InactiveAgentException { } >- public void stopMonitoring() throws InactiveAgentException { } >- public void attach() throws InactiveAgentException, InactiveProcessException { } >- public void detach() throws InactiveAgentException, InactiveProcessException { } >+ public void stopMonitoring() throws InactiveAgentException { >+ } >+ public void attach() throws InactiveAgentException, InactiveProcessException { >+ setActive(true); >+ } >+ public void detach() throws InactiveAgentException, InactiveProcessException { >+ stopMonitoring(); >+ setActive(false); >+ } > > /** > * Get the type of agent. This returns the static generic type of the agent to differentiate it >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.managedagent/plugin.xml,v >retrieving revision 1.11 >diff -u -r1.11 plugin.xml >--- plugin.xml 23 Mar 2007 17:55:20 -0000 1.11 >+++ plugin.xml 4 May 2007 22:55:22 -0000 >@@ -12,7 +12,7 @@ > point="org.eclipse.hyades.trace.ui.agentDeclaration"> > <agent > id="org.eclipse.tptp.monitoring.managedagent.ManagedResourceAgent" >- name="ManagedResourceAgent" >+ name="*" > type="ManagedAgent"/> > </extension> > <extension
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 171287
: 65979