From 0f9cb9b0f903dc1f5c76eae3d2c276ec772b0c81 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 12 Aug 2019 18:18:59 -0600 Subject: [PATCH 01/65] Components are created with KnowtatorView as parameter --- .idea/vcs.xml | 2 - .idea/workspace.xml | 1280 ++++------------- .../ccp/knowtator/view/AnnotationNotes.java | 8 +- .../knowtator/view/KnowtatorComponent.java | 2 - .../ccp/knowtator/view/KnowtatorView.java | 34 +- .../view/chooser/GraphSpaceChooser.java | 4 +- .../view/chooser/KnowtatorChooser.java | 13 +- .../view/chooser/TextSourceChooser.java | 10 + .../ccp/knowtator/view/graph/GraphView.java | 11 +- .../knowtator/view/graph/GraphViewDialog.java | 12 +- .../label/AbstractConceptAnnotationLabel.java | 4 +- .../view/label/AnnotationAnnotatorLabel.java | 4 +- .../view/label/AnnotationClassLabel.java | 10 + .../view/label/AnnotationIdLabel.java | 10 + .../knowtator/view/label/KnowtatorLabel.java | 8 +- .../ccp/knowtator/view/list/ColorList.java | 13 +- .../knowtator/view/list/GraphSpaceList.java | 4 +- .../knowtator/view/list/KnowtatorList.java | 15 +- .../ccp/knowtator/view/list/ProfileList.java | 10 + .../ccp/knowtator/view/list/SpanList.java | 10 + .../knowtator/view/table/AnnotationTable.java | 5 +- .../table/AnnotationTableForOwlClass.java | 4 +- .../table/AnnotationTableForSpannedText.java | 6 +- .../knowtator/view/table/KnowtatorTable.java | 8 +- .../knowtator/view/table/RelationTable.java | 5 +- .../view/textpane/AnnotatableTextPane.java | 5 +- .../view/textpane/KnowtatorTextPane.java | 4 +- .../view/textpane/SearchableTextPane.java | 8 +- 28 files changed, 426 insertions(+), 1083 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 1d53947a..35eb1ddf 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,7 +2,5 @@ - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a2d7cdb0..a229c571 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,134 +1,169 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - @@ -275,23 +235,8 @@ - - - - - - - - - - - - - - - - + - - - - + + - - + @@ -424,8 +359,8 @@ - + @@ -433,49 +368,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - + @@ -485,7 +392,7 @@ - + @@ -548,32 +455,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -586,903 +473,350 @@ file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java - 967 + 961 file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java - 687 + 682 - - - - textSource.getContent().replace("ยท", "").substring(start[0], start[0] + text.length()) - JAVA - CODE_FRAGMENT - - - textSource.getContent().substring(start[0], start[0] + text.length()) - JAVA - CODE_FRAGMENT - - - textSource.getContent() - JAVA - CODE_FRAGMENT - - - textSource.getContent().substring(start1, end) - JAVA - CODE_FRAGMENT - - - realText - .substring(start1, end) - JAVA - CODE_FRAGMENT - - - textSource.getContent().substring(range[0], range[1]) - JAVA - CODE_FRAGMENT - - - conceptAnnotation.getOwlClass().equals(axiom.getEntity().toStringID()) - JAVA - CODE_FRAGMENT - - - model.getOwlClassById("BetterPizza").toString() - JAVA - CODE_FRAGMENT - - - model.getTextSources().stream() - .map( - textSource -> - textSource.getGraphSpaces().stream() - .map( - graphSpace1 -> - graphSpace1.getChildVertices(graphSpace1.getDefaultParent())) - .toArray()) - .toArray(); - JAVA - CODE_FRAGMENT - - - - - modelObject.getClass() == Span.class - JAVA - edu.ucdenver.ccp.knowtator.model.object.Span - EXPRESSION - - - modelObject.getClass() - JAVA - EXPRESSION - - - id.equals("Sentence 243") - JAVA - EXPRESSION - - - id == "Sentence 243" - JAVA - EXPRESSION - - - objectID == "11532192-23990" - JAVA - EXPRESSION - - - - - textSource.getContent().substring(start[0], start[0] + text.length()) - JAVA - EXPRESSION - - - textSource.gett - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] - 8, start[0] + text.length() -8) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] - 8, start[0] + text.length() + 8) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] - 10, start[0] + text.length() + 10) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] + 1, start[0] + text.length() + 1) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] - 6, start[0] + text.length() + 6) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] -6, start[0]+text.length()+6) - JAVA - EXPRESSION - - - textSource.getContent().substring(start[0] -5, start[0]+text.length()+5) - JAVA - EXPRESSION - - - - - - - - - - - + - - - - - - + + - + - - - - - - + + - + - - - - - - + + - + - - - - - + + - + - - - - - + + - + - - - - - - - - - - - - + + - + - - - - - - - - - - + + - + - - - - - + + - + - - + + - + - - + + - - - - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - + + - - - - - - - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - + + - - - + + - + - - - - - - + + - + - - - - - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - + - - + + - + + - + - - + + - - - + + - - - - - - - - + - - + + - - - - + + + - + - - + + + + + + + - + - - + + - + - - + + - + - - + + - + - - + + + + + + - + - - + + + + + + - + - - + + + + + + + + + + + + + + - + - - + + - + - - + + - + - - - - - - - - - + + + + + + - + - - + + + + + + + - + - - + + + + + + - + - - + + - + - - + + - + - - + + - - - - - - - - - - + + + + - - - - - - - - - - - - - My Copyright - - - - - - - - Kotlin (knowtator)|Invalid - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - code - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/AnnotationNotes.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/AnnotationNotes.java index 991e294e..0da84eeb 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/AnnotationNotes.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/AnnotationNotes.java @@ -45,7 +45,8 @@ public class AnnotationNotes extends JTextArea implements KnowtatorComponent, Mo * Instantiates a new Annotation notes. * */ - AnnotationNotes() { + AnnotationNotes(KnowtatorView view) { + this.view = view; addKeyListener( new KeyListener() { @Override @@ -78,11 +79,6 @@ public void changedUpdate(DocumentEvent e) { }); } - @Override - public void setView(KnowtatorView view) { - this.view = view; - } - @Override public void reset() { view.getModel().ifPresent(model -> model.addModelListener(this)); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorComponent.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorComponent.java index bf62685b..c0ee4bc7 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorComponent.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorComponent.java @@ -31,6 +31,4 @@ public interface KnowtatorComponent { /** Dispose. */ void dispose(); - - void setView(KnowtatorView view); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java index 92551914..f226dd2a 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java @@ -260,11 +260,6 @@ public KnowtatorView() { relationsForPropertyList)); } - @Override - public void setView(KnowtatorView view) { - knowtatorComponents.forEach(component -> component.setView(this)); - } - private static void changeFont(Component component, Font font) { component.setFont(font); if (component instanceof Container) { @@ -310,30 +305,30 @@ private void createUIComponents() { owlPropertyLabel = new JLabel(); textPane = - new KnowtatorTextPane( + new KnowtatorTextPane(this, searchTextField, onlyAnnotationsCheckBox, regexCheckBox, caseSensitiveCheckBox); - graphViewDialog = new GraphViewDialog(); + graphViewDialog = new GraphViewDialog(this); - annotationAnnotatorLabel = new AnnotationAnnotatorLabel(); - annotationClassLabel = new AnnotationClassLabel(); - annotationIdLabel = new AnnotationIdLabel(); - annotationNotes = new AnnotationNotes(); + annotationAnnotatorLabel = new AnnotationAnnotatorLabel(this); + annotationClassLabel = new AnnotationClassLabel(this); + annotationIdLabel = new AnnotationIdLabel(this); + annotationNotes = new AnnotationNotes(this); - textSourceChooser = new TextSourceChooser(); + textSourceChooser = new TextSourceChooser(this); - graphSpaceList = new GraphSpaceList(); - spanList = new SpanList(); - profileList = new ProfileList(); - colorList = new ColorList(); + graphSpaceList = new GraphSpaceList(this); + spanList = new SpanList(this); + profileList = new ProfileList(this); + colorList = new ColorList(this); annotationsContainingTextTextField = new JTextField(); annotationsForClassTable = - new AnnotationTableForOwlClass(includeClassDescendantsCheckBox, owlClassLabel); + new AnnotationTableForOwlClass(this, includeClassDescendantsCheckBox, owlClassLabel); conceptAnnotationsForTextTable = - new AnnotationTableForSpannedText(exactMatchCheckBox, annotationsContainingTextTextField); + new AnnotationTableForSpannedText(this, exactMatchCheckBox, annotationsContainingTextTextField); relationsForPropertyList = - new RelationTable(includePropertyDescendantsCheckBox, owlPropertyLabel); + new RelationTable(this, includePropertyDescendantsCheckBox, owlPropertyLabel); // The following methods keep the graph view dialog on top only when the view is active. KnowtatorView view = this; @@ -959,7 +954,6 @@ public void dragOver(DropTargetDragEvent e) { * @throws IOException the io exception */ public void loadProject(File file, ModelListener progressListener) throws IOException { - setView(this); if (!getModel().isPresent() || getModel().get().isNotLoading()) { getModel().ifPresent(BaseModel::dispose); if (getOWLWorkspace() != null) { diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/GraphSpaceChooser.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/GraphSpaceChooser.java index d08127d4..74763975 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/GraphSpaceChooser.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/GraphSpaceChooser.java @@ -25,6 +25,7 @@ package edu.ucdenver.ccp.knowtator.view.chooser; import edu.ucdenver.ccp.knowtator.model.object.GraphSpace; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; /** The type Graph space chooser. */ public class GraphSpaceChooser extends KnowtatorChooser { @@ -33,7 +34,8 @@ public class GraphSpaceChooser extends KnowtatorChooser { * Instantiates a new Graph space chooser. * */ - public GraphSpaceChooser() { + public GraphSpaceChooser(KnowtatorView view) { + super(view); } /** diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/KnowtatorChooser.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/KnowtatorChooser.java index 7ebf660b..82a7de2c 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/KnowtatorChooser.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/KnowtatorChooser.java @@ -48,11 +48,9 @@ public abstract class KnowtatorChooser extends JComboBox< /** The View. */ KnowtatorView view; - /** - * Instantiates a new Knowtator chooser. - * - */ - KnowtatorChooser() { + /** Instantiates a new Knowtator chooser. */ + KnowtatorChooser(KnowtatorView view) { + this.view = view; al = e -> { JComboBox comboBox = (JComboBox) e.getSource(); @@ -122,9 +120,4 @@ public void filterChangedEvent() { public void colorChangedEvent(Profile profile) { react(); } - - @Override - public void setView(KnowtatorView view) { - this.view = view; - } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/TextSourceChooser.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/TextSourceChooser.java index 0413b28d..59b5fc6c 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/TextSourceChooser.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/chooser/TextSourceChooser.java @@ -25,10 +25,20 @@ package edu.ucdenver.ccp.knowtator.view.chooser; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; /** The type Text source chooser. */ public class TextSourceChooser extends KnowtatorChooser { + /** + * Instantiates a new Knowtator chooser. + * + * @param view The Knowtator view + */ + public TextSourceChooser(KnowtatorView view) { + super(view); + } + @Override protected void react() { view.getModel().ifPresent(model -> setCollection(model.getTextSources())); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphView.java index 6c010950..a6cdc9ec 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphView.java @@ -117,8 +117,9 @@ public class GraphView extends JPanel * * @param dialog the dialog */ - GraphView(JDialog dialog) { + GraphView(KnowtatorView view, JDialog dialog) { + this.view = view; this.dialog = dialog; $$$setupUI$$$(); setVisible(false); @@ -312,7 +313,7 @@ private void showGraph(GraphSpace graphSpace) { private void createUIComponents() { JScrollPane scrollPane = new JScrollPane(); scrollPane.getVerticalScrollBar().setUnitIncrement(20); - graphSpaceChooser = new GraphSpaceChooser(); + graphSpaceChooser = new GraphSpaceChooser(view); mxGraph testGraph = new mxGraph(); graphComponent = new mxGraphComponent(testGraph); } @@ -432,12 +433,6 @@ public void dispose() { graphSpaceChooser.dispose(); } - @Override - public void setView(KnowtatorView view) { - this.view = view; - graphSpaceChooser.setView(view); - } - /** * Gets graph component. * diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphViewDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphViewDialog.java index 2fc43748..f2faff36 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphViewDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/graph/GraphViewDialog.java @@ -49,8 +49,8 @@ public class GraphViewDialog extends JDialog implements KnowtatorComponent { /** * Instantiates a new Graph view dialog. */ - public GraphViewDialog() { -// $$$setupUI$$$(); + public GraphViewDialog(KnowtatorView view) { + this.view = view; $$$setupUI$$$(); setSize(new Dimension(800, 800)); @@ -100,7 +100,7 @@ private void onCancel() { } private void createUIComponents() { - graphView = new GraphView(this); + graphView = new GraphView(this.view, this); } @Override @@ -115,12 +115,6 @@ public void dispose() { setVisible(false); } - @Override - public void setView(KnowtatorView view) { - this.view = view; - graphView.setView(view); - } - @Override public void setVisible(boolean visible) { super.setVisible(visible); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AbstractConceptAnnotationLabel.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AbstractConceptAnnotationLabel.java index 051d08b6..4314c693 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AbstractConceptAnnotationLabel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AbstractConceptAnnotationLabel.java @@ -26,6 +26,7 @@ import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.Optional; /** Abstract label for concept annotations. */ @@ -35,7 +36,8 @@ public abstract class AbstractConceptAnnotationLabel extends KnowtatorLabel { * Instantiates a new Abstract concept annotation label. * */ - AbstractConceptAnnotationLabel() { + AbstractConceptAnnotationLabel(KnowtatorView view) { + super(view); } @Override diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationAnnotatorLabel.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationAnnotatorLabel.java index fc22b350..1ef65b2e 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationAnnotatorLabel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationAnnotatorLabel.java @@ -26,6 +26,7 @@ import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; /** The type Annotation annotator label. */ public class AnnotationAnnotatorLabel extends AbstractConceptAnnotationLabel @@ -35,7 +36,8 @@ public class AnnotationAnnotatorLabel extends AbstractConceptAnnotationLabel * Instantiates a new Annotation annotator label. * */ - public AnnotationAnnotatorLabel() { + public AnnotationAnnotatorLabel(KnowtatorView view) { + super(view); } @Override diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationClassLabel.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationClassLabel.java index c2a12a5c..125cd1b4 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationClassLabel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationClassLabel.java @@ -25,6 +25,7 @@ package edu.ucdenver.ccp.knowtator.view.label; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import org.protege.editor.owl.model.event.EventType; import org.protege.editor.owl.model.event.OWLModelManagerChangeEvent; import org.protege.editor.owl.model.event.OWLModelManagerListener; @@ -33,6 +34,15 @@ public class AnnotationClassLabel extends AbstractConceptAnnotationLabel implements OWLModelManagerListener { + /** + * Instantiates a new Abstract concept annotation label. + * + * @param view The view + */ + public AnnotationClassLabel(KnowtatorView view) { + super(view); + } + @Override public void displayConceptAnnotation(ConceptAnnotation conceptAnnotation) { view.getModel() diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationIdLabel.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationIdLabel.java index 9365a70c..609fe06d 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationIdLabel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/AnnotationIdLabel.java @@ -25,11 +25,21 @@ package edu.ucdenver.ccp.knowtator.view.label; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; /** The type Annotation id label. */ public class AnnotationIdLabel extends AbstractConceptAnnotationLabel { + /** + * Instantiates a new Abstract concept annotation label. + * + * @param view The view + */ + public AnnotationIdLabel(KnowtatorView view) { + super(view); + } + @Override public void displayConceptAnnotation(ConceptAnnotation conceptAnnotation) { setText(conceptAnnotation.getId()); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/KnowtatorLabel.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/KnowtatorLabel.java index d5ca1574..1ccb3ed3 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/label/KnowtatorLabel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/label/KnowtatorLabel.java @@ -42,7 +42,8 @@ public abstract class KnowtatorLabel extends JLabel implements KnowtatorComponen * Instantiates a new Knowtator label. * */ - KnowtatorLabel() { + KnowtatorLabel(KnowtatorView view) { + this.view = view; } /** React. */ @@ -73,9 +74,4 @@ public void modelChangeEvent(ChangeEvent event) { public void colorChangedEvent(Profile profile) { react(); } - - @Override - public void setView(KnowtatorView view) { - this.view = view; - } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index 309c3b01..37bbeffb 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -45,11 +45,9 @@ public class ColorList extends JList implements KnowtatorComponent, Mode private final ListSelectionListener lsl; private KnowtatorView view; - /** - * Instantiates a new Color list. - * - */ - public ColorList() { + /** Instantiates a new Color list. */ + public ColorList(KnowtatorView view) { + this.view = view; setModel(new DefaultListModel<>()); setCellRenderer(new ColorListRenderer<>()); lsl = e -> assignColorToClass(view, getSelectedValue()); @@ -73,11 +71,6 @@ private void setCollection() { addListSelectionListener(lsl); } - @Override - public void setView(KnowtatorView view) { - this.view = view; - } - @Override public void reset() { view.getModel().ifPresent(model -> model.addModelListener(this)); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/GraphSpaceList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/GraphSpaceList.java index d25bb084..d07493fe 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/GraphSpaceList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/GraphSpaceList.java @@ -27,6 +27,7 @@ import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.object.GraphSpace; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.Optional; /** The type Graph space list. */ @@ -35,7 +36,8 @@ public class GraphSpaceList extends KnowtatorList { * Instantiates a new Graph space list. * */ - public GraphSpaceList() { + public GraphSpaceList(KnowtatorView view) { + super(view); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/KnowtatorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/KnowtatorList.java index de377cad..7201ef60 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/KnowtatorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/KnowtatorList.java @@ -48,11 +48,9 @@ public abstract class KnowtatorList extends JList /** The View. */ KnowtatorView view; - /** - * Instantiates a new Knowtator list. - * - */ - KnowtatorList() { + /** Instantiates a new Knowtator list. */ + KnowtatorList(KnowtatorView view) { + this.view = view; setModel(new DefaultListModel<>()); KnowtatorList list = this; @@ -122,7 +120,7 @@ public void dispose() { } /** React to model event. */ - void reactToModelEvent() { + private void reactToModelEvent() { ((DefaultListModel) getModel()).clear(); addElementsFromModel(); setSelected(); @@ -142,9 +140,4 @@ public void modelChangeEvent(ChangeEvent event) { public void colorChangedEvent(Profile profile) { reactToModelEvent(); } - - @Override - public void setView(KnowtatorView view) { - this.view = view; - } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ProfileList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ProfileList.java index efb7a0c5..0f3f6913 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ProfileList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ProfileList.java @@ -26,11 +26,21 @@ import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.object.Profile; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.Optional; /** The type Profile list. */ public class ProfileList extends KnowtatorList { + /** + * Instantiates a new Knowtator list. + * + * @param view The view + */ + public ProfileList(KnowtatorView view) { + super(view); + } + @Override public void reactToClick() { // TODO: Something is going wrong when double clicking a profile with no colors. diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/SpanList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/SpanList.java index fb5a755c..8865d60d 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/SpanList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/SpanList.java @@ -28,12 +28,22 @@ import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.Span; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.Optional; /** The type Span list. */ public class SpanList extends KnowtatorList { + /** + * Instantiates a new Knowtator list. + * + * @param view The Knowtator view + */ + public SpanList(KnowtatorView view) { + super(view); + } + @Override public void reactToClick() { Optional spanOptional = Optional.ofNullable(getSelectedValue()); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTable.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTable.java index 48e57f46..15e2d10a 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTable.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTable.java @@ -27,6 +27,7 @@ import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.Optional; import javax.swing.table.DefaultTableModel; @@ -37,8 +38,8 @@ public class AnnotationTable extends KnowtatorTable { * Instantiates a new Annotation table. * */ - AnnotationTable() { - super(); + AnnotationTable(KnowtatorView view) { + super(view); setModel( new DefaultTableModel( new Object[][] {}, new String[] {"Spanned Text", "OWL Entity", "Text Source"}) { diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForOwlClass.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForOwlClass.java index 7c403c6a..c80d7867 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForOwlClass.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForOwlClass.java @@ -24,6 +24,7 @@ package edu.ucdenver.ccp.knowtator.view.table; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.HashSet; import java.util.Set; import javax.swing.JCheckBox; @@ -42,7 +43,8 @@ public class AnnotationTableForOwlClass extends AnnotationTable { * @param owlClassLabel the owl class label */ public AnnotationTableForOwlClass( - JCheckBox includeClassDescendantsCheckBox, JLabel owlClassLabel) { + KnowtatorView view, JCheckBox includeClassDescendantsCheckBox, JLabel owlClassLabel) { + super(view); this.includeClassDescendantsCheckBox = includeClassDescendantsCheckBox; this.owlClassLabel = owlClassLabel; this.activeOwlClassDescendants = new HashSet<>(); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForSpannedText.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForSpannedText.java index 19ff4b96..b803b19e 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForSpannedText.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/AnnotationTableForSpannedText.java @@ -24,6 +24,7 @@ package edu.ucdenver.ccp.knowtator.view.table; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import javax.swing.JCheckBox; import javax.swing.JTextField; @@ -39,9 +40,10 @@ public class AnnotationTableForSpannedText extends AnnotationTable { * @param exactMatchCheckBox the exact match check box * @param annotationsContainingTextTextField the annotations containing text text field */ - public AnnotationTableForSpannedText( + public AnnotationTableForSpannedText(KnowtatorView view, JCheckBox exactMatchCheckBox, - JTextField annotationsContainingTextTextField) { + JTextField annotationsContainingTextTextField) { + super(view); this.exactMatchCheckBox = exactMatchCheckBox; this.annotationsContainingTextTextField = annotationsContainingTextTextField; } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/KnowtatorTable.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/KnowtatorTable.java index 749d5684..c5c602a8 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/KnowtatorTable.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/KnowtatorTable.java @@ -50,7 +50,8 @@ public abstract class KnowtatorTable extends JTable KnowtatorView view; /** Instantiates a new Knowtator table. */ - KnowtatorTable() { + KnowtatorTable(KnowtatorView view) { + this.view = view; getTableHeader().setFont(new Font(getFont().getName(), Font.BOLD, 16)); setAutoCreateRowSorter(true); @@ -148,9 +149,4 @@ public void modelChangeEvent(ChangeEvent event) { public void colorChangedEvent(Profile profile) { reactToModelEvent(); } - - @Override - public void setView(KnowtatorView view) { - this.view = view; - } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/RelationTable.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/RelationTable.java index 4f35d425..1ed42582 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/table/RelationTable.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/table/RelationTable.java @@ -29,6 +29,7 @@ import edu.ucdenver.ccp.knowtator.model.object.AnnotationNode; import edu.ucdenver.ccp.knowtator.model.object.RelationAnnotation; import edu.ucdenver.ccp.knowtator.model.object.TextSource; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.util.HashSet; import java.util.Optional; import java.util.Set; @@ -49,8 +50,8 @@ public class RelationTable extends KnowtatorTable { * @param owlPropertyLabel the owl property label */ public RelationTable( - JCheckBox includePropertyDescendantsCheckBox, JLabel owlPropertyLabel) { - super(); + KnowtatorView view, JCheckBox includePropertyDescendantsCheckBox, JLabel owlPropertyLabel) { + super(view); setModel( new DefaultTableModel( new Object[][] {}, diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java index 7a563f71..9e9ff77c 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java @@ -44,6 +44,7 @@ import edu.ucdenver.ccp.knowtator.model.object.TextSource; import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; import edu.ucdenver.ccp.knowtator.view.KnowtatorDefaultSettings; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import edu.ucdenver.ccp.knowtator.view.actions.ActionUnperformable; import edu.ucdenver.ccp.knowtator.view.actions.collection.ActionParameters; import edu.ucdenver.ccp.knowtator.view.actions.modelactions.ReassignOwlClassAction; @@ -87,8 +88,8 @@ public abstract class AnnotatableTextPane extends SearchableTextPane * * @param searchTextField the search text field */ - AnnotatableTextPane(JTextField searchTextField) { - super(searchTextField); + AnnotatableTextPane(KnowtatorView view, JTextField searchTextField) { + super(view, searchTextField); setEditable(false); setFont(KnowtatorDefaultSettings.FONT); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/KnowtatorTextPane.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/KnowtatorTextPane.java index 67f2a069..9956699b 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/KnowtatorTextPane.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/KnowtatorTextPane.java @@ -27,6 +27,7 @@ import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.ModelListener; import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.awt.image.BufferedImage; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -55,11 +56,12 @@ public class KnowtatorTextPane extends AnnotatableTextPane * @param caseSensitiveCheckBox A check box specifying if the search should be case sensitive */ public KnowtatorTextPane( + KnowtatorView view, JTextField searchTextField, JCheckBox onlyInAnnotationsCheckBox, JCheckBox regexCheckBox, JCheckBox caseSensitiveCheckBox) { - super(searchTextField); + super(view, searchTextField); this.onlyInAnnotationsCheckBox = onlyInAnnotationsCheckBox; this.regexCheckBox = regexCheckBox; this.caseSensitiveCheckBox = caseSensitiveCheckBox; diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/SearchableTextPane.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/SearchableTextPane.java index 75ceaf55..1999efa9 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/SearchableTextPane.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/SearchableTextPane.java @@ -48,18 +48,14 @@ public abstract class SearchableTextPane extends JTextPane /** The View. */ KnowtatorView view; - @Override - public void setView(KnowtatorView view) { - this.view = view; - } - /** * Instantiates a new Searchable text pane. * * @param searchTextField A text field used to search the text pane */ - SearchableTextPane(JTextField searchTextField) { + SearchableTextPane(KnowtatorView view, JTextField searchTextField) { super(); + this.view = view; this.searchTextField = searchTextField; this.isSearching = false; addCaretListener( From 35e9dfae27abb457b2150fcc17e24cae419c6f09 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 12 Aug 2019 19:18:36 -0600 Subject: [PATCH 02/65] Added layers to ConceptAnnotations --- .idea/workspace.xml | 872 +++++++++++++++--- .../knowtator/io/brat/BratStandoffUtil.java | 9 +- .../ccp/knowtator/io/conll/ConllUtil.java | 4 +- .../io/knowtator/KnowtatorXmlAttributes.java | 1 + .../io/knowtator/KnowtatorXmlUtil.java | 18 +- .../io/knowtator/OldKnowtatorXmlUtil.java | 4 +- .../ccp/knowtator/model/BaseModel.java | 7 + .../model/object/ConceptAnnotation.java | 11 +- .../modelactions/ConceptAnnotationAction.java | 3 +- .../KnowtatorCollectionActionsTest.java | 5 +- 10 files changed, 787 insertions(+), 147 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a229c571..f888b3fe 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,35 +1,20 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -45,132 +30,282 @@ - + - - + + - - + + + + + + - + - - - - - - + + - + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - + + - - + + - - + + - - - - - - - - - - + + + + + + + - + - - + + - + - - - - - - + + + + + + @@ -230,7 +377,181 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - + + - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + @@ -531,54 +540,54 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -596,12 +605,12 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java index 9cf38dea..c86451b8 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/textpane/AnnotatableTextPane.java @@ -45,9 +45,7 @@ import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; import edu.ucdenver.ccp.knowtator.view.KnowtatorDefaultSettings; import edu.ucdenver.ccp.knowtator.view.KnowtatorView; -import edu.ucdenver.ccp.knowtator.view.actions.ActionUnperformable; import edu.ucdenver.ccp.knowtator.view.actions.collection.ActionParameters; -import edu.ucdenver.ccp.knowtator.view.actions.modelactions.ReassignOwlClassAction; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; @@ -60,7 +58,6 @@ import java.util.Optional; import java.util.Set; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTextField; import javax.swing.SwingUtilities; @@ -78,7 +75,7 @@ public abstract class AnnotatableTextPane extends SearchableTextPane implements KnowtatorComponent, ModelListener { @SuppressWarnings("unused") - private Logger log = LogManager.getLogger(AnnotatableTextPane.class.getName()); + private final Logger log = LogManager.getLogger(AnnotatableTextPane.class.getName()); private final DefaultHighlighter.DefaultHighlightPainter overlapHighlighter = new DefaultHighlighter.DefaultHighlightPainter(Color.LIGHT_GRAY); @@ -515,34 +512,6 @@ class AnnotationPopupMenu extends JPopupMenu { this.mouseEvent = mouseEvent; } - private JMenuItem reassignOwlClassCommand() { - JMenuItem menuItem = new JMenuItem("Reassign OWL class"); - menuItem.addActionListener( - e -> - view.getModel() - .ifPresent( - model -> { - Optional selectedOwlClass = model.getSelectedOwlClass(); - selectedOwlClass.ifPresent( - owlClass -> - model - .getSelectedTextSource().flatMap(TextSource::getSelectedAnnotation).ifPresent(conceptAnnotation -> { - try { - model.registerAction( - new ReassignOwlClassAction( - model, - conceptAnnotation, - owlClass)); - } catch (ActionUnperformable e1) { - JOptionPane.showMessageDialog( - view, e1.getMessage()); - } - })); - })); - - return menuItem; - } - private JMenuItem addAnnotationCommand() { JMenuItem menuItem = new JMenuItem("Add concept"); menuItem.addActionListener( @@ -639,7 +608,6 @@ private void clickedInsideSpan(ConceptAnnotation conceptAnnotation) { if (conceptAnnotation.size() > 1) { add(removeSpanFromAnnotationCommand(conceptAnnotation)); } - add(reassignOwlClassCommand()); show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } } From 66f5bbec3e941946009542238821d012f2225362 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 3 Jun 2020 06:46:47 -0600 Subject: [PATCH 24/65] Added table of annotations with no matches found --- .idea/workspace.xml | 82 ++++++++++++------- .../ccp/knowtator/model/KnowtatorModel.java | 5 ++ .../ccp/knowtator/model/OwlModel.java | 3 +- .../ucdenver/ccp/knowtator/view/Loader.java | 24 ++++++ 4 files changed, 85 insertions(+), 29 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c15ebb11..7b5d628a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -31,7 +31,11 @@ - + + + + + @@ -471,7 +482,8 @@ - @@ -494,10 +506,10 @@ - + - + @@ -522,11 +534,11 @@ - + - + @@ -540,54 +552,54 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -605,12 +617,12 @@ - + - + @@ -619,13 +631,27 @@ - + - + + + + + file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java + 175 + + + file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/model/object/ConceptAnnotation.java + 175 + + + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index c76b2cec..5f032add 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -50,6 +50,11 @@ public class KnowtatorModel extends OwlModel { private static final Logger log = Logger.getLogger(KnowtatorModel.class); + + public List getOWLClassNotFoundAnnotations() { + return OWLClassNotFoundAnnotations; + } + private List OWLClassNotFoundAnnotations; /** diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java index 1bd977c9..89ce869c 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java @@ -102,7 +102,8 @@ public Optional getOwlClassById(@Nonnull String classID) { ontology.getClassesInSignature().stream() .filter( owlClass -> - owlClass.getIRI().getShortForm().equals(classID) + owlClass.getIRI().toString().equals(classID) + || owlClass.getIRI().getShortForm().equals(classID) || ontology.getAnnotationAssertionAxioms(owlClass.getIRI()).stream() .anyMatch( owlAnnotationAssertionAxiom -> diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/Loader.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/Loader.java index c54fa937..86732f50 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/Loader.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/Loader.java @@ -34,9 +34,13 @@ import java.io.File; import java.util.Objects; import javax.swing.JComponent; +import javax.swing.JOptionPane; import javax.swing.JProgressBar; +import javax.swing.JScrollPane; import javax.swing.JTabbedPane; +import javax.swing.JTable; import javax.swing.SwingWorker; +import javax.swing.table.DefaultTableModel; /** The type Loader. */ public class Loader extends SwingWorker implements ModelListener { @@ -100,6 +104,26 @@ protected Object doInBackground() throws Exception { progressBar1.setValue(0); view.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); view.loadProject(file, this); + + view.getModel().ifPresent(model -> { + if (!model.getOWLClassNotFoundAnnotations().isEmpty()) { + JTable message = new JTable(); + message.setModel( + new DefaultTableModel( + new Object[][] {}, new String[] {"Annotation ID", "OWL class not found"}) { + @Override + public boolean isCellEditable(int row, int col) { + return false; + } + }); + for (String[] item : model.getOWLClassNotFoundAnnotations()) { + ((DefaultTableModel) message.getModel()) + .addRow(item); + } + JOptionPane.showMessageDialog(view, new JScrollPane(message)); + } + }); + return null; } From db1c05bbc07d98b28a6c6fd413cb3f774f7d80bc Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 3 Jun 2020 06:47:08 -0600 Subject: [PATCH 25/65] Added confirm to removing a text source. --- .../AbstractKnowtatorCollectionAction.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java index 5ccc79bf..7163dba7 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java @@ -257,16 +257,26 @@ public static void pickAction( actions.add(new ProfileAction(model, actionType, id)); break; case DOCUMENT: - JOptionPane.showMessageDialog(view, "Select annotation file"); - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setCurrentDirectory(model.getAnnotationsLocation()); - File annotationFile = null; - if (fileChooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - annotationFile = fileChooser.getSelectedFile(); + if (actionType.equals(CollectionActionType.ADD)) { + JOptionPane.showMessageDialog(view, "Select annotation file"); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(model.getAnnotationsLocation()); + + + if (fileChooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { + annotationFile = fileChooser.getSelectedFile(); + actions.add( + new TextSourceAction(model, actionType, file, annotationFile)); + } + } else { + int response = JOptionPane.showConfirmDialog(view, "Remove document from project? (document and annotations will NOT be deleted)", null, JOptionPane.YES_NO_OPTION); + if (response == JOptionPane.YES_OPTION) { + actions.add( + new TextSourceAction(model, actionType, file, annotationFile)); + } } - actions.add( - new TextSourceAction(model, actionType, file, annotationFile)); + break; default: break; From 23229ed39475e6d100d5d987f1e7fbc8c64e72dd Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 3 Jun 2020 08:01:44 -0600 Subject: [PATCH 26/65] Fixed finding owl cLass by id. The owl entity finder is very finicky about when it needs surrounding "<>" --- .idea/workspace.xml | 77 ++++++++++++------- .../ccp/knowtator/model/OwlModel.java | 2 +- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7b5d628a..909e3a0c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,10 +32,7 @@ - - - - + @@ -282,7 +279,8 @@ - + + 1590645202357 @@ -410,7 +408,21 @@ - @@ -483,7 +495,9 @@ - @@ -506,10 +520,10 @@ - + - + @@ -552,54 +566,54 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -617,12 +631,12 @@ - + - + @@ -631,11 +645,11 @@ - + - + @@ -650,6 +664,11 @@ 175 diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java index 89ce869c..563c8dd5 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java @@ -95,7 +95,7 @@ public Optional getOwlClassById(@Nonnull String classID) { if (owlWorkSpace.isPresent()) { return owlWorkSpace.map( owlWorkspace -> - owlWorkspace.getOWLModelManager().getOWLEntityFinder().getOWLClass(classID)); + owlWorkspace.getOWLModelManager().getOWLEntityFinder().getOWLClass(String.format("<%s>", classID))); } else { for (OWLOntology ontology : owlOntologyManager.getOntologies()) { Optional owlClassOptional = From f4c266aa03ef6c8e47c970290f4f13feb162ebaa Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 3 Jun 2020 08:16:40 -0600 Subject: [PATCH 27/65] Fixed annotation node rendering update. --- .idea/workspace.xml | 37 ++++++++++++------- .../knowtator/model/object/GraphSpace.java | 5 +-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 909e3a0c..41b39737 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,7 +32,7 @@ - + @@ -497,7 +504,9 @@ - @@ -566,30 +575,30 @@ - + - - + + - - + + - - + + - + @@ -631,12 +640,12 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java index e2b1ef8b..f25cd11d 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java @@ -406,7 +406,7 @@ public void ontologiesChanged(@Nonnull List changes @Override public void handleChange(OWLModelManagerChangeEvent event) { - if (event.isType(EventType.ENTITY_RENDERING_CHANGED)) { + if (event.isType(EventType.ENTITY_RENDERER_CHANGED)) { try { Arrays.asList(getChildCells(getDefaultParent())) .forEach( @@ -414,8 +414,7 @@ public void handleChange(OWLModelManagerChangeEvent event) { if (o instanceof RelationAnnotation) { ((RelationAnnotation) o).setLabel(); } else if (o instanceof AnnotationNode) { - ((AnnotationNode) o) - .setValue(((AnnotationNode) o).getConceptAnnotation().toMultilineString()); + ((AnnotationNode) o).setValue(((AnnotationNode) o).getConceptAnnotation().toMultilineString()); } }); refresh(); From 87b26dc36a8272816bf8f7c7d5bb7d86119e504f Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 3 Jun 2020 15:48:50 -0600 Subject: [PATCH 28/65] Moved document controls back to top --- .idea/workspace.xml | 49 +++-- .../ccp/knowtator/view/KnowtatorView.form | 197 +++++++++--------- .../ccp/knowtator/view/KnowtatorView.java | 133 ++++++------ 3 files changed, 199 insertions(+), 180 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 41b39737..a64c750d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -23,16 +23,15 @@ - + \ No newline at end of file diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.form index 26a29aa5..97fd627a 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.form @@ -659,122 +659,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -939,7 +823,7 @@ - + @@ -991,16 +875,6 @@ - - - - - - - - - - @@ -1043,6 +917,16 @@ + + + + + + + + + + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java index a9f4de9f..8a649993 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java @@ -29,7 +29,6 @@ import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.REMOVE; import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.ANNOTATION; import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.DOCUMENT; -import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.PROFILE; import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.SPAN; import com.mxgraph.swing.util.mxGraphTransferable; @@ -51,14 +50,12 @@ import edu.ucdenver.ccp.knowtator.view.actions.modelactions.SpanActions; import edu.ucdenver.ccp.knowtator.view.chooser.TextSourceChooser; import edu.ucdenver.ccp.knowtator.view.graph.GraphViewDialog; -import edu.ucdenver.ccp.knowtator.view.iaa.IAAOptionsDialog; import edu.ucdenver.ccp.knowtator.view.label.AnnotationAnnotatorLabel; import edu.ucdenver.ccp.knowtator.view.label.AnnotationClassLabel; import edu.ucdenver.ccp.knowtator.view.label.AnnotationIdLabel; import edu.ucdenver.ccp.knowtator.view.label.AnnotatorLabel; -import edu.ucdenver.ccp.knowtator.view.list.ColorList; import edu.ucdenver.ccp.knowtator.view.list.GraphSpaceList; -import edu.ucdenver.ccp.knowtator.view.list.ProfileList; +import edu.ucdenver.ccp.knowtator.view.profile.ProfileDialog; import edu.ucdenver.ccp.knowtator.view.table.AnnotationTable; import edu.ucdenver.ccp.knowtator.view.table.AnnotationTableForOwlClass; import edu.ucdenver.ccp.knowtator.view.table.AnnotationTableForSpannedText; @@ -89,7 +86,6 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.Method; -import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -157,10 +153,6 @@ public class KnowtatorView extends AbstractOWLClassViewComponent private JButton redoButton; private JProgressBar progressBar; private JList fileList; - private JButton removeProfileButton; - private ProfileList profileList; - private JButton addProfileButton; - private ColorList colorList; private JTextField annotationsContainingTextTextField; private JCheckBox exactMatchCheckBox; private JLabel owlClassLabel; @@ -188,7 +180,6 @@ public class KnowtatorView extends AbstractOWLClassViewComponent private JPanel spanPane; private JPanel graphSpacePane; private JComponent rootPane; - private JButton runIaaButton; private JButton captureImageButton; private JCheckBox oneClickGraphsCheckBox; private JTable conceptAnnotationsForTextTable; @@ -204,8 +195,9 @@ public class KnowtatorView extends AbstractOWLClassViewComponent private JCheckBox reviewRegexCheckBox; private AnnotatorLabel activeProfileLabel; private JButton fileButton; + private JButton profileButton; - private final List knowtatorComponents; + public final List knowtatorComponents; private final HashMap spanSizeButtons; private final HashMap selectionSizeButtons; @@ -240,8 +232,6 @@ public KnowtatorView() { header.setSelectedIndex(0); knowtatorComponents.addAll( Arrays.asList( - profileList, - colorList, textPane, graphViewDialog, annotationNotes, @@ -317,8 +307,6 @@ private void createUIComponents() { graphSpaceList = new GraphSpaceList(this); spanTable = new SpanTable(this); - profileList = new ProfileList(this); - colorList = new ColorList(this); annotationsContainingTextTextField = new JTextField(); @@ -427,22 +415,15 @@ private void makeButtons() { previousMatchButton.addActionListener(e -> textPane.searchPrevious()); searchTextField.addActionListener(e -> textPane.searchForward()); - makeReviewPane(); + profileButton.addActionListener( + e -> { + JDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(this), this); + dialog.pack(); + dialog.setVisible(true); + } + ); - addProfileButton.addActionListener( - e -> - Optional.ofNullable(JOptionPane.showInputDialog(this, "Enter a name for the profile")) - .ifPresent( - profileName -> - pickAction(this, profileName, null, new ActionParameters(ADD, PROFILE)))); - removeProfileButton.addActionListener( - e -> - Optional.of( - JOptionPane.showConfirmDialog( - this, "Are you sure you wish to remove this profile?")) - .filter(result -> JOptionPane.OK_OPTION == result) - .ifPresent( - result -> pickAction(this, null, null, new ActionParameters(REMOVE, PROFILE)))); + makeReviewPane(); addAnnotationButton.addActionListener( e -> @@ -641,30 +622,7 @@ private void makeButtons() { fileChooser.showOpenDialog(KnowtatorView.this); }); - runIaaButton.addActionListener( - e -> - getModel() - .ifPresent( - model -> { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setCurrentDirectory(model.getSaveLocation()); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - // - // disable the "All files" option. - // - fileChooser.setAcceptAllFileFilterUsed(false); - if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { - File outputDirectory = new File(fileChooser.getSelectedFile(), "IAA_results"); - try { - Files.createDirectories(outputDirectory.toPath()); - } catch (IOException ioException) { - ioException.printStackTrace(); - } - JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model, outputDirectory); - iaaDialog.pack(); - iaaDialog.setVisible(true); - } - })); + } private void open(JFileChooser fileChooser) { @@ -870,7 +828,6 @@ public void reset() { knowtatorComponents.forEach(KnowtatorComponent::reset); getModel().ifPresent(model1 -> model1.addModelListener(this)); getModel().ifPresent(model1 -> model1.addOwlModelManagerListener(annotationClassLabel)); - getModel().ifPresent(model1 -> model1.addOwlSelectionModelListener(colorList)); } /** @@ -1527,83 +1484,8 @@ public boolean isSnapToWords() { gbc.fill = GridBagConstraints.HORIZONTAL; panel18.add(refreshRelationReviewButton, gbc); final JPanel panel19 = new JPanel(); - panel19.setLayout(new BorderLayout(0, 0)); - header.addTab("Profile", panel19); - final JSplitPane splitPane1 = new JSplitPane(); - panel19.add(splitPane1, BorderLayout.CENTER); - final JPanel panel20 = new JPanel(); - panel20.setLayout(new GridBagLayout()); - splitPane1.setLeftComponent(panel20); - panel20.setBorder(BorderFactory.createTitledBorder(null, "Profiles", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$("Verdana", -1, 14, panel20.getFont()), null)); - final JScrollPane scrollPane7 = new JScrollPane(); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.BOTH; - panel20.add(scrollPane7, gbc); - Font profileListFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 12, profileList.getFont()); - if (profileListFont != null) { - profileList.setFont(profileListFont); - } - profileList.setToolTipText("Click to activate a profile"); - scrollPane7.setViewportView(profileList); - final JPanel panel21 = new JPanel(); - panel21.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.BOTH; - panel20.add(panel21, gbc); - addProfileButton = new JButton(); - Font addProfileButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, addProfileButton.getFont()); - if (addProfileButtonFont != null) { - addProfileButton.setFont(addProfileButtonFont); - } - addProfileButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-plus-24.png"))); - addProfileButton.setText(""); - addProfileButton.setToolTipText("Add a profile"); - panel21.add(addProfileButton); - removeProfileButton = new JButton(); - removeProfileButton.setEnabled(true); - Font removeProfileButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, removeProfileButton.getFont()); - if (removeProfileButtonFont != null) { - removeProfileButton.setFont(removeProfileButtonFont); - } - removeProfileButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-delete-24.png"))); - removeProfileButton.setText(""); - removeProfileButton.setToolTipText("Remove a profile"); - panel21.add(removeProfileButton); - runIaaButton = new JButton(); - Font runIaaButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, runIaaButton.getFont()); - if (runIaaButtonFont != null) { - runIaaButton.setFont(runIaaButtonFont); - } - this.$$$loadButtonText$$$(runIaaButton, this.$$$getMessageFromBundle$$$("log4j", "run.iaa")); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 2; - panel20.add(runIaaButton, gbc); - final JPanel panel22 = new JPanel(); - panel22.setLayout(new BorderLayout(0, 0)); - splitPane1.setRightComponent(panel22); - panel22.setBorder(BorderFactory.createTitledBorder(null, "Colors", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, 14, panel22.getFont()), null)); - final JScrollPane scrollPane8 = new JScrollPane(); - panel22.add(scrollPane8, BorderLayout.CENTER); - Font colorListFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, colorList.getFont()); - if (colorListFont != null) { - colorList.setFont(colorListFont); - } - colorList.setToolTipText("Click to set OWL Class color"); - scrollPane8.setViewportView(colorList); - final JPanel panel23 = new JPanel(); - panel23.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); - panel22.add(panel23, BorderLayout.NORTH); - final JPanel panel24 = new JPanel(); - panel24.setLayout(new GridBagLayout()); - header.addTab("Settings", panel24); + panel19.setLayout(new GridBagLayout()); + header.addTab("Settings", panel19); oneClickGraphsCheckBox = new JCheckBox(); oneClickGraphsCheckBox.setText("One Click Graphs"); gbc = new GridBagConstraints(); @@ -1611,7 +1493,7 @@ public boolean isSnapToWords() { gbc.gridy = 0; gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.WEST; - panel24.add(oneClickGraphsCheckBox, gbc); + panel19.add(oneClickGraphsCheckBox, gbc); snapToWordsCheckBox = new JCheckBox(); snapToWordsCheckBox.setSelected(true); snapToWordsCheckBox.setText("Snap to words"); @@ -1620,30 +1502,30 @@ public boolean isSnapToWords() { gbc.gridy = 1; gbc.weightx = 1.0; gbc.anchor = GridBagConstraints.WEST; - panel24.add(snapToWordsCheckBox, gbc); - final JPanel panel25 = new JPanel(); - panel25.setLayout(new BorderLayout(0, 0)); - body.setLeftComponent(panel25); - final JScrollPane scrollPane9 = new JScrollPane(); - panel25.add(scrollPane9, BorderLayout.CENTER); + panel19.add(snapToWordsCheckBox, gbc); + final JPanel panel20 = new JPanel(); + panel20.setLayout(new BorderLayout(0, 0)); + body.setLeftComponent(panel20); + final JScrollPane scrollPane7 = new JScrollPane(); + panel20.add(scrollPane7, BorderLayout.CENTER); textPane.setMinimumSize(new Dimension(200, 22)); textPane.setPreferredSize(new Dimension(500, 500)); textPane.setText(""); - scrollPane9.setViewportView(textPane); - final JPanel panel26 = new JPanel(); - panel26.setLayout(new GridBagLayout()); - panel25.add(panel26, BorderLayout.SOUTH); - final JPanel panel27 = new JPanel(); - panel27.setLayout(new BorderLayout(0, 0)); + scrollPane7.setViewportView(textPane); + final JPanel panel21 = new JPanel(); + panel21.setLayout(new GridBagLayout()); + panel20.add(panel21, BorderLayout.SOUTH); + final JPanel panel22 = new JPanel(); + panel22.setLayout(new BorderLayout(0, 0)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; - panel26.add(panel27, gbc); - final JPanel panel28 = new JPanel(); - panel28.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); - panel27.add(panel28, BorderLayout.EAST); + panel21.add(panel22, gbc); + final JPanel panel23 = new JPanel(); + panel23.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + panel22.add(panel23, BorderLayout.EAST); profileFilterCheckBox = new JCheckBox(); Font profileFilterCheckBoxFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, profileFilterCheckBox.getFont()); if (profileFilterCheckBoxFont != null) { @@ -1651,7 +1533,7 @@ public boolean isSnapToWords() { } profileFilterCheckBox.setText("Current Profile"); profileFilterCheckBox.setToolTipText("Toggle filter annotations by current profile"); - panel28.add(profileFilterCheckBox); + panel23.add(profileFilterCheckBox); owlClassFilterCheckBox = new JCheckBox(); Font owlClassFilterCheckBoxFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, owlClassFilterCheckBox.getFont()); if (owlClassFilterCheckBoxFont != null) { @@ -1659,16 +1541,16 @@ public boolean isSnapToWords() { } owlClassFilterCheckBox.setText("Current OWL Class"); owlClassFilterCheckBox.setToolTipText("Toggle filter annotations by current OWL class"); - panel28.add(owlClassFilterCheckBox); + panel23.add(owlClassFilterCheckBox); captureImageButton = new JButton(); captureImageButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-unsplash-32.png"))); captureImageButton.setText(""); captureImageButton.setToolTipText("Capture document"); - panel28.add(captureImageButton); - final JPanel panel29 = new JPanel(); - panel29.setLayout(new GridBagLayout()); - panel28.add(panel29); - panel29.setBorder(BorderFactory.createTitledBorder(null, "Font Size", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + panel23.add(captureImageButton); + final JPanel panel24 = new JPanel(); + panel24.setLayout(new GridBagLayout()); + panel23.add(panel24); + panel24.setBorder(BorderFactory.createTitledBorder(null, "Font Size", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); fontSizeSlider = new JSlider(); fontSizeSlider.setInverted(false); fontSizeSlider.setMajorTickSpacing(8); @@ -1683,48 +1565,48 @@ public boolean isSnapToWords() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; - panel29.add(fontSizeSlider, gbc); - final JPanel panel30 = new JPanel(); - panel30.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - panel27.add(panel30, BorderLayout.WEST); + panel24.add(fontSizeSlider, gbc); + final JPanel panel25 = new JPanel(); + panel25.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel22.add(panel25, BorderLayout.WEST); addTextSourceButton = new JButton(); addTextSourceButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-plus-24.png"))); addTextSourceButton.setText(""); addTextSourceButton.setToolTipText("Add a document"); - panel30.add(addTextSourceButton); + panel25.add(addTextSourceButton); removeTextSourceButton = new JButton(); removeTextSourceButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-delete-24.png"))); removeTextSourceButton.setText(""); removeTextSourceButton.setToolTipText("Remove current document from display"); - panel30.add(removeTextSourceButton); - final JPanel panel31 = new JPanel(); - panel31.setLayout(new BorderLayout(0, 0)); - panel25.add(panel31, BorderLayout.NORTH); - final JPanel panel32 = new JPanel(); - panel32.setLayout(new BorderLayout(0, 0)); - panel31.add(panel32, BorderLayout.CENTER); - final JPanel panel33 = new JPanel(); - panel33.setLayout(new GridBagLayout()); - panel32.add(panel33, BorderLayout.WEST); - panel33.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, 14, panel33.getFont()), null)); - final JLabel label5 = new JLabel(); - Font label5Font = this.$$$getFont$$$(null, Font.BOLD, 12, label5.getFont()); - if (label5Font != null) { - label5.setFont(label5Font); + panel25.add(removeTextSourceButton); + final JPanel panel26 = new JPanel(); + panel26.setLayout(new BorderLayout(0, 0)); + panel20.add(panel26, BorderLayout.NORTH); + final JPanel panel27 = new JPanel(); + panel27.setLayout(new BorderLayout(0, 0)); + panel26.add(panel27, BorderLayout.CENTER); + final JPanel panel28 = new JPanel(); + panel28.setLayout(new GridBagLayout()); + panel27.add(panel28, BorderLayout.WEST); + panel28.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, 14, panel28.getFont()), null)); + profileButton = new JButton(); + Font profileButtonFont = this.$$$getFont$$$(null, Font.BOLD, 12, profileButton.getFont()); + if (profileButtonFont != null) { + profileButton.setFont(profileButtonFont); } - label5.setText("Active Profile:"); + profileButton.setText("Active Profile:"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; - panel33.add(label5, gbc); - final JPanel panel34 = new JPanel(); - panel34.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel28.add(profileButton, gbc); + final JPanel panel29 = new JPanel(); + panel29.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.BOTH; - panel33.add(panel34, gbc); + panel28.add(panel29, gbc); addAnnotationButton = new JButton(); Font addAnnotationButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, addAnnotationButton.getFont()); if (addAnnotationButtonFont != null) { @@ -1736,7 +1618,7 @@ public boolean isSnapToWords() { addAnnotationButton.setToolTipText("Add annotation or span"); addAnnotationButton.setVerticalAlignment(0); addAnnotationButton.setVerticalTextPosition(3); - panel34.add(addAnnotationButton); + panel29.add(addAnnotationButton); removeAnnotationButton = new JButton(); Font removeAnnotationButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, removeAnnotationButton.getFont()); if (removeAnnotationButtonFont != null) { @@ -1747,7 +1629,7 @@ public boolean isSnapToWords() { removeAnnotationButton.setText(""); removeAnnotationButton.setToolTipText("Remove annotation or span"); removeAnnotationButton.setVerticalTextPosition(3); - panel34.add(removeAnnotationButton); + panel29.add(removeAnnotationButton); showGraphViewerButton = new JButton(); Font showGraphViewerButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, showGraphViewerButton.getFont()); if (showGraphViewerButtonFont != null) { @@ -1756,24 +1638,15 @@ public boolean isSnapToWords() { showGraphViewerButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-tree-structure-32.png"))); showGraphViewerButton.setText(""); showGraphViewerButton.setToolTipText("Open graph space viewer for document"); - panel34.add(showGraphViewerButton); - Font activeProfileLabelFont = this.$$$getFont$$$(null, -1, -1, activeProfileLabel.getFont()); - if (activeProfileLabelFont != null) { - activeProfileLabel.setFont(activeProfileLabelFont); - } - activeProfileLabel.setText(""); - gbc = new GridBagConstraints(); - gbc.gridx = 1; - gbc.gridy = 0; - panel33.add(activeProfileLabel, gbc); - final JPanel panel35 = new JPanel(); - panel35.setLayout(new GridBagLayout()); + panel29.add(showGraphViewerButton); + final JPanel panel30 = new JPanel(); + panel30.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.BOTH; - panel33.add(panel35, gbc); + panel28.add(panel30, gbc); previousTextSourceButton = new JButton(); previousTextSourceButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-advance-24 (reversed).png"))); previousTextSourceButton.setText(""); @@ -1781,7 +1654,7 @@ public boolean isSnapToWords() { gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; - panel35.add(previousTextSourceButton, gbc); + panel30.add(previousTextSourceButton, gbc); nextTextSourceButton = new JButton(); nextTextSourceButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-advance-24.png"))); nextTextSourceButton.setText(""); @@ -1789,16 +1662,25 @@ public boolean isSnapToWords() { gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; - panel35.add(nextTextSourceButton, gbc); + panel30.add(nextTextSourceButton, gbc); textSourceChooser.setPreferredSize(new Dimension(150, 24)); textSourceChooser.setToolTipText("Choose a document to view"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; - panel35.add(textSourceChooser, gbc); - final JPanel panel36 = new JPanel(); - panel36.setLayout(new GridBagLayout()); - panel32.add(panel36, BorderLayout.CENTER); + panel30.add(textSourceChooser, gbc); + Font activeProfileLabelFont = this.$$$getFont$$$(null, -1, -1, activeProfileLabel.getFont()); + if (activeProfileLabelFont != null) { + activeProfileLabel.setFont(activeProfileLabelFont); + } + activeProfileLabel.setText(""); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + panel28.add(activeProfileLabel, gbc); + final JPanel panel31 = new JPanel(); + panel31.setLayout(new GridBagLayout()); + panel27.add(panel31, BorderLayout.CENTER); Font searchTextFieldFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, searchTextField.getFont()); if (searchTextFieldFont != null) { searchTextField.setFont(searchTextFieldFont); @@ -1811,43 +1693,43 @@ public boolean isSnapToWords() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel36.add(searchTextField, gbc); - final JLabel label6 = new JLabel(); - label6.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-search-52.png"))); - label6.setText(""); + panel31.add(searchTextField, gbc); + final JLabel label5 = new JLabel(); + label5.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-search-52.png"))); + label5.setText(""); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; - panel36.add(label6, gbc); - final JPanel panel37 = new JPanel(); - panel37.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + panel31.add(label5, gbc); + final JPanel panel32 = new JPanel(); + panel32.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; - panel36.add(panel37, gbc); + panel31.add(panel32, gbc); Font onlyAnnotationsCheckBoxFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, onlyAnnotationsCheckBox.getFont()); if (onlyAnnotationsCheckBoxFont != null) { onlyAnnotationsCheckBox.setFont(onlyAnnotationsCheckBoxFont); } onlyAnnotationsCheckBox.setText("Only in Annotations"); onlyAnnotationsCheckBox.setToolTipText("Toggle search for text contained only in annotations"); - panel37.add(onlyAnnotationsCheckBox); + panel32.add(onlyAnnotationsCheckBox); Font regexCheckBoxFont = this.$$$getFont$$$(null, Font.BOLD, 14, regexCheckBox.getFont()); if (regexCheckBoxFont != null) { regexCheckBox.setFont(regexCheckBoxFont); } regexCheckBox.setText(".*"); regexCheckBox.setToolTipText("Toggle regex search"); - panel37.add(regexCheckBox); + panel32.add(regexCheckBox); Font caseSensitiveCheckBoxFont = this.$$$getFont$$$(null, Font.BOLD, 12, caseSensitiveCheckBox.getFont()); if (caseSensitiveCheckBoxFont != null) { caseSensitiveCheckBox.setFont(caseSensitiveCheckBoxFont); } caseSensitiveCheckBox.setText("Aa"); caseSensitiveCheckBox.setToolTipText("Toggle case sensitive search"); - panel37.add(caseSensitiveCheckBox); + panel32.add(caseSensitiveCheckBox); findTextInOntologyButton = new JButton(); Font findTextInOntologyButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, findTextInOntologyButton.getFont()); if (findTextInOntologyButtonFont != null) { @@ -1858,14 +1740,14 @@ public boolean isSnapToWords() { gbc = new GridBagConstraints(); gbc.gridx = 3; gbc.gridy = 1; - panel36.add(findTextInOntologyButton, gbc); - final JPanel panel38 = new JPanel(); - panel38.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); + panel31.add(findTextInOntologyButton, gbc); + final JPanel panel33 = new JPanel(); + panel33.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); gbc = new GridBagConstraints(); gbc.gridx = 3; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; - panel36.add(panel38, gbc); + panel31.add(panel33, gbc); previousMatchButton = new JButton(); Font previousMatchButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, previousMatchButton.getFont()); if (previousMatchButtonFont != null) { @@ -1874,7 +1756,7 @@ public boolean isSnapToWords() { previousMatchButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-sort-up-24.png"))); previousMatchButton.setText(""); previousMatchButton.setToolTipText("Previous match"); - panel38.add(previousMatchButton); + panel33.add(previousMatchButton); nextMatchButton = new JButton(); Font nextMatchButtonFont = this.$$$getFont$$$("Verdana", Font.PLAIN, 10, nextMatchButton.getFont()); if (nextMatchButtonFont != null) { @@ -1883,13 +1765,13 @@ public boolean isSnapToWords() { nextMatchButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-sort-down-24.png"))); nextMatchButton.setText(""); nextMatchButton.setToolTipText("Next match"); - panel38.add(nextMatchButton); - final JPanel panel39 = new JPanel(); - panel39.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); - panel31.add(panel39, BorderLayout.NORTH); + panel33.add(nextMatchButton); + final JPanel panel34 = new JPanel(); + panel34.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); + panel26.add(panel34, BorderLayout.NORTH); final JToolBar toolBar1 = new JToolBar(); toolBar1.setFloatable(false); - panel39.add(toolBar1); + panel34.add(toolBar1); fileButton = new JButton(); fileButton.setText("File"); toolBar1.add(fileButton); @@ -1907,8 +1789,8 @@ public boolean isSnapToWords() { filePanel = new JPanel(); filePanel.setLayout(new BorderLayout(0, 0)); cardPanel.add(filePanel, "File"); - final JScrollPane scrollPane10 = new JScrollPane(); - filePanel.add(scrollPane10, BorderLayout.CENTER); + final JScrollPane scrollPane8 = new JScrollPane(); + filePanel.add(scrollPane8, BorderLayout.CENTER); fileList = new JList(); Font fileListFont = this.$$$getFont$$$("Verdana", Font.BOLD, 14, fileList.getFont()); if (fileListFont != null) { @@ -1920,17 +1802,17 @@ public boolean isSnapToWords() { defaultListModel1.addElement("Import"); defaultListModel1.addElement("Export"); fileList.setModel(defaultListModel1); - scrollPane10.setViewportView(fileList); - final JPanel panel40 = new JPanel(); - panel40.setLayout(new BorderLayout(0, 0)); - filePanel.add(panel40, BorderLayout.NORTH); + scrollPane8.setViewportView(fileList); + final JPanel panel35 = new JPanel(); + panel35.setLayout(new BorderLayout(0, 0)); + filePanel.add(panel35, BorderLayout.NORTH); progressBar = new JProgressBar(); progressBar.setStringPainted(true); - panel40.add(progressBar, BorderLayout.CENTER); + panel35.add(progressBar, BorderLayout.CENTER); backButton = new JButton(); backButton.setText("Back"); - panel40.add(backButton, BorderLayout.WEST); - label6.setLabelFor(searchTextField); + panel35.add(backButton, BorderLayout.WEST); + label5.setLabelFor(searchTextField); } /** diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index 1513a10a..e70e9cc2 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -26,7 +26,6 @@ import static edu.ucdenver.ccp.knowtator.view.actions.modelactions.ProfileAction.assignColorToClass; -import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.ModelListener; import edu.ucdenver.ccp.knowtator.model.OwlModel; import edu.ucdenver.ccp.knowtator.model.collection.event.ChangeEvent; @@ -46,30 +45,34 @@ import org.apache.log4j.Logger; import org.protege.editor.owl.model.selection.OWLSelectionModelListener; -/** The type Color list. */ -public class ColorList extends JList implements KnowtatorComponent, ModelListener, OWLSelectionModelListener { +/** + * The type Color list. + */ +public class ColorList extends JList implements KnowtatorComponent, ModelListener, OWLSelectionModelListener { private final ListSelectionListener lsl; private final KnowtatorView view; private static final Logger log = Logger.getLogger(ColorList.class); - /** Instantiates a new Color list. */ + /** + * Instantiates a new Color list. + */ public ColorList(KnowtatorView view) { this.view = view; setModel(new DefaultListModel<>()); setCellRenderer(new ColorListRenderer<>()); - lsl = e -> assignColorToClass(view, getSelectedValue()); + lsl = e -> assignColorToClass(view, getSelectedValue()[0]); } private void setCollection() { + log.warn("here"); removeListSelectionListener(lsl); setModel(new DefaultListModel<>()); - view.getModel().flatMap(BaseModel::getSelectedProfile).ifPresent(profile -> + view.getModel().ifPresent(model -> model.getSelectedProfile().ifPresent(profile -> profile.getColors().keySet().stream() .sorted() - .forEach( - o -> ((DefaultListModel) getModel()).addElement(o))); - + .forEach(o -> + ((DefaultListModel) getModel()).addElement(new String[] {o, model.getOwlEntityRendering(o)})))); addListSelectionListener(lsl); } @@ -86,7 +89,8 @@ public void dispose() { } @Override - public void filterChangedEvent() {} + public void filterChangedEvent() { + } @Override public void modelChangeEvent(ChangeEvent event) { @@ -121,7 +125,9 @@ public void selectionChanged() { */ class ColorListRenderer extends JLabel implements ListCellRenderer { - /** Instantiates a new Color list renderer. */ + /** + * Instantiates a new Color list renderer. + */ ColorListRenderer() { setOpaque(true); } @@ -130,19 +136,20 @@ class ColorListRenderer extends JLabel implements ListCellRenderer { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { view.getModel() - .filter(model -> value instanceof String) + .filter(model -> value instanceof String[]) .ifPresent( model -> { + String[] val = (String[]) value; Optional owlClass = model.getSelectedOwlClass(); - if (owlClass.isPresent() && value.equals(owlClass.get())) { + if (owlClass.isPresent() && val[0].equals(owlClass.get())) { setBorder(BorderFactory.createStrokeBorder(new BasicStroke(2))); } else { setBorder(null); } model .getSelectedProfile() - .ifPresent(profile -> setBackground(profile.getColors().get(value))); - setText(value.toString()); + .ifPresent(profile -> setBackground(profile.getColors().get(val[0]))); + setText(val[1]); }); return this; } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form new file mode 100644 index 00000000..e3b8e4f9 --- /dev/null +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form @@ -0,0 +1,164 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java new file mode 100644 index 00000000..a4e85b22 --- /dev/null +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java @@ -0,0 +1,283 @@ +/* + * MIT License + * + * Copyright (c) 2018 Harrison Pielke-Lombardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package edu.ucdenver.ccp.knowtator.view.profile; + +import static edu.ucdenver.ccp.knowtator.view.actions.collection.AbstractKnowtatorCollectionAction.pickAction; +import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.ADD; +import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.REMOVE; +import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.PROFILE; + +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; +import edu.ucdenver.ccp.knowtator.view.actions.collection.ActionParameters; +import edu.ucdenver.ccp.knowtator.view.iaa.IAAOptionsDialog; +import edu.ucdenver.ccp.knowtator.view.list.ColorList; +import edu.ucdenver.ccp.knowtator.view.list.ProfileList; +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Window; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.Optional; +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.KeyStroke; +import javax.swing.border.TitledBorder; + +public class ProfileDialog extends JDialog { + private JPanel contentPane; + private JButton buttonOK; + ProfileList profileList; + ColorList colorList; + private JButton addProfileButton; + private JButton removeProfileButton; + private JButton addColorButton; + private JButton removeColorButton; + private JButton runIaaButton; + private final KnowtatorView view; + + public ProfileDialog(Window parent, KnowtatorView view) { + super(parent); + this.view = view; + $$$setupUI$$$(); + setContentPane(contentPane); + setModal(true); + getRootPane().setDefaultButton(buttonOK); + + view.knowtatorComponents.addAll( + Arrays.asList( + profileList, + colorList)); + + addProfileButton.addActionListener( + e -> + Optional.ofNullable(JOptionPane.showInputDialog(this, "Enter a name for the profile")) + .ifPresent( + profileName -> + pickAction(this.view, profileName, null, new ActionParameters(ADD, PROFILE)))); + removeProfileButton.addActionListener( + e -> + Optional.of( + JOptionPane.showConfirmDialog( + this, "Are you sure you wish to remove this profile?")) + .filter(result -> JOptionPane.OK_OPTION == result) + .ifPresent( + result -> pickAction(this.view, null, null, new ActionParameters(REMOVE, PROFILE)))); + + runIaaButton.addActionListener( + e -> + this.view.getModel() + .ifPresent( + model -> { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(model.getSaveLocation()); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + // + // disable the "All files" option. + // + fileChooser.setAcceptAllFileFilterUsed(false); + if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { + File outputDirectory = new File(fileChooser.getSelectedFile(), "IAA_results"); + try { + Files.createDirectories(outputDirectory.toPath()); + } catch (IOException ioException) { + ioException.printStackTrace(); + } + JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model, outputDirectory); + iaaDialog.pack(); + iaaDialog.setVisible(true); + } + })); + + buttonOK.addActionListener(e -> onOK()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + + profileList.reset(); + colorList.reset(); + } + + private void onOK() { + // add your code here + this.view.knowtatorComponents.remove(profileList); + this.view.knowtatorComponents.remove(colorList); + dispose(); + } + + void onCancel() { + // add your code here if necessary + this.view.knowtatorComponents.remove(profileList); + this.view.knowtatorComponents.remove(colorList); + dispose(); + } + + private void createUIComponents() { + profileList = new ProfileList(this.view); + colorList = new ColorList(this.view); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + createUIComponents(); + contentPane = new JPanel(); + contentPane.setLayout(new GridBagLayout()); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + GridBagConstraints gbc; + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.BOTH; + contentPane.add(panel1, gbc); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 2; + gbc.gridy = 0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + panel1.add(panel2, gbc); + buttonOK = new JButton(); + buttonOK.setText("OK"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel2.add(buttonOK, gbc); + runIaaButton = new JButton(); + runIaaButton.setText("Run IAA"); + runIaaButton.setToolTipText("Run inter-annotator agreement calculation"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel1.add(runIaaButton, gbc); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + contentPane.add(panel3, gbc); + final JSplitPane splitPane1 = new JSplitPane(); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + panel3.add(splitPane1, gbc); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new BorderLayout(0, 0)); + splitPane1.setLeftComponent(panel4); + panel4.setBorder(BorderFactory.createTitledBorder(null, "Profiles", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel4.add(panel5, BorderLayout.NORTH); + addProfileButton = new JButton(); + addProfileButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-plus-24.png"))); + addProfileButton.setText(""); + addProfileButton.setToolTipText("Add a profile"); + panel5.add(addProfileButton); + removeProfileButton = new JButton(); + removeProfileButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-delete-24.png"))); + removeProfileButton.setText(""); + removeProfileButton.setToolTipText("Delete a profile"); + panel5.add(removeProfileButton); + final JScrollPane scrollPane1 = new JScrollPane(); + panel4.add(scrollPane1, BorderLayout.CENTER); + final DefaultListModel defaultListModel1 = new DefaultListModel(); + profileList.setModel(defaultListModel1); + profileList.setToolTipText("Click to activate a profile."); + scrollPane1.setViewportView(profileList); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new BorderLayout(0, 0)); + splitPane1.setRightComponent(panel6); + panel6.setBorder(BorderFactory.createTitledBorder(null, "Colors", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JScrollPane scrollPane2 = new JScrollPane(); + panel6.add(scrollPane2, BorderLayout.CENTER); + colorList.setToolTipText("Click to select color for OWL class."); + scrollPane2.setViewportView(colorList); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + panel6.add(panel7, BorderLayout.NORTH); + addColorButton = new JButton(); + addColorButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-plus-24.png"))); + addColorButton.setText(""); + addColorButton.setToolTipText("Add color for current OWL class"); + panel7.add(addColorButton); + removeColorButton = new JButton(); + removeColorButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-delete-24.png"))); + removeColorButton.setText(""); + removeColorButton.setToolTipText("Remove current color"); + panel7.add(removeColorButton); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } + +} diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialogTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialogTest.java new file mode 100644 index 00000000..15865a04 --- /dev/null +++ b/src/test/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialogTest.java @@ -0,0 +1,130 @@ +/* + * MIT License + * + * Copyright (c) 2018 Harrison Pielke-Lombardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package edu.ucdenver.ccp.knowtator.view.profile; + +import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.ADD; + +import edu.ucdenver.ccp.knowtator.TestingHelpers; +import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; +import edu.ucdenver.ccp.knowtator.view.actions.AbstractKnowtatorAction; +import edu.ucdenver.ccp.knowtator.view.actions.ActionUnperformable; +import edu.ucdenver.ccp.knowtator.view.actions.modelactions.ProfileAction; +import java.io.IOException; +import javax.swing.JOptionPane; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +class ProfileDialogTest { + private static KnowtatorView view; + private static final int defaultExpectedHighlighters = 1; + + @BeforeAll + static void setUp() { + view = new KnowtatorView(); + } + + @Test + void cancelProfileDialogTest() throws IOException { + KnowtatorModel model = TestingHelpers.getLoadedModel(); + TestingHelpers.checkDefaultCollectionValues(model); + view.loadProject(model.getProjectLocation(), null); + TestingHelpers.checkDefaultCollectionValues(view.getModel().get()); + + ProfileDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(view), view); + dialog.pack(); + dialog.onCancel(); + TestingHelpers.checkDefaultCollectionValues(model); + } + + @Test + void okProfileDialogTest() throws IOException { + KnowtatorModel model = TestingHelpers.getLoadedModel(); + TestingHelpers.checkDefaultCollectionValues(model); + view.loadProject(model.getProjectLocation(), null); + TestingHelpers.checkDefaultCollectionValues(view.getModel().get()); + + ProfileDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(view), view); + dialog.pack(); + dialog.onCancel(); + TestingHelpers.checkDefaultCollectionValues(model); + } + + public static void testKnowtatorAction( + ProfileDialog dialog, + KnowtatorModel controller, + AbstractKnowtatorAction action, + int expectedProfiles, + int expectedHighlighters) + throws ActionUnperformable { + checkDefaultCollectionValues(dialog); + controller.registerAction(action); + countCollections( + dialog, + expectedProfiles, + expectedHighlighters); + controller.undo(); + controller.getProfiles().setSelection(controller.getDefaultProfile()); + checkDefaultCollectionValues(dialog); + controller.redo(); + countCollections( + dialog, + expectedProfiles, + expectedHighlighters); + controller.undo(); + } + + private static void countCollections(ProfileDialog dialog, int expectedProfiles, int expectedHighlighters) { + assert dialog.profileList.getModel().getSize() == expectedProfiles; + assert dialog.colorList.getModel().getSize() == expectedHighlighters; + } + + private static void checkDefaultCollectionValues(ProfileDialog dialog) { + assert dialog.profileList.getModel().getSize() == TestingHelpers.defaultExpectedProfiles; + assert dialog.colorList.getModel().getSize() == defaultExpectedHighlighters; + } + + @Test + void addProfileDialogTest() throws IOException, ActionUnperformable { + KnowtatorModel model = TestingHelpers.getLoadedModel(); + TestingHelpers.checkDefaultCollectionValues(model); + view.loadProject(model.getProjectLocation(), null); + TestingHelpers.checkDefaultCollectionValues(view.getModel().get()); + + ProfileDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(view), view); + dialog.pack(); + + model = view.getModel().get(); + + testKnowtatorAction(dialog, model, + new ProfileAction(model, ADD, "I'm new here"), + TestingHelpers.defaultExpectedProfiles + 1, + 0); + + dialog.onCancel(); + TestingHelpers.checkDefaultCollectionValues(model); + } + +} \ No newline at end of file From b2c0bb0bef7891dd5d8cfb6094657c7a0eef150c Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Wed, 17 Jun 2020 23:51:15 -0600 Subject: [PATCH 36/65] Added step after loading project to verify extra profile colors don't remain. --- .idea/workspace.xml | 49 +++++++++---------- .../ccp/knowtator/model/KnowtatorModel.java | 6 +++ .../model/collection/ProfileCollection.java | 5 ++ .../ccp/knowtator/model/object/Profile.java | 11 ++++- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 46d2b3cc..4b5626db 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -30,13 +30,10 @@ - - - - - - + + + - + @@ -303,7 +300,7 @@ - + 1590645202357 @@ -611,10 +608,10 @@ - + - + @@ -660,59 +657,59 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index 5f032add..2657f6dd 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -37,7 +37,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.apache.log4j.Logger; import org.protege.editor.owl.model.OWLWorkspace; @@ -124,6 +126,10 @@ public void load() { profiles.first().ifPresent(profiles::setSelection); textSources.first().ifPresent(textSources::setSelection); + Set owlClasses = new HashSet<>(); + textSources.forEach(textSource -> textSource.getConceptAnnotations().forEach(conceptAnnotation -> owlClasses.add(conceptAnnotation.getOwlClass()))); + profiles.verifyHighlighters(owlClasses); + } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ProfileCollection.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ProfileCollection.java index c79720f1..aecfd94b 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ProfileCollection.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ProfileCollection.java @@ -27,6 +27,7 @@ import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.object.Profile; import java.util.Optional; +import java.util.Set; /** The type Profile collection. */ public class ProfileCollection extends KnowtatorCollection { @@ -79,4 +80,8 @@ public void remove(Profile profile) { super.remove(profile); selectNext(); } + + public void verifyHighlighters(Set owlClasses) { + forEach(profile -> profile.verifyHighLighters(owlClasses)); + } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java index 351fb95a..bc271a8b 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java @@ -34,6 +34,7 @@ import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.Set; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -43,7 +44,7 @@ public class Profile implements ModelObject, Savable, ModelListener { private static Logger log = LogManager.getLogger(Profile.class); private String id; - private final HashMap colors; // + private HashMap colors; // private final KnowtatorModel model; /** @@ -160,4 +161,12 @@ public void colorChangedEvent(Profile profile) { @Override public void modelChangeEvent(ChangeEvent event) {} + + public void verifyHighLighters(Set owlClasses) { + HashMap verifiedColors = new HashMap<>(); + colors.entrySet().stream() + .filter(entry -> owlClasses.contains(entry.getKey())) + .forEach(entry -> verifiedColors.put(entry.getKey(), entry.getValue())); + colors = verifiedColors; + } } From d568ec1cabcef220f02775cebc700dd493c8a35e Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 18 Jun 2020 01:52:56 -0600 Subject: [PATCH 37/65] Verify the profile highlighters when loading the project --- .gitignore | 1 + ...otege_org_protege_common_5_0_0_beta_17.xml | 13 --- ..._editor_core_application_5_0_0_beta_17.xml | 13 --- ...e_org_protege_editor_owl_5_0_0_beta_17.xml | 13 --- ...d_protege_org_protege_xmlcatalog_1_0_5.xml | 13 --- ...d_protege_protege_editor_owl_5_0_0_RC1.xml | 13 --- ...rotege_protege_owlapi_extensions_3_2_6.xml | 13 --- .idea/libraries/Maven__log4j_log4j_1_2_17.xml | 13 --- ...en__net_sourceforge_owlapi_jfact_1_0_0.xml | 13 --- .../Maven__xml_resolver_xml_resolver_1_2.xml | 13 --- .idea/workspace.xml | 93 +++++++++++-------- Knowtator-2.0.iml | 18 ++-- pom.xml | 7 +- .../io/knowtator/KnowtatorXmlUtil.java | 6 +- .../ccp/knowtator/model/OwlModel.java | 77 +++++++++++---- .../ConceptAnnotationCollection.java | 1 + .../ccp/knowtator/model/object/Profile.java | 2 +- .../ccp/knowtator/view/list/ColorList.java | 1 - 18 files changed, 126 insertions(+), 197 deletions(-) delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_org_protege_common_5_0_0_beta_17.xml delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_org_protege_editor_core_application_5_0_0_beta_17.xml delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_org_protege_editor_owl_5_0_0_beta_17.xml delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_org_protege_xmlcatalog_1_0_5.xml delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_protege_editor_owl_5_0_0_RC1.xml delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_protege_owlapi_extensions_3_2_6.xml delete mode 100644 .idea/libraries/Maven__log4j_log4j_1_2_17.xml delete mode 100644 .idea/libraries/Maven__net_sourceforge_owlapi_jfact_1_0_0.xml delete mode 100644 .idea/libraries/Maven__xml_resolver_xml_resolver_1_2.xml diff --git a/.gitignore b/.gitignore index 1a8959e1..aadb2ba5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ src/test/resources/concepts+assertions/ /.lein-failures /.dir-locals.el /.nrepl-port +/.idea/libraries/ diff --git a/.idea/libraries/Maven__edu_stanford_protege_org_protege_common_5_0_0_beta_17.xml b/.idea/libraries/Maven__edu_stanford_protege_org_protege_common_5_0_0_beta_17.xml deleted file mode 100644 index 7cc1cffb..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_org_protege_common_5_0_0_beta_17.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_core_application_5_0_0_beta_17.xml b/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_core_application_5_0_0_beta_17.xml deleted file mode 100644 index d8fc52be..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_core_application_5_0_0_beta_17.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_owl_5_0_0_beta_17.xml b/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_owl_5_0_0_beta_17.xml deleted file mode 100644 index f621f006..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_org_protege_editor_owl_5_0_0_beta_17.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__edu_stanford_protege_org_protege_xmlcatalog_1_0_5.xml b/.idea/libraries/Maven__edu_stanford_protege_org_protege_xmlcatalog_1_0_5.xml deleted file mode 100644 index 602cd043..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_org_protege_xmlcatalog_1_0_5.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__edu_stanford_protege_protege_editor_owl_5_0_0_RC1.xml b/.idea/libraries/Maven__edu_stanford_protege_protege_editor_owl_5_0_0_RC1.xml deleted file mode 100644 index 0f420972..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_protege_editor_owl_5_0_0_RC1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__edu_stanford_protege_protege_owlapi_extensions_3_2_6.xml b/.idea/libraries/Maven__edu_stanford_protege_protege_owlapi_extensions_3_2_6.xml deleted file mode 100644 index 893047d7..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_protege_owlapi_extensions_3_2_6.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__log4j_log4j_1_2_17.xml b/.idea/libraries/Maven__log4j_log4j_1_2_17.xml deleted file mode 100644 index e383c1bf..00000000 --- a/.idea/libraries/Maven__log4j_log4j_1_2_17.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__net_sourceforge_owlapi_jfact_1_0_0.xml b/.idea/libraries/Maven__net_sourceforge_owlapi_jfact_1_0_0.xml deleted file mode 100644 index a98c30bf..00000000 --- a/.idea/libraries/Maven__net_sourceforge_owlapi_jfact_1_0_0.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__xml_resolver_xml_resolver_1_2.xml b/.idea/libraries/Maven__xml_resolver_xml_resolver_1_2.xml deleted file mode 100644 index 3c94b040..00000000 --- a/.idea/libraries/Maven__xml_resolver_xml_resolver_1_2.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4b5626db..ddedb398 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -30,10 +30,30 @@ + + + + + + + + + + + + + + + + - - + + + + + + @@ -300,7 +320,7 @@ - + 1590645202357 @@ -657,62 +677,66 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + @@ -721,9 +745,10 @@ - - + + + @@ -750,9 +775,10 @@ - - + + + @@ -765,10 +791,10 @@ - + - + @@ -780,21 +806,6 @@ 175 diff --git a/Knowtator-2.0.iml b/Knowtator-2.0.iml index 34195c37..f67c6f24 100644 --- a/Knowtator-2.0.iml +++ b/Knowtator-2.0.iml @@ -13,7 +13,7 @@ - + @@ -106,16 +106,14 @@ - - - - + + + + + + + - - - - - diff --git a/pom.xml b/pom.xml index aff3b57d..143f9b3f 100644 --- a/pom.xml +++ b/pom.xml @@ -63,18 +63,13 @@ edu.stanford.protege protege-editor-owl - 5.0.0-RC1 + 5.5.0 org.slf4j slf4j-api 1.7.10 - - edu.stanford.protege - org.protege.editor.owl - 5.0.0-beta-17 - com.github.vlsi.mxgraph jgraphx diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java index c8271fbe..58b53426 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java @@ -171,9 +171,9 @@ private void readToConceptAnnotationCollection( if (owlClass.isPresent()) { owlClassID = owlClass.get().toStringID(); } else { - log.warn( - String.format( - "OWL Class: %s not found for concept: %s", owlClassID, annotationID)); +// log.warn( +// String.format( +// "OWL Class: %s not found for concept: %s", owlClassID, annotationID)); model.addOWLClassNotFoundAnnotations(annotationID, owlClassID); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java index 3d80298e..4a814b08 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java @@ -34,6 +34,7 @@ import java.nio.file.Files; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -46,6 +47,10 @@ import org.protege.editor.owl.model.event.OWLModelManagerListener; import org.protege.editor.owl.model.selection.OWLSelectionModel; import org.protege.editor.owl.model.selection.OWLSelectionModelListener; +import org.protege.editor.owl.ui.prefix.OWLEntityPrefixedNameRenderer; +import org.protege.editor.owl.ui.renderer.OWLEntityRendererImpl; +import org.protege.editor.owl.ui.renderer.OWLRendererPreferences; +import org.protege.editor.owl.ui.renderer.plugin.RendererPlugin; import org.protege.editor.owl.ui.search.SearchDialogPanel; import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.HasAnnotationPropertiesInSignature; @@ -63,7 +68,9 @@ import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.model.OWLOntologyStorageException; -/** The type Owl model. */ +/** + * The type Owl model. + */ public abstract class OwlModel extends BaseModel implements Serializable { @SuppressWarnings("unused") private static final Logger log = LogManager.getLogger(OwlModel.class); @@ -72,12 +79,13 @@ public abstract class OwlModel extends BaseModel implements Serializable { @SuppressWarnings("OptionalUsedAsFieldOrParameterType") private final Optional owlWorkSpace; + private List iris; /** * Instantiates a new Owl model. * * @param projectLocation the project location - * @param owlWorkspace the owl workspace + * @param owlWorkspace the owl workspace * @throws IOException the io exception */ OwlModel(File projectLocation, OWLWorkspace owlWorkspace) throws IOException { @@ -95,9 +103,12 @@ public abstract class OwlModel extends BaseModel implements Serializable { */ public Optional getOwlClassById(@Nonnull String classID) { if (owlWorkSpace.isPresent()) { - return owlWorkSpace.map( + return owlWorkSpace.flatMap( owlWorkspace -> - owlWorkspace.getOWLModelManager().getOWLEntityFinder().getOWLClass(String.format("<%s>", classID))); + owlWorkspace.getOWLModelManager().getOWLEntityFinder().getEntities(IRI.create(classID)).stream() + .filter(owlEntity -> owlEntity instanceof OWLClass) + .map(owlEntity -> (OWLClass) owlEntity) + .findAny()); } else { for (OWLOntology ontology : owlOntologyManager.getOntologies()) { Optional owlClassOptional = @@ -107,11 +118,11 @@ public Optional getOwlClassById(@Nonnull String classID) { owlClass.getIRI().toString().equals(classID) || owlClass.getIRI().getShortForm().equals(classID) || ontology.getAnnotationAssertionAxioms(owlClass.getIRI()).stream() - .anyMatch( - owlAnnotationAssertionAxiom -> - getAnnotationLiteral(owlAnnotationAssertionAxiom) - .map(label -> label.equals(classID)) - .orElse(false))) + .anyMatch( + owlAnnotationAssertionAxiom -> + getAnnotationLiteral(owlAnnotationAssertionAxiom) + .map(label -> label.equals(classID)) + .orElse(false))) .findFirst(); if (owlClassOptional.isPresent()) { return owlClassOptional; @@ -273,7 +284,9 @@ public void searchForString(String stringToSearch) { }); } - /** Load. */ + /** + * Load. + */ public void load() { log.info("Loading ontologies"); try { @@ -428,14 +441,42 @@ public void setSelectedOwlObjectProperty(String property) { public IRI[] getOWLAnnotationProperties() { return owlWorkSpace .map(owlWorkspace -> owlWorkspace.getOWLModelManager().getOntologies().stream() - .map(HasAnnotationPropertiesInSignature::getAnnotationPropertiesInSignature) - .flatMap(Set::stream) - .map(OWLNamedObject::getIRI) - .toArray(IRI[]::new)) + .map(HasAnnotationPropertiesInSignature::getAnnotationPropertiesInSignature) + .flatMap(Set::stream) + .map(OWLNamedObject::getIRI) + .toArray(IRI[]::new)) .orElseGet(() -> owlOntologyManager.getOntologies().stream() - .map(HasAnnotationPropertiesInSignature::getAnnotationPropertiesInSignature) - .flatMap(Set::stream) - .map(OWLNamedObject::getIRI) - .toArray(IRI[]::new)); + .map(HasAnnotationPropertiesInSignature::getAnnotationPropertiesInSignature) + .flatMap(Set::stream) + .map(OWLNamedObject::getIRI) + .toArray(IRI[]::new)); + } + + protected boolean isMyRendererPlugin(RendererPlugin plugin) { + return plugin.getRendererClassName().equals("org.protege.editor.owl.ui.prefix.OWLEntityPrefixedNameRenderer"); + } + + void setRendering() { + + owlWorkSpace.ifPresent(owlWorkspace -> { + OWLRendererPreferences preferences = OWLRendererPreferences.getInstance(); + preferences.setRendererPlugin(preferences.getRendererPluginByClassName(OWLEntityPrefixedNameRenderer.class.getName())); + for (RendererPlugin plugin : preferences.getRendererPlugins()) { + log.warn(plugin.getRendererClassName()); + if (isMyRendererPlugin(plugin)) { + preferences.setRendererPlugin(plugin); + owlWorkspace.getOWLModelManager().refreshRenderer(); + break; + } + } + }); + } + + void resetRendering() { + owlWorkSpace.ifPresent(owlWorkspace -> { + OWLRendererPreferences preferences = OWLRendererPreferences.getInstance(); + preferences.setRendererPlugin(preferences.getRendererPluginByClassName(OWLEntityRendererImpl.class.getName())); + owlWorkspace.getOWLModelManager().refreshRenderer(); + }); } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ConceptAnnotationCollection.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ConceptAnnotationCollection.java index 4a89f2f1..9f52f82b 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ConceptAnnotationCollection.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/collection/ConceptAnnotationCollection.java @@ -208,6 +208,7 @@ public void add(ConceptAnnotation conceptAnnotation) { @Override public void dispose() { model.removeOntologyChangeListener(this); + model.removeModelListener(this); super.dispose(); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java index bc271a8b..44c444eb 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/Profile.java @@ -165,7 +165,7 @@ public void modelChangeEvent(ChangeEvent event) {} public void verifyHighLighters(Set owlClasses) { HashMap verifiedColors = new HashMap<>(); colors.entrySet().stream() - .filter(entry -> owlClasses.contains(entry.getKey())) + .filter(entry -> model.getOwlClassById(entry.getKey()).isPresent()) .forEach(entry -> verifiedColors.put(entry.getKey(), entry.getValue())); colors = verifiedColors; } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index e70e9cc2..b416acef 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -65,7 +65,6 @@ public ColorList(KnowtatorView view) { } private void setCollection() { - log.warn("here"); removeListSelectionListener(lsl); setModel(new DefaultListModel<>()); view.getModel().ifPresent(model -> model.getSelectedProfile().ifPresent(profile -> From 203b3e6a74cfc781168935c113d3303c01923a24 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 18 Jun 2020 02:06:52 -0600 Subject: [PATCH 38/65] Readded logging for when OWL classes aren't found. --- .../ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java index 58b53426..c8271fbe 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java @@ -171,9 +171,9 @@ private void readToConceptAnnotationCollection( if (owlClass.isPresent()) { owlClassID = owlClass.get().toStringID(); } else { -// log.warn( -// String.format( -// "OWL Class: %s not found for concept: %s", owlClassID, annotationID)); + log.warn( + String.format( + "OWL Class: %s not found for concept: %s", owlClassID, annotationID)); model.addOWLClassNotFoundAnnotations(annotationID, owlClassID); } From 5ca59749c7ec72b83f62c69e76af2c485cbf649d Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 18 Jun 2020 02:07:38 -0600 Subject: [PATCH 39/65] Implemented setting color for active owl class --- .../knowtator/view/profile/ProfileDialog.form | 8 -------- .../knowtator/view/profile/ProfileDialog.java | 16 +++++++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form index e3b8e4f9..3d840701 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.form @@ -143,14 +143,6 @@ - - - - - - - -
diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java index a4e85b22..7ab5ebed 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java @@ -28,7 +28,9 @@ import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.ADD; import static edu.ucdenver.ccp.knowtator.view.actions.collection.CollectionActionType.REMOVE; import static edu.ucdenver.ccp.knowtator.view.actions.collection.KnowtatorCollectionType.PROFILE; +import static edu.ucdenver.ccp.knowtator.view.actions.modelactions.ProfileAction.assignColorToClass; +import edu.ucdenver.ccp.knowtator.model.OwlModel; import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import edu.ucdenver.ccp.knowtator.view.actions.collection.ActionParameters; import edu.ucdenver.ccp.knowtator.view.iaa.IAAOptionsDialog; @@ -65,11 +67,10 @@ public class ProfileDialog extends JDialog { private JPanel contentPane; private JButton buttonOK; ProfileList profileList; - ColorList colorList; + public ColorList colorList; private JButton addProfileButton; private JButton removeProfileButton; private JButton addColorButton; - private JButton removeColorButton; private JButton runIaaButton; private final KnowtatorView view; @@ -101,6 +102,12 @@ public ProfileDialog(Window parent, KnowtatorView view) { .ifPresent( result -> pickAction(this.view, null, null, new ActionParameters(REMOVE, PROFILE)))); + addColorButton.addActionListener( + e -> + // TODO: This could be removed if class selection were reflected in color list + this.view.getModel() + .flatMap(OwlModel::getSelectedOwlClass) + .ifPresent(owlClass -> assignColorToClass(this.view, owlClass))); runIaaButton.addActionListener( e -> this.view.getModel() @@ -266,11 +273,6 @@ private void createUIComponents() { addColorButton.setText(""); addColorButton.setToolTipText("Add color for current OWL class"); panel7.add(addColorButton); - removeColorButton = new JButton(); - removeColorButton.setIcon(new ImageIcon(getClass().getResource("/icon/icons8-delete-24.png"))); - removeColorButton.setText(""); - removeColorButton.setToolTipText("Remove current color"); - panel7.add(removeColorButton); } /** From dae06e7b6f8cba9103c2e7e4cd5420fa0c535c9f Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 18 Jun 2020 02:42:59 -0600 Subject: [PATCH 40/65] Scroll to class in color list --- .idea/workspace.xml | 66 +++++++------------ .../ccp/knowtator/view/KnowtatorView.java | 3 +- .../ccp/knowtator/view/list/ColorList.java | 13 ++++ 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ddedb398..b83cabe2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -30,29 +30,8 @@ - - - - - - - - - - - - - - - - - - - - - - + @@ -320,7 +299,8 @@ - + + 1590645202357 @@ -677,59 +657,63 @@ - + - + + - + - + + - + - + + - + - + + - + - + - + - + - + - + - + - + @@ -775,10 +759,10 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java index 8a649993..3a9ae1c9 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java @@ -417,8 +417,9 @@ private void makeButtons() { profileButton.addActionListener( e -> { - JDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(this), this); + ProfileDialog dialog = new ProfileDialog(JOptionPane.getFrameForComponent(this), this); dialog.pack(); + dialog.colorList.selectionChanged(); dialog.setVisible(true); } ); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index b416acef..5f3c4fd9 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -35,6 +35,7 @@ import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.awt.BasicStroke; import java.awt.Component; +import java.util.Enumeration; import java.util.Optional; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; @@ -111,7 +112,19 @@ public void selectionChanged() { owlClassOptional.ifPresent(owlClass -> { setCollection(); int i = ((DefaultListModel) getModel()).indexOf(owlClass); + i = 0; + Enumeration e = ((DefaultListModel) getModel()).elements(); + while(e.hasMoreElements()) { + if(owlClass.equals(e.nextElement()[0])) { + break; + } + i++; + } + + log.warn(owlClass); + log.warn(i); if (-1 < i) { + log.warn("here"); scrollRectToVisible(getCellBounds(i, i)); } }); From f1f0968369fc7035dfaf35fa64d4391700cb8d96 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 30 Jun 2020 15:59:39 -0600 Subject: [PATCH 41/65] Updates and likely required files --- .idea/workspace.xml | 24 +- .../CRAFT_aggregate_OWL_ontology.owl | 226976 +++++++++++++++ 2 files changed, 226986 insertions(+), 14 deletions(-) create mode 100755 src/test/resources/iaa_test_project/Ontologies/CRAFT_aggregate_OWL_ontology.owl diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b83cabe2..17b7c154 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -29,11 +29,7 @@ - - - - - + + + @@ -29,7 +32,17 @@ - + + + + + + + + + + + + + + @@ -97,7 +117,7 @@ - + @@ -133,6 +153,17 @@ + + + - + - - - + @@ -166,13 +198,12 @@ - + @@ -182,13 +213,13 @@ - + @@ -198,7 +229,7 @@ + @@ -297,6 +328,7 @@ + 1590645202357 @@ -505,12 +537,7 @@ - + diff --git a/Knowtator-2.0.iml b/Knowtator-2.0.iml index f67c6f24..33d0615f 100644 --- a/Knowtator-2.0.iml +++ b/Knowtator-2.0.iml @@ -13,7 +13,7 @@ - + @@ -28,11 +28,15 @@ + + + + @@ -98,18 +102,16 @@ - + + - - - - - + + diff --git a/pom.xml b/pom.xml index 143f9b3f..3ed3c4ab 100644 --- a/pom.xml +++ b/pom.xml @@ -53,12 +53,12 @@ edu.stanford.protege protege-common - 5.0.0-RC1 + 5.5.0 edu.stanford.protege protege-editor-core - 5.0.0-RC1 + 5.5.0 edu.stanford.protege From 434473ec2af1b3efc910082b6668e4cd3ce4d940 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Fri, 14 Aug 2020 19:05:32 -0600 Subject: [PATCH 44/65] Added ignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eaa9b3f1..97b02af0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ src/test/resources/concepts+assertions/ /.nrepl-port /.idea/libraries/ /.idea/knowtator.iml +/.attach_pid272926 From 213a12448c7d765c372e8b96335d32ab14c338c6 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Fri, 14 Aug 2020 19:05:40 -0600 Subject: [PATCH 45/65] Changed test conditions for triples. --- src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java | 2 +- .../knowtator/view/actions/KnowtatorCollectionActionsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java index 303a5f71..f75a79c0 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java @@ -65,7 +65,7 @@ public class TestingHelpers { public static final int defaultExpectedAnnotationNodes = 7; /** The constant defaultExpectedTriples. */ - public static final int defaultExpectedTriples = 5; + public static final int defaultExpectedTriples = 4; public static int defaultAnnotationLayers = 1; diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/view/actions/KnowtatorCollectionActionsTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/view/actions/KnowtatorCollectionActionsTest.java index b0c28d3a..bc280815 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/view/actions/KnowtatorCollectionActionsTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/view/actions/KnowtatorCollectionActionsTest.java @@ -220,7 +220,7 @@ public void removeProfileActionTest() throws ActionUnperformable { TestingHelpers.defaultExpectedProfiles - 1, TestingHelpers.defaultExpectedHighlighters - 2, TestingHelpers.defaultExpectedAnnotationNodes - 2, - TestingHelpers.defaultExpectedTriples - 3, + TestingHelpers.defaultExpectedTriples - 2, TestingHelpers.defaultExpectedStructureAnnotations ); From eb60ea399d601457159e09d40cc6a99ed566077e Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 17 Aug 2020 11:42:42 -0500 Subject: [PATCH 46/65] Fixed opening active profile button when no colors in profile. --- Knowtator-2.0.iml | 10 +++++----- .../ucdenver/ccp/knowtator/view/list/ColorList.java | 8 ++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Knowtator-2.0.iml b/Knowtator-2.0.iml index 33d0615f..2166d006 100644 --- a/Knowtator-2.0.iml +++ b/Knowtator-2.0.iml @@ -95,21 +95,21 @@ - + + + + - - - - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index 5f3c4fd9..1f9c1c94 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -111,20 +111,16 @@ public void selectionChanged() { owlClassOptional.ifPresent(owlClass -> { setCollection(); - int i = ((DefaultListModel) getModel()).indexOf(owlClass); - i = 0; + int i = -1; Enumeration e = ((DefaultListModel) getModel()).elements(); while(e.hasMoreElements()) { + i++; if(owlClass.equals(e.nextElement()[0])) { break; } - i++; } - log.warn(owlClass); - log.warn(i); if (-1 < i) { - log.warn("here"); scrollRectToVisible(getCellBounds(i, i)); } }); From b2d54f87bcb8374bd58150e0d0574ecc0fc7821f Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 17 Aug 2020 12:23:16 -0500 Subject: [PATCH 47/65] Added choices for OWL classes in IAA calculation. --- .idea/workspace.xml | 110 +++++++++-------- .../ccp/knowtator/iaa/KnowtatorIaa.java | 41 +++++-- .../knowtator/view/iaa/IAAOptionsDialog.form | 102 ++++++++++------ .../knowtator/view/iaa/IAAOptionsDialog.java | 115 ++++++++++++------ .../ccp/knowtator/KnowtatorIaaTest.java | 8 +- 5 files changed, 238 insertions(+), 138 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index bfcb212f..c6a9e5a9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,16 +32,15 @@ - - - - - + + + + - - - - + + + + @@ -328,7 +316,8 @@ - + + 1590645202357 @@ -533,7 +522,14 @@ - @@ -582,7 +578,6 @@ - @@ -607,7 +602,8 @@ - @@ -622,10 +618,11 @@ - + + @@ -645,9 +642,10 @@ - - + + + @@ -675,76 +673,85 @@ - - + + + - + - + + - + - + + - + - + + - + - + + - + + - + + - + + - + + @@ -778,9 +785,10 @@ - - + + + @@ -790,10 +798,11 @@ - + + @@ -806,10 +815,11 @@ - + + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/iaa/KnowtatorIaa.java b/src/main/java/edu/ucdenver/ccp/knowtator/iaa/KnowtatorIaa.java index 10feead2..14a223be 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/iaa/KnowtatorIaa.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/iaa/KnowtatorIaa.java @@ -31,7 +31,6 @@ import edu.ucdenver.ccp.knowtator.iaa.matcher.Matcher; import edu.ucdenver.ccp.knowtator.iaa.matcher.SpanMatcher; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; -import edu.ucdenver.ccp.knowtator.model.collection.ConceptAnnotationCollection; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.TextSource; import java.io.File; @@ -43,8 +42,11 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; -/** The type Knowtator iaa. */ +/** + * The type Knowtator iaa. + */ public class KnowtatorIaa { private final File outputDirectory; @@ -64,7 +66,7 @@ public class KnowtatorIaa { private final Map annotationTextNames; - private Map textSourceAnnotationsMap; + private Map> textSourceAnnotationsMap; private PrintStream html; @@ -74,15 +76,19 @@ public class KnowtatorIaa { * Instantiates a new Knowtator iaa. * * @param outputDirectory the output directory - * @param model the model + * @param model the model * @throws IaaException the iaa exception */ @SuppressWarnings("unused") - public KnowtatorIaa(File outputDirectory, KnowtatorModel model, Collection textSources, Collection profiles) throws IaaException { + public KnowtatorIaa(File outputDirectory, KnowtatorModel model, + Collection textSources, + Collection profiles, + Collection owlClasses) throws IaaException { this.outputDirectory = outputDirectory; // this.filter = filter; + HashSet owlClasses1 = new HashSet<>(owlClasses); this.model = model; annotationTexts = new HashMap<>(); annotationTextNames = new HashMap<>(); @@ -93,7 +99,14 @@ public KnowtatorIaa(File outputDirectory, KnowtatorModel model, Collection model.getTextSources().get(id)) .filter(Optional::isPresent) .map(Optional::get) - .forEach(textSource -> textSourceAnnotationsMap.put(textSource, textSource.getConceptAnnotations())); + .forEach(textSource -> { + + Collection conceptAnnotations = textSource.getConceptAnnotations().stream() + .filter(conceptAnnotation -> owlClasses1.contains(conceptAnnotation.getOwlClass())) + .collect(Collectors.toList()); + + textSourceAnnotationsMap.put(textSource, conceptAnnotations); + }); initHtml(); } @@ -111,7 +124,9 @@ private void initHtml() throws IaaException { } } - /** Close html. */ + /** + * Close html. + */ public void closeHtml() { html.println(""); html.println(""); @@ -146,9 +161,9 @@ public void runClassIaa() throws IaaException { } private void runIaaWithMatcher(Matcher matcher, Iaa iaa) throws IaaException { - for (ConceptAnnotationCollection conceptAnnotationCollection : + for (Collection conceptAnnotationCollection : textSourceAnnotationsMap.values()) { - Set conceptAnnotations = conceptAnnotationCollection.getCollection(); + Set conceptAnnotations = new HashSet<>(conceptAnnotationCollection); iaa.setConceptAnnotations(conceptAnnotations); iaa.allwayIaa(matcher); iaa.pairwiseIaa(matcher); @@ -162,10 +177,10 @@ private void runIaaWithMatcher(Matcher matcher, Iaa iaa) throws IaaException { */ public void runSpanIaa() throws IaaException { - SpanMatcher spanMatcher = new SpanMatcher(); - Iaa spanIaa = new Iaa(setNames); + SpanMatcher spanMatcher = new SpanMatcher(); + Iaa spanIaa = new Iaa(setNames); - runIaaWithMatcher(spanMatcher, spanIaa); + runIaaWithMatcher(spanMatcher, spanIaa); try { SpanMatcherHtml.printIaa( spanIaa, @@ -178,7 +193,7 @@ public void runSpanIaa() throws IaaException { e.printStackTrace(); } html.printf( - "
  • %s
  • %n", + "
  • %s
  • %n", spanMatcher.getName(), spanMatcher.getName()); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form index 4827d1ed..ba73a2d7 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form @@ -77,40 +77,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -155,6 +121,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index 7f72087f..208ae639 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -27,6 +27,7 @@ import edu.ucdenver.ccp.knowtator.iaa.IaaException; import edu.ucdenver.ccp.knowtator.iaa.KnowtatorIaa; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; +import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.ModelObject; import java.awt.BorderLayout; import java.awt.GridBagConstraints; @@ -37,6 +38,8 @@ import java.awt.event.WindowEvent; import java.io.File; import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; import java.util.Set; @@ -71,8 +74,11 @@ public class IAAOptionsDialog extends JDialog { private JButton profilesSelectAllButton; private JTable profilesTable; private JTable documentsTable; + private JButton owlClassesSelectAllButton; + private JTable owlClassesTable; IAATableModel profilesTableModel; IAATableModel documentsTableModel; + IAATableModel owlClassesTableModel; public IAAOptionsDialog(Window parent, KnowtatorModel model, File outputDirectory) { super(parent); @@ -114,13 +120,23 @@ public void windowClosing(WindowEvent e) { profilesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); profilesTableModel = new IAATableModel( new Object[][] {}, - "Document", + "Profile", model.getProfiles().stream() .map(ModelObject::getId) .collect(Collectors.toList())); profilesTable.setModel(profilesTableModel); profilesSelectAllButton.addActionListener(e -> profilesTableModel.toggleAll()); + owlClassesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + owlClassesTableModel = new IAATableModel( + new Object[][] {}, + "OWL Classes", + new ArrayList<>(new HashSet<>(model.getTextSources().stream() + .flatMap(textSource -> textSource.getConceptAnnotations().stream() + .map(ConceptAnnotation::getOwlClass)) + .collect(Collectors.toSet())))); + owlClassesTable.setModel(owlClassesTableModel); + owlClassesSelectAllButton.addActionListener(e -> owlClassesTableModel.toggleAll()); } private static class IAATableModel extends DefaultTableModel { @@ -168,12 +184,13 @@ void toggleAll() { private void onOK() { Set profiles = profilesTableModel.getSelectedItems(); + Set owlClasses = owlClassesTableModel.getSelectedItems(); Set textSources = documentsTableModel.getSelectedItems(); if (profiles.size() <= 2 && !textSources.isEmpty() && (iaaClassCheckBox.isSelected() || iaaSpanCheckBox.isSelected() || iaaClassAndSpanCheckBox.isSelected())) { try { - KnowtatorIaa knowtatorIaa = new KnowtatorIaa(outputDirectory, model, textSources, profiles); + KnowtatorIaa knowtatorIaa = new KnowtatorIaa(outputDirectory, model, textSources, profiles, owlClasses); if (iaaClassCheckBox.isSelected()) { knowtatorIaa.runClassIaa(); @@ -251,19 +268,69 @@ private void onCancel() { documentsTable = new JTable(); scrollPane2.setViewportView(documentsTable); final JPanel panel3 = new JPanel(); - panel3.setLayout(new GridBagLayout()); + panel3.setLayout(new BorderLayout(0, 0)); gbc = new GridBagConstraints(); - gbc.gridx = 2; + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.BOTH; + contentPane.add(panel3, gbc); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridBagLayout()); + panel3.add(panel4, BorderLayout.NORTH); + panel4.setBorder(BorderFactory.createTitledBorder(null, "Mode", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + iaaClassCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(iaaClassCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.iaa")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + panel4.add(iaaClassCheckBox, gbc); + iaaSpanCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(iaaSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "span.iaa")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.anchor = GridBagConstraints.WEST; + panel4.add(iaaSpanCheckBox, gbc); + iaaClassAndSpanCheckBox = new JCheckBox(); + this.$$$loadButtonText$$$(iaaClassAndSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.and.span.iaa")); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 2; + gbc.anchor = GridBagConstraints.WEST; + panel4.add(iaaClassAndSpanCheckBox, gbc); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new BorderLayout(0, 0)); + gbc = new GridBagConstraints(); + gbc.gridx = 3; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.BOTH; + contentPane.add(panel5, gbc); + panel5.setBorder(BorderFactory.createTitledBorder(null, "OWL Classes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new BorderLayout(0, 0)); + panel5.add(panel6, BorderLayout.CENTER); + owlClassesSelectAllButton = new JButton(); + owlClassesSelectAllButton.setText("Select all"); + panel6.add(owlClassesSelectAllButton, BorderLayout.NORTH); + final JScrollPane scrollPane3 = new JScrollPane(); + panel6.add(scrollPane3, BorderLayout.CENTER); + owlClassesTable = new JTable(); + scrollPane3.setViewportView(owlClassesTable); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.gridx = 3; gbc.gridy = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel3, gbc); + contentPane.add(panel7, gbc); final JPanel spacer1 = new JPanel(); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel3.add(spacer1, gbc); + panel7.add(spacer1, gbc); buttonOK = new JButton(); this.$$$loadButtonText$$$(buttonOK, this.$$$getMessageFromBundle$$$("log4j", "ok")); gbc = new GridBagConstraints(); @@ -272,7 +339,7 @@ private void onCancel() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel3.add(buttonOK, gbc); + panel7.add(buttonOK, gbc); buttonCancel = new JButton(); this.$$$loadButtonText$$$(buttonCancel, this.$$$getMessageFromBundle$$$("log4j", "cancel")); gbc = new GridBagConstraints(); @@ -281,39 +348,7 @@ private void onCancel() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel3.add(buttonCancel, gbc); - final JPanel panel4 = new JPanel(); - panel4.setLayout(new BorderLayout(0, 0)); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel4, gbc); - final JPanel panel5 = new JPanel(); - panel5.setLayout(new GridBagLayout()); - panel4.add(panel5, BorderLayout.NORTH); - panel5.setBorder(BorderFactory.createTitledBorder(null, "Mode", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - iaaClassCheckBox = new JCheckBox(); - this.$$$loadButtonText$$$(iaaClassCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.iaa")); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.WEST; - panel5.add(iaaClassCheckBox, gbc); - iaaSpanCheckBox = new JCheckBox(); - this.$$$loadButtonText$$$(iaaSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "span.iaa")); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 1; - gbc.anchor = GridBagConstraints.WEST; - panel5.add(iaaSpanCheckBox, gbc); - iaaClassAndSpanCheckBox = new JCheckBox(); - this.$$$loadButtonText$$$(iaaClassAndSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.and.span.iaa")); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 2; - gbc.anchor = GridBagConstraints.WEST; - panel5.add(iaaClassAndSpanCheckBox, gbc); + panel7.add(buttonCancel, gbc); } private static Method $$$cachedGetBundleMethod$$$ = null; diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java index 4a9de957..3bf744d4 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java @@ -29,10 +29,12 @@ import edu.ucdenver.ccp.knowtator.iaa.KnowtatorIaa; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.collection.ProfileCollection; +import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.Profile; import edu.ucdenver.ccp.knowtator.model.object.TextSource; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.HashSet; import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; @@ -86,7 +88,11 @@ static void makeProjectTest() throws IaaException, IOException { model.getProfiles().stream() .map(Profile::getId) .filter(myProfiles::contains) - .collect(Collectors.toSet())); + .collect(Collectors.toSet()), + new ArrayList<>(new HashSet(model.getTextSources().stream() + .flatMap(textSource -> textSource.getConceptAnnotations().stream() + .map(ConceptAnnotation::getOwlClass)) + .collect(Collectors.toSet())))); } } From c953f9efbc2136f3d2cc2235504080ee7e3b18cd Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 17 Aug 2020 13:16:42 -0500 Subject: [PATCH 48/65] Made option to compare across projects for IAA. --- ...nford_protege_protege_common_5_0_0_RC1.xml | 13 --- ...felix_org_apache_felix_framework_4_4_1.xml | 13 --- ...ache_felix_org_apache_felix_main_4_4_1.xml | 13 --- .idea/workspace.xml | 91 ++++++++++++------- .../ccp/knowtator/model/BaseModel.java | 47 ++++++---- .../ccp/knowtator/model/KnowtatorModel.java | 10 +- .../ccp/knowtator/model/OwlModel.java | 4 +- .../knowtator/model/object/TextSource.java | 10 +- .../ccp/knowtator/view/KnowtatorView.java | 5 +- .../AbstractKnowtatorCollectionAction.java | 2 +- .../modelactions/TextSourceAction.java | 4 +- .../knowtator/view/iaa/IAAOptionsDialog.form | 11 ++- .../knowtator/view/iaa/IAAOptionsDialog.java | 48 +++++++++- .../knowtator/view/profile/ProfileDialog.java | 2 +- .../ccp/knowtator/KnowtatorIaaTest.java | 4 +- .../ccp/knowtator/ProjectManagerTest.java | 4 +- .../ccp/knowtator/TestingHelpers.java | 4 +- 17 files changed, 166 insertions(+), 119 deletions(-) delete mode 100644 .idea/libraries/Maven__edu_stanford_protege_protege_common_5_0_0_RC1.xml delete mode 100644 .idea/libraries/Maven__org_apache_felix_org_apache_felix_framework_4_4_1.xml delete mode 100644 .idea/libraries/Maven__org_apache_felix_org_apache_felix_main_4_4_1.xml diff --git a/.idea/libraries/Maven__edu_stanford_protege_protege_common_5_0_0_RC1.xml b/.idea/libraries/Maven__edu_stanford_protege_protege_common_5_0_0_RC1.xml deleted file mode 100644 index 847bd125..00000000 --- a/.idea/libraries/Maven__edu_stanford_protege_protege_common_5_0_0_RC1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_felix_org_apache_felix_framework_4_4_1.xml b/.idea/libraries/Maven__org_apache_felix_org_apache_felix_framework_4_4_1.xml deleted file mode 100644 index 568d2ce8..00000000 --- a/.idea/libraries/Maven__org_apache_felix_org_apache_felix_framework_4_4_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_apache_felix_org_apache_felix_main_4_4_1.xml b/.idea/libraries/Maven__org_apache_felix_org_apache_felix_main_4_4_1.xml deleted file mode 100644 index 045e14f3..00000000 --- a/.idea/libraries/Maven__org_apache_felix_org_apache_felix_main_4_4_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c6a9e5a9..9d72f2a2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,15 +32,24 @@ - + - + + + + + + + + + + - + @@ -152,6 +161,19 @@ + + + @@ -578,7 +607,6 @@ - @@ -603,7 +631,8 @@ - @@ -679,79 +708,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -798,28 +827,29 @@ - + - + - + + - + - + @@ -831,11 +861,6 @@ 175 diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java index 55299aa6..f6cb8410 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java @@ -56,12 +56,6 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa public static final HashSet DEFAULT_LAYERS = new HashSet<>(Collections.singletonList("Default")); private final File projectLocation; - private final File annotationsLocation; - private final File articlesLocation; - private final File profilesLocation; - - /** The Ontologies location. */ - final File ontologiesLocation; private final Set modelListeners; private final Map filters; @@ -119,14 +113,15 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa } this.projectLocation = projectLocation; - articlesLocation = new File(projectLocation, "Articles"); - annotationsLocation = new File(projectLocation, "Annotations"); - profilesLocation = (new File(projectLocation, "Profiles")); - ontologiesLocation = new File(projectLocation, "Ontologies"); - Files.createDirectories(articlesLocation.toPath()); - Files.createDirectories(annotationsLocation.toPath()); - Files.createDirectories(profilesLocation.toPath()); - Files.createDirectories(ontologiesLocation.toPath()); + + Files.createDirectories(getArticlesLocation(projectLocation).toPath()); + Files.createDirectories(getAnnotationsLocation(projectLocation).toPath()); + Files.createDirectories(getProfilesLocation(projectLocation).toPath()); + Files.createDirectories(getOntologiesLocation(projectLocation).toPath()); + } + + File getOntologiesLocation(File projectLocation) { + return new File(projectLocation, "Ontologies"); } @Override @@ -174,8 +169,9 @@ public int getNumberOfProfiles() { * * @return the annotations location */ - public File getAnnotationsLocation() { - return annotationsLocation; + public File getAnnotationsLocation(File projectLocation) { + return new File(projectLocation, "Annotations"); + } /** @@ -295,9 +291,10 @@ public void addProfile(Profile profile) { * Gets articles location. * * @return the articles location + * @param projectLocation project location */ - public File getArticlesLocation() { - return articlesLocation; + public File getArticlesLocation(File projectLocation) { + return new File(projectLocation, "Articles"); } /** @@ -321,9 +318,10 @@ public Optional getSelectedGraphSpace() { * Gets profiles location. * * @return the profiles location + * @param projectLocation project location */ - File getProfilesLocation() { - return profilesLocation; + File getProfilesLocation(File projectLocation) { + return new File(projectLocation, "Profiles"); } /** Dispose. */ @@ -429,4 +427,13 @@ public void addStructureModeListener(StructureModeListener listener) { public Set getActiveLayers() { return activeLayers; } + + public File getArticlesLocation(File annotationFileLocation, File projectLocation) { + File file = new File(annotationFileLocation.getParentFile(), "Articles"); + if (file.exists()) { + return file; + } else { + return getArticlesLocation(projectLocation); + } + } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index 2657f6dd..1e158d5a 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -90,8 +90,8 @@ public void save() { } @Override - public void load() { - super.load(); + public void load(File projectLocation) { + super.load(projectLocation); setLoading(true); @@ -101,12 +101,12 @@ public void load() { OldKnowtatorXmlUtil oldXmlUtil = new OldKnowtatorXmlUtil(); try { - Files.list(getProfilesLocation().toPath()) + Files.list(getProfilesLocation(projectLocation).toPath()) .filter(path -> path.toString().endsWith(".xml")) .map(Path::toFile) .forEach(file -> xmlUtil.readToProfileCollection(this, file)); - Files.list(getArticlesLocation().toPath()) + Files.list(getArticlesLocation(projectLocation).toPath()) .filter(path -> path.toString().endsWith(".txt")) .map(Path::toFile) .forEach( @@ -117,7 +117,7 @@ public void load() { log.info("Loading annotations"); OWLClassNotFoundAnnotations = new ArrayList<>(); - Files.list(getAnnotationsLocation().toPath()) + Files.list(getAnnotationsLocation(getProjectLocation()).toPath()) .filter(path -> path.toString().endsWith(".xml")) .map(Path::toFile) .peek(file -> xmlUtil.readToTextSourceCollection(this, file)) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java index 4a814b08..9bc8d333 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java @@ -287,10 +287,10 @@ public void searchForString(String stringToSearch) { /** * Load. */ - public void load() { + public void load(File projectLocation) { log.info("Loading ontologies"); try { - Files.list(ontologiesLocation.toPath()) + Files.list(getOntologiesLocation(projectLocation).toPath()) .filter(path -> path.toString().endsWith(".owl")) .map(path -> path.toFile().toURI().toString()) .forEach( diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java index 8d5b572c..76519166 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java @@ -69,7 +69,7 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { this.saveFile = saveFile == null ? new File( - model.getAnnotationsLocation().getAbsolutePath(), + model.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), textFileName.replace(".txt", ".xml")) : saveFile; this.conceptAnnotations = new ConceptAnnotationCollection(model, this); @@ -80,7 +80,7 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { textFile = new File( - model.getArticlesLocation(), + model.getArticlesLocation(this.saveFile, model.getProjectLocation()), textFileName.endsWith(".txt") ? textFileName : String.format("%s.txt", textFileName)); if (!textFile.exists()) { @@ -94,7 +94,7 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { textFile = Files.copy( Paths.get(file.toURI()), - Paths.get(model.getArticlesLocation().toURI().resolve(file.getName()))) + Paths.get(model.getArticlesLocation(model.getProjectLocation()).toURI().resolve(file.getName()))) .toFile(); } catch (IOException e) { e.printStackTrace(); @@ -159,7 +159,7 @@ public String getContent() { content = FileUtils.readFileToString(textFile, "UTF-8"); return content; } catch (IOException e) { - textFile = new File(model.getArticlesLocation(), String.format("%s.txt", id)); + textFile = new File(model.getArticlesLocation(model.getProjectLocation()), String.format("%s.txt", id)); while (!textFile.exists()) { JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { @@ -194,7 +194,7 @@ public void save() { * @return the save location */ public File getSaveLocation() { - return new File(model.getAnnotationsLocation().getAbsolutePath(), saveFile.getName()); + return new File(model.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), saveFile.getName()); } @Override diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java index 3a9ae1c9..d5df22f5 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java @@ -36,7 +36,6 @@ import edu.ucdenver.ccp.knowtator.model.FilterType; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.ModelListener; -import edu.ucdenver.ccp.knowtator.model.OwlModel; import edu.ucdenver.ccp.knowtator.model.collection.SelectableCollection; import edu.ucdenver.ccp.knowtator.model.collection.event.ChangeEvent; import edu.ucdenver.ccp.knowtator.model.object.GraphSpace; @@ -516,7 +515,7 @@ private void makeButtons() { getModel() .ifPresent( model1 -> { - fileChooser.setCurrentDirectory(model1.getArticlesLocation()); + fileChooser.setCurrentDirectory(model1.getArticlesLocation(model.getProjectLocation())); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { pickAction( @@ -897,7 +896,7 @@ public void loadProject(File file, ModelListener progressListener) throws IOExce getModel().ifPresent(model1 -> model1.addModelListener(progressListener)); } log.info(String.format("Opening from %s", file.getAbsolutePath())); - getModel().ifPresent(OwlModel::load); + getModel().ifPresent(owlModel -> owlModel.load(owlModel.getProjectLocation())); if (progressListener != null) { getModel().ifPresent(model1 -> model1.removeModelListener(progressListener)); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java index 7163dba7..f349ace9 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java @@ -261,7 +261,7 @@ public static void pickAction( if (actionType.equals(CollectionActionType.ADD)) { JOptionPane.showMessageDialog(view, "Select annotation file"); JFileChooser fileChooser = new JFileChooser(); - fileChooser.setCurrentDirectory(model.getAnnotationsLocation()); + fileChooser.setCurrentDirectory(model.getAnnotationsLocation(model.getProjectLocation())); if (fileChooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java index 75c53134..809e3282 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java @@ -55,9 +55,9 @@ public TextSourceAction( @Override protected void prepareAdd() { - if (!file.getParentFile().equals(model.getArticlesLocation())) { + if (!file.getParentFile().equals(model.getArticlesLocation(model.getProjectLocation()))) { try { - FileUtils.copyFile(file, new File(model.getArticlesLocation(), file.getName())); + FileUtils.copyFile(file, new File(model.getArticlesLocation(model.getProjectLocation()), file.getName())); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form index ba73a2d7..eac49b34 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form @@ -2,7 +2,7 @@
    - + @@ -189,6 +189,15 @@ + + + + + + + + +
    diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index 208ae639..983347ff 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -29,6 +29,7 @@ import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.ModelObject; +import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -37,10 +38,13 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; +import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.ResourceBundle; import java.util.Set; import java.util.stream.Collectors; @@ -51,6 +55,7 @@ import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JDialog; +import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; @@ -76,11 +81,12 @@ public class IAAOptionsDialog extends JDialog { private JTable documentsTable; private JButton owlClassesSelectAllButton; private JTable owlClassesTable; + private JButton compareAcrossProjectsButton; IAATableModel profilesTableModel; IAATableModel documentsTableModel; IAATableModel owlClassesTableModel; - public IAAOptionsDialog(Window parent, KnowtatorModel model, File outputDirectory) { + public IAAOptionsDialog(Window parent, KnowtatorModel model, KnowtatorView view, File outputDirectory) { super(parent); this.outputDirectory = outputDirectory; this.model = model; @@ -137,6 +143,39 @@ public void windowClosing(WindowEvent e) { .collect(Collectors.toSet())))); owlClassesTable.setModel(owlClassesTableModel); owlClassesSelectAllButton.addActionListener(e -> owlClassesTableModel.toggleAll()); + + compareAcrossProjectsButton.addActionListener(e -> { + JFileChooser fileChooser = new JFileChooser(); + Optional.ofNullable(KnowtatorView.PREFERENCES.get("Last Project", null)) + .map(File::new) + .filter(File::exists) + .map( + file -> { + fileChooser.setCurrentDirectory(file); + return file; + }) + .map(File::listFiles) + .flatMap( + files -> + Arrays.stream(files) + .filter(file1 -> file1.getName().endsWith(".knowtator")) + .findAny()) + .ifPresent(fileChooser::setSelectedFile); + fileChooser.addActionListener( + e1 -> + Optional.ofNullable(e1) + .filter( + event -> event.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) + .ifPresent(event -> { + try { + KnowtatorModel model2 = new KnowtatorModel(fileChooser.getSelectedFile(), view.getOWLWorkspace()); + model2.load(model2.getProjectLocation()); + model2.load(model.getProjectLocation()); + } catch (IOException ioException) { + ioException.printStackTrace(); + } + })); + }); } private static class IAATableModel extends DefaultTableModel { @@ -349,6 +388,13 @@ private void onCancel() { gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; panel7.add(buttonCancel, gbc); + compareAcrossProjectsButton = new JButton(); + compareAcrossProjectsButton.setText("Compare across projects"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 1; + gbc.fill = GridBagConstraints.HORIZONTAL; + contentPane.add(compareAcrossProjectsButton, gbc); } private static Method $$$cachedGetBundleMethod$$$ = null; diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java index 7ab5ebed..0a74816d 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java @@ -127,7 +127,7 @@ public ProfileDialog(Window parent, KnowtatorView view) { } catch (IOException ioException) { ioException.printStackTrace(); } - JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model, outputDirectory); + JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model, view, outputDirectory); iaaDialog.pack(); iaaDialog.setVisible(true); } diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java index 3bf744d4..1eacd872 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/KnowtatorIaaTest.java @@ -66,7 +66,7 @@ static void makeProjectTest() throws IaaException, IOException { FileUtils.copyDirectory(projectDirectory, tempProjectDir); model = new KnowtatorModel(tempProjectDir, null); - model.load(); + model.load(model.getProjectLocation()); goldStandardDir = new File(model.getProjectLocation(), "iaa"); @@ -89,7 +89,7 @@ static void makeProjectTest() throws IaaException, IOException { .map(Profile::getId) .filter(myProfiles::contains) .collect(Collectors.toSet()), - new ArrayList<>(new HashSet(model.getTextSources().stream() + new ArrayList<>(new HashSet<>(model.getTextSources().stream() .flatMap(textSource -> textSource.getConceptAnnotations().stream() .map(ConceptAnnotation::getOwlClass)) .collect(Collectors.toSet())))); diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java index e3eb0035..21a5841c 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java @@ -52,7 +52,7 @@ class ProjectManagerTest { @Test void loadProjectTest() { TestingHelpers.checkDefaultCollectionValues(model); - model.load(); + model.load(model.getProjectLocation()); } private static List fileToLines(File file) { @@ -74,7 +74,7 @@ void saveProjectTest() { TestingHelpers.checkDefaultCollectionValues(model); model.save(); TestingHelpers.checkDefaultCollectionValues(model); - File file1 = new File(model.getAnnotationsLocation(), "document1.xml"); + File file1 = new File(model.getAnnotationsLocation(model.getProjectLocation()), "document1.xml"); File referenceFile = new File( TestingHelpers.class diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java index f75a79c0..ca2801ab 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java @@ -107,7 +107,7 @@ public static KnowtatorModel getLoadedModel() throws IOException { File tempProjectDir = Files.createTempDir(); FileUtils.copyDirectory(projectDirectory, tempProjectDir); KnowtatorModel model = new KnowtatorModel(tempProjectDir, null); - model.load(); + model.load(model.getProjectLocation()); return model; } @@ -123,7 +123,7 @@ public static KnowtatorModel getLoadedModel(String projectFileName) throws IOExc File tempProjectDir = Files.createTempDir(); FileUtils.copyDirectory(projectDirectory, tempProjectDir); KnowtatorModel model = new KnowtatorModel(tempProjectDir, null); - model.load(); + model.load(model.getProjectLocation()); return model; } From 21d43ee01cf14a9b3ad47084a977b131b90f4b97 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 17 Aug 2020 13:20:51 -0500 Subject: [PATCH 49/65] Made folder location access static. --- .idea/workspace.xml | 57 +++++++++---------- .../ccp/knowtator/model/BaseModel.java | 8 +-- .../knowtator/model/object/TextSource.java | 7 ++- .../ccp/knowtator/view/KnowtatorView.java | 2 +- .../modelactions/TextSourceAction.java | 5 +- 5 files changed, 38 insertions(+), 41 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9d72f2a2..42eb4f2d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,24 +32,11 @@ - - - - - + - - - - - - - - - @@ -607,8 +601,6 @@ - - @@ -632,7 +624,9 @@ - @@ -694,9 +688,10 @@ - - + + + @@ -708,43 +703,43 @@ - + - + - + - + - + - + - + - + @@ -827,11 +822,11 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java index f6cb8410..ae1152ed 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java @@ -120,7 +120,7 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa Files.createDirectories(getOntologiesLocation(projectLocation).toPath()); } - File getOntologiesLocation(File projectLocation) { + public static File getOntologiesLocation(File projectLocation) { return new File(projectLocation, "Ontologies"); } @@ -293,7 +293,7 @@ public void addProfile(Profile profile) { * @return the articles location * @param projectLocation project location */ - public File getArticlesLocation(File projectLocation) { + public static File getArticlesLocation(File projectLocation) { return new File(projectLocation, "Articles"); } @@ -320,7 +320,7 @@ public Optional getSelectedGraphSpace() { * @return the profiles location * @param projectLocation project location */ - File getProfilesLocation(File projectLocation) { + public static File getProfilesLocation(File projectLocation) { return new File(projectLocation, "Profiles"); } @@ -428,7 +428,7 @@ public Set getActiveLayers() { return activeLayers; } - public File getArticlesLocation(File annotationFileLocation, File projectLocation) { + public static File getArticlesLocation(File annotationFileLocation, File projectLocation) { File file = new File(annotationFileLocation.getParentFile(), "Articles"); if (file.exists()) { return file; diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java index 76519166..1841a4f5 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java @@ -25,6 +25,7 @@ package edu.ucdenver.ccp.knowtator.model.object; import edu.ucdenver.ccp.knowtator.io.knowtator.KnowtatorXmlUtil; +import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.ModelListener; import edu.ucdenver.ccp.knowtator.model.Savable; @@ -80,7 +81,7 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { textFile = new File( - model.getArticlesLocation(this.saveFile, model.getProjectLocation()), + BaseModel.getArticlesLocation(this.saveFile, model.getProjectLocation()), textFileName.endsWith(".txt") ? textFileName : String.format("%s.txt", textFileName)); if (!textFile.exists()) { @@ -94,7 +95,7 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { textFile = Files.copy( Paths.get(file.toURI()), - Paths.get(model.getArticlesLocation(model.getProjectLocation()).toURI().resolve(file.getName()))) + Paths.get(BaseModel.getArticlesLocation(model.getProjectLocation()).toURI().resolve(file.getName()))) .toFile(); } catch (IOException e) { e.printStackTrace(); @@ -159,7 +160,7 @@ public String getContent() { content = FileUtils.readFileToString(textFile, "UTF-8"); return content; } catch (IOException e) { - textFile = new File(model.getArticlesLocation(model.getProjectLocation()), String.format("%s.txt", id)); + textFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()), String.format("%s.txt", id)); while (!textFile.exists()) { JFileChooser fileChooser = new JFileChooser(); if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java index d5df22f5..7e5c341e 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/KnowtatorView.java @@ -515,7 +515,7 @@ private void makeButtons() { getModel() .ifPresent( model1 -> { - fileChooser.setCurrentDirectory(model1.getArticlesLocation(model.getProjectLocation())); + fileChooser.setCurrentDirectory(BaseModel.getArticlesLocation(model.getProjectLocation())); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { pickAction( diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java index 809e3282..6a5a2296 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java @@ -25,6 +25,7 @@ package edu.ucdenver.ccp.knowtator.view.actions.modelactions; import edu.ucdenver.ccp.knowtator.io.knowtator.KnowtatorXmlUtil; +import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.object.TextSource; import edu.ucdenver.ccp.knowtator.view.actions.collection.AbstractKnowtatorCollectionAction; @@ -55,9 +56,9 @@ public TextSourceAction( @Override protected void prepareAdd() { - if (!file.getParentFile().equals(model.getArticlesLocation(model.getProjectLocation()))) { + if (!file.getParentFile().equals(BaseModel.getArticlesLocation(model.getProjectLocation()))) { try { - FileUtils.copyFile(file, new File(model.getArticlesLocation(model.getProjectLocation()), file.getName())); + FileUtils.copyFile(file, new File(BaseModel.getArticlesLocation(model.getProjectLocation()), file.getName())); } catch (IOException e) { e.printStackTrace(); } From 83f7c232b7f03a84157b9ad902e4ba90f1a2f0f8 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 17 Aug 2020 18:19:29 -0500 Subject: [PATCH 50/65] Simplified adding of text sources to be just about the file chosen (txt vs. xml). --- .idea/workspace.xml | 116 ++++++++++-------- .../ccp/knowtator/model/BaseModel.java | 24 ++-- .../ccp/knowtator/model/KnowtatorModel.java | 2 +- .../knowtator/model/object/TextSource.java | 38 +++--- .../modelactions/TextSourceAction.java | 2 +- .../knowtator/view/iaa/IAAOptionsDialog.java | 14 +++ .../knowtator/view/profile/ProfileDialog.java | 1 + .../ccp/knowtator/ProjectManagerTest.java | 35 ++++-- .../iaa_test_project/Profiles/Default.xml | 8 ++ 9 files changed, 154 insertions(+), 86 deletions(-) create mode 100644 src/test/resources/iaa_test_project/Profiles/Default.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 42eb4f2d..7e1bd012 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -33,10 +33,15 @@ + + + - + + + - + @@ -148,15 +156,13 @@ - + - - + - - - + - - - + - - @@ -326,7 +332,8 @@ - + + 1590645202357 @@ -552,7 +559,14 @@ - @@ -682,10 +696,11 @@ - + + @@ -703,79 +718,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -822,11 +837,11 @@ - + - + @@ -856,6 +871,11 @@ 175 diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java index ae1152ed..ff39b555 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java @@ -95,13 +95,7 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa selection = new Selection(0, 0); - if (projectLocation.isFile()) { - if (projectLocation.getName().endsWith(".knowtator")) { - projectLocation = new File(projectLocation.getParent()); - } else { - throw new IOException(); - } - } + this.projectLocation = validateProjectLocation(projectLocation); Files.createDirectories(projectLocation.toPath()); @@ -112,14 +106,24 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa .toPath()); } - this.projectLocation = projectLocation; - Files.createDirectories(getArticlesLocation(projectLocation).toPath()); Files.createDirectories(getAnnotationsLocation(projectLocation).toPath()); Files.createDirectories(getProfilesLocation(projectLocation).toPath()); Files.createDirectories(getOntologiesLocation(projectLocation).toPath()); } + public static File validateProjectLocation(File projectLocation) throws IOException { + if (projectLocation.isFile()) { + if (projectLocation.getName().endsWith(".knowtator")) { + return new File(projectLocation.getParent()); + } else { + throw new IOException(); + } + } else { + return projectLocation; + } + } + public static File getOntologiesLocation(File projectLocation) { return new File(projectLocation, "Ontologies"); } @@ -169,7 +173,7 @@ public int getNumberOfProfiles() { * * @return the annotations location */ - public File getAnnotationsLocation(File projectLocation) { + public static File getAnnotationsLocation(File projectLocation) { return new File(projectLocation, "Annotations"); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index 1e158d5a..6313213f 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -111,7 +111,7 @@ public void load(File projectLocation) { .map(Path::toFile) .forEach( file -> { - TextSource newTextSource = new TextSource(this, null, file.getName()); + TextSource newTextSource = new TextSource(this, file, null); textSources.add(newTextSource); }); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java index 1841a4f5..3946bc82 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java @@ -62,27 +62,29 @@ public class TextSource implements ModelObject, Savable, ModelListen * Instantiates a new Text source. * * @param model the model - * @param saveFile the save file - * @param textFileName the text file name + * @param file save file or source text file */ - public TextSource(KnowtatorModel model, File saveFile, String textFileName) { + public TextSource(KnowtatorModel model, File file, String textSourceName) { this.model = model; - this.saveFile = - saveFile == null - ? new File( - model.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), - textFileName.replace(".txt", ".xml")) - : saveFile; + if (file.getName().endsWith(".txt")) { + this.saveFile = new File(BaseModel.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), + file.getName().replace(".txt", ".xml")); + this.textFile = file; + } else if (file.getName().endsWith(".xml")) { + this.saveFile = file; + this.textFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), + textSourceName == null ? file.getName().replace(".xml", ".txt") : textSourceName.endsWith(".txt") ? textSourceName : textSourceName.concat(".txt")); + } else { + this.saveFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), + file.getName().concat(".xml")); + this.textFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), + file.getName().concat(".txt")); + } this.conceptAnnotations = new ConceptAnnotationCollection(model, this); this.graphSpaces = new GraphSpaceCollection(model); model.addModelListener(this); - this.id = model.verifyId(FilenameUtils.getBaseName(textFileName), this, true); - - textFile = - new File( - BaseModel.getArticlesLocation(this.saveFile, model.getProjectLocation()), - textFileName.endsWith(".txt") ? textFileName : String.format("%s.txt", textFileName)); + this.id = model.verifyId(FilenameUtils.getBaseName(this.textFile.getName().replace(".txt", "")), this, true); if (!textFile.exists()) { JFileChooser fileChooser = new JFileChooser(); @@ -90,12 +92,12 @@ public TextSource(KnowtatorModel model, File saveFile, String textFileName) { String.format("Could not find file for %s. Choose file location", id)); if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = fileChooser.getSelectedFile(); + File file1 = fileChooser.getSelectedFile(); try { textFile = Files.copy( Paths.get(file.toURI()), - Paths.get(BaseModel.getArticlesLocation(model.getProjectLocation()).toURI().resolve(file.getName()))) + Paths.get(BaseModel.getArticlesLocation(model.getProjectLocation()).toURI().resolve(file1.getName()))) .toFile(); } catch (IOException e) { e.printStackTrace(); @@ -195,7 +197,7 @@ public void save() { * @return the save location */ public File getSaveLocation() { - return new File(model.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), saveFile.getName()); + return new File(BaseModel.getAnnotationsLocation(model.getProjectLocation()).getAbsolutePath(), saveFile.getName()); } @Override diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java index 6a5a2296..56ce81e3 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/modelactions/TextSourceAction.java @@ -63,7 +63,7 @@ protected void prepareAdd() { e.printStackTrace(); } } - setObject(new TextSource(model, file, file.getName())); + setObject(new TextSource(model, file, null)); } @Override diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index 983347ff..280ebc07 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -56,12 +56,15 @@ import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFileChooser; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; public class IAAOptionsDialog extends JDialog { @@ -171,10 +174,21 @@ public void windowClosing(WindowEvent e) { KnowtatorModel model2 = new KnowtatorModel(fileChooser.getSelectedFile(), view.getOWLWorkspace()); model2.load(model2.getProjectLocation()); model2.load(model.getProjectLocation()); + + JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model2, view, outputDirectory); + iaaDialog.pack(); + iaaDialog.setVisible(true); + this.onCancel(); } catch (IOException ioException) { ioException.printStackTrace(); } })); + + FileFilter fileFilter = new FileNameExtensionFilter("Knowtator", "knowtator"); + fileChooser.setFileFilter(fileFilter); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + + fileChooser.showOpenDialog(view); }); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java index 0a74816d..b6399b23 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/profile/ProfileDialog.java @@ -127,6 +127,7 @@ public ProfileDialog(Window parent, KnowtatorView view) { } catch (IOException ioException) { ioException.printStackTrace(); } + this.onCancel(); JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model, view, outputDirectory); iaaDialog.pack(); iaaDialog.setVisible(true); diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java index 21a5841c..4e9da88c 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java @@ -27,6 +27,7 @@ import difflib.Delta; import difflib.DiffUtils; import difflib.Patch; +import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import java.io.BufferedReader; import java.io.File; @@ -34,6 +35,7 @@ import java.io.IOException; import java.util.LinkedList; import java.util.List; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @SuppressWarnings("EmptyMethod") @@ -41,12 +43,9 @@ class ProjectManagerTest { private static KnowtatorModel model; - static { - try { - model = TestingHelpers.getLoadedModel(); - } catch (IOException e) { - e.printStackTrace(); - } + @BeforeEach + void setup() throws IOException { + model = TestingHelpers.getLoadedModel(); } @Test @@ -74,7 +73,7 @@ void saveProjectTest() { TestingHelpers.checkDefaultCollectionValues(model); model.save(); TestingHelpers.checkDefaultCollectionValues(model); - File file1 = new File(model.getAnnotationsLocation(model.getProjectLocation()), "document1.xml"); + File file1 = new File(BaseModel.getAnnotationsLocation(model.getProjectLocation()), "document1.xml"); File referenceFile = new File( TestingHelpers.class @@ -103,7 +102,27 @@ void newProjectTest() {} void importToManagerTest() {} @Test - void importProjectTest() {} + void importProjectTest() throws IOException { + TestingHelpers.checkDefaultCollectionValues(model); + String projectName = "iaa_test_project"; + File projectFile = new File( + TestingHelpers.class + .getResource(String.format("/%s/%s.knowtator", projectName, projectName)) + .getFile()); + projectFile = BaseModel.validateProjectLocation(projectFile); + model.load(projectFile); + TestingHelpers.countCollections(model, + TestingHelpers.defaultExpectedTextSources, + TestingHelpers.defaultExpectedConceptAnnotations, + TestingHelpers.defaultExpectedSpans, + TestingHelpers.defaultExpectedGraphSpaces, + TestingHelpers.defaultExpectedProfiles, + TestingHelpers.defaultExpectedHighlighters, + TestingHelpers.defaultExpectedAnnotationNodes, + TestingHelpers.defaultExpectedTriples, + TestingHelpers.defaultExpectedStructureAnnotations); + + } @SuppressWarnings("EmptyMethod") @Test diff --git a/src/test/resources/iaa_test_project/Profiles/Default.xml b/src/test/resources/iaa_test_project/Profiles/Default.xml new file mode 100644 index 00000000..fdbbfd68 --- /dev/null +++ b/src/test/resources/iaa_test_project/Profiles/Default.xml @@ -0,0 +1,8 @@ + + + + + + + + From 66e4f28b71c3e6951cc56811996e6089a900c5a2 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 15:11:11 -0500 Subject: [PATCH 51/65] Generalized adding annotation node and made creating annotation node a default node. --- .../ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java | 4 +--- .../ucdenver/ccp/knowtator/model/object/GraphSpace.java | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java index c8271fbe..080117a4 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/io/knowtator/KnowtatorXmlUtil.java @@ -254,9 +254,7 @@ private void readToGraphSpace(GraphSpace graphSpace, Element parent) { Optional conceptAnnotation = graphSpace.getTextSource().getAnnotation(annotationID); if (conceptAnnotation.isPresent()) { - AnnotationNode newVertex = - new AnnotationNode(id, conceptAnnotation.get(), x, y, graphSpace); - graphSpace.addCellToGraph(newVertex); + graphSpace.addAnnotationNode(id, conceptAnnotation.get(), x, y); } else { log.info(String.format("Annotation could not be found %s", annotationID)); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java index f25cd11d..413c1dbd 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java @@ -279,10 +279,13 @@ public AnnotationNode getAnnotationNodeForConceptAnnotation(ConceptAnnotation co * @return the annotation node */ public AnnotationNode makeAnnotationNode(ConceptAnnotation conceptAnnotation) { - // String nodeId = textSource.getGraphSpaces().verifyID(null, "node"); - AnnotationNode newVertex = new AnnotationNode(null, conceptAnnotation, 20, 20, this); + return addAnnotationNode(null, conceptAnnotation, 20, 20); + } + + public AnnotationNode addAnnotationNode(String id, ConceptAnnotation conceptAnnotation, double x, double y) { + AnnotationNode newVertex = new AnnotationNode(id, conceptAnnotation, x, y, this); addCellToGraph(newVertex); - return newVertex; // (AnnotationNode) ((mxGraphModel) getModel()).getCells().get(nodeId); + return newVertex; } @Override From 8238fb4328db8a8d1d9f53c498427ab4c2225458 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 15:11:42 -0500 Subject: [PATCH 52/65] Fixed annotations not using provided project location. --- .../java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index 6313213f..0da797f9 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -117,7 +117,7 @@ public void load(File projectLocation) { log.info("Loading annotations"); OWLClassNotFoundAnnotations = new ArrayList<>(); - Files.list(getAnnotationsLocation(getProjectLocation()).toPath()) + Files.list(getAnnotationsLocation(projectLocation).toPath()) .filter(path -> path.toString().endsWith(".xml")) .map(Path::toFile) .peek(file -> xmlUtil.readToTextSourceCollection(this, file)) From be0d6362c48f2c1b7308a08050937d13dce6e11a Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 15:12:05 -0500 Subject: [PATCH 53/65] Adding document tries to find file's project articles before using model's project articles. --- .idea/workspace.xml | 86 ++++++++++++------- .../knowtator/model/object/TextSource.java | 8 +- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 7e1bd012..ad615647 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,16 +32,14 @@ - - + - + + - - - + - + @@ -299,10 +297,10 @@ + - @@ -333,7 +331,7 @@ - + 1590645202357 @@ -566,7 +564,14 @@ - @@ -615,7 +620,6 @@ - @@ -640,7 +644,8 @@ - @@ -718,79 +723,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -820,6 +825,10 @@ + + + + @@ -837,11 +846,11 @@ - + - + @@ -873,9 +882,24 @@ file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java - 89 + 93 + + file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/graph/GraphActions.java + 86 + + + file://$PROJECT_DIR$/src/main/java/edu/ucdenver/ccp/knowtator/model/object/GraphSpace.java + 285 + + + file://$PROJECT_DIR$/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java + 244 + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java index 3946bc82..a66c7ece 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/object/TextSource.java @@ -72,8 +72,12 @@ public TextSource(KnowtatorModel model, File file, String textSourceName) { this.textFile = file; } else if (file.getName().endsWith(".xml")) { this.saveFile = file; - this.textFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), - textSourceName == null ? file.getName().replace(".xml", ".txt") : textSourceName.endsWith(".txt") ? textSourceName : textSourceName.concat(".txt")); + String textFileName = textSourceName == null ? file.getName().replace(".xml", ".txt") : textSourceName.endsWith(".txt") ? textSourceName : textSourceName.concat(".txt"); + this.textFile = new File(BaseModel.getArticlesLocation(file.getParentFile().getParentFile()).getAbsolutePath(), textFileName); + if (!this.textFile.exists()) { + this.textFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), textFileName); + } + } else { this.saveFile = new File(BaseModel.getArticlesLocation(model.getProjectLocation()).getAbsolutePath(), file.getName().concat(".xml")); From 298da039e337edc467601ecda033f2e1f4df6e1e Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 15:30:51 -0500 Subject: [PATCH 54/65] Set updated values for after importing second project. --- .../edu/ucdenver/ccp/knowtator/ProjectManagerTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java index 4e9da88c..94ad51ad 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/ProjectManagerTest.java @@ -112,11 +112,11 @@ void importProjectTest() throws IOException { projectFile = BaseModel.validateProjectLocation(projectFile); model.load(projectFile); TestingHelpers.countCollections(model, - TestingHelpers.defaultExpectedTextSources, - TestingHelpers.defaultExpectedConceptAnnotations, - TestingHelpers.defaultExpectedSpans, - TestingHelpers.defaultExpectedGraphSpaces, - TestingHelpers.defaultExpectedProfiles, + TestingHelpers.defaultExpectedTextSources + 4, + TestingHelpers.defaultExpectedConceptAnnotations + 456, + TestingHelpers.defaultExpectedSpans + 456, + TestingHelpers.defaultExpectedGraphSpaces + 4, + TestingHelpers.defaultExpectedProfiles + 2, TestingHelpers.defaultExpectedHighlighters, TestingHelpers.defaultExpectedAnnotationNodes, TestingHelpers.defaultExpectedTriples, From d04e1159c13b25a7ad056d7c435bd348d8053f50 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 15:31:28 -0500 Subject: [PATCH 55/65] Collapsed project value assertions to form a single error message. --- .idea/workspace.xml | 53 +++++------ .../ccp/knowtator/TestingHelpers.java | 91 ++++++++++++------- 2 files changed, 82 insertions(+), 62 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index ad615647..76ed467e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -34,10 +34,6 @@ - - - - @@ -331,7 +327,7 @@ - + 1590645202357 @@ -723,79 +719,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -846,11 +842,11 @@ - + - + @@ -891,14 +887,9 @@ - + + @@ -719,79 +722,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -813,6 +816,10 @@ + + + + @@ -842,11 +849,11 @@ - + - + @@ -860,11 +867,11 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java index 9bc8d333..e575bc83 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/OwlModel.java @@ -479,4 +479,8 @@ void resetRendering() { owlWorkspace.getOWLModelManager().refreshRenderer(); }); } + + public void removeOwlSelectionModelListener(OWLSelectionModelListener listener) { + owlWorkSpace.ifPresent(owlWorkSpace -> owlWorkSpace.getOWLSelectionModel().removeListener(listener)); + } } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form index eac49b34..90c5d323 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form @@ -2,7 +2,7 @@
    - + @@ -145,7 +145,7 @@ - + @@ -153,6 +153,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index 280ebc07..fc59f423 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -29,6 +29,7 @@ import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.ModelObject; +import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.awt.BorderLayout; import java.awt.GridBagConstraints; @@ -66,8 +67,10 @@ import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; +import org.protege.editor.owl.model.selection.OWLSelectionModelListener; -public class IAAOptionsDialog extends JDialog { +public class IAAOptionsDialog extends JDialog implements KnowtatorComponent { + private final KnowtatorView view; private JPanel contentPane; private JButton buttonOK; private JButton buttonCancel; @@ -83,8 +86,10 @@ public class IAAOptionsDialog extends JDialog { private JTable profilesTable; private JTable documentsTable; private JButton owlClassesSelectAllButton; - private JTable owlClassesTable; + private OWLClassesTable owlClassesTable; private JButton compareAcrossProjectsButton; + private JButton chooseFromHierarchyButton; + private JCheckBox includeSubclassesCheckBox; IAATableModel profilesTableModel; IAATableModel documentsTableModel; IAATableModel owlClassesTableModel; @@ -93,6 +98,7 @@ public IAAOptionsDialog(Window parent, KnowtatorModel model, KnowtatorView view, super(parent); this.outputDirectory = outputDirectory; this.model = model; + this.view = view; $$$setupUI$$$(); setContentPane(contentPane); @@ -190,6 +196,54 @@ public void windowClosing(WindowEvent e) { fileChooser.showOpenDialog(view); }); + + reset(); + } + + private void createUIComponents() { + // TODO: place custom component creation code here + owlClassesTable = new OWLClassesTable(model, view); + } + + private static class OWLClassesTable extends JTable implements KnowtatorComponent, OWLSelectionModelListener { + + private final KnowtatorModel model; + private final KnowtatorView view; + + public OWLClassesTable(KnowtatorModel model, KnowtatorView view) { + super(); + this.model = model; + this.view = view; + } + + @Override + public void selectionChanged() throws Exception { + Optional owlClassOptional = model.getSelectedOwlClass(); + + owlClassOptional.ifPresent(owlClass -> { + int i = -1; + for (int j = 0; j < getModel().getRowCount(); j++) { + if (getValueAt(0, j).equals(owlClass)) { + break; + } + i++; + } + + if (-1 < i) { + scrollRectToVisible(getCellRect(i, i, true)); + } + }); + } + + @Override + public void reset() { + view.getModel().ifPresent(model -> model.addOwlSelectionModelListener(this)); + } + + @Override + public void dispose() { + view.getModel().ifPresent(model -> model.removeOwlSelectionModelListener(this)); + } } private static class IAATableModel extends DefaultTableModel { @@ -268,6 +322,17 @@ private void onCancel() { dispose(); } + @Override + public void reset() { + view.knowtatorComponents.add(owlClassesTable); + } + + @Override + public void dispose() { + view.knowtatorComponents.remove(owlClassesTable); + super.dispose(); + } + /** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< @@ -276,6 +341,7 @@ private void onCancel() { * @noinspection ALL */ private void $$$setupUI$$$() { + createUIComponents(); contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); final JPanel panel1 = new JPanel(); @@ -368,22 +434,38 @@ private void onCancel() { panel6.add(owlClassesSelectAllButton, BorderLayout.NORTH); final JScrollPane scrollPane3 = new JScrollPane(); panel6.add(scrollPane3, BorderLayout.CENTER); - owlClassesTable = new JTable(); scrollPane3.setViewportView(owlClassesTable); final JPanel panel7 = new JPanel(); panel7.setLayout(new GridBagLayout()); + panel5.add(panel7, BorderLayout.SOUTH); + chooseFromHierarchyButton = new JButton(); + chooseFromHierarchyButton.setText("Choose from hierarchy"); + gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + panel7.add(chooseFromHierarchyButton, gbc); + includeSubclassesCheckBox = new JCheckBox(); + includeSubclassesCheckBox.setText("Include subclasses"); + gbc = new GridBagConstraints(); + gbc.gridx = 1; + gbc.gridy = 0; + gbc.anchor = GridBagConstraints.WEST; + panel7.add(includeSubclassesCheckBox, gbc); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); gbc.gridx = 3; gbc.gridy = 1; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel7, gbc); + contentPane.add(panel8, gbc); final JPanel spacer1 = new JPanel(); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel7.add(spacer1, gbc); + panel8.add(spacer1, gbc); buttonOK = new JButton(); this.$$$loadButtonText$$$(buttonOK, this.$$$getMessageFromBundle$$$("log4j", "ok")); gbc = new GridBagConstraints(); @@ -392,7 +474,7 @@ private void onCancel() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel7.add(buttonOK, gbc); + panel8.add(buttonOK, gbc); buttonCancel = new JButton(); this.$$$loadButtonText$$$(buttonCancel, this.$$$getMessageFromBundle$$$("log4j", "cancel")); gbc = new GridBagConstraints(); @@ -401,7 +483,7 @@ private void onCancel() { gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel7.add(buttonCancel, gbc); + panel8.add(buttonCancel, gbc); compareAcrossProjectsButton = new JButton(); compareAcrossProjectsButton.setText("Compare across projects"); gbc = new GridBagConstraints(); diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java index 1f9c1c94..23d6972f 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/list/ColorList.java @@ -79,12 +79,14 @@ private void setCollection() { @Override public void reset() { view.getModel().ifPresent(model -> model.addModelListener(this)); + view.getModel().ifPresent(model -> model.addOwlSelectionModelListener(this)); setCollection(); } @Override public void dispose() { view.getModel().ifPresent(model -> model.removeModelListener(this)); + view.getModel().ifPresent(model -> model.removeOwlSelectionModelListener(this)); setModel(new DefaultListModel<>()); } From 2ddb4ba4be2b5031bf166f790bd54e22ae96ee71 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 17:41:45 -0500 Subject: [PATCH 57/65] Fixed directory creation (or not creation). --- .../ucdenver/ccp/knowtator/model/BaseModel.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java index ff39b555..7cd9b550 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/BaseModel.java @@ -97,19 +97,20 @@ public abstract class BaseModel extends UndoManager implements CaretListener, Sa this.projectLocation = validateProjectLocation(projectLocation); - Files.createDirectories(projectLocation.toPath()); - - if (Files.list(projectLocation.toPath()) + if (!this.projectLocation.exists()) { + Files.createDirectories(projectLocation.toPath()); + } + if (Files.list(this.projectLocation.toPath()) .noneMatch(path -> path.toString().endsWith(".knowtator"))) { Files.createFile( - new File(projectLocation, String.format("%s.knowtator", projectLocation.getName())) + new File(this.projectLocation, String.format("%s.knowtator", projectLocation.getName())) .toPath()); } - Files.createDirectories(getArticlesLocation(projectLocation).toPath()); - Files.createDirectories(getAnnotationsLocation(projectLocation).toPath()); - Files.createDirectories(getProfilesLocation(projectLocation).toPath()); - Files.createDirectories(getOntologiesLocation(projectLocation).toPath()); + Files.createDirectories(getArticlesLocation(this.projectLocation).toPath()); + Files.createDirectories(getAnnotationsLocation(this.projectLocation).toPath()); + Files.createDirectories(getProfilesLocation(this.projectLocation).toPath()); + Files.createDirectories(getOntologiesLocation(this.projectLocation).toPath()); } public static File validateProjectLocation(File projectLocation) throws IOException { From c2449c67136543754453e28796c2119ab8e19269 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Tue, 18 Aug 2020 17:44:13 -0500 Subject: [PATCH 58/65] Select class and subclasses from Protege hierarchy. --- .idea/workspace.xml | 45 ++++++++-------- .../knowtator/view/iaa/IAAOptionsDialog.form | 13 +---- .../knowtator/view/iaa/IAAOptionsDialog.java | 51 +++++++++++-------- 3 files changed, 55 insertions(+), 54 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 26cf8362..4bf0230b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -34,10 +34,9 @@ - + - - + @@ -700,11 +699,11 @@ - + - + @@ -722,79 +721,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -849,11 +848,11 @@ - + - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form index 90c5d323..54000964 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.form @@ -158,18 +158,9 @@ - + - - - - - - - - - - + diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index fc59f423..39d48ce7 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -67,6 +67,7 @@ import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; +import org.apache.log4j.Logger; import org.protege.editor.owl.model.selection.OWLSelectionModelListener; public class IAAOptionsDialog extends JDialog implements KnowtatorComponent { @@ -88,12 +89,13 @@ public class IAAOptionsDialog extends JDialog implements KnowtatorComponent { private JButton owlClassesSelectAllButton; private OWLClassesTable owlClassesTable; private JButton compareAcrossProjectsButton; - private JButton chooseFromHierarchyButton; private JCheckBox includeSubclassesCheckBox; IAATableModel profilesTableModel; IAATableModel documentsTableModel; IAATableModel owlClassesTableModel; + private static final Logger log = Logger.getLogger(IAAOptionsDialog.class); + public IAAOptionsDialog(Window parent, KnowtatorModel model, KnowtatorView view, File outputDirectory) { super(parent); this.outputDirectory = outputDirectory; @@ -102,7 +104,7 @@ public IAAOptionsDialog(Window parent, KnowtatorModel model, KnowtatorView view, $$$setupUI$$$(); setContentPane(contentPane); - setModal(true); + setModal(false); getRootPane().setDefaultButton(buttonOK); buttonOK.addActionListener(e -> onOK()); @@ -202,18 +204,21 @@ public void windowClosing(WindowEvent e) { private void createUIComponents() { // TODO: place custom component creation code here - owlClassesTable = new OWLClassesTable(model, view); + includeSubclassesCheckBox = new JCheckBox(); + owlClassesTable = new OWLClassesTable(model, view, includeSubclassesCheckBox); } private static class OWLClassesTable extends JTable implements KnowtatorComponent, OWLSelectionModelListener { private final KnowtatorModel model; private final KnowtatorView view; + private final JCheckBox includeSubclassesCheckBox; - public OWLClassesTable(KnowtatorModel model, KnowtatorView view) { + public OWLClassesTable(KnowtatorModel model, KnowtatorView view, JCheckBox includeSubclassesCheckBox) { super(); this.model = model; this.view = view; + this.includeSubclassesCheckBox = includeSubclassesCheckBox; } @Override @@ -221,18 +226,30 @@ public void selectionChanged() throws Exception { Optional owlClassOptional = model.getSelectedOwlClass(); owlClassOptional.ifPresent(owlClass -> { - int i = -1; - for (int j = 0; j < getModel().getRowCount(); j++) { - if (getValueAt(0, j).equals(owlClass)) { - break; + int i = selectOwlClass(owlClass); + if (includeSubclassesCheckBox.isSelected()) { + for (String d : model.getOwlClassDescendants(owlClass)) { + selectOwlClass(d); } - i++; } - if (-1 < i) { - scrollRectToVisible(getCellRect(i, i, true)); + if (-1 < i && i < getModel().getRowCount()) { + scrollRectToVisible(getCellRect(i, 0, true)); } }); + + } + + private int selectOwlClass(String owlClass) { + int i = getModel().getRowCount() == 0 ? -1 : 0; + while (i < getModel().getRowCount() && (i != -1 && !getValueAt(i, 0).equals(owlClass))) { + i++; + } + + if (-1 < i && i < getModel().getRowCount()) { + setValueAt(Boolean.TRUE, i, 1); + } + return i; } @Override @@ -287,6 +304,7 @@ void toggleAll() { .forEach(i -> setValueAt(Boolean.TRUE, i, checkCol)); } } + } private void onOK() { @@ -325,6 +343,7 @@ private void onCancel() { @Override public void reset() { view.knowtatorComponents.add(owlClassesTable); + owlClassesTable.reset(); } @Override @@ -438,17 +457,9 @@ public void dispose() { final JPanel panel7 = new JPanel(); panel7.setLayout(new GridBagLayout()); panel5.add(panel7, BorderLayout.SOUTH); - chooseFromHierarchyButton = new JButton(); - chooseFromHierarchyButton.setText("Choose from hierarchy"); - gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.HORIZONTAL; - panel7.add(chooseFromHierarchyButton, gbc); - includeSubclassesCheckBox = new JCheckBox(); includeSubclassesCheckBox.setText("Include subclasses"); gbc = new GridBagConstraints(); - gbc.gridx = 1; + gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; panel7.add(includeSubclassesCheckBox, gbc); From c48f7aaf4e6366daaf4734826db9333d87ba312d Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 20 Aug 2020 11:44:30 -0500 Subject: [PATCH 59/65] Minor fixes to error reporting. --- src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java index 1a882bca..e4af15cd 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/TestingHelpers.java @@ -241,7 +241,7 @@ public static void countCollections( try { assert actualSpans == expectedSpans; } catch (AssertionError e) { - error = error.concat(String.format("\nThere were %d spans instead of %d%n", actualSpans, expectedSpans)); + error = error.concat(String.format("\nThere were %d spans instead of %d", actualSpans, expectedSpans)); } try { @@ -265,7 +265,7 @@ public static void countCollections( try { assert actualAnnotationNodes == expectedAnnotationNodes; } catch (AssertionError e) { - error = error.concat(String.format("\nThere were %d vertices instead of %d", actualAnnotationNodes, expectedAnnotationNodes)); + error = error.concat(String.format("\nThere were %d annotation nodes instead of %d", actualAnnotationNodes, expectedAnnotationNodes)); } try { From f0bab192bc513fa040bf3d2000e89188e5ea2e40 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 20 Aug 2020 11:46:22 -0500 Subject: [PATCH 60/65] Reload IAA dialog instead of making a new one. --- .idea/workspace.xml | 163 ++++++++++++------ .../ccp/knowtator/model/KnowtatorModel.java | 29 +++- .../AbstractKnowtatorCollectionAction.java | 46 +++-- .../knowtator/view/iaa/IAAOptionsDialog.java | 142 +++++++++------ 4 files changed, 250 insertions(+), 130 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4bf0230b..da1d0b38 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -33,10 +33,13 @@ + - - + + + + + @@ -115,7 +119,7 @@ - + @@ -134,6 +138,14 @@ + + - + - - + - - - + - - - + @@ -211,13 +226,12 @@ - + @@ -227,7 +241,7 @@ @@ -329,6 +344,7 @@ + 1590645202357 @@ -657,21 +673,21 @@ - + - + - + - + @@ -699,11 +715,11 @@ - + - + @@ -721,79 +737,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -831,10 +847,11 @@ - + + @@ -844,15 +861,19 @@ + + + + - + - + @@ -866,11 +887,11 @@ - + - + @@ -897,6 +918,46 @@ 77 diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java index 0da797f9..aeb15ad8 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/model/KnowtatorModel.java @@ -91,6 +91,11 @@ public void save() { @Override public void load(File projectLocation) { + try { + projectLocation = validateProjectLocation(projectLocation); + } catch (IOException e) { + e.printStackTrace(); + } super.load(projectLocation); setLoading(true); @@ -105,7 +110,10 @@ public void load(File projectLocation) { .filter(path -> path.toString().endsWith(".xml")) .map(Path::toFile) .forEach(file -> xmlUtil.readToProfileCollection(this, file)); - + } catch (IOException e) { + e.printStackTrace(); + } + try { Files.list(getArticlesLocation(projectLocation).toPath()) .filter(path -> path.toString().endsWith(".txt")) .map(Path::toFile) @@ -114,6 +122,10 @@ public void load(File projectLocation) { TextSource newTextSource = new TextSource(this, file, null); textSources.add(newTextSource); }); + } catch (IOException e) { + e.printStackTrace(); + } + try { log.info("Loading annotations"); OWLClassNotFoundAnnotations = new ArrayList<>(); @@ -122,17 +134,16 @@ public void load(File projectLocation) { .map(Path::toFile) .peek(file -> xmlUtil.readToTextSourceCollection(this, file)) .forEach(file -> oldXmlUtil.readToTextSourceCollection(this, file)); - - profiles.first().ifPresent(profiles::setSelection); - textSources.first().ifPresent(textSources::setSelection); - - Set owlClasses = new HashSet<>(); - textSources.forEach(textSource -> textSource.getConceptAnnotations().forEach(conceptAnnotation -> owlClasses.add(conceptAnnotation.getOwlClass()))); - profiles.verifyHighlighters(owlClasses); - } catch (IOException e) { e.printStackTrace(); } + profiles.first().ifPresent(profiles::setSelection); + textSources.first().ifPresent(textSources::setSelection); + + Set owlClasses = new HashSet<>(); + textSources.forEach(textSource -> textSource.getConceptAnnotations().forEach(conceptAnnotation -> owlClasses.add(conceptAnnotation.getOwlClass()))); + profiles.verifyHighlighters(owlClasses); + setLoading(false); } diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java index f349ace9..308c43a6 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/actions/collection/AbstractKnowtatorCollectionAction.java @@ -24,6 +24,7 @@ package edu.ucdenver.ccp.knowtator.view.actions.collection; +import edu.ucdenver.ccp.knowtator.model.BaseModel; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.collection.KnowtatorCollection; import edu.ucdenver.ccp.knowtator.model.object.ModelObject; @@ -51,20 +52,24 @@ public abstract class AbstractKnowtatorCollectionAction extends AbstractKnowtatorAction { - /** The Action type. */ + /** + * The Action type. + */ protected final CollectionActionType actionType; private final KnowtatorCollection collection; - /** The Object. */ + /** + * The Object. + */ protected K object; /** * Instantiates a new Abstract knowtator collection action. * - * @param model the model - * @param actionType the action type + * @param model the model + * @param actionType the action type * @param presentationName the presentation name - * @param collection the collection + * @param collection the collection */ protected AbstractKnowtatorCollectionAction( KnowtatorModel model, @@ -190,7 +195,9 @@ public void prepareRemove() throws ActionUnperformable { } } - /** Prepare add. */ + /** + * Prepare add. + */ protected abstract void prepareAdd(); /** @@ -200,7 +207,9 @@ public void prepareRemove() throws ActionUnperformable { */ protected abstract void cleanUpRemove() throws ActionUnperformable; - /** Clean up add. */ + /** + * Clean up add. + */ @SuppressWarnings("EmptyMethod") protected abstract void cleanUpAdd(); @@ -216,9 +225,9 @@ public void setObject(K object) { /** * Way to choose which action should occur. * - * @param view The Knowtator view - * @param id The profile id - * @param file The document file + * @param view The Knowtator view + * @param id The profile id + * @param file The document file * @param actionParametersList Additional parameters for actions */ public static void pickAction( @@ -259,16 +268,17 @@ public static void pickAction( case DOCUMENT: File annotationFile = null; if (actionType.equals(CollectionActionType.ADD)) { - JOptionPane.showMessageDialog(view, "Select annotation file"); - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setCurrentDirectory(model.getAnnotationsLocation(model.getProjectLocation())); + int choice = JOptionPane.showConfirmDialog(view, "Select annotation file?", "Annotation file", JOptionPane.YES_NO_OPTION); + if (choice == JOptionPane.YES_OPTION) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(BaseModel.getAnnotationsLocation(model.getProjectLocation())); + if (fileChooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { + annotationFile = fileChooser.getSelectedFile(); + } + } + actions.add(new TextSourceAction(model, actionType, file, annotationFile)); - if (fileChooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - annotationFile = fileChooser.getSelectedFile(); - actions.add( - new TextSourceAction(model, actionType, file, annotationFile)); - } } else { int response = JOptionPane.showConfirmDialog(view, "Remove document from project? (document and annotations will NOT be deleted)", null, JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index 39d48ce7..b01e5a78 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -29,6 +29,7 @@ import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.model.object.ConceptAnnotation; import edu.ucdenver.ccp.knowtator.model.object.ModelObject; +import edu.ucdenver.ccp.knowtator.model.object.Profile; import edu.ucdenver.ccp.knowtator.view.KnowtatorComponent; import edu.ucdenver.ccp.knowtator.view.KnowtatorView; import java.awt.BorderLayout; @@ -68,10 +69,13 @@ import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.DefaultTableModel; import org.apache.log4j.Logger; +import org.protege.editor.owl.model.OWLWorkspace; import org.protege.editor.owl.model.selection.OWLSelectionModelListener; public class IAAOptionsDialog extends JDialog implements KnowtatorComponent { private final KnowtatorView view; + private KnowtatorModel iaaModel; + private KnowtatorModel model; private JPanel contentPane; private JButton buttonOK; private JButton buttonCancel; @@ -79,7 +83,6 @@ public class IAAOptionsDialog extends JDialog implements KnowtatorComponent { private JPanel profilesPanel; private JPanel documentsPanel; private final File outputDirectory; - private final KnowtatorModel model; private JCheckBox iaaClassCheckBox; private JCheckBox iaaSpanCheckBox; private JCheckBox iaaClassAndSpanCheckBox; @@ -100,6 +103,7 @@ public IAAOptionsDialog(Window parent, KnowtatorModel model, KnowtatorView view, super(parent); this.outputDirectory = outputDirectory; this.model = model; + this.iaaModel = model; this.view = view; $$$setupUI$$$(); @@ -124,36 +128,13 @@ public void windowClosing(WindowEvent e) { KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + setModels(model); documentsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - documentsTableModel = new IAATableModel( - new Object[][] {}, - "Document", - model.getTextSources().stream() - .map(ModelObject::getId) - .collect(Collectors.toList())); - documentsTable.setModel(documentsTableModel); - documentsSelectAllButton.addActionListener(e -> documentsTableModel.toggleAll()); - - profilesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - profilesTableModel = new IAATableModel( - new Object[][] {}, - "Profile", - model.getProfiles().stream() - .map(ModelObject::getId) - .collect(Collectors.toList())); - profilesTable.setModel(profilesTableModel); - profilesSelectAllButton.addActionListener(e -> profilesTableModel.toggleAll()); - owlClassesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - owlClassesTableModel = new IAATableModel( - new Object[][] {}, - "OWL Classes", - new ArrayList<>(new HashSet<>(model.getTextSources().stream() - .flatMap(textSource -> textSource.getConceptAnnotations().stream() - .map(ConceptAnnotation::getOwlClass)) - .collect(Collectors.toSet())))); - owlClassesTable.setModel(owlClassesTableModel); + profilesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); owlClassesSelectAllButton.addActionListener(e -> owlClassesTableModel.toggleAll()); + documentsSelectAllButton.addActionListener(e -> documentsTableModel.toggleAll()); + profilesSelectAllButton.addActionListener(e -> profilesTableModel.toggleAll()); compareAcrossProjectsButton.addActionListener(e -> { JFileChooser fileChooser = new JFileChooser(); @@ -179,14 +160,11 @@ public void windowClosing(WindowEvent e) { event -> event.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) .ifPresent(event -> { try { - KnowtatorModel model2 = new KnowtatorModel(fileChooser.getSelectedFile(), view.getOWLWorkspace()); - model2.load(model2.getProjectLocation()); - model2.load(model.getProjectLocation()); - - JDialog iaaDialog = new IAAOptionsDialog(JOptionPane.getFrameForComponent(this), model2, view, outputDirectory); - iaaDialog.pack(); - iaaDialog.setVisible(true); - this.onCancel(); + File projectLocation1 = fileChooser.getSelectedFile(); + KnowtatorModel newModel = mergeProjects(projectLocation1, this.model, view.getOWLWorkspace(), false, this); + + setModels(newModel); + } catch (IOException ioException) { ioException.printStackTrace(); } @@ -202,40 +180,93 @@ public void windowClosing(WindowEvent e) { reset(); } + public static KnowtatorModel mergeProjects(File projectLocation1, KnowtatorModel model2, OWLWorkspace owlWorkspace, boolean mergeProfiles, JDialog component) throws IOException { + KnowtatorModel newModel = new KnowtatorModel(projectLocation1, owlWorkspace); + newModel.load(projectLocation1); + Set profilesInCommon = newModel.getProfiles().stream() + .filter(profile -> model2.getProfiles().contains(profile)) + .collect(Collectors.toSet()); + + for (Profile profile : profilesInCommon) { + if (mergeProfiles || JOptionPane.showConfirmDialog(component, + String.format("Merge %s between projects for IAA?", profile), + "Profile merge?", + JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) { + profile.setId(String.format("%s - %s", + profile.getId(), + projectLocation1 + .getName() + .replace(".knowtator", ""))); + } + } + + newModel.load(model2.getProjectLocation()); + return newModel; + } + + private void setModels(KnowtatorModel model) { + this.iaaModel = model; + documentsTableModel = new IAATableModel( + new Object[][] {}, + "Document", + model.getTextSources().stream() + .map(ModelObject::getId) + .collect(Collectors.toList())); + documentsTable.setModel(documentsTableModel); + + profilesTableModel = new IAATableModel( + new Object[][] {}, + "Profile", + model.getProfiles().stream() + .map(ModelObject::getId) + .collect(Collectors.toList())); + profilesTable.setModel(profilesTableModel); + + + owlClassesTableModel = new IAATableModel( + new Object[][] {}, + "OWL Classes", + new ArrayList<>(new HashSet<>(model.getTextSources().stream() + .flatMap(textSource -> textSource.getConceptAnnotations().stream() + .map(ConceptAnnotation::getOwlClass)) + .collect(Collectors.toSet())))); + owlClassesTable.setModel(owlClassesTableModel); + } + private void createUIComponents() { - // TODO: place custom component creation code here includeSubclassesCheckBox = new JCheckBox(); - owlClassesTable = new OWLClassesTable(model, view, includeSubclassesCheckBox); + owlClassesTable = new OWLClassesTable(view, includeSubclassesCheckBox); } private static class OWLClassesTable extends JTable implements KnowtatorComponent, OWLSelectionModelListener { - private final KnowtatorModel model; private final KnowtatorView view; private final JCheckBox includeSubclassesCheckBox; - public OWLClassesTable(KnowtatorModel model, KnowtatorView view, JCheckBox includeSubclassesCheckBox) { + public OWLClassesTable(KnowtatorView view, JCheckBox includeSubclassesCheckBox) { super(); - this.model = model; this.view = view; this.includeSubclassesCheckBox = includeSubclassesCheckBox; } @Override public void selectionChanged() throws Exception { - Optional owlClassOptional = model.getSelectedOwlClass(); + view.getModel().ifPresent(model -> { + Optional owlClassOptional = model.getSelectedOwlClass(); + + owlClassOptional.ifPresent(owlClass -> { + int i = selectOwlClass(owlClass); + if (includeSubclassesCheckBox.isSelected()) { + for (String d : model.getOwlClassDescendants(owlClass)) { + selectOwlClass(d); + } + } - owlClassOptional.ifPresent(owlClass -> { - int i = selectOwlClass(owlClass); - if (includeSubclassesCheckBox.isSelected()) { - for (String d : model.getOwlClassDescendants(owlClass)) { - selectOwlClass(d); + if (-1 < i && i < getModel().getRowCount()) { + scrollRectToVisible(getCellRect(i, 0, true)); } - } + }); - if (-1 < i && i < getModel().getRowCount()) { - scrollRectToVisible(getCellRect(i, 0, true)); - } }); } @@ -269,6 +300,13 @@ private static class IAATableModel extends DefaultTableModel { IAATableModel(Object[][] data, String col, List collection) { super(data, new String[] {col, "Checkbox"}); + setCollection(collection); + } + + private void setCollection(List collection) { + for (int i = 0; i < this.getRowCount(); i++) { + removeRow(i); + } for (String item : collection) { addRow(new Object[] {item, Boolean.FALSE}); } @@ -315,7 +353,7 @@ private void onOK() { if (profiles.size() <= 2 && !textSources.isEmpty() && (iaaClassCheckBox.isSelected() || iaaSpanCheckBox.isSelected() || iaaClassAndSpanCheckBox.isSelected())) { try { - KnowtatorIaa knowtatorIaa = new KnowtatorIaa(outputDirectory, model, textSources, profiles, owlClasses); + KnowtatorIaa knowtatorIaa = new KnowtatorIaa(outputDirectory, iaaModel, textSources, profiles, owlClasses); if (iaaClassCheckBox.isSelected()) { knowtatorIaa.runClassIaa(); From c67b9051c33aca7ab032fb754ae2465bd9cbcbd6 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Thu, 20 Aug 2020 11:46:59 -0500 Subject: [PATCH 61/65] Tests for importing/merging projects. --- .../view/iaa/IAAOptionsDialogTest.java | 107 ++++++++++++++++++ .../import_test_project1/Annotations/d1.xml | 9 ++ .../import_test_project1/Articles/d1.txt | 1 + .../import_test_project1.knowtator | 0 4 files changed, 117 insertions(+) create mode 100644 src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java create mode 100644 src/test/resources/import_test_project1/Annotations/d1.xml create mode 100644 src/test/resources/import_test_project1/Articles/d1.txt create mode 100644 src/test/resources/import_test_project1/import_test_project1.knowtator diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java new file mode 100644 index 00000000..2f3ad935 --- /dev/null +++ b/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java @@ -0,0 +1,107 @@ +/* + * MIT License + * + * Copyright (c) 2018 Harrison Pielke-Lombardo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package edu.ucdenver.ccp.knowtator.view.iaa; + +import com.google.common.io.Files; +import edu.ucdenver.ccp.knowtator.TestingHelpers; +import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; +import edu.ucdenver.ccp.knowtator.view.actions.ActionUnperformable; +import java.io.File; +import java.io.IOException; +import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.Test; + +class IAAOptionsDialogTest { + + @Test + void mergeProjectsTest() throws IOException { + File project1 = new File("/home/harrisonpl/Downloads/concepts+assertions_3_2 batch 1/CRAFT_assertions.knowtator"); + File project2 = new File("/home/harrisonpl/Downloads/CRAFT high-level concept annotation project/CRAFT_assertions.knowtator"); + + KnowtatorModel model2 = new KnowtatorModel(project2, null); + model2.load(model2.getProjectLocation()); + TestingHelpers.countCollections(model2, + 97, + 740, + 740, + 412, + 2, + 0, + 381, + 96, + 0); + + KnowtatorModel model1 = new KnowtatorModel(project1, null); + model1.load(model1.getProjectLocation()); + TestingHelpers.countCollections(model1, + 97, + 718, + 718, + 412, + 1, + 18, + 381, + 96, + 0); + + KnowtatorModel mergeModel = IAAOptionsDialog.mergeProjects(project1, model2, null, true, null); + TestingHelpers.countCollections(mergeModel, + 97, + 1458, + 1458, + 412, + 3, + 18, + 381, + 96, + 0); + } + + @Test + public void mergeProjectsTest2() throws ActionUnperformable, IOException { + String projectName = "import_test_project1"; + + File projectDirectory = new File( + TestingHelpers.class + .getResource(String.format("/%s/%s.knowtator", projectName, projectName)) + .getFile()).getParentFile(); + File tempProjectDir = Files.createTempDir(); + FileUtils.copyDirectory(projectDirectory, tempProjectDir); + KnowtatorModel model = new KnowtatorModel(tempProjectDir, null); + model.load(model.getProjectLocation()); + + TestingHelpers.countCollections( + model, + 1, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 0); + } +} \ No newline at end of file diff --git a/src/test/resources/import_test_project1/Annotations/d1.xml b/src/test/resources/import_test_project1/Annotations/d1.xml new file mode 100644 index 00000000..7af151f1 --- /dev/null +++ b/src/test/resources/import_test_project1/Annotations/d1.xml @@ -0,0 +1,9 @@ + + + + + + a + + + diff --git a/src/test/resources/import_test_project1/Articles/d1.txt b/src/test/resources/import_test_project1/Articles/d1.txt new file mode 100644 index 00000000..b0883f38 --- /dev/null +++ b/src/test/resources/import_test_project1/Articles/d1.txt @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyz diff --git a/src/test/resources/import_test_project1/import_test_project1.knowtator b/src/test/resources/import_test_project1/import_test_project1.knowtator new file mode 100644 index 00000000..e69de29b From 3022acf117c3275f9aca80c2383373e2592df0e3 Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Sat, 22 Aug 2020 13:12:26 -0500 Subject: [PATCH 62/65] Made project counts object to help contain and manipulate the project counts. --- .idea/workspace.xml | 67 +++--- .../ccp/knowtator/KnowtatorIaaTest.java | 46 +--- .../ccp/knowtator/ProjectManagerTest.java | 13 +- .../ccp/knowtator/TestingHelpers.java | 198 ++++++++---------- .../ccp/knowtator/io/conll/ConllUtilTest.java | 14 +- .../ccp/knowtator/model/OwlModelTest.java | 82 +------- .../view/actions/FilterActionsTest.java | 51 +---- .../view/actions/GraphActionsTest.java | 55 +---- .../KnowtatorCollectionActionsTest.java | 120 +---------- .../view/iaa/IAAOptionsDialogTest.java | 94 ++++----- .../import_test_project2/Annotations/d1.xml | 13 ++ .../import_test_project3/Annotations/d1.xml | 9 + 12 files changed, 226 insertions(+), 536 deletions(-) create mode 100644 src/test/resources/import_test_project2/Annotations/d1.xml create mode 100644 src/test/resources/import_test_project3/Annotations/d1.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index da1d0b38..06ef91ac 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -33,13 +33,17 @@ - - - - + + + + + + + + - + @@ -309,9 +313,9 @@ + - @@ -344,7 +348,7 @@ - + 1590645202357 @@ -698,6 +702,10 @@ + + + + @@ -737,79 +745,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -843,10 +851,10 @@ - + - + @@ -887,11 +895,11 @@ - + - + @@ -948,11 +956,6 @@ 208 + - - - - - - - - @@ -103,7 +96,7 @@ - + @@ -120,10 +113,11 @@ + - + @@ -167,15 +161,13 @@ - + - - - + + - - - - - - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + - - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - + - + - - + + + + + - + - + - + - + + + + + + + - - - - - - - - -
    diff --git a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java index b01e5a78..a7fe3e9f 100644 --- a/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java +++ b/src/main/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialog.java @@ -61,6 +61,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; @@ -401,145 +402,140 @@ public void dispose() { createUIComponents(); contentPane = new JPanel(); contentPane.setLayout(new GridBagLayout()); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new BorderLayout(0, 0)); + final JSplitPane splitPane1 = new JSplitPane(); GridBagConstraints gbc; gbc = new GridBagConstraints(); - gbc.gridx = 1; - gbc.gridy = 0; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel1, gbc); - panel1.setBorder(BorderFactory.createTitledBorder(null, this.$$$getMessageFromBundle$$$("ui", "profiles"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - profilesPanel = new JPanel(); - profilesPanel.setLayout(new BorderLayout(0, 0)); - panel1.add(profilesPanel, BorderLayout.NORTH); - profilesSelectAllButton = new JButton(); - this.$$$loadButtonText$$$(profilesSelectAllButton, this.$$$getMessageFromBundle$$$("log4j", "select.all")); - profilesPanel.add(profilesSelectAllButton, BorderLayout.NORTH); - final JScrollPane scrollPane1 = new JScrollPane(); - profilesPanel.add(scrollPane1, BorderLayout.CENTER); - profilesTable = new JTable(); - profilesTable.setAutoCreateRowSorter(true); - scrollPane1.setViewportView(profilesTable); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new BorderLayout(0, 0)); - gbc = new GridBagConstraints(); - gbc.gridx = 2; - gbc.gridy = 0; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel2, gbc); - panel2.setBorder(BorderFactory.createTitledBorder(null, this.$$$getMessageFromBundle$$$("log4j", "documents"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); - documentsPanel = new JPanel(); - documentsPanel.setLayout(new BorderLayout(0, 0)); - panel2.add(documentsPanel, BorderLayout.NORTH); - documentsSelectAllButton = new JButton(); - this.$$$loadButtonText$$$(documentsSelectAllButton, this.$$$getMessageFromBundle$$$("log4j", "select.all")); - documentsPanel.add(documentsSelectAllButton, BorderLayout.NORTH); - final JScrollPane scrollPane2 = new JScrollPane(); - documentsPanel.add(scrollPane2, BorderLayout.CENTER); - documentsTable = new JTable(); - scrollPane2.setViewportView(documentsTable); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new BorderLayout(0, 0)); - gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel3, gbc); - final JPanel panel4 = new JPanel(); - panel4.setLayout(new GridBagLayout()); - panel3.add(panel4, BorderLayout.NORTH); - panel4.setBorder(BorderFactory.createTitledBorder(null, "Mode", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + contentPane.add(splitPane1, gbc); + final JSplitPane splitPane2 = new JSplitPane(); + splitPane1.setLeftComponent(splitPane2); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridBagLayout()); + splitPane2.setLeftComponent(panel1); + panel1.setBorder(BorderFactory.createTitledBorder(null, "Mode", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); iaaClassCheckBox = new JCheckBox(); this.$$$loadButtonText$$$(iaaClassCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.iaa")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; - panel4.add(iaaClassCheckBox, gbc); + panel1.add(iaaClassCheckBox, gbc); iaaSpanCheckBox = new JCheckBox(); this.$$$loadButtonText$$$(iaaSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "span.iaa")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.WEST; - panel4.add(iaaSpanCheckBox, gbc); + panel1.add(iaaSpanCheckBox, gbc); iaaClassAndSpanCheckBox = new JCheckBox(); this.$$$loadButtonText$$$(iaaClassAndSpanCheckBox, this.$$$getMessageFromBundle$$$("log4j", "class.and.span.iaa")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; - panel4.add(iaaClassAndSpanCheckBox, gbc); + panel1.add(iaaClassAndSpanCheckBox, gbc); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new BorderLayout(0, 0)); + splitPane2.setRightComponent(panel2); + panel2.setBorder(BorderFactory.createTitledBorder(null, this.$$$getMessageFromBundle$$$("ui", "profiles"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + profilesPanel = new JPanel(); + profilesPanel.setLayout(new BorderLayout(0, 0)); + panel2.add(profilesPanel, BorderLayout.NORTH); + final JScrollPane scrollPane1 = new JScrollPane(); + profilesPanel.add(scrollPane1, BorderLayout.CENTER); + profilesTable = new JTable(); + profilesTable.setAutoCreateRowSorter(true); + scrollPane1.setViewportView(profilesTable); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new BorderLayout(0, 0)); + profilesPanel.add(panel3, BorderLayout.NORTH); + profilesSelectAllButton = new JButton(); + this.$$$loadButtonText$$$(profilesSelectAllButton, this.$$$getMessageFromBundle$$$("log4j", "select.all")); + panel3.add(profilesSelectAllButton, BorderLayout.EAST); + final JSplitPane splitPane3 = new JSplitPane(); + splitPane1.setRightComponent(splitPane3); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new BorderLayout(0, 0)); + splitPane3.setLeftComponent(panel4); + panel4.setBorder(BorderFactory.createTitledBorder(null, this.$$$getMessageFromBundle$$$("log4j", "documents"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + documentsPanel = new JPanel(); + documentsPanel.setLayout(new BorderLayout(0, 0)); + panel4.add(documentsPanel, BorderLayout.NORTH); + final JScrollPane scrollPane2 = new JScrollPane(); + documentsPanel.add(scrollPane2, BorderLayout.CENTER); + documentsTable = new JTable(); + scrollPane2.setViewportView(documentsTable); final JPanel panel5 = new JPanel(); panel5.setLayout(new BorderLayout(0, 0)); - gbc = new GridBagConstraints(); - gbc.gridx = 3; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel5, gbc); - panel5.setBorder(BorderFactory.createTitledBorder(null, "OWL Classes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + documentsPanel.add(panel5, BorderLayout.NORTH); + documentsSelectAllButton = new JButton(); + this.$$$loadButtonText$$$(documentsSelectAllButton, this.$$$getMessageFromBundle$$$("log4j", "select.all")); + panel5.add(documentsSelectAllButton, BorderLayout.EAST); final JPanel panel6 = new JPanel(); panel6.setLayout(new BorderLayout(0, 0)); - panel5.add(panel6, BorderLayout.CENTER); - owlClassesSelectAllButton = new JButton(); - owlClassesSelectAllButton.setText("Select all"); - panel6.add(owlClassesSelectAllButton, BorderLayout.NORTH); + splitPane3.setRightComponent(panel6); + panel6.setBorder(BorderFactory.createTitledBorder(null, "OWL Classes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new BorderLayout(0, 0)); + panel6.add(panel7, BorderLayout.CENTER); final JScrollPane scrollPane3 = new JScrollPane(); - panel6.add(scrollPane3, BorderLayout.CENTER); + panel7.add(scrollPane3, BorderLayout.CENTER); scrollPane3.setViewportView(owlClassesTable); - final JPanel panel7 = new JPanel(); - panel7.setLayout(new GridBagLayout()); - panel5.add(panel7, BorderLayout.SOUTH); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new BorderLayout(0, 0)); + panel7.add(panel8, BorderLayout.NORTH); + owlClassesSelectAllButton = new JButton(); + owlClassesSelectAllButton.setText("Select all"); + panel8.add(owlClassesSelectAllButton, BorderLayout.EAST); + final JPanel panel9 = new JPanel(); + panel9.setLayout(new GridBagLayout()); + panel6.add(panel9, BorderLayout.SOUTH); includeSubclassesCheckBox.setText("Include subclasses"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; - panel7.add(includeSubclassesCheckBox, gbc); - final JPanel panel8 = new JPanel(); - panel8.setLayout(new GridBagLayout()); + panel9.add(includeSubclassesCheckBox, gbc); + final JPanel panel10 = new JPanel(); + panel10.setLayout(new GridBagLayout()); gbc = new GridBagConstraints(); - gbc.gridx = 3; + gbc.gridx = 0; gbc.gridy = 1; - gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; - contentPane.add(panel8, gbc); - final JPanel spacer1 = new JPanel(); + contentPane.add(panel10, gbc); + compareAcrossProjectsButton = new JButton(); + compareAcrossProjectsButton.setText("Compare across projects"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel8.add(spacer1, gbc); - buttonOK = new JButton(); - this.$$$loadButtonText$$$(buttonOK, this.$$$getMessageFromBundle$$$("log4j", "ok")); + panel10.add(compareAcrossProjectsButton, gbc); + buttonCancel = new JButton(); + this.$$$loadButtonText$$$(buttonCancel, this.$$$getMessageFromBundle$$$("log4j", "cancel")); gbc = new GridBagConstraints(); - gbc.gridx = 1; + gbc.gridx = 3; gbc.gridy = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel8.add(buttonOK, gbc); - buttonCancel = new JButton(); - this.$$$loadButtonText$$$(buttonCancel, this.$$$getMessageFromBundle$$$("log4j", "cancel")); + panel10.add(buttonCancel, gbc); + buttonOK = new JButton(); + buttonOK.setText("Run"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; - panel8.add(buttonCancel, gbc); - compareAcrossProjectsButton = new JButton(); - compareAcrossProjectsButton.setText("Compare across projects"); + panel10.add(buttonOK, gbc); + final JPanel spacer1 = new JPanel(); gbc = new GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = 1; + gbc.gridx = 1; + gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; - contentPane.add(compareAcrossProjectsButton, gbc); + panel10.add(spacer1, gbc); } private static Method $$$cachedGetBundleMethod$$$ = null; From e9ddd310bf3a33ae568212d8e92fcaa48e8f217e Mon Sep 17 00:00:00 2001 From: tuh8888 Date: Mon, 24 Aug 2020 15:18:56 -0500 Subject: [PATCH 65/65] Removed test relying on external data which didn't really test properly anyway. --- .idea/workspace.xml | 29 +++++++--------- .../view/iaa/IAAOptionsDialogTest.java | 34 +------------------ 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index be846c9f..416bb6f2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -32,12 +32,7 @@
    - - - - - - + - + @@ -305,8 +300,8 @@ - + @@ -341,7 +336,7 @@ - + 1590645202357 @@ -738,43 +733,43 @@ - + - + - + - + - + - + - + - + diff --git a/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java b/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java index dafc2365..484e5702 100644 --- a/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java +++ b/src/test/java/edu/ucdenver/ccp/knowtator/view/iaa/IAAOptionsDialogTest.java @@ -27,43 +27,11 @@ import edu.ucdenver.ccp.knowtator.TestingHelpers; import edu.ucdenver.ccp.knowtator.model.KnowtatorModel; import edu.ucdenver.ccp.knowtator.view.actions.ActionUnperformable; -import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Test; class IAAOptionsDialogTest { - @Test - void mergeProjectsTest() throws IOException { - File project1 = new File("/home/harrisonpl/Downloads/concepts+assertions_3_2 batch 1/CRAFT_assertions.knowtator"); - File project2 = new File("/home/harrisonpl/Downloads/CRAFT high-level concept annotation project/CRAFT_assertions.knowtator"); - - KnowtatorModel model2 = new KnowtatorModel(project2, null); - model2.load(model2.getProjectLocation()); - - TestingHelpers.ProjectCounts model2Counts = new TestingHelpers.ProjectCounts(97, 740, 740, 412, 2, 0, 381, 96, 0); - TestingHelpers.countCollections(model2, model2Counts); - - KnowtatorModel model1 = new KnowtatorModel(project1, null); - model1.load(model1.getProjectLocation()); - TestingHelpers.ProjectCounts model1Counts = new TestingHelpers.ProjectCounts(97, 718, 718, 412, 1, 18, 381, 96, 0); - TestingHelpers.countCollections(model1, model1Counts); - - KnowtatorModel mergeModel = IAAOptionsDialog.mergeProjects(project1, model2, null, true, null); - TestingHelpers.ProjectCounts overlapCounts = new TestingHelpers.ProjectCounts(97, 718, 718, 412, 0, 0, 0, 0, 0); - TestingHelpers.ProjectCounts mergeModelCounts = model1Counts.add(model2Counts, overlapCounts); - TestingHelpers.countCollections(mergeModel, mergeModelCounts); -// 97, -// 1458, -// 1458, -// 412, -// 3, -// 18, -// 381, -// 96, -// 0 - } - private void checkMerge(String projectName1, TestingHelpers.ProjectCounts project1Counts, String projectName2, TestingHelpers.ProjectCounts project2Counts, TestingHelpers.ProjectCounts overlapCounts) throws IOException { KnowtatorModel model1 = TestingHelpers.getLoadedModel(projectName1); TestingHelpers.countCollections(model1, project1Counts); @@ -78,7 +46,7 @@ private void checkMerge(String projectName1, TestingHelpers.ProjectCounts projec } @Test - public void mergeProjectsTest2() throws ActionUnperformable, IOException { + public void mergeProjectsTest() throws ActionUnperformable, IOException { String projectName1 = "import_test_project1"; TestingHelpers.ProjectCounts model1Counts = new TestingHelpers.ProjectCounts(1, 1, 1, 0 , 1, 0 , 0, 0, 0);