Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

RSE
Release 3.0

org.eclipse.rse.ui.actions
Class SystemBaseDialogAction


java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.jface.action.AbstractAction
          extended by 

org.eclipse.jface.action.Action
              extended by 

org.eclipse.rse.ui.actions.SystemBaseAction
                  extended by 
org.eclipse.rse.ui.actions.SystemBaseDialogAction
All Implemented Interfaces:
IAction, ISelectionChangedListener, ISystemAction, ISystemDialogAction
Direct Known Subclasses:
SystemBaseCopyAction, SystemBaseWizardAction, SystemChangeFilterAction, SystemFilterAbstractFilterAction, SystemFilterAbstractFilterPoolAction, SystemSelectRemoteFileAction, SystemSelectRemoteFolderAction

public abstract class SystemBaseDialogAction
extends SystemBaseAction
implements ISystemDialogAction

A specialization for Action for actions that put up dialogs. These actions have some common requirements:

  • They need to take the parent Shell object in the constructor or later perhaps via setParent
  • They need to be able to set the input value for the dialog. This is typically related to what is currently selected.
  • They need to be able to get the output value from the dialog. This can be queried by calling getValue after the action runs.

    This subclass of SystemBaseAction implements the run() method in a way optimized for the processing of dialogs: it calls an abstract method to create the dialog, then sets the input from the action's value (if set) or selection (otherwise) and opens the dialog. After, it calls an abstract method to extract the dialog's output object which is used to set this action's value, for the benefit of the caller.

    To use this dialog, subclass it and override the following methods

    :
  • createDialog(Shell)
  • getDialogValue(Dialog)
  • run() but ONLY if you don't want the default implementation of this method.

    In addition to the methods you must override, you can optionally call various methods to configure this action. In addition to those in the parent class, this class offers these configuration methods:

  • setDialogHelp(String) to set the context help ID for the dialog, for cases where the dialog is generic and its help depends on context and hence cannot be hardcoded in the dialog class.
  • setValue(Object) to the set the input object to pass to the dialog, for cases where the current selection is not what you want to pass to the dialog.
  • setNeedsProgressMonitor(boolean) to specify if the dialog is to display a progress monitor or not, for cases where this decision depends on context and hence cannot be hardcoded in the dialog class.
  • setProcessAllSelections(boolean) to specify the behaviour when there are multiple objects selected. By default, the dialog will be created and processed once for each selected object, but you can specify that you instead want to only invoke the dialog once and pass in all selected objects as a single ISelection object.


    Field Summary
    protected  boolean cancelled
               
    protected   String dlgHelpId
               
    protected  boolean needsProgressMonitor
               
    protected  boolean needsProgressMonitorSet
               
    protected  boolean processAll
               
    protected   Object value
               
     
    Fields inherited from class org.eclipse.rse.ui.actions. SystemBaseAction
    allowOnMultipleSelection, arrowCursor, helpId, selectionSensitive, shell, sSelection, traceSelections, traceTarget, viewer, waitCursor
     
    Fields inherited from interface org.eclipse.jface.action. IAction
    AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
     
    Constructor Summary
    protected SystemBaseDialogAction ( String text, ImageDescriptor image, Shell shell)
              Constructor for SystemBaseDialogAction when translated label is known.
    protected SystemBaseDialogAction ( String text, String tooltip, ImageDescriptor image, Shell shell)
              Constructor for SystemBaseDialogAction when translated label and tooltip are known.
    protected SystemBaseDialogAction ( String text, String tooltip, String description, ImageDescriptor image, Shell shell)
              Constructor for SystemBaseDialogAction when translated label and tooltip and description are all known.
     
    Method Summary
    protected abstract   Dialog createDialog ( Shell parent)
              If you decide to use the supplied run method as is, then you must override this method to create and return the dialog that is displayed by the default run method implementation.
      String getDialogHelpContextId ()
              Return the help Id destined for the dialog this action brings up
    protected abstract   Object getDialogValue ( Dialog dlg)
              If you decide to use the supplied run method as is, then you must override this method to retrieve the data from the dialog.
     boolean getNeedsProgressMonitor ()
              Return true if the action's dialog/wizard is to include a progress monitor
    protected  boolean getProcessAllSelections ()
              Return setting of setProcessAllSelections.
      Object getValue ()
              Get the value, typically set in actionPerformed after putting up the dialog, and holds the output from the dialog.
     void run ()
              This is the method called by the system when the user selects this action.
     void setDialogHelp ( String id)
              When using generic dialogs, it is nice to offer non-generic help.
     void setNeedsProgressMonitor (boolean needs)
              If desired, specify if you want to include a progress monitor in your dialog or wizard.
     void setProcessAllSelections (boolean all)
              If this action supports being enabled for multiple selections (the default, but changable by calling allowOnMultipleSelections(false)), then by default the default run() implementation will create and invoke the dialog once for each item selected.
     void setValue ( Object value)
              Set the value used as input to the dialog
     boolean wasCancelled ()
              Returns true if the user cancelled the dialog.
    protected  boolean wasNeedsProgressMonitorSet ()
              Return true if the caller explicitly called setNeedsProgressMonitor
     
    Methods inherited from class org.eclipse.rse.ui.actions. SystemBaseAction
    allowOnMultipleSelection, checkObjectType, getContextMenuGroup, getCurrentTreeView, getFirstSelection, getHelpContextId, getNextSelection, getRemoteAdapter, getSelection, getSelectionProvider, getShell, getShell, getSystemConnection, getViewAdapter, getViewer, isDummy, isEnabled, isSelectionSensitive, issueTraceMessage, selectionChanged, setAvailableOffline, setBusyCursor, setContextMenuGroup, setDisplayCursor, setDisplayCursor, setHelp, setHost, setInputs, setSelection, setSelectionProvider, setSelectionSensitive, setShell, setTracing, setTracing, setViewer, updateSelection
     
    Methods inherited from class org.eclipse.jface.action. Action
    convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
     
    Methods inherited from class org.eclipse.jface.action. AbstractAction
    addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
     
    Methods inherited from class org.eclipse.core.commands.common. EventManager
    addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
     
    Methods inherited from class java.lang. Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     
    Methods inherited from interface org.eclipse.rse.ui.actions. ISystemAction
    allowOnMultipleSelection, getContextMenuGroup, getHelpContextId, getSelection, getShell, getViewer, isDummy, isSelectionSensitive, setContextMenuGroup, setHelp, setInputs, setSelection, setSelectionSensitive, setShell, setViewer
     
    Methods inherited from interface org.eclipse.jface.action. IAction
    addPropertyChangeListener, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, removePropertyChangeListener, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
     
    Methods inherited from interface org.eclipse.jface.viewers. ISelectionChangedListener
    selectionChanged
     

    Field Detail

    value

    protected 
    Object value
    

    processAll

    protected boolean processAll
    

    needsProgressMonitor

    protected boolean needsProgressMonitor
    

    needsProgressMonitorSet

    protected boolean needsProgressMonitorSet
    

    cancelled

    protected boolean cancelled
    

    dlgHelpId

    protected 
    String dlgHelpId
    
    Constructor Detail

    SystemBaseDialogAction

    protected SystemBaseDialogAction(
    String text,
                                     
    ImageDescriptor image,
                                     
    Shell shell)
    Constructor for SystemBaseDialogAction when translated label is known. You must separately call setToolTipText and setDescription to enable these if desired.

    Parameters:
    text - string to display in menu or toolbar
    image - icon to display in menu or toolbar. Can be null.
    shell - Shell of parent window. Can be null if you don't know it, but call setShell when you do.

    SystemBaseDialogAction

    protected SystemBaseDialogAction(
    String text,
                                     
    String tooltip,
                                     
    ImageDescriptor image,
                                     
    Shell shell)
    Constructor for SystemBaseDialogAction when translated label and tooltip are known. You must separately call setDescription to enable this if desired.

    Parameters:
    text - string to display in menu or toolbar
    tooltip - string to display when user hovers mouse over action.
    image - icon to display in menu or toolbar. Can be null.
    shell - Shell of parent window. Can be null if you don't know it, but call setShell when you do.

    SystemBaseDialogAction

    protected SystemBaseDialogAction(
    String text,
                                     
    String tooltip,
                                     
    String description,
                                     
    ImageDescriptor image,
                                     
    Shell shell)
    Constructor for SystemBaseDialogAction when translated label and tooltip and description are all known.

    Parameters:
    text - string to display in menu or toolbar
    tooltip - string to display when user hovers mouse over action.
    description - string displayed in status bar of some displays. Longer than tooltip.
    image - icon to display in menu or toolbar. Can be null.
    shell - Shell of parent window. Can be null if you don't know it, but call setShell when you do.
    Method Detail

    getDialogHelpContextId

    public 
    String getDialogHelpContextId()
    Return the help Id destined for the dialog this action brings up


    getValue

    public 
    Object getValue()
    Get the value, typically set in actionPerformed after putting up the dialog, and holds the output from the dialog.

    Specified by:
    getValue in interface ISystemDialogAction

    getNeedsProgressMonitor

    public boolean getNeedsProgressMonitor()
    Return true if the action's dialog/wizard is to include a progress monitor


    wasNeedsProgressMonitorSet

    protected boolean wasNeedsProgressMonitorSet()
    Return true if the caller explicitly called setNeedsProgressMonitor


    getProcessAllSelections

    protected boolean getProcessAllSelections()
    Return setting of setProcessAllSelections.

    See Also:
    setProcessAllSelections(boolean)

    wasCancelled

    public boolean wasCancelled()
    Returns true if the user cancelled the dialog. The default way to guess at this is to test if the output from getDialogValue was null or not. Override if you need to refine this.

    Specified by:
    wasCancelled in interface ISystemDialogAction

    setDialogHelp

    public void setDialogHelp(
    String id)
    When using generic dialogs, it is nice to offer non-generic help. If desired, set the help context ID here, and it will be passed on to the generic dialog after instantiation of it.


    setValue

    public void setValue(
    Object value)
    Set the value used as input to the dialog

    Specified by:
    setValue in interface ISystemDialogAction

    setNeedsProgressMonitor

    public void setNeedsProgressMonitor(boolean needs)
    If desired, specify if you want to include a progress monitor in your dialog or wizard. If the dialog is a SystemPromptDialog or the Wizard is a SystemWizardDialog, it will be passed on after instantiating the dialog or wizard.


    setProcessAllSelections

    public void setProcessAllSelections(boolean all)
    If this action supports being enabled for multiple selections (the default, but changable by calling allowOnMultipleSelections(false)), then by default the default run() implementation will create and invoke the dialog once for each item selected. Call this with true to change that behaviour so that the dialog is only created and processed once.

    Use this when the dialog itself will process all selected items at once.

    The default is false.

    Specified by:
    setProcessAllSelections in interface ISystemDialogAction

    run

    public void run()
    This is the method called by the system when the user selects this action. This is a default implementation which:
    • calls abstract method createDialog() to get the dialog object. Child classes must implement this method.
    • if the returned dialog implements ISystemPromptDialog, then it will call setInputObject passing getValue() as the paramter. If getValue returns null, then instead the currently selected objects are passed as the parameter. If setProcessAllSelections has been called then the current ISelection is passed, else the each object in the selection is passed, and the dialog is displayed once per selected object. Your dialog can then cast this input as necessary to initialize its input fields, say. Presumably it knows what to cast it to. Note: code that creates actions does not typically call setValue unless the action is used in a UI that has no concept of ISelection, such as a raw swt widget. ISelection is a JFace viewer concept.
    • calls dlg.open(getShell()) on the dialog to display it.
    • calls setValue(getDialogValue(dlg)) so callers can get the dialog output via a call to getValue() on this action object. Again, this is typically only used when launching actions from non-viewers, such as launching one dialog from another dialog. When launching from popup-menus of viewers, use selectionChanged instead. Either way, the object set or selected is passed on to the dialog, if not null, by way of a call to the dialog's setInputObject method.
    If this action is to be enabled when multiple items are selected (the default) then the processing above is repeated once for every object selected. If your dialog actually processes all the selected items, then call setProcessAllSelections(true) to change the behaviour to only do all of this once. In this case setInputObject will be called with the entire IStructuredSelection object, and your dialog code can process each of the objects in it.

    Please note that if NO ITEMS are selected, we will still call createDialog but not call setInput.

    To use this default implementation you must implement the createDialog method. Note we will also call dlg.setBlockOnOpen(true) on the returned dialog to force it to be modal.

    Specified by:
    run in interface IAction
    Overrides:
    run in class SystemBaseAction
    See Also:
    Action.run()

    createDialog

    protected abstract 
    Dialog createDialog(
    Shell parent)
    If you decide to use the supplied run method as is, then you must override this method to create and return the dialog that is displayed by the default run method implementation.

    If you override actionPerformed with your own, then simply implement this to return null as it won't be used.

    See Also:
    run()

    getDialogValue

    protected abstract 
    Object getDialogValue(
    Dialog dlg)
    If you decide to use the supplied run method as is, then you must override this method to retrieve the data from the dialog. For SystemPromptDialog dialogs, this is simply a matter of returning dlg.getOutputObject();

    This is called by the run method after the dialog returns, and wasCancelled() is false. Callers of this object can subsequently retrieve this returned value by calling getValue. If you don't need to pass a value back to the caller of this action, simply return null from this method.

    Parameters:
    dlg - The dialog object, after it has returned from open.

    RSE
    Release 3.0

    Copyright (c) IBM Corporation and others 2000, 2008. All Rights Reserved.

  •  
     
      Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire