Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.remotebuild
Class BuildActionDelegate

java.lang.Object
  extended by com.ibm.etools.iseries.remotebuild.BuildActionDelegate
Direct Known Subclasses:
RemoteAction

public abstract class BuildActionDelegate
extends Object

Implements an action delegate that will invoke a set of actions on behalf of a selection made in the iSeries Project Navigator. The selection for this action is expected to be any number of resources associated with a single iSeries project.

Build style providers should subclass this class for their actions.


Field Summary
static String Copyright
           
 
Constructor Summary
BuildActionDelegate()
          Create a new BuildActionDelegate.
 
Method Summary
protected  boolean checkDirtyEditors()
          Check all editors and presents a dialog requesting the user to save any dirty ones.
protected abstract  void checkSelection()
          Checks the selection to see if it applies to this action.
protected  IWorkbenchPart getActivePart()
          Returns the active workbench part on which this action was invoked.
protected  IBMiConnection getConnection()
          Returns the connection relevant to this resource.
protected  AbstractISeriesProject getModelProject()
          Returns the model project if there is exactly one covered by the selection.
protected  AbstractISeriesProject getModelProject(AbstractISeriesResource resource)
          Returns the AbstractISeriesProject associated with an AbstractISeriesResource.
protected  AbstractISeriesProject[] getModelProjects()
          Returns an array of model projects that covers the selection.
protected  RBProject getProject()
          Returns the RBProject resource derived from this selection.
protected  RBProject[] getProjects()
          Returns an array of RBProject that cover the selection.
protected  IStructuredSelection getSelection()
          Returns the current selection if any has been made.
protected  Shell getShell()
          Returns the shell associated with the part in which the selection occurs.
 RBStatus getStatus()
          Returns the status of this operation.
protected  String getTaskName()
           
protected  IWorkbenchWindow getWorkbenchWindow()
          Retrieves the IWorkbenchWindow which can be as a IRunnableContext for operations if such a context is desired.
protected abstract  void handleActionException(Exception exception)
          Handles the Exception that may be raised during the performance of the action.
protected  void initialize()
          Performs any initialization prior to running actions.
 boolean isCanceled()
          Tests the canceled state of this operation.
protected  RBStatus performAction()
           Performs the actual work of this operation.
protected  RBStatus performAction(IProgressMonitor monitor)
           Performs the actual work of this operation.
protected  void performPostActions(IProgressMonitor monitor)
          Performs post-action operations.
protected  void performPreActions(IProgressMonitor monitor)
          Performs pre-action operations.
 void run(IAction action)
          Runs the steps required to complete the action.
protected  void runWorkspaceOperation(Runnable runnable)
          Runs a runnable that is part of a normal action inside a workspace modification envelope.
 void selectionChanged(IAction action, ISelection selection)
          Selection has changed.
 boolean selectionIsProject()
          Tests if the selection is exactly one project.
 boolean selectionIsProjects()
          Tests if the selection is only projects.
 void setActivePart(IAction action, IWorkbenchPart part)
          Set the workbench part that is requesting the action.
protected  void setCanceled(boolean canceled)
          Sets the canceled state of this operation.
protected  void setEnabled(boolean enabled)
          Sets the enabled state for the action that invoked this delegate.
 void showStatusMessage(RBStatus status)
          Shows a status message and asks whether to cancel the operation.
 void showSystemMessage(SystemMessage message)
          Shows a system message in a standard system message dialog.
 void showSystemMessageInUI(SystemMessage message)
          Shows a system message from any thread.
protected  void terminate()
          Performs any termination prior to ending the action.
 
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
Constructor Detail

BuildActionDelegate

public BuildActionDelegate()
Create a new BuildActionDelegate.

Method Detail

checkDirtyEditors

protected boolean checkDirtyEditors()
Check all editors and presents a dialog requesting the user to save any dirty ones.

Returns:
true if the user say OK to the dialog, false if the user cancels the dialog.

setEnabled

protected final void setEnabled(boolean enabled)
Sets the enabled state for the action that invoked this delegate. Should be invoked during checkSelection processing.

For use by subclasses.


getSelection

protected final IStructuredSelection getSelection()
Returns the current selection if any has been made. The current selection is set on selectionChanged and remains in effect until the next one. Returns null if no selection has yet been made.

For use by subclasses.


getActivePart

protected final IWorkbenchPart getActivePart()
Returns the active workbench part on which this action was invoked. This can then be used to get the current view and to determine the current page that is showing.

For use by subclasses.


getShell

protected final Shell getShell()
Returns the shell associated with the part in which the selection occurs.

A convenience method for use by subclasses. Can be used to get the shell for progress monitors.


getWorkbenchWindow

protected final IWorkbenchWindow getWorkbenchWindow()
Retrieves the IWorkbenchWindow which can be as a IRunnableContext for operations if such a context is desired. This context should be used for obtaining progress monitors for the operation as necessary.

Returns:
an IWorkbenchWindow

getModelProject

protected final AbstractISeriesProject getModelProject(AbstractISeriesResource resource)
Returns the AbstractISeriesProject associated with an AbstractISeriesResource. All resources capable of being selected can return this. An AbstractISeriesProjectRoot, which cannot be in a selection, will return null.

For use by subclasses.


getModelProject

protected final AbstractISeriesProject getModelProject()
Returns the model project if there is exactly one covered by the selection. Returns null if there is none or more than one.

For use by subclasses.


getModelProjects

protected final AbstractISeriesProject[] getModelProjects()
Returns an array of model projects that covers the selection. This array may contain zero or more elements.

For use by subclasses.


getProject

protected final RBProject getProject()
Returns the RBProject resource derived from this selection.


getConnection

protected final IBMiConnection getConnection()
Returns the connection relevant to this resource. Returns null if the connection cannot be determined. This may happen if the connection name has changed, if the connection is moved or deleted from its profile, or if the profile of the connection is inactive.


getProjects

protected final RBProject[] getProjects()
Returns an array of RBProject that cover the selection.


getStatus

public final RBStatus getStatus()
Returns the status of this operation.

For use by clients testing this operation after it has finished.


setCanceled

protected final void setCanceled(boolean canceled)
Sets the canceled state of this operation. This will usually be done as the result of an error that prevents further processing or the testing of a progress monitor during the operation.

For use by subclasses.


isCanceled

public final boolean isCanceled()
Tests the canceled state of this operation.


selectionIsProject

public final boolean selectionIsProject()
Tests if the selection is exactly one project.


selectionIsProjects

public final boolean selectionIsProjects()
Tests if the selection is only projects.


initialize

protected void initialize()
Performs any initialization prior to running actions. Subclasses can call super and override.

See Also:
run(IAction)

performPreActions

protected void performPreActions(IProgressMonitor monitor)
Performs pre-action operations. Subclasses can call super and override.

PreActions are run only if the current status is OK and the action has not been canceled.

See Also:
run(IAction)

performAction

protected RBStatus performAction(IProgressMonitor monitor)

Performs the actual work of this operation. It is supplied a progress monitor. It can retrieve its structured selection using getSelection(). It can retrieve its project using getModelProject(). Any long running action should create a progress monitor from the context and periodically test the progress monitor and cancel if requested.

The action is cancelable and runs in the UI thread.

Actions are run only if the current status is OK and the action has not been canceled.

The default implementation does nothing. Subclasses should either override this or performAction().


performAction

protected RBStatus performAction()

Performs the actual work of this operation. It can get create a progress monitor from its context if necessary. It can retrieve its structured selection using getSelection(). It can retrieve its project using getModelProject(). Any long running action should create a progress monitor from the context and periodically test the progress monitor and cancel if requested.

The action is cancelable and runs in the UI thread.

The default implementation creates a ProgressMonitorDialog and runs performAction(monitor) within that. Can be overridden by subclasses if they prefer to use a different IRunnableContext.


performPostActions

protected void performPostActions(IProgressMonitor monitor)
Performs post-action operations. Subclasses can override and call super.

PostActions are run only if the current status is OK and the action has not been canceled.

See Also:
run(IAction)

terminate

protected void terminate()
Performs any termination prior to ending the action. Subclasses can override and call super. Termination is run unconditionally -- even if the operation is canceled and the pre/normal/post actions are skipped.

See Also:
run(IAction)

checkSelection

protected abstract void checkSelection()
Checks the selection to see if it applies to this action. The selection should be examined and the enabled state of the action can then be set using setEnabled(boolean).

Subclasses must implement.


handleActionException

protected abstract void handleActionException(Exception exception)
Handles the Exception that may be raised during the performance of the action. Any logging to be done should be done here since the exception is not re-thrown.

Subclasses must implement.


runWorkspaceOperation

protected final void runWorkspaceOperation(Runnable runnable)
Runs a runnable that is part of a normal action inside a workspace modification envelope. If the operation wishes to update a progress monitor it should use the monitor provided in performAction(IProgressMonitor).

This is a convenience method for use by subclasses.


selectionChanged

public final void selectionChanged(IAction action,
                                   ISelection selection)
Selection has changed. The model resources are synchronized before checkSelection is called.

Required by IObjectActionDelegate.

Implemented here for all subclasses.


setActivePart

public final void setActivePart(IAction action,
                                IWorkbenchPart part)
Set the workbench part that is requesting the action.

Required by IObjectActionDelegate.

Implemented here for all subclasses.


run

public final void run(IAction action)
Runs the steps required to complete the action. The action is cancelable and runs in this thread.

This action invokes the following 5 methods in succession.

This allows users to cancel the action using the progress monitor.

Required by IObjectActionDelegate.

Implemented here for all subclasses.


getTaskName

protected String getTaskName()

showStatusMessage

public void showStatusMessage(RBStatus status)
Shows a status message and asks whether to cancel the operation.


showSystemMessage

public void showSystemMessage(SystemMessage message)
Shows a system message in a standard system message dialog. Must be run from the UI thread.

Parameters:
message - the SystemMessage to show. If the message is null, this does nothing. If the message is an inquiry message, it is assumed to ask the question "Do you want to continue?". If Yes is pressed the operation is continued. If NO is pressed or the dialog is canceled, the operation is canceled.

showSystemMessageInUI

public void showSystemMessageInUI(SystemMessage message)
Shows a system message from any thread.

Parameters:
message - The message to show.

Rational Developer for Power Systems Software
V7.6

Copyright © 2011 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.