http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/actions/RenameProcessorAction.java ---------------------------------------------------------------------- diff --git a/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/actions/RenameProcessorAction.java b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/actions/RenameProcessorAction.java new file mode 100644 index 0000000..9807d85 --- /dev/null +++ b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/actions/RenameProcessorAction.java @@ -0,0 +1,96 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.design.actions; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.util.HashSet; +import java.util.Set; + +import org.apache.taverna.lang.ui.ValidatingUserInputDialog; +import org.apache.taverna.workbench.design.ui.ProcessorPanel; +import org.apache.taverna.workbench.edits.EditException; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.icons.WorkbenchIcons; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workflow.edits.RenameEdit; + +import org.apache.log4j.Logger; + +import org.apache.taverna.scufl2.api.core.Processor; +import org.apache.taverna.scufl2.api.core.Workflow; + +/** + * Action for renaming a processor. + * + * @author David Withers + */ +public class RenameProcessorAction extends DataflowEditAction { + + private static final long serialVersionUID = 1L; + + private static Logger logger = Logger + .getLogger(RenameProcessorAction.class); + + private Processor processor; + + public RenameProcessorAction(Workflow dataflow, Processor processor, + Component component, EditManager editManager, + SelectionManager selectionManager) { + super(dataflow, component, editManager, selectionManager); + this.processor = processor; + putValue(SMALL_ICON, WorkbenchIcons.renameIcon); + putValue(NAME, "Rename service..."); + } + + @Override + public void actionPerformed(ActionEvent e) { + Set<String> usedProcessors = new HashSet<>(); + for (Processor usedProcessor : dataflow.getProcessors()) + if (!usedProcessor.getName().equals(processor.getName())) + usedProcessors.add(usedProcessor.getName()); + + ProcessorPanel inputPanel = new ProcessorPanel(); + + ValidatingUserInputDialog vuid = new ValidatingUserInputDialog( + "Rename service", inputPanel); + vuid.addTextComponentValidation(inputPanel.getProcessorNameField(), + "Set the service name.", usedProcessors, "Duplicate service.", + "[\\p{L}\\p{Digit}_.]+", "Invalid service name."); + vuid.setSize(new Dimension(400, 200)); + + inputPanel.setProcessorName(processor.getName()); + + try { + if (vuid.show(component)) + changeProcessorName(inputPanel); + } catch (EditException e1) { + logger.debug("Rename service (processor) failed", e1); + } + } + + private void changeProcessorName(ProcessorPanel inputPanel) + throws EditException { + String processorName = inputPanel.getProcessorName(); + editManager.doDataflowEdit(dataflow.getParent(), new RenameEdit<>( + processor, processorName)); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowInputPortPanel.java ---------------------------------------------------------------------- diff --git a/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowInputPortPanel.java b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowInputPortPanel.java new file mode 100644 index 0000000..2c8f0c6 --- /dev/null +++ b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowInputPortPanel.java @@ -0,0 +1,202 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.design.ui; + +import static java.awt.GridBagConstraints.HORIZONTAL; +import static java.awt.GridBagConstraints.NONE; +import static java.awt.GridBagConstraints.NORTHWEST; +import static java.awt.GridBagConstraints.WEST; +import static java.awt.event.ItemEvent.SELECTED; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSpinner; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; +import javax.swing.border.EmptyBorder; + +/** + * UI for creating/editing dataflow input ports. + * + * @author David Withers + */ +public class DataflowInputPortPanel extends JPanel { + private static final long serialVersionUID = 2650486705615513458L; + + private JTextField portNameField; + private JRadioButton singleValueButton; + private JRadioButton listValueButton; + private JSpinner listDepthSpinner; + + public DataflowInputPortPanel() { + super(new GridBagLayout()); + + portNameField = new JTextField(); + singleValueButton = new JRadioButton("Single value"); + listValueButton = new JRadioButton("List of depth "); + listDepthSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 100, 1)); + + setBorder(new EmptyBorder(10, 10, 10, 10)); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = WEST; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.ipadx = 10; + add(new JLabel("Name:"), constraints); + + constraints.gridx = 1; + constraints.gridwidth = 2; + constraints.ipadx = 0; + constraints.weightx = 1d; + constraints.fill = HORIZONTAL; + add(portNameField, constraints); + + constraints.gridx = 0; + constraints.gridy = 1; + constraints.gridwidth = 1; + constraints.weightx = 0d; + constraints.fill = NONE; + constraints.ipadx = 10; + constraints.insets = new Insets(10, 0, 0, 0); + add(new JLabel("Type:"), constraints); + + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(singleValueButton); + buttonGroup.add(listValueButton); + + final JLabel helpLabel = new JLabel( + "Depth 1 is a list, 2 is a list of lists, etc."); + helpLabel.setFont(helpLabel.getFont().deriveFont(11f)); + + singleValueButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + boolean selected = (e.getStateChange() == SELECTED); + listDepthSpinner.setEnabled(!selected); + helpLabel.setEnabled(!selected); + } + }); + + constraints.gridx = 1; + constraints.gridwidth = 2; + constraints.ipadx = 0; + add(singleValueButton, constraints); + constraints.gridy = 2; + constraints.gridwidth = 1; + constraints.insets = new Insets(0, 0, 0, 0); + add(listValueButton, constraints); + constraints.gridx = 2; + add(listDepthSpinner, constraints); + constraints.gridx = 1; + constraints.gridy = 3; + constraints.gridwidth = 2; + constraints.weighty = 1d; + constraints.anchor = NORTHWEST; + constraints.insets = new Insets(0, 20, 0, 0); + add(helpLabel, constraints); + } + + /** + * Returns the portNameField. + * + * @return the portNameField + */ + public JTextField getPortNameField() { + return portNameField; + } + + /** + * Returns the singleValueButton. + * + * @return the singleValueButton + */ + public JRadioButton getSingleValueButton() { + return singleValueButton; + } + + /** + * Returns the listValueButton. + * + * @return the listValueButton + */ + public JRadioButton getListValueButton() { + return listValueButton; + } + + /** + * Returns the port name. + * + * @return the port name + */ + public String getPortName() { + return portNameField.getText(); + } + + /** + * Sets the port name. + * + * @param name + * the name of the port + */ + public void setPortName(String name) { + portNameField.setText(name); + // Select the text + if (!name.isEmpty()) { + portNameField.setSelectionStart(0); + portNameField.setSelectionEnd(name.length()); + } + } + + /** + * Returns the port depth. + * + * @return the port depth + */ + public int getPortDepth() { + if (singleValueButton.isSelected()) + return 0; + return (Integer) listDepthSpinner.getValue(); + } + + /** + * Sets the port depth. + * + * @param depth + * the depth of the port + */ + public void setPortDepth(int depth) { + if (depth == 0) { + singleValueButton.setSelected(true); + } else { + listValueButton.setSelected(true); + listDepthSpinner.setValue(depth); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowOutputPortPanel.java ---------------------------------------------------------------------- diff --git a/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowOutputPortPanel.java b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowOutputPortPanel.java new file mode 100644 index 0000000..b06bc04 --- /dev/null +++ b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/DataflowOutputPortPanel.java @@ -0,0 +1,104 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.design.ui; + +import static java.awt.GridBagConstraints.HORIZONTAL; +import static java.awt.GridBagConstraints.VERTICAL; +import static java.awt.GridBagConstraints.WEST; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; + +/** + * UI for creating/editing dataflow output ports. + * + * @author David Withers + */ +public class DataflowOutputPortPanel extends JPanel { + private static final long serialVersionUID = -2542858679939965553L; + + private JTextField portNameField; + + public DataflowOutputPortPanel() { + super(new GridBagLayout()); + + portNameField = new JTextField(); + + setBorder(new EmptyBorder(10, 10, 10, 10)); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = WEST; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.ipadx = 10; + add(new JLabel("Name:"), constraints); + + constraints.gridx = 1; + constraints.gridwidth = 2; + constraints.ipadx = 0; + constraints.weightx = 1d; + constraints.fill = HORIZONTAL; + add(portNameField, constraints); + + constraints.gridx = 0; + constraints.gridy = 1; + constraints.fill = VERTICAL; + constraints.weighty = 1d; + add(new JPanel(), constraints); + } + + /** + * Returns the portNameField. + * + * @return the portNameField + */ + public JTextField getPortNameField() { + return portNameField; + } + + /** + * Returns the port name. + * + * @return the port name + */ + public String getPortName() { + return portNameField.getText(); + } + + /** + * Sets the port name. + * + * @param name the name of the port + */ + public void setPortName(String name) { + portNameField.setText(name); + // Select the text + if (!name.isEmpty()) { + portNameField.setSelectionStart(0); + portNameField.setSelectionEnd(name.length()); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/ProcessorPanel.java ---------------------------------------------------------------------- diff --git a/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/ProcessorPanel.java b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/ProcessorPanel.java new file mode 100644 index 0000000..a656ee5 --- /dev/null +++ b/taverna-design-ui/src/main/java/org/apache/taverna/workbench/design/ui/ProcessorPanel.java @@ -0,0 +1,100 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.workbench.design.ui; + +import static java.awt.GridBagConstraints.HORIZONTAL; +import static java.awt.GridBagConstraints.VERTICAL; +import static java.awt.GridBagConstraints.WEST; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.EmptyBorder; + +/** + * UI for editing processors. + * + * @author David Withers + */ +public class ProcessorPanel extends JPanel { + private static final long serialVersionUID = 260705376633425003L; + + private JTextField processorNameField; + + public ProcessorPanel() { + super(new GridBagLayout()); + + processorNameField = new JTextField(); + + setBorder(new EmptyBorder(10, 10, 10, 10)); + + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.anchor = WEST; + constraints.gridx = 0; + constraints.gridy = 0; + constraints.ipadx = 10; + add(new JLabel("Name:"), constraints); + + constraints.gridx = 1; + constraints.gridwidth = 2; + constraints.ipadx = 0; + constraints.weightx = 1d; + constraints.fill = HORIZONTAL; + add(processorNameField, constraints); + + constraints.gridx = 0; + constraints.gridy = 1; + constraints.fill = VERTICAL; + constraints.weighty = 1d; + add(new JPanel(), constraints); + } + + /** + * Returns the processorNameField. + * + * @return the processorNameField + */ + public JTextField getProcessorNameField() { + return processorNameField; + } + + /** + * Returns the processor name. + * + * @return the processor name + */ + public String getProcessorName() { + return processorNameField.getText(); + } + + /** + * Sets the processor name. + * + * @param name + * the name of the processor + */ + public void setProcessorName(String name) { + processorNameField.setText(name); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/actions/DisabledActivityConfigurationAction.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/actions/DisabledActivityConfigurationAction.java b/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/actions/DisabledActivityConfigurationAction.java deleted file mode 100644 index 54354eb..0000000 --- a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/actions/DisabledActivityConfigurationAction.java +++ /dev/null @@ -1,119 +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.activities.disabled.actions; - -import java.awt.Component; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JOptionPane; - -import org.apache.taverna.scufl2.api.activity.Activity; - -import net.sf.taverna.t2.activities.disabled.views.DisabledConfigView; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.report.ReportManager; -import net.sf.taverna.t2.workbench.ui.actions.activity.ActivityConfigurationAction; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog; - - -@SuppressWarnings("serial") -public class DisabledActivityConfigurationAction extends ActivityConfigurationAction { - - public static final String FIX_DISABLED = "Edit properties"; - private final EditManager editManager; - private final FileManager fileManager; - private final ReportManager reportManager; - - public DisabledActivityConfigurationAction(Activity activity, Frame owner, - EditManager editManager, FileManager fileManager, ReportManager reportManager, - ActivityIconManager activityIconManager, ServiceDescriptionRegistry serviceDescriptionRegistry) { - super(activity, activityIconManager, serviceDescriptionRegistry); - this.editManager = editManager; - this.fileManager = fileManager; - this.reportManager = reportManager; - putValue(NAME, FIX_DISABLED); - } - - public void actionPerformed(ActionEvent e) { - ActivityConfigurationDialog currentDialog = ActivityConfigurationAction - .getDialog(getActivity()); - if (currentDialog != null) { - currentDialog.toFront(); - return; - } - int answer = JOptionPane.showConfirmDialog((Component) e.getSource(), - "Directly editing properties can be dangerous. Are you sure you want to proceed?", - "Confirm editing", JOptionPane.YES_NO_OPTION); - if (answer != JOptionPane.YES_OPTION) { - return; - } - - final DisabledConfigView disabledConfigView = new DisabledConfigView(getActivity()); - final DisabledActivityConfigurationDialog dialog = new DisabledActivityConfigurationDialog( - getActivity(), disabledConfigView); - - ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager); - - } - - private class DisabledActivityConfigurationDialog extends ActivityConfigurationDialog { - public DisabledActivityConfigurationDialog(Activity a, DisabledConfigView p) { - super(a, p, editManager); - this.setModal(true); - super.applyButton.setEnabled(false); - super.applyButton.setVisible(false); - } - - public void configureActivity(Dataflow df, Activity a, Object bean) { - Edit<?> configureActivityEdit = editManager.getEdits() - .getConfigureActivityEdit(a, bean); - try { - List<Edit<?>> editList = new ArrayList<Edit<?>>(); - editList.add(configureActivityEdit); - Processor p = findProcessor(df, a); - if (p != null && p.getActivityList().size() == 1) { - editList.add(editManager.getEdits().getMapProcessorPortsForActivityEdit(p)); - } - Edit e = Tools.getEnableDisabledActivityEdit(super.owningProcessor, activity, - editManager.getEdits()); - if (e != null) { - editList.add(e); - editManager.doDataflowEdit(df, new CompoundEdit(editList)); - reportManager.updateObjectReport(super.owningDataflow, super.owningProcessor); - - } - } catch (IllegalStateException e) { - // TODO Auto-generated catch block - logger.error(e); - } catch (EditException e) { - logger.error(e); - } - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/menu/ConfigureDisabledMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/menu/ConfigureDisabledMenuAction.java b/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/menu/ConfigureDisabledMenuAction.java deleted file mode 100644 index 68a906e..0000000 --- a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/menu/ConfigureDisabledMenuAction.java +++ /dev/null @@ -1,52 +0,0 @@ -package net.sf.taverna.t2.activities.disabled.menu; - -import javax.swing.Action; - -import net.sf.taverna.t2.activities.disabled.actions.DisabledActivityConfigurationAction; -import net.sf.taverna.t2.activities.disabled.views.DisabledActivityViewFactory; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.report.ReportManager; - -public class ConfigureDisabledMenuAction extends AbstractConfigureActivityMenuAction { - - private EditManager editManager; - private FileManager fileManager; - private ReportManager reportManager; - private ActivityIconManager activityIconManager; - private ServiceDescriptionRegistry serviceDescriptionRegistry; - - public ConfigureDisabledMenuAction() { - super(DisabledActivityViewFactory.ACTIVITY_TYPE); - } - - @Override - protected Action createAction() { - return new DisabledActivityConfigurationAction(findActivity(), getParentFrame(), - editManager, fileManager, reportManager, activityIconManager, serviceDescriptionRegistry); - } - - public void setEditManager(EditManager editManager) { - this.editManager = editManager; - } - - public void setFileManager(FileManager fileManager) { - this.fileManager = fileManager; - } - - public void setReportManager(ReportManager reportManager) { - this.reportManager = reportManager; - } - - public void setActivityIconManager(ActivityIconManager activityIconManager) { - this.activityIconManager = activityIconManager; - } - - public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledActivityViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledActivityViewFactory.java b/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledActivityViewFactory.java deleted file mode 100644 index 81c02e7..0000000 --- a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledActivityViewFactory.java +++ /dev/null @@ -1,80 +0,0 @@ -package net.sf.taverna.t2.activities.disabled.views; - -import java.net.URI; -import java.util.Arrays; -import java.util.List; - -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.report.ReportManager; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory; -import org.apache.taverna.scufl2.api.activity.Activity; - -/** - * This class generates a contextual view for a DisabledActivity - * - * @author alanrw - * @author David Withers - */ -public class DisabledActivityViewFactory implements ContextualViewFactory<Activity> { - - public static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/disabled"); - - private EditManager editManager; - private FileManager fileManager; - private ReportManager reportManager; - private ActivityIconManager activityIconManager; - private ColourManager colourManager; - private ServiceDescriptionRegistry serviceDescriptionRegistry; - - /** - * The factory can handle a DisabledActivity - * - * @param object - * @return - */ - public boolean canHandle(Object object) { - return object instanceof Activity && ((Activity) object).getType().equals(ACTIVITY_TYPE); - } - - /** - * Return a contextual view that can display information about a DisabledActivity - * - * @param activity - * @return - */ - public List<ContextualView> getViews(Activity activity) { - return Arrays.asList(new ContextualView[] { new DisabledContextualView(activity, - editManager, fileManager, reportManager, colourManager, activityIconManager, - serviceDescriptionRegistry) }); - } - - public void setEditManager(EditManager editManager) { - this.editManager = editManager; - } - - public void setFileManager(FileManager fileManager) { - this.fileManager = fileManager; - } - - public void setReportManager(ReportManager reportManager) { - this.reportManager = reportManager; - } - - public void setActivityIconManager(ActivityIconManager activityIconManager) { - this.activityIconManager = activityIconManager; - } - - public void setColourManager(ColourManager colourManager) { - this.colourManager = colourManager; - } - - public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledConfigView.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledConfigView.java b/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledConfigView.java deleted file mode 100644 index 38e2b82..0000000 --- a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledConfigView.java +++ /dev/null @@ -1,142 +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.activities.disabled.views; - -import java.awt.BorderLayout; -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import javax.help.CSH; -import javax.swing.JOptionPane; -import javax.swing.JPanel; - -import org.apache.taverna.scufl2.api.activity.Activity; - -import net.sf.taverna.t2.lang.uibuilder.UIBuilder; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.xml.DomDriver; - -@SuppressWarnings("serial") -public class DisabledConfigView extends ActivityConfigurationPanel { - - private ActivityAndBeanWrapper configuration; - private List<String> fieldNames; - - private Object clonedConfig = null; - String origConfigXML = ""; - - public DisabledConfigView(Activity activity) { - super(activity); - setLayout(new BorderLayout()); - fieldNames = null; - initialise(); - } - - @Override - protected void initialise() { - CSH.setHelpIDString( - this, - "net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.DisabledConfigView"); - configuration = activity.getConfiguration(); - XStream xstream = new XStream(new DomDriver()); - Activity a = configuration.getActivity(); - xstream.setClassLoader(a.getClass().getClassLoader()); - Object origConfig = configuration.getBean(); - if (fieldNames == null) { - fieldNames = getFieldNames(origConfig); - } - origConfigXML = xstream.toXML(origConfig); - clonedConfig = xstream.fromXML(origConfigXML); - JPanel panel = UIBuilder.buildEditor(clonedConfig, (String[]) fieldNames.toArray(new String[0])); - this.add(panel, BorderLayout.CENTER); - this.revalidate(); - } - - @Override - public void refreshConfiguration() { - this.removeAll(); - initialise(); - } - - public boolean checkValues() { - boolean result = false; - result = activity.configurationWouldWork(clonedConfig); - if (!result) { - JOptionPane.showMessageDialog( - this, - "The new properties are invalid or not consistent with the workflow", - "Invalid properties", JOptionPane.WARNING_MESSAGE); - } - return result; - } - - public void noteConfiguration() { - if (isConfigurationChanged()) { - ActivityAndBeanWrapper newConfig = new ActivityAndBeanWrapper(); - newConfig.setActivity(configuration.getActivity()); - newConfig.setBean(clonedConfig); - configuration = newConfig; - - XStream xstream = new XStream(new DomDriver()); - xstream.setClassLoader(configuration.getActivity().getClass().getClassLoader()); - - origConfigXML = xstream.toXML(clonedConfig); - } - } - - @Override - public ActivityAndBeanWrapper getConfiguration() { - return configuration; - } - - public boolean isConfigurationChanged() { - XStream xstream = new XStream(new DomDriver()); - xstream.setClassLoader(configuration.getActivity().getClass().getClassLoader()); - return (!xstream.toXML(clonedConfig).equals(origConfigXML)); - } - - private List<String> getFieldNames(Object config) { - List<String> result = new ArrayList<String>(); - try { - BeanInfo beanInfo = Introspector.getBeanInfo(config.getClass()); - for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { - Method readMethod = pd.getReadMethod(); - if ((readMethod != null) && !(pd.getName().equals("class"))) { - try { - result.add(pd.getName()); - } catch (IllegalArgumentException ex) { - // ignore - } - } - } - } catch (IntrospectionException e) { - // ignore - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledContextualView.java b/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledContextualView.java deleted file mode 100644 index ca99430..0000000 --- a/taverna-disabled-activity-ui/src/main/java/net/sf/taverna/t2/activities/disabled/views/DisabledContextualView.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * - */ -package net.sf.taverna.t2.activities.disabled.views; - -import java.awt.Frame; -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.Action; - -import net.sf.taverna.t2.activities.disabled.actions.DisabledActivityConfigurationAction; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.report.ReportManager; -import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView; -import org.apache.taverna.scufl2.api.activity.Activity; -import org.apache.taverna.scufl2.api.port.InputActivityPort; -import org.apache.taverna.scufl2.api.port.OutputActivityPort; - -import com.fasterxml.jackson.databind.JsonNode; - -/** - * A DisabledContextualView displays information about a DisabledActivity - * - * @author alanrw - * @author David Withers - */ -@SuppressWarnings("serial") -public class DisabledContextualView extends HTMLBasedActivityContextualView { - - private List<String> fieldNames; - - private final EditManager editManager; - private final FileManager fileManager; - private final ReportManager reportManager; - private final ActivityIconManager activityIconManager; - private final ServiceDescriptionRegistry serviceDescriptionRegistry; - - public DisabledContextualView(Activity activity, EditManager editManager, - FileManager fileManager, ReportManager reportManager, ColourManager colourManager, - ActivityIconManager activityIconManager, ServiceDescriptionRegistry serviceDescriptionRegistry) { - super(activity, colourManager); - this.editManager = editManager; - this.fileManager = fileManager; - this.reportManager = reportManager; - this.activityIconManager = activityIconManager; - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - } - - /** - * The table for the DisabledActivity shows its ports and the information within the offline - * Activity's configuration. - * - * @return - */ - @Override - protected String getRawTableRowsHtml() { - StringBuilder html = new StringBuilder(); - html.append("<tr><th>Input Port Name</th><th>Depth</th></tr>"); - for (InputActivityPort inputActivityPort : getActivity().getInputPorts()) { - html.append("<tr><td>" + inputActivityPort.getName() + "</td><td>"); - html.append(inputActivityPort.getDepth() + "</td></tr>"); - } - html.append("<tr><th>Output Port Name</th><th>Depth</th></tr>"); - for (OutputActivityPort outputActivityPort : getActivity().getOutputPorts()) { - html.append("<tr><td>" + outputActivityPort.getName() + "</td><td>"); - html.append(outputActivityPort.getDepth() + "</td></tr>"); - } - - JsonNode config = getConfigBean().getJson(); - try { - html.append("<tr><th>Property Name</th><th>Property Value</th></tr>"); - BeanInfo beanInfo = Introspector.getBeanInfo(config.getClass()); - for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { - Method readMethod = pd.getReadMethod(); - if ((readMethod != null) && !(pd.getName().equals("class"))) { - try { - html.append("<tr><td>"); - html.append(pd.getName()); - html.append("</td><td>"); - html.append(readMethod.invoke(config)); - html.append("</td></tr>"); - if (fieldNames == null) { - fieldNames = new ArrayList<String>(); - } - fieldNames.add(pd.getName()); - } catch (IllegalAccessException ex) { - // ignore - } catch (IllegalArgumentException ex) { - // ignore - } catch (InvocationTargetException ex) { - // ignore - } - } - } - } catch (IntrospectionException e) { - // ignore - } - return html.toString(); - } - - @Override - public String getViewTitle() { - return "Unavailable service"; - } - - @Override - public int getPreferredPosition() { - return 100; - } - - @Override - public Action getConfigureAction(Frame owner) { - return new DisabledActivityConfigurationAction(getActivity(), owner, - editManager, fileManager, reportManager, activityIconManager, serviceDescriptionRegistry); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/actions/DisabledActivityConfigurationAction.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/actions/DisabledActivityConfigurationAction.java b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/actions/DisabledActivityConfigurationAction.java new file mode 100644 index 0000000..da38c6c --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/actions/DisabledActivityConfigurationAction.java @@ -0,0 +1,119 @@ +/******************************************************************************* + * 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 org.apache.taverna.activities.disabled.actions; + +import java.awt.Component; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.taverna.scufl2.api.activity.Activity; + +import org.apache.taverna.activities.disabled.views.DisabledConfigView; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.report.ReportManager; +import org.apache.taverna.workbench.ui.actions.activity.ActivityConfigurationAction; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog; + + +@SuppressWarnings("serial") +public class DisabledActivityConfigurationAction extends ActivityConfigurationAction { + + public static final String FIX_DISABLED = "Edit properties"; + private final EditManager editManager; + private final FileManager fileManager; + private final ReportManager reportManager; + + public DisabledActivityConfigurationAction(Activity activity, Frame owner, + EditManager editManager, FileManager fileManager, ReportManager reportManager, + ActivityIconManager activityIconManager, ServiceDescriptionRegistry serviceDescriptionRegistry) { + super(activity, activityIconManager, serviceDescriptionRegistry); + this.editManager = editManager; + this.fileManager = fileManager; + this.reportManager = reportManager; + putValue(NAME, FIX_DISABLED); + } + + public void actionPerformed(ActionEvent e) { + ActivityConfigurationDialog currentDialog = ActivityConfigurationAction + .getDialog(getActivity()); + if (currentDialog != null) { + currentDialog.toFront(); + return; + } + int answer = JOptionPane.showConfirmDialog((Component) e.getSource(), + "Directly editing properties can be dangerous. Are you sure you want to proceed?", + "Confirm editing", JOptionPane.YES_NO_OPTION); + if (answer != JOptionPane.YES_OPTION) { + return; + } + + final DisabledConfigView disabledConfigView = new DisabledConfigView(getActivity()); + final DisabledActivityConfigurationDialog dialog = new DisabledActivityConfigurationDialog( + getActivity(), disabledConfigView); + + ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager); + + } + + private class DisabledActivityConfigurationDialog extends ActivityConfigurationDialog { + public DisabledActivityConfigurationDialog(Activity a, DisabledConfigView p) { + super(a, p, editManager); + this.setModal(true); + super.applyButton.setEnabled(false); + super.applyButton.setVisible(false); + } + + public void configureActivity(Dataflow df, Activity a, Object bean) { + Edit<?> configureActivityEdit = editManager.getEdits() + .getConfigureActivityEdit(a, bean); + try { + List<Edit<?>> editList = new ArrayList<Edit<?>>(); + editList.add(configureActivityEdit); + Processor p = findProcessor(df, a); + if (p != null && p.getActivityList().size() == 1) { + editList.add(editManager.getEdits().getMapProcessorPortsForActivityEdit(p)); + } + Edit e = Tools.getEnableDisabledActivityEdit(super.owningProcessor, activity, + editManager.getEdits()); + if (e != null) { + editList.add(e); + editManager.doDataflowEdit(df, new CompoundEdit(editList)); + reportManager.updateObjectReport(super.owningDataflow, super.owningProcessor); + + } + } catch (IllegalStateException e) { + // TODO Auto-generated catch block + logger.error(e); + } catch (EditException e) { + logger.error(e); + } + } + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/menu/ConfigureDisabledMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/menu/ConfigureDisabledMenuAction.java b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/menu/ConfigureDisabledMenuAction.java new file mode 100644 index 0000000..b99d148 --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/menu/ConfigureDisabledMenuAction.java @@ -0,0 +1,52 @@ +package org.apache.taverna.activities.disabled.menu; + +import javax.swing.Action; + +import org.apache.taverna.activities.disabled.actions.DisabledActivityConfigurationAction; +import org.apache.taverna.activities.disabled.views.DisabledActivityViewFactory; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.activitytools.AbstractConfigureActivityMenuAction; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.report.ReportManager; + +public class ConfigureDisabledMenuAction extends AbstractConfigureActivityMenuAction { + + private EditManager editManager; + private FileManager fileManager; + private ReportManager reportManager; + private ActivityIconManager activityIconManager; + private ServiceDescriptionRegistry serviceDescriptionRegistry; + + public ConfigureDisabledMenuAction() { + super(DisabledActivityViewFactory.ACTIVITY_TYPE); + } + + @Override + protected Action createAction() { + return new DisabledActivityConfigurationAction(findActivity(), getParentFrame(), + editManager, fileManager, reportManager, activityIconManager, serviceDescriptionRegistry); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setFileManager(FileManager fileManager) { + this.fileManager = fileManager; + } + + public void setReportManager(ReportManager reportManager) { + this.reportManager = reportManager; + } + + public void setActivityIconManager(ActivityIconManager activityIconManager) { + this.activityIconManager = activityIconManager; + } + + public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledActivityViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledActivityViewFactory.java b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledActivityViewFactory.java new file mode 100644 index 0000000..02f875f --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledActivityViewFactory.java @@ -0,0 +1,80 @@ +package org.apache.taverna.activities.disabled.views; + +import java.net.URI; +import java.util.Arrays; +import java.util.List; + +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.report.ReportManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory; +import org.apache.taverna.scufl2.api.activity.Activity; + +/** + * This class generates a contextual view for a DisabledActivity + * + * @author alanrw + * @author David Withers + */ +public class DisabledActivityViewFactory implements ContextualViewFactory<Activity> { + + public static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/disabled"); + + private EditManager editManager; + private FileManager fileManager; + private ReportManager reportManager; + private ActivityIconManager activityIconManager; + private ColourManager colourManager; + private ServiceDescriptionRegistry serviceDescriptionRegistry; + + /** + * The factory can handle a DisabledActivity + * + * @param object + * @return + */ + public boolean canHandle(Object object) { + return object instanceof Activity && ((Activity) object).getType().equals(ACTIVITY_TYPE); + } + + /** + * Return a contextual view that can display information about a DisabledActivity + * + * @param activity + * @return + */ + public List<ContextualView> getViews(Activity activity) { + return Arrays.asList(new ContextualView[] { new DisabledContextualView(activity, + editManager, fileManager, reportManager, colourManager, activityIconManager, + serviceDescriptionRegistry) }); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setFileManager(FileManager fileManager) { + this.fileManager = fileManager; + } + + public void setReportManager(ReportManager reportManager) { + this.reportManager = reportManager; + } + + public void setActivityIconManager(ActivityIconManager activityIconManager) { + this.activityIconManager = activityIconManager; + } + + public void setColourManager(ColourManager colourManager) { + this.colourManager = colourManager; + } + + public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledConfigView.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledConfigView.java b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledConfigView.java new file mode 100644 index 0000000..b3ec316 --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledConfigView.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * 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 org.apache.taverna.activities.disabled.views; + +import java.awt.BorderLayout; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import javax.help.CSH; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import org.apache.taverna.scufl2.api.activity.Activity; + +import org.apache.taverna.lang.uibuilder.UIBuilder; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.DomDriver; + +@SuppressWarnings("serial") +public class DisabledConfigView extends ActivityConfigurationPanel { + + private ActivityAndBeanWrapper configuration; + private List<String> fieldNames; + + private Object clonedConfig = null; + String origConfigXML = ""; + + public DisabledConfigView(Activity activity) { + super(activity); + setLayout(new BorderLayout()); + fieldNames = null; + initialise(); + } + + @Override + protected void initialise() { + CSH.setHelpIDString( + this, + "net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.DisabledConfigView"); + configuration = activity.getConfiguration(); + XStream xstream = new XStream(new DomDriver()); + Activity a = configuration.getActivity(); + xstream.setClassLoader(a.getClass().getClassLoader()); + Object origConfig = configuration.getBean(); + if (fieldNames == null) { + fieldNames = getFieldNames(origConfig); + } + origConfigXML = xstream.toXML(origConfig); + clonedConfig = xstream.fromXML(origConfigXML); + JPanel panel = UIBuilder.buildEditor(clonedConfig, (String[]) fieldNames.toArray(new String[0])); + this.add(panel, BorderLayout.CENTER); + this.revalidate(); + } + + @Override + public void refreshConfiguration() { + this.removeAll(); + initialise(); + } + + public boolean checkValues() { + boolean result = false; + result = activity.configurationWouldWork(clonedConfig); + if (!result) { + JOptionPane.showMessageDialog( + this, + "The new properties are invalid or not consistent with the workflow", + "Invalid properties", JOptionPane.WARNING_MESSAGE); + } + return result; + } + + public void noteConfiguration() { + if (isConfigurationChanged()) { + ActivityAndBeanWrapper newConfig = new ActivityAndBeanWrapper(); + newConfig.setActivity(configuration.getActivity()); + newConfig.setBean(clonedConfig); + configuration = newConfig; + + XStream xstream = new XStream(new DomDriver()); + xstream.setClassLoader(configuration.getActivity().getClass().getClassLoader()); + + origConfigXML = xstream.toXML(clonedConfig); + } + } + + @Override + public ActivityAndBeanWrapper getConfiguration() { + return configuration; + } + + public boolean isConfigurationChanged() { + XStream xstream = new XStream(new DomDriver()); + xstream.setClassLoader(configuration.getActivity().getClass().getClassLoader()); + return (!xstream.toXML(clonedConfig).equals(origConfigXML)); + } + + private List<String> getFieldNames(Object config) { + List<String> result = new ArrayList<String>(); + try { + BeanInfo beanInfo = Introspector.getBeanInfo(config.getClass()); + for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { + Method readMethod = pd.getReadMethod(); + if ((readMethod != null) && !(pd.getName().equals("class"))) { + try { + result.add(pd.getName()); + } catch (IllegalArgumentException ex) { + // ignore + } + } + } + } catch (IntrospectionException e) { + // ignore + } + return result; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledContextualView.java b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledContextualView.java new file mode 100644 index 0000000..78d7767 --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/java/org/apache/taverna/activities/disabled/views/DisabledContextualView.java @@ -0,0 +1,128 @@ +/** + * + */ +package org.apache.taverna.activities.disabled.views; + +import java.awt.Frame; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.Action; + +import org.apache.taverna.activities.disabled.actions.DisabledActivityConfigurationAction; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.report.ReportManager; +import org.apache.taverna.workbench.ui.actions.activity.HTMLBasedActivityContextualView; +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.port.InputActivityPort; +import org.apache.taverna.scufl2.api.port.OutputActivityPort; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * A DisabledContextualView displays information about a DisabledActivity + * + * @author alanrw + * @author David Withers + */ +@SuppressWarnings("serial") +public class DisabledContextualView extends HTMLBasedActivityContextualView { + + private List<String> fieldNames; + + private final EditManager editManager; + private final FileManager fileManager; + private final ReportManager reportManager; + private final ActivityIconManager activityIconManager; + private final ServiceDescriptionRegistry serviceDescriptionRegistry; + + public DisabledContextualView(Activity activity, EditManager editManager, + FileManager fileManager, ReportManager reportManager, ColourManager colourManager, + ActivityIconManager activityIconManager, ServiceDescriptionRegistry serviceDescriptionRegistry) { + super(activity, colourManager); + this.editManager = editManager; + this.fileManager = fileManager; + this.reportManager = reportManager; + this.activityIconManager = activityIconManager; + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + } + + /** + * The table for the DisabledActivity shows its ports and the information within the offline + * Activity's configuration. + * + * @return + */ + @Override + protected String getRawTableRowsHtml() { + StringBuilder html = new StringBuilder(); + html.append("<tr><th>Input Port Name</th><th>Depth</th></tr>"); + for (InputActivityPort inputActivityPort : getActivity().getInputPorts()) { + html.append("<tr><td>" + inputActivityPort.getName() + "</td><td>"); + html.append(inputActivityPort.getDepth() + "</td></tr>"); + } + html.append("<tr><th>Output Port Name</th><th>Depth</th></tr>"); + for (OutputActivityPort outputActivityPort : getActivity().getOutputPorts()) { + html.append("<tr><td>" + outputActivityPort.getName() + "</td><td>"); + html.append(outputActivityPort.getDepth() + "</td></tr>"); + } + + JsonNode config = getConfigBean().getJson(); + try { + html.append("<tr><th>Property Name</th><th>Property Value</th></tr>"); + BeanInfo beanInfo = Introspector.getBeanInfo(config.getClass()); + for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) { + Method readMethod = pd.getReadMethod(); + if ((readMethod != null) && !(pd.getName().equals("class"))) { + try { + html.append("<tr><td>"); + html.append(pd.getName()); + html.append("</td><td>"); + html.append(readMethod.invoke(config)); + html.append("</td></tr>"); + if (fieldNames == null) { + fieldNames = new ArrayList<String>(); + } + fieldNames.add(pd.getName()); + } catch (IllegalAccessException ex) { + // ignore + } catch (IllegalArgumentException ex) { + // ignore + } catch (InvocationTargetException ex) { + // ignore + } + } + } + } catch (IntrospectionException e) { + // ignore + } + return html.toString(); + } + + @Override + public String getViewTitle() { + return "Unavailable service"; + } + + @Override + public int getPreferredPosition() { + return 100; + } + + @Override + public Action getConfigureAction(Frame owner) { + return new DisabledActivityConfigurationAction(getActivity(), owner, + editManager, fileManager, reportManager, activityIconManager, serviceDescriptionRegistry); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent deleted file mode 100644 index 022189a..0000000 --- a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.activities.disabled.menu.ConfigureDisabledMenuAction \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory deleted file mode 100644 index 80b0bf3..0000000 --- a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.activities.disabled.views.DisabledActivityViewFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent new file mode 100644 index 0000000..729941e --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent @@ -0,0 +1 @@ +org.apache.taverna.activities.disabled.menu.ConfigureDisabledMenuAction \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory new file mode 100644 index 0000000..87a3c78 --- /dev/null +++ b/taverna-disabled-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory @@ -0,0 +1 @@ +org.apache.taverna.activities.disabled.views.DisabledActivityViewFactory http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context-osgi.xml b/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context-osgi.xml index f938272..dcb97ea 100644 --- a/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context-osgi.xml +++ b/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context-osgi.xml @@ -8,13 +8,13 @@ <service ref="ConfigureDisabledMenuAction" auto-export="interfaces" /> - <service ref="DisabledActivityViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> + <service ref="DisabledActivityViewFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> - <reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" /> - <reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" /> - <reference id="reportManager" interface="net.sf.taverna.t2.workbench.report.ReportManager" /> - <reference id="activityIconManager" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconManager" /> - <reference id="colourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" /> - <reference id="serviceDescriptionRegistry" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry" /> + <reference id="editManager" interface="org.apache.taverna.workbench.edits.EditManager" /> + <reference id="fileManager" interface="org.apache.taverna.workbench.file.FileManager" /> + <reference id="reportManager" interface="org.apache.taverna.workbench.report.ReportManager" /> + <reference id="activityIconManager" interface="org.apache.taverna.workbench.activityicons.ActivityIconManager" /> + <reference id="colourManager" interface="org.apache.taverna.workbench.configuration.colour.ColourManager" /> + <reference id="serviceDescriptionRegistry" interface="org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry" /> </beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context.xml ---------------------------------------------------------------------- diff --git a/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context.xml b/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context.xml index fbc0aa0..555d2fe 100644 --- a/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context.xml +++ b/taverna-disabled-activity-ui/src/main/resources/META-INF/spring/disabled-activity-ui-context.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="ConfigureDisabledMenuAction" class="net.sf.taverna.t2.activities.disabled.menu.ConfigureDisabledMenuAction"> + <bean id="ConfigureDisabledMenuAction" class="org.apache.taverna.activities.disabled.menu.ConfigureDisabledMenuAction"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> <property name="reportManager" ref="reportManager" /> @@ -11,7 +11,7 @@ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" /> </bean> - <bean id="DisabledActivityViewFactory" class="net.sf.taverna.t2.activities.disabled.views.DisabledActivityViewFactory"> + <bean id="DisabledActivityViewFactory" class="org.apache.taverna.activities.disabled.views.DisabledActivityViewFactory"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> <property name="reportManager" ref="reportManager" /> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/CompoundEdit.java ---------------------------------------------------------------------- diff --git a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/CompoundEdit.java b/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/CompoundEdit.java deleted file mode 100644 index e753e1f..0000000 --- a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/CompoundEdit.java +++ /dev/null @@ -1,118 +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.edits; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.taverna.scufl2.api.common.WorkflowBean; - -/** - * Implementation of Edit which contains an ordered list of child edits. Child - * edits are applied collectively and in order, any failure in any child edit - * causes an undo of previously applied children and a propogation of the edit - * exception. - * - * @author Tom Oinn - */ -public class CompoundEdit implements Edit<WorkflowBean> { - private final transient List<Edit<?>> childEdits; - private transient boolean applied = false; - - /** - * Create a new compound edit with no existing Edit objects. - * - */ - public CompoundEdit() { - this.childEdits = new ArrayList<>(); - } - - /** - * Create a new compound edit with the specified edits as children. - */ - public CompoundEdit(List<Edit<?>> edits) { - this.childEdits = edits; - } - - /** - * Get the list of edits. - * @return a live-editable list. - */ - public List<Edit<?>> getChildEdits() { - return childEdits; - } - - /** - * Attempts to call the doEdit method of all child edits. If any of those - * children throws an EditException any successful edits are rolled back and - * the exception is rethrown as the cause of a new EditException from the - * CompoundEdit - */ - @Override - public synchronized WorkflowBean doEdit() throws EditException { - if (isApplied()) - throw new EditException("Cannot apply an edit more than once!"); - List<Edit<?>> doneEdits = new ArrayList<>(); - try { - for (Edit<?> edit : childEdits) { - edit.doEdit(); - /* - * Insert the done edit at position 0 in the list so we can - * iterate over the list in the normal order if we need to - * rollback, this ensures that the most recent edit is first. - */ - doneEdits.add(0, edit); - } - applied = true; - } catch (EditException ee) { - for (Edit<?> undoMe : doneEdits) - undoMe.undo(); - applied = false; - throw new EditException("Failed child of compound edit", ee); - } - return null; - } - - /** - * There is no explicit subject for a compound edit, so this method always - * returns null. - */ - @Override - public Object getSubject() { - return null; - } - - /** - * Rolls back all child edits in reverse order - */ - @Override - public synchronized void undo() { - for (int i = childEdits.size() - 1; i >= 0; i--) - // Undo child edits in reverse order - childEdits.get(i).undo(); - applied = false; - } - - @Override - public boolean isApplied() { - return applied; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/Edit.java ---------------------------------------------------------------------- diff --git a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/Edit.java b/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/Edit.java deleted file mode 100644 index 0e6a6d7..0000000 --- a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/Edit.java +++ /dev/null @@ -1,66 +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.edits; - -import org.apache.taverna.scufl2.api.common.WorkflowBean; - -/** - * The workflow object model exposed by this API is read only. Properties of the - * model can only be changed through implementations of this interface, this - * ensures a consistant approach to grouped edits (transactions) and undo / redo - * support within the UI. It also potentially allows for capture of editing - * provenance where a workflow is repurposed or created from an aggregate of - * several others. - * - * @author Tom Oinn - */ -public interface Edit<TargetType extends WorkflowBean> { - /** - * Perform the edit - * - * @throws EditException - * if the edit fails. If an edit throws EditException it should - * try to ensure the subject is unaltered. Where this is - * impossible consider breaking edits down into a compound edit. - */ - TargetType doEdit() throws EditException; - - /** - * Undo the edit, reverting the subject to the state it was in prior to the - * edit - */ - void undo(); - - /** - * Return the object to which this edit applies - * - * @return - */ - Object getSubject(); - - /** - * Has the edit been applied yet? - * - * @return true if and only if the edit has been successfully applied to the - * subject - */ - boolean isApplied(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditException.java ---------------------------------------------------------------------- diff --git a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditException.java b/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditException.java deleted file mode 100644 index 3c61d84..0000000 --- a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditException.java +++ /dev/null @@ -1,42 +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.edits; - -/** - * Superclass of all exceptions thrown when altering the workflow model through - * the edit manager. - * - * @author Tom Oinn - */ -@SuppressWarnings("serial") -public class EditException extends Exception { - public EditException(String string) { - super(string); - } - - public EditException(String string, Throwable cause) { - super(string, cause); - } - - public EditException(Throwable t) { - super(t); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/a9a52bd5/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditManager.java ---------------------------------------------------------------------- diff --git a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditManager.java b/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditManager.java deleted file mode 100644 index f497df9..0000000 --- a/taverna-edits-api/src/main/java/net/sf/taverna/t2/workbench/edits/EditManager.java +++ /dev/null @@ -1,222 +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.edits; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.lang.observer.Observable; -import org.apache.taverna.lang.observer.Observer; -import net.sf.taverna.t2.workbench.edits.EditManager.EditManagerEvent; - -/** - * Manager that can handle {@link Edit edits} for a {@link WorkflowBundle}. - * <p> - * Edits to a workflow that are to be undoable or redoable should be created by - * using {@link EditManager#getEdits()} to get an {@link Edits} object. Using - * this to create {@link Edit}s, instead of calling {@link Edit#doEdit()}, use - * {@link EditManager#doDataflowEdit(WorkflowBundle, Edit)} to associate the - * edit with the specified Dataflow. - * <p> - * It is possible to undo a series of edits done on a particular dataflow in - * this way by using {@link #undoDataflowEdit(WorkflowBundle)}. If one or more - * undoes have been performed, they can be redone step by step using - * {@link #redoDataflowEdit(WorkflowBundle)}. Note that it is no longer possible - * to call {@link #redoDataflowEdit(WorkflowBundle)} after a - * {@link #doDataflowEdit(WorkflowBundle, Edit)}. - * <p> - * The EditManager is {@link Observable}. If you - * {@linkplain Observable#addObserver(net.sf.taverna.t2.lang.observer.Observer) - * add an observer} you can be notified on {@linkplain DataflowEditEvent edits}, - * {@linkplain DataFlowUndoEvent undoes} and {@linkplain DataFlowRedoEvent - * redoes}. - * - * @author Stian Soiland-Reyes - */ -public interface EditManager extends Observable<EditManagerEvent> { - /** - * <code>true</code> if {@link #redoDataflowEdit(WorkflowBundle)} on the - * given dataflow would redo the last undone edit. If there are no previous - * edits, return <code>false</code>. - * - * @param dataflow - * {@link WorkflowBundle} which last affecting edit is to be - * undone - * @return <code>true</code if and only if - * {@link #redoDataflowEdit(WorkflowBundle)} would undo - */ - boolean canRedoDataflowEdit(WorkflowBundle dataflow); - - /** - * <code>true</code> if {@link #undoDataflowEdit(WorkflowBundle)} on the - * given dataflow would undo the last edit. If there are no previous edits, - * return <code>false</code>. - * - * @param dataflow - * {@link WorkflowBundle} which last affecting edit is to be - * undone - * @return <code>true</code if {@link #undoDataflowEdit(WorkflowBundle)} - * would undo - */ - boolean canUndoDataflowEdit(WorkflowBundle dataflow); - - /** - * Do an {@link Edit} affecting the given {@link WorkflowBundle}. - * <p> - * The edit is {@link Edit#doEdit() performed} and the edit can later be - * undone using {@link EditManager#undoDataflowEdit(WorkflowBundle)}. - * <p> - * Note that any events previously undone with - * {@link EditManager#undoDataflowEdit(WorkflowBundle)} for the given - * dataflow can no longer be - * {@link EditManager#redoDataflowEdit(WorkflowBundle) redone} after calling - * this method. - * - * @see EditManager#undoDataflowEdit(WorkflowBundle) - * @param dataflow - * {@link WorkflowBundle} this edit is affecting - * @param edit - * {@link Edit} that should be done using {@link Edit#doEdit()}. - * @throws EditException - * If {@link Edit#doEdit()} fails - */ - void doDataflowEdit(WorkflowBundle dataflow, Edit<?> edit) - throws EditException; - - /** - * Redo the last {@link Edit} that was undone using - * {@link #undoDataflowEdit(WorkflowBundle)}. - * <p> - * Note that the {@link EditManager} might only be able to redo a reasonable - * number of steps. - * <p> - * It is not possible to use {@link #redoDataflowEdit(WorkflowBundle)} after - * a {@link #doDataflowEdit(WorkflowBundle, Edit)} affecting the same - * {@link WorkflowBundle}, or if no edits have been undone yet. No action - * would be taken in these cases. - * - * @param dataflow - * {@link WorkflowBundle} which last affecting edit is to be - * redone - * @throws EditException - * If {@link Edit#doEdit()} fails - */ - void redoDataflowEdit(WorkflowBundle dataflow) throws EditException; - - /** - * Undo the last {@link Edit} affecting the given {@link WorkflowBundle}. - * <p> - * This can be called in succession until there are no more known undoes. - * Note that the {@link EditManager} might only be able to undo a reasonable - * number of steps. - * <p> - * The last edit must have been performed using - * {@link EditManager#doDataflowEdit(WorkflowBundle, Edit)} or - * {@link EditManager#redoDataflowEdit(WorkflowBundle)}. The undo is done - * using {@link Edit#undo()}. If no edits have been performed for the - * dataflow yet, no action is taken. - * <p> - * Undoes can be redone using {@link #redoDataflowEdit(WorkflowBundle)}. - * - * @param dataflow - * {@link WorkflowBundle} which last affecting edit is to be - * undone - */ - void undoDataflowEdit(WorkflowBundle dataflow); - - /** - * An event about an {@link Edit} on a {@link WorkflowBundle}, accessible - * through {@link AbstractDataflowEditEvent#getEdit()} and - * {@link AbstractDataflowEditEvent#getDataFlow()}. - */ - public static abstract class AbstractDataflowEditEvent implements - EditManagerEvent { - private final WorkflowBundle dataFlow; - private final Edit<?> edit; - - public AbstractDataflowEditEvent(WorkflowBundle dataFlow, Edit<?> edit) { - if (dataFlow == null || edit == null) - throw new NullPointerException( - "Dataflow and/or Edit can't be null"); - this.dataFlow = dataFlow; - this.edit = edit; - } - - /** - * The {@link WorkflowBundle} this event affected. - * - * @return A {@link WorkflowBundle} - */ - public WorkflowBundle getDataFlow() { - return dataFlow; - } - - /** - * The {@link Edit} that was performed, undoed or redone on the - * {@link #getDataFlow() dataflow}. - * - * @return An {@link Edit} - */ - @Override - public Edit<?> getEdit() { - return edit; - } - } - - /** - * An event sent when an {@link Edit} has been performed on a - * {@link WorkflowBundle}. - * - */ - public static class DataflowEditEvent extends AbstractDataflowEditEvent { - public DataflowEditEvent(WorkflowBundle dataFlow, Edit<?> edit) { - super(dataFlow, edit); - } - } - - /** - * An event sent when a previously undone {@link Edit} has been redone on a - * {@link WorkflowBundle}. - * - */ - public static class DataFlowRedoEvent extends AbstractDataflowEditEvent { - public DataFlowRedoEvent(WorkflowBundle dataFlow, Edit<?> edit) { - super(dataFlow, edit); - } - } - - /** - * An event sent when an {@link Edit} has been undone on a - * {@link WorkflowBundle}. - * - */ - public static class DataFlowUndoEvent extends AbstractDataflowEditEvent { - public DataFlowUndoEvent(WorkflowBundle dataFlow, Edit<?> edit) { - super(dataFlow, edit); - } - } - - /** - * An event given to {@link Observer}s registered with - * {@link Observable#addObserver(Observer)}. - */ - public interface EditManagerEvent { - public Edit<?> getEdit(); - } -}
