You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 12:46:56 UTC
[29/50] [abbrv] incubator-taverna-plugin-bioinformatics git commit:
taverna-biomoby-activity-ui/
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActionHelper.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActionHelper.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActionHelper.java
new file mode 100644
index 0000000..9579627
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActionHelper.java
@@ -0,0 +1,852 @@
+/*
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.JTree;
+import javax.swing.ToolTipManager;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean;
+import net.sf.taverna.t2.activities.biomoby.edits.AddBiomobyCollectionDataTypeEdit;
+import net.sf.taverna.t2.activities.biomoby.edits.AddBiomobyDataTypeEdit;
+import net.sf.taverna.t2.activities.biomoby.edits.AddMobyParseDatatypeEdit;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+import net.sf.taverna.t2.workflowmodel.utils.Tools;
+
+import org.apache.log4j.Logger;
+import org.biomoby.client.CentralImpl;
+import org.biomoby.shared.Central;
+import org.biomoby.shared.MobyData;
+import org.biomoby.shared.MobyDataType;
+import org.biomoby.shared.MobyException;
+import org.biomoby.shared.MobyNamespace;
+import org.biomoby.shared.MobyPrimaryDataSet;
+import org.biomoby.shared.MobyPrimaryDataSimple;
+import org.biomoby.shared.NoSuccessException;
+
+
+/**
+ *
+ * @author Eddie An action that for BioMobyProcessors
+ * @auther Stuart Owen - helped port to T2 - but with the minimum code changes possible!
+ */
+public class BiomobyActionHelper {
+
+ private static Logger logger = Logger
+ .getLogger(BiomobyActionHelper.class);
+
+ JProgressBar progressBar = new JProgressBar();
+
+ private EditManager editManager;
+
+ private final FileManager fileManager;
+
+ public BiomobyActionHelper(EditManager editManager, FileManager fileManager) {
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.embl.ebi.escience.scuflui.processoractions.AbstractProcessorAction
+ * #getComponent(org.embl.ebi.escience.scufl.Processor)
+ */
+
+ public JComponent getComponent(final BiomobyActivity activity) {
+ // variables i need
+
+ final String endpoint = activity.getConfiguration().getMobyEndpoint();
+ // set up the root node
+ String serviceName = activity.getMobyService().getName();
+ String description = activity.getMobyService().getDescription();
+
+ MobyServiceTreeNode service = new MobyServiceTreeNode(serviceName,
+ description);
+ DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(service);
+
+ // now add the child nodes containing useful information about the
+ // service
+ DefaultMutableTreeNode input = new DefaultMutableTreeNode("Inputs");
+ DefaultMutableTreeNode output = new DefaultMutableTreeNode("Outputs");
+ rootNode.add(input);
+ rootNode.add(output);
+
+ // process inputs
+ MobyData[] inputs = activity.getMobyService().getPrimaryInputs();
+ for (int i = 0; i < inputs.length; i++) {
+ if (inputs[i] instanceof MobyPrimaryDataSimple) {
+ MobyPrimaryDataSimple simple = (MobyPrimaryDataSimple) inputs[i];
+ StringBuffer sb = new StringBuffer(
+ "Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int j = 0; j < namespaces.length; j++) {
+ sb.append(namespaces[j].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append(" ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(
+ simple.getDataType().getName() + "('"
+ + simple.getName() + "')", sb.toString());
+ input.insert(new DefaultMutableTreeNode(mobyObjectTreeNode),
+ input.getChildCount());
+ } else {
+ // we have a collection
+ MobyPrimaryDataSet collection = (MobyPrimaryDataSet) inputs[i];
+ DefaultMutableTreeNode collectionNode = new DefaultMutableTreeNode(
+ "Collection('" + collection.getName() + "')");
+ input.insert(collectionNode, input.getChildCount());
+ MobyPrimaryDataSimple[] simples = collection.getElements();
+ for (int j = 0; j < simples.length; j++) {
+ MobyPrimaryDataSimple simple = simples[j];
+ StringBuffer sb = new StringBuffer(
+ "Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int k = 0; k < namespaces.length; k++) {
+ sb.append(namespaces[k].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append(" ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(
+ simple.getDataType().getName() + "('"
+ + simple.getName() + "')", sb.toString());
+ collectionNode
+ .insert(new DefaultMutableTreeNode(
+ mobyObjectTreeNode), collectionNode
+ .getChildCount());
+ }
+
+ }
+ }
+ if (inputs.length == 0) {
+ input.add(new DefaultMutableTreeNode(" None "));
+ }
+
+ // process outputs
+ MobyData[] outputs = activity.getMobyService().getPrimaryOutputs();
+ for (int i = 0; i < outputs.length; i++) {
+ if (outputs[i] instanceof MobyPrimaryDataSimple) {
+ MobyPrimaryDataSimple simple = (MobyPrimaryDataSimple) outputs[i];
+ StringBuffer sb = new StringBuffer(
+ "Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int j = 0; j < namespaces.length; j++) {
+ sb.append(namespaces[j].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append(" ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(
+ simple.getDataType().getName() + "('"
+ + simple.getName() + "')", sb.toString());
+ mobyObjectTreeNode.setNamespaces(simple.getNamespaces());
+ output.insert(new DefaultMutableTreeNode(mobyObjectTreeNode),
+ output.getChildCount());
+ } else {
+ // we have a collection
+ MobyPrimaryDataSet collection = (MobyPrimaryDataSet) outputs[i];
+ DefaultMutableTreeNode collectionNode = new DefaultMutableTreeNode(
+ "Collection('" + collection.getName() + "')");
+ output.insert(collectionNode, output.getChildCount());
+ MobyPrimaryDataSimple[] simples = collection.getElements();
+ for (int j = 0; j < simples.length; j++) {
+ MobyPrimaryDataSimple simple = simples[j];
+ StringBuffer sb = new StringBuffer(
+ "Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int k = 0; k < namespaces.length; k++) {
+ sb.append(namespaces[k].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append("ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(
+ simple.getDataType().getName() + "('"
+ + simple.getName() + "')", sb.toString());
+ mobyObjectTreeNode.setNamespaces(simple.getNamespaces());
+ collectionNode
+ .insert(new DefaultMutableTreeNode(
+ mobyObjectTreeNode), collectionNode
+ .getChildCount());
+ }
+
+ }
+ }
+ if (outputs.length == 0) {
+ output.add(new DefaultMutableTreeNode(" None "));
+ }
+
+ // finally return a tree describing the object
+ final JTree tree = new JTree(rootNode);
+ tree.setCellRenderer(new BioMobyServiceTreeCustomRenderer());
+ ToolTipManager.sharedInstance().registerComponent(tree);
+ tree.addMouseListener(new MouseListener() {
+ public void mouseClicked(MouseEvent me) {
+ }
+
+ public void mousePressed(MouseEvent me) {
+ mouseReleased(me);
+ }
+
+ public void mouseReleased(MouseEvent me) {
+ if (me.isPopupTrigger()) // right click, show popup menu
+ {
+ TreePath path = tree.getPathForLocation(me.getX(), me
+ .getY());
+ if (path == null)
+ return;
+ if (path.getPathCount() >= 3) {
+ if (path.getPathCount() == 4
+ && path.getParentPath().getLastPathComponent()
+ .toString().startsWith("Collection(")
+ && (path.getParentPath().toString())
+ .indexOf("Inputs") > 0) {
+ // we have a collection input
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
+ .getLastSelectedPathComponent();
+ final String selectedObject = node.toString();
+ // ensure that the last selected item is an object!
+ if (!selectedObject.equals(path
+ .getLastPathComponent().toString()))
+ return;
+ String collectionName = "";
+ if (path.getParentPath().getLastPathComponent()
+ .toString().indexOf("('") > 0
+ && path.getParentPath()
+ .getLastPathComponent().toString()
+ .indexOf("')") > 0) {
+ collectionName = path.getParentPath()
+ .getLastPathComponent().toString()
+ .substring(
+ path.getParentPath()
+ .getLastPathComponent()
+ .toString().indexOf(
+ "('") + 2,
+ path.getParentPath()
+ .getLastPathComponent()
+ .toString().indexOf(
+ "')"));
+ }
+ final String theCollectionName = collectionName;
+ final JPopupMenu menu = new JPopupMenu();
+ // Create and add a menu item for adding to the item
+ // to the workflow
+ JMenuItem item = new JMenuItem("Add Datatype - "
+ + selectedObject + " to the workflow?");
+ item
+ .setIcon(MobyPanel.getIcon("/Add24.gif"));
+ item.addActionListener(new ActionListener() {
+ // private boolean added = false;
+
+ public void actionPerformed(ActionEvent ae) {
+
+ try {
+ Dataflow currentDataflow = fileManager.getCurrentDataflow();
+ Edit<?> edit = new AddBiomobyCollectionDataTypeEdit(
+ currentDataflow, activity,
+ selectedObject,
+ theCollectionName, editManager.getEdits());
+ editManager.doDataflowEdit(
+ currentDataflow, edit);
+
+ } catch (Exception e) {
+ logger.error("", e);
+ }
+ }
+ });
+ // Create and add a menu item for service details
+ JMenuItem details = new JMenuItem("Find out about "
+ + selectedObject);
+ details
+ .setIcon(MobyPanel.getIcon("/Information24.gif"));
+ details.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+
+ // TODO Create a frame
+ Frame frame = MobyPanel.CreateFrame("A BioMoby Object Description");
+ JPanel panel = new MobyPanel(
+ selectedObject,
+ "A BioMoby Object Description", "");
+
+ frame.add(panel);
+ frame.setSize(getFrameSize());
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ // add the components to the menu
+ menu.add(new JLabel("Add to workflow ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(item);
+ menu.add(new JSeparator());
+ menu.add(new JLabel("Datatype Details ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(details);
+ // show the window
+ menu.show(me.getComponent(), me.getX(), me.getY());
+ } else if (path.getPathCount() == 3
+ && path.getParentPath().getLastPathComponent()
+ .toString().startsWith("Inputs")
+ && !path.getLastPathComponent().toString()
+ .startsWith("Collection(")
+ && !path.getLastPathComponent().toString()
+ .equals(" None ")) {
+ // we have a simple input
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
+ .getLastSelectedPathComponent();
+ if (node == null)
+ return;
+ final String selectedObject = node.toString();
+ // ensure that the last selected item is an object!
+ if (!selectedObject.equals(path
+ .getLastPathComponent().toString()))
+ return;
+
+ final JPopupMenu menu = new JPopupMenu();
+ // Create and add a menu item for adding to the item
+ // to the workflow
+ JMenuItem item = new JMenuItem("Add Datatype - "
+ + selectedObject + " to the workflow?");
+ item
+ .setIcon(MobyPanel.getIcon("/Add24.gif"));
+ item.addActionListener(new ActionListener() {
+ // private boolean added = false;
+
+ public void actionPerformed(ActionEvent ae) {
+
+ try {
+ Dataflow currentDataflow = fileManager.getCurrentDataflow();
+ Edit<?> edit = new AddBiomobyDataTypeEdit(
+ currentDataflow, activity,
+ selectedObject, editManager.getEdits());
+ editManager.doDataflowEdit(
+ currentDataflow, edit);
+
+ } catch (Exception e) {
+ logger.error("Could not perform action", e);
+ }
+ }
+ });
+
+ // Create and add a menu item for service details
+ JMenuItem details = new JMenuItem(
+ "Find out about 1 " + selectedObject);
+ details
+ .setIcon(MobyPanel.getIcon("/Information24.gif"));
+ details.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ // TODO Create a frame
+ Frame frame = MobyPanel.CreateFrame("A BioMoby Object Description");
+ JPanel panel = new MobyPanel(
+ // TODO create a valid description
+ selectedObject,
+ "A BioMoby Object Description",
+ createDataDescription(
+ selectedObject.split("\\(")[0],
+ activity.getConfiguration()
+ .getMobyEndpoint()));
+ frame.add(panel);
+ frame.setSize(getFrameSize());
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ private String createDataDescription(
+ String dataName, String mobyEndpoint) {
+ MobyDataType data;
+ try {
+ Central central = new CentralImpl(
+ mobyEndpoint);
+ data = central.getDataType(dataName);
+
+ } catch (MobyException e) {
+ return "Couldn't retrieve a description on the BioMoby service '"
+ + dataName + "'";
+ } catch (NoSuccessException e) {
+ return "Couldn't retrieve a description on the BioMoby service '"
+ + dataName + "'";
+ }
+ return data.toString();
+ }
+ });
+ // add the components to the menu
+ menu.add(new JLabel("Add to workflow ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(item);
+ menu.add(new JSeparator());
+ menu.add(new JLabel("Datatype Details ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(details);
+ // show the window
+ menu.show(me.getComponent(), me.getX(), me.getY());
+
+ } else if (path.getParentPath().toString().indexOf(
+ "Outputs") >= 0
+ && path.getLastPathComponent().toString()
+ .indexOf(" None ") == -1) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
+ .getLastSelectedPathComponent();
+ if (node == null)
+ return;
+ final String selectedObject = node.toString();
+ if (!selectedObject.equals(path
+ .getLastPathComponent().toString()))
+ return;
+
+ if ((path.getPathCount() == 4
+ && path.getParentPath()
+ .getLastPathComponent().toString()
+ .startsWith("Collection(") && (path
+ .getParentPath().toString())
+ .indexOf("Outputs") > 0)
+ || (path.toString().indexOf("Collection(") < 0)) {
+ final JPopupMenu menu = new JPopupMenu();
+ JMenuItem item = new JMenuItem(
+ "Find Services that Consume "
+ + selectedObject
+ + " - brief search");
+ item
+ .setIcon(MobyPanel.getIcon("/Information24.gif"));
+ final String potentialCollectionString = path
+ .getParentPath().getLastPathComponent()
+ .toString();
+ final boolean isCollection = potentialCollectionString
+ .indexOf("Collection('") >= 0;
+ final Object selectedMobyObjectTreeNodeHolder = (DefaultMutableTreeNode) tree
+ .getLastSelectedPathComponent();
+ item.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ae) {
+ // you would like to search for
+ // selectedObject
+ new Thread("Finding biomoby services") {
+ public void run() {
+ try {
+ // FIXME: ignored for now -
+ // Stuart
+ String name = selectedObject;
+ if (name.indexOf("(") > 0)
+ name = name
+ .substring(
+ 0,
+ name
+ .indexOf("("));
+ String articlename = "";
+ if (isCollection) {
+ articlename = potentialCollectionString
+ .substring(
+ potentialCollectionString
+ .indexOf("('") + 2,
+ potentialCollectionString
+ .lastIndexOf("'"));
+ } else {
+ articlename = selectedObject
+ .substring(
+ selectedObject
+ .indexOf("'") + 1,
+ selectedObject
+ .lastIndexOf("'"));
+ }
+
+ BiomobyObjectActivity boAct = new BiomobyObjectActivity();
+ BiomobyObjectActivityConfigurationBean bean = new BiomobyObjectActivityConfigurationBean();
+ MobyDataType dataType = new MobyDataType(
+ name);
+ bean
+ .setAuthorityName(dataType
+ .getAuthority());
+ bean
+ .setServiceName(dataType
+ .getName());
+ bean
+ .setMobyEndpoint(endpoint);
+ boAct.configure(bean);
+
+ OutputPort theServiceport = null;
+
+ try {
+ if (isCollection)
+ theServiceport = Tools
+ .getActivityOutputPort(
+ activity,
+ name
+ + "(Collection - '"
+ + (articlename
+ .equals("") ? "MobyCollection"
+ : articlename)
+ + "' As Simples)");
+
+ else
+ theServiceport = Tools
+ .getActivityOutputPort(
+ activity,
+ name
+ + "("
+ + articlename
+ + ")");
+ } catch (Exception except) {
+ }
+ BiomobyObjectActionHelper boa = null;
+
+ if (theServiceport == null) {
+ boa = new BiomobyObjectActionHelper(
+ false, editManager, fileManager);
+ } else {
+ boa = new BiomobyObjectActionHelper(
+ theServiceport,
+ false, editManager, fileManager);
+ }
+
+ if (selectedMobyObjectTreeNodeHolder instanceof DefaultMutableTreeNode
+ && ((DefaultMutableTreeNode) selectedMobyObjectTreeNodeHolder)
+ .getUserObject() instanceof MobyObjectTreeNode) {
+ DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) selectedMobyObjectTreeNodeHolder;
+ MobyObjectTreeNode motn = (MobyObjectTreeNode) dmtn
+ .getUserObject();
+ boa
+ .setNamespaces(motn
+ .getNamespaces());
+ }
+ PopupThread popupthread = new PopupThread(
+ boAct, boa);
+ progressBar
+ .setStringPainted(true);
+ progressBar
+ .setVisible(true);
+ popupthread.start();
+
+ while (popupthread
+ .isAlive()) {
+ Thread.sleep(4000);
+ }
+
+ progressBar
+ .setVisible(false);
+ Component c = popupthread
+ .getComponent();
+ Dimension loc = getFrameLocation();
+ Dimension size = getFrameSize();
+ JPanel frame = new SimpleActionFrame(
+ c,
+ "Moby Object Details");
+ createFrame(
+ frame,
+ (int) loc
+ .getWidth(),
+ (int) loc
+ .getHeight(),
+ (int) size
+ .getWidth(),
+ (int) size
+ .getHeight());
+ } catch (Exception e) {
+ }
+ }
+ }.start();
+
+ }
+ });
+
+ JMenuItem item2 = new JMenuItem(
+ "Find Services that Consume "
+ + selectedObject
+ + " - semantic search");
+ item2
+ .setIcon(MobyPanel.getIcon("/Search24.gif"));
+ item2.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ // you would like to search for
+ // selectedObject
+ new Thread("Finding BioMoby services") {
+
+ public void run() {
+ try {
+ String name = selectedObject;
+ if (name.indexOf("(") > 0)
+ name = name
+ .substring(
+ 0,
+ name
+ .indexOf("("));
+ String articlename = "";
+ if (isCollection) {
+ articlename = potentialCollectionString
+ .substring(
+ potentialCollectionString
+ .indexOf("('") + 2,
+ potentialCollectionString
+ .lastIndexOf("'"));
+ } else {
+ articlename = selectedObject
+ .substring(
+ selectedObject
+ .indexOf("'") + 1,
+ selectedObject
+ .lastIndexOf("'"));
+ }
+ BiomobyObjectActivity boAct = new BiomobyObjectActivity();
+ BiomobyObjectActivityConfigurationBean bean = new BiomobyObjectActivityConfigurationBean();
+ MobyDataType dataType = new MobyDataType(
+ name);
+ bean
+ .setAuthorityName(dataType
+ .getAuthority());
+ bean
+ .setServiceName(dataType
+ .getName());
+ bean
+ .setMobyEndpoint(endpoint);
+ boAct.configure(bean);
+
+ OutputPort theServiceport = null;
+
+ try {
+
+ if (isCollection)
+ theServiceport = Tools
+ .getActivityOutputPort(
+ activity,
+ name
+ + "(Collection - '"
+ + (articlename
+ .equals("") ? "MobyCollection"
+ : articlename)
+ + "' As Simples)");
+
+ else
+ theServiceport = Tools
+ .getActivityOutputPort(
+ activity,
+ name
+ + "("
+ + articlename
+ + ")");
+ } catch (Exception except) {
+ }
+ BiomobyObjectActionHelper boa = null;
+
+ if (theServiceport == null)
+ boa = new BiomobyObjectActionHelper(
+ true, editManager, fileManager);
+ else
+ boa = new BiomobyObjectActionHelper(
+ theServiceport,
+ true, editManager, fileManager);
+ if (selectedMobyObjectTreeNodeHolder instanceof DefaultMutableTreeNode
+ && ((DefaultMutableTreeNode) selectedMobyObjectTreeNodeHolder)
+ .getUserObject() instanceof MobyObjectTreeNode) {
+ DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) selectedMobyObjectTreeNodeHolder;
+ MobyObjectTreeNode motn = (MobyObjectTreeNode) dmtn
+ .getUserObject();
+ boa
+ .setNamespaces(motn
+ .getNamespaces());
+ }
+
+ PopupThread popupthread = new PopupThread(
+ boAct, boa);
+ progressBar
+ .setStringPainted(true);
+ progressBar
+ .setVisible(true);
+ popupthread.start();
+
+ while (popupthread
+ .isAlive()) {
+ Thread.sleep(4000);
+ }
+
+ progressBar
+ .setVisible(false);
+ Component c = popupthread
+ .getComponent();
+ Dimension loc = getFrameLocation();
+ Dimension size = getFrameSize();
+ JPanel frame = new SimpleActionFrame(
+ c,
+ "Moby Object Details");
+ createFrame(
+ frame,
+ (int) loc
+ .getWidth(),
+ (int) loc
+ .getHeight(),
+ (int) size
+ .getWidth(),
+ (int) size
+ .getHeight());
+ } catch (Exception e) {
+ }
+ }
+ }.start();
+ }
+ });
+
+ // string may be needed to extract the
+ // collection article name
+ // final String potentialCollectionString =
+ // path.getParentPath()
+ // .getLastPathComponent().toString();
+ // final boolean isCollection =
+ // potentialCollectionString
+ // .indexOf("Collection('") >= 0;
+
+ JMenuItem item3 = new JMenuItem(
+ "Add parser for " + selectedObject
+ + " to the workflow");
+ item3
+ .setIcon(MobyPanel.getIcon("/Cut24.gif"));
+ item3.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent ae) {
+
+ try {
+ Dataflow currentDataflow = fileManager.getCurrentDataflow();
+ Edit<?> edit = new AddMobyParseDatatypeEdit(
+ currentDataflow, activity,
+ selectedObject,isCollection, potentialCollectionString, editManager.getEdits());
+ editManager.doDataflowEdit(
+ currentDataflow, edit);
+
+ } catch (Exception e) {
+ logger.error("Could not perform action", e);
+ }
+
+ }
+ });
+
+ menu.add(new JLabel(
+ "Moby Service Discovery ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(item);
+ menu.add(new JSeparator());
+ menu.add(item2);
+ menu.add(new JLabel("Parse Moby Data ... ",
+ JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(item3);
+
+ menu.show(me.getComponent(), me.getX(), me
+ .getY());
+ }
+ }
+ }
+ }
+ }
+
+ public void mouseEntered(MouseEvent me) {
+ }
+
+ public void mouseExited(MouseEvent me) {
+ }
+ });
+
+ tree.getSelectionModel().setSelectionMode(
+ TreeSelectionModel.SINGLE_TREE_SELECTION);
+ JScrollPane jsp = new JScrollPane(tree);
+ JPanel thePanel = new JPanel(new BorderLayout());
+ thePanel.add(jsp, BorderLayout.CENTER);
+ progressBar = new JProgressBar();
+ progressBar.setValue(0);
+ progressBar.setString("Finding Services ... ");
+ progressBar.setStringPainted(true);
+ progressBar.setIndeterminate(true);
+ progressBar.setVisible(false);
+ thePanel.add(progressBar, BorderLayout.PAGE_END);
+ return thePanel;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.embl.ebi.escience.scuflui.processoractions.ProcessorActionSPI#
+ * getDescription()
+ */
+ public String getDescription() {
+ return "Moby Service Details";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.embl.ebi.escience.scuflui.processoractions.ProcessorActionSPI#getIcon
+ * ()
+ */
+ public ImageIcon getIcon() {
+ return MobyPanel.getIcon("/moby_small.gif");
+ }
+
+ /**
+ * returns the frame size as a dimension for the content pane housing this
+ * action
+ */
+ public Dimension getFrameSize() {
+ return new Dimension(450, 450);
+ }
+
+ /**
+ * Return an Icon to represent this action
+ *
+ * @param loc
+ * the location of the image to use as an icon
+ */
+ public ImageIcon getIcon(String loc) {
+ return MobyPanel.getIcon(loc);
+ }
+
+ /**
+ * Where should the frame open?
+ */
+ public Dimension getFrameLocation() {
+ return new Dimension(100, 100);
+ }
+
+ public void createFrame(JPanel targetComponent,
+ int posX, int posY, int sizeX, int sizeY) {
+ final JPanel component = targetComponent;
+ JFrame newFrame = new JFrame(component.getName());
+ newFrame.getContentPane().setLayout(new BorderLayout());
+ newFrame.getContentPane().add(
+ new JScrollPane((JComponent) targetComponent),
+ BorderLayout.CENTER);
+ newFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ newFrame.setSize(sizeX, sizeY);
+ newFrame.setLocation(posX, posY);
+ newFrame.setVisible(true);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActivityConfigurationAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActivityConfigurationAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActivityConfigurationAction.java
new file mode 100644
index 0000000..f74c76a
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyActivityConfigurationAction.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivityConfigurationBean;
+import net.sf.taverna.t2.activities.biomoby.view.BiomobyConfigView;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workbench.ui.actions.activity.ActivityConfigurationAction;
+import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog;
+
+import org.apache.log4j.Logger;
+
+@SuppressWarnings("serial")
+public class BiomobyActivityConfigurationAction extends
+ ActivityConfigurationAction<BiomobyActivity, BiomobyActivityConfigurationBean> {
+
+ private final Frame owner;
+ private static Logger logger = Logger.getLogger(BiomobyActivityConfigurationAction.class);
+ private final EditManager editManager;
+ private final FileManager fileManager;
+
+ public BiomobyActivityConfigurationAction(BiomobyActivity activity, Frame owner,
+ EditManager editManager, FileManager fileManager,
+ ActivityIconManager activityIconManager) {
+ super(activity, activityIconManager);
+ this.owner = owner;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ }
+
+ public void actionPerformed(ActionEvent arg0) {
+ ActivityConfigurationDialog<BiomobyActivity, BiomobyActivityConfigurationBean> currentDialog = ActivityConfigurationAction
+ .getDialog(getActivity());
+ if (currentDialog != null) {
+ currentDialog.toFront();
+ return;
+ }
+
+ final BiomobyConfigView biomobyConfigView = new BiomobyConfigView(
+ (BiomobyActivity) getActivity());
+ final ActivityConfigurationDialog<BiomobyActivity, BiomobyActivityConfigurationBean> dialog = new ActivityConfigurationDialog<BiomobyActivity, BiomobyActivityConfigurationBean>(
+ getActivity(), biomobyConfigView, editManager, fileManager);
+
+ ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager);
+ }
+
+ public boolean isEnabled() {
+ BiomobyActivity activity = (BiomobyActivity) getActivity();
+ return (activity.getMobyService() != null && activity.containsSecondaries());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyObjectActionHelper.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyObjectActionHelper.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyObjectActionHelper.java
new file mode 100644
index 0000000..9ff9d67
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyObjectActionHelper.java
@@ -0,0 +1,787 @@
+/*
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Vector;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSeparator;
+import javax.swing.JTree;
+import javax.swing.ToolTipManager;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreePath;
+import javax.swing.tree.TreeSelectionModel;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.activities.biomoby.edits.AddBiomobyConsumingServiceEdit;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workflowmodel.Dataflow;
+import net.sf.taverna.t2.workflowmodel.Edit;
+import net.sf.taverna.t2.workflowmodel.Edits;
+import net.sf.taverna.t2.workflowmodel.OutputPort;
+
+import org.apache.log4j.Logger;
+import org.biomoby.client.CentralImpl;
+import org.biomoby.registry.meta.Registry;
+import org.biomoby.shared.Central;
+import org.biomoby.shared.MobyData;
+import org.biomoby.shared.MobyDataType;
+import org.biomoby.shared.MobyException;
+import org.biomoby.shared.MobyNamespace;
+import org.biomoby.shared.MobyPrimaryDataSet;
+import org.biomoby.shared.MobyPrimaryDataSimple;
+import org.biomoby.shared.MobyService;
+import org.biomoby.shared.data.MobyDataInstance;
+import org.biomoby.shared.data.MobyDataObject;
+import org.biomoby.shared.data.MobyDataObjectSet;
+
+public class BiomobyObjectActionHelper {
+
+ private static Logger logger = Logger
+ .getLogger(BiomobyObjectActionHelper.class);
+
+ private boolean searchParentTypes = false;
+
+ private OutputPort outputPort = null;
+
+ private MobyNamespace[] namespaces = null;
+
+ private EditManager editManager;
+
+ private final FileManager fileManager;
+
+ public BiomobyObjectActionHelper(boolean searchParentTypes, EditManager editManager, FileManager fileManager) {
+ super();
+ this.searchParentTypes = searchParentTypes;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ }
+
+ public BiomobyObjectActionHelper(OutputPort outputPort, boolean searchParentTypes, EditManager editManager, FileManager fileManager) {
+ super();
+ this.searchParentTypes = searchParentTypes;
+ this.outputPort = outputPort;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ }
+
+ public BiomobyObjectActionHelper(EditManager editManager, FileManager fileManager) {
+ super();
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ }
+
+ private class Worker extends Thread {
+ private BiomobyObjectActivity activity;
+
+ private BiomobyObjectActionHelper action;
+
+ private JPanel panel = new JPanel(new BorderLayout());
+
+ private JPanel namespacePanel = new JPanel(new BorderLayout());
+
+ private JProgressBar bar = new JProgressBar();
+
+ private JTree namespaceList = null;
+
+ public Worker(BiomobyObjectActivity activity, BiomobyObjectActionHelper object) {
+ super("Biomoby object action worker");
+ this.activity = activity;
+ this.action = object;
+ }
+
+ /*
+ * method to show the progress bar
+ */
+ private void setUpProgressBar(String text) {
+ bar = new JProgressBar();
+ bar.setIndeterminate(true);
+ bar.setValue(0);
+ bar.setStringPainted(true);
+ bar.setVisible(true);
+ bar.setString(text);
+ if (panel != null){
+ panel.add(bar, BorderLayout.PAGE_END);
+ panel.updateUI();
+ }
+ }
+
+ private void takeDownProgressBar() {
+ if (panel != null) {
+ panel.remove(bar);
+ panel.updateUI();
+ }
+
+ }
+
+ public JPanel getPanel() {
+ return this.panel;
+ }
+
+ public void run() {
+ Central central = activity.getCentral();
+ // ask if we should restrict query by namespace
+ // only do this if we dont have an output port
+ if (action.outputPort == null) {
+ if (JOptionPane.YES_OPTION ==
+ JOptionPane.showConfirmDialog(null, "Would you like to restrict your search by based upon a namespace?\n" +
+ "This can allow you to find only those services that operate on a specific kind of data.",
+ "Restrict query space", JOptionPane.YES_NO_OPTION)) {
+ // create a JList chooser with a done button here
+ setUpProgressBar("Getting namespaces list");
+ try {
+ namespacePanel = new JPanel(new BorderLayout());
+ createNamespaceList(central.getFullNamespaces());
+ JButton button = new JButton("Done");
+ button.addActionListener(new ActionListener(){
+ @SuppressWarnings("unchecked")
+ public void actionPerformed(
+ ActionEvent e) {
+ ArrayList<MobyNamespace> chosen = new ArrayList<MobyNamespace>();
+ TreePath[] paths = namespaceList.getSelectionPaths();
+ for (TreePath p : paths) {
+ if (p.getLastPathComponent() instanceof DefaultMutableTreeNode) {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)p.getLastPathComponent();
+ if (node.isRoot()) {
+ chosen = new ArrayList<MobyNamespace>();
+ break;
+ }
+ if (!node.isLeaf()) {
+ // get the children and add them to chosen
+ Enumeration<DefaultMutableTreeNode> children = node.children();
+ while (children.hasMoreElements() )
+ chosen.add(new MobyNamespace(children.nextElement().toString()));
+ } else {
+ // is a leaf ... add to chosen
+ chosen.add(new MobyNamespace(node.toString()));
+ }
+ }
+ }
+ // set the namespaces that were selected
+ setNamespaces(chosen.toArray(new MobyNamespace[]{}));
+ // get the tree - in a new thread
+ Thread t = new Thread(){
+ public void run() {
+ namespacePanel.setVisible(false);
+ setUpProgressBar("Getting BioMOBY details for " + activity.getConfiguration().getServiceName() + " ...");
+ getSemanticServiceTree();
+ }};
+ t.setDaemon(true);
+ t.start();
+
+ }});
+ // add the list and button to the panel
+ namespacePanel.add(new JScrollPane(namespaceList), BorderLayout.CENTER);
+ namespacePanel.add(button, BorderLayout.PAGE_END);
+ panel.add(namespacePanel, BorderLayout.CENTER);
+ panel.updateUI();
+ } catch (MobyException e) {
+ logger.error("", e);
+ takeDownProgressBar();
+ }
+ takeDownProgressBar();
+ // once done is pressed, insert selected namespace into the namespaces array
+ // show the progress bar
+
+ } else {
+ // start our search
+ setNamespaces(null);
+ setUpProgressBar("Getting BioMOBY details for " + activity.getConfiguration().getServiceName() + " ...");
+ getSemanticServiceTree();
+ }
+ } else {
+ // search only for those services that consume the correct namespaces
+ if (this.action != null && this.action.getNamespaces() != null) {
+ setNamespaces(this.action.getNamespaces());
+ } else {
+ setNamespaces(null);
+ }
+ setUpProgressBar("Getting BioMOBY details for " + activity.getConfiguration().getServiceName() + " ...");
+ // start our search
+ getSemanticServiceTree();
+ }
+
+
+ }
+
+ /**
+ * @param central
+ */
+ private void getSemanticServiceTree() {
+ Central central = activity.getCentral();
+ MobyDataType object = activity.getMobyObject();
+ MobyService template = new MobyService("dummy");
+
+ // strip the lsid portion of the name
+ String name = object.getName();
+ if (name.indexOf(":") > 0) {
+ name = name.substring(name.lastIndexOf(":") + 1);
+ }
+ // initialize a data object to pass into the service template
+ Registry mRegistry = new Registry(central.getRegistryEndpoint(),central.getRegistryEndpoint(),"http://domain.com/MOBY/Central");
+ MobyDataObject data = new MobyDataObject("", mRegistry);
+ data.setDataType(new MobyDataType(name));
+ data.setXmlMode(MobyDataInstance.CENTRAL_XML_MODE);
+ if (action.namespaces != null)
+ data.setNamespaces(action.namespaces);
+ // create the nodes for the tree
+ MutableTreeNode parent = new DefaultMutableTreeNode(name);
+ MutableTreeNode inputNode = new DefaultMutableTreeNode("Feeds into");
+ MutableTreeNode outputNode = new DefaultMutableTreeNode("Produced by");
+
+ // what services does this object feed into?
+ template.setInputs(new MobyData[] { data });
+ template.setCategory("");
+ MobyService[] services = null;
+ Set<MobyService> theServices = new TreeSet<MobyService>();
+ try {
+ services = central.findService(template, null, true, action.searchParentTypes);
+
+ theServices.addAll(Arrays.asList(services));
+ MobyDataObjectSet set = new MobyDataObjectSet("");
+ set.add(data);
+ template.setInputs(null);
+ template.setInputs(new MobyData[]{set});
+ services = central.findService(template, null, true, action.searchParentTypes);
+ theServices.addAll(Arrays.asList(services));
+ } catch (MobyException e) {
+ panel.add(new JTree(new String[] { "Error finding services",
+ "TODO: create a better Error" }), BorderLayout.CENTER);
+ panel.updateUI();
+ return;
+ }
+ createTreeNodes(inputNode, theServices.toArray(new MobyService[]{}));
+ if (inputNode.getChildCount() == 0)
+ inputNode.insert(new DefaultMutableTreeNode(
+ "Object Doesn't Currently Feed Into Any Services"), 0);
+
+ // what services return this object?
+ template = null;
+ template = new MobyService("dummy");
+ template.setCategory("");
+ template.setOutputs(new MobyData[] { data });
+ services = null;
+ theServices = new TreeSet<MobyService>();
+ try {
+ services = central.findService(template, null, true, action.searchParentTypes);
+ theServices.addAll(Arrays.asList(services));
+ MobyDataObjectSet set = new MobyDataObjectSet("");
+ set.add(data);
+ template.setOutputs(null);
+ template.setOutputs(new MobyData[]{set});
+ services = central.findService(template, null, true, action.searchParentTypes);
+ theServices.addAll(Arrays.asList(services));
+ } catch (MobyException e) {
+ panel.add(new JTree(new String[] { "Error finding services",
+ "TODO: create a better Error" }), BorderLayout.CENTER);
+ panel.updateUI();
+ return;
+ }
+ createTreeNodes(outputNode, theServices.toArray(new MobyService[]{}));
+ if (outputNode.getChildCount() == 0)
+ outputNode.insert(new DefaultMutableTreeNode(
+ "Object Isn't Produced By Any Services"), 0);
+ // what kind of object is this?
+
+ // set up the nodes
+ parent.insert(inputNode, 0);
+ parent.insert(outputNode, 1);
+
+ // finally return a tree describing the object
+ final JTree tree = new JTree(parent);
+ tree.setCellRenderer(new BioMobyObjectTreeCustomRenderer());
+ ToolTipManager.sharedInstance().registerComponent(tree);
+ tree.addMouseListener(new MouseListener() {
+ public void mouseClicked(MouseEvent me) {
+ }
+
+ public void mousePressed(MouseEvent me) {
+ mouseReleased(me);
+ }
+
+ public void mouseReleased(MouseEvent me) {
+ if (me.isPopupTrigger()) // right click, show popup menu
+ {
+ TreePath path = tree.getPathForLocation(me.getX(), me.getY());
+ if (path == null)
+ return;
+ if (path.getPathCount() == 4) {
+ if (path.getParentPath().getParentPath().getLastPathComponent()
+ .toString().equals("Feeds into")) {
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
+ .getLastSelectedPathComponent();
+ if (node == null)
+ return;
+ final String selectedService = node.toString();
+ // ensure that the last selected item is a
+ // service!
+ if (!selectedService.equals(path.getLastPathComponent().toString()))
+ return;
+ final String selectedAuthority = path.getParentPath()
+ .getLastPathComponent().toString();
+ final JPopupMenu menu = new JPopupMenu();
+ // Create and add a menu item for adding to the
+ // item
+ // to the workflow
+ JMenuItem item = new JMenuItem("Add service - " + selectedService
+ + " to the workflow?");
+ item
+ .setIcon(MobyPanel.getIcon("/Add24.gif"));
+ item.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+
+ try {
+ if (outputPort==null) {
+ outputPort = activity.getOutputPorts().iterator().next();
+ }
+ Dataflow currentDataflow = fileManager.getCurrentDataflow();
+ Edit<?> edit = new AddBiomobyConsumingServiceEdit(
+ currentDataflow, activity,
+ selectedService,selectedAuthority,outputPort, editManager.getEdits());
+ editManager.doDataflowEdit(
+ currentDataflow, edit);
+
+ } catch (Exception e) {
+ logger.error("Could not perform action", e);
+ }
+ }
+ });
+ // Create and add a menu item for service
+ // details
+ JMenuItem details = new JMenuItem("Find out about "
+ + selectedService);
+ details
+ .setIcon(MobyPanel.getIcon("/Information24.gif"));
+ details.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ // Create a frame
+ Frame frame = MobyPanel.CreateFrame("A BioMoby Service Description");
+ frame.setSize(getFrameSize());
+ JPanel panel = new MobyPanel(selectedService,"A BioMoby Service Description",
+ createServiceDescription(selectedService,
+ selectedAuthority, activity.getConfiguration().getMobyEndpoint()));
+ frame.add(panel);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private String createServiceDescription(String selectedService,
+ String selectedAuthority, String endpoint) {
+ StringBuffer sb = new StringBuffer();
+ String newline = System.getProperty("line.separator");
+ MobyService service = new MobyService(selectedService);
+ try {
+ Central central = new CentralImpl(endpoint);
+ service.setAuthority(selectedAuthority);
+ service.setCategory("");
+ MobyService[] services = central.findService(service);
+ if (services == null || services.length != 1) {
+ return "Couldn't retrieve a description on the BioMoby service '"
+ + selectedService + "'";
+ }
+ service = services[0];
+
+ } catch (MobyException e) {
+ logger.error("Could not retrieve a description on the BioMoby service "
+ + selectedService, e);
+ return "Couldn't retrieve a description on the BioMoby service '"
+ + selectedService + "'";
+ }
+ sb.append("Service Contact: " + newline + "\t"
+ + service.getEmailContact() + newline);
+ sb.append("Service Category: " + newline + "\t"
+ + service.getCategory() + newline);
+ sb.append("Service Authority: " + newline + "\t"
+ + service.getAuthority() + newline);
+ sb.append("Service Type: " + newline + "\t"
+ + service.getType() + newline);
+ sb.append("Service Description: " + newline + "\t"
+ + service.getDescription() + newline);
+ sb.append("Location of Service: " + newline + "\t"
+ + service.getURL() + newline);
+ sb.append("Service Signature RDF Document is located at: "
+ + newline + "\t" + service.getSignatureURL()
+ + newline);
+ MobyData[] data = service.getPrimaryInputs();
+ Vector primaryDataSimples = new Vector();
+ Vector primaryDataSets = new Vector();
+ for (int x = 0; x < data.length; x++) {
+ if (data[x] instanceof MobyPrimaryDataSimple)
+ primaryDataSimples.add(data[x]);
+ else
+ primaryDataSets.add(data[x]);
+ }
+ // describe inputs simple then
+ // collections
+ sb.append("Inputs:" + newline);
+ if (primaryDataSimples.size() == 0) {
+ sb.append("\t\tNo Simple input datatypes consumed."
+ + newline);
+ } else {
+ Iterator it = primaryDataSimples.iterator();
+ sb
+ .append("\t\tService consumes the following Simple(s):"
+ + newline);
+ while (it.hasNext()) {
+ MobyPrimaryDataSimple simple = (MobyPrimaryDataSimple) it
+ .next();
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ sb.append("\t\tData type: "
+ + simple.getDataType().getName() + newline);
+ sb.append("\t\t\tArticle name: " + simple.getName()
+ + newline);
+ if (namespaces.length == 0) {
+ sb.append("\t\t\tValid Namespaces: ANY"
+ + newline);
+ } else {
+ sb.append("\t\t\tValid Namespaces: ");
+ for (int x = 0; x < namespaces.length; x++)
+ sb.append(namespaces[x].getName() + " ");
+ sb.append(newline);
+ }
+ }
+ }
+ if (primaryDataSets.size() == 0) {
+ sb.append(newline
+ + "\t\tNo Collection input datatypes consumed."
+ + newline);
+ } else {
+ Iterator it = primaryDataSets.iterator();
+ sb
+ .append(newline
+ + "\t\tService consumes the following collection(s) of datatypes:"
+ + newline);
+ while (it.hasNext()) {
+ MobyPrimaryDataSet set = (MobyPrimaryDataSet) it
+ .next();
+ MobyPrimaryDataSimple simple = null;
+ sb.append("\t\tCollection Name:" + set.getName()
+ + newline);
+ MobyPrimaryDataSimple[] simples = set.getElements();
+ for (int i = 0; i < simples.length; i++) {
+ simple = simples[i];
+ MobyNamespace[] namespaces = simple
+ .getNamespaces();
+ // iterate through set and
+ // do
+ // the following
+ sb.append("\t\tData type: "
+ + simple.getDataType().getName()
+ + newline);
+ sb.append("\t\t\tArticle name: "
+ + simple.getName() + newline);
+ if (namespaces.length == 0) {
+ sb.append("\t\t\tValid Namespaces: ANY"
+ + newline);
+ } else {
+ sb.append("\t\t\tValid Namespaces: ");
+ for (int x = 0; x < namespaces.length; x++)
+ sb
+ .append(namespaces[x].getName()
+ + " ");
+ sb.append(newline);
+ }
+ }
+ }
+ }
+ // describe secondary inputs
+ // describe outputs simple then
+ // collections
+ data = service.getPrimaryOutputs();
+ primaryDataSimples = new Vector();
+ primaryDataSets = new Vector();
+ for (int x = 0; x < data.length; x++) {
+ if (data[x] instanceof MobyPrimaryDataSimple)
+ primaryDataSimples.add(data[x]);
+ else
+ primaryDataSets.add(data[x]);
+ }
+ sb.append("Outputs:" + newline);
+ if (primaryDataSimples.size() == 0) {
+ sb.append("\t\tNo Simple output datatypes produced."
+ + newline);
+ } else {
+ Iterator it = primaryDataSimples.iterator();
+ sb
+ .append("\t\tService produces the following Simple(s):"
+ + newline);
+ while (it.hasNext()) {
+ MobyPrimaryDataSimple simple = (MobyPrimaryDataSimple) it
+ .next();
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ sb.append("\t\tData type: "
+ + simple.getDataType().getName() + newline);
+ sb.append("\t\t\tArticle name: " + simple.getName()
+ + newline);
+ if (namespaces.length == 0) {
+ sb.append("\t\t\tValid Namespaces: ANY"
+ + newline);
+ } else {
+ sb.append("\t\t\tValid Namespaces: ");
+ for (int x = 0; x < namespaces.length; x++)
+ sb.append(namespaces[x].getName() + " ");
+ sb.append(newline);
+ }
+ }
+ }
+ if (primaryDataSets.size() == 0) {
+ sb
+ .append(newline
+ + "\t\tNo Collection output datatypes produced."
+ + newline);
+ } else {
+ Iterator it = primaryDataSets.iterator();
+ sb
+ .append(newline
+ + "\t\tService produces the following collection(s) of datatypes:"
+ + newline);
+ while (it.hasNext()) {
+ MobyPrimaryDataSet set = (MobyPrimaryDataSet) it
+ .next();
+ MobyPrimaryDataSimple simple = null;
+ sb.append("\t\tCollection Name:" + set.getName()
+ + newline);
+ MobyPrimaryDataSimple[] simples = set.getElements();
+ for (int i = 0; i < simples.length; i++) {
+ simple = simples[i];
+ MobyNamespace[] namespaces = simple
+ .getNamespaces();
+ // iterate through set and
+ // do
+ // the following
+ sb.append("\t\tData type: "
+ + simple.getDataType().getName()
+ + newline);
+ sb.append("\t\t\tArticle name: "
+ + simple.getName() + newline);
+ if (namespaces.length == 0) {
+ sb.append("\t\t\tValid Namespaces: ANY"
+ + newline);
+ } else {
+ sb.append("\t\t\tValid Namespaces: ");
+ for (int x = 0; x < namespaces.length; x++)
+ sb
+ .append(namespaces[x].getName()
+ + " ");
+ sb.append(newline);
+ }
+ }
+ }
+ }
+ sb.append((service.isAuthoritative()) ? newline
+ + "The service belongs to this author." + newline
+ : newline
+ + "The service was wrapped by it's author."
+ + newline);
+ return sb.toString();
+ }
+ });
+ // add the components to the menus
+ menu.add(new JLabel("Add to workflow ... ", JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(item);
+ menu.add(new JSeparator());
+ menu.add(new JLabel("Service Details ... ", JLabel.CENTER));
+ menu.add(new JSeparator());
+ menu.add(details);
+ // show the window
+ menu.show(me.getComponent(), me.getX(), me.getY());
+ }
+ }
+ }
+ }
+
+ public void mouseEntered(MouseEvent me) {
+ }
+
+ public void mouseExited(MouseEvent me) {
+ }
+ });
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
+ panel.add(new JScrollPane(tree), BorderLayout.CENTER);
+ takeDownProgressBar();
+ }
+
+ private void createNamespaceList(MobyNamespace[] fullNamespaces) {
+ // sort the namespaces alphabetically
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("ANY");
+ // assuming that they increment by one ...
+ TreeMap<String, TreeSet<String>> sorted = new TreeMap<String, TreeSet<String>>();
+ for (MobyNamespace n : fullNamespaces) {
+ String name = n.getName();
+ String key = name.toUpperCase().substring(0, 1);
+ if (sorted.get(key) == null) {
+ sorted.put(key, new TreeSet<String>());
+ }
+ sorted.get(key).add(name);
+ }
+ for (String o : sorted.keySet()) {
+ if (sorted.get(o) == null)
+ continue;
+ TreeSet<String> set = sorted.get(o);
+ String first = set.first().toUpperCase().charAt(0) + "";
+ DefaultMutableTreeNode node = new DefaultMutableTreeNode(first);
+ for (String s : set) {
+ node.add(new DefaultMutableTreeNode(s));
+ }
+ root.add(node);
+ }
+ namespaceList = new JTree(root);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.embl.ebi.escience.scuflui.processoractions.AbstractProcessorAction#getComponent(org.embl.ebi.escience.scufl.Processor)
+ */
+ public JComponent getComponent(BiomobyObjectActivity activity) {
+
+ // this was done so that for longer requests, something is shown visually and the user then wont think that nothing happened.
+ Worker worker = new Worker(activity, this);
+ worker.start();
+ return worker.getPanel();
+ }
+
+ /*
+ * method that processes the services returned by findService and adds them
+ * to the TreeNode parentNode, sorted by authority
+ */
+ @SuppressWarnings("unchecked")
+ private void createTreeNodes(MutableTreeNode parentNode, MobyService[] services) {
+ HashMap inputHash;
+ inputHash = new HashMap();
+ for (int x = 0; x < services.length; x++) {
+ DefaultMutableTreeNode authorityNode = null;
+ if (!inputHash.containsKey(services[x].getAuthority())) {
+ authorityNode = new DefaultMutableTreeNode(services[x].getAuthority());
+ } else {
+ authorityNode = (DefaultMutableTreeNode) inputHash.get(services[x].getAuthority());
+ }
+ MobyServiceTreeNode serv = new MobyServiceTreeNode(services[x].getName(), services[x]
+ .getDescription());
+ MutableTreeNode temp = new DefaultMutableTreeNode(serv);
+ DefaultMutableTreeNode objects = new DefaultMutableTreeNode("Produces");
+ // add to this node the MobyObjectTreeNodes that it produces!
+ MobyData[] outputs = services[x].getPrimaryOutputs();
+ for (int i = 0; i < outputs.length; i++) {
+ if (outputs[i] instanceof MobyPrimaryDataSimple) {
+ MobyPrimaryDataSimple simple = (MobyPrimaryDataSimple) outputs[i];
+ StringBuffer sb = new StringBuffer("Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int j = 0; j < namespaces.length; j++) {
+ sb.append(namespaces[j].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append("ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(simple
+ .getDataType().getName()
+ + "('" + simple.getName() + "')", sb.toString());
+ objects.insert(new DefaultMutableTreeNode(mobyObjectTreeNode), objects
+ .getChildCount());
+ } else {
+ // we have a collection
+ MobyPrimaryDataSet collection = (MobyPrimaryDataSet) outputs[i];
+ DefaultMutableTreeNode collectionNode = new DefaultMutableTreeNode(
+ "Collection('" + collection.getName() + "')");
+ objects.insert(collectionNode, objects.getChildCount());
+ MobyPrimaryDataSimple[] simples = collection.getElements();
+ for (int j = 0; j < simples.length; j++) {
+ MobyPrimaryDataSimple simple = simples[j];
+ StringBuffer sb = new StringBuffer("Namespaces used by this object: ");
+ MobyNamespace[] namespaces = simple.getNamespaces();
+ for (int k = 0; k < namespaces.length; k++) {
+ sb.append(namespaces[k].getName() + " ");
+ }
+ if (namespaces.length == 0)
+ sb.append("ANY ");
+ MobyObjectTreeNode mobyObjectTreeNode = new MobyObjectTreeNode(simple
+ .getDataType().getName()
+ + "('" + simple.getName() + "')", sb.toString());
+ collectionNode.insert(new DefaultMutableTreeNode(mobyObjectTreeNode),
+ collectionNode.getChildCount());
+ }
+
+ }
+ }
+
+ temp.insert(objects, temp.getChildCount());
+
+ authorityNode.insert(temp, authorityNode.getChildCount());
+ inputHash.put(services[x].getAuthority(), authorityNode);
+
+ }
+ Set set = inputHash.keySet();
+ SortedSet sortedset = new TreeSet(set);
+ for (Iterator it = sortedset.iterator(); it.hasNext();) {
+ parentNode.insert((DefaultMutableTreeNode) inputHash.get((String) it.next()),
+ parentNode.getChildCount());
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.embl.ebi.escience.scuflui.processoractions.ProcessorActionSPI#getDescription()
+ */
+ public String getDescription() {
+ return "Moby Object Details";
+ }
+
+ /*
+ *
+ */
+ public ImageIcon getIcon() {
+ return MobyPanel.getIcon("/moby_small.gif");
+ }
+
+ /**
+ * returns the frame size as a dimension for the content pane housing this
+ * action
+ */
+ public Dimension getFrameSize() {
+ return new Dimension(450, 450);
+ }
+
+ public void setNamespaces(MobyNamespace[] namespaces) {
+ if (namespaces != null && namespaces.length == 0)
+ this.namespaces = null;
+ else
+ this.namespaces = namespaces;
+ }
+ public MobyNamespace[] getNamespaces() {
+ return this.namespaces == null ? new MobyNamespace[]{} : this.namespaces;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyScavengerDialog.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyScavengerDialog.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyScavengerDialog.java
new file mode 100644
index 0000000..4419bf9
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/BiomobyScavengerDialog.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+/*
+ * This file is a component of the Taverna project,
+ * and is licensed under the GNU LGPL.
+ * Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.biomoby.registry.meta.Registries;
+import org.biomoby.registry.meta.RegistriesList;
+import org.biomoby.shared.MobyException;
+
+import net.sf.taverna.t2.lang.ui.ShadedLabel;
+
+/**
+ * a dialog for helping create scavengers for BioMoby registries that are not
+ * the default registry.
+ *
+ */
+public class BiomobyScavengerDialog extends JPanel {
+
+ private static final String CUSTOM = "Custom";
+ private static final long serialVersionUID = -57047613557546674L;
+ private JTextField registryEndpoint = new JTextField(
+ "http://moby.ucalgary.ca/moby/MOBY-Central.pl");
+ private JTextField registryURI = new JTextField(
+ "http://moby.ucalgary.ca/MOBY/Central");
+
+ /**
+ * Default constructor.
+ *
+ */
+ /**
+ * Default constructor.
+ *
+ */
+ public BiomobyScavengerDialog() {
+ super();
+ GridLayout layout = new GridLayout(5, 2);
+ setLayout(layout);
+
+ registryEndpoint.setEnabled(false);
+ registryURI.setEnabled(false);
+
+ // a combo box showing known registries
+ final Registries regs = RegistriesList.getInstance();
+ List<String> choices = new ArrayList<String>(Arrays.asList(regs.list()));
+ choices.add(CUSTOM);
+
+ JComboBox regList = new JComboBox(choices.toArray());
+ regList.setToolTipText("A selection will fill text fields below");
+ regList.setSelectedItem(Registries.DEFAULT_REGISTRY_SYNONYM);
+ regList.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ String contents = (String) ((JComboBox) e.getSource())
+ .getSelectedItem();
+
+ if (contents.equals(CUSTOM)) {
+ registryEndpoint.setEnabled(true);
+ registryURI.setEnabled(true);
+ return;
+ } else {
+ registryEndpoint.setEnabled(false);
+ registryURI.setEnabled(false);
+ }
+ org.biomoby.registry.meta.Registry theReg = null;
+ try {
+ theReg = regs.get(contents);
+ } catch (MobyException ee) {
+ try {
+ theReg = regs.get(null);
+ } catch (MobyException ee2) {
+
+ }
+ }
+ if (theReg != null) {
+ registryEndpoint.setText(theReg.getEndpoint());
+ registryURI.setText(theReg.getNamespace());
+
+ }
+ }
+ });
+ add(new ShadedLabel("Choose a registry from the list: ",
+ ShadedLabel.BLUE, true));
+ add(regList);
+ add(new ShadedLabel("Or select '" + CUSTOM + "' to enter your own below,", ShadedLabel.BLUE, true));
+ add(new ShadedLabel("", ShadedLabel.BLUE, true));
+ add(new ShadedLabel(
+ "Location (URL) of your BioMoby central registry: ",
+ ShadedLabel.BLUE, true));
+ registryEndpoint
+ .setToolTipText("BioMoby Services will be retrieved from the endpoint that you specify here!");
+ add(registryEndpoint);
+ add(new ShadedLabel(
+ "Namespace (URI) of your BioMoby central registry: ",
+ ShadedLabel.BLUE, true));
+ registryURI
+ .setToolTipText("BioMoby Services will be retrieved from the endpoint/URI that you specify here!");
+ add(registryURI);
+ // add(Box.createHorizontalGlue());add(Box.createHorizontalGlue());
+ setPreferredSize(this.getPreferredSize());
+ setMinimumSize(this.getPreferredSize());
+ setMaximumSize(this.getPreferredSize());
+
+ }
+
+ /**
+ *
+ * @return the string representation of the BioMoby Registry endpoint
+ */
+ public String getRegistryEndpoint() {
+ return registryEndpoint.getText();
+ }
+
+ /**
+ *
+ * @return the string representation of the BioMoby Registry endpoint
+ */
+ public String getRegistryURI() {
+ return registryURI.getText();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectDetailsAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectDetailsAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectDetailsAction.java
new file mode 100644
index 0000000..803fde3
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectDetailsAction.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JDialog;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+@SuppressWarnings("serial")
+public class MobyObjectDetailsAction extends AbstractAction {
+
+ private final BiomobyObjectActivity activity;
+ private final Frame owner;
+ private EditManager editManager;
+
+ private static final String MOBY_OBJECT_DETAILS_ACTION = "Datatype registry query";
+ private final FileManager fileManager;
+
+ public MobyObjectDetailsAction(BiomobyObjectActivity activity, Frame owner, EditManager editManager, FileManager fileManager) {
+ this.activity = activity;
+ this.owner = owner;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ putValue(NAME, MOBY_OBJECT_DETAILS_ACTION);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ BiomobyObjectActionHelper helper = new BiomobyObjectActionHelper(editManager, fileManager);
+ Dimension size = helper.getFrameSize();
+
+ Component component = helper.getComponent(activity);
+
+ final JDialog dialog = new HelpEnabledDialog(owner, helper.getDescription(), false, null);
+ dialog.getContentPane().add(component);
+ dialog.pack();
+ // dialog.setTitle(helper.getDescription());
+ dialog.setSize(size);
+ // dialog.setModal(false);
+ dialog.setVisible(true);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectTreeNode.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectTreeNode.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectTreeNode.java
new file mode 100644
index 0000000..f58efc6
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyObjectTreeNode.java
@@ -0,0 +1,50 @@
+/*
+ * This file is a component of the Taverna project,
+ * and is licensed under the GNU LGPL.
+ * Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import org.biomoby.shared.MobyNamespace;
+
+public class MobyObjectTreeNode {
+
+ // name of the object == node name
+ private String name = "";
+
+ // description of object == tool tip text
+ private String description = "";
+
+ private MobyNamespace[] ns = null;
+ /**
+ *
+ * @param name - the name of the Moby Object
+ * @param description - the description of the Moby Service
+ */
+ public MobyObjectTreeNode(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+ /*
+ * over-ride the toString method in order to print node values
+ * that make sense.
+ */
+ public String toString() {
+ return name;
+ }
+
+ public void setNamespaces(MobyNamespace[] namespaces) {
+ if (namespaces != null && namespaces.length == 0)
+ this.ns = null;
+ else
+ this.ns = namespaces;
+ }
+
+ public MobyNamespace[] getNamespaces() {
+ return this.ns;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyPanel.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyPanel.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyPanel.java
new file mode 100644
index 0000000..a2e0a70
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyPanel.java
@@ -0,0 +1,136 @@
+/*
+ * Created on Sep 9, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.BorderLayout;
+import java.awt.Frame;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.ImageIcon;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import net.sf.taverna.t2.lang.ui.DialogTextArea;
+
+/**
+ * @author Eddie Kawas
+ *
+ *
+ */
+public class MobyPanel extends JPanel {
+
+
+ private static final long serialVersionUID = 1L;
+ private DialogTextArea textArea = null;
+ private String text = "";
+ private String name = "";
+ private JLabel jLabel = new JLabel();
+
+ /**
+ * This is the default constructor
+ */
+ public MobyPanel(String label, String name, String text) {
+ super(new BorderLayout());
+ jLabel.setText(label);
+ this.text = text;
+ this.name = name;
+ initialize();
+ }
+
+ public MobyPanel(String label) {
+ super(new BorderLayout());
+ jLabel.setText(label);
+ initialize();
+ }
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(450, 450);
+ jLabel.setHorizontalAlignment(JLabel.CENTER);
+ add(jLabel, BorderLayout.NORTH);
+ add(getTextArea(), BorderLayout.CENTER);
+ }
+
+ /**
+ * This method initializes jTextArea
+ *
+ * @return DialogTextArea
+ */
+ private DialogTextArea getTextArea() {
+ if (textArea == null) {
+ textArea = new DialogTextArea();
+ }
+ textArea.setLineWrap(true);
+ textArea.setWrapStyleWord(true);
+ textArea.setText(this.text);
+ textArea.setEditable(false);
+ textArea.setEnabled(true);
+ textArea.setAutoscrolls(true);
+ textArea.setCaretPosition(0);
+ return textArea;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ if (textArea == null) {
+ textArea = new DialogTextArea(this.text);
+ }
+ textArea.setText(text);
+ }
+
+ /* (non-Javadoc)
+ * @see org.embl.ebi.escience.scuflui.ScuflUIComponent#getIcon()
+ */
+ public ImageIcon getIcon() {
+ return new ImageIcon(MobyPanel.class.getResource("/moby_small.png"));
+ }
+
+ /**
+ *
+ * @param icon a relative path to an icon to get
+ * @return the ImageIcon at icon
+ */
+ public static ImageIcon getIcon(String icon) {
+ return new ImageIcon(MobyPanel.class.getResource(icon));
+ }
+
+ public String getName(){
+ if (name==null) return "";
+ else return name;
+ }
+
+ public void onDisplay() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onDispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public static Frame CreateFrame(String title) {
+ // Create a frame
+ Frame frame = new Frame(title);
+ // Add a listener for the close event
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent evt) {
+ Frame frame = (Frame)evt.getSource();
+ // Hide the frame
+ frame.setVisible(false);
+ // If the frame is no longer needed, call dispose
+ frame.dispose();
+ }
+ });
+ return frame;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyParserAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyParserAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyParserAction.java
new file mode 100644
index 0000000..865c1f1
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyParserAction.java
@@ -0,0 +1,70 @@
+/**
+ * Copyright (C) 2007 The University of Manchester
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JDialog;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+@SuppressWarnings("serial")
+public class MobyParserAction extends AbstractAction {
+
+ private final BiomobyActivity activity;
+ private final Frame owner;
+ private EditManager editManager;
+ private final FileManager fileManager;
+
+ public MobyParserAction(BiomobyActivity activity, Frame owner, EditManager editManager, FileManager fileManager) {
+ this.activity = activity;
+ this.owner = owner;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ putValue(NAME, "Add Biomoby parser");
+
+ }
+ public void actionPerformed(ActionEvent e) {
+ AddParserActionHelper helper = new AddParserActionHelper(editManager, fileManager);
+ Component component = helper.getComponent(activity);
+
+ final JDialog dialog = new HelpEnabledDialog(owner, helper.getDescription(), false, null);
+ dialog.getContentPane().add(component);
+ dialog.pack();
+// dialog.setSize(helper.getFrameSize());
+ dialog.setTitle(helper.getDescription());
+// dialog.setModal(false);
+ dialog.setVisible(true);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceDetailsAction.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceDetailsAction.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceDetailsAction.java
new file mode 100644
index 0000000..5000986
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceDetailsAction.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * This file is a component of the Taverna project, and is licensed under the
+ * GNU LGPL. Copyright Edward Kawas, The BioMoby Project
+ ******************************************************************************/
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JDialog;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyActivity;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
+
+/**
+ * @author Stuart Owen
+ *
+ */
+@SuppressWarnings("serial")
+public class MobyServiceDetailsAction extends AbstractAction {
+
+ private final BiomobyActivity activity;
+ private final Frame owner;
+ private EditManager editManager;
+
+ private static final String MOBY_SERVICE_DETAILS_ACTION = "Browse Biomoby service details";
+ private final FileManager fileManager;
+ public MobyServiceDetailsAction(BiomobyActivity activity, Frame owner, EditManager editManager, FileManager fileManager) {
+ this.activity = activity;
+ this.owner = owner;
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ putValue(NAME, MOBY_SERVICE_DETAILS_ACTION);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+
+ BiomobyActionHelper helper = new BiomobyActionHelper(editManager, fileManager);
+ Dimension size = helper.getFrameSize();
+
+ Component component = helper.getComponent(activity);
+ final JDialog dialog = new HelpEnabledDialog(owner, helper.getDescription(), false, null);
+
+ dialog.getContentPane().add(component);
+ dialog.pack();
+// dialog.setTitle(helper.getDescription());
+ dialog.setSize(size);
+// dialog.setModal(false);
+ dialog.setVisible(true);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceTreeNode.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceTreeNode.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceTreeNode.java
new file mode 100644
index 0000000..c957a1f
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/MobyServiceTreeNode.java
@@ -0,0 +1,42 @@
+/*
+ * This file is a component of the Taverna project,
+ * and is licensed under the GNU LGPL.
+ * Copyright Edward Kawas, The BioMoby Project
+ */
+package net.sf.taverna.t2.activities.biomoby.actions;
+import java.util.ArrayList;
+
+public class MobyServiceTreeNode {
+
+ // name of the service == node name
+ private String name = "";
+
+ // list of objects that service produces
+ @SuppressWarnings("unused")
+ private ArrayList<MobyObjectTreeNode> mobyObjectTreeNodes = null;
+
+ // description of object == tool tip text
+ private String description = "";
+
+
+ /**
+ *
+ * @param name - the name of the Moby Service
+ * @param description - the description of the Moby Service
+ */
+ public MobyServiceTreeNode(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+ /*
+ * over-ride the toString method in order to print node values
+ * that make sense.
+ */
+ public String toString() {
+ return name;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/fd2e9765/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/PopupThread.java
----------------------------------------------------------------------
diff --git a/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/PopupThread.java b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/PopupThread.java
new file mode 100644
index 0000000..0c8b9fc
--- /dev/null
+++ b/taverna-biomoby-activity-ui/src/main/java/net/sf/taverna/t2/activities/biomoby/actions/PopupThread.java
@@ -0,0 +1,34 @@
+package net.sf.taverna.t2.activities.biomoby.actions;
+
+import java.awt.Component;
+
+import net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity;
+
+
+public class PopupThread extends Thread {
+
+ Object object = null;
+
+ BiomobyObjectActivity objectActivity = null;
+
+ BiomobyObjectActionHelper objectAction = null;
+
+ boolean done = false;
+
+ PopupThread(BiomobyObjectActivity bop, BiomobyObjectActionHelper boa) {
+ super("Biomoby popup");
+ this.objectAction = boa;
+ this.objectActivity = bop;
+ setDaemon(true);
+ }
+
+ public void run() {
+ object = objectAction.getComponent(objectActivity);
+ this.done = true;
+ }
+
+ // call after you check if done!
+ public Component getComponent() {
+ return (Component) object;
+ }
+}