Upload
gwenda-cole
View
215
Download
0
Embed Size (px)
Citation preview
UNICORE Plugins – How to Design Application Specific Interfaces
Krzysztof Benedyczak
Michał Wroński
Introduction
• Plugin types– Task Plugin (e.g. Gaussian, Amber)
– Extension Plugin (DBBrowser, LAJ)
• Classes– public abstract class UnicorePlugable
– public abstract class TaskPlugable extends UnicorePlugable
– public abstract class ExtensionPlugable extends UnicorePlugable
TaskPlugin
Job Preparation menu
Job Preparation tree
JPA Panel
ExtensionPlugin
Extensions menu
Plugin window
UnicorePlugable
• public abstract void startPlugin()
• public abstract void stopPlugin()
• public abstract String getPluginInfo()
• public JMenuItem getSettingsItem()
• public HelpSet getHelpSet()
• protected Client getClient()
ExtensionPlugable
public JMenuItem getSettingsItem()
Settings item
Extensions menu
public JMenuItem getCustomMenu()
JPA toolbar
public Component getJPAToolBarComponent()
Vsite toolbar
public Component getVsiteToolBarComponent()
Plugin info
public abstract String getPluginInfo()
ExtensionPlugable API
• public Component getVsiteToolBarComponent()
• public Component getJPAToolBarComponent()
• public JMenuItem getCustomMenu()
• public Object setupSpecialVsiteFeatures(Vsite vsite, AbstractJob job)
TaskPlugable
Add task item
public abstract String getName()
Settings item
public JMenuItem getSettingsItem()
Plugin info
public abstract String getPluginInfo()
Icon
protected String getIconPath()
JPA panel
public abstract JPAPanel getPanelInstance(ActionContainer c)
TaskPlugin – JPAPanel
• End user panel for preparing plugin's input
• Straightforward integration with client's standard panels - mainly for file imports and exports:
TaskPlugin – Container
• Used to simplify low-level AJO creation • It is streamed to NJS • ErrorSet checkContents()
method can be used to validate Container data • Client offers wide range of Containers; most
commonly used in plugins are:– UserContainer: for executing SoftwareResources– GroupContainer: for maintaining complex job
structures
TaskPlugin – OutcomePanel
• is used to post process plugin's task output
• generally it can perform any additional tasks (even submit another jobs)
TaskPlugable API
• public abstract String getName()• public abstract ActionContainer
getContainerInstance(GroupContainer parent)• public abstract JPAPanel
getPanelInstance(ActionContainer container)
• protected String getIconPath()
• public final Class getContainerClass()
• public final boolean hasContainerClass(Class cls)
TaskPlugin – JPAPanel API
• Extends JPAPanel (thus also extends JPanel)• Implements:
– void applyValues() - should setup underlying plugin container with GUI's values
– void resetValues() - just another way round – fills panel with container’s data
– void updateValues(boolean vsiteChanged) – invoked every time panel becomes visible
TaskPlugin – UserContainer
• Simple scenario:– extend UserContainer
– use setPreinstalledSoftware()
– use addFileImport(), addFileExport()
• Optionally implement buildExecuteGroup which:– creates executeGroup instance
– adds to executeGroup custom AbstarctActions with dependences
TaskPlugin – OutcomePanel API
• Container implements IPanelProvider interface to register additional panel(s) in Client's outcome area– JPanel getPanel(int i)
• usually OutcomePanel want to get notifications when new data is fetched and when the panel becomes visible: – OutcomePanel implements Applyable interface
TaskPlugin – JPAPanel codepublic class DBAccessJPAPanel extends JPAPanel {
public DBAccessJPAPanel(JFrame parentFrame, ScriptContainer container) {[...]initComponents();
}/** Apply values from GUI to container */
public void applyValues() {container.setModifiedTime(new Date(System.currentTimeMillis()));container.setName(taskTextField.getText());
}/** Fill values from container into gui */
public void resetValues() {taskTextField.setText(container.getName());scriptTextArea.setText(task.getScript());
}/** Method will be called whenever this panel is activated */
public void updateValues(boolean vsiteChanged) {if (vsiteChanged) loadQueries();enableControls();
}[...]
}
TaskPlugin – Container code (1)public class ExampleContainer extends UserContainer
implements IPanelProvider {
private transient JPanel simpleOutcomePanel;
public ExampleContainer(GroupContainer parent) { super(parent);}
public ErrorSet checkContents() {
ErrorSet er = super.checkContents();
//Does Vsite support needed SoftwareResource? NamedResourceSet nrs =
ResourceManager.getResourceSet(getVsite()); if (nrs.findSoftwareResourceByName("our_executable") == null) er.add(new Uerror(getIdentifier(),"Wrong Vsite")); setErrors(er); return er; }....
TaskPlugin – Container code (2).....
public int getNrOfPanels() { return 1;}
public String getPanelTitle(int i) { return “Simple outcome panel”;}
public void finalizePanel(){}
public JPanel getPanel(int i) { if (!simpleOutcomePanel) simpleOutcomePanel =
new ReexSimpleOutcomePanel(this); return simpleOutcomePanel;}
}
TaskPlugin – OutcomePanel code
public class SimpleOutcomePanel extends JPanel implements Applyable { [...]
public SimpleOutcomePanel(Container container) { initComponents();}
public void applyValues() {}
/** Becomes visible */public void updateValues() { if (plot == null) addPlotPanel();}
/** New outcome */public void resetValues() { if (panelReady) return; if (plot == null) addPlotPanel(); [...]}
[...]
}
Re-usable components
• Graphical interfaces– FileImportPanel, FileExportPanel, RemoteTextEditor
• Container classes– UserContainer, GroupContainer
• Classes to get the outcome of AJO– OutcomeManager
• Classes to manage resources– ResourceManager
• Requests
Requests
• Requests allow to prepare jobs at low level (AJO) without using containers
• but they still hides from programmer many issues: sending job to Vsite, waiting/checking for reply and all certificates related work
• Requests are often used in ExtensionPlugins• There are many out-of-the-box requests in the Client. The
most interesting:– GetJobStatus – GetFilesFromUspace– GetListing
How to implement a Request
• extends ObservableRequestThread • add some IObservers to Request object • implement run() method where:
– AJO is constructed
– AJO is sent with desired method (polling or nonPolling)
– if nonPolling() answer was RetrieveOutcomeReply then in run() we can get (deserialized) outcome – else it must be done in IObserver code
Summary
• TaskPlugin– used as a component in standard Client’s job
– integrates JPAPanel, Container and OutcomePanel
• ExtensionPlugin– adds any other new functionality to the Client
DeviceSteer Plugin (1)
• Plugin for steering remote devices through Unicore infrastructure- user friendly – GUI
• Interactivity in Unicore• Designed in the way which allows simple
adaptation to different devices
DeviceSteer Plugin (2)
DBAccess Plugin (1)
• Plugin allows for access to SQL databases• Features:
– User friendliness
– Support for the most popular free DBMSes: PostgreSQL and MySQL
– Support for SDSC Storage Resource Broker
– Extensibility
DBAccess Plugin (2)
References
• Plugin Programmer’s Guide
• Client API documentation
• Client and plugins source code
QUESTIONS ?