Commit 1284091b authored by tu's avatar tu

Merge remote-tracking branch 'origin/master' into redeWiedergabe_dev

parents ff579975 2d206d8b
Pipeline #10655 passed with stage
in 4 minutes and 35 seconds
......@@ -9,6 +9,9 @@ import java.util.Map;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.jface.window.DefaultToolTip;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
......@@ -85,6 +88,15 @@ public class ATHENEditorBorderComposite extends Composite {
for (AnnotationToDSPair pair : annoToDSPairs) {
Composite composite = new Composite(this, SWT.BORDER);
composite.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
widget.setSelection(new Point(pair.getAnno().getBegin(), pair.getAnno().getEnd()));
widget.showSelection();
}
});
applyStyling(composite, pair.getDrawingstrategy());
controlledWidgets.put(pair, composite);
}
......@@ -117,7 +129,7 @@ public class ATHENEditorBorderComposite extends Composite {
// calculate top line and bottom line
// get top offset
double topOffset = (widget.getLineAtOffset(pair.getAnno().getBegin()) / (widget.getLineCount() + 0.0d))
* getBounds().height;
double bottomOffset = (widget.getLineAtOffset(pair.getAnno().getEnd()) / (widget.getLineCount() + 0.0d))
......@@ -128,7 +140,14 @@ public class ATHENEditorBorderComposite extends Composite {
// every composite displays its annotation
DefaultToolTip toolTip = new DefaultToolTip(composite);
toolTip.setShift(new Point(5, 5));
toolTip.setText(pair.getAnno().toString());
if (pair.getAnno().getType().getName().contains("Scene")) {
toolTip.setText(
pair.getAnno().getFeatureValueAsString(pair.getAnno().getType().getFeatureByBaseName("Type")));
} else {
toolTip.setText(pair.getAnno().toString());
}
});
}
......
......@@ -659,7 +659,7 @@ public class ATHENEditorWidget extends Canvas {
if (editorLines != null && editorLines.size() > topLineOffset) {
firstVisibleCharacter = editorLines.get(topLineOffset).getOffset().x;
}
determineWrappedLines(determineWidgetWidth(), gc, getBounds().height);
determineWrappedLines(determineWidgetWidth(), gc);
// calculate the height of the widget
int height = 0;
......@@ -1109,7 +1109,7 @@ public class ATHENEditorWidget extends Canvas {
return currentInput.getCas().getDocumentText();
}
private void determineWrappedLines(int widgetWidth, GC gc, int height) {
private void determineWrappedLines(int widgetWidth, GC gc) {
editorLines = new ArrayList<>();
......@@ -1520,7 +1520,6 @@ public class ATHENEditorWidget extends Canvas {
@Override
public void layout() {
super.layout();
drawWidget();
}
......
package de.uniwue.mk.kall.athen.annotationbrowserview.ui;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.resource.ResourceConfigurationException;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.ruta.engine.Ruta;
import org.apache.uima.util.InvalidXMLException;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.di.Persist;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.layout.GridLayout;
......@@ -27,8 +37,6 @@ import de.uniwue.mk.kall.editorPainting.paintingstrategies.specialized.JoniSegme
public class AnnotationBrowserView extends AEditorSubordinateViewPart {
private AnnotationBrowserWidget widget;
@Inject
public AnnotationBrowserView() {
......@@ -39,7 +47,6 @@ public class AnnotationBrowserView extends AEditorSubordinateViewPart {
public void postConstruct(Composite parent, MPart part) {
super.postConstruct(parent, part);
System.out.println("Construct Annotation Browser");
}
......@@ -59,7 +66,6 @@ public class AnnotationBrowserView extends AEditorSubordinateViewPart {
public void save() {
// nothing to save
}
@Override
protected void initLayout(Composite composite) {
......@@ -128,6 +134,9 @@ public class AnnotationBrowserView extends AEditorSubordinateViewPart {
@Override
public boolean initTypes() {
// hide all types
editor.allStylesInvisible();
// try to set default editor stylings to given annotations
Type typeDWHeadline = editor.getCas().getTypeSystem().getType("de.uniwue.dw.segmentation.Headline");
Type typeDWHeadlineCandidate = editor.getCas().getTypeSystem()
......@@ -152,6 +161,8 @@ public class AnnotationBrowserView extends AEditorSubordinateViewPart {
return false;
}
private void setDefaultHistoricalDrawingStrategies() {
Type historicalSemnaticType = editor.getCas().getTypeSystem()
......@@ -199,8 +210,6 @@ public class AnnotationBrowserView extends AEditorSubordinateViewPart {
}
}
@Override
public void initModel() {
......
package de.uniwue.mk.kall.athen.annotationbrowserwidget;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import org.apache.uima.cas.FSIndex;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.impl.AnnotationImpl;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.resource.ResourceConfigurationException;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.ruta.engine.Ruta;
import org.apache.uima.util.InvalidXMLException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
......@@ -15,17 +20,18 @@ import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
......@@ -48,9 +54,12 @@ public class AnnotationBrowserWidget extends Composite {
private Label labelSearchAnnotations;
private Label labelSearchFeatureValue;
private Button buttonApplyRUTA;
private Text textSearchTypes;
private Text textSearchAnnotations;
private Text textSearchFeatureValue;
private Text textApplyRUTA;
private AnnotationTextFilter textFilter;
private TreeViewerAlphabeticalSorter alphabeticalSorter;
......@@ -115,8 +124,29 @@ public class AnnotationBrowserWidget extends Composite {
@Override
public void keyReleased(KeyEvent e) {
setFeatureFilterString(textSearchFeatureValue.getText());
viewer.refresh();
// the editor should not surpress any annotations by default
editor.deleteAllSurpressedAndReload(true);
// viewer.refresh();
viewer.setInput(editor);
editor.updateWidget();
}
});
buttonApplyRUTA = new Button(this, SWT.NONE);
buttonApplyRUTA.setText("Apply RUTA");
textApplyRUTA = new Text(this, SWT.NONE | SWT.BORDER);
textApplyRUTA.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
textApplyRUTA.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
buttonApplyRUTA.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String rutaRule = textApplyRUTA.getText();
if (rutaRule != null && rutaRule.trim().length() > 0) {
applyRuta(rutaRule);
}
}
});
......@@ -248,6 +278,17 @@ public class AnnotationBrowserWidget extends Composite {
};
actionSetToModus.setText("Set to Modus");
menuMgr.add(actionSetToModus);
Action actionResetModus = new Action() {
@Override
public void run() {
editor.resetMode();
renewPage();
}
};
actionResetModus.setText("Reset Mode!");
menuMgr.add(actionResetModus);
}
}
});
......@@ -325,10 +366,9 @@ public class AnnotationBrowserWidget extends Composite {
}
}
if (firstElement instanceof AnnotationFS) {
if (firstElement instanceof AnnotationImpl) {
AnnotationImpl anno = (AnnotationImpl) firstElement;
AnnotationFS anno = (AnnotationFS) firstElement;
editor.highlightRange(anno.getBegin(), anno.getEnd() - anno.getBegin(), true);
}
......@@ -348,6 +388,7 @@ public class AnnotationBrowserWidget extends Composite {
private void addTreeMouseListener() {
viewer.getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
......@@ -355,6 +396,15 @@ public class AnnotationBrowserWidget extends Composite {
IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
Object firstElement = sel.getFirstElement();
if(firstElement instanceof TypeStyleDataStructure){
TypeStyleDataStructure tsds = (TypeStyleDataStructure) firstElement;
if(editor.getActualSelectedText()!=null){
AnnotationFS fs = editor.getCas().createAnnotation(tsds.getAnnotationType(), editor.getActualSelectedText().x, editor.getActualSelectedText().y);
editor.addAnnotation(fs);
}
}
if (firstElement instanceof FeatureValueWrapper) {
......@@ -412,7 +462,7 @@ public class AnnotationBrowserWidget extends Composite {
}
public void setNameFilterString(String filterString) {
this.textFilter.setSearchText(filterString,editor);
this.textFilter.setSearchText(filterString, editor);
}
public void setTypeFilterString(String filterString) {
......@@ -420,10 +470,10 @@ public class AnnotationBrowserWidget extends Composite {
}
public void setFeatureFilterString(String filterString) {
this.annoFeatureFilter.setSearchText(filterString,editor);
this.annoFeatureFilter.setSearchText(filterString, editor);
this.editor.updateWidget();
}
public void renewPage() {
......@@ -433,7 +483,6 @@ public class AnnotationBrowserWidget extends Composite {
Object[] expandedElements = viewer.getExpandedElements();
viewer.refresh();
// TODO not working because the expanded element might be changed during
// this process and therefore cannot be expanded properly
......@@ -489,4 +538,39 @@ public class AnnotationBrowserWidget extends Composite {
editor.removeAnnotation(toDelete.get(0));
}
}
private void applyRuta(String rule) {
// delete all eval annotation beforehand
List<AnnotationFS> evalAnnos = new ArrayList<>();
for (AnnotationFS a : editor.getCas()
.getAnnotationIndex(editor.getCas().getTypeSystem().getType("de.uniwue.medIE.Eval"))) {
evalAnnos.add(a);
}
for (AnnotationFS a : evalAnnos) {
editor.getCas().removeFsFromIndexes(a);
}
String[] elements = rule.split(" ");
try {
Ruta.apply(editor.getCas(), rule + "{->MARK(Eval,1," + elements.length + ")};");
} catch (AnalysisEngineProcessException | InvalidXMLException | ResourceInitializationException
| ResourceConfigurationException | IOException | URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// delete all ruta stuff
List<AnnotationFS> annos = new ArrayList<>();
for (AnnotationFS a : editor.getCas().getAnnotationIndex()) {
if (a.getType().getName().contains(".ruta.")) {
annos.add(a);
}
}
for (AnnotationFS a : annos) {
editor.getCas().removeFsFromIndexes(a);
}
viewer.setInput(editor);
}
}
......@@ -26,6 +26,7 @@ public class AnnotationFeatureFilter extends ViewerFilter {
if (!(element instanceof AnnotationFS))
return true;
// by default an annotation is visible
AnnotationFS p = (AnnotationFS) element;
if (searchString == null || searchString.length() == 0) {
......@@ -60,7 +61,7 @@ public class AnnotationFeatureFilter extends ViewerFilter {
String featureValueAsString = p.getFeatureValueAsString(featureByBaseName);
if (featureValueAsString != null && !featureValueAsString.matches(".*" + split2[1] + ".*")) {
if (featureValueAsString != null && !featureValueAsString.matches(split2[1])) {
if (editor != null) {
editor.surpressAnnotation(p, true);
}
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nappiPipelineConfiguration>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/openNLP/sentence/de-sent.bin</value>
</entry>
</configurationParams>
<engineClass>OpenNLPSentenceSplitter</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/openNLP/token/de-token.bin</value>
</entry>
</configurationParams>
<engineClass>OpenNLPTokenizer</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_EXECUTABLE_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/executables/treetagger/bin/tree-tagger.exe</value>
</entry>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/treetagger/pos/german-utf8.par</value>
</entry>
</configurationParams>
<engineClass>TreeTaggerLemmatizer</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_EXECUTABLE_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/executables/treetagger/bin/tree-tagger.exe</value>
</entry>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/treetagger/pos/german-utf8.par</value>
</entry>
</configurationParams>
<engineClass>TreeTaggerPOSTagger</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/rft/german-pc-64bit-utf8.par</value>
</entry>
</configurationParams>
<engineClass>RFTTagger</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/kallimachos/DROCTagger/nerAllModel.bin</value>
</entry>
</configurationParams>
<engineClass>DROCTagger</engineClass>
<reader>false</reader>
</engines>
</nappiPipelineConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<nappiPipelineConfiguration>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/openNLP/sentence/de-sent.bin</value>
</entry>
</configurationParams>
<engineClass>OpenNLPSentenceSplitter</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/openNLP/token/de-token.bin</value>
</entry>
</configurationParams>
<engineClass>OpenNLPTokenizer</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_EXECUTABLE_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/executables/treetagger/bin/tree-tagger.exe</value>
</entry>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/treetagger/pos/german-utf8.par</value>
</entry>
</configurationParams>
<engineClass>TreeTaggerLemmatizer</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_EXECUTABLE_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/executables/treetagger/bin/tree-tagger.exe</value>
</entry>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/treetagger/pos/german-utf8.par</value>
</entry>
</configurationParams>
<engineClass>TreeTaggerPOSTagger</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/rft/german-pc-64bit-utf8.par</value>
</entry>
</configurationParams>
<engineClass>RFTTagger</engineClass>
<reader>false</reader>
</engines>
<engines>
<configurationParams>
<entry>
<key>PARAM_MODEL_LOCATION</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">http://ki.informatik.uni-wuerzburg.de/nappi/nappiOnlineRepository/models/kallimachos/DROCTagger/nerAllModel.bin</value>
</entry>
</configurationParams>
<engineClass>DROCTagger</engineClass>
<reader>false</reader>
</engines>
</nappiPipelineConfiguration>
......@@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import de.uniwue.mk.athen.textwidget.struct.AnnoStyle;
import de.uniwue.mk.athen.textwidget.struct.EditorLine;
import de.uniwue.mk.kall.athen.widget.editor.EEditorEvent;
import de.uniwue.mk.kall.editorPainting.paintingstrategies.specialized.DependencyDrawingStrategy;
import de.uniwue.mkrug.kall.typesystemutil.Util_impl;
......@@ -106,7 +105,6 @@ public class DependencyParseAnalyzer extends AEditorSubordinateTextWidgetAnalyze
}
}
}
@Override
......@@ -191,8 +189,9 @@ public class DependencyParseAnalyzer extends AEditorSubordinateTextWidgetAnalyze
this.analyzerWidget.changeStyle(this.typeDepParseNewCAS, style2);
this.analyzerWidget.getWidget()
.setTopMargin(super.overlay.getClientArea().height
- analyzerWidget.getWidget().getEditorLines().get(0).getLineHeight()*2-10-DependencyDrawingStrategy.ANCHOR_HEIGHT);
.setTopMargin(super.overlay.getClientArea().height
- analyzerWidget.getWidget().getEditorLines().get(0).getLineHeight