http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationDialog.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationDialog.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationDialog.java deleted file mode 100644 index c4c77b7..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationDialog.java +++ /dev/null @@ -1,474 +0,0 @@ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import static java.awt.BorderLayout.SOUTH; -import static java.awt.Cursor.DEFAULT_CURSOR; -import static java.awt.Cursor.WAIT_CURSOR; -import static java.awt.Cursor.getPredefinedCursor; -import static java.lang.Math.max; -import static javax.swing.JOptionPane.CANCEL_OPTION; -import static javax.swing.JOptionPane.NO_OPTION; -import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION; -import static javax.swing.JOptionPane.YES_NO_OPTION; -import static javax.swing.JOptionPane.YES_OPTION; -import static javax.swing.JOptionPane.showConfirmDialog; -import static net.sf.taverna.t2.workbench.MainWindow.getMainWindow; -import static net.sf.taverna.t2.workbench.helper.Helper.showHelp; -import static net.sf.taverna.t2.workbench.ui.actions.activity.ActivityConfigurationAction.clearDialog; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.border.EmptyBorder; - -import net.sf.taverna.t2.lang.observer.Observable; -import net.sf.taverna.t2.lang.observer.Observer; -import net.sf.taverna.t2.lang.ui.DeselectingButton; -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.edits.EditManager.DataFlowRedoEvent; -import net.sf.taverna.t2.workbench.edits.EditManager.DataFlowUndoEvent; -import net.sf.taverna.t2.workbench.edits.EditManager.EditManagerEvent; -import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog; -import net.sf.taverna.t2.workflow.edits.AddChildEdit; -import net.sf.taverna.t2.workflow.edits.AddProcessorInputPortEdit; -import net.sf.taverna.t2.workflow.edits.AddProcessorOutputPortEdit; -import net.sf.taverna.t2.workflow.edits.ChangeDepthEdit; -import net.sf.taverna.t2.workflow.edits.ChangeGranularDepthEdit; -import net.sf.taverna.t2.workflow.edits.ChangeJsonEdit; -import net.sf.taverna.t2.workflow.edits.RemoveChildEdit; -import net.sf.taverna.t2.workflow.edits.RemoveProcessorInputPortEdit; -import net.sf.taverna.t2.workflow.edits.RemoveProcessorOutputPortEdit; -import net.sf.taverna.t2.workflow.edits.RenameEdit; - -import org.apache.log4j.Logger; - -import uk.org.taverna.scufl2.api.activity.Activity; -import uk.org.taverna.scufl2.api.common.Scufl2Tools; -import uk.org.taverna.scufl2.api.configurations.Configuration; -import uk.org.taverna.scufl2.api.container.WorkflowBundle; -import uk.org.taverna.scufl2.api.core.Processor; -import uk.org.taverna.scufl2.api.core.Workflow; -import uk.org.taverna.scufl2.api.port.ActivityPort; -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; -import uk.org.taverna.scufl2.api.profiles.ProcessorBinding; -import uk.org.taverna.scufl2.api.profiles.ProcessorInputPortBinding; -import uk.org.taverna.scufl2.api.profiles.ProcessorOutputPortBinding; -import uk.org.taverna.scufl2.api.profiles.Profile; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -@SuppressWarnings("serial") -public class ActivityConfigurationDialog extends HelpEnabledDialog { - private enum PortType { - INPUT, OUTPUT - } - - protected static Logger logger = Logger.getLogger(ActivityConfigurationDialog.class); - private static final Scufl2Tools scufl2Tools = new Scufl2Tools(); - - private final EditManager editManager; - - private Activity activity; - private ActivityConfigurationPanel panel; - protected WorkflowBundle owningWorkflowBundle; - protected Processor owningProcessor; - private Observer<EditManagerEvent> observer; - Dimension minimalSize = null; - Dimension buttonPanelSize = null; - JPanel buttonPanel; - protected JButton applyButton; - - public ActivityConfigurationDialog(Activity a, ActivityConfigurationPanel p, - EditManager editManager) { - super(getMainWindow(), "Configuring " + a.getClass().getSimpleName(), - false, null); - this.activity = a; - this.panel = p; - this.editManager = editManager; - - owningWorkflowBundle = activity.getParent().getParent(); - owningProcessor = findProcessor(a); - - setTitle(getRelativeName(owningWorkflowBundle, activity)); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setLayout(new BorderLayout()); - - add(panel, BorderLayout.CENTER); - - buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - buttonPanel.setBorder(new EmptyBorder(5, 20, 5, 5)); - - JButton helpButton = new DeselectingButton("Help", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - showHelp(panel); - } - }); - buttonPanel.add(helpButton); - - applyButton = new DeselectingButton("Apply", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - /* - * For the moment it always does an apply as what should be - * happening is that the apply button only becomes available - * when the configuration has changed. However, many - * configuration panels are not set up to detected changes - */ - // if (panel.isConfigurationChanged()) { - if (checkPanelValues()) - applyConfiguration(); - // } else { - // logger.info("Ignoring apply"); - // } - } - }); - buttonPanel.add(applyButton); - - JButton closeButton = new DeselectingButton("Close", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - closeDialog(); - } - }); - buttonPanel.add(closeButton); - - add(buttonPanel, SOUTH); - - this.addWindowListener(new WindowAdapter() { - @Override - public void windowOpened(WindowEvent e) { - requestFocusInWindow(); - panel.whenOpened(); - } - - @Override - public void windowClosing(WindowEvent e) { - closeDialog(); - } - }); - pack(); - minimalSize = getSize(); - setLocationRelativeTo(null); - setResizable(true); - addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - int newWidth = max(getWidth(), minimalSize.width); - int newHeight = max(getHeight(), minimalSize.height); - setSize(new Dimension(newWidth, newHeight)); - } - }); - - observer = new Observer<EditManagerEvent>() { - @Override - public void notify(Observable<EditManagerEvent> sender, EditManagerEvent message) - throws Exception { - logger.info("sender is a " + sender.getClass().getCanonicalName()); - logger.info("message is a " + message.getClass().getCanonicalName()); - Edit<?> edit = message.getEdit(); - logger.info(edit.getClass().getCanonicalName()); - considerEdit(message, edit); - } - }; - editManager.addObserver(observer); - } - - private boolean checkPanelValues() { - boolean result = false; - try { - setCursor(getPredefinedCursor(WAIT_CURSOR)); - result = panel.checkValues(); - } finally { - setCursor(getPredefinedCursor(DEFAULT_CURSOR)); - } - return result; - } - - private void considerEdit(EditManagerEvent message, Edit<?> edit) { - // boolean result = false; - if (edit instanceof CompoundEdit) { - for (Edit<?> subEdit : ((CompoundEdit) edit).getChildEdits()) - considerEdit(message, subEdit); - return; - } - - Object subject = edit.getSubject(); - if (subject == owningProcessor) { - // panel.reevaluate(); - setTitle(getRelativeName(owningWorkflowBundle, activity)); - } else if (subject == owningWorkflowBundle) { - for (Workflow workflow : owningWorkflowBundle.getWorkflows()) - if (!workflow.getProcessors().contains(owningProcessor)) - clearDialog(activity); - } else if (subject == activity) { - if (message instanceof DataFlowUndoEvent) { - logger.info("undo of activity edit found"); - panel.refreshConfiguration(); - } else if (message instanceof DataFlowRedoEvent) { - logger.info("redo of activity edit found"); - panel.refreshConfiguration(); - } - } - } - - protected void configureActivity(ObjectNode json, List<ActivityPortConfiguration> inputPorts, - List<ActivityPortConfiguration> outputPorts) { - configureActivity(owningWorkflowBundle, activity, json, inputPorts, outputPorts); - } - - public void configureActivity(WorkflowBundle workflowBundle, Activity activity, - ObjectNode json, List<ActivityPortConfiguration> inputPorts, - List<ActivityPortConfiguration> outputPorts) { - try { - List<Edit<?>> editList = new ArrayList<Edit<?>>(); - Profile profile = activity.getParent(); - List<ProcessorBinding> processorBindings = scufl2Tools - .processorBindingsToActivity(activity); - Configuration configuration = scufl2Tools.configurationFor(activity, profile); - editList.add(new ChangeJsonEdit(configuration, json)); - - configurePorts(activity, editList, processorBindings, inputPorts, PortType.INPUT); - configurePorts(activity, editList, processorBindings, outputPorts, PortType.OUTPUT); - editManager.doDataflowEdit(workflowBundle, new CompoundEdit(editList)); - } catch (IllegalStateException | EditException e) { - logger.error(e); - } - } - - private void configurePorts(Activity activity, List<Edit<?>> editList, - List<ProcessorBinding> processorBindings, - List<ActivityPortConfiguration> portDefinitions, PortType portType) { - Set<ActivityPort> ports = new HashSet<>(); - for (ActivityPort activityPort : portType == PortType.INPUT ? activity - .getInputPorts() : activity.getOutputPorts()) - ports.add(activityPort); - for (ActivityPortConfiguration portDefinition : portDefinitions) { - String portName = portDefinition.getName(); - int portDepth = portDefinition.getDepth(); - int granularPortDepth = portDefinition.getGranularDepth(); - ActivityPort activityPort = portDefinition.getActivityPort(); - if (activityPort == null) { - // no activity port so add a new one - if (portType == PortType.INPUT) - createInputPort(activity, editList, processorBindings, portDefinition); - else - createOutputPort(activity, editList, processorBindings, portDefinition); - } else { - ports.remove(activityPort); - // check if port has changed - for (ProcessorBinding processorBinding : processorBindings) - if (portType == PortType.INPUT) - for (ProcessorInputPortBinding portBinding : processorBinding - .getInputPortBindings()) { - if (!portBinding.getBoundActivityPort().equals( - activityPort)) - continue; - InputProcessorPort processorPort = portBinding - .getBoundProcessorPort(); - if (!activityPort.getName().equals(portName)) - // port name changed - if (processorPort.getName().equals(activityPort.getName())) - // default mapping so change processor port - editList.add(new RenameEdit<>(processorPort, portName)); - if (!processorPort.getDepth().equals(portDepth)) - // port depth changed - editList.add(new ChangeDepthEdit<>( - processorPort, portDepth)); - } - else - for (ProcessorOutputPortBinding portBinding : processorBinding - .getOutputPortBindings()) { - if (!portBinding.getBoundActivityPort().equals( - activityPort)) - continue; - OutputProcessorPort processorPort = portBinding - .getBoundProcessorPort(); - if (!activityPort.getName().equals(portName)) - // port name changed - if (processorPort.getName().equals( - activityPort.getName())) - // default mapping so change processor port - editList.add(new RenameEdit<>( - processorPort, portName)); - if (!processorPort.getDepth().equals(portDepth)) - // port depth changed - editList.add(new ChangeDepthEdit<>( - processorPort, portDepth)); - if (!processorPort.getGranularDepth().equals( - granularPortDepth)) - // port granular depth changed - editList.add(new ChangeGranularDepthEdit<>( - processorPort, granularPortDepth)); - } - if (!activityPort.getName().equals(portName)) - // port name changed - editList.add(new RenameEdit<>(activityPort, portName)); - if (!activityPort.getDepth().equals(portDepth)) - // port depth changed - editList.add(new ChangeDepthEdit<>(activityPort, portDepth)); - if (activityPort instanceof OutputActivityPort) { - OutputActivityPort outputActivityPort = (OutputActivityPort) activityPort; - Integer granularDepth = outputActivityPort - .getGranularDepth(); - if (granularDepth == null - || !granularDepth.equals(granularPortDepth)) - // granular port depth changed - editList.add(new ChangeGranularDepthEdit<>( - outputActivityPort, granularPortDepth)); - } - } - } - - // remove any unconfigured ports - for (ActivityPort activityPort : ports) { - // remove processor ports and bindings - for (ProcessorBinding processorBinding : processorBindings) - if (portType.equals(PortType.INPUT)) - for (ProcessorInputPortBinding portBinding : processorBinding - .getInputPortBindings()) { - if (portBinding.getBoundActivityPort().equals(activityPort)) { - editList.add(new RemoveProcessorInputPortEdit(processorBinding - .getBoundProcessor(), portBinding.getBoundProcessorPort())); - editList.add(new RemoveChildEdit<>(processorBinding, - portBinding)); - } - } - else - for (ProcessorOutputPortBinding portBinding : processorBinding - .getOutputPortBindings()) - if (portBinding.getBoundActivityPort().equals(activityPort)) { - editList.add(new RemoveProcessorOutputPortEdit(processorBinding - .getBoundProcessor(), portBinding.getBoundProcessorPort())); - editList.add(new RemoveChildEdit<>(processorBinding, - portBinding)); - } - // remove activity port - editList.add(new RemoveChildEdit<Activity>(activity, activityPort)); - } - } - - private void createInputPort(Activity activity, List<Edit<?>> editList, - List<ProcessorBinding> processorBindings, - ActivityPortConfiguration portDefinition) { - InputActivityPort actPort = new InputActivityPort(null, - portDefinition.getName()); - actPort.setDepth(portDefinition.getDepth()); - // add port to activity - editList.add(new AddChildEdit<>(activity, actPort)); - for (ProcessorBinding processorBinding : processorBindings) { - Processor processor = processorBinding.getBoundProcessor(); - // add a new processor port - InputProcessorPort procPort = new InputProcessorPort(); - procPort.setName(portDefinition.getName()); - procPort.setDepth(portDefinition.getDepth()); - editList.add(new AddProcessorInputPortEdit(processor, procPort)); - // add a new port binding - ProcessorInputPortBinding binding = new ProcessorInputPortBinding(); - binding.setBoundProcessorPort(procPort); - binding.setBoundActivityPort(actPort); - editList.add(new AddChildEdit<>(processorBinding, binding)); - } - } - - private void createOutputPort(Activity activity, List<Edit<?>> editList, - List<ProcessorBinding> processorBindings, - ActivityPortConfiguration portDefinition) { - OutputActivityPort actPort = new OutputActivityPort(null, - portDefinition.getName()); - actPort.setDepth(portDefinition.getDepth()); - actPort.setGranularDepth(portDefinition.getGranularDepth()); - // add port to activity - editList.add(new AddChildEdit<Activity>(activity, actPort)); - for (ProcessorBinding processorBinding : processorBindings) { - Processor processor = processorBinding.getBoundProcessor(); - // add a new processor port - OutputProcessorPort procPort = new OutputProcessorPort(); - procPort.setName(portDefinition.getName()); - procPort.setDepth(portDefinition.getDepth()); - procPort.setGranularDepth(portDefinition.getGranularDepth()); - editList.add(new AddProcessorOutputPortEdit(processor, procPort)); - // add a new port binding - ProcessorOutputPortBinding binding = new ProcessorOutputPortBinding(); - binding.setBoundProcessorPort(procPort); - binding.setBoundActivityPort(actPort); - editList.add(new AddChildEdit<>(processorBinding, binding)); - } - } - - protected static Processor findProcessor(Activity activity) { - for (ProcessorBinding processorBinding : scufl2Tools - .processorBindingsToActivity(activity)) - return processorBinding.getBoundProcessor(); - return null; - } - - public static String getRelativeName(WorkflowBundle workflowBundle, Activity activity) { - StringBuilder relativeName = new StringBuilder(""); - if (workflowBundle != null) { - Workflow workflow = workflowBundle.getMainWorkflow(); - if (workflow != null) { - relativeName.append(workflow.getName()); - relativeName.append(":"); - } - } - Processor processor = findProcessor(activity); - if (processor != null) - relativeName.append(processor.getName()); - return relativeName.toString(); - } - - public boolean closeDialog() { - if (panel.isConfigurationChanged()) { - String relativeName = getRelativeName(owningWorkflowBundle, activity); - if (checkPanelValues()) { - int answer = showConfirmDialog(this, - "Do you want to save the configuration of " + relativeName + "?", - relativeName, YES_NO_CANCEL_OPTION); - if (answer == YES_OPTION) { - applyConfiguration(); - } else if (answer == CANCEL_OPTION) { - return false; - } - } else if (showConfirmDialog( - this, - "New configuration could not be saved. Do you still want to close?", - relativeName, YES_NO_OPTION) == NO_OPTION) - return false; - } - panel.whenClosed(); - clearDialog(activity); - return true; - } - - private void applyConfiguration() { - panel.noteConfiguration(); - configureActivity(panel.getJson(), panel.getInputPorts(), - panel.getOutputPorts()); - panel.refreshConfiguration(); - } - - @Override - public void dispose() { - super.dispose(); - editManager.removeObserver(observer); - } -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationPanel.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationPanel.java deleted file mode 100644 index cf7f42a..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityConfigurationPanel.java +++ /dev/null @@ -1,214 +0,0 @@ -/** - * - */ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JPanel; - -import org.apache.log4j.Logger; - -import uk.org.taverna.commons.services.ActivityTypeNotFoundException; -import uk.org.taverna.commons.services.InvalidConfigurationException; -import uk.org.taverna.commons.services.ServiceRegistry; -import uk.org.taverna.scufl2.api.activity.Activity; -import uk.org.taverna.scufl2.api.common.Scufl2Tools; -import uk.org.taverna.scufl2.api.configurations.Configuration; -import uk.org.taverna.scufl2.api.port.ActivityPort; -import uk.org.taverna.scufl2.api.port.InputActivityPort; -import uk.org.taverna.scufl2.api.port.OutputActivityPort; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * @author alanrw - */ -@SuppressWarnings("serial") -public abstract class ActivityConfigurationPanel extends JPanel { - private static final Logger logger = Logger.getLogger(ActivityConfigurationPanel.class); - private final static Scufl2Tools scufl2Tools = new Scufl2Tools(); - - // protected final URITools uriTools = new URITools(); - private final Activity activity; - private final Configuration configuration; - private final List<ActivityPortConfiguration> inputPorts; - private final List<ActivityPortConfiguration> outputPorts; - protected ObjectNode json; - - public ActivityConfigurationPanel(Activity activity) { - this(activity, scufl2Tools.configurationFor(activity, - activity.getParent())); - } - - public ActivityConfigurationPanel(Activity activity, - Configuration configuration) { - this.activity = activity; - this.configuration = configuration; - inputPorts = new ArrayList<>(); - outputPorts = new ArrayList<>(); - } - - /** - * Initializes the configuration panel. This method is also used to discard - * any changes and reset the panel to its initial state. Subclasses should - * implement this method to set up the panel and must call - * <tt>super.initialise()</tt> first. - */ - protected void initialise() { - json = configuration.getJson().deepCopy(); - inputPorts.clear(); - for (InputActivityPort activityPort : activity.getInputPorts()) - inputPorts.add(new ActivityPortConfiguration(activityPort)); - outputPorts.clear(); - for (OutputActivityPort activityPort : activity.getOutputPorts()) - outputPorts.add(new ActivityPortConfiguration(activityPort)); - } - - public abstract boolean checkValues(); - - public abstract void noteConfiguration(); - - public boolean isConfigurationChanged() { - noteConfiguration(); - if (portsChanged(inputPorts, activity.getInputPorts().size())) - return true; - if (portsChanged(outputPorts, activity.getOutputPorts().size())) - return true; - return !json.equals(configuration.getJson()); - } - - public Configuration getConfiguration() { - return configuration; - } - - public ObjectNode getJson() { - return json; - } - - protected void setJson(ObjectNode json) { - this.json = json; - } - - public void refreshConfiguration() { - initialise(); - } - - public void whenOpened() { - } - - public void whenClosed() { - } - - /** - * Convenience method for getting simple String property values. - * - * @param name - * the property name - * @return the property value - */ - protected String getProperty(String name) { - JsonNode jsonNode = json.get(name); - if (jsonNode == null) - return null; - return json.get(name).asText(); - } - - /** - * Convenience method for setting simple String property values. - * - * @param name - * the property name - * @param value - * the property value - */ - protected void setProperty(String name, String value) { - json.put(name, value); - } - - public List<ActivityPortConfiguration> getInputPorts() { - return inputPorts; - } - - public List<ActivityPortConfiguration> getOutputPorts() { - return outputPorts; - } - - protected void configureInputPorts(ServiceRegistry serviceRegistry) { - try { - Map<String, InputActivityPort> newInputPorts = new HashMap<>(); - for (InputActivityPort port : serviceRegistry - .getActivityInputPorts(getActivity().getType(), getJson())) - newInputPorts.put(port.getName(), port); - List<ActivityPortConfiguration> inputPorts = getInputPorts(); - for (ActivityPortConfiguration portConfig : new ArrayList<>( - inputPorts)) - if (newInputPorts.containsKey(portConfig.getName())) { - InputActivityPort port = newInputPorts.remove(portConfig - .getName()); - portConfig.setDepth(port.getDepth()); - } else - inputPorts.remove(portConfig); - for (InputActivityPort newPort : newInputPorts.values()) - inputPorts.add(new ActivityPortConfiguration(newPort.getName(), - newPort.getDepth())); - } catch (InvalidConfigurationException | ActivityTypeNotFoundException e) { - logger.warn("Error configuring input ports", e); - } - } - - protected void configureOutputPorts(ServiceRegistry serviceRegistry) { - try { - Map<String, OutputActivityPort> newOutputPorts = new HashMap<>(); - for (OutputActivityPort port : serviceRegistry - .getActivityOutputPorts(getActivity().getType(), getJson())) - newOutputPorts.put(port.getName(), port); - List<ActivityPortConfiguration> outputPorts = getOutputPorts(); - for (ActivityPortConfiguration portConfig : new ArrayList<>( - outputPorts)) - if (newOutputPorts.containsKey(portConfig.getName())) { - OutputActivityPort port = newOutputPorts.remove(portConfig - .getName()); - portConfig.setDepth(port.getDepth()); - portConfig.setGranularDepth(port.getGranularDepth()); - } else - outputPorts.remove(portConfig); - for (OutputActivityPort newPort : newOutputPorts.values()) - outputPorts.add(new ActivityPortConfiguration( - newPort.getName(), newPort.getDepth())); - } catch (InvalidConfigurationException | ActivityTypeNotFoundException e) { - logger.warn("Error configuring output ports", e); - } - } - - private boolean portsChanged(List<ActivityPortConfiguration> portDefinitions, int ports) { - int checkedPorts = 0; - for (ActivityPortConfiguration portDefinition : portDefinitions) { - String portName = portDefinition.getName(); - int portDepth = portDefinition.getDepth(); - ActivityPort activityPort = portDefinition.getActivityPort(); - if (activityPort == null) - // new port added - return true; - if (!activityPort.getName().equals(portName)) - // port name changed - return true; - if (!activityPort.getDepth().equals(portDepth)) - // port depth changed - return true; - checkedPorts++; - } - if (checkedPorts < ports) - // ports deleted - return true; - return false; - } - - public Activity getActivity() { - return activity; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityPortConfiguration.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityPortConfiguration.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityPortConfiguration.java deleted file mode 100644 index 6b23fd5..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ActivityPortConfiguration.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2013 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import uk.org.taverna.scufl2.api.port.ActivityPort; - -/** - * - * - * @author David Withers - */ -public class ActivityPortConfiguration { - - private ActivityPort activityPort; - - private String name; - - private int depth; - - private int granularDepth; - - public ActivityPortConfiguration(ActivityPort activityPort) { - this.activityPort = activityPort; - name = activityPort.getName(); - depth = activityPort.getDepth(); - } - - public ActivityPortConfiguration(String name, int depth) { - this(name, depth, depth); - } - - public ActivityPortConfiguration(String name, int depth, int granularDepth) { - this.name = name; - this.depth = depth; - this.granularDepth = granularDepth; - } - - public ActivityPort getActivityPort() { - return activityPort; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getDepth() { - return depth; - } - - public void setDepth(int depth) { - this.depth = depth; - } - - public int getGranularDepth() { - return granularDepth; - } - - public void setGranularDepth(int granularDepth) { - this.granularDepth = granularDepth; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactory.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactory.java deleted file mode 100644 index b5d29d7..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import java.util.List; - -import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView; - -/** - * Defines a factory class that when associated with a selected object creates a - * {@link ContextualView} for that selection. - * <p> - * This factory acts as an SPI to find {@link ContextualView}s for a given - * Activity and other workflow components. - * </p> - * - * @author Stuart Owen - * @author Ian Dunlop - * @author Stian Soiland-Reyes - * - * - * @param <SelectionType> - * - the selection type this factory is associated with - * - * @see ContextualView - * @see ContextualViewFactoryRegistry - */ -public interface ContextualViewFactory<SelectionType> { - /** - * @param selection - * - the object for which ContextualViews needs to be generated - * @return instance of {@link ContextualView} - */ - public List<ContextualView> getViews(SelectionType selection); - - /** - * Used by the SPI system to find the correct factory that can handle the - * given object type. - * - * @param selection - * @return true if this factory relates to the given selection type - * @see ContextualViewFactoryRegistry - */ - public boolean canHandle(Object selection); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactoryRegistry.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactoryRegistry.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactoryRegistry.java deleted file mode 100644 index 305f3c0..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ContextualViewFactoryRegistry.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2011 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import java.util.List; - -/** - * A registry for discovering ActivityViewFactories for a given object, - * like an {@link net.sf.taverna.t2.workflowmodel.processor.activity.Activity}. - * - * @author David Withers - */ -public interface ContextualViewFactoryRegistry { - /** - * Discover and return the ContextualViewFactory associated to the provided - * object. This is accomplished by returning the discovered - * {@link ContextualViewFactory#canHandle(Object)} that returns true for - * that Object. - * - * @param object - * @return - * @see ContextualViewFactory#canHandle(Object) - */ - public <T> List<ContextualViewFactory<? super T>> getViewFactoriesForObject(T object); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/DependencyConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/DependencyConfigurationPanel.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/DependencyConfigurationPanel.java deleted file mode 100644 index c28cb55..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/DependencyConfigurationPanel.java +++ /dev/null @@ -1,293 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2013 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import static java.awt.BorderLayout.CENTER; -import static java.awt.BorderLayout.NORTH; -import static java.awt.Color.RED; -import static java.awt.GridBagConstraints.FIRST_LINE_START; -import static java.awt.GridBagConstraints.HORIZONTAL; -import static java.awt.event.ItemEvent.DESELECTED; -import static java.awt.event.ItemEvent.SELECTED; -import static java.util.Arrays.asList; -import static javax.swing.Box.createRigidArea; -import static javax.swing.BoxLayout.PAGE_AXIS; -import static javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER; -import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.swing.BoxLayout; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.border.EmptyBorder; - -/** - * Component for configuring activities that require dependencies. - * - * @author David Withers - */ -@SuppressWarnings("serial") -public class DependencyConfigurationPanel extends JPanel { - private String classLoaderSharing; - private List<String> localDependencies; - private File libDir; - - public DependencyConfigurationPanel(String classLoaderSharing, - List<String> localDependencies, File libDir) { - this.classLoaderSharing = classLoaderSharing; - this.localDependencies = localDependencies; - this.libDir = libDir; - setLayout(new BoxLayout(this, PAGE_AXIS)); - - // Create panel with classloading options - JPanel classloadingPanel = new ClassloadingPanel(); - // Create panel for selecting jar files - JPanel jarFilesPanel = new JarFilesPanel(); - - add(classloadingPanel); - add(createRigidArea(new Dimension(0,10))); - add(jarFilesPanel); - add(createRigidArea(new Dimension(0,10))); - - } - - public String getClassLoaderSharing() { - return classLoaderSharing; - } - - public List<String> getLocalDependencies() { - return localDependencies; - } - - // Classloading option 'workflow' - private static final String WORKFLOW = "Shared for whole workflow"; - // Classloading option 'system' - private static final String SYSTEM = "System classloader"; - - // Panel containing classloading options - private class ClassloadingPanel extends JPanel { - // Combobox with classloading options - private JComboBox<String> jcbClassloadingOption; - // Classloading option descriptions - private HashMap<String, String> classloadingDescriptions; - // JLabel with classloading option description - private JLabel jlClassloadingDescription; - - /* - * Panel containing a list of possible classloading options which users - * can select from - */ - private ClassloadingPanel() { - super(new GridBagLayout()); - jcbClassloadingOption = new JComboBox<>(new String[] { WORKFLOW, - SYSTEM }); - // Set the current classlaoding option based on the configuration bean - if ("workflow".equals(classLoaderSharing)) { - jcbClassloadingOption.setSelectedItem(WORKFLOW); - } else if ("system".equals(classLoaderSharing)) { - jcbClassloadingOption.setSelectedItem(SYSTEM); - } - - jcbClassloadingOption.addActionListener(new ActionListener(){ - // Fires up when combobox selection changes - @Override - public void actionPerformed(ActionEvent e) { - Object selectedItem = jcbClassloadingOption.getSelectedItem(); - jlClassloadingDescription.setText(classloadingDescriptions - .get(selectedItem)); - if (selectedItem.equals(WORKFLOW)) - classLoaderSharing = "workflow"; - else if (selectedItem.equals(SYSTEM)) - classLoaderSharing = "system"; - } - }); - //jcbClassloadingOption.setEnabled(false); - - classloadingDescriptions = new HashMap<>(); - classloadingDescriptions.put(WORKFLOW, "<html><small>" - + "Classes are shared across the whole workflow (with any service<br>" - + "also selecting this option), but are reinitialised for each workflow run.<br>" - + "This might be needed if a service passes objects to another, or <br>" - + "state is shared within static members of loaded classes." - + "</small></html>"); - classloadingDescriptions.put(SYSTEM, "<html><small><p>" - + "The (global) system classloader is used, any dependencies defined here are<br>" - + "made available globally on the first run. Note that if you are NOT using<br>" - + "the defaulf Taverna BootstrapClassLoader, any settings here will be disregarded." - + "</p><p>" - + "This is mainly useful if you are using JNI-based libraries. Note that <br>" - + "for JNI you also have to specify <code>-Djava.library.path</code> and <br>" - + "probably your operating system's dynamic library search path<br>" - + "<code>LD_LIBRARY_PATH</code> / <code>DYLD_LIBRARY_PATH</code> / <code>PATH</code> </p>" - + "</small></html>"); - - /* - * Set the current classlaoding description based on the item - * selected in the combobox. - */ - jlClassloadingDescription = new JLabel(classloadingDescriptions - .get(jcbClassloadingOption.getSelectedItem())); - - // Add components to the ClassloadingPanel - GridBagConstraints c = new GridBagConstraints(); - c.anchor = FIRST_LINE_START; - c.fill = HORIZONTAL; - c.gridx = 0; - c.insets = new Insets(10,0,0,0); - add(new JLabel("Classloader persistence"), c); - c.insets = new Insets(0,0,0,0); - add(jcbClassloadingOption, c); - c.insets = new Insets(0,30,0,0); - add(jlClassloadingDescription, c); - } - } - - // Panel for users to add local JAR dependencies (contains a list of jar files which users can select from) - private class JarFilesPanel extends JPanel { - private JLabel warning = new JLabel( - "<html>" - + "<center<font color='red'>" - + "Warning: Depending on local libraries makes this workflow<br>" - + "difficult or impossible to run for other users. Try depending<br>" - + "on artifacts from a public repository if possible.</font></center>" - + "</html>"); - - private JarFilesPanel() { - super(); - setMinimumSize(new Dimension(400, 150)); - setLayout(new BorderLayout()); - setBorder(new EmptyBorder(0,10,0,10)); - - JPanel labelPanel = new JPanel(); - labelPanel.setLayout(new BoxLayout(labelPanel, PAGE_AXIS)); - JLabel label = new JLabel("Local JAR files"); - JLabel libLabel = new JLabel("<html><small>" + libDir.getAbsolutePath() - + "</small></html>"); - labelPanel.add(label); - labelPanel.add(libLabel); - - add(labelPanel, NORTH); - add(new JScrollPane(jarFiles(), VERTICAL_SCROLLBAR_AS_NEEDED, - HORIZONTAL_SCROLLBAR_NEVER), CENTER); - - warning.setVisible(false); - /* - * We'll skip the warning until we actually have support for - * artifacts - */ - //add(warning); - updateWarning(); - } - - private void updateWarning() { - // Show warning if there is any local dependencies - warning.setVisible(!localDependencies.isEmpty()); - } - - public JPanel jarFiles() { - JPanel panel = new JPanel(); - panel.setLayout(new BoxLayout(panel, PAGE_AXIS)); - - // List of all jar files in the lib directory - List<String> jarFiles = asList(libDir - .list(new FileExtFilter(".jar"))); - /* - * We also add the list of jars that may have been configured - * sometime before but are now not present in the lib directory for - * some reason - */ - Set<String> missingLocalDeps = new HashSet<>(localDependencies); - missingLocalDeps.removeAll(jarFiles); - /* - * jarFiles and missingLocalDeps now contain two sets of files that - * do not intersect - */ - List<String> jarFilesList = new ArrayList<>(); - // Put them all together - jarFilesList.addAll(jarFiles); - jarFilesList.addAll(missingLocalDeps); - Collections.sort(jarFilesList); - - if (jarFilesList.isEmpty()) { - panel.add(new JLabel("<html><small>To depend on a JAR file, " - + "copy it to the above-mentioned folder.</small></html>")); - return panel; - } - - for (String jarFile : jarFilesList) { - JCheckBox checkBox = new JCheckBox(jarFile); - // Has it already been selected in some previous configuring? - checkBox.setSelected(localDependencies.contains(jarFile)); - checkBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - JCheckBox box = (JCheckBox) e.getSource(); - if (e.getStateChange() == SELECTED) - localDependencies.add(box.getText()); - else if (e.getStateChange() == DESELECTED) - localDependencies.remove(box.getText()); - updateWarning(); - } - }); - panel.add(checkBox); - // The jar may not be in the lib directory, so warn the user - if (!new File(libDir, jarFile).exists()) { - checkBox.setForeground(RED); - checkBox.setText(checkBox.getText() + " (missing file!)"); - } - } - return panel; - } - } - - public static class FileExtFilter implements FilenameFilter { - final String ext; - - public FileExtFilter(String ext) { - this.ext = ext; - } - - @Override - public boolean accept(File dir, String name) { - return name.endsWith(ext); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListConfigurationComponent.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListConfigurationComponent.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListConfigurationComponent.java deleted file mode 100644 index c0e3aab..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListConfigurationComponent.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import static java.awt.BorderLayout.CENTER; -import static java.awt.BorderLayout.EAST; -import static java.awt.BorderLayout.SOUTH; -import static java.awt.FlowLayout.RIGHT; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.util.List; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -/** - * @author David Withers - */ -@SuppressWarnings("serial") -public abstract class ListConfigurationComponent<T> extends JPanel { - private static final String REMOVE = "Remove"; - private static final String ADD = "Add"; - - private String name; - private List<T> items; - private JPanel listPanel; - - public ListConfigurationComponent(String name, List<T> items) { - this.name = name; - setLayout(new BorderLayout()); - - listPanel = new JPanel(new ListLayout()); - JPanel buttonPanel = new JPanel(new FlowLayout(RIGHT)); - buttonPanel.add(new JButton(createAddAction())); - - add(new JScrollPane(listPanel), CENTER); - add(buttonPanel, SOUTH); - - setItems(items); - } - - protected void setItems(List<T> items) { - this.items = items; - listPanel.removeAll(); - for (T item : items) - addItemComponent(item); - } - - protected void addItem(T item) { - items.add(item); - addItemComponent(item); - } - - protected void addItemComponent(T item) { - JComponent itemPanel = new JPanel(new BorderLayout()); - itemPanel.add(createItemComponent(item), CENTER); - itemPanel.add(new JButton(createRemoveAction(item)), EAST); - listPanel.add(itemPanel); - listPanel.revalidate(); - listPanel.repaint(); - } - - protected void removeItem(T item) { - int index = items.indexOf(item); - if (index >= 0) { - items.remove(index); - listPanel.remove(index); - listPanel.revalidate(); - listPanel.repaint(); - } - } - - private Action createRemoveAction(final T item) { - return new AbstractAction(REMOVE) { - @Override - public void actionPerformed(ActionEvent e) { - removeItem(item); - } - }; - } - - private Action createAddAction() { - return new AbstractAction(ADD + " " + name) { - @Override - public void actionPerformed(ActionEvent e) { - addItem(createDefaultItem()); - } - }; - } - - protected abstract Component createItemComponent(T item); - - protected abstract T createDefaultItem(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListLayout.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListLayout.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListLayout.java deleted file mode 100644 index 0ce35b5..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ListLayout.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.LayoutManager; - -/** - * Lays out components vertically using their preferred height and the available - * width. - * - * @author David Withers - */ -public class ListLayout implements LayoutManager { - private static final int DEFAULT_GAP = 5; - private final int gap; - - public ListLayout() { - this(DEFAULT_GAP); - } - - public ListLayout(int gap) { - this.gap = gap; - } - - @Override - public void removeLayoutComponent(Component comp) { - } - - @Override - public void addLayoutComponent(String name, Component comp) { - } - - @Override - public void layoutContainer(Container parent) { - Insets insets = parent.getInsets(); - int x = insets.left; - int y = insets.top; - int width = parent.getWidth() - insets.left - insets.right; - Component[] components = parent.getComponents(); - for (int i = 0; i < components.length; i++) { - components[i].setLocation(x, y); - components[i].setSize(width, - components[i].getPreferredSize().height); - y = y + gap + components[i].getHeight(); - } - } - - @Override - public Dimension minimumLayoutSize(Container parent) { - Insets insets = parent.getInsets(); - int minimumWidth = 0; - int minimumHeight = 0; - Component[] components = parent.getComponents(); - for (int i = 0; i < components.length; i++) { - Dimension size = components[i].getPreferredSize(); - if (size.width > minimumWidth) - minimumWidth = size.width; - minimumHeight = minimumHeight + size.height + gap; - } - minimumWidth = minimumWidth + insets.left + insets.right; - minimumHeight = minimumHeight + insets.top + insets.bottom; - - return new Dimension(minimumWidth, minimumHeight); - } - - @Override - public Dimension preferredLayoutSize(Container parent) { - return minimumLayoutSize(parent); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/MultiPageActivityConfigurationPanel.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/MultiPageActivityConfigurationPanel.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/MultiPageActivityConfigurationPanel.java deleted file mode 100644 index 19cd180..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/MultiPageActivityConfigurationPanel.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import static java.awt.BorderLayout.CENTER; - -import java.awt.BorderLayout; -import java.awt.Component; - -import javax.swing.JTabbedPane; - -import uk.org.taverna.scufl2.api.activity.Activity; - -/** - * Component for configuring activities that have multiple configuration pages. - * - * @author David Withers - */ -@SuppressWarnings("serial") -public abstract class MultiPageActivityConfigurationPanel extends - ActivityConfigurationPanel { - private JTabbedPane tabbedPane; - - /** - * Constructs a new <code>MultiPageActivityConfigurationPanel</code>. - * - * @param activity - */ - public MultiPageActivityConfigurationPanel(Activity activity) { - super(activity); - setLayout(new BorderLayout()); - tabbedPane = new JTabbedPane(); - add(tabbedPane, CENTER); - } - - public void addPage(String name, Component component) { - tabbedPane.addTab(name, component); - } - - public void removePage(String name) { - tabbedPane.removeTabAt(tabbedPane.indexOfTab(name)); - } - - public void removeAllPages() { - tabbedPane.removeAll(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ScriptConfigurationComponent.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ScriptConfigurationComponent.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ScriptConfigurationComponent.java deleted file mode 100644 index 8cb7652..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ScriptConfigurationComponent.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import static java.awt.BorderLayout.CENTER; -import static java.awt.BorderLayout.SOUTH; -import static java.awt.Color.WHITE; -import static java.awt.Font.PLAIN; -import static javax.swing.JOptionPane.INFORMATION_MESSAGE; -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 net.sf.taverna.t2.lang.ui.FileTools.readStringFromFile; -import static net.sf.taverna.t2.lang.ui.FileTools.saveStringToFile; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Set; - -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.JTextPane; - -import net.sf.taverna.t2.lang.ui.KeywordDocument; -import net.sf.taverna.t2.lang.ui.LineEnabledTextPanel; -import net.sf.taverna.t2.lang.ui.LinePainter; -import net.sf.taverna.t2.lang.ui.NoWrapEditorKit; - -/** - * Component for configuring activities that have scripts. - * - * @author David Withers - */ -@SuppressWarnings("serial") -public class ScriptConfigurationComponent extends JPanel { - private JTextPane scriptTextArea; - - public ScriptConfigurationComponent(String script, Set<String> keywords, - Set<String> ports, final String scriptType, - final String fileExtension) { - this(script, keywords, ports, scriptType, fileExtension, ""); - } - - public ScriptConfigurationComponent(String script, Set<String> keywords, - Set<String> ports, final String scriptType, - final String fileExtension, final String resetScript) { - super(new BorderLayout()); - scriptTextArea = new JTextPane(); - new LinePainter(scriptTextArea, WHITE); - - final KeywordDocument doc = new KeywordDocument(keywords, ports); - - // NOTE: Due to T2-1145 - always set editor kit BEFORE setDocument - scriptTextArea.setEditorKit(new NoWrapEditorKit()); - scriptTextArea.setFont(new Font("Monospaced", PLAIN, 14)); - scriptTextArea.setDocument(doc); - scriptTextArea.setText(script); - scriptTextArea.setCaretPosition(0); - scriptTextArea.setPreferredSize(new Dimension(200, 100)); - - add(new LineEnabledTextPanel(scriptTextArea), CENTER); - - final JButton checkScriptButton = new JButton("Check script"); - checkScriptButton.setToolTipText("Check the " + scriptType + " script"); - checkScriptButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent ex) { - showMessageDialog(ScriptConfigurationComponent.this, scriptType - + " script check not implemented", scriptType - + " script check", INFORMATION_MESSAGE); - } - }); - - JButton loadScriptButton = new JButton("Load script"); - loadScriptButton.setToolTipText("Load a " + scriptType - + " script from a file"); - loadScriptButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String newScript = readStringFromFile( - ScriptConfigurationComponent.this, "Load " + scriptType - + " script", fileExtension); - if (newScript != null) { - scriptTextArea.setText(newScript); - scriptTextArea.setCaretPosition(0); - } - } - }); - - JButton saveRScriptButton = new JButton("Save script"); - saveRScriptButton.setToolTipText("Save the " + scriptType - + " script to a file"); - saveRScriptButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - saveStringToFile(ScriptConfigurationComponent.this, "Save " - + scriptType + " script", fileExtension, - scriptTextArea.getText()); - } - }); - - JButton clearScriptButton = new JButton("Clear script"); - clearScriptButton.setToolTipText("Clear current script from the edit area"); - clearScriptButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (showConfirmDialog(ScriptConfigurationComponent.this, - "Do you really want to clear the script?", - "Clearing the script", YES_NO_OPTION) == YES_OPTION) - scriptTextArea.setText(resetScript); - } - }); - - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(new FlowLayout()); - buttonPanel.add(checkScriptButton); - buttonPanel.add(loadScriptButton); - buttonPanel.add(saveRScriptButton); - buttonPanel.add(clearScriptButton); - - add(buttonPanel, SOUTH); - } - - public String getScript() { - return scriptTextArea.getText(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextField.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextField.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextField.java deleted file mode 100644 index cf1ff96..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextField.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import javax.swing.JTextField; - -/** - * Adds a "<tt>valid</tt>" property to a JTextField. - * - * @author David Withers - */ -@SuppressWarnings("serial") -public class ValidatingTextField extends JTextField { - private boolean valid = true; - - public ValidatingTextField() { - } - - public ValidatingTextField(String text) { - super(text); - } - - @Override - public boolean isValid() { - return valid; - } - - public void setValid(boolean valid) { - if (this.valid != valid) { - boolean old = this.valid; - this.valid = valid; - firePropertyChange("valid", old, valid); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextGroup.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextGroup.java b/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextGroup.java deleted file mode 100644 index 7597f7c..0000000 --- a/taverna-workbench-contextual-views-api/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/ValidatingTextGroup.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2012 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 - ******************************************************************************/ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -/** - * - * - * @author David Withers - */ -public class ValidatingTextGroup { - private Map<ValidatingTextField, DocumentListener> textComponents; - - public ValidatingTextGroup() { - textComponents = new HashMap<>(); - } - - public void addValidTextComponent(ValidatingTextField textComponent) { - setUniqueText(textComponent); - DocumentListener documentListener = new ValidatorDocumentListener(); - textComponent.getDocument().addDocumentListener(documentListener); - textComponents.put(textComponent, documentListener); - } - - public void addTextComponent(ValidatingTextField textComponent) { - DocumentListener documentListener = new ValidatorDocumentListener(); - textComponent.getDocument().addDocumentListener(documentListener); - textComponents.put(textComponent, documentListener); - validate(); - } - - public void removeTextComponent(ValidatingTextField textComponent) { - textComponent.getDocument().removeDocumentListener( - textComponents.remove(textComponent)); - validate(); - } - - private void setUniqueText(ValidatingTextField textComponent) { - String text = textComponent.getText(); - if (textExists(text)) { - // Remove any existing number suffix - String nameTemplate = text.replaceAll("_\\d+$", "_"); - long i = 1; - do { - text = nameTemplate + i++; - } while (textExists(text)); - - textComponent.setText(text); - } - } - - private void validate() { - Map<String, ValidatingTextField> textValues = new HashMap<>(); - Set<ValidatingTextField> maybeValid = new HashSet<>(); - for (ValidatingTextField textComponent : textComponents.keySet()) { - ValidatingTextField duplicate = textValues.get(textComponent - .getText()); - if (duplicate != null) { - duplicate.setValid(false); - maybeValid.remove(duplicate); - textComponent.setValid(false); - } else { - textValues.put(textComponent.getText(), textComponent); - maybeValid.add(textComponent); - } - } - for (ValidatingTextField textComponent : maybeValid) - textComponent.setValid(true); - } - - private boolean textExists(String text) { - for (ValidatingTextField currentTextComponent : textComponents.keySet()) - if (text.equals(currentTextComponent.getText())) - return true; - return false; - } - - class ValidatorDocumentListener implements DocumentListener { - @Override - public void insertUpdate(DocumentEvent e) { - validate(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - validate(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - validate(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI b/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI deleted file mode 100644 index 312f95b..0000000 --- a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentFactorySPI +++ /dev/null @@ -1,2 +0,0 @@ -#net.sf.taverna.t2.workbench.ui.actions.activity.draggable.ActivityDraggerPaletteComponentFactory -#net.sf.taverna.t2.workbench.ui.views.contextualviews.DragActivitiesToHereComponentFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI b/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI deleted file mode 100644 index 1448a49..0000000 --- a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.zaria.UIComponentSPI +++ /dev/null @@ -1,3 +0,0 @@ -#net.sf.taverna.t2.workbench.ui.actions.activity.draggable.ActivityDraggerPaletteComponent -#net.sf.taverna.t2.workbench.ui.views.contextualviews.DragActivitiesToHereComponent -net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualViewComponent http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context-osgi.xml b/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context-osgi.xml deleted file mode 100644 index ab22b97..0000000 --- a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context-osgi.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?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"> - -</beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context.xml b/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context.xml deleted file mode 100644 index d662d87..0000000 --- a/taverna-workbench-contextual-views-api/src/main/resources/META-INF/spring/contextual-views-api-context.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?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"> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-impl/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-impl/pom.xml b/taverna-workbench-contextual-views-impl/pom.xml deleted file mode 100644 index 1cafa80..0000000 --- a/taverna-workbench-contextual-views-impl/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>net.sf.taverna.t2</groupId> - <artifactId>ui-impl</artifactId> - <version>2.0-SNAPSHOT</version> - </parent> - <groupId>net.sf.taverna.t2.ui-impl</groupId> - <artifactId>contextual-views-impl</artifactId> - <packaging>bundle</packaging> - <name>Contextual Views Implementation</name> - <description>Contextual views for the activities</description> - <dependencies> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>contextual-views-api</artifactId> - <version>${t2.ui.api.version}</version> - </dependency> - <dependency> - <groupId>net.sf.taverna.t2.ui-api</groupId> - <artifactId>selection-api</artifactId> - <version>${t2.ui.api.version}</version> - </dependency> - <dependency> - <groupId>uk.org.taverna.scufl2</groupId> - <artifactId>scufl2-api</artifactId> - <version>${scufl2.version}</version> - </dependency> - - <dependency> - <groupId>javax.help</groupId> - <artifactId>javahelp</artifactId> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/dc466d6d/taverna-workbench-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java ---------------------------------------------------------------------- diff --git a/taverna-workbench-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java b/taverna-workbench-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java deleted file mode 100644 index 8bac354..0000000 --- a/taverna-workbench-contextual-views-impl/src/main/java/net/sf/taverna/t2/workbench/ui/views/contextualviews/activity/impl/ContextualViewFactoryRegistryImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ - -/** - * @author Alan R Williams - */ -package net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.impl; - -import java.util.ArrayList; -import java.util.List; - -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactoryRegistry; - -/** - * An SPI registry for discovering ActivityViewFactories for a given object, - * like an {@link net.sf.taverna.t2.workflowmodel.processor.activity.Activity}. - * <p> - * For {@link ContextualViewFactory factories} to be found, its full qualified - * name needs to be defined as a resource file - * <code>/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualViewFactory</code> - * - * @author Stuart Owen - * @author Ian Dunlop - * @author Stian Soiland-Reyes - * - * @see ContextualViewFactory - */ -public class ContextualViewFactoryRegistryImpl implements - ContextualViewFactoryRegistry { - private List<ContextualViewFactory<?>> contextualViewFactories; - - /** - * Discover and return the ContextualViewFactory associated to the provided - * object. This is accomplished by returning the discovered - * {@link ContextualViewFactory#canHandle(Object)} that returns true for - * that Object. - * - * @param object - * @return - * @see ContextualViewFactory#canHandle(Object) - */ - @Override - public List<ContextualViewFactory<?>> getViewFactoriesForObject( - Object object) { - List<ContextualViewFactory<?>> result = new ArrayList<>(); - for (ContextualViewFactory<?> factory : contextualViewFactories) - if (factory.canHandle(object)) - result.add(factory); - return result; - } - - public void setContextualViewFactories( - List<ContextualViewFactory<?>> contextualViewFactories) { - this.contextualViewFactories = contextualViewFactories; - } -}
