http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProvider.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProvider.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProvider.java new file mode 100644 index 0000000..c9d7c59 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProvider.java @@ -0,0 +1,227 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.servicedescriptions; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.Icon; +import javax.wsdl.Operation; +import javax.wsdl.WSDLException; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.taverna.activities.wsdl.WSDLActivityHealthChecker; +import org.apache.taverna.lang.observer.Observable; +import org.apache.taverna.lang.observer.Observer; +import org.apache.taverna.security.credentialmanager.CredentialManager; +import org.apache.taverna.servicedescriptions.AbstractConfigurableServiceProvider; +import org.apache.taverna.servicedescriptions.CustomizedConfigurePanelProvider; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.servicedescriptions.events.RemovedProviderEvent; +import org.apache.taverna.servicedescriptions.events.ServiceDescriptionRegistryEvent; +import org.apache.taverna.wsdl.parser.UnknownOperationException; +import org.apache.taverna.wsdl.parser.WSDLParser; + +import org.apache.log4j.Logger; +import org.apache.taverna.servicedescriptions.CustomizedConfigurePanelProvider.CustomizedConfigureCallBack; +import org.apache.taverna.servicedescriptions.ServiceDescriptionProvider.FindServiceDescriptionsCallBack; +import org.xml.sax.SAXException; + +public class WSDLServiceProvider extends + AbstractConfigurableServiceProvider<WSDLServiceProviderConfig> implements + CustomizedConfigurePanelProvider<WSDLServiceProviderConfig> { + + private static Logger logger = Logger.getLogger(WSDLServiceProvider.class); + + private static final URI providerId = URI + .create("http://taverna.sf.net/2010/service-provider/wsdl"); + + private CredentialManager credentialManager; + + public static class FlushWSDLCacheOnRemovalObserver implements + Observer<ServiceDescriptionRegistryEvent> { + public void notify( + Observable<ServiceDescriptionRegistryEvent> registry, + ServiceDescriptionRegistryEvent event) throws Exception { + if (!(event instanceof RemovedProviderEvent)) { + return; + } + RemovedProviderEvent removedProviderEvent = (RemovedProviderEvent) event; + if (!(removedProviderEvent.getProvider() instanceof WSDLServiceProvider)) { + return; + } + WSDLServiceProvider serviceProvider = (WSDLServiceProvider) removedProviderEvent + .getProvider(); + URI wsdlLocation = serviceProvider.getConfiguration().getURI(); + WSDLParser.flushCache(wsdlLocation.toASCIIString()); + logger.info("Flushed cache for WSDL " + wsdlLocation); + } + } + + private static final String WSDL_SERVICE = "WSDL service"; + + private static FlushWSDLCacheOnRemovalObserver flushObserver = new FlushWSDLCacheOnRemovalObserver(); + + private ServiceDescriptionRegistry serviceDescriptionRegistry; + + public WSDLServiceProvider() { + super(new WSDLServiceProviderConfig("http://somehost/service?wsdl")); + } + + public String getName() { + return WSDL_SERVICE; + } + + public List<WSDLServiceProviderConfig> getDefaultConfigurations() { + + List<WSDLServiceProviderConfig> defaults = new ArrayList<WSDLServiceProviderConfig>(); + + // If defaults have failed to load from a configuration file then load them here. + if (!serviceDescriptionRegistry.isDefaultSystemConfigurableProvidersLoaded()){ + // 2009-12-16: 503 server error + defaults.add(new WSDLServiceProviderConfig( + "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl")); + defaults.add(new WSDLServiceProviderConfig( + "http://soap.bind.ca/wsdl/bind.wsdl")); + defaults.add(new WSDLServiceProviderConfig( + "http://www.ebi.ac.uk/ws/services/urn:Dbfetch?wsdl")); + } // else return an empty list + + return defaults; + } + + public void findServiceDescriptionsAsync( + FindServiceDescriptionsCallBack callBack) { + + URI wsdl = serviceProviderConfig.getURI(); + + callBack.status("Parsing wsdl:" + wsdl); + WSDLParser parser = null; + try { + parser = new WSDLParser(wsdl.toASCIIString()); + List<Operation> operations = parser.getOperations(); + callBack.status("Found " + operations.size() + " WSDL operations:" + + wsdl); + List<WSDLServiceDescription> items = new ArrayList<WSDLServiceDescription>(); + for (Operation op : operations) { + WSDLServiceDescription item = new WSDLServiceDescription(credentialManager); + try { + String name = op.getName(); + item.setOperation(name); + String use = parser.getUse(name); + String style = parser.getStyle(); + if (!WSDLActivityHealthChecker.checkStyleAndUse(style, use)) { + logger.warn("Unsupported style and use combination " + style + "/" + use + " for operation " + name + " from " + wsdl); + continue; + } + item.setUse(use); + item.setStyle(style); + item.setURI(wsdl); + item.setDescription(parser.getOperationDocumentation(name)); + items.add(item); + } catch (UnknownOperationException e) { + String message = "Encountered an unexpected operation name:" + + item.getOperation(); + callBack.fail(message, e); + } + } + callBack.partialResults(items); + callBack.finished(); + } catch (ParserConfigurationException e) { + String message = "Error configuring the WSDL parser"; + callBack.fail(message, e); + } catch (WSDLException e) { + String message = "There was an error with the wsdl: " + wsdl; + callBack.fail(message, e); + } catch (IOException e) { + String message = "There was an IO error parsing the wsdl: " + wsdl + + " Possible reason: the wsdl location was incorrect."; + callBack.fail(message, e); + } catch (SAXException e) { + String message = "There was an error with the XML in the wsdl: " + + wsdl; + callBack.fail(message, e); + } catch (IllegalArgumentException e) { // a problem with the wsdl url + String message = "There was an error with the wsdl: " + wsdl + " " + + "Possible reason: the wsdl location was incorrect."; + callBack.fail(message, e); + } catch (Exception e) { // anything else we did not expect + String message = "There was an error with the wsdl: " + wsdl; + callBack.fail(message, e); + } + } + + @Override + public String toString() { + return getName() + " " + getConfiguration().getURI(); + } + + public Icon getIcon() { + return WSDLActivityIcon.getWSDLIcon(); + } + + @Override + protected List<? extends Object> getIdentifyingData() { + List<String> result; + result = Arrays.asList(getConfiguration().getURI().toString()); + return result; + } + + /** + * Will be set by ServiceDescriptionRegistryImpl + * + * @param registry Registry this provider has been added to + */ + public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + synchronized (flushObserver) { + // Add the (static common) observer if the registry does not have it + if (!serviceDescriptionRegistry.getObservers().contains(flushObserver)) { + serviceDescriptionRegistry.addObserver(flushObserver); + } + } + } + + @SuppressWarnings("serial") + public void createCustomizedConfigurePanel(final CustomizedConfigureCallBack<WSDLServiceProviderConfig> callBack) { + + AddWSDLServiceDialog addWSDLServiceDialog = new AddWSDLServiceDialog() { + @Override + protected void addRegistry(String wsdlURL) { + + WSDLServiceProviderConfig providerConfig = new WSDLServiceProviderConfig(wsdlURL); + callBack.newProviderConfiguration(providerConfig); + } + }; + addWSDLServiceDialog.setVisible(true); + } + + public String getId() { + return providerId.toString(); + } + + public void setCredentialManager(CredentialManager credentialManager) { + this.credentialManager = credentialManager; + } + +}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java new file mode 100644 index 0000000..465de26 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java @@ -0,0 +1,51 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.servicedescriptions; + +import java.net.URI; + +import org.apache.taverna.lang.beans.PropertyAnnotated; +import org.apache.taverna.lang.beans.PropertyAnnotation; + +public class WSDLServiceProviderConfig extends PropertyAnnotated { + private URI uri; + + public WSDLServiceProviderConfig() { + } + + public WSDLServiceProviderConfig(String uri) { + this.uri = URI.create(uri); + } + + @PropertyAnnotation(displayName = "WSDL location", preferred = true) + public URI getURI() { + return uri; + } + + public void setURI(URI uri) { + this.uri = uri; + } + + @Override + public String toString() { + return getURI().toASCIIString(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java new file mode 100644 index 0000000..bfd2ba0 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java @@ -0,0 +1,62 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.servicedescriptions; + +import java.net.URI; + +import javax.swing.Icon; +import javax.swing.ImageIcon; + +import org.apache.taverna.workbench.activityicons.ActivityIconSPI; + +/** + * + * @author Alex Nenadic + * + */ +public class XMLInputSplitterActivityIcon implements ActivityIconSPI{ + + private static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/in"); + + private static Icon icon = null; + + public int canProvideIconScore(URI activityType) { + if (activityType.equals(ACTIVITY_TYPE)) + return DEFAULT_ICON + 1; + else + return NO_ICON; + } + + public Icon getIcon(URI activityType) { + return getXMLOutputSplitterIcon(); + } + + public static Icon getXMLOutputSplitterIcon() { + if (icon == null) { + icon = new ImageIcon(XMLOutputSplitterActivityIcon.class.getResource("/xml-splitter.png")); + } + return icon; + } + +} + + + + http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java new file mode 100644 index 0000000..edc5fe6 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java @@ -0,0 +1,63 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.servicedescriptions; + +import java.net.URI; + +import javax.swing.Icon; +import javax.swing.ImageIcon; + +import org.apache.taverna.workbench.activityicons.ActivityIconSPI; + +/** + * + * @author Alex Nenadic + * + */ +public class XMLOutputSplitterActivityIcon implements ActivityIconSPI{ + + private static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/out"); + + private static Icon icon = null; + + public int canProvideIconScore(URI activityType) { + if (activityType.equals(ACTIVITY_TYPE)) + return DEFAULT_ICON + 1; + else + return NO_ICON; + } + + public Icon getIcon(URI activityType) { + return getXMLOutputSplitterIcon(); + } + + public static Icon getXMLOutputSplitterIcon() { + if (icon == null) { + icon = new ImageIcon(XMLOutputSplitterActivityIcon.class.getResource("/xml-splitter.png")); + } + return icon; + } + +} + + + + + http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/AbstractXMLSplitterActionView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/AbstractXMLSplitterActionView.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/AbstractXMLSplitterActionView.java new file mode 100644 index 0000000..58436d5 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/AbstractXMLSplitterActionView.java @@ -0,0 +1,178 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.io.IOException; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.wsdl.WSDLException; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.taverna.activities.wsdl.actions.AbstractAddXMLSplitterAction; +import org.apache.taverna.activities.wsdl.actions.AddXMLInputSplitterAction; +import org.apache.taverna.activities.wsdl.actions.AddXMLOutputSplitterAction; +import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceDescription; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.ui.actions.activity.HTMLBasedActivityContextualView; +import org.apache.taverna.wsdl.parser.TypeDescriptor; +import org.apache.taverna.wsdl.parser.UnknownOperationException; + +import org.apache.log4j.Logger; +import org.jdom.JDOMException; +import org.xml.sax.SAXException; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.port.DepthPort; +import org.apache.taverna.scufl2.api.port.InputActivityPort; +import org.apache.taverna.scufl2.api.port.OutputActivityPort; + +@SuppressWarnings("serial") +public abstract class AbstractXMLSplitterActionView extends HTMLBasedActivityContextualView { + + private static Logger logger = Logger.getLogger(AbstractXMLSplitterActionView.class); + protected final EditManager editManager; + protected final SelectionManager selectionManager; + protected AbstractAddXMLSplitterAction splitterAction; + + public AbstractXMLSplitterActionView(Activity activity, EditManager editManager, + SelectionManager selectionManager, ColourManager colourManager) { + super(activity, colourManager); + this.editManager = editManager; + this.selectionManager = selectionManager; + if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { + splitterAction = new AddXMLOutputSplitterAction(getActivity(), + null, editManager, selectionManager); + } else if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { + splitterAction = new AddXMLInputSplitterAction(getActivity(), + null, editManager, selectionManager); + } + super.initView(); + } + + @Override + public void initView() { + } + + protected void addOutputSplitter(final JComponent mainFrame, JPanel flowPanel) { + if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { + try { + Map<String, TypeDescriptor> descriptors = splitterAction.getTypeDescriptors(); + if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) { + flowPanel.add(new JButton(splitterAction)); + } + } catch (UnknownOperationException | IOException | ParserConfigurationException + | WSDLException | SAXException | JDOMException e) { + logger.warn("Could not find type descriptors for " + getActivity(), e); + } + } + } + + protected void addInputSplitter(final JComponent mainFrame, JPanel flowPanel) { + if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { + try { + Map<String, TypeDescriptor> descriptors = splitterAction.getTypeDescriptors(); + if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) { + splitterAction.setOwner(mainFrame); + flowPanel.add(new JButton(splitterAction)); + } + } catch (UnknownOperationException | IOException | ParserConfigurationException + | WSDLException | SAXException | JDOMException e) { + logger.warn("Could not find type descriptors for " + getActivity(), e); + } + } + } + + protected String describePorts() { + StringBuilder html = new StringBuilder(); + + if (!getActivity().getInputPorts().isEmpty()) { + html.append("<tr><th colspan='2' align='left'>Inputs</th></tr>"); + for (InputActivityPort port : getActivity().getInputPorts()) { + TypeDescriptor descriptor = null; + if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { + try { + descriptor = splitterAction.getTypeDescriptors().get(port.getName()); + } catch (UnknownOperationException | IOException | ParserConfigurationException + | WSDLException | SAXException | JDOMException e) { + logger.warn("Could not find type descriptors for " + getActivity(), e); + } + } + if (descriptor == null) { + html.append(describePort(port)); + } else { + html.append(describePort(port, descriptor)); + } + + } + } + + if (!getActivity().getOutputPorts().isEmpty()) { + html.append("<tr><th colspan='2' align='left'>Outputs</th></tr>"); + for (OutputActivityPort port : getActivity().getOutputPorts()) { + TypeDescriptor descriptor = null; + if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { + try { + descriptor = splitterAction.getTypeDescriptors().get(port.getName()); + } catch (UnknownOperationException | IOException | ParserConfigurationException + | WSDLException | SAXException | JDOMException e) { + logger.warn("Could not find type descriptors for " + getActivity(), e); + } + } + if (descriptor == null) { + html.append(describePort(port)); + } else { + html.append(describePort(port, descriptor)); + } + } + } + + return html.toString(); + } + + private String describePort(DepthPort port, TypeDescriptor descriptor) { + String html = "<tr><td>" + port.getName() + "</td><td>"; + if (descriptor != null && descriptor.isOptional()) { + html += "<em>optional</em><br>"; + } + html+="Depth:"+port.getDepth()+"<br>"; + if (descriptor != null ) { + html+="<code>"+descriptor.getQname().toString()+"</code><br>"; +// if (descriptor.getDocumentation() != null && !descriptor.getDocumentation().isEmpty()){ +// html += "<p>"+descriptor.getDocumentation()+"</p>"; +// } + } + + html+="</td></tr>"; + return html; + } + + private String describePort(DepthPort port) { + String html = "<tr><td>" + port.getName() + "</td><td>"; + html += "Depth:" + port.getDepth() + "<br>"; + html += "</td></tr>"; + return html; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityConfigurationView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityConfigurationView.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityConfigurationView.java new file mode 100644 index 0000000..59470f7 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityConfigurationView.java @@ -0,0 +1,445 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.net.URI; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.SwingConstants; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import javax.swing.plaf.basic.BasicComboBoxRenderer; + +import org.apache.taverna.activities.wsdl.security.SecurityProfiles; +import org.apache.taverna.lang.ui.DialogTextArea; +import org.apache.taverna.security.credentialmanager.CredentialManager; +import org.apache.taverna.workbench.ui.credentialmanager.CredentialManagerUI; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel; +import org.apache.taverna.scufl2.api.activity.Activity; + +/** + * Configuration dialog for WSDL activity. + * + * @author Alex Nenadic + */ +@SuppressWarnings("serial") +public class WSDLActivityConfigurationView extends ActivityConfigurationPanel implements ItemListener { + + private CredentialManager credentialManager; + private CredentialManagerUI credManagerUI; + + private ButtonGroup buttonGroup; + private JRadioButton noSecurityRadioButton; + private JLabel noSecurityLabel; + private JRadioButton httpSecurityAuthNRadioButton; + private JLabel httpSecurityAuthNLabel; + private JRadioButton wsSecurityAuthNRadioButton; + private JLabel wsSecurityAuthNLabel; + + // Password types + private final String PLAINTEXT_PASSWORD = "Plaintext password"; + private final String DIGEST_PASSWORD = "Digest password"; + private String[] passwordTypes = new String[] { PLAINTEXT_PASSWORD, DIGEST_PASSWORD }; + private String[] tooltips = new String[] { + "Password will be sent in plaintext (which is OK if service is using HTTPS)", + "Password will be digested (cryptographically hashed) before sending" }; + private JComboBox<String> passwordTypeComboBox; + private JCheckBox addTimestampCheckBox; + private JButton setHttpUsernamePasswordButton; + private JButton setWsdlUsernamePasswordButton; + + // private Logger logger = Logger.getLogger(WSDLActivityConfigurationView.class); + + public WSDLActivityConfigurationView(Activity activity, CredentialManager credentialManager) { + super(activity); + this.credentialManager = credentialManager; + initialise(); + } + + @Override + protected void initialise() { + super.initialise(); + + int gridy = 0; + + // title panel + JPanel titlePanel = new JPanel(new BorderLayout()); + titlePanel.setBackground(Color.WHITE); + JLabel titleLabel = new JLabel("Security configuration"); + titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f)); + titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10)); + DialogTextArea titleMessage = new DialogTextArea( + "Select a security profile for the service"); + titleMessage.setMargin(new Insets(5, 20, 10, 10)); + titleMessage.setFont(titleMessage.getFont().deriveFont(11f)); + titleMessage.setEditable(false); + titleMessage.setFocusable(false); + titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10)); + titlePanel.add(titleLabel, BorderLayout.NORTH); + titlePanel.add(titleMessage, BorderLayout.CENTER); + addDivider(titlePanel, SwingConstants.BOTTOM, true); + + // Main panel + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new GridBagLayout()); + mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); + + // Create the radio buttons + noSecurityRadioButton = new JRadioButton("None"); + noSecurityRadioButton.addItemListener(this); + + wsSecurityAuthNRadioButton = new JRadioButton( + "WS-Security username and password authentication"); + wsSecurityAuthNRadioButton.addItemListener(this); + + httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication"); + httpSecurityAuthNRadioButton.addItemListener(this); + + // Group the radio buttons + buttonGroup = new ButtonGroup(); + buttonGroup.add(noSecurityRadioButton); + buttonGroup.add(wsSecurityAuthNRadioButton); + buttonGroup.add(httpSecurityAuthNRadioButton); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.weightx = 1.0; + gbc.weighty = 0.0; + + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 10, 0, 0); + mainPanel.add(noSecurityRadioButton, gbc); + + noSecurityLabel = new JLabel("Service requires no security"); + noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f)); + // addDivider(noSecurityLabel, SwingConstants.BOTTOM, false); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 40, 10, 10); + mainPanel.add(noSecurityLabel, gbc); + + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 10, 0, 0); + mainPanel.add(httpSecurityAuthNRadioButton, gbc); + + ActionListener usernamePasswordListener = new ActionListener() { + + public void actionPerformed(ActionEvent e) { + // Get Credential Manager UI to get the username and password for the service + if (credManagerUI == null) { + credManagerUI = new CredentialManagerUI(credentialManager); + } + credManagerUI.newPasswordForService(URI.create(getJson().get("operation") + .get("wsdl").textValue())); + } + }; + + httpSecurityAuthNLabel = new JLabel( + "Service requires HTTP username and password in order to authenticate the user"); + httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f)); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 40, 10, 10); + mainPanel.add(httpSecurityAuthNLabel, gbc); + + // Set username and password button; + setHttpUsernamePasswordButton = new JButton("Set username and password"); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(0, 40, 10, 10); + gbc.weightx = 1.0; + gbc.weighty = 1.0; // add any vertical space to this component + mainPanel.add(setHttpUsernamePasswordButton, gbc); + setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener); + + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 10, 0, 0); + mainPanel.add(wsSecurityAuthNRadioButton, gbc); + + wsSecurityAuthNLabel = new JLabel( + "Service requires WS-Security username and password in order to authenticate the user"); + wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f)); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0, 40, 0, 0); + mainPanel.add(wsSecurityAuthNLabel, gbc); + + // Password type list + passwordTypeComboBox = new JComboBox<>(passwordTypes); + passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer()); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(10, 40, 0, 0); + mainPanel.add(passwordTypeComboBox, gbc); + + // 'Add timestamp' checkbox + addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message"); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(5, 40, 10, 10); + mainPanel.add(addTimestampCheckBox, gbc); + + // Set username and password button; + setWsdlUsernamePasswordButton = new JButton("Set username and password"); + gbc.gridx = 0; + gbc.gridy = gridy++; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(0, 40, 10, 10); + gbc.weightx = 1.0; + gbc.weighty = 1.0; // add any vertical space to this component + mainPanel.add(setWsdlUsernamePasswordButton, gbc); + setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener); + + addDivider(mainPanel, SwingConstants.BOTTOM, true); + + // Enable/disable controls based on what is the current security profiles + if (!getJson().has("securityProfile")) { + noSecurityRadioButton.setSelected(true); + } else { + URI securityProfile = URI.create(getJson().get("securityProfile").textValue()); + if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) { + wsSecurityAuthNRadioButton.setSelected(true); + } + if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN) + || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) { + httpSecurityAuthNRadioButton.setSelected(true); + } + if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) { + passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD); + } else if (securityProfile + .equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) { + passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD); + } + if (securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD) + || securityProfile + .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) { + addTimestampCheckBox.setSelected(true); + } else { + addTimestampCheckBox.setSelected(false); + } + } + + // Put everything together + JPanel layoutPanel = new JPanel(new BorderLayout()); + layoutPanel.add(titlePanel, BorderLayout.NORTH); + layoutPanel.add(mainPanel, BorderLayout.CENTER); + layoutPanel.setPreferredSize(new Dimension(550, 400)); + + add(layoutPanel); + } + + @Override + public boolean checkValues() { + return true; + } + + @Override + public void noteConfiguration() { + + if (noSecurityRadioButton.isSelected()) { + getJson().remove("securityProfile"); // no security required + } else if (httpSecurityAuthNRadioButton.isSelected()) { + getJson().put("securityProfile", SecurityProfiles.HTTP_BASIC_AUTHN.toString()); + } else if (wsSecurityAuthNRadioButton.isSelected()) { // plaintext password + if (passwordTypeComboBox.getSelectedItem().equals(PLAINTEXT_PASSWORD)) { + if (addTimestampCheckBox.isSelected()) { + getJson().put( + "securityProfile", + SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD + .toString()); + } else { + getJson().put("securityProfile", + SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD.toString()); + } + } else { // digest password + if (addTimestampCheckBox.isSelected()) { + getJson().put( + "securityProfile", + SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD + .toString()); + } else { + getJson().put("securityProfile", + SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD.toString()); + } + } + } + } + + /** + * Disable/enable items on the panel based on this radio button + * has been selected. + */ + public void itemStateChanged(ItemEvent e) { + + Object source = e.getItemSelectable(); + if (source == noSecurityRadioButton) { + httpSecurityAuthNLabel.setEnabled(false); + wsSecurityAuthNLabel.setEnabled(false); + passwordTypeComboBox.setEnabled(false); + setHttpUsernamePasswordButton.setEnabled(false); + setWsdlUsernamePasswordButton.setEnabled(false); + addTimestampCheckBox.setEnabled(false); + + noSecurityLabel.setEnabled(true); + } else if (source == httpSecurityAuthNRadioButton) { + noSecurityLabel.setEnabled(false); + httpSecurityAuthNLabel.setEnabled(true); + wsSecurityAuthNLabel.setEnabled(false); + passwordTypeComboBox.setEnabled(false); + setHttpUsernamePasswordButton.setEnabled(true); + setWsdlUsernamePasswordButton.setEnabled(false); + addTimestampCheckBox.setEnabled(false); + } else if (source == wsSecurityAuthNRadioButton) { + noSecurityLabel.setEnabled(false); + httpSecurityAuthNLabel.setEnabled(false); + wsSecurityAuthNLabel.setEnabled(true); + passwordTypeComboBox.setEnabled(true); + setHttpUsernamePasswordButton.setEnabled(false); + setWsdlUsernamePasswordButton.setEnabled(true); + addTimestampCheckBox.setEnabled(true); + } + } + + /** + * A renderer for JComboBox that will display a tooltip for + * the selected item. + */ + class ComboBoxTooltipRenderer extends BasicComboBoxRenderer { + public Component getListCellRendererComponent(JList list, Object value, int index, + boolean isSelected, boolean cellHasFocus) { + if (isSelected) { + setBackground(list.getSelectionBackground()); + setForeground(list.getSelectionForeground()); + if (-1 < index) { + list.setToolTipText(tooltips[index]); + } + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + setFont(list.getFont()); + setText((value == null) ? "" : value.toString()); + return this; + } + } + + /** + * Adds a light gray or etched border to the top or bottom of a JComponent. + * + * @author David Withers + * @param component + */ + protected void addDivider(JComponent component, final int position, final boolean etched) { + component.setBorder(new Border() { + private final Color borderColor = new Color(.6f, .6f, .6f); + + public Insets getBorderInsets(Component c) { + if (position == SwingConstants.TOP) { + return new Insets(5, 0, 0, 0); + } else { + return new Insets(0, 0, 5, 0); + } + } + + public boolean isBorderOpaque() { + return false; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (position == SwingConstants.TOP) { + if (etched) { + g.setColor(borderColor); + g.drawLine(x, y, x + width, y); + g.setColor(Color.WHITE); + g.drawLine(x, y + 1, x + width, y + 1); + } else { + g.setColor(Color.LIGHT_GRAY); + g.drawLine(x, y, x + width, y); + } + } else { + if (etched) { + g.setColor(borderColor); + g.drawLine(x, y + height - 2, x + width, y + height - 2); + g.setColor(Color.WHITE); + g.drawLine(x, y + height - 1, x + width, y + height - 1); + } else { + g.setColor(Color.LIGHT_GRAY); + g.drawLine(x, y + height - 1, x + width, y + height - 1); + } + } + } + + }); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityContextualView.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityContextualView.java new file mode 100644 index 0000000..3e26d4c --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityContextualView.java @@ -0,0 +1,107 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Frame; + +import javax.swing.Action; +import javax.swing.JComponent; +import javax.swing.JPanel; + +import org.apache.taverna.activities.wsdl.actions.WSDLActivityConfigureAction; +import org.apache.taverna.security.credentialmanager.CredentialManager; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.ui.actions.activity.HTMLBasedActivityContextualView; +import org.apache.taverna.scufl2.api.activity.Activity; + +import com.fasterxml.jackson.databind.JsonNode; + +@SuppressWarnings("serial") +public class WSDLActivityContextualView extends AbstractXMLSplitterActionView { + + private final ActivityIconManager activityIconManager; + private final ServiceDescriptionRegistry serviceDescriptionRegistry; + private final CredentialManager credentialManager; + private final FileManager fileManager; + + public WSDLActivityContextualView(Activity activity, EditManager editManager, FileManager fileManager, + SelectionManager selectionManager, ActivityIconManager activityIconManager, + ColourManager colourManager, CredentialManager credentialManager, + ServiceDescriptionRegistry serviceDescriptionRegistry) { + super(activity, editManager, selectionManager, colourManager); + this.fileManager = fileManager; + this.activityIconManager = activityIconManager; + this.credentialManager = credentialManager; + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + } + + /** + * Gets the component from the {@link HTMLBasedActivityContextualView} and adds buttons to it + * allowing XML splitters to be added + */ + @Override + public JComponent getMainFrame() { + final JComponent mainFrame = super.getMainFrame(); + JPanel flowPanel = new JPanel(new FlowLayout()); + + addInputSplitter(mainFrame, flowPanel); + addOutputSplitter(mainFrame, flowPanel); + + mainFrame.add(flowPanel, BorderLayout.SOUTH); + return mainFrame; + } + + @Override + public String getViewTitle() { + return "WSDL-based service"; + } + + @Override + protected String getRawTableRowsHtml() { + JsonNode operation = getConfigBean().getJson().get("operation"); + String summary = "<tr><td>WSDL</td><td>" + operation.get("wsdl").textValue(); + summary += "</td></tr><tr><td>Operation</td><td>" + operation.get("name").textValue() + + "</td></tr>"; + boolean securityConfigured = getConfigBean().getJson().has("securityProfile"); + summary += "<tr><td>Secure</td><td>" + securityConfigured + "</td></tr>"; + summary += "</tr>"; + summary += describePorts(); + return summary; + } + + @Override + public Action getConfigureAction(Frame owner) { + return new WSDLActivityConfigureAction(getActivity(), owner, editManager, fileManager, + activityIconManager, serviceDescriptionRegistry, credentialManager); + } + + @Override + public int getPreferredPosition() { + return 100; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityViewFactory.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityViewFactory.java new file mode 100644 index 0000000..9ec1966 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/WSDLActivityViewFactory.java @@ -0,0 +1,87 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.util.Arrays; +import java.util.List; + +import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceDescription; +import org.apache.taverna.security.credentialmanager.CredentialManager; +import org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry; +import org.apache.taverna.workbench.activityicons.ActivityIconManager; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory; +import org.apache.taverna.scufl2.api.activity.Activity; + +public class WSDLActivityViewFactory implements ContextualViewFactory<Activity> { + + private EditManager editManager; + private ActivityIconManager activityIconManager; + private ColourManager colourManager; + private SelectionManager selectionManager; + private ServiceDescriptionRegistry serviceDescriptionRegistry; + private CredentialManager credentialManager; + private FileManager fileManager; + + public boolean canHandle(Object object) { + return object instanceof Activity + && ((Activity) object).getType().equals(WSDLServiceDescription.ACTIVITY_TYPE); + } + + public List<ContextualView> getViews(Activity activity) { + return Arrays + .asList(new ContextualView[] { new WSDLActivityContextualView(activity, + editManager, fileManager, selectionManager, activityIconManager, colourManager, + credentialManager, serviceDescriptionRegistry) }); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setFileManager(FileManager fileManager) { + this.fileManager = fileManager; + } + + public void setSelectionManager(SelectionManager selectionManager) { + this.selectionManager = selectionManager; + } + + public void setActivityIconManager(ActivityIconManager activityIconManager) { + this.activityIconManager = activityIconManager; + } + + public void setColourManager(ColourManager colourManager) { + this.colourManager = colourManager; + } + + public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { + this.serviceDescriptionRegistry = serviceDescriptionRegistry; + } + + public void setCredentialManager(CredentialManager credentialManager) { + this.credentialManager = credentialManager; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterContextualView.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterContextualView.java new file mode 100644 index 0000000..a6a9877 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterContextualView.java @@ -0,0 +1,77 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; + +import javax.swing.JComponent; +import javax.swing.JPanel; + +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.ui.actions.activity.HTMLBasedActivityContextualView; + +import org.apache.log4j.Logger; + +import org.apache.taverna.scufl2.api.activity.Activity; + +@SuppressWarnings("serial") +public class XMLSplitterContextualView extends AbstractXMLSplitterActionView { + + public XMLSplitterContextualView(Activity activity, + EditManager editManager, SelectionManager selectionManager, ColourManager colourManager) { + super(activity, editManager, selectionManager, colourManager); + } + + static Logger logger = Logger.getLogger(XMLSplitterContextualView.class); + + /** + * Gets the component from the {@link HTMLBasedActivityContextualView} and adds buttons to it + * allowing XML splitters to be added + */ + @Override + public JComponent getMainFrame() { + final JComponent mainFrame = super.getMainFrame(); + JPanel flowPanel = new JPanel(new FlowLayout()); + + addInputSplitter(mainFrame, flowPanel); + addOutputSplitter(mainFrame, flowPanel); + mainFrame.add(flowPanel, BorderLayout.SOUTH); + return mainFrame; + } + + @Override + public String getViewTitle() { + return "XML splitter"; + } + + @Override + protected String getRawTableRowsHtml() { + return describePorts(); + } + + @Override + public int getPreferredPosition() { + return 100; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterViewFactory.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterViewFactory.java new file mode 100644 index 0000000..9453254 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/views/XMLSplitterViewFactory.java @@ -0,0 +1,63 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import java.util.Arrays; +import java.util.List; + +import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceDescription; +import org.apache.taverna.workbench.configuration.colour.ColourManager; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory; +import org.apache.taverna.scufl2.api.activity.Activity; + +public class XMLSplitterViewFactory implements ContextualViewFactory<Activity> { + + private EditManager editManager; + private SelectionManager selectionManager; + private ColourManager colourManager; + + public boolean canHandle(Object object) { + + return object instanceof Activity + && (((Activity) object).getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE) + || ((Activity) object).getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)); + } + + public List<ContextualView> getViews(Activity activity) { + return Arrays.asList(new ContextualView[] { new XMLSplitterContextualView(activity, + editManager, selectionManager, colourManager) }); + } + + public void setEditManager(EditManager editManager) { + this.editManager = editManager; + } + + public void setSelectionManager(SelectionManager selectionManager) { + this.selectionManager = selectionManager; + } + + public void setColourManager(ColourManager colourManager) { + this.colourManager = colourManager; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider deleted file mode 100644 index 3bf8341..0000000 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceProvider http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent deleted file mode 100644 index 7b0e040..0000000 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent +++ /dev/null @@ -1,5 +0,0 @@ -net.sf.taverna.t2.activities.wsdl.menu.AddXMLInputSplitterForWSDLActivityMenuAction -net.sf.taverna.t2.activities.wsdl.menu.AddXMLInputSplitterForXMLInputSplitterMenuAction -net.sf.taverna.t2.activities.wsdl.menu.AddXMLOutputSplitterForWSDLActivityMenuAction -net.sf.taverna.t2.activities.wsdl.menu.AddXMLOutputSplitterForXMLOutputSplitterMenuAction -net.sf.taverna.t2.activities.wsdl.menu.ConfigureWSDLMenuAction http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI deleted file mode 100644 index 17d19e3..0000000 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI +++ /dev/null @@ -1,3 +0,0 @@ -net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLActivityIcon -net.sf.taverna.t2.activities.wsdl.servicedescriptions.XMLInputSplitterActivityIcon -net.sf.taverna.t2.activities.wsdl.servicedescriptions.XMLOutputSplitterActivityIcon \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory deleted file mode 100644 index 04d48eb..0000000 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory +++ /dev/null @@ -1,2 +0,0 @@ -net.sf.taverna.t2.activities.wsdl.views.WSDLActivityViewFactory -net.sf.taverna.t2.activities.wsdl.views.XMLSplitterViewFactory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.servicedescriptions.ServiceDescriptionProvider ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.servicedescriptions.ServiceDescriptionProvider b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.servicedescriptions.ServiceDescriptionProvider new file mode 100644 index 0000000..c25d541 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.servicedescriptions.ServiceDescriptionProvider @@ -0,0 +1 @@ +org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceProvider http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent new file mode 100644 index 0000000..15f6441 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.ui.menu.MenuComponent @@ -0,0 +1,5 @@ +org.apache.taverna.activities.wsdl.menu.AddXMLInputSplitterForWSDLActivityMenuAction +org.apache.taverna.activities.wsdl.menu.AddXMLInputSplitterForXMLInputSplitterMenuAction +org.apache.taverna.activities.wsdl.menu.AddXMLOutputSplitterForWSDLActivityMenuAction +org.apache.taverna.activities.wsdl.menu.AddXMLOutputSplitterForXMLOutputSplitterMenuAction +org.apache.taverna.activities.wsdl.menu.ConfigureWSDLMenuAction http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.activityicons.ActivityIconSPI ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.activityicons.ActivityIconSPI b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.activityicons.ActivityIconSPI new file mode 100644 index 0000000..0f3274f --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.activityicons.ActivityIconSPI @@ -0,0 +1,3 @@ +org.apache.taverna.activities.wsdl.servicedescriptions.WSDLActivityIcon +org.apache.taverna.activities.wsdl.servicedescriptions.XMLInputSplitterActivityIcon +org.apache.taverna.activities.wsdl.servicedescriptions.XMLOutputSplitterActivityIcon \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory new file mode 100644 index 0000000..bcc7d37 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/services/org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory @@ -0,0 +1,2 @@ +org.apache.taverna.activities.wsdl.views.WSDLActivityViewFactory +org.apache.taverna.activities.wsdl.views.XMLSplitterViewFactory \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context-osgi.xml b/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context-osgi.xml index ac79064..beb6b73 100644 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context-osgi.xml +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context-osgi.xml @@ -6,14 +6,14 @@ http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> - <service ref="WSDLActivityIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" /> - <service ref="XMLInputSplitterActivityIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" /> - <service ref="XMLOutputSplitterActivityIcon" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI" /> + <service ref="WSDLActivityIcon" interface="org.apache.taverna.workbench.activityicons.ActivityIconSPI" /> + <service ref="XMLInputSplitterActivityIcon" interface="org.apache.taverna.workbench.activityicons.ActivityIconSPI" /> + <service ref="XMLOutputSplitterActivityIcon" interface="org.apache.taverna.workbench.activityicons.ActivityIconSPI" /> <service ref="WSDLServiceProvider"> <interfaces> - <beans:value>net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider</beans:value> - <beans:value>net.sf.taverna.t2.servicedescriptions.ConfigurableServiceProvider</beans:value> + <beans:value>org.apache.taverna.servicedescriptions.ServiceDescriptionProvider</beans:value> + <beans:value>org.apache.taverna.servicedescriptions.ConfigurableServiceProvider</beans:value> </interfaces> </service> @@ -23,15 +23,15 @@ <service ref="AddXMLOutputSplitterForXMLOutputSplitterMenuAction" auto-export="interfaces" /> <service ref="ConfigureWSDLMenuAction" auto-export="interfaces" /> - <service ref="WSDLActivityViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> - <service ref="XMLSplitterViewFactory" interface="net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> + <service ref="WSDLActivityViewFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> + <service ref="XMLSplitterViewFactory" interface="org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory" /> - <reference id="editManager" interface="net.sf.taverna.t2.workbench.edits.EditManager" /> - <reference id="fileManager" interface="net.sf.taverna.t2.workbench.file.FileManager" /> - <reference id="activityIconManager" interface="net.sf.taverna.t2.workbench.activityicons.ActivityIconManager" /> - <reference id="colourManager" interface="net.sf.taverna.t2.workbench.configuration.colour.ColourManager" /> - <reference id="serviceDescriptionRegistry" interface="net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry" /> - <reference id="credentialManager" interface="net.sf.taverna.t2.security.credentialmanager.CredentialManager" /> - <reference id="selectionManager" interface="net.sf.taverna.t2.workbench.selection.SelectionManager" /> + <reference id="editManager" interface="org.apache.taverna.workbench.edits.EditManager" /> + <reference id="fileManager" interface="org.apache.taverna.workbench.file.FileManager" /> + <reference id="activityIconManager" interface="org.apache.taverna.workbench.activityicons.ActivityIconManager" /> + <reference id="colourManager" interface="org.apache.taverna.workbench.configuration.colour.ColourManager" /> + <reference id="serviceDescriptionRegistry" interface="org.apache.taverna.servicedescriptions.ServiceDescriptionRegistry" /> + <reference id="credentialManager" interface="org.apache.taverna.security.credentialmanager.CredentialManager" /> + <reference id="selectionManager" interface="org.apache.taverna.workbench.selection.SelectionManager" /> </beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context.xml ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context.xml b/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context.xml index fede275..013fdf1 100644 --- a/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context.xml +++ b/taverna-wsdl-activity-ui/src/main/resources/META-INF/spring/wsdl-activity-ui-context.xml @@ -3,32 +3,32 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="WSDLActivityIcon" class="net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLActivityIcon" /> - <bean id="XMLInputSplitterActivityIcon" class="net.sf.taverna.t2.activities.wsdl.servicedescriptions.XMLInputSplitterActivityIcon" /> - <bean id="XMLOutputSplitterActivityIcon" class="net.sf.taverna.t2.activities.wsdl.servicedescriptions.XMLOutputSplitterActivityIcon" /> + <bean id="WSDLActivityIcon" class="org.apache.taverna.activities.wsdl.servicedescriptions.WSDLActivityIcon" /> + <bean id="XMLInputSplitterActivityIcon" class="org.apache.taverna.activities.wsdl.servicedescriptions.XMLInputSplitterActivityIcon" /> + <bean id="XMLOutputSplitterActivityIcon" class="org.apache.taverna.activities.wsdl.servicedescriptions.XMLOutputSplitterActivityIcon" /> - <bean id="WSDLServiceProvider" class="net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceProvider"> + <bean id="WSDLServiceProvider" class="org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceProvider"> <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" /> <property name="credentialManager" ref="credentialManager" /> </bean> - <bean id="AddXMLInputSplitterForWSDLActivityMenuAction" class="net.sf.taverna.t2.activities.wsdl.menu.AddXMLInputSplitterForWSDLActivityMenuAction"> + <bean id="AddXMLInputSplitterForWSDLActivityMenuAction" class="org.apache.taverna.activities.wsdl.menu.AddXMLInputSplitterForWSDLActivityMenuAction"> <property name="editManager" ref="editManager" /> <property name="selectionManager" ref="selectionManager" /> </bean> - <bean id="AddXMLInputSplitterForXMLInputSplitterMenuAction" class="net.sf.taverna.t2.activities.wsdl.menu.AddXMLInputSplitterForXMLInputSplitterMenuAction"> + <bean id="AddXMLInputSplitterForXMLInputSplitterMenuAction" class="org.apache.taverna.activities.wsdl.menu.AddXMLInputSplitterForXMLInputSplitterMenuAction"> <property name="editManager" ref="editManager" /> <property name="selectionManager" ref="selectionManager" /> </bean> - <bean id="AddXMLOutputSplitterForWSDLActivityMenuAction" class="net.sf.taverna.t2.activities.wsdl.menu.AddXMLOutputSplitterForWSDLActivityMenuAction"> + <bean id="AddXMLOutputSplitterForWSDLActivityMenuAction" class="org.apache.taverna.activities.wsdl.menu.AddXMLOutputSplitterForWSDLActivityMenuAction"> <property name="editManager" ref="editManager" /> <property name="selectionManager" ref="selectionManager" /> </bean> - <bean id="AddXMLOutputSplitterForXMLOutputSplitterMenuAction" class="net.sf.taverna.t2.activities.wsdl.menu.AddXMLOutputSplitterForXMLOutputSplitterMenuAction"> + <bean id="AddXMLOutputSplitterForXMLOutputSplitterMenuAction" class="org.apache.taverna.activities.wsdl.menu.AddXMLOutputSplitterForXMLOutputSplitterMenuAction"> <property name="editManager" ref="editManager" /> <property name="selectionManager" ref="selectionManager" /> </bean> - <bean id="ConfigureWSDLMenuAction" class="net.sf.taverna.t2.activities.wsdl.menu.ConfigureWSDLMenuAction"> + <bean id="ConfigureWSDLMenuAction" class="org.apache.taverna.activities.wsdl.menu.ConfigureWSDLMenuAction"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> <property name="activityIconManager" ref="activityIconManager" /> @@ -36,7 +36,7 @@ <property name="credentialManager" ref="credentialManager" /> </bean> - <bean id="WSDLActivityViewFactory" class="net.sf.taverna.t2.activities.wsdl.views.WSDLActivityViewFactory"> + <bean id="WSDLActivityViewFactory" class="org.apache.taverna.activities.wsdl.views.WSDLActivityViewFactory"> <property name="editManager" ref="editManager" /> <property name="fileManager" ref="fileManager" /> <property name="activityIconManager" ref="activityIconManager" /> @@ -44,7 +44,7 @@ <property name="serviceDescriptionRegistry" ref="serviceDescriptionRegistry" /> <property name="credentialManager" ref="credentialManager" /> </bean> - <bean id="XMLSplitterViewFactory" class="net.sf.taverna.t2.activities.wsdl.views.XMLSplitterViewFactory"> + <bean id="XMLSplitterViewFactory" class="org.apache.taverna.activities.wsdl.views.XMLSplitterViewFactory"> <property name="editManager" ref="editManager" /> <property name="selectionManager" ref="selectionManager" /> <property name="colourManager" ref="colourManager" /> http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/test/java/net/sf/taverna/t2/activities/wsdl/views/TestWSDLActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/test/java/net/sf/taverna/t2/activities/wsdl/views/TestWSDLActivityContextualView.java b/taverna-wsdl-activity-ui/src/test/java/net/sf/taverna/t2/activities/wsdl/views/TestWSDLActivityContextualView.java deleted file mode 100644 index 0fa054b..0000000 --- a/taverna-wsdl-activity-ui/src/test/java/net/sf/taverna/t2/activities/wsdl/views/TestWSDLActivityContextualView.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007 The University of Manchester - * - * Modifications to the initial code base are copyright of their - * respective authors, or their employers as appropriate. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - ******************************************************************************/ -package net.sf.taverna.t2.activities.wsdl.views; - -import static org.junit.Assert.assertNull; - -import org.junit.Before; - -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 TestWSDLActivityContextualView { - - Activity a; - - @Before - public void setUp() throws Exception { - a=new Activity(); - Configuration configuration = new Configuration(); - ObjectNode json = (ObjectNode) configuration.getJson(); - ObjectNode operation = json.objectNode(); - operation.put("name", "getReport"); - json.set("operation", operation); - String wsdlUrl=TestWSDLActivityContextualView.class.getResource("/GMService.wsdl").toExternalForm(); - operation.put("wsdl", wsdlUrl); - configuration.setConfigures(a); - } - - public void testConfigurationAction() { - WSDLActivityContextualView view = new WSDLActivityContextualView(a, null, null, null, null, null, null, null); - assertNull("WSDL has no configure action, so should be null",view.getConfigureAction(null)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/test/java/org/apache/taverna/activities/wsdl/views/TestWSDLActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/test/java/org/apache/taverna/activities/wsdl/views/TestWSDLActivityContextualView.java b/taverna-wsdl-activity-ui/src/test/java/org/apache/taverna/activities/wsdl/views/TestWSDLActivityContextualView.java new file mode 100644 index 0000000..4ca3d72 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/test/java/org/apache/taverna/activities/wsdl/views/TestWSDLActivityContextualView.java @@ -0,0 +1,52 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.views; + +import static org.junit.Assert.assertNull; + +import org.junit.Before; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.configurations.Configuration; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class TestWSDLActivityContextualView { + + Activity a; + + @Before + public void setUp() throws Exception { + a=new Activity(); + Configuration configuration = new Configuration(); + ObjectNode json = (ObjectNode) configuration.getJson(); + ObjectNode operation = json.objectNode(); + operation.put("name", "getReport"); + json.set("operation", operation); + String wsdlUrl=TestWSDLActivityContextualView.class.getResource("/GMService.wsdl").toExternalForm(); + operation.put("wsdl", wsdlUrl); + configuration.setConfigures(a); + } + + public void testConfigurationAction() { + WSDLActivityContextualView view = new WSDLActivityContextualView(a, null, null, null, null, null, null, null); + assertNull("WSDL has no configure action, so should be null",view.getConfigureAction(null)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-xpath-activity-ui/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java ---------------------------------------------------------------------- diff --git a/taverna-xpath-activity-ui/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java b/taverna-xpath-activity-ui/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java deleted file mode 100644 index d0f131a..0000000 --- a/taverna-xpath-activity-ui/src/main/java/net/sf/taverna/t2/activities/xpath/ui/config/TwoFieldQueryPanel.java +++ /dev/null @@ -1,110 +0,0 @@ -package net.sf.taverna.t2.activities.xpath.ui.config; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; - -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -/** - * Auxiliary class that creates a JPanel with two labels and two text fields. - * - * It can be used to be placed into a dialog made by JOptionPane to get two - * input values, not just one. - * - * @author Sergejs Aleksejevs - */ -public class TwoFieldQueryPanel extends JPanel { - private JTextField tfFirstValue; - private JTextField tfSecondValue; - - public TwoFieldQueryPanel(String firstFieldName, String secondFieldName) { - this(null, firstFieldName, null, secondFieldName, null); - } - - public TwoFieldQueryPanel(String message, String firstFieldName, - String secondFieldName) { - this(message, firstFieldName, null, secondFieldName, null); - } - - public TwoFieldQueryPanel(String firstFieldName, - String firstFieldDefaultValue, String secondFieldName, - String secondFieldDefaultValue) { - this(null, firstFieldName, firstFieldDefaultValue, secondFieldName, - secondFieldDefaultValue); - } - - public TwoFieldQueryPanel(String message, String firstFieldName, - String firstFieldDefaultValue, String secondFieldName, - String secondFieldDefaultValue) { - super(); - this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.gridx = 0; - c.gridy = 0; - c.weightx = 0; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(3, 5, 3, 5); - - if (message != null && message.length() > 0) { - c.gridwidth = 2; - c.insets = new Insets(5, 5, 15, 5); - this.add(new JLabel(message), c); - - c.gridwidth = 1; - c.gridx = 0; - c.gridy++; - c.insets = new Insets(3, 5, 3, 5); - } - - this.add(new JLabel(firstFieldName), c); - - c.gridx++; - c.weightx = 1.0; - tfFirstValue = new JTextField(20); - if (firstFieldDefaultValue != null) { - tfFirstValue.setText(firstFieldDefaultValue); - } - tfFirstValue.selectAll(); - tfFirstValue.requestFocusInWindow(); - this.add(tfFirstValue, c); - - c.gridx = 0; - c.gridy++; - c.weightx = 0; - this.add(new JLabel(secondFieldName), c); - - c.gridx++; - c.weightx = 1.0; - tfSecondValue = new JTextField(20); - if (secondFieldDefaultValue != null) { - tfSecondValue.setText(secondFieldDefaultValue); - } - tfSecondValue.selectAll(); - this.add(tfSecondValue, c); - } - - /** - * @return Trimmed value from the first text field. Guaranteed to be - * non-null. - */ - public String getFirstValue() { - return (tfFirstValue.getText().trim()); - } - - /** - * @return Trimmed value from the second text field. Guaranteed to be - * non-null. - */ - public String getSecondValue() { - return (tfSecondValue.getText().trim()); - } - -}
