You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:36:01 UTC
[46/58] [abbrv] incubator-taverna-plugin-component git commit:
org.apache.taverna.component.ui
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/ProfileChooserPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/ProfileChooserPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/ProfileChooserPanel.java
deleted file mode 100644
index e6077fa..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/ProfileChooserPanel.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.NONE;
-import static java.awt.GridBagConstraints.WEST;
-import static java.awt.event.ItemEvent.SELECTED;
-import static net.sf.taverna.t2.component.ui.util.Utils.LONG_STRING;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.concurrent.ExecutionException;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.profile.Profile;
-
-/**
- * @author alanrw
- */
-public class ProfileChooserPanel extends JPanel implements
- Observer<RegistryChoiceMessage>, Observable<ProfileChoiceMessage> {
- private static final String READING_MSG = "Reading profiles";
- private static final String PROFILE_LABEL = "Profile:";
- private static final long serialVersionUID = 2175274929391537032L;
- private static Logger logger = getLogger(ProfileChooserPanel.class);
-
- private final List<Observer<ProfileChoiceMessage>> observers = new ArrayList<>();
- private final JComboBox<String> profileBox = new JComboBox<>();
- private final SortedMap<String, Profile> profileMap = new TreeMap<>();
-
- private Registry registry;
-
- public ProfileChooserPanel(RegistryChooserPanel registryPanel) {
- this();
- registryPanel.addObserver(new Observer<RegistryChoiceMessage>() {
- @Override
- public void notify(Observable<RegistryChoiceMessage> sender,
- RegistryChoiceMessage message) throws Exception {
- try {
- registry = message.getChosenRegistry();
- updateProfileModel();
- } catch (Exception e) {
- logger.error("failure when notifying about chosen registry", e);
- }
- }
- });
- }
-
- public ProfileChooserPanel() {
- super();
- profileBox.setPrototypeDisplayValue(LONG_STRING);
- this.setLayout(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = WEST;
- gbc.fill = NONE;
- this.add(new JLabel(PROFILE_LABEL), gbc);
- gbc.gridx = 1;
- gbc.weightx = 1;
- gbc.fill = BOTH;
- this.add(profileBox, gbc);
- profileBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent event) {
- if (event.getStateChange() == SELECTED)
- setProfile(profileMap.get(profileBox.getSelectedItem()));
- }
- });
-
- profileBox.setEditable(false);
- }
-
- @Override
- public void notify(Observable<RegistryChoiceMessage> sender,
- RegistryChoiceMessage message) throws Exception {
- try {
- registry = message.getChosenRegistry();
- updateProfileModel();
- } catch (Exception e) {
- logger.error("failure when notifying about chosen registry", e);
- }
- }
-
- private void updateProfileModel() {
- profileMap.clear();
- profileBox.removeAllItems();
- profileBox.setToolTipText(null);
- profileBox.addItem(READING_MSG);
- profileBox.setEnabled(false);
- new ProfileUpdater().execute();
- }
-
- private void setProfile(Profile componentProfile) {
- if (componentProfile != null)
- profileBox.setToolTipText(componentProfile.getDescription());
- else
- profileBox.setToolTipText(null);
-
- Profile chosenProfile = getChosenProfile();
- ProfileChoiceMessage message = new ProfileChoiceMessage(chosenProfile);
- for (Observer<ProfileChoiceMessage> o : getObservers())
- try {
- o.notify(this, message);
- } catch (Exception e) {
- logger.error("failure when notifying about profile choice", e);
- }
- }
-
- public Profile getChosenProfile() {
- if (profileBox.getSelectedIndex() < 0)
- return null;
-
- return profileMap.get(profileBox.getSelectedItem());
- }
-
- private class ProfileUpdater extends SwingWorker<String, Object> {
- @Override
- protected String doInBackground() throws Exception {
- if (registry == null)
- return null;
- List<Profile> componentProfiles;
- try {
- componentProfiles = registry.getComponentProfiles();
- } catch (ComponentException e) {
- logger.error("failed to get profiles", e);
- throw e;
- } catch (NullPointerException e) {
- logger.error("failed to get profiles", e);
- throw e;
- }
- for (Profile profile : componentProfiles)
- try {
- profileMap.put(profile.getName(), profile);
- } catch (NullPointerException e) {
- logger.error("failure getting profile name", e);
- }
-
- return null;
- }
-
- @Override
- protected void done() {
- profileBox.removeAllItems();
- try {
- get();
- for (String name : profileMap.keySet())
- profileBox.addItem(name);
- if (!profileMap.isEmpty()) {
- String firstKey = profileMap.firstKey();
- profileBox.setSelectedItem(firstKey);
- setProfile(profileMap.get(firstKey));
- } else
- profileBox.addItem("No profiles available");
- } catch (InterruptedException | ExecutionException e) {
- logger.error(e);
- profileBox.addItem("Unable to read profiles");
- }
- profileBox.setEnabled(!profileMap.isEmpty());
- }
- }
-
- @Override
- public void addObserver(Observer<ProfileChoiceMessage> observer) {
- observers.add(observer);
- ProfileChoiceMessage message = new ProfileChoiceMessage(getChosenProfile());
- try {
- observer.notify(this, message);
- } catch (Exception e) {
- logger.error("failure when notifying about profile choice", e);
- }
- }
-
- @Override
- public void removeObserver(Observer<ProfileChoiceMessage> observer) {
- observers.remove(observer);
- }
-
- @Override
- public List<Observer<ProfileChoiceMessage>> getObservers() {
- return observers;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserComponentEntryPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserComponentEntryPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserComponentEntryPanel.java
deleted file mode 100644
index f9a8fbb..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserComponentEntryPanel.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-
-/**
- * @author alanrw
- */
-public class RegistryAndFamilyChooserComponentEntryPanel extends JPanel {
- private static final long serialVersionUID = -6675545311458594678L;
- private static final String T2FLOW = ".t2flow";
- private static final String WFBUNDLE = ".wfbundle";
-
- private JTextField componentNameField = new JTextField(20);
- private RegistryAndFamilyChooserPanel registryAndFamilyChooserPanel;
-
- public RegistryAndFamilyChooserComponentEntryPanel(ComponentPreference prefs) {
- super(new GridBagLayout());
- registryAndFamilyChooserPanel = new RegistryAndFamilyChooserPanel(prefs);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.gridwidth = 2;
- gbc.weightx = 1;
- this.add(registryAndFamilyChooserPanel, gbc);
- gbc.gridy = 1;
-
- gbc.gridwidth = 1;
- gbc.gridx = 0;
- gbc.weightx = 0;
- gbc.fill = GridBagConstraints.NONE;
- this.add(new JLabel("Component name:"), gbc);
- gbc.gridx = 1;
- gbc.weightx = 1;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- this.add(componentNameField, gbc);
- }
-
- public String getComponentName() {
- return componentNameField.getText();
- }
-
- public void setComponentName(String name) {
- componentNameField.setText(name);
- }
-
- public Version.ID getComponentVersionIdentification() {
- String componentName = getComponentName();
- Family familyChoice = registryAndFamilyChooserPanel.getChosenFamily();
- Registry registry = registryAndFamilyChooserPanel.getChosenRegistry();
-
- if (familyChoice == null || registry == null || componentName == null
- || componentName.isEmpty())
- return null;
-
- return new Version.Identifier(registry.getRegistryBase(),
- familyChoice.getName(), trim(componentName), -1);
- }
-
- private static String trim(String name) {
- if (name.endsWith(WFBUNDLE))
- return name.substring(0, name.length() - WFBUNDLE.length());
- else if (name.endsWith(T2FLOW))
- return name.substring(0, name.length() - T2FLOW.length());
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserPanel.java
deleted file mode 100644
index 8c81a1d..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryAndFamilyChooserPanel.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.util.List;
-
-import javax.swing.JPanel;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-
-/**
- * @author alanrw
- */
-public class RegistryAndFamilyChooserPanel extends JPanel implements
- Observer<ProfileChoiceMessage>, Observable<FamilyChoiceMessage> {
- private static Logger logger = getLogger(RegistryAndFamilyChooserPanel.class);
- private static final long serialVersionUID = -535518473593617735L;
- final RegistryChooserPanel registryPanel;
- final FamilyChooserPanel familyPanel;
-
- public RegistryAndFamilyChooserPanel(ComponentPreference prefs) {
- super(new GridBagLayout());
- registryPanel = new RegistryChooserPanel(prefs);
- familyPanel = new FamilyChooserPanel(registryPanel);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = WEST;
- gbc.fill = BOTH;
- gbc.gridwidth = 2;
- gbc.weightx = 1;
- add(registryPanel, gbc);
-
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.weighty = 1;
- add(familyPanel, gbc);
- }
-
- public Registry getChosenRegistry() {
- return registryPanel.getChosenRegistry();
- }
-
- public Family getChosenFamily() {
- return familyPanel.getChosenFamily();
- }
-
- @Override
- public void addObserver(Observer<FamilyChoiceMessage> observer) {
- familyPanel.addObserver(observer);
- }
-
- @Override
- public List<Observer<FamilyChoiceMessage>> getObservers() {
- return familyPanel.getObservers();
- }
-
- @Override
- public void removeObserver(Observer<FamilyChoiceMessage> observer) {
- familyPanel.removeObserver(observer);
- }
-
- @Override
- public void notify(Observable<ProfileChoiceMessage> sender,
- ProfileChoiceMessage message) {
- try {
- familyPanel.notify(sender, message);
- } catch (Exception e) {
- logger.error("problem handling notification about profile choice",
- e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChoiceMessage.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChoiceMessage.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChoiceMessage.java
deleted file mode 100644
index d03a0b0..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChoiceMessage.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import org.apache.taverna.component.api.Registry;
-
-/**
- * @author alanrw
- */
-public class RegistryChoiceMessage {
- private final Registry chosenRegistry;
-
- public RegistryChoiceMessage(Registry chosenRegistry) {
- this.chosenRegistry = chosenRegistry;
- }
-
- /**
- * @return the chosenRegistry
- */
- public Registry getChosenRegistry() {
- return chosenRegistry;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChooserPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChooserPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChooserPanel.java
deleted file mode 100644
index 0308d15..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/RegistryChooserPanel.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static java.awt.event.ItemEvent.SELECTED;
-import static net.sf.taverna.t2.component.ui.util.Utils.LONG_STRING;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.Vector;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Registry;
-
-/**
- * @author alanrw
- */
-public class RegistryChooserPanel extends JPanel implements
- Observable<RegistryChoiceMessage> {
- private static final String REGISTRY_LABEL = "Component registry:";
- private static final long serialVersionUID = 8390860727800654604L;
- private static final Logger logger = getLogger(RegistryChooserPanel.class);
-
- private final List<Observer<RegistryChoiceMessage>> observers = new ArrayList<>();
- private final JComboBox<String> registryBox;
- private final SortedMap<String, Registry> registryMap;
-
- public RegistryChooserPanel(ComponentPreference pref) {
- setLayout(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- registryMap = pref.getRegistryMap();
- registryBox = new JComboBox<>(new Vector<>(registryMap.keySet()));
- registryBox.setPrototypeDisplayValue(LONG_STRING);
- registryBox.setEditable(false);
-
- gbc.gridx = 0;
- gbc.anchor = WEST;
- this.add(new JLabel(REGISTRY_LABEL), gbc);
- gbc.gridx = 1;
- gbc.weightx = 1;
- gbc.fill = BOTH;
- this.add(registryBox, gbc);
-
- registryBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent event) {
- if (event.getStateChange() == SELECTED)
- dealWithSelection();
- }
- });
-
- String firstKey = registryMap.firstKey();
- registryBox.setSelectedItem(firstKey);
- dealWithSelection();
- }
-
- private void updateToolTipText() {
- String key = (String) registryBox.getSelectedItem();
- Registry registry = registryMap.get(key);
- registryBox.setToolTipText(registry.getRegistryBase().toString());
- }
-
- private void dealWithSelection() {
- updateToolTipText();
- Registry chosenRegistry = getChosenRegistry();
- RegistryChoiceMessage message = new RegistryChoiceMessage(
- chosenRegistry);
- for (Observer<RegistryChoiceMessage> o : getObservers())
- try {
- o.notify(this, message);
- } catch (Exception e) {
- logger.error("problem handling selection update", e);
- }
- }
-
- @Override
- public void addObserver(Observer<RegistryChoiceMessage> observer) {
- observers.add(observer);
- Registry chosenRegistry = getChosenRegistry();
- RegistryChoiceMessage message = new RegistryChoiceMessage(
- chosenRegistry);
- try {
- observer.notify(this, message);
- } catch (Exception e) {
- logger.error("problem handling addition of observer", e);
- }
- }
-
- @Override
- public List<Observer<RegistryChoiceMessage>> getObservers() {
- return observers;
- }
-
- @Override
- public void removeObserver(Observer<RegistryChoiceMessage> observer) {
- observers.remove(observer);
- }
-
- public Registry getChosenRegistry() {
- if (registryBox.getSelectedIndex() < 0)
- return null;
- return registryMap.get(registryBox.getSelectedItem());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SearchChoicePanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SearchChoicePanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SearchChoicePanel.java
deleted file mode 100644
index f68500e..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SearchChoicePanel.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.panel;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.WEST;
-import static java.awt.event.ItemEvent.SELECTED;
-import static net.sf.taverna.t2.component.ui.util.Utils.LONG_STRING;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutionException;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-
-/**
- * @author alanrw
- */
-@SuppressWarnings("serial")
-public class SearchChoicePanel extends JPanel {
- private static final Logger logger = getLogger(SearchChoicePanel.class);
- private static final String SEARCHING = "Searching...";
- private static final String[] SEARCHING_ARRAY = new String[] { SEARCHING };
- private static final String NO_MATCHES = "No matches";
- private static final String SEARCH_FAILED = "Search failed";
- private static final List<String> RESERVED_WORDS = Arrays.asList(SEARCHING,
- NO_MATCHES, SEARCH_FAILED);
-
- private ComponentPreference preference;//FIXME beaninject from constructor
- private ComponentFactory factory;//FIXME beaninject from constructor
- private Registry registry;
- private String prefixes;
- private String queryText;
- private JLabel registryURLLabel;
- private JComboBox<String> familyBox;
- private JComboBox<String> componentBox;
- private JComboBox<Object> versionBox;
-
- public SearchChoicePanel(Registry registry, String prefixes,
- String queryText) {
- super(new GridBagLayout());
- this.registry = registry;
- this.prefixes = prefixes;
- this.queryText = queryText;
-
- componentBox = new JComboBox<>(SEARCHING_ARRAY);
- componentBox.setPrototypeDisplayValue(LONG_STRING);
- familyBox = new JComboBox<>(SEARCHING_ARRAY);
- familyBox.setPrototypeDisplayValue(LONG_STRING);
- versionBox = new JComboBox<Object>(SEARCHING_ARRAY);
- versionBox.setPrototypeDisplayValue(LONG_STRING);
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- JLabel registryLabel = new JLabel("Component registry:");
-
- gbc.insets.left = 5;
- gbc.insets.right = 5;
- gbc.gridx = 0;
- gbc.anchor = WEST;
- gbc.fill = BOTH;
- gbc.gridwidth = 1;
- gbc.weightx = 1;
- gbc.gridy++;
- this.add(registryLabel, gbc);
- gbc.gridx = 1;
- registryURLLabel = new JLabel(SEARCHING);
- this.add(registryURLLabel, gbc);
- gbc.gridx = 0;
- gbc.gridy++;
- this.add(new JLabel("Component family:"), gbc);
- gbc.gridx = 1;
-
- this.add(familyBox, gbc);
- gbc.gridx = 0;
- gbc.gridy++;
- this.add(new JLabel("Component:"), gbc);
- gbc.gridx = 1;
- this.add(componentBox, gbc);
-
- gbc.gridx = 0;
- gbc.gridy++;
-
- this.add(new JLabel("Component version:"), gbc);
- gbc.gridx = 1;
- this.add(versionBox, gbc);
-
- new Searcher().execute();
- }
-
- private class Searcher extends SwingWorker<Set<Version.ID>, Object> {
- @Override
- protected Set<Version.ID> doInBackground() throws Exception {
- return registry.searchForComponents(prefixes, queryText);
- }
-
- @Override
- protected void done() {
- clearAll();
- try {
- Set<Version.ID> matches = get();
- if (matches.isEmpty())
- setAll(NO_MATCHES);
- else
- searchCompletedSuccessfully(matches);
- } catch (InterruptedException e) {
- logger.error("search was interrupted", e);
- setAll(SEARCH_FAILED);
- } catch (ExecutionException e) {
- logger.error("problem in execution", e.getCause());
- setAll(SEARCH_FAILED);
- }
- }
- }
-
- private void clearAll() {
- familyBox.removeAllItems();
- componentBox.removeAllItems();
- versionBox.removeAllItems();
- }
-
- private void setAll(String text) {
- registryURLLabel.setText(text);
- familyBox.addItem(text);
- componentBox.addItem(text);
- versionBox.addItem(text);
- }
-
- private String[] calculateMatchingFamilyNames(
- Set<Version.ID> matchingComponents) {
- Set<String> result = new TreeSet<>();
- for (Version.ID v : matchingComponents)
- result.add(v.getFamilyName());
- return result.toArray(new String[0]);
- }
-
- private void updateComponentBox(Set<Version.ID> matchingComponents,
- JComboBox<String> componentBox, String selectedItem) {
- componentBox.removeAllItems();
- String[] matchingComponentNames = calculateMatchingComponentNames(
- matchingComponents, selectedItem);
- for (String componentName : matchingComponentNames)
- componentBox.addItem(componentName);
- componentBox.setSelectedIndex(0);
- }
-
- private String[] calculateMatchingComponentNames(
- Set<Version.ID> matchingComponents, String familyName) {
- Set<String> result = new TreeSet<>();
- for (Version.ID v : matchingComponents)
- if (v.getFamilyName().equals(familyName))
- result.add(v.getComponentName());
- return result.toArray(new String[0]);
- }
-
- private void updateVersionBox(Set<Version.ID> matchingComponents,
- JComboBox<Object> versionBox, String componentName,
- String familyName) {
- versionBox.removeAllItems();
- for (Integer v : calculateMatchingVersionNumbers(matchingComponents,
- componentName, familyName))
- versionBox.addItem(v);
- versionBox.setSelectedIndex(0);
- }
-
- private Integer[] calculateMatchingVersionNumbers(
- Set<Version.ID> matchingComponents, String componentName,
- String familyName) {
- Set<Integer> result = new TreeSet<>();
- for (Version.ID v : matchingComponents)
- if (v.getFamilyName().equals(familyName)
- && v.getComponentName().equals(componentName))
- result.add(v.getComponentVersion());
- return result.toArray(new Integer[0]);
- }
-
- public Version.ID getVersionIdentification() {
- String registryString = registryURLLabel.getText();
- if (RESERVED_WORDS.contains(registryString))
- return null;
-
- try {
- return factory.getVersion(registry.getRegistryBase(),
- (String) familyBox.getSelectedItem(),
- (String) componentBox.getSelectedItem(),
- (Integer) versionBox.getSelectedItem()).getID();
- } catch (ComponentException e) {
- logger.warn(
- "unexpected failure to construct component version token",
- e);
- return null;
- }
- }
-
- private void searchCompletedSuccessfully(final Set<Version.ID> matches) {
- Version.ID one = (Version.ID) matches.toArray()[0];
- registryURLLabel.setText(preference.getRegistryName(one
- .getRegistryBase()));
- for (String familyName : calculateMatchingFamilyNames(matches))
- familyBox.addItem(familyName);
- familyBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == SELECTED)
- updateComponentBox(matches, componentBox,
- (String) familyBox.getSelectedItem());
- }
- });
- componentBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == SELECTED)
- updateVersionBox(matches, versionBox,
- (String) componentBox.getSelectedItem(),
- (String) familyBox.getSelectedItem());
- }
- });
- familyBox.setSelectedIndex(0);
- updateComponentBox(matches, componentBox,
- (String) familyBox.getSelectedItem());
- updateVersionBox(matches, versionBox,
- (String) componentBox.getSelectedItem(),
- (String) familyBox.getSelectedItem());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SharingPolicyChooserPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SharingPolicyChooserPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SharingPolicyChooserPanel.java
deleted file mode 100644
index 1519798..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/panel/SharingPolicyChooserPanel.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.ui.panel;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.NONE;
-import static java.awt.GridBagConstraints.WEST;
-import static net.sf.taverna.t2.component.ui.util.Utils.LONG_STRING;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.concurrent.ExecutionException;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.SwingWorker;
-
-import net.sf.taverna.t2.lang.observer.Observable;
-import net.sf.taverna.t2.lang.observer.Observer;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.SharingPolicy;
-
-/**
- * @author alanrw
- */
-public class SharingPolicyChooserPanel extends JPanel {
- private static final String SHARING_LABEL = "Sharing policy:";
- private static final String READING_MSG = "Reading sharing policies";
- private static final String NO_PERMISSIONS_MSG = "No permissions available";
- private static final long serialVersionUID = 2175274929391537032L;
- private static final Logger logger = getLogger(SharingPolicyChooserPanel.class);
-
- private final JComboBox<String> permissionBox = new JComboBox<>();
- private final SortedMap<String, SharingPolicy> permissionMap = new TreeMap<>();
- private Registry registry;
-
- public SharingPolicyChooserPanel(RegistryChooserPanel registryPanel) {
- this();
- registryPanel.addObserver(new Observer<RegistryChoiceMessage>(){
- @Override
- public void notify(Observable<RegistryChoiceMessage> sender,
- RegistryChoiceMessage message) throws Exception {
- try {
- registry = message.getChosenRegistry();
- updateProfileModel();
- } catch (Exception e) {
- logger.error("problem when handling notification of registry", e);
- }
- }
- });
- }
- public SharingPolicyChooserPanel() {
- super();
- permissionBox.setPrototypeDisplayValue(LONG_STRING);
- this.setLayout(new GridBagLayout());
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.anchor = WEST;
- gbc.fill = NONE;
- this.add(new JLabel(SHARING_LABEL), gbc);
- gbc.gridx = 1;
- gbc.weightx = 1;
- gbc.fill = BOTH;
- this.add(permissionBox, gbc);
-
- permissionBox.setEditable(false);
- }
-
- private void updateProfileModel() {
- permissionMap.clear();
- permissionBox.removeAllItems();
- permissionBox.addItem(READING_MSG);
- permissionBox.setEnabled(false);
- new SharingPolicyUpdater().execute();
- }
-
- public SharingPolicy getChosenPermission() {
- if (permissionBox.getSelectedIndex() < 0)
- return null;
- return permissionMap.get(permissionBox.getSelectedItem());
- }
-
- private class SharingPolicyUpdater extends SwingWorker<String, Object> {
- @Override
- protected String doInBackground() throws Exception {
- List<SharingPolicy> sharingPolicies;
- if (registry == null)
- return null;
- try {
- sharingPolicies = registry.getPermissions();
- if (sharingPolicies == null)
- return null;
- } catch (ComponentException e) {
- logger.error("problem getting permissions", e);
- throw e;
- } catch (NullPointerException e) {
- logger.error("null pointer getting permissions", e);
- throw e;
- }
-
- for (SharingPolicy policy : sharingPolicies)
- try {
- permissionMap.put(policy.getName(), policy);
- } catch (NullPointerException e) {
- logger.error("problem getting name of policy", e);
- }
- return null;
- }
-
- @Override
- protected void done() {
- permissionBox.removeAllItems();
- try {
- get();
- for (String name : permissionMap.keySet())
- permissionBox.addItem(name);
- if (!permissionMap.isEmpty()) {
- String firstKey = permissionMap.firstKey();
- permissionBox.setSelectedItem(firstKey);
- } else {
- permissionBox.addItem(NO_PERMISSIONS_MSG);
- }
- } catch (InterruptedException | ExecutionException e) {
- logger.error(e);
- permissionBox.addItem("Unable to read permissions");
- }
- permissionBox.setEnabled(!permissionMap.isEmpty());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferencePanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferencePanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferencePanel.java
deleted file mode 100644
index c0a278a..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferencePanel.java
+++ /dev/null
@@ -1,283 +0,0 @@
-package net.sf.taverna.t2.component.ui.preference;
-
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.CENTER;
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.WEST;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static javax.swing.JTable.AUTO_RESIZE_LAST_COLUMN;
-import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
-import static net.sf.taverna.t2.component.ui.util.Utils.URL_PATTERN;
-import static net.sf.taverna.t2.workbench.helper.Helper.showHelp;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.io.File;
-import java.awt.event.MouseEvent;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import javax.swing.AbstractAction;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JTextArea;
-import javax.swing.border.EmptyBorder;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-import net.sf.taverna.t2.lang.ui.ValidatingUserInputDialog;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Registry;
-
-public class ComponentPreferencePanel extends JPanel {
- private static final String BAD_URL_MESSAGE = "Invalid URL";
- private static final String SET_URL_MESSAGE = "Set the URL of the profile";
- private static final String HELP_LABEL = "Help";
- private static final String RESET_LABEL = "Reset";
- private static final String APPLY_LABEL = "Apply";
- private static final String ADD_REMOTE_TITLE = "Add Remote Component Registry";
- private static final String ADD_LOCAL_TITLE = "Add Local Component Registry";
- private static final String ADD_REMOTE_LABEL = "Add remote registry";
- private static final String ADD_LOCAL_LABEL = "Add local registry";
- private static final String REMOVE_LABEL = "Remove registry";
- private static final String TITLE = "Component registry management";
- private static final String VALIDATION_MESSAGE = "Set the registry name";
- private static final String EXCEPTION_MESSAGE = "Unable to access registry at ";
- private static final String EXCEPTION_TITLE = "Component registry problem";
- private static final String INVALID_NAME = "Invalid registry name";
- private static final String DUPLICATE = "Duplicate registry name";
- private static final long serialVersionUID = 1310173658718093383L;
-
- private final Logger logger = getLogger(ComponentPreferencePanel.class);
-
- private ComponentFactory factory;
- private ComponentPreference prefs;
- private RegistryTableModel tableModel = new RegistryTableModel();
-
- @SuppressWarnings("serial")
- private JTable registryTable = new JTable(tableModel) {
- @Override
- public String getToolTipText(MouseEvent me) {
- int row = rowAtPoint(me.getPoint());
- if (row >= 0)
- return tableModel.getRowTooltipText(row);
- return super.getToolTipText(me);
- }
- };
-
- public ComponentPreferencePanel(ComponentFactory componentFactory,
- ComponentPreference preferences) {
- super(new GridBagLayout());
- factory = componentFactory;
- prefs = preferences;
-
- GridBagConstraints gbc = new GridBagConstraints();
-
- // Title describing what kind of settings we are configuring here
- JTextArea descriptionText = new JTextArea(TITLE);
- descriptionText.setLineWrap(true);
- descriptionText.setWrapStyleWord(true);
- descriptionText.setEditable(false);
- descriptionText.setFocusable(false);
- descriptionText.setBorder(new EmptyBorder(10, 10, 10, 10));
- gbc.anchor = WEST;
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.gridwidth = 1;
- gbc.weightx = 1.0;
- gbc.weighty = 0.0;
- gbc.fill = HORIZONTAL;
- add(descriptionText, gbc);
-
- gbc.gridy++;
- gbc.insets = new Insets(10, 0, 0, 0);
-
- registryTable.getColumnModel().getColumn(0).setPreferredWidth(20);
- registryTable.setAutoResizeMode(AUTO_RESIZE_LAST_COLUMN);
- registryTable.setSelectionMode(SINGLE_SELECTION);
- JScrollPane scrollPane = new JScrollPane(registryTable);
- // registryTable.setFillsViewportHeight(true);
-
- gbc.weighty = 1.0;
- gbc.fill = BOTH;
-
- add(scrollPane, gbc);
-
- // Add buttons panel
- gbc.gridx = 0;
- gbc.gridy++;
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridwidth = 1;
- gbc.fill = HORIZONTAL;
- gbc.anchor = CENTER;
- gbc.insets = new Insets(10, 0, 0, 0);
- add(createRegistryButtonPanel(), gbc);
-
- // Add buttons panel
- gbc.gridx = 0;
- gbc.gridy++;
- gbc.weightx = 0.0;
- gbc.weighty = 0.0;
- gbc.gridwidth = 1;
- gbc.fill = HORIZONTAL;
- gbc.anchor = CENTER;
- gbc.insets = new Insets(10, 0, 0, 0);
- add(createButtonPanel(), gbc);
-
- setFields();
- }
-
- /**
- * Create the buttons for managing the list of registries.
- * @return
- */
- @SuppressWarnings("serial")
- private Component createRegistryButtonPanel() {
- JPanel panel = new JPanel();
- panel.add(new DeselectingButton(new AbstractAction(REMOVE_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- remove();
- }
- }));
- panel.add(new DeselectingButton(new AbstractAction(ADD_LOCAL_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- addLocal();
- }
- }));
- panel.add(new DeselectingButton(new AbstractAction(ADD_REMOTE_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- addRemote();
- }
- }));
- return panel;
- }
-
- /**
- * Create the panel to contain the buttons
- *
- * @return
- */
- @SuppressWarnings("serial")
- private JPanel createButtonPanel() {
- final JPanel panel = new JPanel();
- panel.add(new DeselectingButton(new AbstractAction(HELP_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- showHelp(panel);
- }
- }));
- panel.add(new DeselectingButton(new AbstractAction(RESET_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- setFields();
- }
- }));
- panel.add(new DeselectingButton(new AbstractAction(APPLY_LABEL) {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- applySettings();
- setFields();
- }
- }));
- return panel;
- }
-
- void remove() {
- int selectedRow = registryTable.getSelectedRow();
- if (selectedRow != -1)
- tableModel.removeRow(selectedRow);
- }
-
- void addLocal() {
- // Run the GUI
- LocalRegistryPanel inputPanel = new LocalRegistryPanel();
- ValidatingUserInputDialog vuid = new ValidatingUserInputDialog(
- ADD_LOCAL_TITLE, inputPanel);
- vuid.addTextComponentValidation(inputPanel.getRegistryNameField(),
- VALIDATION_MESSAGE, tableModel.getRegistryMap().keySet(),
- DUPLICATE, "[\\p{L}\\p{Digit}_.]+", INVALID_NAME);
- vuid.setSize(new Dimension(400, 250));
- if (!vuid.show(ComponentPreferencePanel.this))
- return;
-
- // Add the local registry
- String location = inputPanel.getLocationField().getText();
- File newDir = new File(location);
- try {
- tableModel.insertRegistry(inputPanel.getRegistryNameField()
- .getText(), getLocalRegistry(newDir));
- } catch (MalformedURLException e) {
- logger.error("bad url provided by user", e);
- showMessageDialog(null, EXCEPTION_MESSAGE + location,
- EXCEPTION_TITLE, ERROR_MESSAGE);
- } catch (ComponentException e) {
- logger.error("problem creating local registry", e);
- showMessageDialog(null, EXCEPTION_MESSAGE + location,
- EXCEPTION_TITLE, ERROR_MESSAGE);
- }
- }
-
- void addRemote() {
- RemoteRegistryPanel inputPanel = new RemoteRegistryPanel();
- ValidatingUserInputDialog vuid = new ValidatingUserInputDialog(
- ADD_REMOTE_TITLE, inputPanel);
- vuid.addTextComponentValidation(inputPanel.getRegistryNameField(),
- VALIDATION_MESSAGE, tableModel.getRegistryMap().keySet(),
- DUPLICATE, "[\\p{L}\\p{Digit}_.]+", INVALID_NAME);
- vuid.addTextComponentValidation(inputPanel.getLocationField(),
- SET_URL_MESSAGE, null, "", URL_PATTERN, BAD_URL_MESSAGE);
- vuid.setSize(new Dimension(400, 250));
- if (!vuid.show(ComponentPreferencePanel.this))
- return;
-
- String location = inputPanel.getLocationField().getText();
- try {
- tableModel.insertRegistry(inputPanel.getRegistryNameField()
- .getText(), getRemoteRegistry(location));
- } catch (MalformedURLException e) {
- logger.error("bad url provided by user", e);
- showMessageDialog(null, EXCEPTION_MESSAGE + location,
- EXCEPTION_TITLE, ERROR_MESSAGE);
- } catch (ComponentException e) {
- showMessageDialog(null, EXCEPTION_MESSAGE + location,
- EXCEPTION_TITLE, ERROR_MESSAGE);
- logger.error("problem creating remote registry", e);
- }
- }
-
- Registry getLocalRegistry(File location) throws ComponentException,
- MalformedURLException {
- return factory.getRegistry(location.toURI().toURL());
- }
-
- Registry getRemoteRegistry(String location) throws MalformedURLException,
- ComponentException {
- URL url = new URL(location);
- if (url.getProtocol() == null || url.getProtocol().equals("file"))
- throw new MalformedURLException(
- "may not use relative or local URLs for locating registry");
- return factory.getRegistry(url);
- }
-
- private void applySettings() {
- prefs.setRegistryMap(tableModel.getRegistryMap());
- }
-
- private void setFields() {
- tableModel.setRegistryMap(prefs.getRegistryMap());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferenceUIFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferenceUIFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferenceUIFactory.java
deleted file mode 100644
index 8b7bf19..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/ComponentPreferenceUIFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.preference;
-
-import javax.swing.JPanel;
-
-import uk.org.taverna.configuration.Configurable;
-import uk.org.taverna.configuration.ConfigurationUIFactory;
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-
-/**
- * @author alanrw
- */
-public class ComponentPreferenceUIFactory implements ConfigurationUIFactory {
- public static final String DISPLAY_NAME = "Components";
-
- private JPanel configPanel;//FIXME beaninject
- private ComponentPreference prefs;// FIXME beaninject
-
- public ComponentPreferenceUIFactory() {
- super();
- }
-
- public void setConfigPanel(JPanel configPanel) {
- this.configPanel = configPanel;
- }
-
- public void setPreferences(ComponentPreference pref) {
- this.prefs = pref;
- }
-
- @Override
- public boolean canHandle(String uuid) {
- return uuid.equals(prefs.getUUID());
- }
-
- @Override
- public Configurable getConfigurable() {
- return prefs;
- }
-
- @Override
- public JPanel getConfigurationPanel() {
- return configPanel;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/LocalRegistryPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/LocalRegistryPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/LocalRegistryPanel.java
deleted file mode 100644
index 8f86786..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/LocalRegistryPanel.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.preference;
-
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.NONE;
-import static java.awt.GridBagConstraints.WEST;
-import static javax.swing.JFileChooser.APPROVE_OPTION;
-import static javax.swing.JFileChooser.DIRECTORIES_ONLY;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.io.IOException;
-
-import javax.swing.AbstractAction;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.border.EmptyBorder;
-
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-
-import org.apache.log4j.Logger;
-
-/**
- * @author alanrw
- *
- */
-public class LocalRegistryPanel extends JPanel {
- private static final String BROWSE_LABEL = "Browse";
- private static final String LOCATION_LABEL = "Location:";
- private static final String NAME_LABEL = "Name:";
- private static final long serialVersionUID = 732945735813617327L;
-
- private final Logger logger = getLogger(LocalRegistryPanel.class);
-
- private JTextField registryNameField = new JTextField(20);
- private JTextField locationField = new JTextField(20);
-
- public LocalRegistryPanel() {
- super(new GridBagLayout());
-
- setBorder(new EmptyBorder(10, 10, 10, 10));
-
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.anchor = WEST;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.ipadx = 20;
- add(new JLabel(NAME_LABEL), constraints);
-
- constraints.gridx = 1;
- constraints.gridwidth = 2;
- constraints.ipadx = 0;
- constraints.weightx = 1d;
- constraints.fill = HORIZONTAL;
- add(registryNameField, constraints);
-
- constraints.gridy++;
- constraints.gridx = 0;
- constraints.ipadx = 20;
- constraints.fill = NONE;
- add(new JLabel(LOCATION_LABEL), constraints);
-
- constraints.gridx = 1;
- constraints.gridwidth = 2;
- constraints.ipadx = 0;
- constraints.weightx = 1d;
- constraints.fill = HORIZONTAL;
- add(locationField, constraints);
-
- constraints.gridy++;
- constraints.gridx = 0;
- constraints.ipadx = 20;
- constraints.fill = NONE;
- add(new DeselectingButton(new AbstractAction(BROWSE_LABEL) {
- private static final long serialVersionUID = -8676803966947261009L;
-
- @Override
- public void actionPerformed(ActionEvent arg0) {
- pickDirectory();
- }
- }), constraints);
- }
-
- private void pickDirectory() {
- JFileChooser chooser = new JFileChooser();
- chooser.setFileSelectionMode(DIRECTORIES_ONLY);
- int returnVal = chooser.showOpenDialog(LocalRegistryPanel.this);
- try {
- if (returnVal == APPROVE_OPTION)
- locationField.setText(chooser.getSelectedFile()
- .getCanonicalPath());
- } catch (IOException e) {
- logger.error("unexpected filesystem problem", e);
- }
- }
-
- /**
- * @return the registryNameField
- */
- public JTextField getRegistryNameField() {
- return registryNameField;
- }
-
- /**
- * @return the locationField
- */
- public JTextField getLocationField() {
- return locationField;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RegistryTableModel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RegistryTableModel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RegistryTableModel.java
deleted file mode 100644
index 1aa6084..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RegistryTableModel.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.preference;
-
-import static java.lang.String.format;
-
-import java.util.Map.Entry;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import javax.swing.table.DefaultTableModel;
-
-import org.apache.taverna.component.api.Registry;
-
-/**
- * @author alanrw
- *
- */
-public class RegistryTableModel extends DefaultTableModel {
- private static final long serialVersionUID = -7789666945764974370L;
- private SortedMap<String, Registry> registryMap = new TreeMap<String, Registry>();
-
- public RegistryTableModel() {
- super(new String[] { "Registry name", "Registry location" }, 0);
- }
-
- public void setRegistryMap(SortedMap<String, Registry> registries) {
- registryMap.clear();
- registryMap.putAll(registries);
- updateRows();
- }
-
- public void updateRows() {
- super.setRowCount(0);
- for (Entry<String, Registry> entry : registryMap.entrySet())
- super.addRow(new Object[] { entry.getKey(),
- entry.getValue().getRegistryBaseString() });
- }
-
- @Override
- public boolean isCellEditable(int row, int column) {
- return false;
- }
-
- public String getRowTooltipText(int row) {
- Registry registry = registryMap.get(getValueAt(row, 0));
- return format("This is a %s registry.", registry.getRegistryTypeName());
- }
-
- @Override
- public void removeRow(int row) {
- String key = (String) getValueAt(row, 0);
- registryMap.remove(key);
- super.removeRow(row);
- }
-
- public void insertRegistry(String name, Registry newRegistry) {
- registryMap.put(name, newRegistry);
- updateRows();
- }
-
- /**
- * @return the registryMap
- */
- public SortedMap<String, Registry> getRegistryMap() {
- return registryMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RemoteRegistryPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RemoteRegistryPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RemoteRegistryPanel.java
deleted file mode 100644
index 58962cc..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/preference/RemoteRegistryPanel.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.preference;
-
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.NONE;
-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;
-
-/**
- * @author alanrw
- *
- */
-public class RemoteRegistryPanel extends JPanel {
- private static final String LOCATION_LABEL = "Location:";
- private static final String NAME_LABEL = "Name:";
- private static final long serialVersionUID = 8833815753329010062L;
-
- private JTextField registryNameField = new JTextField(20);
- private JTextField locationField = new JTextField(20);
-
- public RemoteRegistryPanel() {
- super(new GridBagLayout());
-
- setBorder(new EmptyBorder(10, 10, 10, 10));
-
- GridBagConstraints constraints = new GridBagConstraints();
-
- constraints.anchor = WEST;
- constraints.gridx = 0;
- constraints.gridy = 0;
- constraints.ipadx = 20;
- add(new JLabel(NAME_LABEL), constraints);
-
- constraints.gridx = 1;
- constraints.gridwidth = 2;
- constraints.ipadx = 0;
- constraints.weightx = 1d;
- constraints.fill = HORIZONTAL;
- add(registryNameField, constraints);
-
- constraints.gridy++;
- constraints.gridx = 0;
- constraints.ipadx = 20;
- constraints.fill = NONE;
- add(new JLabel(LOCATION_LABEL), constraints);
-
- constraints.gridx = 1;
- constraints.gridwidth = 2;
- constraints.ipadx = 0;
- constraints.weightx = 1d;
- constraints.fill = HORIZONTAL;
- add(locationField, constraints);
- }
-
- /**
- * @return the registryNameField
- */
- public JTextField getRegistryNameField() {
- return registryNameField;
- }
-
- /**
- * @return the locationField
- */
- public JTextField getLocationField() {
- return locationField;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceDesc.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceDesc.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceDesc.java
deleted file mode 100644
index 35a945d..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceDesc.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package net.sf.taverna.t2.component.ui.serviceprovider;
-
-import static java.util.Arrays.asList;
-import static net.sf.taverna.t2.component.ui.ComponentConstants.ACTIVITY_URI;
-import static org.apache.log4j.Logger.getLogger;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.COMPONENT_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.COMPONENT_VERSION;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.FAMILY_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.REGISTRY_BASE;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.swing.Icon;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.servicedescriptions.ServiceDescription;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-import org.apache.taverna.component.api.Version.ID;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class ComponentServiceDesc extends ServiceDescription {
- private static Logger logger = getLogger(ComponentServiceDesc.class);
-
- private Version.ID identification;
- private final ComponentPreference preference;
- private final ComponentFactory factory;
- private final ComponentServiceIcon iconProvider;
-
- public ComponentServiceDesc(ComponentPreference preference,
- ComponentFactory factory, ComponentServiceIcon iconProvider,
- Version.ID identification) {
- this.preference = preference;
- this.factory = factory;
- this.identification = identification;
- this.iconProvider = iconProvider;
- }
-
- /**
- * The configuration bean which is to be used for configuring the
- * instantiated activity. This is built from the component identifier.
- */
- @Override
- public Configuration getActivityConfiguration() {
- Configuration config = new Configuration();
- installActivityConfiguration(config);
- return config;
- }
-
- /**
- * Make the given activity be configured to be using the component that this
- * class identifies.
- */
- public void installActivityConfiguration(Activity activity) {
- installActivityConfiguration(activity.getConfiguration());
- }
-
- /**
- * Update the given configuration to have the fields for the component that
- * this class identifies.
- */
- public void installActivityConfiguration(Configuration config) {
- ObjectNode c = config.getJsonAsObjectNode();
- ID id = getIdentification();
- c.put(REGISTRY_BASE, id.getRegistryBase().toExternalForm());
- c.put(FAMILY_NAME, id.getFamilyName());
- c.put(COMPONENT_NAME, id.getComponentName());
- c.put(COMPONENT_VERSION, id.getComponentVersion());
- config.setJson(c);
- }
-
- /**
- * An icon to represent this service description in the service palette.
- */
- @Override
- public Icon getIcon() {
- return iconProvider.getIcon();
- }
-
- /**
- * The display name that will be shown in service palette and will be used
- * as a template for processor name when added to workflow.
- */
- @Override
- public String getName() {
- return getIdentification().getComponentName();
- }
-
- /**
- * The path to this service description in the service palette. Folders will
- * be created for each element of the returned path.
- */
- @Override
- public List<String> getPath() {
- return asList("Components",
- preference.getRegistryName(identification.getRegistryBase()),
- identification.getFamilyName());
- }
-
- /**
- * Returns a list of data values uniquely identifying this component
- * description (i.e., no duplicates).
- */
- @Override
- protected List<? extends Object> getIdentifyingData() {
- return Arrays.asList(identification.getRegistryBase(),
- identification.getFamilyName(),
- identification.getComponentName());
- }
-
- @Override
- public String toString() {
- return "Component " + getName();
- }
-
- /**
- * @return the identification
- */
- public Version.ID getIdentification() {
- return identification;
- }
-
- /**
- * @param identification
- * the identification to set
- */
- public void setIdentification(Version.ID identification) {
- this.identification = identification;
- }
-
- public URL getHelpURL() {
- try {
- return factory.getVersion(getIdentification()).getHelpURL();
- } catch (ComponentException e) {
- logger.error(
- "failed to get component in order to determine its help URL",
- e);
- return null;
- }
- }
-
- @Override
- public URI getActivityType() {
- return ACTIVITY_URI;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceIcon.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceIcon.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceIcon.java
deleted file mode 100644
index 5b796b2..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceIcon.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.sf.taverna.t2.component.ui.serviceprovider;
-
-import static net.sf.taverna.t2.component.ui.serviceprovider.Service.COMPONENT_ACTIVITY_URI;
-
-import java.net.URI;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI;
-
-public class ComponentServiceIcon implements ActivityIconSPI {
- private static class Init {
- private static Icon icon = new ImageIcon(
- ComponentServiceIcon.class.getResource("/brick.png"));
- }
-
- @Override
- public int canProvideIconScore(URI activityType) {
- if (activityType.equals(COMPONENT_ACTIVITY_URI))
- return DEFAULT_ICON + 1;
- return NO_ICON;
- }
-
- @Override
- public Icon getIcon(URI activityType) {
- return Init.icon;
- }
-
- public Icon getIcon() {
- return Init.icon;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProvider.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProvider.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProvider.java
deleted file mode 100644
index 60294cd..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProvider.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package net.sf.taverna.t2.component.ui.serviceprovider;
-
-import static java.util.Arrays.asList;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static net.sf.taverna.t2.component.ui.ComponentConstants.ACTIVITY_URI;
-import static org.apache.log4j.Logger.getLogger;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.FAMILY_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.REGISTRY_BASE;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedMap;
-
-import javax.swing.Icon;
-
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.panel.RegistryAndFamilyChooserPanel;
-import net.sf.taverna.t2.component.ui.util.Utils;
-import net.sf.taverna.t2.servicedescriptions.AbstractConfigurableServiceProvider;
-import net.sf.taverna.t2.servicedescriptions.CustomizedConfigurePanelProvider;
-import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Component;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.common.Visitor;
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class ComponentServiceProvider extends
- AbstractConfigurableServiceProvider implements
- CustomizedConfigurePanelProvider {
- static final URI providerId = URI
- .create("http://taverna.sf.net/2012/service-provider/component");
- private static Logger logger = getLogger(ComponentServiceProvider.class);
-
- private final ComponentFactory factory;
- private final ComponentPreference prefs;
- private final ComponentServiceIcon iconProvider;
- private final Utils utils;
-
- public ComponentServiceProvider(ComponentFactory factory,
- ComponentPreference prefs, ComponentServiceIcon iconProvider,
- Utils utils) {
- super(makeConfig(null, null));
- this.factory = factory;
- this.prefs = prefs;
- this.iconProvider = iconProvider;
- this.utils = utils;
- }
-
- private static class Conf {
- URL registryBase;
- String familyName;
-
- Conf(Configuration config) throws MalformedURLException {
- ObjectNode node = config.getJsonAsObjectNode();
- JsonNode item = node.get(REGISTRY_BASE);
- if (item != null && !item.isNull())
- registryBase = URI.create(item.textValue()).toURL();
- item = node.get(FAMILY_NAME);
- if (item != null && !item.isNull())
- familyName = item.textValue();
- }
- }
-
- /**
- * Do the actual search for services. Return using the callBack parameter.
- */
- @Override
- public void findServiceDescriptionsAsync(
- FindServiceDescriptionsCallBack callBack) {
- Conf config;
-
- Registry registry;
- try {
- config = new Conf(getConfiguration());
- registry = factory.getRegistry(config.registryBase);
- } catch (ComponentException | MalformedURLException e) {
- logger.error("failed to get registry API", e);
- callBack.fail("Unable to read components", e);
- return;
- }
-
- try {
- List<ComponentServiceDesc> results = new ArrayList<>();
- for (Family family : registry.getComponentFamilies()) {
- // TODO get check on family name in there
- if (family.getName().equals(config.familyName))
- for (Component component : family.getComponents())
- try {
- SortedMap<Integer, Version> versions = component
- .getComponentVersionMap();
- ComponentServiceDesc newDesc = new ComponentServiceDesc(
- prefs, factory, iconProvider, versions.get(
- versions.lastKey()).getID());
- results.add(newDesc);
- } catch (Exception e) {
- logger.error("problem getting service descriptor",
- e);
- }
- callBack.partialResults(results);
- callBack.finished();
- }
- } catch (ComponentException e) {
- logger.error("problem querying registry", e);
- callBack.fail("Unable to read components", e);
- }
- }
-
- /**
- * Icon for service provider
- */
- @Override
- public Icon getIcon() {
- return iconProvider.getIcon();
- }
-
- /**
- * Name of service provider, appears in right click for 'Remove service
- * provider'
- */
- @Override
- public String getName() {
- return "Component service";
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- @Override
- public String getId() {
- return providerId.toASCIIString();
- }
-
- @Override
- protected List<? extends Object> getIdentifyingData() {
- try {
- Conf config = new Conf(getConfiguration());
- return asList(config.registryBase.toString(), config.familyName);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void createCustomizedConfigurePanel(
- CustomizedConfigureCallBack callBack) {
- RegistryAndFamilyChooserPanel panel = new RegistryAndFamilyChooserPanel(prefs);
-
- if (showConfirmDialog(null, panel, "Component family import",
- OK_CANCEL_OPTION) != OK_OPTION)
- return;
-
- Registry registry = panel.getChosenRegistry();
- Family family = panel.getChosenFamily();
- if (registry == null || family == null)
- return;
- callBack.newProviderConfiguration(makeConfig(
- registry.getRegistryBaseString(), family.getName()));
- }
-
- private static Configuration makeConfig(String registryUrl,
- String familyName) {
- ObjectNode cfg = JsonNodeFactory.instance.objectNode();
- cfg.put(REGISTRY_BASE, registryUrl);
- cfg.put(FAMILY_NAME, familyName);
- Configuration conf = new Configuration();
- conf.setJson(cfg);
- conf.setType(providerId);
- return conf;
- }
-
- @Override
- public ServiceDescriptionProvider newInstance() {
- return new ComponentServiceProvider(factory, prefs, iconProvider, utils);
- }
-
- @Override
- public URI getType() {
- return ACTIVITY_URI;
- }
-
- @Override
- public void setType(URI type) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean accept(Visitor visitor) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void refreshProvidedComponent(Version.ID ident) {
- try {
- utils.refreshComponentServiceProvider(new ComponentServiceProviderConfig(
- ident).getConfiguration());
- } catch (Exception e) {
- logger.error("Unable to refresh service panel", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProviderConfig.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProviderConfig.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProviderConfig.java
deleted file mode 100644
index 9f6f52d..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/ComponentServiceProviderConfig.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package net.sf.taverna.t2.component.ui.serviceprovider;
-
-import static net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceProvider.providerId;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.FAMILY_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.REGISTRY_BASE;
-
-import java.net.URL;
-
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-
-public class ComponentServiceProviderConfig {
- private URL registryBase;
- private String familyName;
-
- public ComponentServiceProviderConfig() {
- }
-
- public ComponentServiceProviderConfig(Family family) {
- registryBase = family.getComponentRegistry().getRegistryBase();
- familyName = family.getName();
- }
-
- public ComponentServiceProviderConfig(Version.ID ident) {
- registryBase = ident.getRegistryBase();
- familyName = ident.getFamilyName();
- }
-
- /**
- * @return the registryBase
- */
- public URL getRegistryBase() {
- return registryBase;
- }
-
- /**
- * @param registryBase
- * the registryBase to set
- */
- public void setRegistryBase(URL registryBase) {
- this.registryBase = registryBase;
- }
-
- /**
- * @return the familyName
- */
- public String getFamilyName() {
- return familyName;
- }
-
- /**
- * @param familyName
- * the familyName to set
- */
- public void setFamilyName(String familyName) {
- this.familyName = familyName;
- }
-
- public Configuration getConfiguration() {
- Configuration c = new Configuration();
- c.getJsonAsObjectNode().put(REGISTRY_BASE,
- registryBase.toExternalForm());
- c.getJsonAsObjectNode().put(FAMILY_NAME, familyName);
- c.setType(providerId);
- return c;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/Service.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/Service.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/Service.java
deleted file mode 100644
index af8ddb6..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/serviceprovider/Service.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package net.sf.taverna.t2.component.ui.serviceprovider;
-
-import java.net.URI;
-
-public interface Service {
- URI COMPONENT_ACTIVITY_URI = URI
- .create("http://ns.taverna.org.uk/2010/activity/component");
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentFileType.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentFileType.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentFileType.java
deleted file mode 100644
index b03296a..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentFileType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package net.sf.taverna.t2.component.ui.util;
-
-import net.sf.taverna.t2.workbench.file.FileType;
-
-/**
- * The type of components.
- *
- * @author alanrw
- */
-public class ComponentFileType extends FileType {
- // TODO Change mimetype for sculf2?
- static final String COMPONENT_MIMETYPE = "application/vnd.taverna.component";
-
- private ComponentFileType() {
- }
-
- @Override
- public String getDescription() {
- return "Taverna component";
- }
-
- // Not really used
- @Override
- public String getExtension() {
- return "component";
- }
-
- @Override
- public String getMimeType() {
- return COMPONENT_MIMETYPE;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentHealthCheck.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentHealthCheck.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentHealthCheck.java
deleted file mode 100644
index 2a36fc3..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/ComponentHealthCheck.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package net.sf.taverna.t2.component.ui.util;
-
-import static org.apache.log4j.Logger.getLogger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.component.ui.ComponentActivityConfigurationBean;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.Visitor;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.validation.correctness.DefaultDispatchingVisitor;
-
-public class ComponentHealthCheck extends VisitKind {
- public static final int NO_PROBLEM = 0;
- public static final int OUT_OF_DATE = 10;
- public static final int NON_SHAREABLE = 20;
- public static final int FAILS_PROFILE = 30;
- private static Logger logger = getLogger(ComponentHealthCheck.class);
- private static final String OUTDATED_MSG = "Component out of date";
-
- private ComponentFactory factory;
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public List<Object> checkForOutdatedComponents(WorkflowBundle bundle) {
- UpgradeChecker uc = new UpgradeChecker();
- bundle.accept(uc);
- return uc.warnings;
- }
-
- private class UpgradeChecker extends DefaultDispatchingVisitor {
- ComponentFactory factory;
- List<Object> warnings = new ArrayList<>();
-
- @Override
- public void visitActivity(Activity activity) {
- ComponentActivityConfigurationBean config = new ComponentActivityConfigurationBean(
- activity.getConfiguration().getJson(), factory);
- Version v;
- try {
- v = config.getVersion();
- } catch (ComponentException e) {
- logger.error("failed to get component description", e);
- warnings.add(e);//FIXME Just putting the exception in here isn't good
- return;
- }
- visitComponent(activity, v);
- }
- protected void visitComponent(Activity activity, Version version) {
- int latest = version.getComponent().getComponentVersionMap().lastKey();
- if (latest > version.getVersionNumber())
- warnings.add(new VisitReport(ComponentHealthCheck.this,
- activity, OUTDATED_MSG, OUT_OF_DATE,
- VisitReport.Status.WARNING));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/Utils.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/Utils.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/Utils.java
deleted file mode 100644
index ebd7c36..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/util/Utils.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.ui.util;
-
-import static net.sf.taverna.t2.component.ui.ComponentConstants.ACTIVITY_URI;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.Named;
-import uk.org.taverna.scufl2.api.common.NamedSet;
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import net.sf.taverna.t2.component.preference.ComponentPreference;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceIcon;
-import net.sf.taverna.t2.component.ui.serviceprovider.ComponentServiceProvider;
-import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-/**
- * @author alanrw
- */
-public class Utils {
- // From http://stackoverflow.com/questions/163360/regular-expresion-to-match-urls-in-java
- public static String URL_PATTERN = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
- public static final String LONG_STRING = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
- public static final String SHORT_STRING = "XXX";
-
- private FileManager fileManager;
- private ServiceDescriptionRegistry registry;
- private ComponentFactory factory;
- private ComponentPreference prefs;
- private ComponentServiceIcon icon;
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- public void setIcon(ComponentServiceIcon icon) {
- this.icon = icon;
- }
-
- public void setPrefs(ComponentPreference prefs) {
- this.prefs = prefs;
- }
-
- public void setRegistry(ServiceDescriptionRegistry registry) {
- this.registry = registry;
- }
-
- public void refreshComponentServiceProvider(Configuration config) {
- ComponentServiceProvider provider = new ComponentServiceProvider(
- factory, prefs, icon, this);
- provider.configure(config);
- registry.removeServiceDescriptionProvider(provider);
- registry.addServiceDescriptionProvider(provider);
- }
-
- public void removeComponentServiceProvider(Configuration config) {
- ComponentServiceProvider provider = new ComponentServiceProvider(
- factory, prefs, icon, this);
- provider.configure(config);
- registry.removeServiceDescriptionProvider(provider);
- }
-
- public boolean dataflowIsComponent(WorkflowBundle d) {
- if (d == null)
- return false;
- Object dataflowSource = fileManager.getDataflowSource(d);
- return dataflowSource instanceof Version.ID;// FIXME Really?
- }
-
- public boolean currentDataflowIsComponent() {
- return dataflowIsComponent(fileManager.getCurrentDataflow());
- }
-
- public static boolean isComponentActivity(Object obj) {
- if (obj == null || !(obj instanceof Activity))
- return false;
- Configuration cfg = ((Activity) obj).getConfiguration();
- return cfg != null && ACTIVITY_URI.equals(cfg.getType());
- }
-
- private static final Pattern SANITIZER_RE = Pattern
- .compile("[^a-zA-Z0-9]+");
- private static final Pattern SUFFIXED_RE = Pattern
- .compile("^(.+)_([0-9]+)$");
-
- /**
- * Pick a name that is unique within the context set. This is done by
- * appending "<tt>_<i>n</i></tt>" as necessary, where <tt><i>n</i></tt> is a
- * number.
- *
- * @param name
- * The suggested name; this is always checked first.
- * @param context
- * The set of things that the name will have to be unique within.
- * @return A name that is definitely not the name of anything in the given
- * set.
- */
- public static String uniqueName(String name, NamedSet<? extends Named> context) {
- String candidate = SANITIZER_RE.matcher(name).replaceAll("_");
- if (context.getByName(candidate) == null)
- return candidate;
- int counter = 0;
- String prefix = candidate;
- Matcher m = SUFFIXED_RE.matcher(candidate);
- if (m.matches()) {
- prefix = m.group(1);
- counter = Integer.parseInt(m.group(2));
- }
- do {
- candidate = prefix + "_" + (++counter);
- } while (context.getByName(candidate) != null);
- return candidate;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/view/ComponentActivityContextViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/view/ComponentActivityContextViewFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/view/ComponentActivityContextViewFactory.java
deleted file mode 100644
index 80b8640..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/ui/view/ComponentActivityContextViewFactory.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package net.sf.taverna.t2.component.ui.view;
-
-import static org.apache.taverna.component.api.config.ComponentConfig.URI;
-
-import java.awt.Frame;
-import java.net.MalformedURLException;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.swing.Action;
-
-import org.apache.taverna.component.api.ComponentFactory;
-
-import uk.org.taverna.commons.services.ServiceRegistry;
-import uk.org.taverna.scufl2.api.activity.Activity;
-import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry;
-import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
-import net.sf.taverna.t2.workbench.configuration.colour.ColourManager;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory;
-import net.sf.taverna.t2.component.ui.config.ComponentConfigureAction;
-
-public class ComponentActivityContextViewFactory implements
- ContextualViewFactory<Activity> {
- private ColourManager colourManager;
- private ViewUtil util;
- private ComponentFactory factory;
- private ActivityIconManager aim;
- private ServiceDescriptionRegistry sdr;
- private EditManager em;
- private FileManager fm;
- private ServiceRegistry sr;
-
- public void setComponentFactory(ComponentFactory factory) {
- this.factory = factory;
- }
-
- public void setColourManager(ColourManager colourManager) {
- this.colourManager = colourManager;
- }
-
- public void setViewUtils(ViewUtil util) {
- this.util = util;
- }
-
- public void setIconManager(ActivityIconManager aim) {
- this.aim = aim;
- }
-
- public void setServiceDescriptionRegistry(ServiceDescriptionRegistry sdr) {
- this.sdr = sdr;
- }
-
- public void setEditManager(EditManager em) {
- this.em = em;
- }
-
- public void setFileManager(FileManager fm) {
- this.fm = fm;
- }
-
- public void setServiceTypeRegistry(ServiceRegistry sr) {
- this.sr = sr;
- }
-
- @Override
- public boolean canHandle(Object selection) {
- return selection instanceof Activity
- && ((Activity) selection).getType().equals(URI);
- }
-
- @Override
- public List<ContextualView> getViews(Activity selection) {
- return Arrays.<ContextualView>asList(new ComponentActivityContextualView(selection));
- }
-
- @SuppressWarnings("serial")
- private class ComponentActivityContextualView extends
- HTMLBasedActivityContextualView {
- public ComponentActivityContextualView(Activity activity) {
- super(activity, colourManager);
- init();
- }
-
- private void init() {
- }
-
- @Override
- public String getViewTitle() {
- return "Component service";
- }
-
- /**
- * View position hint
- */
- @Override
- public int getPreferredPosition() {
- // We want to be on top
- return 100;
- }
-
- @Override
- public Action getConfigureAction(Frame owner) {
- return new ComponentConfigureAction(getActivity(), owner, factory,
- aim, sdr, em, fm, sr);
- }
-
- @Override
- protected String getRawTableRowsHtml() {
- try {
- return util.getRawTablesHtml(getConfigBean());
- } catch (MalformedURLException e) {
- return "<tr><td>malformed URL: <pre>" + e.getMessage()
- + "</pre></td></tr>";
- }
- }
- }
-}