Merge branch 'README'
diff --git a/pom.xml b/pom.xml
index 52fdae6..b48b4bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,43 +1,27 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sf.taverna.t2</groupId>
<artifactId>ui-activities</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
- <groupId>net.sf.taverna.t2.ui-activities</groupId>
- <artifactId>xpath-activity-ui</artifactId>
- <name>XPath Activity - UI bindings</name>
-
- <dependencies>
- <dependency>
- <groupId>net.sf.taverna.t2.activities</groupId>
- <artifactId>xpath-activity</artifactId>
- <version>${t2.activities.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>${dom4j.version}</version>
- </dependency>
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- <version>${jaxen.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>net.sf.taverna.t2.ui-api</groupId>
- <artifactId>activity-icons-api</artifactId>
- <version>${t2.ui.api.version}</version>
- <type>jar</type>
- </dependency>
- <dependency>
+ <groupId>net.sf.taverna.t2.ui-activities</groupId>
+ <artifactId>xpath-activity-ui</artifactId>
+ <packaging>bundle</packaging>
+ <name>XPath Activity - UI bindings</name>
+ <dependencies>
+ <dependency>
+ <groupId>net.sf.taverna.t2.activities</groupId>
+ <artifactId>xpath-activity</artifactId>
+ <version>${t2.activities.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.taverna.t2.ui-api</groupId>
+ <artifactId>activity-icons-api</artifactId>
+ <version>${t2.ui.api.version}</version>
+ </dependency>
+ <dependency>
<groupId>net.sf.taverna.t2.ui-api</groupId>
<artifactId>contextual-views-api</artifactId>
<version>${t2.ui.api.version}</version>
@@ -47,33 +31,37 @@
<artifactId>menu-api</artifactId>
<version>${t2.ui.api.version}</version>
</dependency>
-
- <!-- for AbstractConfigureActivityMenuAction -->
<dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
- <artifactId>activity-tools</artifactId>
- <version>${t2.ui.impl.version}</version>
- </dependency>
-
- <dependency>
+ <groupId>net.sf.taverna.t2.ui-api</groupId>
+ <artifactId>report-api</artifactId>
+ <version>${t2.ui.api.version}</version>
+ </dependency>
+ <dependency>
<groupId>net.sf.taverna.t2.ui-components</groupId>
<artifactId>workflow-view</artifactId>
<version>${t2.ui.components.version}</version>
</dependency>
- <dependency>
- <groupId>net.sf.taverna.t2.ui-components</groupId>
- <artifactId>graph-view</artifactId>
- <version>${t2.ui.components.version}</version>
- </dependency>
-
-
- <!-- for ColourManager -->
- <dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
- <artifactId>configuration-impl</artifactId>
- <version>${t2.ui.impl.version}</version>
- </dependency>
-
- </dependencies>
-
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <releases />
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>mygrid-repository</id>
+ <name>myGrid Repository</name>
+ <url>http://www.mygrid.org.uk/maven/repository
+ </url>
+ </repository>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots />
+ <id>mygrid-snapshot-repository</id>
+ <name>myGrid Snapshot Repository</name>
+ <url>http://www.mygrid.org.uk/maven/snapshot-repository</url>
+ </repository>
+ </repositories>
</project>
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java
index 1d47391..d0f131a 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java
@@ -9,109 +9,102 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
-
/**
* Auxiliary class that creates a JPanel with two labels and two text fields.
- *
+ *
* It can be used to be placed into a dialog made by JOptionPane to get two
- * input values, not just one.
- *
+ * input values, not just one.
+ *
* @author Sergejs Aleksejevs
*/
-public class TwoFieldQueryPanel extends JPanel
-{
- private JTextField tfFirstValue;
- private JTextField tfSecondValue;
-
-
- public TwoFieldQueryPanel(String firstFieldName, String secondFieldName)
- {
- this(null, firstFieldName, null, secondFieldName, null);
- }
-
- public TwoFieldQueryPanel(String message, String firstFieldName, String secondFieldName)
- {
- this(message, firstFieldName, null, secondFieldName, null);
- }
-
- public TwoFieldQueryPanel(String firstFieldName, String firstFieldDefaultValue,
- String secondFieldName, String secondFieldDefaultValue)
- {
- this(null, firstFieldName, firstFieldDefaultValue, secondFieldName, secondFieldDefaultValue);
- }
-
- public TwoFieldQueryPanel(String message,
- String firstFieldName, String firstFieldDefaultValue,
- String secondFieldName, String secondFieldDefaultValue)
- {
- super();
- this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- this.setLayout(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
-
- c.gridx = 0;
- c.gridy = 0;
- c.weightx = 0;
- c.fill = GridBagConstraints.HORIZONTAL;
- c.anchor = GridBagConstraints.WEST;
- c.insets = new Insets(3,5,3,5);
-
-
- if (message != null && message.length() > 0)
- {
- c.gridwidth = 2;
- c.insets = new Insets(5, 5, 15, 5);
- this.add(new JLabel(message), c);
-
- c.gridwidth = 1;
- c.gridx = 0;
- c.gridy++;
- c.insets = new Insets(3,5,3,5);
- }
-
-
- this.add(new JLabel(firstFieldName), c);
-
- c.gridx++;
- c.weightx = 1.0;
- tfFirstValue = new JTextField(20);
- if (firstFieldDefaultValue != null) {
- tfFirstValue.setText(firstFieldDefaultValue);
- }
- tfFirstValue.selectAll();
- tfFirstValue.requestFocusInWindow();
- this.add(tfFirstValue, c);
-
- c.gridx = 0;
- c.gridy++;
- c.weightx = 0;
- this.add(new JLabel(secondFieldName), c);
-
- c.gridx++;
- c.weightx = 1.0;
- tfSecondValue = new JTextField(20);
- if (secondFieldDefaultValue != null) {
- tfSecondValue.setText(secondFieldDefaultValue);
- }
- tfSecondValue.selectAll();
- this.add(tfSecondValue, c);
- }
-
-
- /**
- * @return Trimmed value from the first text field. Guaranteed to be non-null.
- */
- public String getFirstValue() {
- return (tfFirstValue.getText().trim());
- }
-
-
- /**
- * @return Trimmed value from the second text field. Guaranteed to be non-null.
- */
- public String getSecondValue() {
- return (tfSecondValue.getText().trim());
- }
-
+public class TwoFieldQueryPanel extends JPanel {
+ private JTextField tfFirstValue;
+ private JTextField tfSecondValue;
+
+ public TwoFieldQueryPanel(String firstFieldName, String secondFieldName) {
+ this(null, firstFieldName, null, secondFieldName, null);
+ }
+
+ public TwoFieldQueryPanel(String message, String firstFieldName,
+ String secondFieldName) {
+ this(message, firstFieldName, null, secondFieldName, null);
+ }
+
+ public TwoFieldQueryPanel(String firstFieldName,
+ String firstFieldDefaultValue, String secondFieldName,
+ String secondFieldDefaultValue) {
+ this(null, firstFieldName, firstFieldDefaultValue, secondFieldName,
+ secondFieldDefaultValue);
+ }
+
+ public TwoFieldQueryPanel(String message, String firstFieldName,
+ String firstFieldDefaultValue, String secondFieldName,
+ String secondFieldDefaultValue) {
+ super();
+ this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ this.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+
+ c.gridx = 0;
+ c.gridy = 0;
+ c.weightx = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.WEST;
+ c.insets = new Insets(3, 5, 3, 5);
+
+ if (message != null && message.length() > 0) {
+ c.gridwidth = 2;
+ c.insets = new Insets(5, 5, 15, 5);
+ this.add(new JLabel(message), c);
+
+ c.gridwidth = 1;
+ c.gridx = 0;
+ c.gridy++;
+ c.insets = new Insets(3, 5, 3, 5);
+ }
+
+ this.add(new JLabel(firstFieldName), c);
+
+ c.gridx++;
+ c.weightx = 1.0;
+ tfFirstValue = new JTextField(20);
+ if (firstFieldDefaultValue != null) {
+ tfFirstValue.setText(firstFieldDefaultValue);
+ }
+ tfFirstValue.selectAll();
+ tfFirstValue.requestFocusInWindow();
+ this.add(tfFirstValue, c);
+
+ c.gridx = 0;
+ c.gridy++;
+ c.weightx = 0;
+ this.add(new JLabel(secondFieldName), c);
+
+ c.gridx++;
+ c.weightx = 1.0;
+ tfSecondValue = new JTextField(20);
+ if (secondFieldDefaultValue != null) {
+ tfSecondValue.setText(secondFieldDefaultValue);
+ }
+ tfSecondValue.selectAll();
+ this.add(tfSecondValue, c);
+ }
+
+ /**
+ * @return Trimmed value from the first text field. Guaranteed to be
+ * non-null.
+ */
+ public String getFirstValue() {
+ return (tfFirstValue.getText().trim());
+ }
+
+ /**
+ * @return Trimmed value from the second text field. Guaranteed to be
+ * non-null.
+ */
+ public String getSecondValue() {
+ return (tfSecondValue.getText().trim());
+ }
+
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigurationPanelProvider.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigurationPanelProvider.java
index 90e3878..5954986 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigurationPanelProvider.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigurationPanelProvider.java
@@ -2,48 +2,45 @@
import java.awt.BorderLayout;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.swing.BorderFactory;
import javax.swing.JOptionPane;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel;
-
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
import net.sf.taverna.t2.activities.xpath.XPathActivityConfigurationBean;
+import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
-@SuppressWarnings("serial")
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+
/**
- *
+ *
* @author Sergejs Aleksejevs
+ * @author David Withers
*/
-public class XPathActivityConfigurationPanelProvider
- extends
- ActivityConfigurationPanel<XPathActivity, XPathActivityConfigurationBean> {
- private XPathActivity activity;
- private XPathActivityConfigurationBean configBean;
+@SuppressWarnings("serial")
+public class XPathActivityConfigurationPanelProvider extends ActivityConfigurationPanel {
private XPathActivityConfigurationPanel configPanel;
+ private final ServiceRegistry serviceRegistry;
- public XPathActivityConfigurationPanelProvider(XPathActivity activity) {
- this.activity = activity;
- initGui();
+ public XPathActivityConfigurationPanelProvider(Activity activity, ServiceRegistry serviceRegistry) {
+ super(activity);
+ this.serviceRegistry = serviceRegistry;
+ initialise();
}
- protected void initGui() {
+ @Override
+ protected void initialise() {
+ super.initialise();
removeAll();
setLayout(new BorderLayout());
- // create view title
- // ShadedLabel slConfigurationLabel = new
- // ShadedLabel("Configuration options for this XPath service",
- // ShadedLabel.ORANGE);
- // JPanel jpConfigurationLabel = new JPanel(new GridLayout(1,1));
- // jpConfigurationLabel.add(slConfigurationLabel);
- // jpConfigurationLabel.setBorder(BorderFactory.createEmptyBorder(10,
- // 10, 0, 10));
- // add(jpConfigurationLabel, BorderLayout.NORTH);
-
// create actual contents of the config panel
this.configPanel = new XPathActivityConfigurationPanel();
add(configPanel, BorderLayout.CENTER);
@@ -51,92 +48,63 @@
// place the whole configuration panel into a raised area, so that
// automatically added 'Apply' / 'Close' buttons visually apply to
// the whole of the panel, not just part of it
- this.setBorder(BorderFactory.createCompoundBorder(BorderFactory
- .createEmptyBorder(12, 12, 2, 12), BorderFactory
- .createRaisedBevelBorder()));
-
- // set preferred size for the panel (otherwise it will be way too small)
- //this.setMinimumSize(new Dimension(800, 600));
- //this.setPreferredSize(new Dimension(950, 650));
+ this.setBorder(BorderFactory.createCompoundBorder(
+ BorderFactory.createEmptyBorder(12, 12, 2, 12),
+ BorderFactory.createRaisedBevelBorder()));
// Populate fields from activity configuration bean
refreshConfiguration();
}
/**
- * Check that user values in the UI are valid.
- */
- @Override
- public boolean checkValues() {
- // the only validity condition is the correctness of the XPath
- // expression -- so checking that
- int xpathExpressionStatus = XPathActivityConfigurationBean
- .validateXPath(this.configPanel.getCurrentXPathExpression());
-
- // show an explicit warning message to explain the problem
- if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_EMPTY) {
- JOptionPane.showMessageDialog(this,
- "XPath expression should not be empty", "XPath Activity",
- JOptionPane.WARNING_MESSAGE);
- } else if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_INVALID) {
- JOptionPane
- .showMessageDialog(
- this,
- "<html><center>XPath expression is invalid - hover the mouse over the XPath status<br>"
- + "icon to get more information</center></html>",
- "XPath Activity", JOptionPane.WARNING_MESSAGE);
- }
-
- return (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_VALID);
- }
-
- /**
- * Return configuration bean generated from user interface last time
- * noteConfiguration() was called.
- */
- @Override
- public XPathActivityConfigurationBean getConfiguration() {
- // Should already have been made by noteConfiguration()
- return configBean;
- }
-
- /**
- * Check if the user has changed the configuration from the original
- */
- @Override
- public boolean isConfigurationChanged() {
- boolean xmlDocumentHasNotChanged = (configPanel.getCurrentXMLTree() == null && configBean
- .getXmlDocument() == null)
- || (configPanel.getCurrentXMLTree() != null
- && configBean.getXmlDocument() != null && configPanel
- .getCurrentXMLTree().getDocumentUsedToPopulateTree()
- .asXML().equals(configBean.getXmlDocument()));
- boolean xpathExpressionHasNotChanged = configPanel
- .getCurrentXPathExpression().equals(
- configBean.getXpathExpression());
- boolean xpathNamespaceMapHasNotChanged = configPanel
- .getCurrentXPathNamespaceMap().equals(
- configBean.getXpathNamespaceMap());
-
- // true (changed) unless all fields match the originals
- return !(xmlDocumentHasNotChanged && xpathExpressionHasNotChanged && xpathNamespaceMapHasNotChanged);
- }
-
- /**
* Prepare a new configuration bean from the UI, to be returned with
* getConfiguration()
*/
@Override
public void noteConfiguration() {
- configBean = new XPathActivityConfigurationBean();
-
if (configPanel.getCurrentXMLTree() != null) {
- configBean.setXmlDocument(configPanel.getCurrentXMLTree()
+ setProperty("exampleXmlDocument", configPanel.getCurrentXMLTree()
.getDocumentUsedToPopulateTree().asXML());
}
- configBean.setXpathExpression(configPanel.getCurrentXPathExpression());
- configBean.setXpathNamespaceMap(configPanel
- .getCurrentXPathNamespaceMap());
+ setProperty("xpathExpression", configPanel.getCurrentXPathExpression());
+
+ Map<String, String> xPathNamespaceMap = configPanel.getCurrentXPathNamespaceMap();
+ if (xPathNamespaceMap.isEmpty()) {
+ json.remove("xpathNamespaceMap");
+ } else {
+ ArrayNode namespaceMapNode = json.arrayNode();
+ for (Entry<String, String> namespaceMapping : xPathNamespaceMap.entrySet()) {
+ namespaceMapNode.addObject().put("prefix", namespaceMapping.getKey()).put("uri", namespaceMapping.getValue());
+ }
+ json.set("xpathNamespaceMap", namespaceMapNode);
+ }
+
+ configureInputPorts(serviceRegistry);
+ configureOutputPorts(serviceRegistry);
+}
+
+ /**
+ * Check that user values in the UI are valid.
+ */
+ @Override
+ public boolean checkValues() {
+ // the only validity condition is the correctness of the XPath
+ // expression -- so checking that
+ int xpathExpressionStatus = XPathActivityConfigurationBean.validateXPath(this.configPanel
+ .getCurrentXPathExpression());
+
+ // show an explicit warning message to explain the problem
+ if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_EMPTY) {
+ JOptionPane.showMessageDialog(this, "XPath expression should not be empty",
+ "XPath Activity", JOptionPane.WARNING_MESSAGE);
+ } else if (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_INVALID) {
+ JOptionPane.showMessageDialog(this,
+ "<html><center>XPath expression is invalid - hover the mouse over the XPath status<br>"
+ + "icon to get more information</center></html>", "XPath Activity",
+ JOptionPane.WARNING_MESSAGE);
+ }
+
+ return (xpathExpressionStatus == XPathActivityConfigurationBean.XPATH_VALID);
}
/**
@@ -144,17 +112,20 @@
*/
@Override
public void refreshConfiguration() {
- configBean = activity.getConfiguration();
-
- if (configBean.getXmlDocument() != null) {
- configPanel.setSourceXML(configBean.getXmlDocument());
+ if (json.has("exampleXmlDocument")) {
+ configPanel.setSourceXML(getProperty("exampleXmlDocument"));
configPanel.parseXML();
}
- configPanel.setCurrentXPathExpression(configBean.getXpathExpression());
+ configPanel.setCurrentXPathExpression(getProperty("xpathExpression"));
- configPanel.setCurrentXPathNamespaceMapValues(configBean
- .getXpathNamespaceMap());
+ Map<String, String> xpathNamespaceMap = new HashMap<>();
+ if (json.has("xpathNamespaceMap")) {
+ for (JsonNode namespaceMapping : json.get("xpathNamespaceMap")) {
+ xpathNamespaceMap.put(namespaceMapping.get("prefix").asText(), namespaceMapping.get("uri").asText());
+ }
+ }
+ configPanel.setCurrentXPathNamespaceMapValues(xpathNamespaceMap);
configPanel.reloadNamespaceMappingTableFromLocalMap();
// if the XML tree was populated, (re-)run the XPath expression
@@ -166,7 +137,7 @@
// discard the first 'leg', as it's a side effect of
// "String.split()" -
// non-existent string to the left of the first "/"
- String[] xpathLegs = configBean.getXpathExpression().split("/");
+ String[] xpathLegs = getProperty("xpathExpression").split("/");
List<String> xpathLegList = new ArrayList<String>();
for (int i = 1; i < xpathLegs.length; i++) {
xpathLegList.add("/" + xpathLegs[i]);
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigureAction.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigureAction.java
index 0579ff7..4e68948 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigureAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/XPathActivityConfigureAction.java
@@ -3,39 +3,50 @@
import java.awt.Frame;
import java.awt.event.ActionEvent;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+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 uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
-import net.sf.taverna.t2.activities.xpath.XPathActivityConfigurationBean;
-
-@SuppressWarnings("serial")
/**
* @author Sergejs Aleksejevs
+ * @author David Withers
*/
-public class XPathActivityConfigureAction extends ActivityConfigurationAction<XPathActivity, XPathActivityConfigurationBean>
-{
+@SuppressWarnings("serial")
+public class XPathActivityConfigureAction extends ActivityConfigurationAction {
- public XPathActivityConfigureAction(XPathActivity activity, Frame owner) {
- super(activity);
+ private final EditManager editManager;
+ private final FileManager fileManager;
+ private final ServiceRegistry serviceRegistry;
+
+ public XPathActivityConfigureAction(Activity activity, Frame owner,
+ EditManager editManager, FileManager fileManager,
+ ActivityIconManager activityIconManager,
+ ServiceDescriptionRegistry serviceDescriptionRegistry, ServiceRegistry serviceRegistry) {
+ super(activity, activityIconManager, serviceDescriptionRegistry);
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ this.serviceRegistry = serviceRegistry;
}
- @SuppressWarnings("unchecked")
- public void actionPerformed(ActionEvent e)
- {
- ActivityConfigurationDialog<XPathActivity,XPathActivityConfigurationBean> currentDialog =
- ActivityConfigurationAction.getDialog(getActivity());
-
+ public void actionPerformed(ActionEvent e) {
+ ActivityConfigurationDialog currentDialog = ActivityConfigurationAction.getDialog(getActivity());
+
if (currentDialog != null) {
currentDialog.toFront();
return;
}
-
- XPathActivityConfigurationPanelProvider panel = new XPathActivityConfigurationPanelProvider(getActivity());
- ActivityConfigurationDialog<XPathActivity, XPathActivityConfigurationBean> dialog =
- new ActivityConfigurationDialog<XPathActivity, XPathActivityConfigurationBean>(getActivity(), panel);
- ActivityConfigurationAction.setDialog(getActivity(), dialog);
+ XPathActivityConfigurationPanelProvider panel = new XPathActivityConfigurationPanelProvider(
+ getActivity(), serviceRegistry);
+ ActivityConfigurationDialog dialog = new ActivityConfigurationDialog(
+ getActivity(), panel, editManager);
+
+ ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager);
}
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/ConfigureXPathActivityMenuAction.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/ConfigureXPathActivityMenuAction.java
index 4abb800..6695dc9 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/ConfigureXPathActivityMenuAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/ConfigureXPathActivityMenuAction.java
@@ -2,35 +2,64 @@
import javax.swing.Action;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
import net.sf.taverna.t2.activities.xpath.ui.config.XPathActivityConfigureAction;
+import net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathTemplateService;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.file.FileManager;
+import uk.org.taverna.commons.services.ServiceRegistry;
/**
- * This action is responsible for enabling the contextual menu entry
- * on processors that perform XPathActivity'ies.
- *
- * NB! As a side-effect this also enables the pop-up with for configuration
- * of the processor when it is added to the workflow from the Service Panel.
- *
+ * This action is responsible for enabling the contextual menu entry on processors that perform
+ * XPathActivity'ies.
+ * NB! As a side-effect this also enables the pop-up with for configuration of the processor when it
+ * is added to the workflow from the Service Panel.
+ *
* @author Sergejs Aleksejevs
+ * @author David Withers
*/
-public class ConfigureXPathActivityMenuAction extends
- AbstractConfigureActivityMenuAction<XPathActivity>
-{
+public class ConfigureXPathActivityMenuAction extends AbstractConfigureActivityMenuAction {
- public ConfigureXPathActivityMenuAction() {
- super(XPathActivity.class);
- }
-
- @Override
- protected Action createAction()
- {
- XPathActivityConfigureAction configAction = new XPathActivityConfigureAction(
- findActivity(), getParentFrame());
- configAction.putValue(Action.NAME, "Configure XPath service");
- addMenuDots(configAction);
- return configAction;
- }
+ private EditManager editManager;
+ private FileManager fileManager;
+ private ActivityIconManager activityIconManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
+
+ public ConfigureXPathActivityMenuAction() {
+ super(XPathTemplateService.ACTIVITY_TYPE);
+ }
+
+ @Override
+ protected Action createAction() {
+ XPathActivityConfigureAction configAction = new XPathActivityConfigureAction(
+ findActivity(), getParentFrame(), editManager, fileManager, activityIconManager,
+ serviceDescriptionRegistry, serviceRegistry);
+ configAction.putValue(Action.NAME, "Configure XPath service");
+ addMenuDots(configAction);
+ return configAction;
+ }
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setFileManager(FileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ public void setActivityIconManager(ActivityIconManager activityIconManager) {
+ this.activityIconManager = activityIconManager;
+ }
+
+ public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) {
+ this.serviceDescriptionRegistry = serviceDescriptionRegistry;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ }
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextViewFactory.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextViewFactory.java
index 034d500..355ab8d 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextViewFactory.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextViewFactory.java
@@ -3,25 +3,57 @@
import java.util.Arrays;
import java.util.List;
+import net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathTemplateService;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+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.views.contextualviews.ContextualView;
import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
/**
- *
* @author Sergejs Aleksejevs
*/
-public class XPathActivityMainContextViewFactory implements
- ContextualViewFactory<XPathActivity>
-{
+public class XPathActivityMainContextViewFactory implements ContextualViewFactory<Activity> {
+
+ private EditManager editManager;
+ private FileManager fileManager;
+ private ActivityIconManager activityIconManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
public boolean canHandle(Object selection) {
- return selection instanceof XPathActivity;
+ return selection instanceof Activity
+ && ((Activity) selection).getType()
+ .equals(XPathTemplateService.ACTIVITY_TYPE);
}
- public List<ContextualView> getViews(XPathActivity selection) {
- return Arrays.<ContextualView>asList(new XPathActivityMainContextualView(selection));
+ public List<ContextualView> getViews(Activity selection) {
+ return Arrays.<ContextualView> asList(new XPathActivityMainContextualView(selection,
+ editManager, fileManager, activityIconManager, serviceDescriptionRegistry,
+ serviceRegistry));
}
-
+
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setFileManager(FileManager fileManager) {
+ this.fileManager = fileManager;
+ }
+
+ public void setActivityIconManager(ActivityIconManager activityIconManager) {
+ this.activityIconManager = activityIconManager;
+ }
+
+ public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) {
+ this.serviceDescriptionRegistry = serviceDescriptionRegistry;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ }
+
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextualView.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextualView.java
index 8d65f81..d872228 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextualView.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/contextualview/XPathActivityMainContextualView.java
@@ -10,7 +10,6 @@
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.util.Map;
import javax.swing.Action;
import javax.swing.BorderFactory;
@@ -22,124 +21,142 @@
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
-import net.sf.taverna.t2.activities.xpath.XPathActivityConfigurationBean;
import net.sf.taverna.t2.activities.xpath.ui.config.XPathActivityConfigureAction;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+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.views.contextualviews.ContextualView;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
+import uk.org.taverna.scufl2.api.common.Scufl2Tools;
+import uk.org.taverna.scufl2.api.configurations.Configuration;
-@SuppressWarnings("serial")
+import com.fasterxml.jackson.databind.JsonNode;
+
/**
- *
+ *
* @author Sergejs Aleksejevs
+ * @author David Withers
*/
-public class XPathActivityMainContextualView extends ContextualView
-{
- private XPathActivityMainContextualView thisContextualView;
- private final XPathActivity activity;
-
+@SuppressWarnings("serial")
+public class XPathActivityMainContextualView extends ContextualView {
+
+ private final Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ private XPathActivityMainContextualView thisContextualView;
+
+ private final Activity activity;
+
private JPanel jpMainPanel;
private JTextField tfXPathExpression;
-
+
private DefaultTableModel xpathNamespaceMappingsTableModel;
private JTable jtXPathNamespaceMappings;
private JScrollPane spXPathNamespaceMappings;
-
-
- public XPathActivityMainContextualView(XPathActivity activity) {
- this.thisContextualView = this;
+ private final EditManager editManager;
+ private final FileManager fileManager;
+ private final ActivityIconManager activityIconManager;
+ private final ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private final ServiceRegistry serviceRegistry;
+
+ public XPathActivityMainContextualView(Activity activity, EditManager editManager,
+ FileManager fileManager, ActivityIconManager activityIconManager,
+ ServiceDescriptionRegistry serviceDescriptionRegistry, ServiceRegistry serviceRegistry) {
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ this.activityIconManager = activityIconManager;
+ this.serviceDescriptionRegistry = serviceDescriptionRegistry;
+ this.serviceRegistry = serviceRegistry;
+ this.thisContextualView = this;
this.activity = activity;
initView();
}
-
-
+
@Override
- public JComponent getMainFrame()
- {
+ public JComponent getMainFrame() {
jpMainPanel = new JPanel(new GridBagLayout());
- jpMainPanel.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createEmptyBorder(4, 2, 4, 2),
- BorderFactory.createEmptyBorder()
-// BorderFactory.createLineBorder(ColourManager.getInstance().getPreferredColour(XPathActivity.class.getCanonicalName()), 2) // makes a thin border with the colour of the processor
- ));
-
+ jpMainPanel.setBorder(BorderFactory.createCompoundBorder(
+ BorderFactory.createEmptyBorder(4, 2, 4, 2), BorderFactory.createEmptyBorder()));
+
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
c.weighty = 0;
-
-
+
// --- XPath Expression ---
-
+
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(5, 5, 5, 5);
JLabel jlXPathExpression = new JLabel("XPath Expression:");
jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
jpMainPanel.add(jlXPathExpression, c);
-
+
c.gridx++;
c.weightx = 1.0;
tfXPathExpression = new JTextField();
tfXPathExpression.setEditable(false);
jpMainPanel.add(tfXPathExpression, c);
-
-
+
// --- Label to Show/Hide Mapping Table ---
-
-
+
final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
- jlShowHideNamespaceMappings.setForeground(Color.BLUE);
- jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
- jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
- jlShowHideNamespaceMappings.setText((spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings...");
- thisContextualView.revalidate();
- }
- });
-
- c.gridx = 0;
- c.gridy++;
- c.gridwidth = 2;
- c.weightx = 1.0;
- c.weighty = 0;
- c.fill = GridBagConstraints.HORIZONTAL;
- jpMainPanel.add(jlShowHideNamespaceMappings, c);
-
-
- // --- Namespace Mapping Table ---
-
+ jlShowHideNamespaceMappings.setForeground(Color.BLUE);
+ jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
+ jlShowHideNamespaceMappings.setText((spXPathNamespaceMappings.isVisible() ? "Hide"
+ : "Show") + " namespace mappings...");
+ thisContextualView.revalidate();
+ }
+ });
+
+ c.gridx = 0;
+ c.gridy++;
+ c.gridwidth = 2;
+ c.weightx = 1.0;
+ c.weighty = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ jpMainPanel.add(jlShowHideNamespaceMappings, c);
+
+ // --- Namespace Mapping Table ---
+
xpathNamespaceMappingsTableModel = new DefaultTableModel() {
- /**
- * No cells should be editable
- */
- public boolean isCellEditable(int rowIndex,int columnIndex) {
- return (false);
- }
- };
- xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
- xpathNamespaceMappingsTableModel.addColumn("Namespace URI");
-
+ /**
+ * No cells should be editable
+ */
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return (false);
+ }
+ };
+ xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
+ xpathNamespaceMappingsTableModel.addColumn("Namespace URI");
+
jtXPathNamespaceMappings = new JTable();
jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
- // TODO - next line is to be enabled when Taverna is migrated to Java 1.6; for now it's fine to run without this
- // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure that when the dedicated area is larger than the table, the latter is stretched vertically to fill the empty space
-
- jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set relative sizes of columns
+ // TODO - next line is to be enabled when Taverna is migrated to Java
+ // 1.6; for now it's fine to run without this
+ // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
+ // that when the dedicated area is larger than the table, the latter is
+ // stretched vertically to fill the empty space
+
+ jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
+ // relative
+ // sizes of
+ // columns
jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);
-
+
c.gridy++;
spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
spXPathNamespaceMappings.setVisible(false);
jpMainPanel.add(spXPathNamespaceMappings, c);
-
-
+
// populate the view with values
refreshView();
-
+
return jpMainPanel;
}
@@ -149,7 +166,6 @@
* views (even when this contextual view is collapsed).
*/
public String getViewTitle() {
- XPathActivityConfigurationBean configuration = activity.getConfiguration();
return "XPath Service Details";
}
@@ -157,18 +173,21 @@
* Typically called when the activity configuration has changed.
*/
@Override
- public void refreshView()
- {
- XPathActivityConfigurationBean configBean = activity.getConfiguration();
-
+ public void refreshView() {
+ Configuration configuration = scufl2Tools.configurationFor(activity, activity.getParent());
+ JsonNode json = configuration.getJson();
+
// Set XPath Expression
- tfXPathExpression.setText("" + configBean.getXpathExpression());
-
+ tfXPathExpression.setText(json.get("xpathExpression").asText());
+
// Populate Namespace Mappings
xpathNamespaceMappingsTableModel.getDataVector().removeAllElements();
- for (Map.Entry<String,String> mapping : configBean.getXpathNamespaceMap().entrySet()) {
- xpathNamespaceMappingsTableModel.addRow(new Object[] {mapping.getKey(), mapping.getValue()});
- }
+ if (json.has("xpathNamespaceMap")) {
+ for (JsonNode mapping : json.get("xpathNamespaceMap")) {
+ xpathNamespaceMappingsTableModel.addRow(new Object[] {
+ mapping.get("prefix").asText(), mapping.get("uri").asText() });
+ }
+ }
}
/**
@@ -179,11 +198,12 @@
// want to be on top, as it's the main contextual view for this activity
return 100;
}
-
+
@Override
public Action getConfigureAction(final Frame owner) {
- // "Configure" button appears because of this action being returned
- return new XPathActivityConfigureAction(activity, owner);
+ // "Configure" button appears because of this action being returned
+ return new XPathActivityConfigureAction(activity, owner, editManager, fileManager,
+ activityIconManager, serviceDescriptionRegistry, serviceRegistry);
}
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateAction.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateAction.java
index 214d6cd..a80696d 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateAction.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
+ * Copyright (C) 2007-2009 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
@@ -21,30 +21,25 @@
package net.sf.taverna.t2.activities.xpath.ui.menu;
import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
import java.net.URI;
import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
import net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathTemplateService;
import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
+import net.sf.taverna.t2.ui.menu.MenuManager;
import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.selection.SelectionManager;
import net.sf.taverna.t2.workbench.ui.workflowview.WorkflowView;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-import org.apache.log4j.Logger;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.core.Workflow;
/**
* An action to add a REST activity + a wrapping processor to the workflow.
- *
+ *
* @author Alex Nenadic
- *
*/
@SuppressWarnings("serial")
public class AddXPathTemplateAction extends AbstractContextualMenuAction {
@@ -54,8 +49,15 @@
private static final URI insertSection = URI
.create("http://taverna.sf.net/2009/contextMenu/insert");
- private static Logger logger = Logger
- .getLogger(AddXPathTemplateAction.class);
+ private EditManager editManager;
+
+ private MenuManager menuManager;
+
+ private SelectionManager selectionManager;
+
+ private ActivityIconManager activityIconManager;
+
+ private ServiceRegistry serviceRegistry;
public AddXPathTemplateAction() {
super(insertSection, 1000);
@@ -63,8 +65,7 @@
@Override
public boolean isEnabled() {
- return super.isEnabled()
- && getContextualSelection().getSelection() instanceof Dataflow;
+ return super.isEnabled() && getContextualSelection().getSelection() instanceof Workflow;
}
@Override
@@ -72,20 +73,38 @@
return new AddXPathAction();
}
-
+
protected class AddXPathAction extends AbstractAction {
- AddXPathAction () {
- super (ADD_XPATH, ActivityIconManager.getInstance().iconForActivity(
- new XPathActivity()));
+ AddXPathAction() {
+ super(ADD_XPATH, activityIconManager
+ .iconForActivity(XPathTemplateService.ACTIVITY_TYPE));
}
public void actionPerformed(ActionEvent e) {
- Dataflow workflow = FileManager.getInstance()
- .getCurrentDataflow();
- WorkflowView.importServiceDescription(XPathTemplateService.getServiceDescription(),
- false);
+ WorkflowView.importServiceDescription(XPathTemplateService.getServiceDescription(),
+ false, editManager, menuManager, selectionManager, serviceRegistry);
}
}
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setMenuManager(MenuManager menuManager) {
+ this.menuManager = menuManager;
+ }
+
+ public void setSelectionManager(SelectionManager selectionManager) {
+ this.selectionManager = selectionManager;
+ }
+
+ public void setActivityIconManager(ActivityIconManager activityIconManager) {
+ this.activityIconManager = activityIconManager;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ }
+
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateMenuAction.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateMenuAction.java
index c8e12d4..9132110 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateMenuAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/menu/AddXPathTemplateMenuAction.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2007-2009 The University of Manchester
- *
+ * Copyright (C) 2007-2009 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
@@ -25,62 +25,93 @@
import java.awt.event.KeyEvent;
import java.net.URI;
+import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.KeyStroke;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
import net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathTemplateService;
import net.sf.taverna.t2.ui.menu.AbstractMenuAction;
+import net.sf.taverna.t2.ui.menu.DesignOnlyAction;
+import net.sf.taverna.t2.ui.menu.MenuManager;
import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
+import net.sf.taverna.t2.workbench.edits.EditManager;
+import net.sf.taverna.t2.workbench.selection.SelectionManager;
import net.sf.taverna.t2.workbench.ui.workflowview.WorkflowView;
-import net.sf.taverna.t2.workbench.views.graph.actions.DesignOnlyAction;
-import net.sf.taverna.t2.workbench.views.graph.menu.InsertMenu;
-
-import org.apache.log4j.Logger;
+import uk.org.taverna.commons.services.ServiceRegistry;
/**
* An action to add a REST activity + a wrapping processor to the workflow.
- *
+ *
* @author Alex Nenadic
* @author alanrw
- *
*/
@SuppressWarnings("serial")
public class AddXPathTemplateMenuAction extends AbstractMenuAction {
private static final String ADD_XPATH = "XPath";
- private static final URI ADD_XPATH_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#graphMenuAddXPath");
+ private static final URI INSERT = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#insert");
- private static Logger logger = Logger
- .getLogger(AddXPathTemplateMenuAction.class);
+ private static final URI ADD_XPATH_URI = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#graphMenuAddXPath");
+
+ private EditManager editManager;
+
+ private MenuManager menuManager;
+
+ private SelectionManager selectionManager;
+
+ private ActivityIconManager activityIconManager;
+
+ private ServiceRegistry serviceRegistry;
public AddXPathTemplateMenuAction() {
- super(InsertMenu.INSERT, 1000, ADD_XPATH_URI);
+ super(INSERT, 1000, ADD_XPATH_URI);
}
@Override
protected Action createAction() {
-
return new AddXPathMenuAction();
}
-
- protected class AddXPathMenuAction extends DesignOnlyAction {
- AddXPathMenuAction () {
- super ();
- putValue(SMALL_ICON, ActivityIconManager.getInstance().iconForActivity(
- new XPathActivity()));
- putValue(NAME, ADD_XPATH);
- putValue(SHORT_DESCRIPTION, "XPath service");
- putValue(Action.ACCELERATOR_KEY,
- KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
+
+ protected class AddXPathMenuAction extends AbstractAction implements DesignOnlyAction {
+ AddXPathMenuAction() {
+ super();
+ putValue(SMALL_ICON,
+ activityIconManager.iconForActivity(XPathTemplateService.ACTIVITY_TYPE));
+ putValue(NAME, ADD_XPATH);
+ putValue(SHORT_DESCRIPTION, "XPath service");
+ putValue(
+ Action.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.SHIFT_DOWN_MASK
+ | InputEvent.ALT_DOWN_MASK));
}
public void actionPerformed(ActionEvent e) {
WorkflowView.importServiceDescription(XPathTemplateService.getServiceDescription(),
- false);
+ false, editManager, menuManager, selectionManager, serviceRegistry);
}
}
+ public void setEditManager(EditManager editManager) {
+ this.editManager = editManager;
+ }
+
+ public void setMenuManager(MenuManager menuManager) {
+ this.menuManager = menuManager;
+ }
+
+ public void setSelectionManager(SelectionManager selectionManager) {
+ this.selectionManager = selectionManager;
+ }
+
+ public void setActivityIconManager(ActivityIconManager activityIconManager) {
+ this.activityIconManager = activityIconManager;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ }
+
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathActivityIcon.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathActivityIcon.java
index bebe007..2251efb 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathActivityIcon.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathActivityIcon.java
@@ -1,93 +1,86 @@
package net.sf.taverna.t2.activities.xpath.ui.servicedescription;
+
import java.awt.Color;
+import java.net.URI;
import javax.swing.Icon;
import javax.swing.ImageIcon;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI;
-import net.sf.taverna.t2.workbench.ui.impl.configuration.colour.ColourManager;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
/**
- *
* @author Sergejs Aleksejevs
*/
-public class XPathActivityIcon implements ActivityIconSPI
-{
- private static final Color PROCESSOR_COLOUR = Color.decode("#E6FF5E");
-
-
- // --- LOCATIONS OF ICONS USED IN THE XPath ACTIVITY ---
-
- private static final String FAMFAMFAM_SILK_PATH = "famfamfam_silk/";
- private static final String FOLDS_PATH = "folds/";
-
- public static final String XPATH_ACTIVITY_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png";
- public static final String XPATH_ACTIVITY_CONFIGURATION_PARSE_XML_ICON = "arrow_right.png";
-
- public static final String XML_TREE_ROOT_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png";
- public static final String XML_TREE_NODE_ICON = FAMFAMFAM_SILK_PATH + "tag.png";
- public static final String XML_TREE_ATTRIBUTE_ICON = "xpath_attribute.png";
-
- public static final String XML_TREE_EXPAND_ALL_ICON = FAMFAMFAM_SILK_PATH + "text_linespacing.png";
- public static final String XML_TREE_COLLAPSE_ALL_ICON = FAMFAMFAM_SILK_PATH + "text_linespacing (collapse).png";
-
- public static final String XPATH_STATUS_OK_ICON = FAMFAMFAM_SILK_PATH + "accept.png";
- public static final String XPATH_STATUS_ERROR_ICON = FAMFAMFAM_SILK_PATH + "exclamation.png";
- public static final String XPATH_STATUS_UNKNOWN_ICON = FAMFAMFAM_SILK_PATH + "help.png";
-
- public static final String FOLD_ICON = FOLDS_PATH + "fold.png";
- public static final String UNFOLD_ICON = FOLDS_PATH + "unfold.png";
-
- // ------
-
- private static ImageIcon icon;
-
-
- static {
- // set colour for XPath processors in the workflow diagram
- ColourManager.getInstance().setPreferredColour(
- XPathActivity.class.getCanonicalName(), PROCESSOR_COLOUR);
- }
-
- public int canProvideIconScore(Activity<?> activity)
- {
- if (activity.getClass().getName().equals(XPathActivity.class.getName()))
- return DEFAULT_ICON + 1;
- else
- return NO_ICON;
- }
+public class XPathActivityIcon implements ActivityIconSPI {
+ private static final Color PROCESSOR_COLOUR = Color.decode("#E6FF5E");
- public Icon getIcon(Activity<?> activity) {
- return (getXPathActivityIcon());
- }
+ // --- LOCATIONS OF ICONS USED IN THE XPath ACTIVITY ---
- public static Icon getXPathActivityIcon() {
- if (icon == null) {
- synchronized(XPathActivityIcon.class) {
- if (icon == null) {
- try {
- icon = new ImageIcon(XPathActivityIcon.class.getResource(XPATH_ACTIVITY_ICON));
- }
- catch (NullPointerException e) {
- /* icon wasn't found - do nothing, but no icon will be available */
- }
- }
- }
- }
- return (icon);
- }
-
-
- public static Icon getIconById(String iconID) {
- try {
- return (new ImageIcon(XPathActivityIcon.class.getResource(iconID)));
- }
- catch (NullPointerException e) {
- // requested icon wasn't found - just return null
- return (null);
- }
- }
+ private static final String FAMFAMFAM_SILK_PATH = "famfamfam_silk/";
+ private static final String FOLDS_PATH = "folds/";
+
+ public static final String XPATH_ACTIVITY_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png";
+ public static final String XPATH_ACTIVITY_CONFIGURATION_PARSE_XML_ICON = "arrow_right.png";
+
+ public static final String XML_TREE_ROOT_ICON = FAMFAMFAM_SILK_PATH + "page_white_code.png";
+ public static final String XML_TREE_NODE_ICON = FAMFAMFAM_SILK_PATH + "tag.png";
+ public static final String XML_TREE_ATTRIBUTE_ICON = "xpath_attribute.png";
+
+ public static final String XML_TREE_EXPAND_ALL_ICON = FAMFAMFAM_SILK_PATH
+ + "text_linespacing.png";
+ public static final String XML_TREE_COLLAPSE_ALL_ICON = FAMFAMFAM_SILK_PATH
+ + "text_linespacing (collapse).png";
+
+ public static final String XPATH_STATUS_OK_ICON = FAMFAMFAM_SILK_PATH + "accept.png";
+ public static final String XPATH_STATUS_ERROR_ICON = FAMFAMFAM_SILK_PATH + "exclamation.png";
+ public static final String XPATH_STATUS_UNKNOWN_ICON = FAMFAMFAM_SILK_PATH + "help.png";
+
+ public static final String FOLD_ICON = FOLDS_PATH + "fold.png";
+ public static final String UNFOLD_ICON = FOLDS_PATH + "unfold.png";
+
+ // ------
+
+ private static ImageIcon icon;
+
+ public int canProvideIconScore(URI activityType) {
+ if (XPathTemplateService.ACTIVITY_TYPE.equals(activityType))
+ return DEFAULT_ICON + 1;
+ else
+ return NO_ICON;
+ }
+
+ public Icon getIcon(URI activityType) {
+ return getXPathActivityIcon();
+ }
+
+ public static Icon getXPathActivityIcon() {
+ if (icon == null) {
+ synchronized (XPathActivityIcon.class) {
+ if (icon == null) {
+ try {
+ icon = new ImageIcon(
+ XPathActivityIcon.class.getResource(XPATH_ACTIVITY_ICON));
+ } catch (NullPointerException e) {
+ /* icon wasn't found - do nothing, but no icon will be available */
+ }
+ }
+ }
+ }
+ return (icon);
+ }
+
+ public static Icon getIconById(String iconID) {
+ try {
+ return (new ImageIcon(XPathActivityIcon.class.getResource(iconID)));
+ } catch (NullPointerException e) {
+ // requested icon wasn't found - just return null
+ return (null);
+ }
+ }
+
+ public void setColourManager(ColourManager colourManager) {
+ colourManager.setPreferredColour(XPathTemplateService.ACTIVITY_TYPE.toString(), PROCESSOR_COLOUR);
+ }
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathTemplateService.java b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathTemplateService.java
index b23d5cd..d55235d 100644
--- a/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathTemplateService.java
+++ b/src/main/java/net/sf/taverna/t2/activities/xpath/ui/servicedescription/XPathTemplateService.java
@@ -1,67 +1,57 @@
package net.sf.taverna.t2.activities.xpath.ui.servicedescription;
+import java.net.URI;
+
import javax.swing.Icon;
-import net.sf.taverna.t2.activities.xpath.XPathActivity;
-import net.sf.taverna.t2.activities.xpath.XPathActivityConfigurationBean;
import net.sf.taverna.t2.servicedescriptions.AbstractTemplateService;
import net.sf.taverna.t2.servicedescriptions.ServiceDescription;
+import uk.org.taverna.scufl2.api.configurations.Configuration;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
/**
- *
* @author Sergejs Aleksejevs
+ * @author David Withers
*/
-public class XPathTemplateService extends AbstractTemplateService<XPathActivityConfigurationBean>
-{
- public XPathTemplateService ()
- {
- super();
- /*
- // TODO - re-enable this if it is necessary to add another folder inside "Service templates" in the Service Panel
- templateService = new AbstractTemplateService.TemplateServiceDescription() {
- public List<String> getPath() {
- return Arrays.asList(SERVICE_TEMPLATES, "XPath");
- }
- };
- */
- }
-
- @Override
- public Class<XPathActivity> getActivityClass() {
- return XPathActivity.class;
- }
-
- @Override
- /**
- * Default values for this template service are provided in this method.
- */
- public XPathActivityConfigurationBean getActivityConfiguration()
- {
- return (XPathActivityConfigurationBean.getDefaultInstance());
- }
-
- @Override
- public Icon getIcon() {
- return XPathActivityIcon.getXPathActivityIcon();
- }
-
- public String getName() {
- return "XPath Service";
- }
-
- public String getDescription() {
- return "Service for point-and-click creation of XPath expressions for XML data";
- }
-
- @SuppressWarnings("unchecked")
+public class XPathTemplateService extends AbstractTemplateService {
+
+ public static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xpath");
+
+ @Override
+ public URI getActivityType() {
+ return ACTIVITY_TYPE;
+ }
+
+ @Override
+ public Configuration getActivityConfiguration() {
+ Configuration configuration = new Configuration();
+ configuration.setType(ACTIVITY_TYPE.resolve("#Config"));
+ ObjectNode json = (ObjectNode) configuration.getJson();
+ json.put("xpathExpression", "/");
+ return configuration;
+ }
+
+ @Override
+ public Icon getIcon() {
+ return XPathActivityIcon.getXPathActivityIcon();
+ }
+
+ public String getName() {
+ return "XPath";
+ }
+
+ public String getDescription() {
+ return "Service for point-and-click creation of XPath expressions for XML data";
+ }
+
public static ServiceDescription getServiceDescription() {
XPathTemplateService gts = new XPathTemplateService();
return gts.templateService;
}
+ public String getId() {
+ return "http://www.taverna.org.uk/2010/services/xpath";
+ }
- public String getId() {
- return "http://www.taverna.org.uk/2010/services/xpath";
- }
-
}
diff --git a/src/main/resources/META-INF/spring/xpath-activity-ui-context-osgi.xml b/src/main/resources/META-INF/spring/xpath-activity-ui-context-osgi.xml
new file mode 100644
index 0000000..1e53ea6
--- /dev/null
+++ b/src/main/resources/META-INF/spring/xpath-activity-ui-context-osgi.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <service ref="XPathActivityIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" />
+
+ <service ref="XPathTemplateService" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider" />
+
+ <service ref="ConfigureXPathActivityMenuAction" auto-export="interfaces" />
+ <service ref="AddXPathTemplateAction" auto-export="interfaces" />
+ <service ref="AddXPathTemplateMenuAction" auto-export="interfaces" />
+
+ <service ref="XPathActivityMainContextViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" />
+
+ <reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" />
+ <reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" />
+ <reference id="menuManager" interface="net.sf.taverna.t2.ui.menu.MenuManager" />
+ <reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" />
+ <reference id="activityIconManager" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconManager" />
+ <reference id="colourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" />
+ <reference id="serviceDescriptionRegistry" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry" />
+ <reference id="serviceRegistry" interface="uk.org.taverna.commons.services.ServiceRegistry" />
+
+</beans:beans>
diff --git a/src/main/resources/META-INF/spring/xpath-activity-ui-context.xml b/src/main/resources/META-INF/spring/xpath-activity-ui-context.xml
new file mode 100644
index 0000000..0116b2e
--- /dev/null
+++ b/src/main/resources/META-INF/spring/xpath-activity-ui-context.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="XPathActivityIcon"
+ class="net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathActivityIcon">
+ <property name="colourManager" ref="colourManager" />
+ </bean>
+
+ <bean id="XPathTemplateService"
+ class="net.sf.taverna.t2.activities.xpath.ui.servicedescription.XPathTemplateService" />
+
+ <bean id="ConfigureXPathActivityMenuAction"
+ class="net.sf.taverna.t2.activities.xpath.ui.contextualview.ConfigureXPathActivityMenuAction">
+ <property name="editManager" ref="editManager" />
+ <property name="fileManager" ref="fileManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+ <bean id="AddXPathTemplateAction"
+ class="net.sf.taverna.t2.activities.xpath.ui.menu.AddXPathTemplateAction">
+ <property name="editManager" ref="editManager" />
+ <property name="menuManager" ref="menuManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+ <bean id="AddXPathTemplateMenuAction"
+ class="net.sf.taverna.t2.activities.xpath.ui.menu.AddXPathTemplateMenuAction">
+ <property name="editManager" ref="editManager" />
+ <property name="menuManager" ref="menuManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+
+ <bean id="XPathActivityMainContextViewFactory"
+ class="net.sf.taverna.t2.activities.xpath.ui.contextualview.XPathActivityMainContextViewFactory">
+ <property name="editManager" ref="editManager" />
+ <property name="fileManager" ref="fileManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+
+</beans>