package rename folders
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/commit/b7b61e71 Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/tree/b7b61e71 Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/diff/b7b61e71 Branch: refs/heads/master Commit: b7b61e7133ed485a12d22bdf6b7d3a3cccff3f4a Parents: 6664979 Author: Stian Soiland-Reyes <[email protected]> Authored: Fri Jun 29 11:53:30 2018 +0100 Committer: Stian Soiland-Reyes <[email protected]> Committed: Fri Jun 29 11:53:30 2018 +0100 ---------------------------------------------------------------------- .../component/ui/ComponentAction.java | 66 ++ .../ui/ComponentActivityConfigurationBean.java | 184 +++++ .../component/ui/ComponentConstants.java | 28 + ...bstractSemanticAnnotationContextualView.java | 296 ++++++++ .../annotation/AnnotateSemanticsMenuAction.java | 117 ++++ .../AnnotationPropertyPanelFactory.java | 73 ++ .../DatatypePropertyPanelFactory.java | 76 +++ .../DateTimePropertyPanelFactory.java | 136 ++++ .../FallbackPropertyPanelFactory.java | 60 ++ .../component/ui/annotation/GreyBorder.java | 36 + ...jectPropertyWithIndividualsPanelFactory.java | 196 ++++++ .../ui/annotation/PropertyPanelFactorySPI.java | 82 +++ .../SemanticAnnotationContextualView.java | 144 ++++ ...SemanticAnnotationContextualViewFactory.java | 67 ++ .../ui/annotation/SemanticAnnotationPanel.java | 271 ++++++++ .../ui/annotation/SemanticAnnotationUtils.java | 190 ++++++ .../ui/annotation/TurtleContextualView.java | 93 +++ .../ui/annotation/TurtleInputPanel.java | 105 +++ .../annotation/UnrecognizedStatementPanel.java | 43 ++ .../annotation/UnresolveablePredicatePanel.java | 43 ++ .../ui/config/ComponentConfigurationPanel.java | 171 +++++ .../ui/config/ComponentConfigureAction.java | 69 ++ .../ComponentDataflowHealthCheckExplainer.java | 91 +++ .../ui/file/ComponentDataflowHealthChecker.java | 114 ++++ .../component/ui/file/ComponentOpener.java | 88 +++ .../component/ui/file/ComponentSaver.java | 185 +++++ .../component/ui/file/FileManagerObserver.java | 146 ++++ .../component/ui/localworld/LocalWorld.java | 107 +++ .../AbstractContextComponentMenuAction.java | 58 ++ .../ui/menu/ComponentConfigureMenuAction.java | 81 +++ .../component/ui/menu/ComponentMenu.java | 41 ++ .../component/ui/menu/ComponentSection.java | 44 ++ .../ui/menu/NestedWorkflowCreationDialog.java | 666 ++++++++++++++++++ .../menu/NestedWorkflowCreatorMenuAction.java | 94 +++ ...penComponentFromComponentActivityAction.java | 81 +++ ...omponentFromComponentActivityMenuAction.java | 104 +++ .../ui/menu/ReplaceByComponentAction.java | 275 ++++++++ .../ui/menu/ReplaceByComponentMenuAction.java | 87 +++ .../component/AbstractComponentMenuAction.java | 31 + .../ui/menu/component/ComponentCloseAction.java | 73 ++ .../component/ComponentCloseMenuAction.java | 66 ++ .../ui/menu/component/ComponentCopyAction.java | 164 +++++ .../menu/component/ComponentCopyMenuAction.java | 61 ++ .../menu/component/ComponentCreatorSupport.java | 257 +++++++ .../menu/component/ComponentDeleteAction.java | 143 ++++ .../component/ComponentDeleteMenuAction.java | 67 ++ .../ui/menu/component/ComponentMenuAction.java | 56 ++ .../ui/menu/component/ComponentMenuSection.java | 37 + .../ui/menu/component/ComponentMergeAction.java | 135 ++++ .../component/ComponentMergeMenuAction.java | 55 ++ .../ui/menu/component/ComponentSaveAction.java | 69 ++ .../menu/component/ComponentSaveMenuAction.java | 67 ++ .../menu/component/ComponentSearchAction.java | 169 +++++ .../component/ComponentSearchMenuAction.java | 85 +++ .../ComponentServiceCreatorAction.java | 112 +++ .../ComponentServiceCreatorMenuAction.java | 77 +++ .../ComponentWorkflowCreatorAction.java | 84 +++ .../ComponentWorkflowCreatorMenuAction.java | 72 ++ .../FileOpenFromComponentMenuAction.java | 74 ++ .../OpenWorkflowFromComponentAction.java | 137 ++++ .../family/ComponentFamilyCreateAction.java | 176 +++++ .../family/ComponentFamilyCreateMenuAction.java | 58 ++ .../family/ComponentFamilyDeleteAction.java | 201 ++++++ .../family/ComponentFamilyDeleteMenuAction.java | 69 ++ .../menu/family/ComponentFamilyMenuSection.java | 37 + .../profile/ComponentProfileCopyAction.java | 177 +++++ .../profile/ComponentProfileCopyMenuAction.java | 58 ++ .../profile/ComponentProfileDeleteAction.java | 113 +++ .../ComponentProfileDeleteMenuAction.java | 58 ++ .../profile/ComponentProfileImportAction.java | 181 +++++ .../ComponentProfileImportMenuAction.java | 64 ++ .../profile/ComponentProfileMenuSection.java | 40 ++ .../registry/ComponentRegistryManageAction.java | 52 ++ .../ComponentRegistryManageMenuAction.java | 63 ++ .../registry/ComponentRegistryMenuSection.java | 37 + .../ui/panel/ComponentChoiceMessage.java | 50 ++ .../ui/panel/ComponentChooserPanel.java | 233 +++++++ .../ui/panel/ComponentListCellRenderer.java | 62 ++ .../ui/panel/ComponentVersionChooserPanel.java | 186 +++++ .../component/ui/panel/FamilyChoiceMessage.java | 40 ++ .../component/ui/panel/FamilyChooserPanel.java | 235 +++++++ .../component/ui/panel/LicenseChooserPanel.java | 187 +++++ .../component/ui/panel/PrefixPanel.java | 96 +++ .../ui/panel/ProfileChoiceMessage.java | 40 ++ .../component/ui/panel/ProfileChooserPanel.java | 219 ++++++ ...stryAndFamilyChooserComponentEntryPanel.java | 98 +++ .../ui/panel/RegistryAndFamilyChooserPanel.java | 102 +++ .../ui/panel/RegistryChoiceMessage.java | 40 ++ .../ui/panel/RegistryChooserPanel.java | 138 ++++ .../component/ui/panel/SearchChoicePanel.java | 259 +++++++ .../ui/panel/SharingPolicyChooserPanel.java | 157 +++++ .../ui/preference/ComponentDefaults.java | 57 ++ .../ui/preference/ComponentPreference.java | 143 ++++ .../ui/preference/ComponentPreferencePanel.java | 300 ++++++++ .../ComponentPreferenceUIFactory.java | 61 ++ .../ui/preference/LocalRegistryPanel.java | 132 ++++ .../ui/preference/RegistryTableModel.java | 86 +++ .../ui/preference/RemoteRegistryPanel.java | 94 +++ .../serviceprovider/ComponentServiceDesc.java | 174 +++++ .../serviceprovider/ComponentServiceIcon.java | 51 ++ .../ComponentServiceProvider.java | 236 +++++++ .../ComponentServiceProviderConfig.java | 88 +++ .../component/ui/serviceprovider/Service.java | 27 + .../component/ui/util/ComponentFileType.java | 51 ++ .../component/ui/util/ComponentHealthCheck.java | 86 +++ .../taverna_extras/component/ui/util/Utils.java | 144 ++++ .../ComponentActivityContextViewFactory.java | 140 ++++ ...itySemanticAnnotationContextViewFactory.java | 154 +++++ ...omponentActivitySemanticAnnotationPanel.java | 112 +++ .../ui/view/ComponentContextViewFactory.java | 61 ++ .../ui/view/ComponentContextualView.java | 89 +++ .../component/ui/view/ViewUtil.java | 178 +++++ .../taverna/component/ui/ComponentAction.java | 66 -- .../ui/ComponentActivityConfigurationBean.java | 184 ----- .../component/ui/ComponentConstants.java | 28 - ...bstractSemanticAnnotationContextualView.java | 296 -------- .../annotation/AnnotateSemanticsMenuAction.java | 117 ---- .../AnnotationPropertyPanelFactory.java | 73 -- .../DatatypePropertyPanelFactory.java | 76 --- .../DateTimePropertyPanelFactory.java | 136 ---- .../FallbackPropertyPanelFactory.java | 60 -- .../component/ui/annotation/GreyBorder.java | 36 - ...jectPropertyWithIndividualsPanelFactory.java | 196 ------ .../ui/annotation/PropertyPanelFactorySPI.java | 82 --- .../SemanticAnnotationContextualView.java | 144 ---- ...SemanticAnnotationContextualViewFactory.java | 67 -- .../ui/annotation/SemanticAnnotationPanel.java | 271 -------- .../ui/annotation/SemanticAnnotationUtils.java | 190 ------ .../ui/annotation/TurtleContextualView.java | 93 --- .../ui/annotation/TurtleInputPanel.java | 105 --- .../annotation/UnrecognizedStatementPanel.java | 43 -- .../annotation/UnresolveablePredicatePanel.java | 43 -- .../ui/config/ComponentConfigurationPanel.java | 171 ----- .../ui/config/ComponentConfigureAction.java | 69 -- .../ComponentDataflowHealthCheckExplainer.java | 91 --- .../ui/file/ComponentDataflowHealthChecker.java | 114 ---- .../component/ui/file/ComponentOpener.java | 88 --- .../component/ui/file/ComponentSaver.java | 185 ----- .../component/ui/file/FileManagerObserver.java | 146 ---- .../component/ui/localworld/LocalWorld.java | 107 --- .../AbstractContextComponentMenuAction.java | 58 -- .../ui/menu/ComponentConfigureMenuAction.java | 81 --- .../component/ui/menu/ComponentMenu.java | 41 -- .../component/ui/menu/ComponentSection.java | 44 -- .../ui/menu/NestedWorkflowCreationDialog.java | 666 ------------------ .../menu/NestedWorkflowCreatorMenuAction.java | 94 --- ...penComponentFromComponentActivityAction.java | 81 --- ...omponentFromComponentActivityMenuAction.java | 104 --- .../ui/menu/ReplaceByComponentAction.java | 275 -------- .../ui/menu/ReplaceByComponentMenuAction.java | 87 --- .../component/AbstractComponentMenuAction.java | 31 - .../ui/menu/component/ComponentCloseAction.java | 73 -- .../component/ComponentCloseMenuAction.java | 66 -- .../ui/menu/component/ComponentCopyAction.java | 164 ----- .../menu/component/ComponentCopyMenuAction.java | 61 -- .../menu/component/ComponentCreatorSupport.java | 257 ------- .../menu/component/ComponentDeleteAction.java | 143 ---- .../component/ComponentDeleteMenuAction.java | 67 -- .../ui/menu/component/ComponentMenuAction.java | 56 -- .../ui/menu/component/ComponentMenuSection.java | 37 - .../ui/menu/component/ComponentMergeAction.java | 135 ---- .../component/ComponentMergeMenuAction.java | 55 -- .../ui/menu/component/ComponentSaveAction.java | 69 -- .../menu/component/ComponentSaveMenuAction.java | 67 -- .../menu/component/ComponentSearchAction.java | 169 ----- .../component/ComponentSearchMenuAction.java | 85 --- .../ComponentServiceCreatorAction.java | 112 --- .../ComponentServiceCreatorMenuAction.java | 77 --- .../ComponentWorkflowCreatorAction.java | 84 --- .../ComponentWorkflowCreatorMenuAction.java | 72 -- .../FileOpenFromComponentMenuAction.java | 74 -- .../OpenWorkflowFromComponentAction.java | 137 ---- .../family/ComponentFamilyCreateAction.java | 176 ----- .../family/ComponentFamilyCreateMenuAction.java | 58 -- .../family/ComponentFamilyDeleteAction.java | 201 ------ .../family/ComponentFamilyDeleteMenuAction.java | 69 -- .../menu/family/ComponentFamilyMenuSection.java | 37 - .../profile/ComponentProfileCopyAction.java | 177 ----- .../profile/ComponentProfileCopyMenuAction.java | 58 -- .../profile/ComponentProfileDeleteAction.java | 113 --- .../ComponentProfileDeleteMenuAction.java | 58 -- .../profile/ComponentProfileImportAction.java | 181 ----- .../ComponentProfileImportMenuAction.java | 64 -- .../profile/ComponentProfileMenuSection.java | 40 -- .../registry/ComponentRegistryManageAction.java | 52 -- .../ComponentRegistryManageMenuAction.java | 63 -- .../registry/ComponentRegistryMenuSection.java | 37 - .../ui/panel/ComponentChoiceMessage.java | 50 -- .../ui/panel/ComponentChooserPanel.java | 233 ------- .../ui/panel/ComponentListCellRenderer.java | 62 -- .../ui/panel/ComponentVersionChooserPanel.java | 186 ----- .../component/ui/panel/FamilyChoiceMessage.java | 40 -- .../component/ui/panel/FamilyChooserPanel.java | 235 ------- .../component/ui/panel/LicenseChooserPanel.java | 187 ----- .../taverna/component/ui/panel/PrefixPanel.java | 96 --- .../ui/panel/ProfileChoiceMessage.java | 40 -- .../component/ui/panel/ProfileChooserPanel.java | 219 ------ ...stryAndFamilyChooserComponentEntryPanel.java | 98 --- .../ui/panel/RegistryAndFamilyChooserPanel.java | 102 --- .../ui/panel/RegistryChoiceMessage.java | 40 -- .../ui/panel/RegistryChooserPanel.java | 138 ---- .../component/ui/panel/SearchChoicePanel.java | 259 ------- .../ui/panel/SharingPolicyChooserPanel.java | 157 ----- .../ui/preference/ComponentDefaults.java | 57 -- .../ui/preference/ComponentPreference.java | 143 ---- .../ui/preference/ComponentPreferencePanel.java | 300 -------- .../ComponentPreferenceUIFactory.java | 61 -- .../ui/preference/LocalRegistryPanel.java | 132 ---- .../ui/preference/RegistryTableModel.java | 86 --- .../ui/preference/RemoteRegistryPanel.java | 94 --- .../serviceprovider/ComponentServiceDesc.java | 174 ----- .../serviceprovider/ComponentServiceIcon.java | 51 -- .../ComponentServiceProvider.java | 236 ------- .../ComponentServiceProviderConfig.java | 88 --- .../component/ui/serviceprovider/Service.java | 27 - .../component/ui/util/ComponentFileType.java | 51 -- .../component/ui/util/ComponentHealthCheck.java | 86 --- .../apache/taverna/component/ui/util/Utils.java | 144 ---- .../ComponentActivityContextViewFactory.java | 140 ---- ...itySemanticAnnotationContextViewFactory.java | 154 ----- ...omponentActivitySemanticAnnotationPanel.java | 112 --- .../ui/view/ComponentContextViewFactory.java | 61 -- .../ui/view/ComponentContextualView.java | 89 --- .../taverna/component/ui/view/ViewUtil.java | 178 ----- .../component/activity/ComponentActivity.java | 167 +++++ .../ComponentActivityConfigurationBean.java | 168 +++++ .../activity/ComponentActivityFactory.java | 142 ++++ .../activity/ComponentActivityLocalChecker.java | 69 ++ .../ComponentActivityUpgradeChecker.java | 83 +++ .../activity/ComponentExceptionFactory.java | 38 ++ .../activity/ComponentHealthCheck.java | 42 ++ .../ComponentImplementationException.java | 37 + .../component/activity/ProxyCallback.java | 264 +++++++ .../component/activity/package-info.java | 19 + .../component/profile/ActivityProfileImpl.java | 53 ++ .../component/profile/BaseProfileLocator.java | 154 +++++ .../component/profile/ComponentProfileImpl.java | 683 +++++++++++++++++++ .../component/profile/PortProfileImpl.java | 58 ++ .../profile/SemanticAnnotationProfileImpl.java | 175 +++++ .../component/registry/ClientVersion.java | 51 ++ .../component/registry/Component.java | 161 +++++ .../component/registry/ComponentFamily.java | 161 +++++ .../registry/ComponentImplementationCache.java | 75 ++ .../component/registry/ComponentRegistry.java | 242 +++++++ .../component/registry/ComponentUtil.java | 130 ++++ .../component/registry/ComponentVersion.java | 77 +++ .../ComponentVersionIdentification.java | 212 ++++++ .../registry/local/LocalComponent.java | 149 ++++ .../registry/local/LocalComponentFamily.java | 155 +++++ .../registry/local/LocalComponentRegistry.java | 220 ++++++ .../local/LocalComponentRegistryFactory.java | 62 ++ .../registry/local/LocalComponentVersion.java | 108 +++ .../component/registry/standard/Client.java | 654 ++++++++++++++++++ .../registry/standard/NewComponent.java | 239 +++++++ .../registry/standard/NewComponentFamily.java | 151 ++++ .../registry/standard/NewComponentLicense.java | 76 +++ .../registry/standard/NewComponentProfile.java | 121 ++++ .../registry/standard/NewComponentRegistry.java | 485 +++++++++++++ .../standard/NewComponentRegistryFactory.java | 83 +++ .../component/registry/standard/Policy.java | 136 ++++ .../registry/standard/annotations/Unused.java | 43 ++ .../standard/annotations/package-info.java | 24 + .../registry/standard/package-info.java | 23 + .../component/utils/AnnotationUtils.java | 109 +++ .../component/utils/SystemUtils.java | 135 ++++ .../component/activity/ComponentActivity.java | 167 ----- .../ComponentActivityConfigurationBean.java | 168 ----- .../activity/ComponentActivityFactory.java | 142 ---- .../activity/ComponentActivityLocalChecker.java | 69 -- .../ComponentActivityUpgradeChecker.java | 83 --- .../activity/ComponentExceptionFactory.java | 38 -- .../activity/ComponentHealthCheck.java | 42 -- .../ComponentImplementationException.java | 37 - .../component/activity/ProxyCallback.java | 264 ------- .../component/activity/package-info.java | 19 - .../component/profile/ActivityProfileImpl.java | 53 -- .../component/profile/BaseProfileLocator.java | 154 ----- .../component/profile/ComponentProfileImpl.java | 683 ------------------- .../component/profile/PortProfileImpl.java | 58 -- .../profile/SemanticAnnotationProfileImpl.java | 175 ----- .../component/registry/ClientVersion.java | 51 -- .../taverna/component/registry/Component.java | 161 ----- .../component/registry/ComponentFamily.java | 161 ----- .../registry/ComponentImplementationCache.java | 75 -- .../component/registry/ComponentRegistry.java | 242 ------- .../component/registry/ComponentUtil.java | 130 ---- .../component/registry/ComponentVersion.java | 77 --- .../ComponentVersionIdentification.java | 212 ------ .../registry/local/LocalComponent.java | 149 ---- .../registry/local/LocalComponentFamily.java | 155 ----- .../registry/local/LocalComponentRegistry.java | 220 ------ .../local/LocalComponentRegistryFactory.java | 62 -- .../registry/local/LocalComponentVersion.java | 108 --- .../component/registry/standard/Client.java | 654 ------------------ .../registry/standard/NewComponent.java | 239 ------- .../registry/standard/NewComponentFamily.java | 151 ---- .../registry/standard/NewComponentLicense.java | 76 --- .../registry/standard/NewComponentProfile.java | 121 ---- .../registry/standard/NewComponentRegistry.java | 485 ------------- .../standard/NewComponentRegistryFactory.java | 83 --- .../component/registry/standard/Policy.java | 136 ---- .../registry/standard/annotations/Unused.java | 43 -- .../standard/annotations/package-info.java | 24 - .../registry/standard/package-info.java | 23 - .../component/utils/AnnotationUtils.java | 109 --- .../taverna/component/utils/SystemUtils.java | 135 ---- .../component/AnnotationTest.java | 48 ++ .../component/ComponentActivityTest.java | 125 ++++ .../component/registry/ComponentFamilyTest.java | 122 ++++ .../registry/ComponentRegistryTest.java | 181 +++++ .../component/registry/ComponentTest.java | 111 +++ .../registry/ComponentVersionTest.java | 94 +++ .../component/registry/Harness.java | 30 + .../local/LocalComponentFamilyTest.java | 40 ++ .../local/LocalComponentRegistryTest.java | 59 ++ .../registry/local/LocalComponentTest.java | 40 ++ .../local/LocalComponentVersionTest.java | 40 ++ .../registry/local/RegistrySupport.java | 44 ++ .../standard/NewComponentFamilyTest.java | 42 ++ .../standard/NewComponentRegistryTest.java | 75 ++ .../registry/standard/NewComponentTest.java | 42 ++ .../standard/NewComponentVersionTest.java | 42 ++ .../registry/standard/RegistrySupport.java | 55 ++ .../taverna/component/AnnotationTest.java | 48 -- .../component/ComponentActivityTest.java | 125 ---- .../component/registry/ComponentFamilyTest.java | 122 ---- .../registry/ComponentRegistryTest.java | 181 ----- .../component/registry/ComponentTest.java | 111 --- .../registry/ComponentVersionTest.java | 94 --- .../taverna/component/registry/Harness.java | 30 - .../local/LocalComponentFamilyTest.java | 40 -- .../local/LocalComponentRegistryTest.java | 59 -- .../registry/local/LocalComponentTest.java | 40 -- .../local/LocalComponentVersionTest.java | 40 -- .../registry/local/RegistrySupport.java | 44 -- .../standard/NewComponentFamilyTest.java | 42 -- .../standard/NewComponentRegistryTest.java | 75 -- .../registry/standard/NewComponentTest.java | 42 -- .../standard/NewComponentVersionTest.java | 42 -- .../registry/standard/RegistrySupport.java | 55 -- .../taverna_extras/component/api/Component.java | 89 +++ .../component/api/ComponentException.java | 48 ++ .../component/api/ComponentFactory.java | 45 ++ .../taverna_extras/component/api/Family.java | 117 ++++ .../taverna_extras/component/api/License.java | 23 + .../taverna_extras/component/api/NamedItem.java | 26 + .../taverna_extras/component/api/Registry.java | 158 +++++ .../component/api/SharingPolicy.java | 32 + .../taverna_extras/component/api/Version.java | 224 ++++++ .../component/api/config/ComponentConfig.java | 23 + .../api/config/ComponentPropertyNames.java | 32 + .../component/api/package-info.java | 25 + .../component/api/profile/ActivityProfile.java | 23 + .../component/api/profile/AnnotatedElement.java | 28 + .../api/profile/ExceptionHandling.java | 47 ++ .../api/profile/ExceptionReplacement.java | 43 ++ .../component/api/profile/HandleException.java | 55 ++ .../component/api/profile/PortProfile.java | 22 + .../component/api/profile/Profile.java | 65 ++ .../api/profile/SemanticAnnotationProfile.java | 72 ++ .../apache/taverna/component/api/Component.java | 89 --- .../component/api/ComponentException.java | 48 -- .../taverna/component/api/ComponentFactory.java | 45 -- .../apache/taverna/component/api/Family.java | 117 ---- .../apache/taverna/component/api/License.java | 23 - .../apache/taverna/component/api/NamedItem.java | 26 - .../apache/taverna/component/api/Registry.java | 158 ----- .../taverna/component/api/SharingPolicy.java | 32 - .../apache/taverna/component/api/Version.java | 224 ------ .../component/api/config/ComponentConfig.java | 23 - .../api/config/ComponentPropertyNames.java | 32 - .../taverna/component/api/package-info.java | 25 - .../component/api/profile/ActivityProfile.java | 23 - .../component/api/profile/AnnotatedElement.java | 28 - .../api/profile/ExceptionHandling.java | 47 -- .../api/profile/ExceptionReplacement.java | 43 -- .../component/api/profile/HandleException.java | 55 -- .../component/api/profile/PortProfile.java | 22 - .../taverna/component/api/profile/Profile.java | 65 -- .../api/profile/SemanticAnnotationProfile.java | 72 -- 380 files changed, 21510 insertions(+), 21510 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentAction.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentAction.java new file mode 100644 index 0000000..f359c9d --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentAction.java @@ -0,0 +1,66 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui; + +import static java.awt.Color.RED; +import static javax.swing.SwingUtilities.invokeLater; +import static org.apache.log4j.Logger.getLogger; + +import javax.swing.AbstractAction; + +import org.apache.log4j.Logger; +import io.github.taverna_extras.component.ui.serviceprovider.ComponentServiceIcon; + +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.workbench.models.graph.GraphController; +import org.apache.taverna.workbench.models.graph.svg.SVGGraph; +import org.apache.taverna.workbench.views.graph.GraphViewComponent; + +@SuppressWarnings("serial") +public abstract class ComponentAction extends AbstractAction { + private static Logger logger = getLogger(ComponentAction.class); + + protected GraphViewComponent graphView; + + protected ComponentAction(String title, GraphViewComponent graphView) { + this.graphView = graphView; + } + + public void setIcon(ComponentServiceIcon icon) { + putValue(SMALL_ICON, icon.getIcon()); + } + + protected void markGraphAsBelongingToComponent(WorkflowBundle bundle) { + final GraphController gc = graphView.getGraphController(bundle + .getMainWorkflow()); + invokeLater(new Runnable() { + @Override + public void run() { + try { + SVGGraph g = (SVGGraph) gc.getGraph(); + g.setFillColor(RED); + gc.redraw(); + } catch (NullPointerException e) { + logger.error(e); + } + } + }); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentActivityConfigurationBean.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentActivityConfigurationBean.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentActivityConfigurationBean.java new file mode 100644 index 0000000..26e673e --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentActivityConfigurationBean.java @@ -0,0 +1,184 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui; + +import static org.apache.log4j.Logger.getLogger; +import static io.github.taverna_extras.component.api.config.ComponentPropertyNames.COMPONENT_NAME; +import static io.github.taverna_extras.component.api.config.ComponentPropertyNames.COMPONENT_VERSION; +import static io.github.taverna_extras.component.api.config.ComponentPropertyNames.FAMILY_NAME; +import static io.github.taverna_extras.component.api.config.ComponentPropertyNames.REGISTRY_BASE; +import static io.github.taverna_extras.component.ui.ComponentConstants.ACTIVITY_URI; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.log4j.Logger; +import io.github.taverna_extras.component.api.Component; +import io.github.taverna_extras.component.api.ComponentException; +import io.github.taverna_extras.component.api.ComponentFactory; +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.api.config.ComponentPropertyNames; +import io.github.taverna_extras.component.api.profile.ExceptionHandling; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.configurations.Configuration; +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.port.InputActivityPort; +import org.apache.taverna.scufl2.api.port.InputWorkflowPort; +import org.apache.taverna.scufl2.api.port.OutputActivityPort; +import org.apache.taverna.scufl2.api.port.OutputWorkflowPort; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Component activity configuration bean. + */ +public class ComponentActivityConfigurationBean extends Version.Identifier { + public static final String ERROR_CHANNEL = "error_channel"; + public static final List<String> ignorableNames = Arrays + .asList(ERROR_CHANNEL); + private static final long serialVersionUID = 5774901665863468058L; + private static final Logger logger = getLogger(ComponentActivityConfigurationBean.class); + + private ActivityPortsDefinitionBean ports = null; + private ComponentFactory factory; + private ExceptionHandling eh; + + public ComponentActivityConfigurationBean(Version.ID toBeCopied, + ComponentFactory factory) { + super(toBeCopied.getRegistryBase(), toBeCopied.getFamilyName(), + toBeCopied.getComponentName(), toBeCopied.getComponentVersion()); + this.factory = factory; + try { + getPorts(); + } catch (ComponentException e) { + logger.error("failed to get component realization", e); + } + } + + public ComponentActivityConfigurationBean(JsonNode json, + ComponentFactory factory) throws MalformedURLException { + super(getUrl(json), getFamily(json), getComponent(json), + getVersion(json)); + this.factory = factory; + } + + public ComponentActivityConfigurationBean(Configuration configuration, + ComponentFactory factory) throws MalformedURLException { + this(configuration.getJson(), factory); + } + + private static URL getUrl(JsonNode json) throws MalformedURLException { + return new URL(json.get(REGISTRY_BASE).textValue()); + } + + private static String getFamily(JsonNode json) { + return json.get(FAMILY_NAME).textValue(); + } + + private static String getComponent(JsonNode json) { + return json.get(COMPONENT_NAME).textValue(); + } + + private static Integer getVersion(JsonNode json) { + JsonNode node = json.get(COMPONENT_VERSION); + if (node == null || !node.isInt()) + return null; + return node.intValue(); + } + + public Component getComponent() throws ComponentException { + return factory.getComponent(getRegistryBase(), getFamilyName(), + getComponentName()); + } + + public Version getVersion() throws ComponentException { + return factory.getVersion(this); + } + + private ActivityPortsDefinitionBean getPortsDefinition(WorkflowBundle w) { + ActivityPortsDefinitionBean result = new ActivityPortsDefinitionBean(); + + for (InputWorkflowPort iwp : w.getMainWorkflow().getInputPorts()) + result.inputs.add(makeInputDefinition(iwp)); + for (OutputWorkflowPort owp : w.getMainWorkflow().getOutputPorts()) + result.outputs.add(makeOutputDefinition(getDepth(owp), owp.getName())); + + try { + eh = factory.getFamily(getRegistryBase(), getFamilyName()) + .getComponentProfile().getExceptionHandling(); + if (eh != null) + result.outputs.add(makeOutputDefinition(1, ERROR_CHANNEL)); + } catch (io.github.taverna_extras.component.api.ComponentException e) { + logger.error("failed to get exception handling for family", e); + } + return result; + } + + private int getDepth(OutputWorkflowPort owp) { + return 0; //FIXME How to get the depth of an output? + } + + private InputActivityPort makeInputDefinition(InputWorkflowPort dip) { + InputActivityPort port = new InputActivityPort(); + port.setName(dip.getName()); + port.setDepth(dip.getDepth()); + return port; + } + + private OutputActivityPort makeOutputDefinition(int depth, String name) { + OutputActivityPort port = new OutputActivityPort(); + port.setName(name); + port.setDepth(depth); + port.setGranularDepth(depth); + return port; + } + + /** + * @return the ports + */ + public ActivityPortsDefinitionBean getPorts() throws ComponentException { + if (ports == null) + ports = getPortsDefinition(getVersion().getImplementation()); + return ports; + } + + public ExceptionHandling getExceptionHandling() { + return eh; + } + + public void installConfiguration(Activity a) { + Configuration conf = a.createConfiguration(ACTIVITY_URI); + ObjectNode json = conf.getJsonAsObjectNode(); + json.put(REGISTRY_BASE, getRegistryBase().toExternalForm()); + json.put(FAMILY_NAME, getFamilyName()); + json.put(COMPONENT_NAME, getComponentName()); + json.put(COMPONENT_VERSION, getComponentVersion()); + } + + public static class ActivityPortsDefinitionBean { + public List<InputActivityPort> inputs = new ArrayList<>(); + public List<OutputActivityPort> outputs = new ArrayList<>(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentConstants.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentConstants.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentConstants.java new file mode 100644 index 0000000..baec10f --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/ComponentConstants.java @@ -0,0 +1,28 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui; + +import static java.net.URI.create; + +import java.net.URI; + +public interface ComponentConstants { + URI ACTIVITY_URI = create("http://ns.taverna.org.uk/2010/activity/component"); +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AbstractSemanticAnnotationContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AbstractSemanticAnnotationContextualView.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AbstractSemanticAnnotationContextualView.java new file mode 100644 index 0000000..6cc48d0 --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AbstractSemanticAnnotationContextualView.java @@ -0,0 +1,296 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static java.awt.GridBagConstraints.HORIZONTAL; +import static java.awt.GridBagConstraints.NORTHWEST; +import static java.lang.String.CASE_INSENSITIVE_ORDER; +import static org.apache.log4j.Logger.getLogger; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.createSemanticAnnotation; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.getDisplayName; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeMap; +import java.util.concurrent.ExecutionException; + +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingWorker; + +import org.apache.log4j.Logger; +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.taverna.scufl2.api.common.AbstractNamed; +import org.apache.taverna.scufl2.api.common.Named; + +import org.apache.jena.ontology.OntProperty; +import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Resource; +import org.apache.jena.rdf.model.Statement; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; + +/** + * @author alanrw + */ +public abstract class AbstractSemanticAnnotationContextualView extends + ContextualView { + private static final long serialVersionUID = 3567849347002793442L; + private static final Logger logger = getLogger(SemanticAnnotationContextualView.class); + + private final FileManager fileManager; + + public AbstractSemanticAnnotationContextualView(FileManager fileManager, + boolean allowChange) { + super(); + this.fileManager = fileManager; + this.allowChange = allowChange; + } + + private final boolean allowChange; + private JPanel panel; + private AbstractNamed annotated; + private List<SemanticAnnotationProfile> semanticAnnotationProfiles; + private Model model; + private Resource subject; + + private static Comparator<SemanticAnnotationProfile> comparator = new Comparator<SemanticAnnotationProfile>() { + @Override + public int compare(SemanticAnnotationProfile arg0, + SemanticAnnotationProfile arg1) { + String d0 = getDisplayName(arg0.getPredicate()); + String d1 = getDisplayName(arg1.getPredicate()); + return CASE_INSENSITIVE_ORDER.compare(d0, d1); + } + }; + + @Override + public JComponent getMainFrame() { + return panel; + } + + @Override + public int getPreferredPosition() { + return 510; + } + + protected final void initialise() { + populateModel(); + if (panel == null) + panel = new JPanel(new GridBagLayout()); + else + panel.removeAll(); + populatePanel(panel); + } + + public void removeStatement(Statement statement) { + model.remove(statement); + // populatePanel(panel); + updateSemanticAnnotation(); + } + + public void addStatement(Statement statement) { + model.add(statement); + // populatePanel(panel); + updateSemanticAnnotation(); + } + + public void changeStatement(Statement origStatement, OntProperty predicate, + RDFNode node) { + if (predicate == null) + return; + model.remove(origStatement); + model.add(subject, predicate, node); + // populatePanel(panel); + updateSemanticAnnotation(); + } + + public void addStatement(OntProperty predicate, RDFNode node) { + if (predicate == null) + return; + model.add(subject, predicate, node); + // populatePanel(panel); + updateSemanticAnnotation(); + } + + @Override + public void refreshView() { + populatePanel(panel); + } + + // public void addModel(Model model) { + // this.model.add(model); + // initialise(); + // updateSemanticAnnotation(); + // } + + public void updateSemanticAnnotation() { + try { + createSemanticAnnotation(fileManager.getCurrentDataflow(), + annotated, model); + } catch (IOException e) { + logger.error("failed to add semantic annotation", e); + } + } + + public void setAnnotated(Named annotated) { + this.annotated = (AbstractNamed) annotated; + } + + public void setSemanticAnnotationProfiles( + List<SemanticAnnotationProfile> profiles) { + this.semanticAnnotationProfiles = profiles; + } + + public Model getModel() { + return model; + } + + private void populateModel() { + this.model = SemanticAnnotationUtils.populateModel(fileManager + .getCurrentDataflow()); + this.subject = model.createResource(annotated.getURI().toASCIIString()); + } + + public Named getAnnotated() { + return annotated; + } + + private void populatePanel(JPanel panel) { + panel.removeAll(); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = NORTHWEST; + gbc.fill = HORIZONTAL; + gbc.gridx = 0; + gbc.weightx = 1; + gbc.weighty = 0; + gbc.insets = new Insets(5, 5, 5, 5); + panel.add(new JLabel("Reading semantic annotations"), gbc); + revalidate(); + initView(); + new StatementsReader().execute(); + } + + private Set<Statement> listStatements(OntProperty predicate) { + if (predicate == null) + return Collections.emptySet(); + return model.listStatements(subject, predicate, (RDFNode) null).toSet(); + } + + private void populateViewWithPredicates(GridBagConstraints gbc, + Map<SemanticAnnotationProfile, Set<Statement>> profileStatements, + Set<Statement> statements, + Set<SemanticAnnotationProfile> unresolvablePredicates) { + for (Entry<SemanticAnnotationProfile, Set<Statement>> entry : profileStatements + .entrySet()) { + panel.add( + new SemanticAnnotationPanel(this, entry.getKey(), entry + .getValue(), allowChange), gbc); + panel.add(new JSeparator(), gbc); + } + for (SemanticAnnotationProfile semanticAnnotationProfile : unresolvablePredicates) { + panel.add( + new UnresolveablePredicatePanel(semanticAnnotationProfile), + gbc); + panel.add(new JSeparator(), gbc); + } + + if (semanticAnnotationProfiles.isEmpty()) + panel.add(new JLabel("No annotations possible"), gbc); + for (Statement s : statements) + panel.add(new UnrecognizedStatementPanel(s), gbc); + + gbc.weighty = 1; + panel.add(new JPanel(), gbc); + } + + private class StatementsReader extends SwingWorker<Void, Object> { + private Map<SemanticAnnotationProfile, Set<Statement>> profileStatements = new TreeMap<>( + comparator); + private Set<Statement> statements; + private Set<SemanticAnnotationProfile> unresolvablePredicates = new HashSet<>(); + + @Override + protected Void doInBackground() throws Exception { + try { + parseStatements(); + } catch (Exception e) { + logger.error("failed to parse annotation statements", e); + throw e; + } + return null; + } + + private void parseStatements() { + statements = listStatements(null); + for (SemanticAnnotationProfile semanticAnnotationProfile : semanticAnnotationProfiles) { + OntProperty predicate = semanticAnnotationProfile + .getPredicate(); + if (predicate == null) { + unresolvablePredicates.add(semanticAnnotationProfile); + continue; + } + + Set<Statement> statementsWithPredicate = listStatements(predicate); + profileStatements.put(semanticAnnotationProfile, + statementsWithPredicate); + statements.removeAll(statementsWithPredicate); + } + } + + @Override + protected void done() { + panel.removeAll(); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.anchor = NORTHWEST; + gbc.fill = HORIZONTAL; + gbc.gridx = 0; + gbc.weightx = 1; + gbc.weighty = 0; + gbc.insets = new Insets(5, 5, 5, 5); + + try { + get(); + populateViewWithPredicates(gbc, profileStatements, statements, + unresolvablePredicates); + } catch (ExecutionException | InterruptedException e) { + logger.error(e); + panel.add(new JLabel("Unable to read semantic annotations"), + gbc); + } + + revalidate(); + initView(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotateSemanticsMenuAction.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotateSemanticsMenuAction.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotateSemanticsMenuAction.java new file mode 100644 index 0000000..1543533 --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotateSemanticsMenuAction.java @@ -0,0 +1,117 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static java.awt.BorderLayout.CENTER; +import static java.awt.BorderLayout.SOUTH; +import static java.awt.FlowLayout.TRAILING; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URI; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import io.github.taverna_extras.component.api.ComponentFactory; +import io.github.taverna_extras.component.api.Version; +import org.apache.taverna.lang.ui.DeselectingButton; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.common.AbstractNamed; +import org.apache.taverna.scufl2.api.port.ActivityPort; +import org.apache.taverna.ui.menu.AbstractContextualMenuAction; +import org.apache.taverna.workbench.file.FileManager; + +/** + * @author alanrw + */ +public class AnnotateSemanticsMenuAction extends AbstractContextualMenuAction { + private static final String ANNOTATE_SEMANTICS = "Annotate semantics..."; + private static final URI configureSection = URI + .create("http://taverna.sf.net/2009/contextMenu/configure"); + private FileManager fileManager; + private ComponentFactory factory; + + public AnnotateSemanticsMenuAction() { + super(configureSection, 45); + } + + public void setComponentFactory(ComponentFactory factory) { + this.factory = factory; + } + + public void setFileManager(FileManager fm) { + this.fileManager = fm; + } + + @Override + public boolean isEnabled() { + Object selection = getContextualSelection().getSelection(); + Object dataflowSource = fileManager.getDataflowSource(fileManager + .getCurrentDataflow()); + if (dataflowSource instanceof Version.ID) + return (selection instanceof AbstractNamed) + && !(selection instanceof Activity || selection instanceof ActivityPort); + return false; + } + + @SuppressWarnings("serial") + @Override + protected Action createAction() { + return new AbstractAction(ANNOTATE_SEMANTICS) { + @Override + public void actionPerformed(ActionEvent e) { + showAnnotateSemanticsPanel(); + } + }; + } + + private void showAnnotateSemanticsPanel() { + SemanticAnnotationContextualView view = new SemanticAnnotationContextualView( + fileManager, factory, (AbstractNamed) getContextualSelection() + .getSelection()); + + final JDialog dialog = new JDialog((Frame) null, "Annotate semantics"); + dialog.setLayout(new BorderLayout()); + dialog.add(new JScrollPane(view), CENTER); + + JPanel buttonPanel = new JPanel(new FlowLayout(TRAILING)); + buttonPanel.add(new DeselectingButton("OK", new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dialog.setVisible(false); + } + })); + + dialog.add(buttonPanel, SOUTH); + dialog.setSize(new Dimension(400, 300)); + dialog.setLocationRelativeTo(null); + dialog.setModal(true); + dialog.setVisible(true); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotationPropertyPanelFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotationPropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotationPropertyPanelFactory.java new file mode 100644 index 0000000..0dfaf0a --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/AnnotationPropertyPanelFactory.java @@ -0,0 +1,73 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static org.apache.jena.rdf.model.ResourceFactory.createTypedLiteral; +import static java.lang.Integer.MIN_VALUE; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.getObjectName; + +import javax.swing.JComponent; +import javax.swing.JTextArea; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.jena.ontology.OntProperty; +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; + +/** + * + * + * @author Alan Williams + */ +public class AnnotationPropertyPanelFactory extends PropertyPanelFactorySPI { + @Override + public JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return getDefaultInputComponent(semanticAnnotationProfile, statement); + } + + @Override + public RDFNode getNewTargetNode(Statement originalStatement, + JComponent component) { + String newText = ((JTextArea) component).getText(); + if ((originalStatement == null) + || !getObjectName(originalStatement).equals(newText)) + return createTypedLiteral(newText); + return null; + } + + @Override + public int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile) { + OntProperty property = semanticAnnotationProfile.getPredicate(); + if ((property != null) && property.isAnnotationProperty()) + return 100; + return MIN_VALUE; + } + + @Override + public JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return getDefaultDisplayComponent(semanticAnnotationProfile, statement); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DatatypePropertyPanelFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DatatypePropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DatatypePropertyPanelFactory.java new file mode 100644 index 0000000..bd7ebcc --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DatatypePropertyPanelFactory.java @@ -0,0 +1,76 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static org.apache.jena.rdf.model.ResourceFactory.createTypedLiteral; +import static java.lang.Integer.MIN_VALUE; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.getObjectName; + +import javax.swing.JComponent; +import javax.swing.JTextArea; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.jena.ontology.OntProperty; +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; + +/** + * @author Alan Williams + */ +public class DatatypePropertyPanelFactory extends PropertyPanelFactorySPI { + public DatatypePropertyPanelFactory() { + super(); + } + + @Override + public JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return getDefaultInputComponent(semanticAnnotationProfile, statement); + } + + @Override + public RDFNode getNewTargetNode(Statement originalStatement, + JComponent component) { + JTextArea inputText = (JTextArea) component; + String newText = inputText.getText(); + if ((originalStatement == null) + || !getObjectName(originalStatement).equals(newText)) + return createTypedLiteral(newText); + return null; + } + + @Override + public int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile) { + OntProperty property = semanticAnnotationProfile.getPredicate(); + if ((property != null) && property.isDatatypeProperty()) + return 100; + return MIN_VALUE; + } + + @Override + public JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return getDefaultDisplayComponent(semanticAnnotationProfile, statement); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DateTimePropertyPanelFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DateTimePropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DateTimePropertyPanelFactory.java new file mode 100644 index 0000000..e9dbda7 --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/DateTimePropertyPanelFactory.java @@ -0,0 +1,136 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static org.apache.jena.datatypes.xsd.XSDDatatype.XSDdateTime; +import static org.apache.jena.rdf.model.ResourceFactory.createTypedLiteral; +import static java.lang.Integer.MIN_VALUE; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import javax.swing.JComponent; +import javax.swing.JSpinner; +import javax.swing.SpinnerDateModel; +import javax.swing.text.DefaultCaret; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.jena.datatypes.xsd.XSDDateTime; +import org.apache.jena.ontology.OntProperty; +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; + +/** + * + * + * @author Alan Williams + */ +public class DateTimePropertyPanelFactory extends PropertyPanelFactorySPI { + + private static String DateTimeString = XSDdateTime.getURI(); + + public DateTimePropertyPanelFactory() { + super(); + } + + @Override + public JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + Date now = new Date(); + SpinnerDateModel dateModel = new SpinnerDateModel(now, null, now, + Calendar.DAY_OF_MONTH); + JSpinner s = new JSpinner(dateModel); + JSpinner.DateEditor de = new JSpinner.DateEditor(s, + "yyyy-MM-dd-HH-mm-ss"); + + /* + * Suggested hack from + * http://www.coderanch.com/t/345684/GUI/java/JSpinner-DateEditor-Set-default-focus + */ + + de.getTextField().setCaret(new DefaultCaret() { + private static final long serialVersionUID = 6779256780590610172L; + private boolean diverted = false; + + @Override + public void setDot(int dot) { + diverted = (dot == 0); + if (diverted) + dot = getComponent().getDocument().getLength(); + super.setDot(dot); + } + + @Override + public void moveDot(int dot) { + if (diverted) { + super.setDot(0); + diverted = false; + } + super.moveDot(dot); + } + }); + s.setEditor(de); + if (statement != null) { + Object o = statement.getObject().asLiteral().getValue(); + if (o instanceof XSDDateTime) + dateModel.setValue(((XSDDateTime) o).asCalendar().getTime()); + } + return s; + } + + @Override + public RDFNode getNewTargetNode(Statement originalStatement, + JComponent component) { + JSpinner spinner = (JSpinner) component; + Date d = (Date) spinner.getValue(); + if ((originalStatement == null) + || !originalStatement.getObject().asLiteral().getValue() + .equals(d)) { + Calendar cal = GregorianCalendar.getInstance(); + cal.setTime(d); + return createTypedLiteral(cal); + } + return null; + } + + @Override + public int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile) { + OntProperty property = semanticAnnotationProfile.getPredicate(); + if ((property != null) && property.isDatatypeProperty() + && DateTimeString.equals(semanticAnnotationProfile + .getClassString())) + return 200; + return MIN_VALUE; + } + + @Override + public JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + JComponent result = getInputComponent(semanticAnnotationProfile, + statement); + result.setEnabled(false); + return result; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/FallbackPropertyPanelFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/FallbackPropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/FallbackPropertyPanelFactory.java new file mode 100644 index 0000000..efc3b42 --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/FallbackPropertyPanelFactory.java @@ -0,0 +1,60 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import javax.swing.JComponent; +import javax.swing.JLabel; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; + +/** + * @author alanrw + */ +public class FallbackPropertyPanelFactory extends PropertyPanelFactorySPI { + @Override + public JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return new JLabel("Unable to handle " + + semanticAnnotationProfile.getPredicateString()); + } + + @Override + public RDFNode getNewTargetNode(Statement originalStatement, + JComponent component) { + return null; + } + + @Override + public int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile) { + return 0; + } + + @Override + public JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return getDefaultDisplayComponent(semanticAnnotationProfile, statement); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/GreyBorder.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/GreyBorder.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/GreyBorder.java new file mode 100644 index 0000000..d5e4fbe --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/GreyBorder.java @@ -0,0 +1,36 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; + +import javax.swing.border.AbstractBorder; + +@SuppressWarnings("serial") +class GreyBorder extends AbstractBorder { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, + int height) { + g.setColor(Color.GRAY); + g.drawLine(x, y + height - 1, x + width - 1, y + height - 1); + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/ObjectPropertyWithIndividualsPanelFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/ObjectPropertyWithIndividualsPanelFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/ObjectPropertyWithIndividualsPanelFactory.java new file mode 100644 index 0000000..fefe5c0 --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/ObjectPropertyWithIndividualsPanelFactory.java @@ -0,0 +1,196 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static java.awt.FlowLayout.RIGHT; +import static java.awt.GridBagConstraints.EAST; +import static java.awt.GridBagConstraints.NORTHWEST; +import static java.lang.Integer.MIN_VALUE; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; +import static javax.swing.JOptionPane.showConfirmDialog; +import static javax.swing.JOptionPane.showInputDialog; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.getDisplayName; + +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; +import io.github.taverna_extras.component.ui.localworld.LocalWorld; + +import org.apache.jena.ontology.Individual; +import org.apache.jena.ontology.OntClass; +import org.apache.jena.ontology.OntModel; +import org.apache.jena.ontology.OntProperty; +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; +import org.apache.taverna.lang.ui.DeselectingButton; + +/** + * @author David Withers + * @author Alan Williams + */ +public class ObjectPropertyWithIndividualsPanelFactory extends + PropertyPanelFactorySPI { + /* + * TODO Consider what sort of sharing model is appropriate for the local + * world + */ + private static LocalWorld localWorld = LocalWorld.getInstance(); + + @Override + public int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile) { + OntProperty property = semanticAnnotationProfile.getPredicate(); + if ((property != null) && property.isObjectProperty() + /* + * && !semanticAnnotationProfile.getIndividuals().isEmpty() + */) + return 100; + return MIN_VALUE; + } + + @Override + public JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + return new ComboBoxWithAdd(semanticAnnotationProfile, statement); + } + + @Override + public RDFNode getNewTargetNode(Statement originalStatement, + JComponent component) { + ComboBoxWithAdd panel = (ComboBoxWithAdd) component; + RDFNode newNode = panel.getSelectedItem(); + if ((originalStatement == null) + || !originalStatement.getObject().equals(newNode)) + return newNode; + return null; + } + + + private static class ComboBoxWithAdd extends JPanel { + private static final long serialVersionUID = -9156213096428945270L; + private static DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer(); + OntClass rangeClass = null; + JComboBox<Individual> resources; + + public ComboBoxWithAdd( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + super(new GridBagLayout()); + + rangeClass = semanticAnnotationProfile.getRangeClass(); + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = NORTHWEST; + List<Individual> individuals = semanticAnnotationProfile + .getIndividuals(); + if (rangeClass != null) + individuals + .addAll(localWorld.getIndividualsOfClass(rangeClass)); + + resources = new JComboBox<Individual>(new Vector<>(individuals)); + resources.setRenderer(new ListCellRenderer<Individual>() { + @Override + public Component getListCellRendererComponent( + JList<? extends Individual> list, Individual value, + int index, boolean isSelected, boolean cellHasFocus) { + return defaultRenderer.getListCellRendererComponent(list, + getDisplayName(value), index, isSelected, + cellHasFocus); + } + }); + resources.setEditable(false); + if (statement != null) { + Object origResource = statement.getObject(); + if (origResource != null) + resources.setSelectedItem(origResource); + } + this.add(resources, gbc); + + gbc.gridy++; + + JPanel buttonPanel = new JPanel(new FlowLayout(RIGHT)); + buttonPanel.add(new DeselectingButton("Add external", + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addExternal(); + } + })); + buttonPanel.add(new DeselectingButton("Add local", + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addLocal(); + } + })); + gbc.anchor = EAST; + this.add(buttonPanel, gbc); + } + + private void addExternal() { + String answer = showInputDialog("Please enter the URL for the resource"); + resources.addItem(localWorld.createIndividual(answer, rangeClass)); + } + + private void addLocal() { + TurtleInputPanel turtlePanel = new TurtleInputPanel(rangeClass); + if (showConfirmDialog(null, turtlePanel, "Turtle input", + OK_CANCEL_OPTION, QUESTION_MESSAGE) == OK_OPTION) { + OntModel addedModel = turtlePanel.getContentAsModel(); + for (Individual i : addedModel.listIndividuals(rangeClass) + .toList()) + resources.addItem(i); + localWorld.addModelFromString(turtlePanel.getContentAsString()); + } + } + + public RDFNode getSelectedItem() { + return (RDFNode) resources.getSelectedItem(); + } + } + + @Override + public JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + JComponent result = getDefaultDisplayComponent( + semanticAnnotationProfile, statement); + return result; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/PropertyPanelFactorySPI.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/PropertyPanelFactorySPI.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/PropertyPanelFactorySPI.java new file mode 100644 index 0000000..2b8dd7d --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/PropertyPanelFactorySPI.java @@ -0,0 +1,82 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static java.awt.Color.WHITE; +import static io.github.taverna_extras.component.ui.annotation.SemanticAnnotationUtils.getObjectName; + +import javax.swing.JComponent; +import javax.swing.JTextArea; +import javax.swing.border.EmptyBorder; + +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.jena.rdf.model.RDFNode; +import org.apache.jena.rdf.model.Statement; + +/** + * @author David Withers + */ +public abstract class PropertyPanelFactorySPI { + public abstract JComponent getInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement); + + /** + * Returns null if the target node is the same as the original statement + * + * @param origStatement + * @param inputComponent + * @return + */ + public abstract RDFNode getNewTargetNode(Statement origStatement, + JComponent inputComponent); + + public abstract int getRatingForSemanticAnnotation( + SemanticAnnotationProfile semanticAnnotationProfile); + + public abstract JComponent getDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement); + + public static JComponent getDefaultInputComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + JTextArea inputText = new JTextArea(20, 80); + if (statement != null) + inputText.setText(getObjectName(statement)); + inputText.setLineWrap(true); + inputText.setWrapStyleWord(true); + return inputText; + } + + public static JComponent getDefaultDisplayComponent( + SemanticAnnotationProfile semanticAnnotationProfile, + Statement statement) { + JTextArea value = new JTextArea(getObjectName(statement)); + value.setLineWrap(true); + value.setWrapStyleWord(true); + value.setEditable(false); + value.setBackground(WHITE); + value.setOpaque(true); + value.setBorder(new EmptyBorder(2, 4, 2, 4)); + return value; + } +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualView.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualView.java new file mode 100644 index 0000000..4aa2b4e --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualView.java @@ -0,0 +1,144 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import static java.lang.String.format; +import static org.apache.log4j.Logger.getLogger; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; +import io.github.taverna_extras.component.api.ComponentException; +import io.github.taverna_extras.component.api.ComponentFactory; +import io.github.taverna_extras.component.api.Family; +import io.github.taverna_extras.component.api.Registry; +import io.github.taverna_extras.component.api.Version; +import io.github.taverna_extras.component.api.profile.Profile; +import io.github.taverna_extras.component.api.profile.SemanticAnnotationProfile; + +import org.apache.taverna.scufl2.api.common.AbstractNamed; +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.core.Processor; +import org.apache.taverna.scufl2.api.core.Workflow; +import org.apache.taverna.scufl2.api.port.InputWorkflowPort; +import org.apache.taverna.scufl2.api.port.OutputWorkflowPort; +import org.apache.taverna.workbench.file.FileManager; + +/** + * @author David Withers + */ +public class SemanticAnnotationContextualView extends + AbstractSemanticAnnotationContextualView { + private static final long serialVersionUID = -322165507536778154L; + public static final String VIEW_TITLE = "Semantic Annotations"; + private static Logger logger = getLogger(SemanticAnnotationContextualView.class); + + private final FileManager fileManager; + private final ComponentFactory factory; + + public SemanticAnnotationContextualView(FileManager fileManager, + ComponentFactory factory, AbstractNamed selection) { + super(fileManager, true); + this.fileManager = fileManager; + this.factory = factory; + super.setAnnotated(selection); + List<SemanticAnnotationProfile> profiles = new ArrayList<>(); + try { + Profile componentProfile = getComponentProfile(); + if (componentProfile != null) { + if (selection instanceof Workflow + || selection instanceof WorkflowBundle) + profiles = componentProfile.getSemanticAnnotations(); + else if (selection instanceof InputWorkflowPort) + profiles = componentProfile + .getInputSemanticAnnotationProfiles(); + else if (selection instanceof OutputWorkflowPort) + profiles = componentProfile + .getOutputSemanticAnnotationProfiles(); + else if (selection instanceof Processor) + profiles = componentProfile + .getActivitySemanticAnnotationProfiles(); + } + } catch (ComponentException e) { + logger.error("failed to look up semantic annotations", e); + } + super.setSemanticAnnotationProfiles(profiles); + super.initialise(); + } + + private Profile getComponentProfile() { + Object dataflowSource = fileManager.getDataflowSource(fileManager + .getCurrentDataflow()); + if (dataflowSource instanceof Version.ID) { + Version.ID identification = (Version.ID) dataflowSource; + try { + Registry componentRegistry = factory.getRegistry(identification + .getRegistryBase()); + Family componentFamily = componentRegistry + .getComponentFamily(identification.getFamilyName()); + return componentFamily.getComponentProfile(); + } catch (ComponentException e) { + logger.warn( + format("No component profile found for component family %s at component registry %s", + identification.getFamilyName(), + identification.getRegistryBase()), e); + } + } + return null; + } + + @Override + public String getViewTitle() { + return VIEW_TITLE; + } + +/* + public static void main(String[] args) throws Exception { + JFrame frame = new JFrame(); + frame.setSize(400, 200); + ComponentVersionIdentification identification = new ComponentVersionIdentification( + new URL("http://sandbox.myexperiment.org"), + "SCAPE Migration Action Components", "Image To Tiff", 2); + Dataflow dataflow = fileManager.openDataflow(new ComponentFileType(), + identification); + + Processor processor = edits.createProcessor("processor"); + try { + editManager.doDataflowEdit(dataflow, + edits.getAddProcessorEdit(dataflow, processor)); + } catch (EditException e) { + e.printStackTrace(); + } + final SemanticAnnotationContextualView view = new SemanticAnnotationContextualView( + processor); + editManager.addObserver(new Observer<EditManager.EditManagerEvent>() { + @Override + public void notify(Observable<EditManagerEvent> arg0, + EditManagerEvent arg1) throws Exception { + view.refreshView(); + view.repaint(); + } + }); + frame.add(view); + frame.setVisible(true); + } +*/ +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/b7b61e71/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualViewFactory.java b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualViewFactory.java new file mode 100644 index 0000000..8ec838f --- /dev/null +++ b/taverna-component-activity-ui/src/main/java/io/github/taverna_extras/component/ui/annotation/SemanticAnnotationContextualViewFactory.java @@ -0,0 +1,67 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package io.github.taverna_extras.component.ui.annotation; + +import java.util.Arrays; +import java.util.List; + +import io.github.taverna_extras.component.api.ComponentFactory; +import io.github.taverna_extras.component.api.Version; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.common.AbstractNamed; +import org.apache.taverna.scufl2.api.container.WorkflowBundle; +import org.apache.taverna.scufl2.api.port.ActivityPort; +import org.apache.taverna.workbench.file.FileManager; +import org.apache.taverna.workbench.ui.views.contextualviews.ContextualView; +import org.apache.taverna.workbench.ui.views.contextualviews.activity.ContextualViewFactory; + +/** + * @author David Withers + */ +public class SemanticAnnotationContextualViewFactory implements + ContextualViewFactory<AbstractNamed> { + private FileManager fileManager; + private ComponentFactory factory; + + private WorkflowBundle bundle; + + public void setComponentFactory(ComponentFactory factory) { + this.factory = factory; + } + + public void setFileManager(FileManager fm) { + this.fileManager = fm; + } + + @Override + public boolean canHandle(Object selection) { + bundle = fileManager.getCurrentDataflow(); + return fileManager.getDataflowSource(bundle) instanceof Version.ID + && selection instanceof AbstractNamed + && !(selection instanceof Activity || selection instanceof ActivityPort); + } + + @Override + public List<ContextualView> getViews(AbstractNamed selection) { + return Arrays.asList(new SemanticAnnotationContextualView(fileManager, + factory, selection), new TurtleContextualView(selection, bundle)); + } +}
