diff --git a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/part/RedeWiedergabeView.java b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/part/RedeWiedergabeView.java index 8a133f660d2134f7252490dfec677a45817c23ef..71a8d5cb55dc70f54565f7eb2ef0503a0475af59 100644 --- a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/part/RedeWiedergabeView.java +++ b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/part/RedeWiedergabeView.java @@ -909,88 +909,148 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart { } - - // methods that are required by the view public void createSpeaker() { - int counter = 0; - AnnotationFS selected = null; - if (editor.getSelectionOfVisibleAnnotations().size() > 0) { - for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) { - if (anno.getType().equals(speakerType)) { - selected = anno; + boolean speakerIDFlag = false; + for (AnnotationFS speaker : speakerList){ + if (speaker.getFeatureValueAsString(speakerIDFeat) == null){ + JFrame jFrame = new JFrame("Information"); + JOptionPane.showMessageDialog(jFrame, "Please assign an ID to the speaker " + "\"" + speaker.getFeatureValueAsString(speakerFeat) + "\"" + ".", "Attention", JOptionPane.WARNING_MESSAGE); + speakerIDFlag = true; + } + } + + if (speakerIDFlag == false) + { + + //int counter = 0; + AnnotationFS selected = null; + if (editor.getSelectionOfVisibleAnnotations().size() > 0) { + for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) { + if (anno.getType().equals(speakerType)) { + selected = anno; + } } } - } - // remove vorschlag - CAS cas = editor.getCas(); - Type t = speakerType; - // get the selection + // remove vorschlag + CAS cas = editor.getCas(); + Type t = speakerType; + // get the selection - if (selected == null) { + if (selected == null) { - Point selection = editor.getActualSelectedText(); - if (selection == null || selection.x == selection.y) { - return; - } - AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y); - - anno.getFeatureValueAsString(speakerFeat); - String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat); - speakerFeatValue = anno.getCoveredText(); - updateAnnotation(anno, speakerFeat, speakerFeatValue, true); - - for (AnnotationFS frame : frameList) - { - if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()) - { - anno.getFeatureValueAsString(speakerFeat); - addAnnotation(anno); - updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true); + Point selection = editor.getActualSelectedText(); + if (selection == null || selection.x == selection.y) { + return; } - else + AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y); + + anno.getFeatureValueAsString(speakerFeat); + String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat); + speakerFeatValue = anno.getCoveredText(); + updateAnnotation(anno, speakerFeat, speakerFeatValue, true); + addAnnotation(anno); + + for (AnnotationFS frame : frameList) { - counter++; + if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()) + { + anno.getFeatureValueAsString(speakerFeat); + addAnnotation(anno); + updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true); + } + + for (AnnotationFS stwr : stwrList){ + if (anno.getBegin() >= stwr.getBegin() && anno.getEnd() <= stwr.getEnd()) + { + anno.getFeatureValueAsString(speakerFeat); + addAnnotation(anno); + updateAnnotation(anno, speakerIDFeat, stwr.getFeatureValueAsString(stwrIDFeat), true); + } } - if (counter == frameList.size()) - { - JFrame jFrame = new JFrame("Information"); - JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE); + + /* + else + { + counter++; + } + + if (counter == frameList.size()) + { + JFrame jFrame = new JFrame("Information"); + JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE); + } + */ } } - } - /* - Display.getCurrent().asyncExec(() -> { + /* + Display.getCurrent().asyncExec(() -> { + renewPage(); + }); + */ renewPage(); - }); - */ - renewPage(); + } } - public void correctSpeakerExp(AnnotationFS selected) + public void createSpeakerOutsideFrame(AnnotationFS selected) { List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType); - List<AnnotationFS> expSelection = editor.getCurrentSelectionOfType(expressionType); + String concatenatedId = ""; + + if (speakerSelection != null && speakerSelection.size() > 0) - { + { AnnotationFS anno = speakerSelection.get(0); - updateAnnotation(anno, speakerIDFeat, selected.getFeatureValueAsString(frameIDFeat), true); + if (anno.getFeatureValueAsString(speakerIDFeat) == null) + { + concatenatedId = selected.getFeatureValueAsString(frameIDFeat); + updateAnnotation(anno, speakerIDFeat, concatenatedId, true); + }else if (anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(frameIDFeat) + " " + ".*") + || anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(frameIDFeat) + " " + ".*" ) + || anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(frameIDFeat)) + || anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(frameIDFeat))){ + JFrame jFrame = new JFrame("Information"); + JOptionPane.showMessageDialog(jFrame, "The speaker already has the ID " + selected.getFeatureValueAsString(frameIDFeat) + ".", "Attention", JOptionPane.WARNING_MESSAGE); + }else { + concatenatedId = anno.getFeatureValueAsString(speakerIDFeat) + " " + selected.getFeatureValueAsString(frameIDFeat); + updateAnnotation(anno, speakerIDFeat, concatenatedId, true); + } } - - if (expSelection != null && expSelection.size() > 0) + } + + public void createSpeakerOutsideStwr(AnnotationFS selected) + { + List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType); + String concatenatedId = ""; + + if (speakerSelection != null && speakerSelection.size() > 0) { - AnnotationFS anno = expSelection.get(0); - updateAnnotation(anno, expressionIDFeat, selected.getFeatureValueAsString(frameIDFeat), true); - } + AnnotationFS anno = speakerSelection.get(0); + if (anno.getFeatureValueAsString(speakerIDFeat) == null) + { + concatenatedId = selected.getFeatureValueAsString(stwrIDFeat); + updateAnnotation(anno, speakerIDFeat, concatenatedId, true); + }else if (anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(stwrIDFeat) + " " + ".*") + || anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(stwrIDFeat) + " " + ".*" ) + || anno.getFeatureValueAsString(speakerIDFeat).matches(".*" + " " + selected.getFeatureValueAsString(stwrIDFeat)) + || anno.getFeatureValueAsString(speakerIDFeat).matches(selected.getFeatureValueAsString(stwrIDFeat))){ + JFrame jFrame = new JFrame("Information"); + JOptionPane.showMessageDialog(jFrame, "The speaker already has the ID " + selected.getFeatureValueAsString(stwrIDFeat) + ".", "Attention", JOptionPane.WARNING_MESSAGE); + }else { + concatenatedId = anno.getFeatureValueAsString(speakerIDFeat) + " " + selected.getFeatureValueAsString(stwrIDFeat); + updateAnnotation(anno, speakerIDFeat, concatenatedId, true); + } + } } - // methods that are required by the view + public void createExpression() { - int counter = 0; + int frameCounter = 0; + int repCounter = 0; AnnotationFS selected = null; if (editor.getSelectionOfVisibleAnnotations().size() > 0) { for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) { @@ -1001,7 +1061,6 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart { } } - // remove vorschlag CAS cas = editor.getCas(); Type t = expressionType; // get the selection @@ -1018,34 +1077,56 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart { expFeatValue = anno.getCoveredText(); updateAnnotation(anno, expressionFeat, expFeatValue, true); - for (AnnotationFS frame : frameList) - { - if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()) - { + for (AnnotationFS frame : frameList){ + if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()){ anno.getFeatureValueAsString(expressionFeat); updateAnnotation(anno, expressionIDFeat, frame.getFeatureValueAsString(frameIDFeat), true); addAnnotation(anno); - } + } else { - counter++; - } - - if (counter == frameList.size()) + frameCounter++; + } + /* + if (frameCounter == frameList.size()) { JFrame jFrame = new JFrame("Information"); - JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE); + JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE); + } + */ + } + + ArrayList<AnnotationFS> repAnnoList = getReportedAnno(stwrList); + for (AnnotationFS repAnno : repAnnoList){ + if (anno.getBegin() >= repAnno.getBegin() && anno.getEnd() <= repAnno.getEnd()){ + anno.getFeatureValueAsString(expressionFeat); + updateAnnotation(anno, expressionIDFeat, repAnno.getFeatureValueAsString(stwrIDFeat), true); + addAnnotation(anno); } + else + { + repCounter++; + } + } + if (repCounter == repAnnoList.size() && frameCounter == frameList.size()) + { + JFrame jFrame = new JFrame("Information"); + JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or in a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE); } } - /* - Display.getCurrent().asyncExec(() -> { - renewPage(); - }); - */ renewPage(); } + public ArrayList<AnnotationFS> getReportedAnno(List<AnnotationFS>stwrList){ + ArrayList<AnnotationFS> reportedList = new ArrayList<AnnotationFS>(); + for (AnnotationFS stwr : stwrList){ + if (stwr.getFeatureValueAsString(rTypeFeat).equals("reported")){ + reportedList.add(stwr); + } + } + return reportedList; + } + public void createSpeech() { ambigMediumDialog.speechFlag = false; ambigMediumDialog.thoughtFlag = false; diff --git a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwFrameTableComposite.java b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwFrameTableComposite.java index 39a2fb96e87909e2c2c4bdd4fb02f2cfe89fb72b..d9e27935b84d95d23590d8e9742198ea822e1bf8 100644 --- a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwFrameTableComposite.java +++ b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwFrameTableComposite.java @@ -201,7 +201,7 @@ public class RwFrameTableComposite extends Composite{ { IStructuredSelection sel = (IStructuredSelection) frameViewer.getSelection(); AnnotationFS selected = (AnnotationFS) sel.getFirstElement(); - part.correctSpeakerExp(selected); + part.createSpeakerOutsideFrame(selected); } // small utility method diff --git a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwSpeakerDrawingStrategy.java b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwSpeakerDrawingStrategy.java index 21df66a9b3ef7bec6c06d3cddd3cf997b3b6fc2a..d5d959bb97916917e0ebd3e4c644553753abd273 100644 --- a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwSpeakerDrawingStrategy.java +++ b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwSpeakerDrawingStrategy.java @@ -80,7 +80,9 @@ public class RwSpeakerDrawingStrategy implements IAnnotationDrawingStrategy { String feat = anno.getFeatureValueAsString(f); if (feat != null && feat.trim().length() > 0) { // Only draw if String not empty. - gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x + lastRect.width - 1, + //gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x + lastRect.width - 1, + // lastRect.y - FONTSIZE - 7); + gc.drawString(anno.getFeatureValueAsString(f) + s, lastRect.x-10 + lastRect.width - 1, lastRect.y - FONTSIZE - 7); } } diff --git a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwStwrTableComposite.java b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwStwrTableComposite.java index dbea7900ae760921ffb6b3e692cdbddc6d06f9e7..cf49df04c0b42d5d31d51cc3c8d41f2fe69d743f 100644 --- a/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwStwrTableComposite.java +++ b/de.uniwue.mk.athen/bundles/de.ids.tt.athen.rwview/src/de/ids/tt/athen/rwview/ui/RwStwrTableComposite.java @@ -109,12 +109,12 @@ public class RwStwrTableComposite extends Composite{ createTableViewerColumn("Stwr", 45, 1, part::determineStwr); createTableViewerColumn("Medium", 45, 2, part::determineMedium); createTableViewerColumn("Type", 45, 3, part::determineRType); - createTableViewerColumn("Level", 45, 4, part::determineLevel); - createTableViewerColumn("NonFact", 45, 5, part::determineNonFact); - createTableViewerColumn("Prag", 45, 6, part::determinePrag); - createTableViewerColumn("Border", 45, 7, part::determineBorder); - createTableViewerColumn("Metaph", 45, 8, part::determineMetaph); - createTableViewerColumn("ID", 45, 9, part::determineStwrID); + createTableViewerColumn("ID", 45, 4, part::determineStwrID); + createTableViewerColumn("Level", 45, 5, part::determineLevel); + createTableViewerColumn("NonFact", 45, 6, part::determineNonFact); + createTableViewerColumn("Prag", 45, 7, part::determinePrag); + createTableViewerColumn("Border", 45, 8, part::determineBorder); + createTableViewerColumn("Metaph", 45, 9, part::determineMetaph); createTableViewerColumn("Note", 45, 10, part::determineStwrNote); } @@ -203,6 +203,8 @@ public class RwStwrTableComposite extends Composite{ // table got a key listener stwrViewer.getTable().addListener(SWT.KeyDown, (Event e) -> handleTableKeyDown(e)); + stwrViewer.getTable().addListener(SWT.MouseDoubleClick, (Event e) -> handleTableDoubleClick(e)); + } private void handleTableKeyDown(Event e) { @@ -252,6 +254,13 @@ public class RwStwrTableComposite extends Composite{ part.toggleMetaph(selectedAnnos); } } + + private void handleTableDoubleClick (Event e) + { + IStructuredSelection sel = (IStructuredSelection) stwrViewer.getSelection(); + AnnotationFS selected = (AnnotationFS) sel.getFirstElement(); + part.createSpeakerOutsideStwr(selected); + } // small utility method private List<AnnotationFS> getSelectedAnnotationsFromTable() {