Size: 1262
Comment:
|
Size: 2934
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 23: | Line 23: |
* Dialog |
* Dialog |
Line 31: | Line 32: |
// in the plugin | |
Line 35: | Line 37: |
dict.put("service.pid","whatever"); | dict.put("service.pid","myuipanel.persistent.id"); |
Line 38: | Line 40: |
Line 44: | Line 45: |
Or | |
Line 47: | Line 46: |
* Specify tunables. * Provide suggestions on where to put it (Tab, menu item). |
{{{ // The factory is the service. The factory will return individual action objects // that can store internal state. If we didn't have a factory, then the individual // actions wouldn't be able to store their state because they'd persist as services. interface CytoscapeActionFactory { CytoscapeAction createAction(context of some sort); } interface CytoscapeAction { void run(); } // meta data defining where/how to use the action Hashtable dict = new HashTable(); dict.put("preferred.menu","whereever/submenu"); dict.put("action.panel","myuipanel.persistent.id"); // so that it can get the exact panel dict.put("menu.label","asdfasdf"); dict.put("icon", new Icon("my.png")); bundleContext.registerService(CytoscapeActionFactory.class.getName(), new MyCyActionFactory(), dict); }}} Menu Action flow of events 1. Click on a menu 1. menu actionPerformed looks for registered service for CytoscapeActionFactory. The individual factory returned is determined when the menu is created. This happens dynamically based on how the CytoscapeActionFactories are defined. 1. The factory.createAction() method is called with all of the appropriate params (e.g. currentNetwork, currentNetworkView, etc.). 1. The CytoscapeAction object can now be run at your leisure. CytoscapeAction can implement additional interfaces, e.g. ProgressTrackable, which would mean a progress monitor could be added. A CytoscapeAction needs it's basic inputs (current network, current view, etc.), but it also may need separate parameters. These should be defined as some sort of Tunable or List<Tunable> or a JPanel that returns some sort of configuration object, e.g. a Dictionary of key -> value pairs. |
Cytoscape APIs
Cytoscape Provided Services
Plugin Implemented Services
The APIs for these services are defined as interfaces in Cytoscape. The interfaces are as follows:
UI Services
Interactive - provide an option to bring up before or after action has run Action to create panel Action to be triggered by the panel
- Control Tab
- Results Tab
- Dialog
// the service interface interface UIPanel { JPanel getJPanel(); } // in the plugin // meta data defining where/how to use the panel Hashtable dict = new HashTable(); dict.put("panel.location","control"); dict.put("panel.name","hello world"); dict.put("service.pid","myuipanel.persistent.id"); bundleContext.registerService(UIPanel.class.getName(), new MyUIPanel(), dict);
Single Action
- Menu Item
- Button On Toolbar
// The factory is the service. The factory will return individual action objects // that can store internal state. If we didn't have a factory, then the individual // actions wouldn't be able to store their state because they'd persist as services. interface CytoscapeActionFactory { CytoscapeAction createAction(context of some sort); } interface CytoscapeAction { void run(); } // meta data defining where/how to use the action Hashtable dict = new HashTable(); dict.put("preferred.menu","whereever/submenu"); dict.put("action.panel","myuipanel.persistent.id"); // so that it can get the exact panel dict.put("menu.label","asdfasdf"); dict.put("icon", new Icon("my.png")); bundleContext.registerService(CytoscapeActionFactory.class.getName(), new MyCyActionFactory(), dict);
Menu Action flow of events
- Click on a menu
menu actionPerformed looks for registered service for CytoscapeActionFactory. The individual factory returned is determined when the menu is created. This happens dynamically based on how the CytoscapeActionFactories are defined.
- The factory.createAction() method is called with all of the appropriate params (e.g. currentNetwork, currentNetworkView, etc.).
The CytoscapeAction object can now be run at your leisure.
CytoscapeAction can implement additional interfaces, e.g. ProgressTrackable, which would mean a progress monitor could be added.
A CytoscapeAction needs it's basic inputs (current network, current view, etc.), but it also may need separate parameters. These should be defined as some sort of Tunable or List<Tunable> or a JPanel that returns some sort of configuration object, e.g. a Dictionary of key -> value pairs.
Action Services
An action gets current context (network, view, etc.). Then the action does "something". The action should be independent of the UI. Make the actions chainable.