public abstract class ActionProvider extends Object
DocumentViewer
to support standard actions (such as copy and paste) or any additional custom actions.
The actions may be added to a toolbar or menu etc. This depends on the options set for each
action.
Example: extract sequence inside the sequence viewer.
If the DocumentViewer that supplies this ActionProvider as its corresponding panel focused and
returns actions for
copy, paste etc. Then these actions will be linked with the Edit->Copy, Edit->Paste etc. items and
their keyboard shortcuts (Ctrl/Cmd + C etc) when the panel is focused.
All methods have default empty implementations. If you wish to provide any functionality
should override the relevant methods.
All methods in this class will be called on the dispatch thread so swing operations are safe.
The following example shows how to create an ActionProvider overriding the getCutAction() method. Note that this code comes from the example in
DocumentViewerFactory and assumes that there is a global String variable called residues.
new ActionProvider(){
public GeneiousAction getCopyAction() {
return new GeneiousAction("Copy"){
public void actionPerformed(ActionEvent e){
StringSelection ss = new StringSelection(residues);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
};
}
};
| Modifier | Constructor and Description |
|---|---|
protected |
ActionProvider()
Default constructor.
|
protected |
ActionProvider(ActionProvider internal)
Create a wrapper ActionProvider that delegates all methods to an internal ActionProvider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addActionsChangedListener(SimpleListener listener)
if the action provider may change the actions it provides at some point then it should notify
all of the listeners that have been added using this function.
|
GeneiousAction |
getBackAction()
Provide an optional back action that is displayed as a back arrow in the viewer toolbar
and has the default back keyboard shortcut.
|
GeneiousAction |
getCopyAction()
Action that should be performed when this viewer etc.
|
List<GeneiousActionToolbar.CustomToolbarComponent> |
getCustomToolbarComponents()
Gets a list of custom components to add to the toolbar displayed at the top of the viewer panel.
|
GeneiousAction |
getCutAction()
Action that should be performed when this viewer etc.
|
GeneiousAction |
getDeleteAction()
Action that should be performed when this viewer etc.
|
List<GeneiousAction> |
getExternalActions()
Get a list of actions that should appear in the main menu or elsewhere outside the viewer's toolbar.
|
GeneiousAction |
getForwardAction()
Provide an optional forward action that is displayed as a forward arrow in the viewer toolbar
and has the default forward keyboard shortcut.
|
List<GeneiousAction> |
getOtherActions()
Get a list of other actions associated with viewer which will be displayed in a toolbar within the viewer panel.
|
GeneiousAction |
getPasteAction()
Action that should be performed when this viewer etc.
|
GeneiousAction |
getRedoAction()
Action that should be performed when this viewer etc.
|
GeneiousAction |
getSaveAction()
Provide an optional action which will be performed when the user selects Save from the file menu
or pushes Ctrl+S (Cmd+S on Mac OS).
|
GeneiousAction |
getSelectAllAction()
Action that should be performed when this viewer etc.
|
GeneiousAction |
getUndoAction()
Action that should be performed when this viewer etc.
|
void |
removeActionsChangedListener(SimpleListener listener)
removes a listener added using addActionsChangedListener
|
protected ActionProvider(ActionProvider internal)
internal - the internal ActionProvider to delegate all methods to.protected ActionProvider()
public GeneiousAction getCopyAction()
public GeneiousAction getPasteAction()
public GeneiousAction getCutAction()
public GeneiousAction getDeleteAction()
public GeneiousAction getSelectAllAction()
public GeneiousAction getUndoAction()
public GeneiousAction getRedoAction()
public GeneiousAction getBackAction()
public GeneiousAction getForwardAction()
public GeneiousAction getSaveAction()
public void addActionsChangedListener(SimpleListener listener)
removeActionsChangedListener(org.virion.jam.util.SimpleListener)listener - the listener to be notified when the actions change.public void removeActionsChangedListener(SimpleListener listener)
listener - the listener to be removedpublic List<GeneiousAction> getOtherActions()
GeneiousActionOptions.setInMainToolbar(boolean, double)
will be ignored for these actions. See getExternalActions() if you wish to do that. However,
if getCustomToolbarComponents() returns a non-empty list then the toolbar position will be used for determining the relative positions.
The default implementation returns an empty list.getCustomToolbarComponents()public List<GeneiousActionToolbar.CustomToolbarComponent> getCustomToolbarComponents()
getOtherActions() instead.getOtherActions()public List<GeneiousAction> getExternalActions()
GeneiousActions with identical GeneiousActionOptions must also be returned from
DocumentViewerFactory.getPossibleExternalActions().
Musn't include any of the standard actions such as Cut, Copy and Paste which are already in the menu.