Remote Systems
v6.4.1

com.ibm.etools.systems.core.ui.actions
Class SystemAbstractPopupMenuExtensionAction

java.lang.Object
  extended bycom.ibm.etools.systems.core.ui.actions.SystemAbstractPopupMenuExtensionAction
Direct Known Subclasses:
SystemAbstractRemoteFilePopupMenuExtensionAction, TestPopupMenuAction1

public abstract class SystemAbstractPopupMenuExtensionAction
extends Object

This is a base class to simplify the creation of actions supplied via the com.ibm.etools.systems.core.popupMenus extension point.

The only method you must implement is run(). You may optionally override getEnabled(Object[])

Convenience methods are:

See Also:
ISystemRemoteElementAdapter, SystemPromptDialog

Field Summary
static String copyright
           
protected static Object[] EMPTY_ARRAY
           
protected  IAction proxyAction
           
protected  IStructuredSelection sel
           
protected  Shell shell
           
protected  IWorkbenchPart viewPart
           
 
Constructor Summary
SystemAbstractPopupMenuExtensionAction()
          Constructor
 
Method Summary
 IWorkbenchPart getActivePart()
          Get the current view part.
protected  RemoteCmdSubSystem getCommandSubSystem()
          Internal method to find and return the associated command subsystem, for the purpose of issuing a remote command.
 boolean getEnabled(Object[] currentlySelected)
          The user has selected one or more objects.
 Object getFirstSelectedRemoteObject()
          Retrieve the first selected object, for convenience.
 ISystemRemoteElementAdapter getFirstSelectedRemoteObjectAdapter()
          Retrieve the adapter of the first selected object as an ISystemRemoteElementAdapter object, for convenience.
 IAction getProxyAction()
          Return the proxy action for this action delegate
 ISystemRemoteElementAdapter getRemoteAdapter(Object o)
          Returns the implementation of ISystemRemoteElementAdapter for the given object.
 String getRemoteObjectName(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the name of the given remote object, given its remote object adapter.
 String getRemoteObjectSubSubType(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the sub-subtype of the given remote object, given its remote object adapter.
 String getRemoteObjectSubSystemFactoryId(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the id of the subsystem factory of the given remote object, given its remote object adapter.
 String getRemoteObjectSubType(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the subtype of the given remote object, given its remote object adapter.
 String getRemoteObjectType(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the type of the given remote object, given its remote object adapter.
 String getRemoteObjectTypeCategory(Object obj, ISystemRemoteElementAdapter adapter)
          Returns the type category of the given remote object, given its remote object adapter.
 ISystemRemoteElementAdapter[] getSelectedRemoteObjectAdapters()
          Retrieve the adapters of the currently selected objects as an array of ISystemRemoteElementAdapter objects.
 Object[] getSelectedRemoteObjects()
          Retrieve the currently selected objects as an array of Object objects.
 IStructuredSelection getSelection()
          Retrieve the current selected objects as a structured selection
 int getSelectionCount()
          Retrieve the number of items currently selected
 Shell getShell()
          Return the shell hosting this action
 SubSystem getSubSystem()
          Returns the subsystem from which the selected remote objects were resolved.
 SubSystemFactory getSubSystemFactory()
          Returns the subsystem factory which owns the subsystem from which the selected remote objects were resolved
 SystemConnection getSystemConnection()
          Return the SystemConnection from which the selected remote objects were resolved
 String getWorkingDirectory(IRemoteFile selectedFile)
          Helper method to return the path to change-directory to, given a selected remote file object
Same as RemoteCommandHelpers.getWorkingDirectory(IRemoteFile)
 void printTest()
          Debug method to print out details of given selected object...
abstract  void run()
          The user has selected this action.
 void run(IAction action)
          The Eclipse-supplied proxy action has been selected to run.
 Object[] runCommand(String command)
          Execute a remote command.
 boolean runCommand(String cmdString, String path)
          This is a more flexible version of runCommand that allows explicitly specifying more options than the other flavor.
 void selectionChanged(IAction action, ISelection sel)
          Called by Eclipse when the user selects something.
 void setActivePart(IAction action, IWorkbenchPart part)
           
 void setChecked(boolean checked)
          For toggle actions (attribute state specified in action tag), set the toggle state
 void setEnabled(boolean enabled)
          Change the enabled state of the action
 void showInView(IRemoteCommandShell cmd)
          Show/log the given command in the commands view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

viewPart

protected IWorkbenchPart viewPart

sel

protected IStructuredSelection sel

proxyAction

protected IAction proxyAction

shell

protected Shell shell

EMPTY_ARRAY

protected static final Object[] EMPTY_ARRAY
Constructor Detail

SystemAbstractPopupMenuExtensionAction

public SystemAbstractPopupMenuExtensionAction()
Constructor

Method Detail

run

public abstract void run()
The user has selected this action. This is where the actual code for the action goes.


getEnabled

public boolean getEnabled(Object[] currentlySelected)
The user has selected one or more objects. This is an opportunity to enable/disable this action based on the current selection. By default, it is always enabled. Return false to disable it.


setActivePart

public void setActivePart(IAction action,
                          IWorkbenchPart part)
See Also:
IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)

getActivePart

public IWorkbenchPart getActivePart()
Get the current view part. Handy for things like getting the shell.


run

public void run(IAction action)
The Eclipse-supplied proxy action has been selected to run. This is the foreward to us, the actual action. This method's default implementation is to simply call run().

See Also:
IActionDelegate#run(IAction)

selectionChanged

public void selectionChanged(IAction action,
                             ISelection sel)
Called by Eclipse when the user selects something. Our opportunity to enable or disable this menu item. The default implementation of this method calls getEnabled to determine if the proxy action should be enabled or not, then calls setEnabled on that proxy action with the result.

See Also:
IActionDelegate#selectionChanged(IAction, ISelection)

setChecked

public void setChecked(boolean checked)
For toggle actions (attribute state specified in action tag), set the toggle state


setEnabled

public void setEnabled(boolean enabled)
Change the enabled state of the action


getProxyAction

public IAction getProxyAction()
Return the proxy action for this action delegate


getShell

public Shell getShell()
Return the shell hosting this action


getSelection

public IStructuredSelection getSelection()
Retrieve the current selected objects as a structured selection


getSelectionCount

public int getSelectionCount()
Retrieve the number of items currently selected


getSelectedRemoteObjects

public Object[] getSelectedRemoteObjects()
Retrieve the currently selected objects as an array of Object objects. Array may be length 0, but will never be null, for convenience. To do anything interesting with the object, you will also need to retrieve its adapter

See Also:
getRemoteAdapter(Object)

getFirstSelectedRemoteObject

public Object getFirstSelectedRemoteObject()
Retrieve the first selected object, for convenience. Will be null if there is nothing selected To do anything interesting with the object, you will also need to retrieve its adapter

See Also:
getRemoteAdapter(Object)

getSelectedRemoteObjectAdapters

public ISystemRemoteElementAdapter[] getSelectedRemoteObjectAdapters()
Retrieve the adapters of the currently selected objects as an array of ISystemRemoteElementAdapter objects. Array may be length 0, but will never be null, for convenience.


getFirstSelectedRemoteObjectAdapter

public ISystemRemoteElementAdapter getFirstSelectedRemoteObjectAdapter()
Retrieve the adapter of the first selected object as an ISystemRemoteElementAdapter object, for convenience. Will be null if there is nothing selected


getRemoteAdapter

public ISystemRemoteElementAdapter getRemoteAdapter(Object o)
Returns the implementation of ISystemRemoteElementAdapter for the given object. Returns null if this object does not adaptable to this.


getRemoteObjectName

public String getRemoteObjectName(Object obj,
                                  ISystemRemoteElementAdapter adapter)
Returns the name of the given remote object, given its remote object adapter. Same as adapter.getName(obj);


getRemoteObjectSubSystemFactoryId

public String getRemoteObjectSubSystemFactoryId(Object obj,
                                                ISystemRemoteElementAdapter adapter)
Returns the id of the subsystem factory of the given remote object, given its remote object adapter. Same as adapter.getSubSystemFactoryId(obj);


getRemoteObjectTypeCategory

public String getRemoteObjectTypeCategory(Object obj,
                                          ISystemRemoteElementAdapter adapter)
Returns the type category of the given remote object, given its remote object adapter. Same as adapter.getRemoteTypeCategory(obj);


getRemoteObjectType

public String getRemoteObjectType(Object obj,
                                  ISystemRemoteElementAdapter adapter)
Returns the type of the given remote object, given its remote object adapter. Same as adapter.getRemoteType(obj);


getRemoteObjectSubType

public String getRemoteObjectSubType(Object obj,
                                     ISystemRemoteElementAdapter adapter)
Returns the subtype of the given remote object, given its remote object adapter. Same as adapter.getRemoteSubType(obj);


getRemoteObjectSubSubType

public String getRemoteObjectSubSubType(Object obj,
                                        ISystemRemoteElementAdapter adapter)
Returns the sub-subtype of the given remote object, given its remote object adapter. Same as adapter.getRemoteSubSubType(obj);


getSubSystem

public SubSystem getSubSystem()
Returns the subsystem from which the selected remote objects were resolved.


getSubSystemFactory

public SubSystemFactory getSubSystemFactory()
Returns the subsystem factory which owns the subsystem from which the selected remote objects were resolved


getSystemConnection

public SystemConnection getSystemConnection()
Return the SystemConnection from which the selected remote objects were resolved


runCommand

public Object[] runCommand(String command)
Execute a remote command. What this does is find the associated command subsystem for the remote objects, and submit the command to it to be run. The command and its results are logged in the command console view, for the user to see. If an exception occurs for some reason, it is shown to the user, and null is returned. Otherwise an array of objects is returned, typically representing messages issued by the remote command shell. If no messages are issued, an array of length zero is returned, as opposed to null when something goes wrong.

This flavour will start a new shell to run the command, and will not set the current directory. See also runCommand(String,String).

Parameters:
command - Command to be executed remotely.
Returns:
Array of objects that are the result of running this command. Typically, these are messages logged by the command. Actually, this is usually an empty Object array if successful, and null if not successful. It is only here for historical reasons.

getWorkingDirectory

public String getWorkingDirectory(IRemoteFile selectedFile)
Helper method to return the path to change-directory to, given a selected remote file object
Same as RemoteCommandHelpers.getWorkingDirectory(IRemoteFile)


runCommand

public boolean runCommand(String cmdString,
                          String path)
This is a more flexible version of runCommand that allows explicitly specifying more options than the other flavor.
Specifically, this is an encapsulation of code needed to run a universal subsystem command. A universal command is a command that runs in a Unix or Linux or Windows command shell, as opposed to something unique like an OS/400 or z/OS command. This:

Same as RemoteCommandHelpers.runUniversalCommand(Shell,String,String,RemoteCmdSubSystem)

Parameters:
cmdString - - the resolved command
path - - the path to run the command against. Can be absolute or relative or null. This will become the current directory. See getWorkingDirectory(IRemoteFile)
Returns:
true if we should continue, false if something went wrong
See Also:
getWorkingDirectory(IRemoteFile)

showInView

public void showInView(IRemoteCommandShell cmd)
Show/log the given command in the commands view.
This is done for you if you call one the runCommand methods.
Same as RemoteCommandHelpers.showInView(IRemoteCommandShell)


getCommandSubSystem

protected RemoteCmdSubSystem getCommandSubSystem()
Internal method to find and return the associated command subsystem, for the purpose of issuing a remote command. This is just a shortcut to getSubSystem().getCommandSubSystem()


printTest

public void printTest()
Debug method to print out details of given selected object...


Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.