You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:36:05 UTC
[50/58] [abbrv] incubator-taverna-plugin-component git commit:
org.apache.taverna.component.ui
org.apache.taverna.component.ui
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/43334c1d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/tree/43334c1d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/diff/43334c1d
Branch: refs/heads/master
Commit: 43334c1d0298bb6e8b30f9a7558ebfc85afb5ca2
Parents: 40c404c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Sat Feb 21 21:23:22 2015 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Sat Feb 21 21:23:22 2015 +0000
----------------------------------------------------------------------
...bstractSemanticAnnotationContextualView.java | 281 ---------
.../annotation/AnnotateSemanticsMenuAction.java | 101 ---
.../AnnotationPropertyPanelFactory.java | 74 ---
.../DatatypePropertyPanelFactory.java | 77 ---
.../DateTimePropertyPanelFactory.java | 137 ----
.../FallbackPropertyPanelFactory.java | 44 --
.../t2/component/annotation/GreyBorder.java | 17 -
...jectPropertyWithIndividualsPanelFactory.java | 198 ------
.../annotation/PropertyPanelFactorySPI.java | 83 ---
.../SemanticAnnotationContextualView.java | 146 -----
...SemanticAnnotationContextualViewFactory.java | 68 --
.../annotation/SemanticAnnotationPanel.java | 253 --------
.../annotation/SemanticAnnotationUtils.java | 191 ------
.../annotation/TurtleContextualView.java | 78 ---
.../component/annotation/TurtleInputPanel.java | 90 ---
.../annotation/UnrecognizedStatementPanel.java | 27 -
.../annotation/UnresolveablePredicatePanel.java | 27 -
.../t2/component/localworld/LocalWorld.java | 92 ---
.../component/preference/ComponentDefaults.java | 39 --
.../preference/ComponentPreference.java | 128 ----
.../t2/component/ui/ComponentAction.java | 48 --
.../ui/ComponentActivityConfigurationBean.java | 165 -----
.../t2/component/ui/ComponentConstants.java | 9 -
.../ui/config/ComponentConfigurationPanel.java | 153 -----
.../ui/config/ComponentConfigureAction.java | 50 --
.../ComponentDataflowHealthCheckExplainer.java | 75 ---
.../ui/file/ComponentDataflowHealthChecker.java | 89 ---
.../t2/component/ui/file/ComponentOpener.java | 73 ---
.../t2/component/ui/file/ComponentSaver.java | 170 -----
.../component/ui/file/FileManagerObserver.java | 128 ----
.../AbstractContextComponentMenuAction.java | 39 --
.../ui/menu/ComponentConfigureMenuAction.java | 63 --
.../t2/component/ui/menu/ComponentMenu.java | 27 -
.../t2/component/ui/menu/ComponentSection.java | 29 -
.../ui/menu/NestedWorkflowCreationDialog.java | 628 -------------------
.../menu/NestedWorkflowCreatorMenuAction.java | 78 ---
...penComponentFromComponentActivityAction.java | 66 --
...omponentFromComponentActivityMenuAction.java | 88 ---
.../ui/menu/ReplaceByComponentAction.java | 261 --------
.../ui/menu/ReplaceByComponentMenuAction.java | 71 ---
.../component/AbstractComponentMenuAction.java | 13 -
.../ui/menu/component/ComponentCloseAction.java | 58 --
.../component/ComponentCloseMenuAction.java | 50 --
.../ui/menu/component/ComponentCopyAction.java | 149 -----
.../menu/component/ComponentCopyMenuAction.java | 45 --
.../menu/component/ComponentCreatorSupport.java | 241 -------
.../menu/component/ComponentDeleteAction.java | 128 ----
.../component/ComponentDeleteMenuAction.java | 51 --
.../ui/menu/component/ComponentMenuAction.java | 38 --
.../ui/menu/component/ComponentMenuSection.java | 22 -
.../ui/menu/component/ComponentMergeAction.java | 120 ----
.../component/ComponentMergeMenuAction.java | 39 --
.../ui/menu/component/ComponentSaveAction.java | 54 --
.../menu/component/ComponentSaveMenuAction.java | 51 --
.../menu/component/ComponentSearchAction.java | 155 -----
.../component/ComponentSearchMenuAction.java | 70 ---
.../ComponentServiceCreatorAction.java | 97 ---
.../ComponentServiceCreatorMenuAction.java | 60 --
.../ComponentWorkflowCreatorAction.java | 69 --
.../ComponentWorkflowCreatorMenuAction.java | 56 --
.../FileOpenFromComponentMenuAction.java | 58 --
.../OpenWorkflowFromComponentAction.java | 122 ----
.../family/ComponentFamilyCreateAction.java | 161 -----
.../family/ComponentFamilyCreateMenuAction.java | 42 --
.../family/ComponentFamilyDeleteAction.java | 186 ------
.../family/ComponentFamilyDeleteMenuAction.java | 53 --
.../menu/family/ComponentFamilyMenuSection.java | 21 -
.../profile/ComponentProfileCopyAction.java | 162 -----
.../profile/ComponentProfileCopyMenuAction.java | 42 --
.../profile/ComponentProfileDeleteAction.java | 98 ---
.../ComponentProfileDeleteMenuAction.java | 42 --
.../profile/ComponentProfileImportAction.java | 166 -----
.../ComponentProfileImportMenuAction.java | 49 --
.../profile/ComponentProfileMenuSection.java | 25 -
.../registry/ComponentRegistryManageAction.java | 34 -
.../ComponentRegistryManageMenuAction.java | 47 --
.../registry/ComponentRegistryMenuSection.java | 22 -
.../ui/panel/ComponentChoiceMessage.java | 34 -
.../ui/panel/ComponentChooserPanel.java | 218 -------
.../ui/panel/ComponentListCellRenderer.java | 46 --
.../ui/panel/ComponentVersionChooserPanel.java | 171 -----
.../component/ui/panel/FamilyChoiceMessage.java | 24 -
.../component/ui/panel/FamilyChooserPanel.java | 220 -------
.../component/ui/panel/LicenseChooserPanel.java | 189 ------
.../t2/component/ui/panel/PrefixPanel.java | 81 ---
.../ui/panel/ProfileChoiceMessage.java | 24 -
.../component/ui/panel/ProfileChooserPanel.java | 204 ------
...stryAndFamilyChooserComponentEntryPanel.java | 83 ---
.../ui/panel/RegistryAndFamilyChooserPanel.java | 87 ---
.../ui/panel/RegistryChoiceMessage.java | 24 -
.../ui/panel/RegistryChooserPanel.java | 123 ----
.../component/ui/panel/SearchChoicePanel.java | 244 -------
.../ui/panel/SharingPolicyChooserPanel.java | 159 -----
.../ui/preference/ComponentPreferencePanel.java | 283 ---------
.../ComponentPreferenceUIFactory.java | 47 --
.../ui/preference/LocalRegistryPanel.java | 117 ----
.../ui/preference/RegistryTableModel.java | 70 ---
.../ui/preference/RemoteRegistryPanel.java | 78 ---
.../serviceprovider/ComponentServiceDesc.java | 156 -----
.../serviceprovider/ComponentServiceIcon.java | 33 -
.../ComponentServiceProvider.java | 218 -------
.../ComponentServiceProviderConfig.java | 69 --
.../component/ui/serviceprovider/Service.java | 8 -
.../t2/component/ui/util/ComponentFileType.java | 32 -
.../component/ui/util/ComponentHealthCheck.java | 66 --
.../sf/taverna/t2/component/ui/util/Utils.java | 126 ----
.../ComponentActivityContextViewFactory.java | 121 ----
...itySemanticAnnotationContextViewFactory.java | 135 ----
...omponentActivitySemanticAnnotationPanel.java | 93 ---
.../ui/view/ComponentContextViewFactory.java | 42 --
.../ui/view/ComponentContextualView.java | 75 ---
.../taverna/t2/component/ui/view/ViewUtil.java | 163 -----
.../taverna/component/ui/ComponentAction.java | 48 ++
.../ui/ComponentActivityConfigurationBean.java | 165 +++++
.../component/ui/ComponentConstants.java | 9 +
...bstractSemanticAnnotationContextualView.java | 281 +++++++++
.../annotation/AnnotateSemanticsMenuAction.java | 101 +++
.../AnnotationPropertyPanelFactory.java | 74 +++
.../DatatypePropertyPanelFactory.java | 77 +++
.../DateTimePropertyPanelFactory.java | 137 ++++
.../FallbackPropertyPanelFactory.java | 44 ++
.../component/ui/annotation/GreyBorder.java | 17 +
...jectPropertyWithIndividualsPanelFactory.java | 198 ++++++
.../ui/annotation/PropertyPanelFactorySPI.java | 83 +++
.../SemanticAnnotationContextualView.java | 146 +++++
...SemanticAnnotationContextualViewFactory.java | 68 ++
.../ui/annotation/SemanticAnnotationPanel.java | 253 ++++++++
.../ui/annotation/SemanticAnnotationUtils.java | 191 ++++++
.../ui/annotation/TurtleContextualView.java | 78 +++
.../ui/annotation/TurtleInputPanel.java | 90 +++
.../annotation/UnrecognizedStatementPanel.java | 27 +
.../annotation/UnresolveablePredicatePanel.java | 27 +
.../ui/config/ComponentConfigurationPanel.java | 153 +++++
.../ui/config/ComponentConfigureAction.java | 50 ++
.../ComponentDataflowHealthCheckExplainer.java | 75 +++
.../ui/file/ComponentDataflowHealthChecker.java | 89 +++
.../component/ui/file/ComponentOpener.java | 73 +++
.../component/ui/file/ComponentSaver.java | 170 +++++
.../component/ui/file/FileManagerObserver.java | 128 ++++
.../component/ui/localworld/LocalWorld.java | 92 +++
.../AbstractContextComponentMenuAction.java | 39 ++
.../ui/menu/ComponentConfigureMenuAction.java | 63 ++
.../component/ui/menu/ComponentMenu.java | 27 +
.../component/ui/menu/ComponentSection.java | 29 +
.../ui/menu/NestedWorkflowCreationDialog.java | 628 +++++++++++++++++++
.../menu/NestedWorkflowCreatorMenuAction.java | 78 +++
...penComponentFromComponentActivityAction.java | 66 ++
...omponentFromComponentActivityMenuAction.java | 88 +++
.../ui/menu/ReplaceByComponentAction.java | 261 ++++++++
.../ui/menu/ReplaceByComponentMenuAction.java | 71 +++
.../component/AbstractComponentMenuAction.java | 13 +
.../ui/menu/component/ComponentCloseAction.java | 58 ++
.../component/ComponentCloseMenuAction.java | 51 ++
.../ui/menu/component/ComponentCopyAction.java | 149 +++++
.../menu/component/ComponentCopyMenuAction.java | 45 ++
.../menu/component/ComponentCreatorSupport.java | 241 +++++++
.../menu/component/ComponentDeleteAction.java | 128 ++++
.../component/ComponentDeleteMenuAction.java | 52 ++
.../ui/menu/component/ComponentMenuAction.java | 38 ++
.../ui/menu/component/ComponentMenuSection.java | 22 +
.../ui/menu/component/ComponentMergeAction.java | 120 ++++
.../component/ComponentMergeMenuAction.java | 39 ++
.../ui/menu/component/ComponentSaveAction.java | 54 ++
.../menu/component/ComponentSaveMenuAction.java | 52 ++
.../menu/component/ComponentSearchAction.java | 155 +++++
.../component/ComponentSearchMenuAction.java | 70 +++
.../ComponentServiceCreatorAction.java | 97 +++
.../ComponentServiceCreatorMenuAction.java | 61 ++
.../ComponentWorkflowCreatorAction.java | 69 ++
.../ComponentWorkflowCreatorMenuAction.java | 57 ++
.../FileOpenFromComponentMenuAction.java | 59 ++
.../OpenWorkflowFromComponentAction.java | 122 ++++
.../family/ComponentFamilyCreateAction.java | 160 +++++
.../family/ComponentFamilyCreateMenuAction.java | 43 ++
.../family/ComponentFamilyDeleteAction.java | 186 ++++++
.../family/ComponentFamilyDeleteMenuAction.java | 54 ++
.../menu/family/ComponentFamilyMenuSection.java | 22 +
.../profile/ComponentProfileCopyAction.java | 161 +++++
.../profile/ComponentProfileCopyMenuAction.java | 43 ++
.../profile/ComponentProfileDeleteAction.java | 97 +++
.../ComponentProfileDeleteMenuAction.java | 43 ++
.../profile/ComponentProfileImportAction.java | 166 +++++
.../ComponentProfileImportMenuAction.java | 49 ++
.../profile/ComponentProfileMenuSection.java | 25 +
.../registry/ComponentRegistryManageAction.java | 35 ++
.../ComponentRegistryManageMenuAction.java | 48 ++
.../registry/ComponentRegistryMenuSection.java | 22 +
.../ui/panel/ComponentChoiceMessage.java | 34 +
.../ui/panel/ComponentChooserPanel.java | 218 +++++++
.../ui/panel/ComponentListCellRenderer.java | 46 ++
.../ui/panel/ComponentVersionChooserPanel.java | 171 +++++
.../component/ui/panel/FamilyChoiceMessage.java | 24 +
.../component/ui/panel/FamilyChooserPanel.java | 220 +++++++
.../component/ui/panel/LicenseChooserPanel.java | 189 ++++++
.../taverna/component/ui/panel/PrefixPanel.java | 81 +++
.../ui/panel/ProfileChoiceMessage.java | 24 +
.../component/ui/panel/ProfileChooserPanel.java | 204 ++++++
...stryAndFamilyChooserComponentEntryPanel.java | 82 +++
.../ui/panel/RegistryAndFamilyChooserPanel.java | 87 +++
.../ui/panel/RegistryChoiceMessage.java | 24 +
.../ui/panel/RegistryChooserPanel.java | 123 ++++
.../component/ui/panel/SearchChoicePanel.java | 243 +++++++
.../ui/panel/SharingPolicyChooserPanel.java | 159 +++++
.../ui/preference/ComponentDefaults.java | 39 ++
.../ui/preference/ComponentPreference.java | 128 ++++
.../ui/preference/ComponentPreferencePanel.java | 282 +++++++++
.../ComponentPreferenceUIFactory.java | 46 ++
.../ui/preference/LocalRegistryPanel.java | 117 ++++
.../ui/preference/RegistryTableModel.java | 70 +++
.../ui/preference/RemoteRegistryPanel.java | 78 +++
.../serviceprovider/ComponentServiceDesc.java | 156 +++++
.../serviceprovider/ComponentServiceIcon.java | 33 +
.../ComponentServiceProvider.java | 218 +++++++
.../ComponentServiceProviderConfig.java | 69 ++
.../component/ui/serviceprovider/Service.java | 8 +
.../component/ui/util/ComponentFileType.java | 32 +
.../component/ui/util/ComponentHealthCheck.java | 65 ++
.../apache/taverna/component/ui/util/Utils.java | 126 ++++
.../ComponentActivityContextViewFactory.java | 121 ++++
...itySemanticAnnotationContextViewFactory.java | 135 ++++
...omponentActivitySemanticAnnotationPanel.java | 93 +++
.../ui/view/ComponentContextViewFactory.java | 42 ++
.../ui/view/ComponentContextualView.java | 75 +++
.../taverna/component/ui/view/ViewUtil.java | 162 +++++
...component.annotation.PropertyPanelFactorySPI | 10 +-
...t2.workbench.report.explainer.VisitExplainer | 2 +-
.../spring/component-activity-context.xml | 102 +--
227 files changed, 11281 insertions(+), 11277 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AbstractSemanticAnnotationContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AbstractSemanticAnnotationContextualView.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AbstractSemanticAnnotationContextualView.java
deleted file mode 100644
index 93b07a2..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AbstractSemanticAnnotationContextualView.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.NORTHWEST;
-import static java.lang.String.CASE_INSENSITIVE_ORDER;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.createSemanticAnnotation;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getDisplayName;
-import static org.apache.log4j.Logger.getLogger;
-
-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 net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.common.Named;
-
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Statement;
-
-/**
- * @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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotateSemanticsMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotateSemanticsMenuAction.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotateSemanticsMenuAction.java
deleted file mode 100644
index 92d2935..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotateSemanticsMenuAction.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.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 org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.port.ActivityPort;
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-import net.sf.taverna.t2.ui.menu.AbstractContextualMenuAction;
-import net.sf.taverna.t2.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotationPropertyPanelFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotationPropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotationPropertyPanelFactory.java
deleted file mode 100644
index 5f1ff0e..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/AnnotationPropertyPanelFactory.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static com.hp.hpl.jena.rdf.model.ResourceFactory.createTypedLiteral;
-import static java.lang.Integer.MIN_VALUE;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getObjectName;
-
-import javax.swing.JComponent;
-import javax.swing.JTextArea;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DatatypePropertyPanelFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DatatypePropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DatatypePropertyPanelFactory.java
deleted file mode 100644
index a8d6344..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DatatypePropertyPanelFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static com.hp.hpl.jena.rdf.model.ResourceFactory.createTypedLiteral;
-import static java.lang.Integer.MIN_VALUE;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getObjectName;
-
-import javax.swing.JComponent;
-import javax.swing.JTextArea;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DateTimePropertyPanelFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DateTimePropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DateTimePropertyPanelFactory.java
deleted file mode 100644
index 566f49d..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/DateTimePropertyPanelFactory.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static com.hp.hpl.jena.datatypes.xsd.XSDDatatype.XSDdateTime;
-import static com.hp.hpl.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 org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import com.hp.hpl.jena.datatypes.xsd.XSDDateTime;
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/FallbackPropertyPanelFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/FallbackPropertyPanelFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/FallbackPropertyPanelFactory.java
deleted file mode 100644
index 5b32370..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/FallbackPropertyPanelFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/GreyBorder.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/GreyBorder.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/GreyBorder.java
deleted file mode 100644
index c171497..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/GreyBorder.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package net.sf.taverna.t2.component.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/ObjectPropertyWithIndividualsPanelFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/ObjectPropertyWithIndividualsPanelFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/ObjectPropertyWithIndividualsPanelFactory.java
deleted file mode 100644
index c6c27dd..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/ObjectPropertyWithIndividualsPanelFactory.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.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 net.sf.taverna.t2.component.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 org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.component.localworld.LocalWorld;
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-
-import com.hp.hpl.jena.ontology.Individual;
-import com.hp.hpl.jena.ontology.OntClass;
-import com.hp.hpl.jena.ontology.OntModel;
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Statement;
-
-/**
- * @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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/PropertyPanelFactorySPI.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/PropertyPanelFactorySPI.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/PropertyPanelFactorySPI.java
deleted file mode 100644
index e9a9981..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/PropertyPanelFactorySPI.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static java.awt.Color.WHITE;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getObjectName;
-
-import javax.swing.JComponent;
-import javax.swing.JTextArea;
-import javax.swing.border.EmptyBorder;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualView.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualView.java
deleted file mode 100644
index b347252..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualView.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static java.lang.String.format;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Family;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.Version;
-import org.apache.taverna.component.api.profile.Profile;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-
-/**
- * @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/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualViewFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualViewFactory.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualViewFactory.java
deleted file mode 100644
index 448bd14..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationContextualViewFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.taverna.component.api.ComponentFactory;
-import org.apache.taverna.component.api.Version;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.api.port.ActivityPort;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-import net.sf.taverna.t2.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));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationPanel.java
deleted file mode 100644
index 98266f5..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationPanel.java
+++ /dev/null
@@ -1,253 +0,0 @@
-package net.sf.taverna.t2.component.annotation;
-
-import static java.awt.BorderLayout.CENTER;
-import static java.awt.BorderLayout.NORTH;
-import static java.awt.Color.WHITE;
-import static java.awt.Font.BOLD;
-import static java.awt.GridBagConstraints.BOTH;
-import static java.awt.GridBagConstraints.EAST;
-import static java.awt.GridBagConstraints.HORIZONTAL;
-import static java.awt.GridBagConstraints.NONE;
-import static java.awt.GridBagConstraints.SOUTHEAST;
-import static java.lang.Integer.MIN_VALUE;
-import static java.lang.String.format;
-import static javax.swing.JOptionPane.ERROR_MESSAGE;
-import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
-import static javax.swing.JOptionPane.OK_OPTION;
-import static javax.swing.JOptionPane.showConfirmDialog;
-import static javax.swing.JOptionPane.showMessageDialog;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getDisplayName;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getObjectName;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.border.EmptyBorder;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Statement;
-
-public class SemanticAnnotationPanel extends JPanel {
- private static final long serialVersionUID = -5949183295606132775L;
-
- private List<PropertyPanelFactorySPI> propertyPanelFactories; //FIXME beaninject
- private final AbstractSemanticAnnotationContextualView semanticAnnotationContextualView;
- private final SemanticAnnotationProfile semanticAnnotationProfile;
- private final Set<Statement> statements;
- private final boolean allowChange;
- private final PropertyPanelFactorySPI bestFactory;
-
- public SemanticAnnotationPanel(
- AbstractSemanticAnnotationContextualView semanticAnnotationContextualView,
- SemanticAnnotationProfile semanticAnnotationProfile,
- Set<Statement> statements, boolean allowChange) {
- this.semanticAnnotationContextualView = semanticAnnotationContextualView;
- this.semanticAnnotationProfile = semanticAnnotationProfile;
- this.statements = statements;
- this.allowChange = allowChange;
- this.bestFactory = findBestPanelFactory();
- initialise();
- }
-
- private void initialise() {
- setLayout(new GridBagLayout());
- // setBorder(new 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);
- // }
- // });
-
- GridBagConstraints c = new GridBagConstraints();
- c.anchor = SOUTHEAST;
- c.fill = BOTH;
- c.weightx = 1;
- c.gridx = 0;
-
- OntProperty predicate = semanticAnnotationProfile.getPredicate();
- c.gridwidth = 3;
- JLabel label = new JLabel(format("Annotation type : %s",
- getDisplayName(predicate)));
- label.setBorder(new EmptyBorder(5, 5, 5, 5));
- label.setBackground(WHITE);
- label.setOpaque(true);
- add(label, c);
-
- c.insets = new Insets(7, 0, 0, 0);
- c.anchor = EAST;
- c.fill = HORIZONTAL;
- if (statements.isEmpty()) {
- c.gridwidth = 2;
- // c.weightx = 1;
- // c.gridy++;
- add(new JLabel("No semantic annotations"), c);
- } else {
- c.gridwidth = 1;
- for (Statement statement : statements) {
- c.gridx = 0;
- c.weightx = 1;
- if (bestFactory != null) {
- add(bestFactory.getDisplayComponent(
- semanticAnnotationProfile, statement), c);
- } else {
- 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));
- add(value, c);
- }
- if (allowChange) {
- c.gridx = 1;
- c.weightx = 0;
- add(createChangeButton(statement), c);
-
- c.gridx = 2;
- add(createDeleteButton(statement), c);
- }
- }
- }
-
- if (allowChange
- && !enoughAlready(statements,
- semanticAnnotationProfile.getMaxOccurs())) {
- c.gridx = 0;
- c.gridwidth = 3;
- c.anchor = SOUTHEAST;
- c.fill = NONE;
- add(createAddButton(), c);
- }
- }
-
- private boolean enoughAlready(Set<Statement> statements, Integer maxOccurs) {
- return (maxOccurs != null) && (statements.size() >= maxOccurs);
- }
-
- private JButton createChangeButton(final Statement statement) {
- return new DeselectingButton("Change", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- addOrChangeAnnotation(statement);
- }
- });
- }
-
- private JButton createDeleteButton(final Statement statement) {
- return new DeselectingButton("Delete", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- semanticAnnotationContextualView.removeStatement(statement);
- }
- });
- }
-
- private JButton createAddButton() {
- return new DeselectingButton("Add Annotation", new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addOrChangeAnnotation(null);
- }
- });
- }
-
- private void addOrChangeAnnotation(Statement statement) {
- JPanel annotationPanel = null;
- JComponent inputComponent = null;
-
- if (bestFactory != null) {
- inputComponent = bestFactory.getInputComponent(
- semanticAnnotationProfile, statement);
- annotationPanel = getPropertyPanel(
- getDisplayName(semanticAnnotationProfile.getPredicate()),
- inputComponent);
- }
-
- if (annotationPanel == null) {
- showMessageDialog(null, format("Unable to handle %s",
- semanticAnnotationProfile.getPredicateString()),
- "Annotation problem", ERROR_MESSAGE);
- return;
- }
-
- int answer = showConfirmDialog(null, annotationPanel,
- "Add/change annotation", OK_CANCEL_OPTION);
- if (answer == OK_OPTION) {
- RDFNode response = bestFactory.getNewTargetNode(statement,
- inputComponent);
- if (response == null)
- return;
- if (statement != null)
- semanticAnnotationContextualView.changeStatement(statement,
- semanticAnnotationProfile.getPredicate(), response);
- else
- semanticAnnotationContextualView.addStatement(
- semanticAnnotationProfile.getPredicate(), response);
- }
- }
-
- private PropertyPanelFactorySPI findBestPanelFactory() {
- PropertyPanelFactorySPI result = null;
- int currentRating = MIN_VALUE;
- for (PropertyPanelFactorySPI factory : propertyPanelFactories) {
- int ratingForSemanticAnnotation = factory
- .getRatingForSemanticAnnotation(semanticAnnotationProfile);
- if (ratingForSemanticAnnotation > currentRating) {
- currentRating = ratingForSemanticAnnotation;
- result = factory;
- }
- }
- return result;
- }
-
- public static JPanel getPropertyPanel(String displayName,
- Component inputComponent) {
- JPanel result = new JPanel();
- result.setLayout(new BorderLayout());
- JPanel messagePanel = new JPanel(new BorderLayout());
- messagePanel.setBorder(new EmptyBorder(5, 5, 0, 0));
- messagePanel.setBackground(WHITE);
- result.add(messagePanel, NORTH);
-
- JLabel inputLabel = new JLabel("Enter a value for the annotation");
- inputLabel.setBackground(WHITE);
- Font baseFont = inputLabel.getFont();
- inputLabel.setFont(baseFont.deriveFont(BOLD));
- messagePanel.add(inputLabel, NORTH);
-
- JTextArea messageText = new JTextArea(format(
- "Enter a value for the annotation '%s'", displayName));
- messageText.setMargin(new Insets(5, 10, 10, 10));
- messageText.setMinimumSize(new Dimension(0, 30));
- messageText.setFont(baseFont.deriveFont(11f));
- messageText.setEditable(false);
- messageText.setFocusable(false);
- messagePanel.add(messageText, CENTER);
-
- result.add(new JScrollPane(inputComponent), CENTER);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationUtils.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationUtils.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationUtils.java
deleted file mode 100644
index 0fd8c27..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/SemanticAnnotationUtils.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.component.annotation;
-
-import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.profile.Profile;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import uk.org.taverna.scufl2.api.annotation.Annotation;
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.ontology.OntResource;
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.RDFNode;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.rdf.model.Statement;
-
-/**
- * @author David Withers
- */
-public class SemanticAnnotationUtils {
- protected static final String ENCODING = "TURTLE";
- /* Pretend-base for making relative URIs */
- private static String BASE = "widget://4aa8c93c-3212-487c-a505-3e337adf54a3/";
- private static Logger logger = getLogger(SemanticAnnotationUtils.class);
-
- public static String getObjectName(Statement statement) {
- return getDisplayName(statement.getObject());
- }
-
- public static String getDisplayName(RDFNode node) {
- if (node == null)
- return "unknown";
- else if (node.isAnon())
- return "anon";
- else if (node.isLiteral())
- return node.asLiteral().getLexicalForm();
- else if (node.isResource()) {
- Resource resource = node.asResource();
- if (resource instanceof OntResource) {
- String label = ((OntResource) resource).getLabel(null);
- if (label != null)
- return label;
- }
- String localName = resource.getLocalName();
- if ((localName != null) && !localName.isEmpty())
- return localName;
- return resource.toString();
- } else
- return "unknown";
- }
-
- public static Annotation findSemanticAnnotation(AbstractNamed annotated) {
- for (Annotation annotation : annotated.getAnnotations())
- return annotation;
- return null;
- }
-
- public static String getStrippedAnnotationContent(Annotation annotation)
- throws IOException {
- AbstractNamed target = (AbstractNamed) annotation.getTarget();
- return annotation.getRDFContent().replace(
- target.getRelativeURI(annotation).toASCIIString(), BASE);
- }
-
- public static Annotation createSemanticAnnotation(WorkflowBundle bundle,
- AbstractNamed target, Model model) throws IOException {
- Calendar now = new GregorianCalendar();
- Annotation annotation = new Annotation();
- annotation.setParent(bundle);
- String path = annotation.getResourcePath();
- annotation.setTarget(target);
- // annotation.setAnnotatedBy(annotatedBy);
- annotation.setAnnotatedAt(now);
- // annotation.setSerializedBy(serializedBy);
- annotation.setSerializedAt(now);
- bundle.getResources().addResource(
- "@base<" + target.getRelativeURI(annotation).toASCIIString()
- + "> .\n" + createTurtle(model), path, "text/rdf+n3");
- return annotation;
- }
-
- /**
- * @param model
- * @return
- */
- public static String createTurtle(Model model) {
- StringWriter stringWriter = new StringWriter();
- model.write(stringWriter, ENCODING, BASE);
- // Workaround for https://issues.apache.org/jira/browse/JENA-132
- return stringWriter.toString().replace(BASE, "");
- }
-
- public static Model populateModel(WorkflowBundle annotated) {
- Model result = createDefaultModel();
- try {
- for (Annotation a : annotated.getAnnotations())
- populateModelFromString(result, a.getRDFContent());
- } catch (Exception e) {
- logger.error("failed to construct semantic annotation model", e);
- }
- return result;
- }
-
- public static void populateModel(Model result, Annotation annotation)
- throws IOException {
- AbstractNamed target = (AbstractNamed) annotation.getTarget();
- String content = annotation.getRDFContent().replace(
- target.getRelativeURI(annotation).toASCIIString(), BASE);
- populateModelFromString(result, content);
- }
-
- public static void populateModelFromString(Model result, String content) {
- result.read(new StringReader(content), BASE, ENCODING);
- }
-
- public static Resource createBaseResource(Model model) {
- return model.createResource(BASE);
- }
-
- /**
- * Check if a profile is satisfied by a component.
- *
- * @param bundle
- * The component definition.
- * @param componentProfile
- * The profile definition.
- * @return The set of failed constraints. If empty, the profile is satisfied
- * by the component.
- */
- public static Set<SemanticAnnotationProfile> checkComponent(
- WorkflowBundle bundle, Profile componentProfile) {
- // TODO Check port presence by name
- Set<SemanticAnnotationProfile> problemProfiles = new HashSet<>();
- Model model = populateModel(bundle);
- Set<Statement> statements = model.listStatements().toSet();
- try {
- for (SemanticAnnotationProfile saProfile : componentProfile
- .getSemanticAnnotations()) {
- OntProperty predicate = saProfile.getPredicate();
- if (predicate == null)
- continue;
- int count = 0;
- for (Statement statement : statements)
- if (statement.getPredicate().equals(predicate))
- count++;
- if (count < saProfile.getMinOccurs())
- problemProfiles.add(saProfile);
- if (saProfile.getMaxOccurs() != null
- && count > saProfile.getMaxOccurs())
- // The UI should prevent this, but check anyway
- problemProfiles.add(saProfile);
- }
- } catch (ComponentException e) {
- logger.error("failed to look up profiles for semantic annotations", e);
- }
- return problemProfiles;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleContextualView.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleContextualView.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleContextualView.java
deleted file mode 100644
index f993c48..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleContextualView.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import static java.awt.BorderLayout.CENTER;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.findSemanticAnnotation;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.getStrippedAnnotationContent;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.awt.BorderLayout;
-import java.io.IOException;
-
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView;
-
-import org.slf4j.Logger;
-
-import uk.org.taverna.scufl2.api.annotation.Annotation;
-import uk.org.taverna.scufl2.api.common.AbstractNamed;
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-
-/**
- * @author alanrw
- */
-public class TurtleContextualView extends ContextualView {
- private static final long serialVersionUID = -3401885589263647202L;
- private static final Logger log = getLogger(TurtleContextualView.class);
- private JPanel panel;
- private String annotationContent = "";
-
- public TurtleContextualView(AbstractNamed selection, WorkflowBundle bundle) {
- Annotation annotation = findSemanticAnnotation(selection);
- try {
- if (annotation != null)
- annotationContent = getStrippedAnnotationContent(annotation);
- } catch (IOException e) {
- log.info("failed to read semantic annotation; using empty string", e);
- }
- initialise();
- initView();
- }
-
- @Override
- public JComponent getMainFrame() {
- return panel;
- }
-
- @Override
- public int getPreferredPosition() {
- return 512;
- }
-
- @Override
- public String getViewTitle() {
- return "Turtle representation";
- }
-
- @Override
- public void refreshView() {
- initialise();
- }
-
- protected final void initialise() {
- if (panel == null)
- panel = new JPanel(new BorderLayout());
- else
- panel.removeAll();
- JTextArea textArea = new JTextArea(20, 80);
- textArea.setEditable(false);
- textArea.setText(annotationContent);
- panel.add(textArea, CENTER);
- revalidate();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleInputPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleInputPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleInputPanel.java
deleted file mode 100644
index 875ea82..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/TurtleInputPanel.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import static com.hp.hpl.jena.rdf.model.ModelFactory.createOntologyModel;
-import static java.awt.BorderLayout.CENTER;
-import static java.awt.BorderLayout.EAST;
-import static java.awt.BorderLayout.SOUTH;
-import static net.sf.taverna.t2.component.annotation.SemanticAnnotationUtils.populateModelFromString;
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-
-import net.sf.taverna.t2.lang.ui.DeselectingButton;
-import net.sf.taverna.t2.lang.ui.ReadOnlyTextArea;
-
-import com.hp.hpl.jena.ontology.Individual;
-import com.hp.hpl.jena.ontology.OntClass;
-import com.hp.hpl.jena.ontology.OntModel;
-
-/**
- * @author alanrw
- */
-@SuppressWarnings("serial")
-public class TurtleInputPanel extends JPanel {
- JTextArea turtleTextArea = new JTextArea(30, 80);
- ReadOnlyTextArea errors = new ReadOnlyTextArea(1, 80);
- private OntClass clazz;
-
- public TurtleInputPanel(OntClass clazz) {
- super(new BorderLayout());
- this.clazz = clazz;
-
- add(new JScrollPane(turtleTextArea), CENTER);
-
- turtleTextArea.setText("<#changeme> a <" + clazz.getURI() + ">\n\n\n.");
-
- JPanel buttonPanel = new JPanel();
- buttonPanel.setLayout(new BorderLayout());
- JButton validateButton = new DeselectingButton(new AbstractAction(
- "Validate") {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- getContentAsModel();
- }
- });
- buttonPanel.add(errors, CENTER);
- errors.setOpaque(false);
- buttonPanel.add(validateButton, EAST);
- add(buttonPanel, SOUTH);
- }
-
- public OntModel getContentAsModel() {
- OntModel result = createOntologyModel();
- try {
- populateModelFromString(result, getContentAsString());
-
- // Check it is not still called changeme
- List<Individual> individuals = result.listIndividuals(clazz)
- .toList();
- if (individuals.isEmpty()) {
- errors.setText("No valid individuals");
- return null;
- }
- for (Individual i : individuals)
- if (i.getURI().endsWith("changeme")) {
- errors.setText("Name has not been changed");
- return null;
- }
-
- errors.setText("No errors found");
- return result;
- } catch (Throwable ex) { // syntax error?
- errors.setText(ex.getMessage());
- return null;
- }
- }
-
- public String getContentAsString() {
- return turtleTextArea.getText();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnrecognizedStatementPanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnrecognizedStatementPanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnrecognizedStatementPanel.java
deleted file mode 100644
index a226ef0..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnrecognizedStatementPanel.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import static java.lang.String.format;
-
-import java.awt.BorderLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import com.hp.hpl.jena.rdf.model.Statement;
-
-/**
- * @author alanrw
- *
- */
-@SuppressWarnings("serial")
-public class UnrecognizedStatementPanel extends JPanel {
- public UnrecognizedStatementPanel(Statement statement) {
- setLayout(new BorderLayout());
- setBorder(new GreyBorder());
- add(new JLabel(format("Unable to find %s in the profile",
- statement.getPredicate())));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/43334c1d/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnresolveablePredicatePanel.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnresolveablePredicatePanel.java b/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnresolveablePredicatePanel.java
deleted file mode 100644
index 8e369e1..0000000
--- a/taverna-component-activity-ui/src/main/java/net/sf/taverna/t2/component/annotation/UnresolveablePredicatePanel.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.annotation;
-
-import static java.lang.String.format;
-
-import java.awt.BorderLayout;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-/**
- * @author alanrw
- */
-@SuppressWarnings("serial")
-public class UnresolveablePredicatePanel extends JPanel {
- public UnresolveablePredicatePanel(
- SemanticAnnotationProfile semanticAnnotationProfile) {
- setLayout(new BorderLayout());
- setBorder(new GreyBorder());
- add(new JLabel(format("Unable to resolve %s in the ontology",
- semanticAnnotationProfile.getPredicateString())));
- }
-}