Merge branch 'README'
diff --git a/pom.xml b/pom.xml
index 7f398c7..77e4508 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,40 +4,18 @@
<parent>
<groupId>net.sf.taverna.t2</groupId>
<artifactId>ui-activities</artifactId>
- <version>1.1-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
- <groupId>net.sf.taverna.t2.ui-activities
- </groupId>
+ <groupId>net.sf.taverna.t2.ui-activities</groupId>
<artifactId>spreadsheet-import-activity-ui</artifactId>
+ <packaging>bundle</packaging>
<name>Taverna 2 Spreadsheet Import Activity UI</name>
-
- <repositories>
- <repository>
- <id>mygrid-repository</id>
- <name>myGrid Repository</name>
- <url>http://www.mygrid.org.uk/maven/repository</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
- <properties>
- </properties>
-
<dependencies>
<dependency>
<groupId>net.sf.taverna.t2.activities</groupId>
<artifactId>spreadsheet-import-activity</artifactId>
<version>${t2.activities.version}</version>
</dependency>
-
- <!-- taverna core -->
- <dependency>
- <groupId>net.sf.taverna.t2.core</groupId>
- <artifactId>workflowmodel-api</artifactId>
- <version>${t2.core.version}</version>
- </dependency>
<!-- taverna lang -->
<dependency>
<groupId>net.sf.taverna.t2.lang</groupId>
@@ -70,26 +48,10 @@
<artifactId>menu-api</artifactId>
<version>${t2.ui.api.version}</version>
</dependency>
- <!-- taverna ui-impl -->
<dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
+ <groupId>net.sf.taverna.t2.ui-api</groupId>
<artifactId>activity-tools</artifactId>
- <version>${t2.ui.impl.version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
- <artifactId>contextual-views-impl</artifactId>
- <version>${t2.ui.impl.version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
- <artifactId>helper</artifactId>
- <version>${t2.ui.impl.version}</version>
- </dependency>
- <dependency>
- <groupId>net.sf.taverna.t2.ui-impl</groupId>
- <artifactId>configuration-impl</artifactId>
- <version>${t2.ui.impl.version}</version>
+ <version>${t2.ui.api.version}</version>
</dependency>
<!-- taverna ui-components -->
<dependency>
@@ -99,33 +61,46 @@
</version>
</dependency>
<dependency>
- <groupId>net.sf.taverna.t2.ui-components</groupId>
- <artifactId>graph-view</artifactId>
- <version>${t2.ui.components.version}</version>
- </dependency>
+ <groupId>uk.org.taverna.scufl2</groupId>
+ <artifactId>scufl2-api</artifactId>
+ <version>${scufl2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.2.2</version>
+ </dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>com.springsource.org.apache.commons.lang</artifactId>
+ <version>${commons.lang.version}</version>
</dependency>
<dependency>
- <groupId>javax.help</groupId>
- <artifactId>javahelp</artifactId>
- <version>2.0.02</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.13</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
+ <groupId>org.apache.log4j</groupId>
+ <artifactId>com.springsource.org.apache.log4j</artifactId>
+ <version>${log4j.version}</version>
</dependency>
</dependencies>
-
-</project>
\ No newline at end of file
+ <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/spreadsheet/actions/SpreadsheetImportActivityConfigurationAction.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/actions/SpreadsheetImportActivityConfigurationAction.java
index 18d1a25..0a70680 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/actions/SpreadsheetImportActivityConfigurationAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/actions/SpreadsheetImportActivityConfigurationAction.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -23,68 +23,50 @@
import java.awt.Frame;
import java.awt.event.ActionEvent;
-import javax.swing.AbstractAction;
-
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration;
-import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView;
+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.helper.HelpEnabledDialog;
import net.sf.taverna.t2.workbench.ui.actions.activity.ActivityConfigurationAction;
import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
/**
* The configuration action for a SpreadsheetImport activity.
- *
+ *
* @author David Withers
*/
@SuppressWarnings("serial")
-public class SpreadsheetImportActivityConfigurationAction extends
- ActivityConfigurationAction<SpreadsheetImportActivity, SpreadsheetImportConfiguration> {
+public class SpreadsheetImportActivityConfigurationAction extends ActivityConfigurationAction {
private static final String CONFIGURE = "Configure";
- private final Frame owner;
+ private final EditManager editManager;
- public SpreadsheetImportActivityConfigurationAction(SpreadsheetImportActivity activity,
- Frame owner) {
- super(activity);
+ private final FileManager fileManager;
+
+ private final ServiceRegistry serviceRegistry;
+
+ public SpreadsheetImportActivityConfigurationAction(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;
putValue(NAME, CONFIGURE);
- this.owner = owner;
}
public void actionPerformed(ActionEvent e) {
final SpreadsheetImportConfigView spreadsheetConfigView = new SpreadsheetImportConfigView(
- (SpreadsheetImportActivity) getActivity());
- final HelpEnabledDialog dialog = new HelpEnabledDialog(owner, SpreadsheetImportUIText
- .getString("SpreadsheetImportActivityConfigurationAction.dialogTitle"), true, null);
- final Dataflow owningDataflow = FileManager.getInstance()
- .getCurrentDataflow();
- dialog.add(spreadsheetConfigView);
- // dialog.setSize(500, 600);
- dialog.pack();
+ getActivity(), serviceRegistry);
+ final ActivityConfigurationDialog dialog = new ActivityConfigurationDialog(getActivity(),
+ spreadsheetConfigView, editManager);
- spreadsheetConfigView.setOkAction(new AbstractAction(SpreadsheetImportUIText
- .getString("SpreadsheetImportActivityConfigurationAction.okButton")) {
- public void actionPerformed(ActionEvent arg0) {
- if (spreadsheetConfigView.isConfigurationChanged()) {
- ActivityConfigurationDialog.configureActivityStatic(owningDataflow, activity, spreadsheetConfigView.getConfiguration());
- }
- dialog.setVisible(false);
- dialog.dispose();
- }
- });
- spreadsheetConfigView.setCancelAction(new AbstractAction(SpreadsheetImportUIText
- .getString("SpreadsheetImportActivityConfigurationAction.canceButton")) {
- public void actionPerformed(ActionEvent e) {
- dialog.setVisible(false);
- dialog.dispose();
- }
-
- });
- dialog.setVisible(true);
+ ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager);
}
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateAction.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateAction.java
index 4f69760..3073acb 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateAction.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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,22 +25,22 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
-import javax.swing.JComponent;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
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 spreadsheet import activity + a wrapping processor to the workflow.
- *
+ *
* @author David Withers
*/
@SuppressWarnings("serial")
@@ -49,27 +49,33 @@
private static final URI insertSection = URI
.create("http://taverna.sf.net/2009/contextMenu/insert");
- private static Logger logger = Logger.getLogger(SpreadsheetImportAddTemplateAction.class);
+ private EditManager editManager;
+ private MenuManager menuManager;
+ private SelectionManager selectionManager;
+ private ActivityIconManager activityIconManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
public SpreadsheetImportAddTemplateAction() {
- super(insertSection, 60);
+ super(insertSection, 700);
}
@Override
public boolean isEnabled() {
- return super.isEnabled() && getContextualSelection().getSelection() instanceof Dataflow;
+ return super.isEnabled() && getContextualSelection().getSelection() instanceof Workflow;
}
@Override
protected Action createAction() {
- AbstractAction action = new AbstractAction(SpreadsheetImportUIText
- .getString("SpreadsheetImportAddTemplateAction.addMenu"), ActivityIconManager
- .getInstance().iconForActivity(new SpreadsheetImportActivity())) {
+ AbstractAction action = new AbstractAction(
+ SpreadsheetImportUIText.getString("SpreadsheetImportAddTemplateAction.addMenu"),
+ activityIconManager.iconForActivity(SpreadsheetImportTemplateService.ACTIVITY_TYPE)) {
public void actionPerformed(ActionEvent e) {
- WorkflowView.importServiceDescription(SpreadsheetImportTemplateService.getServiceDescription(),
- false);
+ WorkflowView.importServiceDescription(serviceDescriptionRegistry
+ .getServiceDescription(SpreadsheetImportTemplateService.ACTIVITY_TYPE), false,
+ editManager, menuManager, selectionManager, serviceRegistry);
}
};
@@ -77,4 +83,28 @@
return action;
}
+ 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 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/spreadsheet/menu/SpreadsheetImportAddTemplateMenuAction.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateMenuAction.java
index e1e34b6..048073a 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateMenuAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportAddTemplateMenuAction.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,43 +25,48 @@
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.spreadsheet.SpreadsheetImportActivity;
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
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.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.workbench.views.graph.actions.DesignOnlyAction;
-import net.sf.taverna.t2.workbench.views.graph.menu.GraphEditMenuSection;
-import net.sf.taverna.t2.workbench.views.graph.menu.InsertMenu;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-
-import org.apache.log4j.Logger;
+import uk.org.taverna.commons.services.ServiceRegistry;
/**
* An action to add a spreadsheet import activity + a wrapping processor to the workflow.
- *
- * @author Alan R Williams
*
+ * @author Alan R Williams
*/
@SuppressWarnings("serial")
public class SpreadsheetImportAddTemplateMenuAction extends AbstractMenuAction {
private static final URI ADD_SPREADSHEET_IMPORT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#graphMenuAddSpreadsheetImport");
-
- private static Logger logger = Logger.getLogger(SpreadsheetImportAddTemplateMenuAction.class);
-
- private static String ADD_SPREADSHEET_IMPORT = SpreadsheetImportUIText
- .getString("SpreadsheetImportAddTemplateAction.addMenu");
+ .create("http://taverna.sf.net/2008/t2workbench/menu#graphMenuAddSpreadsheetImport");
- public SpreadsheetImportAddTemplateMenuAction(){
- super(InsertMenu.INSERT, 24, ADD_SPREADSHEET_IMPORT_URI);
+ private static final URI INSERT = URI
+ .create("http://taverna.sf.net/2008/t2workbench/menu#insert");
+
+ private static String ADD_SPREADSHEET_IMPORT = SpreadsheetImportUIText
+ .getString("SpreadsheetImportAddTemplateAction.addMenu");
+
+ private EditManager editManager;
+ private MenuManager menuManager;
+ private SelectionManager selectionManager;
+ private ActivityIconManager activityIconManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
+
+ public SpreadsheetImportAddTemplateMenuAction() {
+ super(INSERT, 700, ADD_SPREADSHEET_IMPORT_URI);
}
@Override
@@ -69,24 +74,51 @@
return new AddSpreadsheetImportMenuAction();
}
- protected class AddSpreadsheetImportMenuAction extends DesignOnlyAction {
+ protected class AddSpreadsheetImportMenuAction extends AbstractAction implements
+ DesignOnlyAction {
AddSpreadsheetImportMenuAction() {
super();
- putValue(SMALL_ICON, ActivityIconManager.getInstance()
- .iconForActivity(new SpreadsheetImportActivity()));
- putValue(NAME, ADD_SPREADSHEET_IMPORT);
- putValue(SHORT_DESCRIPTION, ADD_SPREADSHEET_IMPORT);
- putValue(Action.ACCELERATOR_KEY,
- KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
-
+ putValue(SMALL_ICON,
+ activityIconManager
+ .iconForActivity(SpreadsheetImportTemplateService.ACTIVITY_TYPE));
+ putValue(NAME, ADD_SPREADSHEET_IMPORT);
+ putValue(SHORT_DESCRIPTION, ADD_SPREADSHEET_IMPORT);
+ putValue(
+ Action.ACCELERATOR_KEY,
+ KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.SHIFT_DOWN_MASK
+ | InputEvent.ALT_DOWN_MASK));
+
}
public void actionPerformed(ActionEvent e) {
-
- WorkflowView.importServiceDescription(SpreadsheetImportTemplateService.getServiceDescription(),
- false);
-
+ WorkflowView.importServiceDescription(serviceDescriptionRegistry
+ .getServiceDescription(SpreadsheetImportTemplateService.ACTIVITY_TYPE), 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 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/spreadsheet/menu/SpreadsheetImportConfigureMenuAction.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportConfigureMenuAction.java
index 415c689..7d1fa0a 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportConfigureMenuAction.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/menu/SpreadsheetImportConfigureMenuAction.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -22,31 +22,63 @@
import javax.swing.Action;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
+import uk.org.taverna.commons.services.ServiceRegistry;
+
import net.sf.taverna.t2.activities.spreadsheet.actions.SpreadsheetImportActivityConfigurationAction;
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
+import net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService;
+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;
/**
* Menu action for SpreadsheetImport activity configuration.
- *
+ *
* @author David Withers
*/
-public class SpreadsheetImportConfigureMenuAction extends
- AbstractConfigureActivityMenuAction<SpreadsheetImportActivity> {
+public class SpreadsheetImportConfigureMenuAction extends AbstractConfigureActivityMenuAction {
+
+ private EditManager editManager;
+ private FileManager fileManager;
+ private ActivityIconManager activityIconManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
public SpreadsheetImportConfigureMenuAction() {
- super(SpreadsheetImportActivity.class);
+ super(SpreadsheetImportTemplateService.ACTIVITY_TYPE);
}
@Override
protected Action createAction() {
Action result = new SpreadsheetImportActivityConfigurationAction(findActivity(),
- getParentFrame());
+ getParentFrame(), editManager, fileManager, activityIconManager,
+ serviceDescriptionRegistry, serviceRegistry);
result.putValue(Action.NAME, SpreadsheetImportUIText
.getString("SpreadsheetImportConfigureMenuAction.configureMenu"));
addMenuDots(result);
return result;
}
+ 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/spreadsheet/servicedescriptions/SpreadsheetImportActivityIcon.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportActivityIcon.java
index b0b56ec..1987364 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportActivityIcon.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportActivityIcon.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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,49 +21,51 @@
package net.sf.taverna.t2.activities.spreadsheet.servicedescriptions;
import java.awt.Color;
+import java.net.URI;
import javax.swing.Icon;
import javax.swing.ImageIcon;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
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;
/**
* UI icon for the SpreadsheetImport Activity.
- *
+ *
* @author David Withers
*/
public class SpreadsheetImportActivityIcon implements ActivityIconSPI {
public static final String SPREADSHEET_COLOUR_HTML = "#40e0d0";
public static final Color SPREADSHEET_COLOUR = Color.decode(SPREADSHEET_COLOUR_HTML);
-
- static {
- ColourManager.getInstance().setPreferredColour(
- "net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity", SPREADSHEET_COLOUR);
- }
-
- static Icon icon = null;
- public int canProvideIconScore(Activity<?> activity) {
- if (activity.getClass().getName().equals(SpreadsheetImportActivity.class.getName())) {
+ private static Icon icon = null;
+
+ @Override
+ public int canProvideIconScore(URI activityType) {
+ if (SpreadsheetImportTemplateService.ACTIVITY_TYPE.equals(activityType))
return DEFAULT_ICON + 1;
- } else {
+ else
return NO_ICON;
- }
}
- public Icon getIcon(Activity<?> activity) {
+ @Override
+ public Icon getIcon(URI activityType) {
return getSpreadsheetImportIcon();
}
public static Icon getSpreadsheetImportIcon() {
if (icon == null) {
- icon = new ImageIcon(SpreadsheetImportActivityIcon.class
- .getResource("/spreadsheet-import.png"));
+ icon = new ImageIcon(
+ SpreadsheetImportActivityIcon.class.getResource("/spreadsheet-import.png"));
}
return icon;
}
+
+ public void setColourManager(ColourManager colourManager) {
+ colourManager.setPreferredColour(
+ "http://ns.taverna.org.uk/2010/activity/spreadsheet-import",
+ SPREADSHEET_COLOUR);
+ }
+
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportTemplateService.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportTemplateService.java
index 1289d32..8057f2d 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportTemplateService.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/servicedescriptions/SpreadsheetImportTemplateService.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -24,38 +24,53 @@
import javax.swing.Icon;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.servicedescriptions.AbstractTemplateService;
import net.sf.taverna.t2.servicedescriptions.ServiceDescription;
+import uk.org.taverna.scufl2.api.configurations.Configuration;
/**
* Definition of the SpreadsheetImport spreadsheet import template service.
- *
+ *
* @author David Withers
*/
-public class SpreadsheetImportTemplateService extends
- AbstractTemplateService<SpreadsheetImportConfiguration> {
-
+public class SpreadsheetImportTemplateService extends AbstractTemplateService {
+
+ public static final URI ACTIVITY_TYPE = URI
+ .create("http://ns.taverna.org.uk/2010/activity/spreadsheet-import");
+
private static final String SERVICE_NAME = SpreadsheetImportUIText
.getString("SpreadsheetImportTemplateService.serviceName");
private static final URI providerId = URI
- .create("http://taverna.sf.net/2010/service-provider/spreadsheet");
-
+ .create("http://taverna.sf.net/2010/service-provider/spreadsheet");
+
public String getName() {
return SERVICE_NAME;
}
@Override
- public Class<SpreadsheetImportActivity> getActivityClass() {
- return SpreadsheetImportActivity.class;
+ public URI getActivityType() {
+ return ACTIVITY_TYPE;
}
@Override
- public SpreadsheetImportConfiguration getActivityConfiguration() {
- return new SpreadsheetImportConfiguration();
+ public Configuration getActivityConfiguration() {
+ Configuration configuration = new Configuration();
+ configuration.setType(ACTIVITY_TYPE.resolve("#Config"));
+ ObjectNode json = (ObjectNode) configuration.getJson();
+ json.put("columnRange", json.objectNode().put("start", 0).put("end", 1));
+ json.put("rowRange", json.objectNode().put("start", 0).put("end", -1));
+ json.put("emptyCellValue", "");
+ json.put("allRows", true);
+ json.put("excludeFirstRow", false);
+ json.put("ignoreBlankRows", false);
+ json.put("emptyCellPolicy", "EMPTY_STRING");
+ json.put("outputFormat", "PORT_PER_COLUMN");
+ json.put("csvDelimiter", ",");
+ return configuration;
}
@Override
@@ -69,7 +84,7 @@
.getString("SpreadsheetImportTemplateService.serviceDescription");
}
- public static ServiceDescription<SpreadsheetImportConfiguration> getServiceDescription() {
+ public static ServiceDescription getServiceDescription() {
SpreadsheetImportTemplateService bts = new SpreadsheetImportTemplateService();
return bts.templateService;
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigTableModel.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigTableModel.java
index 53aa433..0409b8e 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigTableModel.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigTableModel.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -35,7 +35,7 @@
* The default mapping is for the port name to be the same as the column label. The
* columnToPortMapping only contains entries for port names that are not the same as the column
* label.
- *
+ *
* @author David Withers
*/
@SuppressWarnings("serial")
@@ -48,7 +48,7 @@
/**
* Constructs a TableModel that maps column labels to port names for the specified range of
* columns.
- *
+ *
* @param fromColumn
* the start of the column range
* @param toColumn
@@ -69,7 +69,7 @@
/**
* Sets the start of the column range.
- *
+ *
* @param fromColumn
* the start of the column range
*/
@@ -82,7 +82,7 @@
/**
* Sets the end of the column range.
- *
+ *
* @param toColumn
* the end of the column range
*/
@@ -98,7 +98,7 @@
* <p>
* If the columnLabel is the columnToPortMapping the value is returned; otherwise the
* columnLabel is returned.
- *
+ *
* @param columnLabel
* the column to find the port name for
* @return the port name for the given column label
@@ -118,7 +118,7 @@
* <p>
* If the port name is not the same as the column label the port name is added the
* columnToPortMapping.
- *
+ *
* @param columnLabel
* @param portName
*/
@@ -135,7 +135,7 @@
* <p>
* The map only contains entries for port names that are not the same as their corresponding
* column label.
- *
+ *
* @return the map of column labels to port names
*/
public Map<String, String> getColumnToPortMapping() {
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigView.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigView.java
index 7035544..af57c44 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigView.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportConfigView.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -35,24 +35,18 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.Stack;
-import java.util.Map.Entry;
-import javax.help.CSH;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
-import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -74,26 +68,29 @@
import javax.swing.text.PlainDocument;
import net.sf.taverna.t2.activities.spreadsheet.Range;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetEmptyCellPolicy;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetOutputFormat;
import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetUtils;
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.lang.ui.DialogTextArea;
import net.sf.taverna.t2.lang.ui.icons.Icons;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
+import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.log4j.Logger;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
/**
* Configuration panel for the spreadsheet import activity.
- *
+ *
* @author David Withers
*/
@SuppressWarnings("serial")
-public class SpreadsheetImportConfigView extends JPanel {
+public class SpreadsheetImportConfigView extends ActivityConfigurationPanel {
private static final String INCONSISTENT_ROW_MESSAGE = SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.INCONSISTENT_ROW_MESSAGE");
@@ -130,10 +127,6 @@
private static Logger logger = Logger.getLogger(SpreadsheetImportConfigView.class);
- private SpreadsheetImportConfiguration oldConfiguration;
-
- private SpreadsheetImportConfiguration newConfiguration;
-
private JPanel titlePanel, contentPanel, buttonPanel, page1, page2;
private JLabel titleLabel, titleIcon, rowLabel, columnLabel;
@@ -159,7 +152,7 @@
private SpreadsheetImportConfigTableModel columnMappingTableModel;
- private JButton actionOkButton, actionCancelButton, nextButton, backButton;
+ private JButton nextButton, backButton;
private CardLayout cardLayout = new CardLayout();
@@ -167,45 +160,31 @@
private Stack<String> errorMessages = new Stack<String>();
- private KeyListener enterKeyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (actionOkButton.isSelected() && e.getKeyCode() == KeyEvent.VK_ENTER) {
- actionOkButton.doClick();
- }
- }
- };
+ private ObjectNode newConfiguration;
+
+ private final ServiceRegistry serviceRegistry;
/**
* Constructs a configuration view for an SpreadsheetImport Activity.
- *
+ *
* @param activity
*/
- public SpreadsheetImportConfigView(SpreadsheetImportActivity activity) {
- oldConfiguration = activity.getConfiguration();
- newConfiguration = new SpreadsheetImportConfiguration(oldConfiguration);
+ public SpreadsheetImportConfigView(Activity activity, ServiceRegistry serviceRegistry) {
+ super(activity);
+ this.serviceRegistry = serviceRegistry;
initialise();
- layoutPanel();
}
- public SpreadsheetImportConfiguration getConfiguration() {
- return newConfiguration;
- }
+ @Override
+ protected void initialise() {
+ super.initialise();
+ newConfiguration = getJson().deepCopy();
- public boolean isConfigurationChanged() {
- return !oldConfiguration.equals(newConfiguration);
- }
-
- /**
- * Initialises the panel components.
- */
- private void initialise() {
- CSH.setHelpIDString(this, this.getClass().getCanonicalName());
-
// title
titlePanel = new JPanel(new BorderLayout());
titlePanel.setBackground(Color.WHITE);
- addDivider(titlePanel, SwingConstants.BOTTOM, true);
-
+ addDivider(titlePanel, SwingConstants.BOTTOM, true);
+
titleLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.panelTitle"));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
titleIcon = new JLabel("");
@@ -222,12 +201,10 @@
columnLabel = new JLabel(SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.columnSectionLabel"));
- Range columnRange = newConfiguration.getColumnRange();
- columnFromValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.getStart()), 4);
- columnFromValue.addKeyListener(enterKeyListener);
+ JsonNode columnRange = newConfiguration.get("columnRange");
+ columnFromValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("start").intValue()), 4);
columnFromValue.setMinimumSize(columnFromValue.getPreferredSize());
- columnToValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.getEnd()), 4);
- columnToValue.addKeyListener(enterKeyListener);
+ columnToValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("end").intValue()), 4);
columnToValue.setMinimumSize(columnToValue.getPreferredSize());
columnFromValue.getDocument().addDocumentListener(new DocumentListener() {
@@ -253,7 +230,7 @@
if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
columnMappingTableModel.setFromColumn(fromColumnIndex);
columnMappingTableModel.setToColumn(toColumnIndex);
- newConfiguration.setColumnRange(new Range(fromColumnIndex, toColumnIndex));
+ newConfiguration.set("columnRange", newConfiguration.objectNode().put("start", fromColumnIndex).put("end", toColumnIndex));
validatePortNames();
}
removeErrorMessage(FROM_COLUMN_ERROR_MESSAGE);
@@ -289,7 +266,7 @@
if (checkColumnRange(fromColumnIndex, toColumnIndex)) {
columnMappingTableModel.setFromColumn(fromColumnIndex);
columnMappingTableModel.setToColumn(toColumnIndex);
- newConfiguration.setColumnRange(new Range(fromColumnIndex, toColumnIndex));
+ newConfiguration.set("columnRange", newConfiguration.objectNode().put("start", fromColumnIndex).put("end", toColumnIndex));
validatePortNames();
}
removeErrorMessage(TO_COLUMN_ERROR_MESSAGE);
@@ -314,20 +291,18 @@
.getString("SpreadsheetImportConfigView.ignoreBlankRowsOption"));
rowSelectAllOption.setFocusable(false);
rowExcludeFirstOption.setFocusable(false);
-
- Range rowRange = newConfiguration.getRowRange();
- rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.getStart() + 1), 4);
- if (rowRange.getEnd() == -1) {
+
+ JsonNode rowRange = newConfiguration.get("rowRange");
+ rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("start").intValue() + 1), 4);
+ if (rowRange.get("end").intValue() == -1) {
rowToValue = new JTextField(new NumericDocument(), "", 4);
} else {
- rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.getEnd() + 1), 4);
+ rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("end").intValue() + 1), 4);
}
- rowFromValue.addKeyListener(enterKeyListener);
rowFromValue.setMinimumSize(rowFromValue.getPreferredSize());
- rowToValue.addKeyListener(enterKeyListener);
rowToValue.setMinimumSize(rowToValue.getPreferredSize());
- if (newConfiguration.isAllRows()) {
+ if (newConfiguration.get("allRows").booleanValue()) {
rowSelectAllOption.setSelected(true);
rowFromValue.setEditable(false);
rowFromValue.setEnabled(false);
@@ -336,9 +311,9 @@
} else {
rowExcludeFirstOption.setEnabled(false);
}
- rowExcludeFirstOption.setSelected(newConfiguration.isExcludeFirstRow());
- rowIgnoreBlankRows.setSelected(newConfiguration.isIgnoreBlankRows());
-
+ rowExcludeFirstOption.setSelected(newConfiguration.get("excludeFirstRow").booleanValue());
+ rowIgnoreBlankRows.setSelected(newConfiguration.get("ignoreBlankRows").booleanValue());
+
rowFromValue.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
}
@@ -357,7 +332,7 @@
} else if (text.trim().matches("[1-9][0-9]*")) {
checkRowRange(rowFromValue.getText(), rowToValue.getText());
int fromRow = Integer.parseInt(rowFromValue.getText());
- newConfiguration.getRowRange().setStart(fromRow - 1);
+ ((ObjectNode) newConfiguration.get("rowRange")).put("start", fromRow - 1);
removeErrorMessage(FROM_ROW_ERROR_MESSAGE);
removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE);
} else {
@@ -381,13 +356,13 @@
private void checkValue(String text) {
if (text.trim().equals("")) {
- newConfiguration.getRowRange().setEnd(-1);
+ ((ObjectNode) newConfiguration.get("rowRange")).put("end", -1);
removeErrorMessage(TO_ROW_ERROR_MESSAGE);
removeErrorMessage(INCONSISTENT_ROW_MESSAGE);
} else if (text.trim().matches("[0-9]+")) {
checkRowRange(rowFromValue.getText(), rowToValue.getText());
int toRow = Integer.parseInt(rowToValue.getText());
- newConfiguration.getRowRange().setEnd(toRow - 1);
+ ((ObjectNode) newConfiguration.get("rowRange")).put("end", toRow - 1);
removeErrorMessage(TO_ROW_ERROR_MESSAGE);
} else {
addErrorMessage(TO_ROW_ERROR_MESSAGE);
@@ -398,7 +373,7 @@
rowSelectAllOption.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
- newConfiguration.setAllRows(true);
+ newConfiguration.put("allRows", true);
rowExcludeFirstOption.setEnabled(true);
if (rowExcludeFirstOption.isSelected()) {
rowFromValue.setText("2");
@@ -411,7 +386,7 @@
rowToValue.setEditable(false);
rowToValue.setEnabled(false);
} else {
- newConfiguration.setAllRows(false);
+ newConfiguration.put("allRows", false);
rowExcludeFirstOption.setEnabled(false);
rowFromValue.setEditable(true);
rowFromValue.setEnabled(true);
@@ -424,23 +399,23 @@
rowExcludeFirstOption.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
- newConfiguration.setExcludeFirstRow(true);
+ newConfiguration.put("excludeFirstRow", true);
rowFromValue.setText("2");
- newConfiguration.getRowRange().setStart(1);
+ ((ObjectNode) newConfiguration.get("rowRange")).put("start", 1);
} else {
- newConfiguration.setExcludeFirstRow(false);
+ newConfiguration.put("excludeFirstRow", false);
rowFromValue.setText("1");
- newConfiguration.getRowRange().setStart(0);
+ ((ObjectNode) newConfiguration.get("rowRange")).put("start", 0);
}
}
});
rowIgnoreBlankRows.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- newConfiguration.setIgnoreBlankRows(e.getStateChange() == ItemEvent.SELECTED);
+ newConfiguration.put("ignoreBlankRows", e.getStateChange() == ItemEvent.SELECTED);
}
});
-
+
// empty cells
emptyCellLabel = new JLabel(SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.emptyCellSectionLabel"));
@@ -457,39 +432,37 @@
emptyCellUserDefinedOption.setFocusable(false);
emptyCellErrorValueOption.setFocusable(false);
- emptyCellUserDefinedValue = new JTextField(newConfiguration.getEmptyCellValue());
- emptyCellUserDefinedValue.addKeyListener(enterKeyListener);
+ emptyCellUserDefinedValue = new JTextField(newConfiguration.get("emptyCellValue").textValue());
emptyCellButtonGroup.add(emptyCellEmptyStringOption);
emptyCellButtonGroup.add(emptyCellUserDefinedOption);
emptyCellButtonGroup.add(emptyCellErrorValueOption);
- if (newConfiguration.getEmptyCellPolicy().equals(SpreadsheetEmptyCellPolicy.GENERATE_ERROR)) {
+ if (newConfiguration.get("emptyCellPolicy").textValue().equals("GENERATE_ERROR")) {
emptyCellErrorValueOption.setSelected(true);
emptyCellUserDefinedValue.setEnabled(false);
emptyCellUserDefinedValue.setEditable(false);
- } else if (newConfiguration.getEmptyCellPolicy().equals(
- SpreadsheetEmptyCellPolicy.EMPTY_STRING)) {
+ } else if (newConfiguration.get("emptyCellPolicy").textValue().equals("EMPTY_STRING")) {
emptyCellEmptyStringOption.setSelected(true);
emptyCellUserDefinedValue.setEnabled(false);
emptyCellUserDefinedValue.setEditable(false);
} else {
emptyCellUserDefinedOption.setSelected(true);
- emptyCellUserDefinedValue.setText(newConfiguration.getEmptyCellValue());
+ emptyCellUserDefinedValue.setText(newConfiguration.get("emptyCellValue").textValue());
emptyCellUserDefinedValue.setEnabled(true);
emptyCellUserDefinedValue.setEditable(true);
}
emptyCellEmptyStringOption.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- newConfiguration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.EMPTY_STRING);
+ newConfiguration.put("emptyCellPolicy", "EMPTY_STRING");
emptyCellUserDefinedValue.setEnabled(false);
emptyCellUserDefinedValue.setEditable(false);
}
});
emptyCellUserDefinedOption.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- newConfiguration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.USER_DEFINED);
+ newConfiguration.put("emptyCellPolicy", "USER_DEFINED");
emptyCellUserDefinedValue.setEnabled(true);
emptyCellUserDefinedValue.setEditable(true);
emptyCellUserDefinedValue.requestFocusInWindow();
@@ -497,7 +470,7 @@
});
emptyCellErrorValueOption.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- newConfiguration.setEmptyCellPolicy(SpreadsheetEmptyCellPolicy.GENERATE_ERROR);
+ newConfiguration.put("emptyCellPolicy", "GENERATE_ERROR");
emptyCellUserDefinedValue.setEnabled(false);
emptyCellUserDefinedValue.setEditable(false);
}
@@ -505,15 +478,15 @@
emptyCellUserDefinedValue.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
- newConfiguration.setEmptyCellValue(emptyCellUserDefinedValue.getText());
+ newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
}
public void insertUpdate(DocumentEvent e) {
- newConfiguration.setEmptyCellValue(emptyCellUserDefinedValue.getText());
+ newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
}
public void removeUpdate(DocumentEvent e) {
- newConfiguration.setEmptyCellValue(emptyCellUserDefinedValue.getText());
+ newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText());
}
});
@@ -522,8 +495,14 @@
.getString("SpreadsheetImportConfigView.columnMappingSectionLabel"));
addDivider(columnMappingLabel, SwingConstants.TOP, false);
+ Map<String, String> columnToPortMapping = new HashMap<>();
+ if (newConfiguration.has("columnNames")) {
+ for (JsonNode columnName : newConfiguration.get("columnNames")) {
+ columnToPortMapping.put(columnName.get("column").textValue(), columnName.get("port").textValue());
+ }
+ }
columnMappingTableModel = new SpreadsheetImportConfigTableModel(columnFromValue.getText(),
- columnToValue.getText(), oldConfiguration.getColumnNames());
+ columnToValue.getText(), columnToPortMapping);
columnMappingTable = new JTable();
columnMappingTable.setRowSelectionAllowed(false);
@@ -565,8 +544,13 @@
int row = columnMappingTable.getEditingRow();
int column = columnMappingTable.getEditingColumn();
columnMappingTableModel.setValueAt(text, row, column);
- newConfiguration.setColumnNames(columnMappingTableModel
- .getColumnToPortMapping());
+
+ ArrayNode columnNames = newConfiguration.arrayNode();
+ Map<String, String> columnToPortMapping = columnMappingTableModel.getColumnToPortMapping();
+ for (Entry<String,String> entry : columnToPortMapping.entrySet()) {
+ columnNames.add(newConfiguration.objectNode().put("column", entry.getKey()).put("port", entry.getValue()));
+ }
+ newConfiguration.put("columnNames", columnNames);
validatePortNames();
}
@@ -579,7 +563,7 @@
// output format
outputFormatLabel = new JLabel(SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.outputFormatSectionLabel"));
-
+
outputFormatMultiplePort = new JRadioButton(SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.multiplePortOption"));
outputFormatSinglePort = new JRadioButton(SpreadsheetImportUIText
@@ -589,13 +573,13 @@
outputFormatDelimiterLabel = new JLabel(SpreadsheetImportUIText
.getString("SpreadsheetImportConfigView.userDefinedCsvDelimiter"));
- outputFormatDelimiter = new JTextField(newConfiguration.getCsvDelimiter(), 5);
-
+ outputFormatDelimiter = new JTextField(newConfiguration.get("csvDelimiter").textValue(), 5);
+
outputFormatButtonGroup = new ButtonGroup();
outputFormatButtonGroup.add(outputFormatMultiplePort);
outputFormatButtonGroup.add(outputFormatSinglePort);
-
- if (newConfiguration.getOutputFormat().equals(SpreadsheetOutputFormat.PORT_PER_COLUMN)) {
+
+ if (newConfiguration.get("outputFormat").textValue().equals("PORT_PER_COLUMN")) {
outputFormatMultiplePort.setSelected(true);
outputFormatDelimiterLabel.setEnabled(false);
outputFormatDelimiter.setEnabled(false);
@@ -611,7 +595,7 @@
outputFormatDelimiter.setEnabled(false);
columnMappingLabel.setEnabled(true);
enableTable(columnMappingTable, true);
- newConfiguration.setOutputFormat(SpreadsheetOutputFormat.PORT_PER_COLUMN);
+ newConfiguration.put("outputFormat", "PORT_PER_COLUMN");
}
});
outputFormatSinglePort.addActionListener(new ActionListener() {
@@ -620,7 +604,7 @@
outputFormatDelimiter.setEnabled(true);
columnMappingLabel.setEnabled(false);
enableTable(columnMappingTable, false);
- newConfiguration.setOutputFormat(SpreadsheetOutputFormat.SINGLE_PORT);
+ newConfiguration.put("outputFormat", "SINGLE_PORT");
}
});
@@ -636,29 +620,22 @@
public void removeUpdate(DocumentEvent e) {
handleUpdate();
}
-
+
private void handleUpdate() {
String text = null;
try {
text = StringEscapeUtils.unescapeJava(outputFormatDelimiter.getText());
} catch (RuntimeException re) {}
if (text == null || text.length() == 0) {
- newConfiguration.setCsvDelimiter(",");
+ newConfiguration.put("csvDelimiter", ",");
} else {
- newConfiguration.setCsvDelimiter(text.substring(0, 1));
+ newConfiguration.put("csvDelimiter", text.substring(0, 1));
}
}
});
-
- // buttons
- actionOkButton = new JButton();
- actionOkButton.setFocusable(false);
- actionOkButton.setSelected(true);
- actionCancelButton = new JButton();
- actionCancelButton.setFocusable(false);
-
+ // buttons
nextButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.nextButton"));
nextButton.setFocusable(false);
nextButton.addActionListener(new ActionListener() {
@@ -679,15 +656,30 @@
cardLayout.first(contentPanel);
}
});
-
+
buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- addDivider(buttonPanel, SwingConstants.TOP, true);
+ addDivider(buttonPanel, SwingConstants.TOP, true);
+
+ removeAll();
+ layoutPanel();
+ }
+
+ @Override
+ public void noteConfiguration() {
+ setJson(newConfiguration);
+ configureInputPorts(serviceRegistry);
+ configureOutputPorts(serviceRegistry);
+ }
+
+ @Override
+ public boolean checkValues() {
+ return errorMessages.isEmpty();
}
private void layoutPanel() {
setPreferredSize(new Dimension(450, 400));
setLayout(new BorderLayout());
-
+
page1 = new JPanel(new GridBagLayout());
page2 = new JPanel(new GridBagLayout());
@@ -695,7 +687,7 @@
contentPanel.add(page1, "page1");
contentPanel.add(page2, "page2");
add(contentPanel, BorderLayout.CENTER);
-
+
// title
titlePanel.setBorder(new CompoundBorder(titlePanel.getBorder(), new EmptyBorder(10, 10, 0, 10)));
add(titlePanel, BorderLayout.NORTH);
@@ -757,7 +749,7 @@
page1.add(rowIgnoreBlankRows, c);
c.gridx = 0;
-
+
// empty cells
c.insets = new Insets(10, 10, 10, 10);
page1.add(emptyCellLabel, c);
@@ -776,7 +768,7 @@
c.insets = new Insets(10, 10, 10, 10);
c.weighty = 0;
c.weightx = 1;
- page2.add(outputFormatLabel, c);
+ page2.add(outputFormatLabel, c);
c.insets = new Insets(0, 25, 0, 10);
page2.add(outputFormatMultiplePort, c);
@@ -787,7 +779,7 @@
outputFormatDelimiterPanel.add(outputFormatDelimiterLabel);
outputFormatDelimiterPanel.add(outputFormatDelimiter);
page2.add(outputFormatDelimiterPanel, c);
-
+
// column mapping
c.insets = new Insets(10, 10, 0, 10);
page2.add(columnMappingLabel, c);
@@ -797,29 +789,26 @@
c.weighty = 1;
page2.add(new JScrollPane(columnMappingTable), c);
- buttonPanel.add(actionCancelButton);
buttonPanel.add(backButton);
buttonPanel.add(nextButton);
- buttonPanel.add(actionOkButton);
add(buttonPanel, BorderLayout.SOUTH);
}
/**
* Displays the message with no icon.
- *
+ *
* @param message
* the message to display
*/
public void setMessage(String message) {
titleIcon.setIcon(null);
titleMessage.setText(message);
- actionOkButton.setEnabled(true);
}
/**
* Adds the message to the top of the warning message stack. If the message is already in the
* stack it is moved to the top. If there are no error messages the message is displayed.
- *
+ *
* @param message
* the warning message to add
*/
@@ -837,7 +826,7 @@
* Removes the message from the warning message stack. If there are no error messages the next
* warning message is displayed. If there are no warning messages the default message is
* displayed.
- *
+ *
* @param message
* the warning message to remove
*/
@@ -854,20 +843,19 @@
/**
* Displays the message and a warning icon.
- *
+ *
* @param message
* the warning message to display
*/
public void setWarningMessage(String message) {
titleIcon.setIcon(Icons.warningIcon);
titleMessage.setText(message);
- actionOkButton.setEnabled(true);
}
/**
* Adds the message to the top of the error message stack. If the message is already in the
* stack it is moved to the top. The message is then displayed.
- *
+ *
* @param message
* the error message to add
*/
@@ -883,7 +871,7 @@
* Removes the message from the error message stack and displays the next error message. If
* there are no error messages the next warning message is displayed. If there are no warning
* messages the default message is displayed.
- *
+ *
* @param message
* the error message to remove
*/
@@ -902,20 +890,24 @@
/**
* Displays the message and an error icon.
- *
+ *
* @param message
* the error message to display
*/
public void setErrorMessage(String message) {
titleIcon.setIcon(Icons.severeIcon);
titleMessage.setText(message);
- actionOkButton.setEnabled(false);
}
protected boolean validatePortNames() {
boolean isValid = true;
- Range columnRange = newConfiguration.getColumnRange();
- Map<String, String> mapping = newConfiguration.getColumnNames();
+ Range columnRange = SpreadsheetUtils.getRange(newConfiguration.get("columnRange"));
+ Map<String, String> mapping = new HashMap<>();
+ if (newConfiguration.has("columnNames")) {
+ for (JsonNode columnName : newConfiguration.get("columnNames")) {
+ mapping.put(columnName.get("column").textValue(), columnName.get("port").textValue());
+ }
+ }
Set<String> usedNames = new HashSet<String>();
for (Entry<String, String> entry : mapping.entrySet()) {
if (columnRange.contains(SpreadsheetUtils.getColumnIndex(entry.getKey()))) {
@@ -973,13 +965,13 @@
/**
* Adds a light gray or etched border to the top or bottom of a JComponent.
- *
+ *
* @param component
*/
protected void addDivider(JComponent component, final int position, final boolean etched) {
component.setBorder(new Border() {
private final Color borderColor = new Color(.6f, .6f, .6f);
-
+
public Insets getBorderInsets(Component c) {
if (position == SwingConstants.TOP) {
return new Insets(5, 0, 0, 0);
@@ -1019,14 +1011,6 @@
});
}
- public void setOkAction(Action okAction) {
- actionOkButton.setAction(okAction);
- }
-
- public void setCancelAction(Action cancelAction) {
- actionCancelButton.setAction(cancelAction);
- }
-
private void enableTable(JTable table, boolean enabled) {
table.setEnabled(enabled);
Component editor = table.getEditorComponent();
@@ -1035,13 +1019,13 @@
}
if (enabled) {
table.setForeground(Color.BLACK);
- table.getTableHeader().setForeground(Color.BLACK);
+ table.getTableHeader().setForeground(Color.BLACK);
} else {
table.setForeground(Color.LIGHT_GRAY);
- table.getTableHeader().setForeground(Color.LIGHT_GRAY);
+ table.getTableHeader().setForeground(Color.LIGHT_GRAY);
}
}
-
+
static class UpperCaseDocument extends PlainDocument {
@Override
public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
@@ -1061,38 +1045,38 @@
}
}
}
-
+
/**
* Main method for testing the panel.
- *
+ *
* @param args
* @throws ActivityConfigurationException
*/
- public static void main(String[] args) throws ActivityConfigurationException {
- final JFrame frame = new JFrame();
- SpreadsheetImportActivity activity = new SpreadsheetImportActivity();
- activity.configure(new SpreadsheetImportConfiguration());
- final SpreadsheetImportConfigView config = new SpreadsheetImportConfigView(activity);
- config.setOkAction(new AbstractAction("Finish") {
- public void actionPerformed(ActionEvent arg0) {
- Range columnRange = config.getConfiguration().getColumnRange();
- String fromColumn = SpreadsheetUtils.getColumnLabel(columnRange.getStart());
- String toColumn = SpreadsheetUtils.getColumnLabel(columnRange.getEnd());
- System.out.printf("%s (%s) - %s (%s)", fromColumn, columnRange.getStart(),
- toColumn, columnRange.getEnd());
- frame.setVisible(false);
- frame.dispose();
- }
- });
- config.setCancelAction(new AbstractAction("Cancel") {
- public void actionPerformed(ActionEvent arg0) {
- frame.setVisible(false);
- frame.dispose();
- }
- });
- frame.add(config);
- frame.pack();
- frame.setVisible(true);
- }
+// public static void main(String[] args) throws ActivityConfigurationException {
+// final JFrame frame = new JFrame();
+// SpreadsheetImportActivity activity = new SpreadsheetImportActivity();
+// activity.configure(new SpreadsheetImportConfiguration());
+// final SpreadsheetImportConfigView config = new SpreadsheetImportConfigView(activity);
+// config.setOkAction(new AbstractAction("Finish") {
+// public void actionPerformed(ActionEvent arg0) {
+// Range columnRange = config.getConfiguration().getColumnRange();
+// String fromColumn = SpreadsheetUtils.getColumnLabel(columnRange.getStart());
+// String toColumn = SpreadsheetUtils.getColumnLabel(columnRange.getEnd());
+// System.out.printf("%s (%s) - %s (%s)", fromColumn, columnRange.getStart(),
+// toColumn, columnRange.getEnd());
+// frame.setVisible(false);
+// frame.dispose();
+// }
+// });
+// config.setCancelAction(new AbstractAction("Cancel") {
+// public void actionPerformed(ActionEvent arg0) {
+// frame.setVisible(false);
+// frame.dispose();
+// }
+// });
+// frame.add(config);
+// frame.pack();
+// frame.setVisible(true);
+// }
}
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualView.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualView.java
index 56755fe..2078faa 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualView.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualView.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -24,39 +24,56 @@
import javax.swing.Action;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportConfiguration;
import net.sf.taverna.t2.activities.spreadsheet.actions.SpreadsheetImportActivityConfigurationAction;
import net.sf.taverna.t2.activities.spreadsheet.il8n.SpreadsheetImportUIText;
import net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportActivityIcon;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
+import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
+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.HTMLBasedActivityContextualView;
-import net.sf.taverna.t2.workflowmodel.Port;
-import net.sf.taverna.t2.workflowmodel.processor.activity.Activity;
+import uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
+import uk.org.taverna.scufl2.api.port.InputActivityPort;
+import uk.org.taverna.scufl2.api.port.OutputActivityPort;
/**
* A simple non editable HTML table view over a {@link SpreadsheetImportActivity}. Clicking on the
* configure button shows the editable {@link SpreadsheetImportConfigView}
- *
+ *
* @author David Withers
*/
-public class SpreadsheetImportContextualView extends
- HTMLBasedActivityContextualView<SpreadsheetImportConfiguration> {
+public class SpreadsheetImportContextualView extends HTMLBasedActivityContextualView {
private static final long serialVersionUID = 1L;
+ private final EditManager editManager;
+ private final FileManager fileManager;
+ private final ActivityIconManager activityIconManager;
+ private final ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private final ServiceRegistry serviceRegistry;
- public SpreadsheetImportContextualView(Activity<?> activity) {
- super(activity);
+ public SpreadsheetImportContextualView(Activity activity, EditManager editManager,
+ FileManager fileManager, ActivityIconManager activityIconManager,
+ ColourManager colourManager, ServiceDescriptionRegistry serviceDescriptionRegistry, ServiceRegistry serviceRegistry) {
+ super(activity, colourManager);
+ this.editManager = editManager;
+ this.fileManager = fileManager;
+ this.activityIconManager = activityIconManager;
+ this.serviceDescriptionRegistry = serviceDescriptionRegistry;
+ this.serviceRegistry = serviceRegistry;
}
@Override
protected String getRawTableRowsHtml() {
StringBuilder html = new StringBuilder();
html.append("<tr><th>");
- html.append(SpreadsheetImportUIText.getString("SpreadsheetImportContextualView.inputPortName"));
+ html.append(SpreadsheetImportUIText
+ .getString("SpreadsheetImportContextualView.inputPortName"));
html.append("</th><th>");
html.append(SpreadsheetImportUIText.getString("SpreadsheetImportContextualView.depth"));
html.append("</th></tr>");
- for (Port port : getActivity().getInputPorts()) {
+ for (InputActivityPort port : getActivity().getInputPorts()) {
html.append("<tr><td>");
html.append(port.getName());
html.append("</td><td>");
@@ -64,11 +81,12 @@
html.append("</td></tr>");
}
html.append("<tr><th>");
- html.append(SpreadsheetImportUIText.getString("SpreadsheetImportContextualView.outputPortName"));
+ html.append(SpreadsheetImportUIText
+ .getString("SpreadsheetImportContextualView.outputPortName"));
html.append("</th><th>");
html.append(SpreadsheetImportUIText.getString("SpreadsheetImportContextualView.depth"));
html.append("</th></tr>");
- for (Port port : getActivity().getOutputPorts()) {
+ for (OutputActivityPort port : getActivity().getOutputPorts()) {
html.append("<tr><td>");
html.append(port.getName());
html.append("</td><td>");
@@ -86,14 +104,15 @@
@Override
public Action getConfigureAction(Frame owner) {
return new SpreadsheetImportActivityConfigurationAction(
- (SpreadsheetImportActivity) getActivity(), owner);
+ getActivity(), owner, editManager, fileManager,
+ activityIconManager, serviceDescriptionRegistry, serviceRegistry);
}
@Override
public String getBackgroundColour() {
return SpreadsheetImportActivityIcon.SPREADSHEET_COLOUR_HTML;
}
-
+
@Override
public int getPreferredPosition() {
return 100;
diff --git a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualViewFactory.java b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualViewFactory.java
index 2de2b43..7e49168 100644
--- a/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualViewFactory.java
+++ b/src/main/java/net/sf/taverna/t2/activities/spreadsheet/views/SpreadsheetImportContextualViewFactory.java
@@ -1,19 +1,19 @@
/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
+ * Copyright (C) 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
@@ -23,24 +23,65 @@
import java.util.Arrays;
import java.util.List;
-import net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity;
+import net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService;
+import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
+import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
+import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
+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 uk.org.taverna.commons.services.ServiceRegistry;
+import uk.org.taverna.scufl2.api.activity.Activity;
/**
* Factory for creating contextual a view of the SpreadsheetImport Activity
- *
+ *
* @author David Withers
*/
-public class SpreadsheetImportContextualViewFactory implements
- ContextualViewFactory<SpreadsheetImportActivity> {
+public class SpreadsheetImportContextualViewFactory implements ContextualViewFactory<Activity> {
+
+ private EditManager editManager;
+ private FileManager fileManager;
+ private ActivityIconManager activityIconManager;
+ private ColourManager colourManager;
+ private ServiceDescriptionRegistry serviceDescriptionRegistry;
+ private ServiceRegistry serviceRegistry;
public boolean canHandle(Object object) {
- return object.getClass().isAssignableFrom(SpreadsheetImportActivity.class);
+ return object instanceof Activity
+ && ((Activity) object).getType().equals(
+ SpreadsheetImportTemplateService.ACTIVITY_TYPE);
}
- public List<ContextualView> getViews(SpreadsheetImportActivity activity) {
- return Arrays.asList(new ContextualView[] {new SpreadsheetImportContextualView(activity)});
+ public List<ContextualView> getViews(Activity activity) {
+ return Arrays.asList(new ContextualView[] { new SpreadsheetImportContextualView(activity,
+ editManager, fileManager, activityIconManager, colourManager,
+ 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 setColourManager(ColourManager colourManager) {
+ this.colourManager = colourManager;
+ }
+
+ public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) {
+ this.serviceDescriptionRegistry = serviceDescriptionRegistry;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
}
}
diff --git a/src/main/resources/META-INF/spring/spreadsheet-import-activity-ui-context-osgi.xml b/src/main/resources/META-INF/spring/spreadsheet-import-activity-ui-context-osgi.xml
new file mode 100644
index 0000000..72ffb77
--- /dev/null
+++ b/src/main/resources/META-INF/spring/spreadsheet-import-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="SpreadsheetImportActivityIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" />
+
+ <service ref="SpreadsheetImportTemplateService" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider" />
+
+ <service ref="SpreadsheetImportAddTemplateAction" auto-export="interfaces" />
+ <service ref="SpreadsheetImportConfigureMenuAction" auto-export="interfaces" />
+ <service ref="SpreadsheetImportAddTemplateMenuAction" auto-export="interfaces" />
+
+ <service ref="SpreadsheetImportContextualViewFactory" 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/spreadsheet-import-activity-ui-context.xml b/src/main/resources/META-INF/spring/spreadsheet-import-activity-ui-context.xml
new file mode 100644
index 0000000..7fdba26
--- /dev/null
+++ b/src/main/resources/META-INF/spring/spreadsheet-import-activity-ui-context.xml
@@ -0,0 +1,45 @@
+<?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="SpreadsheetImportActivityIcon" class="net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportActivityIcon">
+ <property name="colourManager" ref="colourManager" />
+ </bean>
+
+ <bean id="SpreadsheetImportTemplateService" class="net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService" />
+
+ <bean id="SpreadsheetImportAddTemplateAction" class="net.sf.taverna.t2.activities.spreadsheet.menu.SpreadsheetImportAddTemplateAction">
+ <property name="editManager" ref="editManager" />
+ <property name="menuManager" ref="menuManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+ <bean id="SpreadsheetImportAddTemplateMenuAction" class="net.sf.taverna.t2.activities.spreadsheet.menu.SpreadsheetImportAddTemplateMenuAction">
+ <property name="editManager" ref="editManager" />
+ <property name="menuManager" ref="menuManager" />
+ <property name="selectionManager" ref="selectionManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+ <bean id="SpreadsheetImportConfigureMenuAction" class="net.sf.taverna.t2.activities.spreadsheet.menu.SpreadsheetImportConfigureMenuAction">
+ <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="SpreadsheetImportContextualViewFactory" class="net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportContextualViewFactory">
+ <property name="editManager" ref="editManager" />
+ <property name="fileManager" ref="fileManager" />
+ <property name="activityIconManager" ref="activityIconManager" />
+ <property name="colourManager" ref="colourManager" />
+ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" />
+ <property name="serviceRegistry" ref="serviceRegistry" />
+ </bean>
+
+</beans>