Author: pkluegl
Date: Sat Jul 6 13:08:30 2013
New Revision: 1500254
URL: http://svn.apache.org/r1500254
Log:
UIMA-3029
- some small ui improvements: remember selection and check multiple types
Modified:
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesDialog.java
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/UpdateTaskHandler.java
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java
Modified:
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesDialog.java
URL:
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesDialog.java?rev=1500254&r1=1500253&r2=1500254&view=diff
==============================================================================
---
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesDialog.java
(original)
+++
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesDialog.java
Sat Jul 6 13:08:30 2013
@@ -243,6 +243,18 @@ public class SelectTypesDialog extends D
Widget item = event.item;
if (item instanceof TableItem) {
TableItem ti = (TableItem) item;
+ TableItem[] selection = matchingTypesUI.getSelection();
+ for (TableItem tableItem : selection) {
+ if(tableItem != ti) {
+ if (ti.getChecked()) {
+ tableItem.setChecked(true);
+ selectedTypes.add(tableItem.getText());
+ } else {
+ selectedTypes.remove(tableItem.getText());
+ tableItem.setChecked(false);
+ }
+ }
+ }
if (ti.getChecked()) {
selectedTypes.add(ti.getText());
} else {
Modified:
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/UpdateTaskHandler.java
URL:
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/UpdateTaskHandler.java?rev=1500254&r1=1500253&r2=1500254&view=diff
==============================================================================
---
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/UpdateTaskHandler.java
(original)
+++
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/UpdateTaskHandler.java
Sat Jul 6 13:08:30 2013
@@ -51,6 +51,7 @@ import org.eclipse.core.runtime.IProgres
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
@@ -69,23 +70,26 @@ public class UpdateTaskHandler implement
private String documentSink;
+ private AnnotationCheckTreeNode previousSelection;
+
CheckAnnotationUpdateTaskJob(String documentSource, String documentSink,
String typeSystem,
- AnnotationCheckComposite composite) {
+ AnnotationCheckComposite composite, AnnotationCheckTreeNode
previousSelection) {
super("Update annotation check task...");
this.documentSource = documentSource;
this.documentSink = documentSink;
this.typeSystem = typeSystem;
this.composite = composite;
+ this.previousSelection = previousSelection;
}
- CheckAnnotationUpdateTaskJob(AnnotationCheckComposite composite) {
+ CheckAnnotationUpdateTaskJob(AnnotationCheckComposite composite,
AnnotationCheckTreeNode previousSelection ) {
this(composite.getDocumentSource(), composite.getDocumentSink(),
composite.getTypeSystem(),
- composite);
+ composite, previousSelection);
}
public IStatus run(IProgressMonitor monitor) {
List<String> selectedTypes = composite.getSelectedTypes();
-
+
File dir = new File(documentSource);
File[] listFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File file, String string) {
@@ -162,7 +166,15 @@ public class UpdateTaskHandler implement
}
}
}
+ if(previousSelection != null) {
+ CheckElement element = previousSelection.getElement();
+ TreePath oldPath = getPathTo(element, root);
+ if(oldPath != null) {
+ treePath = oldPath;
+ }
+ }
final TreeSelection firstSelection = new TreeSelection(treePath);
+
cas.release();
composite.setOldDocs(docs);
composite.getDisplay().asyncExec(new Runnable() {
@@ -176,6 +188,43 @@ public class UpdateTaskHandler implement
return Status.OK_STATUS;
}
+ private TreePath getPathTo(CheckElement element, IAnnotationCheckTreeNode
root) {
+ AnnotationCheckTreeNode[] children = root.getChildren();
+ for (AnnotationCheckTreeNode eachDocNode : children) {
+ if(element instanceof CheckAnnotation) {
+ AnnotationCheckTreeNode[] children2 = eachDocNode.getChildren();
+ for (AnnotationCheckTreeNode eachANode : children2) {
+ if(isSameElement(eachANode.getElement(), element)) {
+ return new TreePath(new Object[] { root, eachDocNode,
eachANode});
+ }
+ }
+ } else {
+ if(isSameElement(eachDocNode.getElement(), element)) {
+ return new TreePath(new Object[] { root, eachDocNode});
+ }
+ }
+
+ }
+ return null;
+ }
+
+ private boolean isSameElement(CheckElement e1, CheckElement e2) {
+ if(e1 == null || e2 == null) {
+ return false;
+ }
+ if(e1 instanceof CheckAnnotation && e2 instanceof CheckAnnotation) {
+ CheckAnnotation ca1 = (CheckAnnotation) e1;
+ CheckAnnotation ca2 = (CheckAnnotation) e2;
+ return ca1.begin == ca2.begin && ca1.end == ca2.end &&
ca1.type.equals(ca2.type);
+ }
+ if(e1 instanceof CheckDocument && e2 instanceof CheckDocument) {
+ CheckDocument cd1 = (CheckDocument) e1;
+ CheckDocument cd2 = (CheckDocument) e2;
+ return cd1.source.equals(cd2.source);
+ }
+ return false;
+ }
+
private boolean documentAlreadyDoneforTypes(CheckDocument element,
List<String> selectedTypes) {
if(element.checkedTypes.isEmpty() && !selectedTypes.isEmpty()) {
return false;
@@ -228,7 +277,9 @@ public class UpdateTaskHandler implement
acView = (AnnotationCheckView)
HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench()
.getActiveWorkbenchWindow().getActivePage().showView(AnnotationCheckView.ID);
AnnotationCheckComposite composite = (AnnotationCheckComposite)
acView.getComposite();
- CheckAnnotationUpdateTaskJob job = new
CheckAnnotationUpdateTaskJob(composite);
+ TreeSelection selection = (TreeSelection)
composite.getTreeViewer().getSelection();
+ AnnotationCheckTreeNode previousSelection = (AnnotationCheckTreeNode)
selection.getFirstElement();
+ CheckAnnotationUpdateTaskJob job = new
CheckAnnotationUpdateTaskJob(composite, previousSelection);
job.schedule();
} catch (Exception e) {
RutaAddonsPlugin.error(e);
Modified:
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java
URL:
http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java?rev=1500254&r1=1500253&r2=1500254&view=diff
==============================================================================
---
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java
(original)
+++
uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java
Sat Jul 6 13:08:30 2013
@@ -254,6 +254,18 @@ public class SelectTypesDialog extends D
Widget item = event.item;
if (item instanceof TableItem) {
TableItem ti = (TableItem) item;
+ TableItem[] selection = matchingTypesUI.getSelection();
+ for (TableItem tableItem : selection) {
+ if(tableItem != ti) {
+ if (ti.getChecked()) {
+ tableItem.setChecked(true);
+ selectedTypes.add(tableItem.getText());
+ } else {
+ selectedTypes.remove(tableItem.getText());
+ tableItem.setChecked(false);
+ }
+ }
+ }
if (ti.getChecked()) {
selectedTypes.add(ti.getText());
} else {