Class ActionProvider
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.ActionProvider
-
public abstract class ActionProvider extends java.lang.Object
May be supplied by aDocumentViewer
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 inDocumentViewerFactory
and assumes that there is a global String variable calledresidues
.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); } }; } };
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ActionProvider()
Default constructor.protected
ActionProvider(ActionProvider internal)
Create a wrapper ActionProvider that delegates all methods to an internal ActionProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActionsChangedListener(org.virion.jam.util.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.java.util.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.java.util.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.java.util.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(org.virion.jam.util.SimpleListener listener)
removes a listener added using addActionsChangedListener
-
-
-
Constructor Detail
-
ActionProvider
protected ActionProvider(ActionProvider internal)
Create a wrapper ActionProvider that delegates all methods to an internal ActionProvider. Useful for creating an ActionProvider that wants to essentially override one or more of the actions provided by another ActionProvider.- Parameters:
internal
- the internal ActionProvider to delegate all methods to.
-
ActionProvider
protected ActionProvider()
Default constructor. Does nothing.
-
-
Method Detail
-
getCopyAction
public GeneiousAction getCopyAction()
Action that should be performed when this viewer etc. is focused and 'Copy' is selected from the Edit menu (or Ctlr/Cmd-C is pressed). Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- copy action
-
getPasteAction
public GeneiousAction getPasteAction()
Action that should be performed when this viewer etc. is focused and 'Paste' is selected from the Edit menu (or Ctlr/Cmd-V is pressed). Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- paste action
-
getCutAction
public GeneiousAction getCutAction()
Action that should be performed when this viewer etc. is focused and 'Cut' is selected from the Edit menu (or Ctlr/Cmd-X is pressed). Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- cut action
-
getDeleteAction
public GeneiousAction getDeleteAction()
Action that should be performed when this viewer etc. is focused and 'Delete' is selected from the Edit menu. Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- delete action
-
getSelectAllAction
public GeneiousAction getSelectAllAction()
Action that should be performed when this viewer etc. is focused and 'Select all' is selected from the Edit menu (or Ctlr/Cmd-A is pressed). Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- select all action
-
getUndoAction
public GeneiousAction getUndoAction()
Action that should be performed when this viewer etc. is focused and 'Undo' is selected from the Edit menu (or Ctlr/Cmd-Z is pressed).. Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- undo action
-
getRedoAction
public GeneiousAction getRedoAction()
Action that should be performed when this viewer etc. is focused and Redo' is selected from the Edit menu (or Ctlr/Cmd-Shift-Z is pressed). Null if not applicable (will be disabled in edit menu). The default implementation returns null.- Returns:
- redo action
-
getBackAction
public 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. This action should take the viewer back to its most recent state. Eg the last selection range. Should not undo changes to the document.- Returns:
- back action
-
getForwardAction
public 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. This action should take the viewer forwards to the state the viewer was in before back was last performed. Should not redo changes to the document.- Returns:
- forward action
-
getSaveAction
public 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). This action should save any changes to the currently viewed document. The ActionProvider must automatically disable the save action when there are no changes to be saved. So in almost all situations, the save action returned from this method should be in a disabled state initially and only become enabled when the user makes changes. The save action should disable itself again when changes are successfully saved.- Returns:
- save action
-
addActionsChangedListener
public void addActionsChangedListener(org.virion.jam.util.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. The action provider will never change the actions it provides, then it can safely do nothing in this function implementation. The default implementation of this function does nothing. If a subclass overrides this, it should also overrideremoveActionsChangedListener(org.virion.jam.util.SimpleListener)
- Parameters:
listener
- the listener to be notified when the actions change.
-
removeActionsChangedListener
public void removeActionsChangedListener(org.virion.jam.util.SimpleListener listener)
removes a listener added using addActionsChangedListener- Parameters:
listener
- the listener to be removed
-
getOtherActions
public java.util.List<GeneiousAction> getOtherActions()
Get a list of other actions associated with viewer which will be displayed in a toolbar within the viewer panel. The toolbar buttons will be in the same order as the actions in the list. Any location options on the action such asGeneiousActionOptions.setInMainToolbar(boolean, double)
will be ignored for these actions. SeegetExternalActions()
if you wish to do that. However, ifgetCustomToolbarComponents()
returns a non-empty list then the toolbar position will be used for determining the relative positions. The default implementation returns an empty list.- Returns:
- actions list. may be null or empty.
- See Also:
getCustomToolbarComponents()
-
getCustomToolbarComponents
public java.util.List<GeneiousActionToolbar.CustomToolbarComponent> getCustomToolbarComponents()
Gets a list of custom components to add to the toolbar displayed at the top of the viewer panel. Most components should be representable as buttons in which case they should be returned fromgetOtherActions()
instead.- Returns:
- a list of custom components to add to the toolbar displayed at the top of the viewer panel The default implementation returns an empty list.
- Since:
- API 4.600 (Geneious 6.0.0)
- See Also:
getOtherActions()
-
getExternalActions
public java.util.List<GeneiousAction> getExternalActions()
Get a list of actions that should appear in the main menu or elsewhere outside the viewer's toolbar.GeneiousActions
with identicalGeneiousActionOptions
must also be returned fromDocumentViewerFactory.getPossibleExternalActions()
. Musn't include any of the standard actions such as Cut, Copy and Paste which are already in the menu.- Returns:
- a list of actions that should appear in the main menu or elsewhere outside the viewer's toolbar
-
-