com.ibm.carma.ui.action.custom
Class CustomActionParameterDialog

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by org.eclipse.jface.dialogs.IconAndMessageDialog
              extended by org.eclipse.jface.dialogs.MessageDialog
                  extended by com.ibm.carma.ui.action.custom.CustomActionParameterDialog
All Implemented Interfaces:
org.eclipse.jface.window.IShellProvider

public class CustomActionParameterDialog
extends org.eclipse.jface.dialogs.MessageDialog

This Dialog is designed to query users for needed parameters. Here is an example of how this class can be used:

 if (manager.isPromptNeeded(resource, actionId)) {
    //find the action & then prompt the user
    final Action action = resource.findActionFor(actionId);
    if (action == null) { //this means that there is nothing special about this action
       resource.performAction(actionId, monitor, null);
       return;
    }
    Display.getDefault().syncExec(new Runnable(){
       public void run() {
          CustomActionParameterDialog dialog = new CustomActionParameterDialog(
             Display.getDefault().getActiveShell(), null, action, resource, manager);
          dialog.open();
          if (dialog.getReturnCode() == 0) {
             promptResults = dialog.getParameters();
          } else {
             promptResults = null;
          }
       }});
    if (promptResults != null)
       resource.performAction(actionId, monitor, promptResults);
    else
       ; //do nothing, we've been cancelled
 }      
 

This Class does not check the passed in manager to see if it should prompt, rather it always prompts, assuming the caller knows what he or she is doing. The manager however is querried to provide the default values displayed in the prompt. Those values will be set to the results intermingled with any values the user set. Constant parameters are not displayed.

See Also:
CustomActionUtil, CustomActionParameterManager

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
static java.lang.String COPYRIGHT
           
 
Fields inherited from class org.eclipse.jface.dialogs.MessageDialog
ERROR, INFORMATION, NONE, QUESTION, WARNING
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
blockedHandler, buttonBar, DIALOG_DEFAULT_BOUNDS, DIALOG_PERSISTLOCATION, DIALOG_PERSISTSIZE, DLG_IMG_ERROR, DLG_IMG_HELP, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING, ELLIPSIS
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.swt.graphics.Image dialogTitleImage, Action action, CARMAResource resource, CustomActionParameterManager manager)
          Deprecated. use the CustomActionParameterDialog(Shell, Image, Action, CustomActionAccepter, CustomActionParameterManager) constructor
CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.swt.graphics.Image dialogTitleImage, Action action, CustomActionAccepter resource, CustomActionParameterManager manager)
          Creates a new instance.
CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell, org.eclipse.swt.graphics.Image dialogTitleImage, Action action, RepositoryManager repositoryManager, CustomActionParameterManager manager)
          Deprecated. use the CustomActionParameterDialog(Shell, Image, Action, CustomActionAccepter, CustomActionParameterManager) constructor
 
Method Summary
 java.lang.Object[] getParameters()
           
 boolean isNoPromptForTask()
           
 boolean isStoreValues()
           
 void setMessage(java.lang.String string)
          Sets the message area of the dialog to string
 
Methods inherited from class org.eclipse.jface.dialogs.MessageDialog
getImage, openConfirm, openError, openInformation, openQuestion, openWarning
 
Methods inherited from class org.eclipse.jface.dialogs.IconAndMessageDialog
getErrorImage, getInfoImage, getQuestionImage, getWarningImage
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, close, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, create, getBlockedHandler, getImage, setBlockedHandler, shortenText
 
Methods inherited from class org.eclipse.jface.window.Window
getDefaultImage, getDefaultImages, getDefaultOrientation, getReturnCode, getShell, getWindowManager, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setWindowManager
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

CustomActionParameterDialog

public CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell,
                                   org.eclipse.swt.graphics.Image dialogTitleImage,
                                   Action action,
                                   CustomActionAccepter resource,
                                   CustomActionParameterManager manager)
Creates a new instance.

Parameters:
parentShell - The shell the dialog will display in
dialogTitleImage - The title of the Dialog
action - the Action whose parameters the dialog is querying the user for
resource - the resource that the action will be run against.
manager - the CustomActionParameterManager which holds the default values for this action

CustomActionParameterDialog

@Deprecated
public CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell,
                                              org.eclipse.swt.graphics.Image dialogTitleImage,
                                              Action action,
                                              CARMAResource resource,
                                              CustomActionParameterManager manager)
Deprecated. use the CustomActionParameterDialog(Shell, Image, Action, CustomActionAccepter, CustomActionParameterManager) constructor

Creates a new instance.

Parameters:
parentShell - The shell the dialog will display in
dialogTitleImage - The title of the Dialog
action - the Action whose parameters the dialog is querying the user for
resource - the CARMAResource that the action will be run against.
manager - the CustomActionParameterManager which holds the default values for this action

CustomActionParameterDialog

@Deprecated
public CustomActionParameterDialog(org.eclipse.swt.widgets.Shell parentShell,
                                              org.eclipse.swt.graphics.Image dialogTitleImage,
                                              Action action,
                                              RepositoryManager repositoryManager,
                                              CustomActionParameterManager manager)
Deprecated. use the CustomActionParameterDialog(Shell, Image, Action, CustomActionAccepter, CustomActionParameterManager) constructor

Creates a new instance.

Parameters:
parentShell - The shell the dialog will display in
dialogTitleImage - The title of the Dialog
action - the Action whose parameters the dialog is querying the user for
repositoryManager - the RepositoryManager that the action will be run against.
manager - the CustomActionParameterManager which holds the default values for this action
Method Detail

getParameters

public java.lang.Object[] getParameters()
Returns:
an Object[] filled with parameters, suitable for passing to an action, or null if the user cancelled

setMessage

public void setMessage(java.lang.String string)
Sets the message area of the dialog to string

Parameters:
string -

isStoreValues

public boolean isStoreValues()
Returns:
true if the user wants to store these results, false otherwise

isNoPromptForTask

public boolean isNoPromptForTask()
Returns:
true if the user does not want to be prompted again during this task, false otherwise