You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:36:03 UTC
[48/58] [abbrv] incubator-taverna-plugin-component git commit:
org.apache.taverna.component.ui
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/OpenComponentFromComponentActivityMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/OpenComponentFromComponentActivityMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/OpenComponentFromComponentActivityMenuAction.java
deleted file mode 100644
index 8d46720..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/OpenComponentFromComponentActivityMenuAction.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import org.apache.taverna.component.api.ComponentFactory;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.core.Processor;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.FileType;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workbench.views.graph.GraphViewComponent;
-
-/**
- * @author alanrw
- */
-public class OpenComponentFromComponentActivityMenuAction extends
- AbstractContextualMenuAction {
- private static final URI configureSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/configure");
-
- private SelectionManager sm;
- private FileManager fileManager;
- private ComponentFactory factory;
- private FileType fileType;
- private GraphViewComponent graphView;
- private ComponentServiceIcon icon;
-
- public OpenComponentFromComponentActivityMenuAction() {
- super(configureSection, 75);
- }
-
- public void setSelectionManager(SelectionManager sm) {
- this.sm = sm;
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setFileType(FileType fileType) {
- this.fileType = fileType;
- }
-
- public void setGraphView(GraphViewComponent graphView) {
- this.graphView = graphView;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- @Override
- public boolean isEnabled() {
- return getSelectedActivity() != null;
- }
-
- @Override
- protected Action createAction() {
- OpenComponentFromComponentActivityAction action = new OpenComponentFromComponentActivityAction(
- fileManager, factory, fileType, graphView, icon);
- action.setSelection(getSelectedActivity());
- return action;
- }
-
- private Activity getSelectedActivity() {
- Object selection = getContextualSelection().getSelection();
- if (!super.isEnabled() || !(selection instanceof Processor))
- return null;
-
- try {
- return ((Processor) selection).getActivity(sm.getSelectedProfile());
- } catch (RuntimeException e) {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentAction.java
deleted file mode 100644
index 8e8806a..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentAction.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu;
-
-import static java.awt.BorderLayout.CENTER;
-import static java.awt.BorderLayout.SOUTH;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static net.sf.taverna.t2.component.ui.ComponentActivityConfigurationBean.ignorableNames;
-import static net.sf.taverna.t2.component.ui.util.Utils.uniqueName;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.COMPONENT_NAME;
-import static uk.org.taverna.scufl2.api.common.Scufl2Tools.NESTED_WORKFLOW;
-
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.JCheckBox;
-import javax.swing.JPanel;
-import javax.swing.JSeparator;
-
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.ComponentActivityConfigurationBean;
-import net.sf.taverna.t2.component.ui.panel.ComponentChooserPanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.edits.CompoundEdit;
-import net.sf.taverna.t2.workbench.edits.Edit;
-import net.sf.taverna.t2.workbench.edits.EditException;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workflow.edits.AddActivityEdit;
-import net.sf.taverna.t2.workflow.edits.AddActivityInputPortMappingEdit;
-import net.sf.taverna.t2.workflow.edits.AddActivityOutputPortMappingEdit;
-import net.sf.taverna.t2.workflow.edits.RemoveActivityEdit;
-import net.sf.taverna.t2.workflow.edits.RenameEdit;
-//import net.sf.taverna.t2.workflowmodel.utils.Tools;
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.Scufl2Tools;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.port.InputActivityPort;
-import uk.org.taverna.scufl2.api.port.InputProcessorPort;
-import uk.org.taverna.scufl2.api.port.OutputActivityPort;
-import uk.org.taverna.scufl2.api.port.OutputProcessorPort;
-
-/**
- * @author alanrw
- */
-public class ReplaceByComponentAction extends AbstractAction {
- private static final long serialVersionUID = 7364648399658711574L;
-
- private final EditManager em;
- private final ComponentPreference prefs;
- private final SelectionManager sm;
- private final ComponentFactory factory;
- private final Scufl2Tools tools = new Scufl2Tools();
-
- private Processor selection;
-
- public ReplaceByComponentAction(ComponentPreference prefs,
- ComponentFactory factory, EditManager em, SelectionManager sm,
- ComponentServiceIcon icon) {
- super("Replace by component...", icon.getIcon());
- this.prefs = prefs;
- this.em = em;
- this.sm = sm;
- this.factory = factory;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- JPanel overallPanel = new JPanel(new BorderLayout());
- ComponentChooserPanel panel = new ComponentChooserPanel(prefs);
- overallPanel.add(panel, CENTER);
- JPanel checkBoxPanel = new JPanel(new FlowLayout());
- JCheckBox replaceAllCheckBox = new JCheckBox(
- "Replace all matching services");
- checkBoxPanel.add(replaceAllCheckBox);
- checkBoxPanel.add(new JSeparator());
- JCheckBox renameServicesCheckBox = new JCheckBox("Rename service(s)");
- checkBoxPanel.add(renameServicesCheckBox);
- renameServicesCheckBox.setSelected(true);
- overallPanel.add(checkBoxPanel, SOUTH);
- int answer = showConfirmDialog(null, overallPanel, "Component choice",
- OK_CANCEL_OPTION);
- if (answer == OK_OPTION)
- doReplace(panel.getChosenRegistry(), panel.getChosenFamily(),
- replaceAllCheckBox.isSelected(),
- renameServicesCheckBox.isSelected(),
- panel.getChosenComponent());
- }
-
- private void doReplace(Registry chosenRegistry, Family chosenFamily,
- boolean replaceAll, boolean rename, Component chosenComponent) {
- Version chosenVersion = chosenComponent.getComponentVersionMap().get(
- chosenComponent.getComponentVersionMap().lastKey());
- Version.ID ident = new Version.Identifier(
- chosenRegistry.getRegistryBase(), chosenFamily.getName(),
- chosenComponent.getName(), chosenVersion.getVersionNumber());
-
- ComponentActivityConfigurationBean cacb = new ComponentActivityConfigurationBean(
- ident, factory);
-
- try {
- if (replaceAll) {
- Activity baseActivity = selection.getActivity(sm
- .getSelectedProfile());
- URI activityType = baseActivity.getType();
- String configString = getConfigString(baseActivity);
-
- replaceAllMatchingActivities(activityType, cacb, configString,
- rename, sm.getSelectedWorkflow());
- } else
- replaceActivity(cacb, selection, rename,
- sm.getSelectedWorkflow());
- } catch (Exception e) {
- showMessageDialog(
- null,
- "Failed to replace nested workflow with component: "
- + e.getMessage(), "Component Problem",
- ERROR_MESSAGE);
- }
- }
-
- private String getConfigString(Activity baseActivity) {
- return baseActivity.getConfiguration().getJsonAsString();
- }
-
- private void replaceAllMatchingActivities(URI activityType,
- ComponentActivityConfigurationBean cacb, String configString,
- boolean rename, Workflow d) throws IntermediateException {
- for (Processor p : d.getProcessors()) {
- Activity a = p.getActivity(sm.getSelectedProfile());
- if (a.getType().equals(activityType)
- && getConfigString(a).equals(configString))
- replaceActivity(cacb, p, rename, d);
- else if (a.getType().equals(NESTED_WORKFLOW))
- replaceAllMatchingActivities(activityType, cacb, configString,
- rename,
- tools.nestedWorkflowForProcessor(p, a.getParent()));
- }
- }
-
- private void replaceActivity(ComponentActivityConfigurationBean cacb,
- Processor p, boolean rename, Workflow d) throws IntermediateException {
- final Activity originalActivity = p.getActivity(sm.getSelectedProfile());
- final List<Edit<?>> currentWorkflowEditList = new ArrayList<>();
-
- Activity replacementActivity = new Activity();
- try {
- URI configType;
- replacementActivity.createConfiguration(configType);
-
- replacementActivity.configure(cacb);
- //FIXME
- } catch (Exception e) {
- throw new IntermediateException(
- "Unable to configure component", e);
- }
- if (originalActivity.getInputPorts().size() != replacementActivity
- .getInputPorts().size())
- throw new IntermediateException(
- "Component does not have matching ports", null);
-
- int replacementOutputSize = replacementActivity.getOutputPorts().size();
- int originalOutputSize = originalActivity.getOutputPorts().size();
- for (String name : ignorableNames) {
- if (originalActivity.getOutputPorts().getByName(name) != null)
- originalOutputSize--;
- if (replacementActivity.getOutputPorts().getByName(name) != null)
- replacementOutputSize--;
- }
-
- int sizeDifference = replacementOutputSize - originalOutputSize;
- if (sizeDifference != 0)
- throw new IntermediateException(
- "Component does not have matching ports", null);
-
- for (InputActivityPort aip : originalActivity.getInputPorts()) {
- String aipName = aip.getName();
- int aipDepth = aip.getDepth();
- InputActivityPort caip = replacementActivity.getInputPorts().getByName(aipName);
- if ((caip == null) || (caip.getDepth() != aipDepth))
- throw new RuntimeException("Original input port "
- + aipName + " is not matched");
- }
- for (OutputActivityPort aop : originalActivity.getOutputPorts()) {
- String aopName = aop.getName();
- int aopDepth = aop.getDepth();
- OutputActivityPort caop = replacementActivity.getOutputPorts().getByName(aopName);
- if ((caop == null || aopDepth != caop.getDepth())
- && !ignorableNames.contains(aopName))
- throw new IntermediateException(
- "Original output port " + aopName + " is not matched", null);
- }
-
- for (InputProcessorPort pip : p.getInputPorts()) {
- InputActivityPort iap = replacementActivity.getInputPorts()
- .getByName(pip.getName());
- if (iap == null)
- iap = new InputActivityPort(replacementActivity, pip.getName());
- currentWorkflowEditList.add(new AddActivityInputPortMappingEdit(
- replacementActivity, pip, iap));
- }
-
- for (OutputProcessorPort pop : p.getOutputPorts()) {
- OutputActivityPort oap = replacementActivity.getOutputPorts()
- .getByName(pop.getName());
- if (oap == null)
- oap = new OutputActivityPort(replacementActivity, pop.getName());
- currentWorkflowEditList.add(new AddActivityOutputPortMappingEdit(
- replacementActivity, pop, oap));
- }
-
- currentWorkflowEditList
- .add(new AddActivityEdit(p, replacementActivity));
- currentWorkflowEditList
- .add(new RemoveActivityEdit(p, originalActivity));
-
- if (rename) {
- String possibleName = replacementActivity.getConfiguration()
- .getJsonAsObjectNode().get(COMPONENT_NAME).textValue();
- currentWorkflowEditList.add(new RenameEdit<>(p, uniqueName(
- possibleName, d.getProcessors())));
- }
- try {
- em.doDataflowEdit(d.getParent(), new CompoundEdit(
- currentWorkflowEditList));
- } catch (EditException e) {
- throw new IntermediateException(
- "Unable to replace with component", e);
- }
- }
-
- public void setSelection(Processor selection) {
- this.selection = selection;
- }
-
- @SuppressWarnings("serial")
- private static class IntermediateException extends Exception {
- IntermediateException(String msg, Throwable cause) {
- super(msg, cause);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentMenuAction.java
deleted file mode 100644
index f2d5fb0..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/ReplaceByComponentMenuAction.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import org.apache.taverna.component.api.ComponentFactory;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import uk.org.taverna.scufl2.api.core.Processor;
-
-/**
- * @author alanrw
- */
-public class ReplaceByComponentMenuAction extends AbstractContextualMenuAction {
- private static final URI configureSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/configure");
-
- private ComponentPreference preferences;
- private EditManager editManager;
- private SelectionManager selectionManager;
- private ComponentFactory factory;
- private ComponentServiceIcon icon;
-
- public ReplaceByComponentMenuAction() {
- super(configureSection, 75);
- }
-
- public void setPreferences(ComponentPreference preferences) {
- this.preferences = preferences;
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- @Override
- public boolean isEnabled() {
- Object selection = getContextualSelection().getSelection();
- if (!super.isEnabled())
- return false;
- return (selection instanceof Processor);
- }
-
- @Override
- protected Action createAction() {
- ReplaceByComponentAction action = new ReplaceByComponentAction(
- preferences, factory, editManager, selectionManager, icon);
- action.setSelection((Processor) getContextualSelection().getSelection());
- return action;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/AbstractComponentMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/AbstractComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/AbstractComponentMenuAction.java
deleted file mode 100644
index 86a401b..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/AbstractComponentMenuAction.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static net.sf.taverna.t2.component.ui.menu.component.ComponentMenuSection.COMPONENT_SECTION;
-
-import java.net.URI;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuAction;
-
-abstract class AbstractComponentMenuAction extends AbstractMenuAction {
- public AbstractComponentMenuAction(int positionHint, URI id) {
- super(COMPONENT_SECTION, positionHint, id);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseAction.java
deleted file mode 100644
index b53bc77..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.events.FileManagerEvent;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author alanrw
- */
-public class ComponentCloseAction extends AbstractAction implements
- Observer<FileManagerEvent> {
- private static final long serialVersionUID = -153986599735293879L;
- private static final String CLOSE_COMPONENT = "Close component";
- @SuppressWarnings("unused")
- private static Logger logger = getLogger(ComponentCloseAction.class);
-
- private Action closeAction;
- private final Utils utils;
-
- public ComponentCloseAction(Action closeWorkflowAction, FileManager fm,
- ComponentServiceIcon icon, Utils utils) {
- super(CLOSE_COMPONENT, icon.getIcon());
- closeAction = closeWorkflowAction;
- this.utils = utils;
- fm.addObserver(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent arg0) {
- closeAction.actionPerformed(arg0);
- }
-
- @Override
- public boolean isEnabled() {
- return utils.currentDataflowIsComponent();
- }
-
- @Override
- public void notify(Observable<FileManagerEvent> sender,
- FileManagerEvent message) throws Exception {
- setEnabled(utils.currentDataflowIsComponent());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseMenuAction.java
deleted file mode 100644
index eda5cad..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCloseMenuAction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-/**
- * @author alanrw
- */
-public class ComponentCloseMenuAction extends AbstractComponentMenuAction {
- private static final URI CLOSE_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentClose");
-
- private Action action;
- private FileManager fm;
- private ComponentServiceIcon icon;
- private Utils utils;
-
- public ComponentCloseMenuAction() {
- super(1000, CLOSE_COMPONENT_URI);
- }
-
- public void setCloseWorkflowAction(Action action) {
- this.action = action;
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setUtils(Utils utils) {
- this.utils = utils;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentCloseAction(action, fm, icon, utils);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyAction.java
deleted file mode 100644
index 696d53c..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyAction.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.JPanel;
-import javax.swing.border.TitledBorder;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.panel.ComponentChoiceMessage;
-import net.sf.taverna.t2.component.ui.panel.ComponentChooserPanel;
-import net.sf.taverna.t2.component.ui.panel.ProfileChoiceMessage;
-import net.sf.taverna.t2.component.ui.panel.RegistryAndFamilyChooserPanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceProviderConfig;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Version;
-import org.apache.taverna.component.api.profile.Profile;
-
-/**
- * @author alanrw
- */
-public class ComponentCopyAction extends AbstractAction {
- private static final long serialVersionUID = -4440978712410081685L;
- private static final Logger logger = getLogger(ComponentCopyAction.class);
- private static final String COPY_COMPONENT = "Copy component...";
-
- private final ComponentPreference prefs;
- private final Utils utils;
-
- public ComponentCopyAction(ComponentPreference pref, ComponentServiceIcon icon, Utils utils) {
- super(COPY_COMPONENT, icon.getIcon());
- this.prefs = pref;
- this.utils = utils;
- }
-
- @Override
- public void actionPerformed(ActionEvent arg0) {
- JPanel overallPanel = new JPanel();
- overallPanel.setLayout(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- ComponentChooserPanel source = new ComponentChooserPanel(prefs);
- source.setBorder(new TitledBorder("Source component"));
-
- gbc.insets = new Insets(0, 5, 0, 5);
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = WEST;
- gbc.fill = BOTH;
- gbc.gridwidth = 2;
- gbc.weightx = 1;
- overallPanel.add(source, gbc);
-
- final RegistryAndFamilyChooserPanel target = new RegistryAndFamilyChooserPanel(prefs);
- target.setBorder(new TitledBorder("Target family"));
- gbc.gridy++;
- overallPanel.add(target, gbc);
-
- source.addObserver(new Observer<ComponentChoiceMessage>() {
- @Override
- public void notify(Observable<ComponentChoiceMessage> sender,
- ComponentChoiceMessage message) throws Exception {
- Profile componentProfile = null;
- Family componentFamily = message.getComponentFamily();
- if (componentFamily != null)
- componentProfile = componentFamily.getComponentProfile();
- ProfileChoiceMessage profileMessage = new ProfileChoiceMessage(
- componentProfile);
- target.notify(null, profileMessage);
- }
- });
-
- int answer = showConfirmDialog(null, overallPanel, "Copy Component",
- OK_CANCEL_OPTION);
- if (answer == OK_OPTION)
- doCopy(source.getChosenComponent(), target.getChosenFamily());
- }
-
- private void doCopy(Component sourceComponent, Family targetFamily) {
- if (sourceComponent == null) {
- showMessageDialog(null, "Unable to determine source component",
- "Component Copy Problem", ERROR_MESSAGE);
- return;
- } else if (targetFamily == null) {
- showMessageDialog(null, "Unable to determine target family",
- "Component Copy Problem", ERROR_MESSAGE);
- return;
- }
-
- try {
- String componentName = sourceComponent.getName();
- boolean alreadyUsed = targetFamily.getComponent(componentName) != null;
- if (alreadyUsed)
- showMessageDialog(null, componentName + " is already used",
- "Duplicate component name", ERROR_MESSAGE);
- else {
- Version targetVersion = doCopy(sourceComponent, targetFamily,
- componentName);
- try {
- utils.refreshComponentServiceProvider(new ComponentServiceProviderConfig(
- targetVersion.getID()).getConfiguration());
- } catch (Exception e) {
- logger.error(e);
- }
- }
- } catch (ComponentException e) {
- logger.error("failed to copy component", e);
- showMessageDialog(null,
- "Unable to create component: " + e.getMessage(),
- "Component Copy Problem", ERROR_MESSAGE);
- }
- }
-
- private Version doCopy(Component sourceComponent, Family targetFamily,
- String componentName) throws ComponentException {
- return targetFamily
- .createComponentBasedOn(
- componentName,
- sourceComponent.getDescription(),
- sourceComponent
- .getComponentVersionMap()
- .get(sourceComponent.getComponentVersionMap()
- .lastKey()).getImplementation());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyMenuAction.java
deleted file mode 100644
index e694b40..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCopyMenuAction.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-
-/**
- * @author alanrw
- */
-public class ComponentCopyMenuAction extends AbstractComponentMenuAction {
- private static final URI COPY_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentCopy");
-
- private ComponentPreference prefs;
- private ComponentServiceIcon icon;
- private Utils utils;
-
- public ComponentCopyMenuAction() {
- super(800, COPY_COMPONENT_URI);
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setPreferences(ComponentPreference prefs) {//FIXME beaninject
- this.prefs = prefs;
- }
-
- public void setUtils(Utils utils) {
- this.utils = utils;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentCopyAction(prefs, icon, utils);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCreatorSupport.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCreatorSupport.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCreatorSupport.java
deleted file mode 100644
index 7c715bf..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentCreatorSupport.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static net.sf.taverna.t2.component.ui.util.Utils.refreshComponentServiceProvider;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.api.core.DataLink;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.port.InputProcessorPort;
-import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-import uk.org.taverna.scufl2.api.port.OutputProcessorPort;
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.ComponentActivityConfigurationBean;
-import net.sf.taverna.t2.component.ui.panel.RegistryAndFamilyChooserComponentEntryPanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceProviderConfig;
-import net.sf.taverna.t2.component.ui.util.ComponentFileType;
-import net.sf.taverna.t2.workbench.edits.CompoundEdit;
-import net.sf.taverna.t2.workbench.edits.Edit;
-import net.sf.taverna.t2.workbench.edits.EditException;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.FileType;
-import net.sf.taverna.t2.workbench.file.exceptions.OverwriteException;
-import net.sf.taverna.t2.workbench.file.exceptions.SaveException;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.t2.workflow.edits.AddActivityEdit;
-import net.sf.taverna.t2.workflow.edits.AddActivityInputPortMappingEdit;
-import net.sf.taverna.t2.workflow.edits.AddActivityOutputPortMappingEdit;
-import net.sf.taverna.t2.workflow.edits.AddDataLinkEdit;
-import net.sf.taverna.t2.workflow.edits.AddProcessorEdit;
-import net.sf.taverna.t2.workflow.edits.AddWorkflowInputPortEdit;
-import net.sf.taverna.t2.workflow.edits.AddWorkflowOutputPortEdit;
-import net.sf.taverna.t2.workflow.edits.RemoveActivityEdit;
-import net.sf.taverna.t2.workflow.edits.RenameEdit;
-import static net.sf.taverna.t2.workflowmodel.utils.Tools;
-
-public class ComponentCreatorSupport {
- private static final Logger logger = getLogger(ComponentCreatorSupport.class);
-
- private ComponentFactory factory;
- private FileManager fm;
- private EditManager em;
- private ComponentPreference prefs;
- private FileType ft;
- private SelectionManager sm;
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setPreferences(ComponentPreference pref) {
- this.prefs = pref;
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setEditManager(EditManager em) {
- this.em = em;
- }
-
- public void setFileType(FileType ft) {
- this.ft = ft;
- }
-
- public void setSelectionManager(SelectionManager sm) {
- this.sm = sm;
- }
-
- public class CopiedProcessor {
- Processor processor;
- Map<String,Workflow> requiredSubworkflows;
- }
-
- void moveComponentActivityIntoPlace(Activity toReplace, Processor contextProcessor,
- Activity replacingActivity) throws EditException {
- List<Edit<?>> editsToDo = new ArrayList<>();
- for (InputProcessorPort pip : contextProcessor.getInputPorts())
- editsToDo.add(new AddActivityInputPortMappingEdit(toReplace, pip, null/*FIXME*/));
- for (OutputProcessorPort pop : contextProcessor.getOutputPorts())
- editsToDo.add(new AddActivityOutputPortMappingEdit(toReplace, pop, null/*FIXME*/));
- editsToDo.add(new RemoveActivityEdit(contextProcessor, toReplace));
- editsToDo.add(new AddActivityEdit(contextProcessor, replacingActivity));
- em.doDataflowEdit(contextProcessor.getParent().getParent(),
- new CompoundEdit(editsToDo));
- }
-
- void connectNewProcessor(Workflow d, Processor newProcessor)
- throws EditException {
- List<Edit<?>> editsToDo = new ArrayList<>();
-
- for (InputProcessorPort pip : newProcessor.getInputPorts()) {
- InputWorkflowPort dip = new InputWorkflowPort(d, pip.getName());
- // FIXME How to set depth?
- editsToDo.add(new AddWorkflowInputPortEdit(d, dip));
- editsToDo.add(new AddDataLinkEdit(d, new DataLink(d, dip, pip)));
- }
-
- for (OutputProcessorPort pop : newProcessor.getOutputPorts()) {
- OutputWorkflowPort dop = new OutputWorkflowPort(d, pop.getName());
- // TODO How to indicate depth?
- editsToDo.add(new AddWorkflowOutputPortEdit(d, dop));
- editsToDo.add(new AddDataLinkEdit(d, new DataLink(d, pop, dop)));
- }
- em.doDataflowEdit(d.getParent(), new CompoundEdit(editsToDo));
- }
-
- public ComponentActivityConfigurationBean saveWorkflowAsComponent(
- WorkflowBundle d, Version.ID ident) throws SaveException, IOException,
- ComponentException {
- if (ident == null)
- return null;
-
- createInitialComponent(d, ident);
-
- refreshComponentServiceProvider(new ComponentServiceProviderConfig(
- ident));
- return new ComponentActivityConfigurationBean(ident, factory);
- }
-
- public ComponentActivityConfigurationBean saveWorkflowAsComponent(
- Workflow d, Version.ID ident) throws SaveException, IOException,
- ComponentException {
- WorkflowBundle b = new WorkflowBundle();
- ((Workflow)d.clone()).setParent(b);
- //FIXME also must copy profile parts!
- return saveWorkflowAsComponent(b, ident);
- }
-
- Version.ID getNewComponentIdentification(String defaultName) {
- RegistryAndFamilyChooserComponentEntryPanel panel = new RegistryAndFamilyChooserComponentEntryPanel(prefs);
- panel.setComponentName(defaultName);
- int result = showConfirmDialog(null, panel, "Component location",
- OK_CANCEL_OPTION);
- if (result != OK_OPTION)
- return null;
-
- Version.ID ident = panel.getComponentVersionIdentification();
- if (ident == null) {
- showMessageDialog(null,
- "Not enough information to create component",
- "Component creation problem", ERROR_MESSAGE);
- return null;
- }
-
- try {
- Component existingComponent = factory.getComponent(ident);
- if (existingComponent != null) {
- showMessageDialog(null,
- "Component with this name already exists",
- "Component creation problem", ERROR_MESSAGE);
- return null;
- }
- } catch (ComponentException e) {
- logger.error("failed to search registry", e);
- showMessageDialog(null,
- "Problem searching registry: " + e.getMessage(),
- "Component creation problem", ERROR_MESSAGE);
- return null;
- }
- return ident;
- }
-
- CopiedProcessor copyProcessor(Processor p) throws IOException {
- CopiedProcessor copy = new CopiedProcessor();
- copy.processor = ProcessorXMLSerializer.getInstance().processorToXML(p);
- copy.requiredSubworkflows = new HashMap<>();
- rememberSubworkflows(p, copy);
- return copy;
- }
-
- void rememberSubworkflows(Processor p, CopiedProcessor copy) {
- for (Activity a : p.getActivity(sm.getSelectedProfile()))
- if (a instanceof NestedDataflow) {
- NestedDataflow da = (NestedDataflow) a;
- Workflow df = da.getNestedDataflow();
- if (!copy.requiredSubworkflows.containsKey(df.getIdentifier())) {
- copy.requiredSubworkflows.put(df.getIdentifier(),
- DataflowXMLSerializer.getInstance()
- .serializeDataflow(df));
- for (Processor sp : df.getProcessors())
- rememberSubworkflows(sp, copy);
- }
- }
- }
-
- public Processor pasteProcessor(CopiedProcessor copy, Workflow d)
- throws
- ClassNotFoundException, InstantiationException,
- IllegalAccessException {
- Processor result = ProcessorXMLDeserializer.getInstance()
- .deserializeProcessor(copy.processor, copy.requiredSubworkflows);
- if (result == null)
- return null;
-
- String newName = Tools.uniqueProcessorName(result.getName(), d);
-
- List<Edit<?>> editList = new ArrayList<>();
- if (!newName.equals(result.getName()))
- editList.add(new RenameEdit<>(result, newName));
- editList.add(new AddProcessorEdit(d, result));
- em.doDataflowEdit(d.getParent(), new CompoundEdit(editList));
-
- return result;
- }
-
- public Version.ID createInitialComponent(WorkflowBundle d, Version.ID ident)
- throws ComponentException {
- try {
- fm.saveDataflow(d, ft, ident, false);
-
- em.doDataflowEdit(d, new RenameEdit<>(d, d.getName()));
- } catch (SaveException | IllegalStateException | EditException e) {
- throw new ComponentException(e);
- }
- return ident;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteAction.java
deleted file mode 100644
index b87eaba..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static java.lang.String.format;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.YES_NO_OPTION;
-import static javax.swing.JOptionPane.YES_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.event.ActionEvent;
-import java.util.concurrent.ExecutionException;
-
-import javax.swing.AbstractAction;
-import javax.swing.SwingWorker;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.panel.ComponentChooserPanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceProviderConfig;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * @author alanrw
- */
-public class ComponentDeleteAction extends AbstractAction {
- private static final String COMPONENT_PROBLEM_TITLE = "Component Problem";
- private static final String CONFIRM_MSG = "Are you sure you want to delete %s?";
- private static final String CONFIRM_TITLE = "Delete Component Confirmation";
- private static final String DELETE_COMPONENT_LABEL = "Delete component...";
- private static final String DELETE_FAILED_TITLE = "Component Deletion Error";
- private static final String FAILED_MSG = "Unable to delete %s: %s";
- private static final String OPEN_COMPONENT_MSG = "The component is open";
- private static final String TITLE = "Component choice";
- private static final String WHAT_COMPONENT_MSG = "Unable to determine component";
- private static final long serialVersionUID = -2992743162132614936L;
- private static final Logger logger = getLogger(ComponentDeleteAction.class);
-
- private final FileManager fm;
- private final ComponentPreference prefs;
- private final Utils utils;
-
- public ComponentDeleteAction(FileManager fm, ComponentPreference prefs,
- ComponentServiceIcon icon, Utils utils) {
- super(DELETE_COMPONENT_LABEL, icon.getIcon());
- this.fm = fm;
- this.prefs = prefs;
- this.utils = utils;
- }
-
- @Override
- public void actionPerformed(ActionEvent evt) {
- ComponentChooserPanel panel = new ComponentChooserPanel(prefs);
- int answer = showConfirmDialog(null, panel, TITLE, OK_CANCEL_OPTION);
- if (answer == OK_OPTION)
- doDelete(panel.getChosenComponent());
- }
-
- private void doDelete(final Component chosenComponent) {
- if (chosenComponent == null) {
- showMessageDialog(null, WHAT_COMPONENT_MSG,
- COMPONENT_PROBLEM_TITLE, ERROR_MESSAGE);
- } else if (componentIsInUse(chosenComponent)) {
- showMessageDialog(null, OPEN_COMPONENT_MSG,
- COMPONENT_PROBLEM_TITLE, ERROR_MESSAGE);
- } else if (showConfirmDialog(null,
- format(CONFIRM_MSG, chosenComponent.getName()), CONFIRM_TITLE,
- YES_NO_OPTION) == YES_OPTION)
- new SwingWorker<Configuration, Object>() {
- @Override
- protected Configuration doInBackground() throws Exception {
- return deleteComponent(chosenComponent);
- }
-
- @Override
- protected void done() {
- refresh(chosenComponent, this);
- }
- }.execute();
- }
-
- private Configuration deleteComponent(Component component)
- throws ComponentException {
- ComponentServiceProviderConfig config = new ComponentServiceProviderConfig(
- component.getFamily());
- component.delete();
- return config.getConfiguration();
- }
-
- protected void refresh(Component component,
- SwingWorker<Configuration, Object> worker) {
- try {
- utils.refreshComponentServiceProvider(worker.get());
- } catch (ExecutionException e) {
- logger.error("failed to delete component", e.getCause());
- showMessageDialog(
- null,
- format(FAILED_MSG, component.getName(), e.getCause()
- .getMessage()), DELETE_FAILED_TITLE, ERROR_MESSAGE);
- } catch (InterruptedException e) {
- logger.warn("interrupted during component deletion", e);
- }
- }
-
- private boolean componentIsInUse(Component component) {
- for (WorkflowBundle d : fm.getOpenDataflows()) {
- Object dataflowSource = fm.getDataflowSource(d);
- if (dataflowSource instanceof Version.ID
- && ((Version.ID) dataflowSource).mostlyEqualTo(component))
- return true;
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteMenuAction.java
deleted file mode 100644
index e348f8a..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentDeleteMenuAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-/**
- * @author alanrw
- */
-public class ComponentDeleteMenuAction extends AbstractComponentMenuAction {
- private static final URI DELETE_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentDelete");
-
- private FileManager fm;
- private ComponentServiceIcon icon;
- private ComponentPreference prefs;
- private Utils utils;
-
- public ComponentDeleteMenuAction() {
- super(1200, DELETE_COMPONENT_URI);
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setPreferences(ComponentPreference prefs) {
- this.prefs = prefs;
- }
-
- public void setUtils(Utils utils) {
- this.utils = utils;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentDeleteAction(fm, prefs, icon, utils);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuAction.java
deleted file mode 100644
index 2162f91..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static net.sf.taverna.t2.component.ui.menu.component.ComponentMenuSection.COMPONENT_SECTION;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuAction;
-
-/**
- * Basis for all menu actions. Intended to be configured by Spring.
- *
- * @author Donal Fellows
- */
-public class ComponentMenuAction extends AbstractMenuAction {
- /**
- * Construct a menu action to appear within the "Components" menu.
- * @param positionHint
- * Where on the menu this should come.
- * @param id
- * How this should be identified to Taverna.
- */
- public ComponentMenuAction(int positionHint, String id) {
- super(COMPONENT_SECTION, positionHint, URI.create(id));
- }
-
- private Action action;
-
- public void setAction(Action action) {
- this.action = action;
- }
-
- @Override
- protected Action createAction() {
- return action;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuSection.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuSection.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuSection.java
deleted file mode 100644
index 3904dc2..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMenuSection.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static net.sf.taverna.t2.component.ui.menu.ComponentMenu.COMPONENT;
-
-import java.net.URI;
-
-import net.sf.taverna.t2.ui.menu.AbstractMenuSection;
-
-/**
- * @author alanrw
- */
-public class ComponentMenuSection extends AbstractMenuSection {
- public static final URI COMPONENT_SECTION = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentSection");
-
- public ComponentMenuSection() {
- super(COMPONENT, 400, COMPONENT_SECTION);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeAction.java
deleted file mode 100644
index 82f0b1e..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeAction.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.JPanel;
-import javax.swing.border.TitledBorder;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.panel.ComponentChoiceMessage;
-import net.sf.taverna.t2.component.ui.panel.ComponentChooserPanel;
-import net.sf.taverna.t2.component.ui.panel.ProfileChoiceMessage;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Version;
-
-/**
- * @author alanrw
- */
-public class ComponentMergeAction extends AbstractAction {
- private static final long serialVersionUID = 6791184757725253807L;
- private static final Logger logger = getLogger(ComponentMergeAction.class);
- private static final String MERGE_COMPONENT = "Merge component...";
-
- private final ComponentPreference prefs;
-
- public ComponentMergeAction(ComponentPreference prefs,
- ComponentServiceIcon icon) {
- super(MERGE_COMPONENT, icon.getIcon());
- this.prefs = prefs;
- }
-
- @Override
- public void actionPerformed(ActionEvent arg0) {
- JPanel overallPanel = new JPanel();
- overallPanel.setLayout(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- ComponentChooserPanel source = new ComponentChooserPanel(prefs);
- source.setBorder(new TitledBorder("Source component"));
-
- gbc.insets = new Insets(0, 5, 0, 5);
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = WEST;
- gbc.fill = BOTH;
- gbc.gridwidth = 2;
- gbc.weightx = 1;
- overallPanel.add(source, gbc);
-
- final ComponentChooserPanel target = new ComponentChooserPanel(prefs);
- target.setBorder(new TitledBorder("Target component"));
- gbc.gridy++;
- overallPanel.add(target, gbc);
-
- source.addObserver(new Observer<ComponentChoiceMessage>() {
- @Override
- public void notify(Observable<ComponentChoiceMessage> sender,
- ComponentChoiceMessage message) throws Exception {
- target.notify(null, new ProfileChoiceMessage(message
- .getComponentFamily().getComponentProfile()));
- }
- });
-
- int answer = showConfirmDialog(null, overallPanel, "Merge Component",
- OK_CANCEL_OPTION);
- if (answer == OK_OPTION)
- doMerge(source.getChosenComponent(), target.getChosenComponent());
- }
-
- private void doMerge(Component sourceComponent, Component targetComponent) {
- if (sourceComponent == null) {
- showMessageDialog(null, "Unable to determine source component",
- "Component Merge Problem", ERROR_MESSAGE);
- return;
- } else if (targetComponent == null) {
- showMessageDialog(null, "Unable to determine target component",
- "Component Merge Problem", ERROR_MESSAGE);
- return;
- } else if (sourceComponent.equals(targetComponent)) {
- showMessageDialog(null, "Cannot merge a component with itself",
- "Component Merge Problem", ERROR_MESSAGE);
- return;
- }
-
- try {
- Version sourceVersion = sourceComponent.getComponentVersionMap()
- .get(sourceComponent.getComponentVersionMap().lastKey());
- targetComponent.addVersionBasedOn(
- sourceVersion.getImplementation(), "Merge from "
- + sourceComponent.getFamily().getName() + ":"
- + sourceComponent.getName());
- } catch (ComponentException e) {
- logger.error("failed to merge component", e);
- showMessageDialog(null, "Failed to merge component: " + e,
- "Component Merge Problem", ERROR_MESSAGE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeMenuAction.java
deleted file mode 100644
index 6f5b011..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentMergeMenuAction.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-
-/**
- * @author alanrw
- */
-public class ComponentMergeMenuAction extends AbstractComponentMenuAction {
- private static final URI MERGE_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentMerge");
-
- private ComponentServiceIcon icon;
- private ComponentPreference prefs;
-
- public ComponentMergeMenuAction() {
- super(900, MERGE_COMPONENT_URI);
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setPreferences(ComponentPreference prefs) {
- this.prefs = prefs;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentMergeAction(prefs, icon);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveAction.java
deleted file mode 100644
index d6bea1d..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.events.FileManagerEvent;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author alanrw
- */
-public class ComponentSaveAction extends AbstractAction implements
- Observer<FileManagerEvent> {
- private static final long serialVersionUID = -2391891750558659714L;
- @SuppressWarnings("unused")
- private static Logger logger = getLogger(ComponentSaveAction.class);
- private static final String SAVE_COMPONENT = "Save component";
-
- private Utils utils;
- private Action saveWorkflowAction;
-
- public ComponentSaveAction(Action saveAction, FileManager fm,
- ComponentServiceIcon icon, Utils utils) {
- super(SAVE_COMPONENT, icon.getIcon());
- saveWorkflowAction = saveAction;
- this.utils = utils;
- fm.addObserver(this);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- saveWorkflowAction.actionPerformed(e);
- }
-
- @Override
- public void notify(Observable<FileManagerEvent> sender,
- FileManagerEvent message) throws Exception {
- setEnabled(saveWorkflowAction.isEnabled()
- && utils.currentDataflowIsComponent());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveMenuAction.java
deleted file mode 100644
index c6c79d9..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSaveMenuAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-/**
- * @author alanrw
- */
-public class ComponentSaveMenuAction extends AbstractComponentMenuAction {
- private static final URI SAVE_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentSave");
-
- private Action action;
- private FileManager fm;
- private ComponentServiceIcon icon;
- private Utils utils;
-
- public ComponentSaveMenuAction() {
- super(1100, SAVE_COMPONENT_URI);
- }
-
- //FIXME beaninject net.sf.taverna.t2.workbench.file.impl.actions.SaveWorkflowAction
- public void setSaveWorkflowAction(Action action) {
- this.action = action;
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setUtils(Utils utils) {
- this.utils = utils;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentSaveAction(action, fm, icon, utils);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchAction.java
deleted file mode 100644
index 5574edd..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchAction.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.QUESTION_MESSAGE;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static javax.swing.JOptionPane.showOptionDialog;
-import static net.sf.taverna.t2.workbench.ui.workflowview.WorkflowView.importServiceDescription;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.util.Map.Entry;
-import java.util.SortedMap;
-
-import javax.swing.AbstractAction;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.panel.PrefixPanel;
-import net.sf.taverna.t2.component.ui.panel.ProfileChooserPanel;
-import net.sf.taverna.t2.component.ui.panel.RegistryChooserPanel;
-import net.sf.taverna.t2.component.ui.panel.SearchChoicePanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceDesc;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.ui.menu.MenuManager;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-import org.apache.taverna.component.api.profile.Profile;
-
-import uk.org.taverna.commons.services.ServiceRegistry;
-
-/**
- * @author alanrw
- */
-public class ComponentSearchAction extends AbstractAction {
- private static final String WFDESC_PREFIX = "wfdesc";
- private static final long serialVersionUID = -7780471499146286881L;
- @SuppressWarnings("unused")
- private static final Logger logger = getLogger(ComponentSearchAction.class);
- private static final String SEARCH_FOR_COMPONENTS = "Search for components...";
-
- private final ComponentPreference prefs;
- private final ComponentFactory factory;
- private final EditManager em;
- private final MenuManager mm;
- private final SelectionManager sm;
- private final ServiceRegistry sr;
- private final ComponentServiceIcon icon;
-
- public ComponentSearchAction(ComponentPreference prefs,
- ComponentFactory factory, EditManager em, MenuManager mm,
- SelectionManager sm, ServiceRegistry sr, ComponentServiceIcon icon) {
- super(SEARCH_FOR_COMPONENTS, icon.getIcon());
- this.prefs = prefs;
- this.factory = factory;
- this.em = em;
- this.mm = mm;
- this.sm = sm;
- this.sr = sr;
- this.icon = icon;
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- JPanel overallPanel = new JPanel(new GridBagLayout());
- GridBagConstraints gbc = new GridBagConstraints();
-
- RegistryChooserPanel registryPanel = new RegistryChooserPanel(prefs);
-
- gbc.insets.left = 5;
- gbc.insets.right = 5;
- gbc.gridx = 0;
- gbc.anchor = WEST;
- gbc.fill = BOTH;
- gbc.gridwidth = 2;
- gbc.weightx = 1;
- gbc.gridy++;
- overallPanel.add(registryPanel, gbc);
-
- ProfileChooserPanel profilePanel = new ProfileChooserPanel(registryPanel);
- gbc.gridx = 0;
- gbc.gridy++;
- overallPanel.add(profilePanel, gbc);
-
- PrefixPanel prefixPanel = new PrefixPanel(profilePanel);
- gbc.gridx = 0;
- gbc.gridy++;
- overallPanel.add(prefixPanel, gbc);
-
- JTextArea queryPane = new JTextArea(20, 80);
- gbc.gridx = 0;
- gbc.weighty = 1;
- gbc.gridy++;
- overallPanel.add(new JScrollPane(queryPane), gbc);
-
- int answer = showConfirmDialog(null, overallPanel,
- "Search for components", OK_CANCEL_OPTION);
- if (answer == OK_OPTION)
- doSearch(registryPanel.getChosenRegistry(),
- profilePanel.getChosenProfile(),
- prefixPanel.getPrefixMap(), queryPane.getText());
- }
-
- private void doSearch(Registry chosenRegistry, Profile chosenProfile,
- SortedMap<String, String> prefixMap, String queryString) {
- if (chosenRegistry == null) {
- showMessageDialog(null, "Unable to determine registry",
- "Component Registry Problem", ERROR_MESSAGE);
- return;
- }
- if (chosenProfile == null) {
- showMessageDialog(null, "Unable to determine profile",
- "Component Profile Problem", ERROR_MESSAGE);
- return;
- }
- StringBuilder prefixString = new StringBuilder();
- for (Entry<String, String> entry : prefixMap.entrySet())
- if (!entry.getKey().equals(WFDESC_PREFIX))
- prefixString.append(constructPrefixString(entry));
-
- SearchChoicePanel searchChoicePanel = new SearchChoicePanel(
- chosenRegistry, prefixString.toString(), queryString);
- int answer = showOptionDialog(null, searchChoicePanel,
- "Matching components", OK_CANCEL_OPTION, QUESTION_MESSAGE,
- null, new String[] { "Add to workflow", "Cancel" }, "Cancel");
- if (answer == OK_OPTION) {
- Version.ID ident = searchChoicePanel.getVersionIdentification();
- if (ident != null)
- importServiceDescription(new ComponentServiceDesc(prefs,
- factory, icon, ident), false, em, mm, sm, sr);
- }
- }
-
- private static String constructPrefixString(Entry<String, String> entry) {
- String key = entry.getKey();
- String value = entry.getValue();
- return String.format("PREFIX %s:<%s>\n", key, value);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchMenuAction.java
deleted file mode 100644
index 9695cf8..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentSearchMenuAction.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import org.apache.taverna.component.api.ComponentFactory;
-
-import uk.org.taverna.commons.services.ServiceRegistry;
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.ui.menu.MenuManager;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-
-/**
- * @author alanrw
- */
-public class ComponentSearchMenuAction extends AbstractComponentMenuAction {
- private static final URI SEARCH_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentSearch");
- private ComponentPreference prefs;
- private ComponentFactory factory;
- private EditManager em;
- private MenuManager mm;
- private SelectionManager sm;
- private ServiceRegistry serviceRegistry;
- private ComponentServiceIcon icon;
-
- public ComponentSearchMenuAction() {
- super(1500, SEARCH_COMPONENT_URI);
- }
-
- public void setPreferences(ComponentPreference prefs) {
- this.prefs = prefs;
- }
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setEditManager(EditManager em) {
- this.em = em;
- }
-
- public void setMenuManager(MenuManager mm) {
- this.mm = mm;
- }
-
- public void setSelectionManager(SelectionManager sm) {
- this.sm = sm;
- }
-
- public void setServiceRegistry(ServiceRegistry serviceRegistry) {
- this.serviceRegistry = serviceRegistry;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentSearchAction(prefs, factory, em, mm, sm,
- serviceRegistry, icon);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorAction.java
deleted file mode 100644
index f5d0c87..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorAction.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static org.apache.log4j.Logger.getLogger;
-import static uk.org.taverna.scufl2.api.common.Scufl2Tools.NESTED_WORKFLOW;
-
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-
-import net.sf.taverna.t2.component.ui.menu.component.ComponentCreatorSupport.CopiedProcessor;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Version;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.profiles.Profile;
-
-/**
- * @author alanrw
- */
-public class ComponentServiceCreatorAction extends AbstractAction {
- private static final long serialVersionUID = -2611514696254112190L;
- private static Logger logger = getLogger(ComponentServiceCreatorAction.class);
-
- private final Processor p;
- private final Profile profile;
- private final ComponentCreatorSupport support;
-
- public ComponentServiceCreatorAction(Processor processor, SelectionManager sm,
- ComponentCreatorSupport support, ComponentServiceIcon icon) {
- super("Create component...", icon.getIcon());
- this.support = support;
- p = processor;
- profile = sm.getSelectedProfile();
- }
-
- private Workflow getNestedWorkflow(Activity a) {
- JsonNode nw = a.getConfiguration().getJson().get("nestedWorkflow");
- return a.getParent().getParent().getWorkflows().getByName(nw.asText());
- }
-
- @Override
- public void actionPerformed(ActionEvent event) {
- Version.ID ident = support.getNewComponentIdentification(p.getName());
- if (ident == null)
- return;
-
- Activity a = p.getActivity(profile);
-
- try {
- Workflow d;
- if (NESTED_WORKFLOW.equals(a.getType()))
- d = getNestedWorkflow(a);
- else {
- d = new Workflow();
-
- /* TODO: Keep the description */
- // fm.setCurrentDataflow(current);
-
- CopiedProcessor processorElement = support.copyProcessor(p);
-
- Processor newProcessor;
- try {
- newProcessor = support.pasteProcessor(processorElement, d);
- } catch (IllegalArgumentException e) {
- logger.error(
- "failed to paste processor representing component",
- e);
- showMessageDialog(null, e.getMessage(),
- "Component creation failure", ERROR_MESSAGE);
- return;
- }
-
- support.connectNewProcessor(d, newProcessor);
- }
-
- Activity ca = new Activity();
- support.saveWorkflowAsComponent(d, ident).installConfiguration(ca);
- support.moveComponentActivityIntoPlace(a, p, ca);
- } catch (Exception e) {
- logger.error("failed to instantiate component", e);
- showMessageDialog(null, e.getCause().getMessage(),
- "Component creation failure", ERROR_MESSAGE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorMenuAction.java
deleted file mode 100644
index 9be949c..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentServiceCreatorMenuAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.core.Processor;
-import net.sf.taverna.t2.component.ui.menu.AbstractContextComponentMenuAction;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-
-/**
- * @author alanrw
- */
-public class ComponentServiceCreatorMenuAction extends
- AbstractContextComponentMenuAction {
- private static final URI configureSection = URI
- .create("http://taverna.sf.net/2009/contextMenu/configure");
-
- private ComponentCreatorSupport support;
- private SelectionManager sm;
- private ComponentServiceIcon icon;
-
- public ComponentServiceCreatorMenuAction() {
- super(configureSection, 60);
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setSelectionManager(SelectionManager sm) {
- this.sm = sm;
- }
-
- public void setSupport(ComponentCreatorSupport support) {
- this.support = support;
- }
-
- @Override
- public boolean isEnabled() {
- if (!super.isEnabled())
- return false;
- Activity a = findActivity();
- if (a == null)
- return false;
- return !isComponentActivity(a);
- }
-
- @Override
- protected Action createAction() {
- return new ComponentServiceCreatorAction(
- (Processor) getContextualSelection().getSelection(), sm,
- support, icon);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorAction.java
deleted file mode 100644
index e186c10..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorAction.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.event.ActionEvent;
-
-import net.sf.taverna.t2.component.ui.ComponentAction;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.events.FileManagerEvent;
-import net.sf.taverna.t2.workbench.views.graph.GraphViewComponent;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * @author alanrw
- */
-public class ComponentWorkflowCreatorAction extends ComponentAction implements
- Observer<FileManagerEvent> {
- private static final long serialVersionUID = -299685223430721587L;
- private static Logger logger = getLogger(ComponentWorkflowCreatorAction.class);
- private static final String CREATE_COMPONENT = "Create component from current workflow...";
-
- private ComponentCreatorSupport support;
- private FileManager fileManager;
- private Utils utils;
-
- public ComponentWorkflowCreatorAction(ComponentCreatorSupport support,
- FileManager fm, GraphViewComponent graphView,
- ComponentServiceIcon icon, Utils utils) {
- super(CREATE_COMPONENT, graphView);
- this.support = support;
- this.utils = utils;
- fm.addObserver(this);
- this.setIcon(icon);
- }
-
- @Override
- public void actionPerformed(ActionEvent event) {
- WorkflowBundle bundle = fileManager.getCurrentDataflow();
- try {
- Version.ID ident = support.getNewComponentIdentification(bundle.getName());//TODO is this right
- if (ident == null)
- return;
- support.saveWorkflowAsComponent(bundle, ident);
- } catch (Exception e) {
- showMessageDialog(graphView, e.getCause().getMessage(),
- "Component creation failure", ERROR_MESSAGE);
- logger.error("failed to save workflow as component", e);
- }
- }
-
- @Override
- public void notify(Observable<FileManagerEvent> sender,
- FileManagerEvent message) throws Exception {
- setEnabled(!utils.currentDataflowIsComponent());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java
deleted file mode 100644
index 8dac7ba..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.views.graph.GraphViewComponent;
-
-/**
- * @author alanrw
- */
-public class ComponentWorkflowCreatorMenuAction extends AbstractComponentMenuAction {
- private static final URI COMPONENT_WORKFLOW_CREATE_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentCreate");
-
- private ComponentCreatorSupport support;
- private FileManager fm;
- private GraphViewComponent graphView;
- private ComponentServiceIcon icon;
- private Utils utils;
-
- public ComponentWorkflowCreatorMenuAction() {
- super(600, COMPONENT_WORKFLOW_CREATE_URI);
- }
-
- public void setSupport(ComponentCreatorSupport support) {
- this.support = support;
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setGraphView(GraphViewComponent graphView) {
- this.graphView = graphView;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setUtils(Utils utils) {
- this.utils = utils;
- }
-
- @Override
- protected Action createAction() {
- return new ComponentWorkflowCreatorAction(support, fm, graphView, icon, utils);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/FileOpenFromComponentMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/FileOpenFromComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/FileOpenFromComponentMenuAction.java
deleted file mode 100644
index 0d79699..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/FileOpenFromComponentMenuAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import java.net.URI;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.FileType;
-import net.sf.taverna.t2.workbench.views.graph.GraphViewComponent;
-
-/**
- * @author alanrw
- */
-public class FileOpenFromComponentMenuAction extends
- AbstractComponentMenuAction {
- private static final URI FILE_OPEN_FROM_COMPONENT_URI = URI
- .create("http://taverna.sf.net/2008/t2workbench/menu#componentOpen");
- private FileManager fm;
- private FileType ft;
- private ComponentPreference prefs;
- private GraphViewComponent graphView;
- private ComponentServiceIcon icon;
-
- public FileOpenFromComponentMenuAction() {
- super(700, FILE_OPEN_FROM_COMPONENT_URI);
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setFileType(FileType ft) {
- this.ft = ft;
- }
-
- public void setPreferences(ComponentPreference prefs) {
- this.prefs = prefs;
- }
-
- public void setGraphView(GraphViewComponent graphView) {
- this.graphView = graphView;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- @Override
- protected Action createAction() {
- return new OpenWorkflowFromComponentAction(fm, ft, prefs, graphView,
- icon);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/OpenWorkflowFromComponentAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/OpenWorkflowFromComponentAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/OpenWorkflowFromComponentAction.java
deleted file mode 100644
index 41ac068..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/menu/component/OpenWorkflowFromComponentAction.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.menu.component;
-
-import static javax.swing.JOptionPane.CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.QUESTION_MESSAGE;
-import static javax.swing.JOptionPane.YES_NO_OPTION;
-import static javax.swing.JOptionPane.showOptionDialog;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JOptionPane;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.ComponentAction;
-import net.sf.taverna.t2.component.ui.panel.ComponentChoiceMessage;
-import net.sf.taverna.t2.component.ui.panel.ComponentVersionChooserPanel;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.file.FileType;
-import net.sf.taverna.t2.workbench.file.exceptions.OpenException;
-import net.sf.taverna.t2.workbench.views.graph.GraphViewComponent;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * @author alanrw
- */
-public class OpenWorkflowFromComponentAction extends ComponentAction {
- private static final long serialVersionUID = 7382677337746318211L;
- private static final Logger logger = getLogger(OpenWorkflowFromComponentAction.class);
- private static final String ACTION_NAME = "Open component...";
- private static final String ACTION_DESCRIPTION = "Open the workflow that implements a component";
-
- private final FileManager fm;
- private final FileType ft;
- private final ComponentPreference prefs;
-
- public OpenWorkflowFromComponentAction(FileManager fm, FileType ft,
- ComponentPreference prefs, GraphViewComponent graphView,
- ComponentServiceIcon icon) {
- super(ACTION_NAME, graphView);
- this.fm = fm;
- this.ft = ft;
- this.prefs = prefs;
- setIcon(icon);
- putValue(SHORT_DESCRIPTION, ACTION_DESCRIPTION);
- }
-
- @Override
- public void actionPerformed(ActionEvent arg) {
- final ComponentVersionChooserPanel panel = new ComponentVersionChooserPanel(prefs);
-
- final JButton okay = new JButton("OK");
- okay.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- getOptionPane((JComponent) e.getSource()).setValue(OK_OPTION);
- doOpen(panel.getChosenRegistry(), panel.getChosenFamily(),
- panel.getChosenComponent(),
- panel.getChosenComponentVersion());
- }
- });
- okay.setEnabled(false);
- // Only enable the OK button of a component is not null
- panel.getComponentChooserPanel().addObserver(
- new Observer<ComponentChoiceMessage>() {
- @Override
- public void notify(
- Observable<ComponentChoiceMessage> sender,
- ComponentChoiceMessage message) throws Exception {
- okay.setEnabled(message.getChosenComponent() != null);
- }
- });
-
- final JButton cancel = new JButton("Cancel");
- cancel.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- getOptionPane((JComponent)e.getSource()).setValue(CANCEL_OPTION);
- }
- });
-
- showOptionDialog(graphView, panel, "Component version choice",
- YES_NO_OPTION, QUESTION_MESSAGE, null, new Object[] { okay,
- cancel }, okay);
- }
-
- protected JOptionPane getOptionPane(JComponent parent) {
- if (parent instanceof JOptionPane)
- return (JOptionPane) parent;
- return getOptionPane((JComponent) parent.getParent());
- }
-
- private void doOpen(Registry registry, Family family, Component component,
- Version version) {
- Version.ID ident = new Version.Identifier(
- registry.getRegistryBase(), family.getName(),
- component.getName(), version.getVersionNumber());
-
- try {
- WorkflowBundle d = fm.openDataflow(ft, ident);
- markGraphAsBelongingToComponent(d);
- } catch (OpenException e) {
- logger.error("Failed to open component definition", e);
- }
- }
-}