com.bbn.swede.ui.wizards.action
Class AbstractOpenWizardAction

java.lang.Object
  extended byAction
      extended bycom.bbn.swede.ui.wizards.action.AbstractOpenWizardAction
Direct Known Subclasses:
NewOWLClassWizardAction, NewOWLDocumentWizardAction, NewOWLOntologyWizardAction, NewOWLProjectWizardAction, NewOWLPropertyWizardAction

public abstract class AbstractOpenWizardAction
extends Action

Common base class for SWeDE's "New ..." actions.

Author:
tself
See Also:
Serialized Form

Constructor Summary
protected AbstractOpenWizardAction()
          Creates a AbstractOpenWizardAction with no restrictions on types, and does allow an empty selection.
  AbstractOpenWizardAction(String label, boolean acceptEmptySelection)
          Creates a AbstractOpenWizardAction.
  AbstractOpenWizardAction(String label, Class[] activatedOnTypes, boolean acceptEmptySelection)
          Creates a AbstractOpenWizardAction.
  AbstractOpenWizardAction(String label, Class[] activatedOnTypes, boolean acceptEmptySelection, boolean allowEmptyWorkspace)
          Creates an open wizard action.
 
Method Summary
 boolean canActionBeAdded()
          Tests if the action can be run on the current selection.
protected  boolean checkWorkspaceNotEmpty()
          Indicates whether the workspace is non-empty.
protected abstract  Wizard createWizard()
          Creates a wizard for the action.
 void dispose()
           
protected  Shell getActiveWorkbenchShell()
          Retrieves the active workbench shell.
protected  IStructuredSelection getCurrentSelection()
          Retrieves the current selection from the workbench.
protected  IWorkbench getWorkbench()
          Retrieves the active workbench.
 void init(IWorkbenchWindow window)
           
 void run()
          Performs the action.
 void run(IAction action)
           
 void selectionChanged(IAction action, ISelection selection)
           
protected  boolean shouldAcceptElement(Object obj)
          Indicates whether or not an element should be accepted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractOpenWizardAction

public AbstractOpenWizardAction(String label,
                                boolean acceptEmptySelection)
Creates a AbstractOpenWizardAction.

Parameters:
label - The label of the action
acceptEmptySelection - Specifies if the action allows an empty selection

AbstractOpenWizardAction

public AbstractOpenWizardAction(String label,
                                Class[] activatedOnTypes,
                                boolean acceptEmptySelection)
Creates a AbstractOpenWizardAction.

Parameters:
label - The label of the action
activatedOnTypes - The action is only enabled when all objects in the selection are of the given types. null will allow all types.
acceptEmptySelection - Specifies if the action allows an empty selection

AbstractOpenWizardAction

public AbstractOpenWizardAction(String label,
                                Class[] activatedOnTypes,
                                boolean acceptEmptySelection,
                                boolean allowEmptyWorkspace)
Creates an open wizard action.

Parameters:
label - The display name of the action
activatedOnTypes - An array of types the action can be run against
acceptEmptySelection - true if the action can be run with an empty selection, else false.
allowEmptyWorkspace - true if the action can be run in an empty workspace, else false.

AbstractOpenWizardAction

protected AbstractOpenWizardAction()
Creates a AbstractOpenWizardAction with no restrictions on types, and does allow an empty selection.

Method Detail

getWorkbench

protected IWorkbench getWorkbench()
Retrieves the active workbench.

Returns:
The workbench

getActiveWorkbenchShell

protected Shell getActiveWorkbenchShell()
Retrieves the active workbench shell.

Returns:
The workbench shell.

shouldAcceptElement

protected boolean shouldAcceptElement(Object obj)
Indicates whether or not an element should be accepted. Can be overridden to add more checks.

Parameters:
obj - The object to check. Guarunteed to be an instance of an accepted type.
Returns:
true if the action can be run against obj, false if not.

createWizard

protected abstract Wizard createWizard()
                                throws CoreException
Creates a wizard for the action.

Returns:
The wizard
Throws:
CoreException - if wizard creation fails

getCurrentSelection

protected IStructuredSelection getCurrentSelection()
Retrieves the current selection from the workbench.

Returns:
The current selection

run

public void run()
Performs the action.


canActionBeAdded

public boolean canActionBeAdded()
Tests if the action can be run on the current selection.

Returns:
true if the action can be run on the current selection, false if not.

run

public void run(IAction action)

dispose

public void dispose()

init

public void init(IWorkbenchWindow window)

selectionChanged

public void selectionChanged(IAction action,
                             ISelection selection)

checkWorkspaceNotEmpty

protected boolean checkWorkspaceNotEmpty()
Indicates whether the workspace is non-empty.

Returns:
true if the workspace is non-empty or if empty workspaces are allowed, otherwise false.


Copyright © 2004-2005 BBN Technologies. All Rights Reserved.