http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteAction.java deleted file mode 100644 index 72141c9..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteAction.java +++ /dev/null @@ -1,143 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static java.lang.String.format; -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.YES_NO_OPTION; -import static javax.swing.JOptionPane.YES_OPTION; -import static javax.swing.JOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.event.ActionEvent; -import java.util.concurrent.ExecutionException; - -import javax.swing.AbstractAction; -import javax.swing.SwingWorker; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.Component; -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.panel.ComponentChooserPanel; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceProviderConfig; -import io.github.taverna_extras.component.ui.util.Utils; - -import org.apache.taverna.scufl2.api.configurations.Configuration; -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.workbench.file.FileManager; - -/** - * @author alanrw - */ -public class ComponentDeleteAction extends AbstractAction { - private static final String COMPONENT_PROBLEM_TITLE = "Component Problem"; - private static final String CONFIRM_MSG = "Are you sure you want to delete %s?"; - private static final String CONFIRM_TITLE = "Delete Component Confirmation"; - private static final String DELETE_COMPONENT_LABEL = "Delete component..."; - private static final String DELETE_FAILED_TITLE = "Component Deletion Error"; - private static final String FAILED_MSG = "Unable to delete %s: %s"; - private static final String OPEN_COMPONENT_MSG = "The component is open"; - private static final String TITLE = "Component choice"; - private static final String WHAT_COMPONENT_MSG = "Unable to determine component"; - private static final long serialVersionUID = -2992743162132614936L; - private static final Logger logger = getLogger(ComponentDeleteAction.class); - - private final FileManager fm; - private final ComponentPreference prefs; - private final Utils utils; - - public ComponentDeleteAction(FileManager fm, ComponentPreference prefs, - ComponentServiceIcon icon, Utils utils) { - super(DELETE_COMPONENT_LABEL, icon.getIcon()); - this.fm = fm; - this.prefs = prefs; - this.utils = utils; - } - - @Override - public void actionPerformed(ActionEvent evt) { - ComponentChooserPanel panel = new ComponentChooserPanel(prefs); - int answer = showConfirmDialog(null, panel, TITLE, OK_CANCEL_OPTION); - if (answer == OK_OPTION) - doDelete(panel.getChosenComponent()); - } - - private void doDelete(final Component chosenComponent) { - if (chosenComponent == null) { - showMessageDialog(null, WHAT_COMPONENT_MSG, - COMPONENT_PROBLEM_TITLE, ERROR_MESSAGE); - } else if (componentIsInUse(chosenComponent)) { - showMessageDialog(null, OPEN_COMPONENT_MSG, - COMPONENT_PROBLEM_TITLE, ERROR_MESSAGE); - } else if (showConfirmDialog(null, - format(CONFIRM_MSG, chosenComponent.getName()), CONFIRM_TITLE, - YES_NO_OPTION) == YES_OPTION) - new SwingWorker<Configuration, Object>() { - @Override - protected Configuration doInBackground() throws Exception { - return deleteComponent(chosenComponent); - } - - @Override - protected void done() { - refresh(chosenComponent, this); - } - }.execute(); - } - - private Configuration deleteComponent(Component component) - throws ComponentException { - ComponentServiceProviderConfig config = new ComponentServiceProviderConfig( - component.getFamily()); - component.delete(); - return config.getConfiguration(); - } - - protected void refresh(Component component, - SwingWorker<Configuration, Object> worker) { - try { - utils.refreshComponentServiceProvider(worker.get()); - } catch (ExecutionException e) { - logger.error("failed to delete component", e.getCause()); - showMessageDialog( - null, - format(FAILED_MSG, component.getName(), e.getCause() - .getMessage()), DELETE_FAILED_TITLE, ERROR_MESSAGE); - } catch (InterruptedException e) { - logger.warn("interrupted during component deletion", e); - } - } - - private boolean componentIsInUse(Component component) { - for (WorkflowBundle d : fm.getOpenDataflows()) { - Object dataflowSource = fm.getDataflowSource(d); - if (dataflowSource instanceof Version.ID - && ((Version.ID) dataflowSource).mostlyEqualTo(component)) - return true; - } - return false; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteMenuAction.java deleted file mode 100644 index 99c75f9..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentDeleteMenuAction.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.workbench.file.FileManager; - -/** - * @author alanrw - */ -public class ComponentDeleteMenuAction extends AbstractComponentMenuAction { - private static final URI DELETE_COMPONENT_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentDelete"); - - private FileManager fm; - private ComponentServiceIcon icon; - private ComponentPreference prefs; - private Utils utils; - - public ComponentDeleteMenuAction() { - super(1200, DELETE_COMPONENT_URI); - } - - public void setFileManager(FileManager fm) { - this.fm = fm; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - public void setUtils(Utils utils) { - this.utils = utils; - } - - @Override - protected Action createAction() { - return new ComponentDeleteAction(fm, prefs, icon, utils); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuAction.java deleted file mode 100644 index 1176e6d..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static io.github.taverna_extras.component.ui.menu.component.ComponentMenuSection.COMPONENT_SECTION; - -import java.net.URI; - -import javax.swing.Action; -import org.apache.taverna.ui.menu.AbstractMenuAction; - -/** - * Basis for all menu actions. Intended to be configured by Spring. - * - * @author Donal Fellows - */ -public class ComponentMenuAction extends AbstractMenuAction { - /** - * Construct a menu action to appear within the "Components" menu. - * @param positionHint - * Where on the menu this should come. - * @param id - * How this should be identified to Taverna. - */ - public ComponentMenuAction(int positionHint, String id) { - super(COMPONENT_SECTION, positionHint, URI.create(id)); - } - - private Action action; - - public void setAction(Action action) { - this.action = action; - } - - @Override - protected Action createAction() { - return action; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuSection.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuSection.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuSection.java deleted file mode 100644 index 07e037d..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMenuSection.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static io.github.taverna_extras.component.ui.menu.ComponentMenu.COMPONENT; - -import java.net.URI; -import org.apache.taverna.ui.menu.AbstractMenuSection; - -/** - * @author alanrw - */ -public class ComponentMenuSection extends AbstractMenuSection { - public static final URI COMPONENT_SECTION = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentSection"); - - public ComponentMenuSection() { - super(COMPONENT, 400, COMPONENT_SECTION); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeAction.java deleted file mode 100644 index a350b16..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeAction.java +++ /dev/null @@ -1,135 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static java.awt.GridBagConstraints.BOTH; -import static java.awt.GridBagConstraints.WEST; -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; - -import javax.swing.AbstractAction; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.Component; -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.panel.ComponentChoiceMessage; -import io.github.taverna_extras.component.ui.panel.ComponentChooserPanel; -import io.github.taverna_extras.component.ui.panel.ProfileChoiceMessage; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.lang.observer.Observable; -import org.apache.taverna.lang.observer.Observer; - -/** - * @author alanrw - */ -public class ComponentMergeAction extends AbstractAction { - private static final long serialVersionUID = 6791184757725253807L; - private static final Logger logger = getLogger(ComponentMergeAction.class); - private static final String MERGE_COMPONENT = "Merge component..."; - - private final ComponentPreference prefs; - - public ComponentMergeAction(ComponentPreference prefs, - ComponentServiceIcon icon) { - super(MERGE_COMPONENT, icon.getIcon()); - this.prefs = prefs; - } - - @Override - public void actionPerformed(ActionEvent arg0) { - JPanel overallPanel = new JPanel(); - overallPanel.setLayout(new GridBagLayout()); - - GridBagConstraints gbc = new GridBagConstraints(); - - ComponentChooserPanel source = new ComponentChooserPanel(prefs); - source.setBorder(new TitledBorder("Source component")); - - gbc.insets = new Insets(0, 5, 0, 5); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = WEST; - gbc.fill = BOTH; - gbc.gridwidth = 2; - gbc.weightx = 1; - overallPanel.add(source, gbc); - - final ComponentChooserPanel target = new ComponentChooserPanel(prefs); - target.setBorder(new TitledBorder("Target component")); - gbc.gridy++; - overallPanel.add(target, gbc); - - source.addObserver(new Observer<ComponentChoiceMessage>() { - @Override - public void notify(Observable<ComponentChoiceMessage> sender, - ComponentChoiceMessage message) throws Exception { - target.notify(null, new ProfileChoiceMessage(message - .getComponentFamily().getComponentProfile())); - } - }); - - int answer = showConfirmDialog(null, overallPanel, "Merge Component", - OK_CANCEL_OPTION); - if (answer == OK_OPTION) - doMerge(source.getChosenComponent(), target.getChosenComponent()); - } - - private void doMerge(Component sourceComponent, Component targetComponent) { - if (sourceComponent == null) { - showMessageDialog(null, "Unable to determine source component", - "Component Merge Problem", ERROR_MESSAGE); - return; - } else if (targetComponent == null) { - showMessageDialog(null, "Unable to determine target component", - "Component Merge Problem", ERROR_MESSAGE); - return; - } else if (sourceComponent.equals(targetComponent)) { - showMessageDialog(null, "Cannot merge a component with itself", - "Component Merge Problem", ERROR_MESSAGE); - return; - } - - try { - Version sourceVersion = sourceComponent.getComponentVersionMap() - .get(sourceComponent.getComponentVersionMap().lastKey()); - targetComponent.addVersionBasedOn( - sourceVersion.getImplementation(), "Merge from " - + sourceComponent.getFamily().getName() + ":" - + sourceComponent.getName()); - } catch (ComponentException e) { - logger.error("failed to merge component", e); - showMessageDialog(null, "Failed to merge component: " + e, - "Component Merge Problem", ERROR_MESSAGE); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeMenuAction.java deleted file mode 100644 index 1bcac6a..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentMergeMenuAction.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; - -/** - * @author alanrw - */ -public class ComponentMergeMenuAction extends AbstractComponentMenuAction { - private static final URI MERGE_COMPONENT_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentMerge"); - - private ComponentServiceIcon icon; - private ComponentPreference prefs; - - public ComponentMergeMenuAction() { - super(900, MERGE_COMPONENT_URI); - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - @Override - protected Action createAction() { - return new ComponentMergeAction(prefs, icon); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveAction.java deleted file mode 100644 index 0226432..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static org.apache.log4j.Logger.getLogger; - -import java.awt.event.ActionEvent; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.lang.observer.Observable; -import org.apache.taverna.lang.observer.Observer; -import org.apache.taverna.workbench.file.FileManager; -import org.apache.taverna.workbench.file.events.FileManagerEvent; - -/** - * @author alanrw - */ -public class ComponentSaveAction extends AbstractAction implements - Observer<FileManagerEvent> { - private static final long serialVersionUID = -2391891750558659714L; - @SuppressWarnings("unused") - private static Logger logger = getLogger(ComponentSaveAction.class); - private static final String SAVE_COMPONENT = "Save component"; - - private Utils utils; - private Action saveWorkflowAction; - - public ComponentSaveAction(Action saveAction, FileManager fm, - ComponentServiceIcon icon, Utils utils) { - super(SAVE_COMPONENT, icon.getIcon()); - saveWorkflowAction = saveAction; - this.utils = utils; - fm.addObserver(this); - } - - @Override - public void actionPerformed(ActionEvent e) { - saveWorkflowAction.actionPerformed(e); - } - - @Override - public void notify(Observable<FileManagerEvent> sender, - FileManagerEvent message) throws Exception { - setEnabled(saveWorkflowAction.isEnabled() - && utils.currentDataflowIsComponent()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveMenuAction.java deleted file mode 100644 index cd0418d..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSaveMenuAction.java +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.workbench.file.FileManager; - -/** - * @author alanrw - */ -public class ComponentSaveMenuAction extends AbstractComponentMenuAction { - private static final URI SAVE_COMPONENT_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentSave"); - - private Action action; - private FileManager fm; - private ComponentServiceIcon icon; - private Utils utils; - - public ComponentSaveMenuAction() { - super(1100, SAVE_COMPONENT_URI); - } - - //FIXME beaninject net.sf.taverna.t2.workbench.file.impl.actions.SaveWorkflowAction - public void setSaveWorkflowAction(Action action) { - this.action = action; - } - - public void setFileManager(FileManager fm) { - this.fm = fm; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setUtils(Utils utils) { - this.utils = utils; - } - - @Override - protected Action createAction() { - return new ComponentSaveAction(action, fm, icon, utils); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchAction.java deleted file mode 100644 index 56e7395..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchAction.java +++ /dev/null @@ -1,169 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static java.awt.GridBagConstraints.BOTH; -import static java.awt.GridBagConstraints.WEST; -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.QUESTION_MESSAGE; -import static javax.swing.JOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.showMessageDialog; -import static javax.swing.JOptionPane.showOptionDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; -import java.util.Map.Entry; -import java.util.SortedMap; - -import javax.swing.AbstractAction; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.ComponentFactory; -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.api.profile.Profile; -import io.github.taverna_extras.component.ui.panel.PrefixPanel; -import io.github.taverna_extras.component.ui.panel.ProfileChooserPanel; -import io.github.taverna_extras.component.ui.panel.RegistryChooserPanel; -import io.github.taverna_extras.component.ui.panel.SearchChoicePanel; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceDesc; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.services.ServiceRegistry; -import org.apache.taverna.ui.menu.MenuManager; -import org.apache.taverna.workbench.edits.EditManager; -import org.apache.taverna.workbench.selection.SelectionManager; -import org.apache.taverna.workbench.ui.workflowview.WorkflowView; - -/** - * @author alanrw - */ -public class ComponentSearchAction extends AbstractAction { - private static final String WFDESC_PREFIX = "wfdesc"; - private static final long serialVersionUID = -7780471499146286881L; - @SuppressWarnings("unused") - private static final Logger logger = getLogger(ComponentSearchAction.class); - private static final String SEARCH_FOR_COMPONENTS = "Search for components..."; - - private final ComponentPreference prefs; - private final ComponentFactory factory; - private final EditManager em; - private final MenuManager mm; - private final SelectionManager sm; - private final ServiceRegistry sr; - private final ComponentServiceIcon icon; - - public ComponentSearchAction(ComponentPreference prefs, - ComponentFactory factory, EditManager em, MenuManager mm, - SelectionManager sm, ServiceRegistry sr, ComponentServiceIcon icon) { - super(SEARCH_FOR_COMPONENTS, icon.getIcon()); - this.prefs = prefs; - this.factory = factory; - this.em = em; - this.mm = mm; - this.sm = sm; - this.sr = sr; - this.icon = icon; - } - - @Override - public void actionPerformed(ActionEvent e) { - JPanel overallPanel = new JPanel(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - - RegistryChooserPanel registryPanel = new RegistryChooserPanel(prefs); - - gbc.insets.left = 5; - gbc.insets.right = 5; - gbc.gridx = 0; - gbc.anchor = WEST; - gbc.fill = BOTH; - gbc.gridwidth = 2; - gbc.weightx = 1; - gbc.gridy++; - overallPanel.add(registryPanel, gbc); - - ProfileChooserPanel profilePanel = new ProfileChooserPanel(registryPanel); - gbc.gridx = 0; - gbc.gridy++; - overallPanel.add(profilePanel, gbc); - - PrefixPanel prefixPanel = new PrefixPanel(profilePanel); - gbc.gridx = 0; - gbc.gridy++; - overallPanel.add(prefixPanel, gbc); - - JTextArea queryPane = new JTextArea(20, 80); - gbc.gridx = 0; - gbc.weighty = 1; - gbc.gridy++; - overallPanel.add(new JScrollPane(queryPane), gbc); - - int answer = showConfirmDialog(null, overallPanel, - "Search for components", OK_CANCEL_OPTION); - if (answer == OK_OPTION) - doSearch(registryPanel.getChosenRegistry(), - profilePanel.getChosenProfile(), - prefixPanel.getPrefixMap(), queryPane.getText()); - } - - private void doSearch(Registry chosenRegistry, Profile chosenProfile, - SortedMap<String, String> prefixMap, String queryString) { - if (chosenRegistry == null) { - showMessageDialog(null, "Unable to determine registry", - "Component Registry Problem", ERROR_MESSAGE); - return; - } - if (chosenProfile == null) { - showMessageDialog(null, "Unable to determine profile", - "Component Profile Problem", ERROR_MESSAGE); - return; - } - StringBuilder prefixString = new StringBuilder(); - for (Entry<String, String> entry : prefixMap.entrySet()) - if (!entry.getKey().equals(WFDESC_PREFIX)) - prefixString.append(constructPrefixString(entry)); - - SearchChoicePanel searchChoicePanel = new SearchChoicePanel( - chosenRegistry, prefixString.toString(), queryString); - int answer = showOptionDialog(null, searchChoicePanel, - "Matching components", OK_CANCEL_OPTION, QUESTION_MESSAGE, - null, new String[] { "Add to workflow", "Cancel" }, "Cancel"); - if (answer == OK_OPTION) { - Version.ID ident = searchChoicePanel.getVersionIdentification(); - if (ident != null) - WorkflowView.importServiceDescription(new ComponentServiceDesc(prefs, - factory, icon, ident), false, em, mm, sm, sr); - } - } - - private static String constructPrefixString(Entry<String, String> entry) { - String key = entry.getKey(); - String value = entry.getValue(); - return String.format("PREFIX %s:<%s>\n", key, value); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchMenuAction.java deleted file mode 100644 index c621651..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentSearchMenuAction.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.api.ComponentFactory; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.services.ServiceRegistry; -import org.apache.taverna.ui.menu.MenuManager; -import org.apache.taverna.workbench.edits.EditManager; -import org.apache.taverna.workbench.selection.SelectionManager; - -/** - * @author alanrw - */ -public class ComponentSearchMenuAction extends AbstractComponentMenuAction { - private static final URI SEARCH_COMPONENT_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentSearch"); - private ComponentPreference prefs; - private ComponentFactory factory; - private EditManager em; - private MenuManager mm; - private SelectionManager sm; - private ServiceRegistry serviceRegistry; - private ComponentServiceIcon icon; - - public ComponentSearchMenuAction() { - super(1500, SEARCH_COMPONENT_URI); - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - public void setComponentFactory(ComponentFactory factory) { - this.factory = factory; - } - - public void setEditManager(EditManager em) { - this.em = em; - } - - public void setMenuManager(MenuManager mm) { - this.mm = mm; - } - - public void setSelectionManager(SelectionManager sm) { - this.sm = sm; - } - - public void setServiceRegistry(ServiceRegistry serviceRegistry) { - this.serviceRegistry = serviceRegistry; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - @Override - protected Action createAction() { - return new ComponentSearchAction(prefs, factory, em, mm, sm, - serviceRegistry, icon); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorAction.java deleted file mode 100644 index 0c7a668..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorAction.java +++ /dev/null @@ -1,112 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; -import static org.apache.taverna.scufl2.api.common.Scufl2Tools.NESTED_WORKFLOW; - -import java.awt.event.ActionEvent; - -import javax.swing.AbstractAction; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.menu.component.ComponentCreatorSupport.CopiedProcessor; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; - -import com.fasterxml.jackson.databind.JsonNode; - -import org.apache.taverna.scufl2.api.activity.Activity; -import org.apache.taverna.scufl2.api.core.Processor; -import org.apache.taverna.scufl2.api.core.Workflow; -import org.apache.taverna.scufl2.api.profiles.Profile; -import org.apache.taverna.workbench.selection.SelectionManager; - -/** - * @author alanrw - */ -public class ComponentServiceCreatorAction extends AbstractAction { - private static final long serialVersionUID = -2611514696254112190L; - private static Logger logger = getLogger(ComponentServiceCreatorAction.class); - - private final Processor p; - private final Profile profile; - private final ComponentCreatorSupport support; - - public ComponentServiceCreatorAction(Processor processor, SelectionManager sm, - ComponentCreatorSupport support, ComponentServiceIcon icon) { - super("Create component...", icon.getIcon()); - this.support = support; - p = processor; - profile = sm.getSelectedProfile(); - } - - private Workflow getNestedWorkflow(Activity a) { - JsonNode nw = a.getConfiguration().getJson().get("nestedWorkflow"); - return a.getParent().getParent().getWorkflows().getByName(nw.asText()); - } - - @Override - public void actionPerformed(ActionEvent event) { - Version.ID ident = support.getNewComponentIdentification(p.getName()); - if (ident == null) - return; - - Activity a = p.getActivity(profile); - - try { - Workflow d; - if (NESTED_WORKFLOW.equals(a.getType())) - d = getNestedWorkflow(a); - else { - d = new Workflow(); - - /* TODO: Keep the description */ - // fm.setCurrentDataflow(current); - - CopiedProcessor processorElement = support.copyProcessor(p); - - Processor newProcessor; - try { - newProcessor = support.pasteProcessor(processorElement, d); - } catch (IllegalArgumentException e) { - logger.error( - "failed to paste processor representing component", - e); - showMessageDialog(null, e.getMessage(), - "Component creation failure", ERROR_MESSAGE); - return; - } - - support.connectNewProcessor(d, newProcessor); - } - - Activity ca = new Activity(); - support.saveWorkflowAsComponent(d, ident).installConfiguration(ca); - support.moveComponentActivityIntoPlace(a, p, ca); - } catch (Exception e) { - logger.error("failed to instantiate component", e); - showMessageDialog(null, e.getCause().getMessage(), - "Component creation failure", ERROR_MESSAGE); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorMenuAction.java deleted file mode 100644 index ef55fa5..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentServiceCreatorMenuAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.menu.AbstractContextComponentMenuAction; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; - -import org.apache.taverna.scufl2.api.activity.Activity; -import org.apache.taverna.scufl2.api.core.Processor; -import org.apache.taverna.workbench.selection.SelectionManager; - -/** - * @author alanrw - */ -public class ComponentServiceCreatorMenuAction extends - AbstractContextComponentMenuAction { - private static final URI configureSection = URI - .create("http://taverna.sf.net/2009/contextMenu/configure"); - - private ComponentCreatorSupport support; - private SelectionManager sm; - private ComponentServiceIcon icon; - - public ComponentServiceCreatorMenuAction() { - super(configureSection, 60); - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setSelectionManager(SelectionManager sm) { - this.sm = sm; - } - - public void setSupport(ComponentCreatorSupport support) { - this.support = support; - } - - @Override - public boolean isEnabled() { - if (!super.isEnabled()) - return false; - Activity a = findActivity(); - if (a == null) - return false; - return !isComponentActivity(a); - } - - @Override - protected Action createAction() { - return new ComponentServiceCreatorAction( - (Processor) getContextualSelection().getSelection(), sm, - support, icon); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorAction.java deleted file mode 100644 index c21de5b..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.event.ActionEvent; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.ComponentAction; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.lang.observer.Observable; -import org.apache.taverna.lang.observer.Observer; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.workbench.file.FileManager; -import org.apache.taverna.workbench.file.events.FileManagerEvent; -import org.apache.taverna.workbench.views.graph.GraphViewComponent; - -/** - * @author alanrw - */ -public class ComponentWorkflowCreatorAction extends ComponentAction implements - Observer<FileManagerEvent> { - private static final long serialVersionUID = -299685223430721587L; - private static Logger logger = getLogger(ComponentWorkflowCreatorAction.class); - private static final String CREATE_COMPONENT = "Create component from current workflow..."; - - private ComponentCreatorSupport support; - private FileManager fileManager; - private Utils utils; - - public ComponentWorkflowCreatorAction(ComponentCreatorSupport support, - FileManager fm, GraphViewComponent graphView, - ComponentServiceIcon icon, Utils utils) { - super(CREATE_COMPONENT, graphView); - this.support = support; - this.utils = utils; - fm.addObserver(this); - this.setIcon(icon); - } - - @Override - public void actionPerformed(ActionEvent event) { - WorkflowBundle bundle = fileManager.getCurrentDataflow(); - try { - Version.ID ident = support.getNewComponentIdentification(bundle.getName());//TODO is this right - if (ident == null) - return; - support.saveWorkflowAsComponent(bundle, ident); - } catch (Exception e) { - showMessageDialog(graphView, e.getCause().getMessage(), - "Component creation failure", ERROR_MESSAGE); - logger.error("failed to save workflow as component", e); - } - } - - @Override - public void notify(Observable<FileManagerEvent> sender, - FileManagerEvent message) throws Exception { - setEnabled(!utils.currentDataflowIsComponent()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java deleted file mode 100644 index 8ddaf5c..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/ComponentWorkflowCreatorMenuAction.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.workbench.file.FileManager; -import org.apache.taverna.workbench.views.graph.GraphViewComponent; - -/** - * @author alanrw - */ -public class ComponentWorkflowCreatorMenuAction extends AbstractComponentMenuAction { - private static final URI COMPONENT_WORKFLOW_CREATE_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentCreate"); - - private ComponentCreatorSupport support; - private FileManager fm; - private GraphViewComponent graphView; - private ComponentServiceIcon icon; - private Utils utils; - - public ComponentWorkflowCreatorMenuAction() { - super(600, COMPONENT_WORKFLOW_CREATE_URI); - } - - public void setSupport(ComponentCreatorSupport support) { - this.support = support; - } - - public void setFileManager(FileManager fm) { - this.fm = fm; - } - - public void setGraphView(GraphViewComponent graphView) { - this.graphView = graphView; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setUtils(Utils utils) { - this.utils = utils; - } - - @Override - protected Action createAction() { - return new ComponentWorkflowCreatorAction(support, fm, graphView, icon, utils); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/FileOpenFromComponentMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/FileOpenFromComponentMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/FileOpenFromComponentMenuAction.java deleted file mode 100644 index 016098f..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/FileOpenFromComponentMenuAction.java +++ /dev/null @@ -1,74 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.workbench.file.FileManager; -import org.apache.taverna.workbench.file.FileType; -import org.apache.taverna.workbench.views.graph.GraphViewComponent; - -/** - * @author alanrw - */ -public class FileOpenFromComponentMenuAction extends - AbstractComponentMenuAction { - private static final URI FILE_OPEN_FROM_COMPONENT_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentOpen"); - private FileManager fm; - private FileType ft; - private ComponentPreference prefs; - private GraphViewComponent graphView; - private ComponentServiceIcon icon; - - public FileOpenFromComponentMenuAction() { - super(700, FILE_OPEN_FROM_COMPONENT_URI); - } - - public void setFileManager(FileManager fm) { - this.fm = fm; - } - - public void setFileType(FileType ft) { - this.ft = ft; - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - public void setGraphView(GraphViewComponent graphView) { - this.graphView = graphView; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - @Override - protected Action createAction() { - return new OpenWorkflowFromComponentAction(fm, ft, prefs, graphView, - icon); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/OpenWorkflowFromComponentAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/OpenWorkflowFromComponentAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/OpenWorkflowFromComponentAction.java deleted file mode 100644 index 373195f..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/component/OpenWorkflowFromComponentAction.java +++ /dev/null @@ -1,137 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.component; - -import static javax.swing.JOptionPane.CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.QUESTION_MESSAGE; -import static javax.swing.JOptionPane.YES_NO_OPTION; -import static javax.swing.JOptionPane.showOptionDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JOptionPane; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.Component; -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.ComponentAction; -import io.github.taverna_extras.component.ui.panel.ComponentChoiceMessage; -import io.github.taverna_extras.component.ui.panel.ComponentVersionChooserPanel; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.lang.observer.Observable; -import org.apache.taverna.lang.observer.Observer; - -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.workbench.file.FileManager; -import org.apache.taverna.workbench.file.FileType; -import org.apache.taverna.workbench.file.exceptions.OpenException; -import org.apache.taverna.workbench.views.graph.GraphViewComponent; - -/** - * @author alanrw - */ -public class OpenWorkflowFromComponentAction extends ComponentAction { - private static final long serialVersionUID = 7382677337746318211L; - private static final Logger logger = getLogger(OpenWorkflowFromComponentAction.class); - private static final String ACTION_NAME = "Open component..."; - private static final String ACTION_DESCRIPTION = "Open the workflow that implements a component"; - - private final FileManager fm; - private final FileType ft; - private final ComponentPreference prefs; - - public OpenWorkflowFromComponentAction(FileManager fm, FileType ft, - ComponentPreference prefs, GraphViewComponent graphView, - ComponentServiceIcon icon) { - super(ACTION_NAME, graphView); - this.fm = fm; - this.ft = ft; - this.prefs = prefs; - setIcon(icon); - putValue(SHORT_DESCRIPTION, ACTION_DESCRIPTION); - } - - @Override - public void actionPerformed(ActionEvent arg) { - final ComponentVersionChooserPanel panel = new ComponentVersionChooserPanel(prefs); - - final JButton okay = new JButton("OK"); - okay.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - getOptionPane((JComponent) e.getSource()).setValue(OK_OPTION); - doOpen(panel.getChosenRegistry(), panel.getChosenFamily(), - panel.getChosenComponent(), - panel.getChosenComponentVersion()); - } - }); - okay.setEnabled(false); - // Only enable the OK button of a component is not null - panel.getComponentChooserPanel().addObserver( - new Observer<ComponentChoiceMessage>() { - @Override - public void notify( - Observable<ComponentChoiceMessage> sender, - ComponentChoiceMessage message) throws Exception { - okay.setEnabled(message.getChosenComponent() != null); - } - }); - - final JButton cancel = new JButton("Cancel"); - cancel.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - getOptionPane((JComponent)e.getSource()).setValue(CANCEL_OPTION); - } - }); - - showOptionDialog(graphView, panel, "Component version choice", - YES_NO_OPTION, QUESTION_MESSAGE, null, new Object[] { okay, - cancel }, okay); - } - - protected JOptionPane getOptionPane(JComponent parent) { - if (parent instanceof JOptionPane) - return (JOptionPane) parent; - return getOptionPane((JComponent) parent.getParent()); - } - - private void doOpen(Registry registry, Family family, Component component, - Version version) { - Version.ID ident = new Version.Identifier( - registry.getRegistryBase(), family.getName(), - component.getName(), version.getVersionNumber()); - - try { - WorkflowBundle d = fm.openDataflow(ft, ident); - markGraphAsBelongingToComponent(d); - } catch (OpenException e) { - logger.error("Failed to open component definition", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateAction.java deleted file mode 100644 index 0fe2ee4..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateAction.java +++ /dev/null @@ -1,176 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.family; - -import static java.awt.GridBagConstraints.BOTH; -import static java.awt.GridBagConstraints.WEST; -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; - -import javax.swing.AbstractAction; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.border.TitledBorder; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.api.License; -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.api.SharingPolicy; -import io.github.taverna_extras.component.api.profile.Profile; -import io.github.taverna_extras.component.ui.panel.LicenseChooserPanel; -import io.github.taverna_extras.component.ui.panel.ProfileChooserPanel; -import io.github.taverna_extras.component.ui.panel.RegistryChooserPanel; -import io.github.taverna_extras.component.ui.panel.SharingPolicyChooserPanel; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; - -/** - * @author alanrw - */ -public class ComponentFamilyCreateAction extends AbstractAction { - private static final long serialVersionUID = -7780471499146286881L; - private static final Logger logger = getLogger(ComponentFamilyCreateAction.class); - private static final String CREATE_FAMILY = "Create family..."; - - private ComponentPreference prefs; - private JPanel overallPanel; - private GridBagConstraints gbc; - - public ComponentFamilyCreateAction(ComponentPreference prefs, - ComponentServiceIcon iconProvider) { - super(CREATE_FAMILY, iconProvider.getIcon()); - this.prefs = prefs; - } - - @Override - public void actionPerformed(ActionEvent arg0) { - overallPanel = new JPanel(new GridBagLayout()); - gbc = new GridBagConstraints(); - - RegistryChooserPanel registryPanel = new RegistryChooserPanel(prefs); - - gbc.insets.left = 5; - gbc.insets.right = 5; - gbc.gridx = 0; - gbc.anchor = WEST; - gbc.fill = BOTH; - gbc.gridwidth = 2; - gbc.weightx = 1; - gbc.gridy++; - overallPanel.add(registryPanel, gbc); - - ProfileChooserPanel profilePanel = new ProfileChooserPanel( - registryPanel); - gbc.gridx = 0; - gbc.weighty = 1; - gbc.gridy++; - overallPanel.add(profilePanel, gbc); - - gbc.gridx = 0; - gbc.gridwidth = 1; - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy++; - overallPanel.add(new JLabel("Component family name:"), gbc); - - gbc.gridx = 1; - gbc.weightx = 1; - JTextField familyNameField = new JTextField(60); - overallPanel.add(familyNameField, gbc); - - gbc.gridx = 0; - gbc.gridwidth = 2; - gbc.weightx = 0; - gbc.weighty = 0; - gbc.gridy++; - JTextArea familyDescription = new JTextArea(10, 60); - JScrollPane familyDescriptionPane = new JScrollPane(familyDescription); - familyDescriptionPane.setBorder(new TitledBorder("Family description")); - overallPanel.add(familyDescriptionPane, gbc); - - gbc.gridx = 0; - gbc.gridwidth = 2; - gbc.weightx = 1; - gbc.weighty = 1; - gbc.gridy++; - SharingPolicyChooserPanel permissionPanel = new SharingPolicyChooserPanel( - registryPanel); - overallPanel.add(permissionPanel, gbc); - - gbc.gridy++; - LicenseChooserPanel licensePanel = new LicenseChooserPanel(); - registryPanel.addObserver(licensePanel); - overallPanel.add(licensePanel, gbc); - - int answer = showConfirmDialog(null, overallPanel, - "Create Component Family", OK_CANCEL_OPTION); - if (answer == OK_OPTION) - doCreate(registryPanel.getChosenRegistry(), - profilePanel.getChosenProfile(), familyNameField.getText(), - familyDescription.getText(), - permissionPanel.getChosenPermission(), - licensePanel.getChosenLicense()); - } - - private void doCreate(Registry chosenRegistry, Profile chosenProfile, - String newName, String familyDescription, SharingPolicy permission, - License license) { - if (chosenRegistry == null) { - showMessageDialog(null, "Unable to determine registry", - "Component Registry Problem", ERROR_MESSAGE); - return; - } else if (chosenProfile == null) { - showMessageDialog(null, "Unable to determine profile", - "Component Profile Problem", ERROR_MESSAGE); - return; - } else if ((newName == null) || newName.isEmpty()) { - showMessageDialog(null, "Name must be specified", - "Missing component family name", ERROR_MESSAGE); - return; - } - - try { - if (chosenRegistry.getComponentFamily(newName) != null) { - showMessageDialog(null, newName + " is already used", - "Duplicate component family name", ERROR_MESSAGE); - return; - } - chosenRegistry.createComponentFamily(newName, chosenProfile, - familyDescription, license, permission); - } catch (ComponentException e) { - logger.error("failed to create family", e); - showMessageDialog(null, - "Unable to create family: " + e.getMessage(), - "Family creation problem", ERROR_MESSAGE); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateMenuAction.java deleted file mode 100644 index 94c0080..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyCreateMenuAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.family; - -import static io.github.taverna_extras.component.ui.menu.family.ComponentFamilyMenuSection.COMPONENT_FAMILY_SECTION; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import org.apache.taverna.ui.menu.AbstractMenuAction; - -/** - * @author alanrw - */ -public class ComponentFamilyCreateMenuAction extends AbstractMenuAction { - private static final URI COMPONENT_FAMILY_CREATE_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentFamilyCreate"); - - private ComponentPreference prefs; - private ComponentServiceIcon iconProvider; - - public ComponentFamilyCreateMenuAction() { - super(COMPONENT_FAMILY_SECTION, 400, COMPONENT_FAMILY_CREATE_URI); - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - public void setIcon(ComponentServiceIcon iconProvider) { - this.iconProvider = iconProvider; - } - - @Override - protected Action createAction() { - return new ComponentFamilyCreateAction(prefs, iconProvider); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteAction.java deleted file mode 100644 index 4ac20e4..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteAction.java +++ /dev/null @@ -1,201 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.family; - -import static java.awt.GridBagConstraints.BOTH; -import static java.awt.GridBagConstraints.WEST; -import static java.lang.String.format; -import static javax.swing.JOptionPane.ERROR_MESSAGE; -import static javax.swing.JOptionPane.OK_CANCEL_OPTION; -import static javax.swing.JOptionPane.OK_OPTION; -import static javax.swing.JOptionPane.YES_NO_OPTION; -import static javax.swing.JOptionPane.YES_OPTION; -import static javax.swing.JOptionPane.showConfirmDialog; -import static javax.swing.JOptionPane.showMessageDialog; -import static org.apache.log4j.Logger.getLogger; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.util.concurrent.ExecutionException; - -import javax.swing.AbstractAction; -import javax.swing.JPanel; -import javax.swing.SwingWorker; - -import org.apache.log4j.Logger; -import io.github.taverna_extras.component.api.ComponentException; -import io.github.taverna_extras.component.api.Family; -import io.github.taverna_extras.component.api.Registry; -import io.github.taverna_extras.component.api.Version; -import io.github.taverna_extras.component.ui.panel.FamilyChooserPanel; -import io.github.taverna_extras.component.ui.panel.RegistryChooserPanel; -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceProviderConfig; -import io.github.taverna_extras.component.ui.util.Utils; - -import org.apache.taverna.scufl2.api.configurations.Configuration; -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.workbench.file.FileManager; - -/** - * @author alanrw - */ -public class ComponentFamilyDeleteAction extends AbstractAction { - private static final String CONFIRM_MSG = "Are you sure you want to delete %s"; - private static final String CONFIRM_TITLE = "Delete Component Family Confirmation"; - private static final String DELETE_FAMILY_LABEL = "Delete family..."; - private static final String ERROR_TITLE = "Component Family Deletion Error"; - private static final String FAILED_MSG = "Unable to delete %s: %s"; - private static final String FAMILY_FAIL_TITLE = "Component Family Problem"; - private static final String OPEN_MSG = "Components in the family are open"; - private static final String PICK_FAMILY_TITLE = "Delete Component Family"; - private static final String REGISTRY_FAIL_TITLE = "Component Registry Problem"; - private static final String WHAT_FAMILY_MSG = "Unable to determine family"; - private static final String WHAT_REGISTRY_MSG = "Unable to determine registry"; - private static final Logger logger = getLogger(ComponentFamilyDeleteAction.class); - private static final long serialVersionUID = -4976161883778371344L; - - private final FileManager fm; - private final ComponentPreference prefs; - private final Utils utils; - - public ComponentFamilyDeleteAction(FileManager fm, - ComponentPreference prefs, ComponentServiceIcon icon, Utils utils) { - super(DELETE_FAMILY_LABEL, icon.getIcon()); - this.fm = fm; - this.prefs = prefs; - this.utils = utils; - } - - @Override - public void actionPerformed(ActionEvent ev) { - JPanel overallPanel = new JPanel(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - - RegistryChooserPanel registryPanel = new RegistryChooserPanel(prefs); - - gbc.insets = new Insets(0, 5, 0, 5); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = WEST; - gbc.fill = BOTH; - gbc.gridwidth = 2; - gbc.weightx = 1; - overallPanel.add(registryPanel, gbc); - - FamilyChooserPanel familyPanel = new FamilyChooserPanel(registryPanel); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.weighty = 1; - overallPanel.add(familyPanel, gbc); - - int answer = showConfirmDialog(null, overallPanel, PICK_FAMILY_TITLE, - OK_CANCEL_OPTION); - if (answer == OK_OPTION) - deletionActionFlow(registryPanel.getChosenRegistry(), - familyPanel.getChosenFamily()); - } - - /** - * Check if the preconditions for the deletion action are satisfied. - * - * @param chosenRegistry - * What registry contains the family. - * @param chosenFamily - */ - private void deletionActionFlow(Registry chosenRegistry, - final Family chosenFamily) { - if (chosenRegistry == null) { - showMessageDialog(null, WHAT_REGISTRY_MSG, REGISTRY_FAIL_TITLE, - ERROR_MESSAGE); - return; - } else if (chosenFamily == null) { - showMessageDialog(null, WHAT_FAMILY_MSG, FAMILY_FAIL_TITLE, - ERROR_MESSAGE); - return; - } else if (familyIsInUse(chosenRegistry, chosenFamily)) { - showMessageDialog(null, OPEN_MSG, FAMILY_FAIL_TITLE, ERROR_MESSAGE); - return; - } else if (showConfirmDialog(null, - format(CONFIRM_MSG, chosenFamily.getName()), CONFIRM_TITLE, - YES_NO_OPTION) == YES_OPTION) - new SwingWorker<ComponentServiceProviderConfig, Object>() { - @Override - protected ComponentServiceProviderConfig doInBackground() - throws Exception { - return deleteFamily(chosenFamily); - } - - @Override - protected void done() { - deletionDone(chosenFamily, this); - } - }.execute(); - } - - private ComponentServiceProviderConfig deleteFamily(Family family) - throws ComponentException { - ComponentServiceProviderConfig config = new ComponentServiceProviderConfig( - family); - family.delete(); - return config; - } - - private void deletionDone(Family family, - SwingWorker<ComponentServiceProviderConfig, Object> worker) { - Configuration config; - try { - config = worker.get().getConfiguration(); - } catch (InterruptedException e) { - logger.warn("interrupted during removal of component family", e); - return; - } catch (ExecutionException e) { - logger.error("failed to delete family", e.getCause()); - showMessageDialog( - null, - format(FAILED_MSG, family.getName(), e.getCause() - .getMessage()), ERROR_TITLE, ERROR_MESSAGE); - return; - } - try { - utils.removeComponentServiceProvider(config); - } catch (Exception e) { - logger.error("failed to update service provider panel " - + "after deleting family", e); - } - } - - private boolean familyIsInUse(Registry chosenRegistry, Family chosenFamily) { - for (WorkflowBundle d : fm.getOpenDataflows()) { - Object dataflowSource = fm.getDataflowSource(d); - if (dataflowSource instanceof Version.ID) { - Version.ID ident = (Version.ID) dataflowSource; - if (ident.getRegistryBase().toString() - .equals(chosenRegistry.getRegistryBase().toString()) - && ident.getFamilyName().equals(chosenFamily.getName())) - return true; - } - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteMenuAction.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteMenuAction.java deleted file mode 100644 index ffb3cbf..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyDeleteMenuAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.family; - -import java.net.URI; - -import javax.swing.Action; - -import io.github.taverna_extras.component.ui.preference.ComponentPreference; -import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; -import io.github.taverna_extras.component.ui.util.Utils; -import org.apache.taverna.ui.menu.AbstractMenuAction; -import org.apache.taverna.workbench.file.FileManager; - -/** - * @author alanrw - */ -public class ComponentFamilyDeleteMenuAction extends AbstractMenuAction { - private static final URI COMPONENT_FAMILY_DELETE_URI = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentFamilyDelete"); - - private FileManager fm; - private ComponentPreference prefs; - private ComponentServiceIcon icon; - private Utils utils; - - public ComponentFamilyDeleteMenuAction() { - super(ComponentFamilyMenuSection.COMPONENT_FAMILY_SECTION, 500, - COMPONENT_FAMILY_DELETE_URI); - } - - public void setFileManager(FileManager fm) { - this.fm = fm; - } - - public void setIcon(ComponentServiceIcon icon) { - this.icon = icon; - } - - public void setPreferences(ComponentPreference prefs) { - this.prefs = prefs; - } - - public void setUtils(Utils utils) { - this.utils = utils; - } - - @Override - protected Action createAction() { - return new ComponentFamilyDeleteAction(fm, prefs, icon, utils); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyMenuSection.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyMenuSection.java b/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyMenuSection.java deleted file mode 100644 index dbc331e..0000000 --- a/taverna-component-activity-ui/src/main/java/org/apache/taverna/component/ui/menu/family/ComponentFamilyMenuSection.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* 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 io.github.taverna_extras.component.ui.menu.family; - -import java.net.URI; - -import io.github.taverna_extras.component.ui.menu.ComponentMenu; -import org.apache.taverna.ui.menu.AbstractMenuSection; - -/** - * @author alanrw - */ -public class ComponentFamilyMenuSection extends AbstractMenuSection { - public static final URI COMPONENT_FAMILY_SECTION = URI - .create("http://taverna.sf.net/2008/t2workbench/menu#componentFamilySection"); - - public ComponentFamilyMenuSection() { - super(ComponentMenu.COMPONENT, 300, COMPONENT_FAMILY_SECTION); - } -}
