Author: pkluegl Date: Sun Jun 30 16:54:36 2013 New Revision: 1498154 URL: http://svn.apache.org/r1498154 Log: no jira - smaller modifications - added copy/paste to constraint view - catch exception in measures for constraints - fixed default target types in testing view
Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java?rev=1498154&r1=1498153&r2=1498154&view=diff ============================================================================== --- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java (original) +++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/ui/ConstraintSelectComposite.java Sun Jun 30 16:54:36 2013 @@ -44,6 +44,11 @@ import org.eclipse.jface.viewers.TableVi import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; @@ -63,6 +68,8 @@ import org.eclipse.ui.IMemento; public class ConstraintSelectComposite extends Composite implements ISelectionChangedListener { + private Clipboard clipboard; + private Button constraintButtonRuta; private Button constraintButtonRutaList; @@ -102,6 +109,7 @@ public class ConstraintSelectComposite e public ConstraintSelectComposite(Composite parent, int style) { super(parent, style); initGui(); + clipboard = new Clipboard(parent.getDisplay()); comparatorFactory = new CDEComparatorFactory(); } @@ -243,6 +251,25 @@ public class ConstraintSelectComposite e tableFormData.bottom = new FormAttachment(100, 0); table.setLayoutData(tableFormData); + table.addKeyListener(new KeyListener() { + + public void keyPressed(KeyEvent e) { + if (((e.stateMask & SWT.CTRL) == SWT.CTRL) && (e.keyCode == 'c')) { + String output = ""; + TableItem[] items = table.getSelection(); + for (TableItem item : items) { + ConstraintData data = (ConstraintData) item.getData(); + output = output + data.getConstraint().getData() + "\n"; + } + clipboard.setContents(new Object[] { output }, + new Transfer[] { TextTransfer.getInstance() }); + } + } + + public void keyReleased(KeyEvent arg0) { + } + }); + tableViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java?rev=1498154&r1=1498153&r2=1498154&view=diff ============================================================================== --- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java (original) +++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/cde/utils/EvaluationMeasures.java Sun Jun 30 16:54:36 2013 @@ -56,7 +56,11 @@ public class EvaluationMeasures { DecimalFormat instance = (DecimalFormat) DecimalFormat.getInstance(Locale.US); instance.applyPattern("#.####"); String format = instance.format(d); - return Double.valueOf(format); + try { + return Double.valueOf(format); + } catch (Exception e) { + } + return d; } public static double cosine(double[] a1, double[] a2) { Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java?rev=1498154&r1=1498153&r2=1498154&view=diff ============================================================================== --- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java (original) +++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java Sun Jun 30 16:54:36 2013 @@ -111,7 +111,7 @@ public class RerunActionHandler implemen private List<String> includedTypes; RerunHandlerJob(ExecutionEvent event, String scriptName, String viewCasName, - List<String> excludedTypes, List<String> includedTypes) { + List<String> excludedTypes, List<String> includedTypes) { super("Testing " + scriptName + "..."); this.event = event; this.viewCasName = viewCasName; @@ -175,30 +175,41 @@ public class RerunActionHandler implemen testCas = testCas.getView(viewCasName); runCas = runCas.getView(viewCasName); - if(includedTypes != null && !includedTypes.isEmpty()) { + if (includedTypes != null && !includedTypes.isEmpty()) { excludedTypes = new ArrayList<String>(); - List<Type> types = runCas.getTypeSystem().getProperlySubsumedTypes(runCas.getAnnotationType()); + List<Type> types = runCas.getTypeSystem().getProperlySubsumedTypes( + runCas.getAnnotationType()); for (Type type : types) { - if(!includedTypes.contains(type.getName())) { + if (!includedTypes.contains(type.getName())) { excludedTypes.add(type.getName()); } } } - + + List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); if (excludedTypes != null && !excludedTypes.isEmpty()) { - List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); AnnotationIndex<AnnotationFS> annotationIndex = runCas.getAnnotationIndex(); for (AnnotationFS annotationFS : annotationIndex) { Type type = annotationFS.getType(); String typeName = type.getName(); - if(includedTypes.contains(typeName)|| !excludedTypes.contains(typeName)) { - if (type != null && runCas.getTypeSystem().subsumes(runCas.getAnnotationType(), type)) { - toRemove.add(annotationFS); + if (includedTypes.contains(typeName) || !excludedTypes.contains(typeName)) { + if (type != null + && runCas.getTypeSystem().subsumes(runCas.getAnnotationType(), type)) { + toRemove.add(annotationFS); } } } - for (AnnotationFS annotationFS : toRemove) { - runCas.removeFsFromIndexes(annotationFS); + } + if (excludedTypes != null && excludedTypes.isEmpty() && includedTypes != null + && includedTypes.isEmpty()) { + AnnotationIndex<AnnotationFS> annotationIndex = runCas.getAnnotationIndex(); + for (AnnotationFS each : annotationIndex) { + toRemove.add(each); + } + } + for (AnnotationFS each : toRemove) { + if(!runCas.getDocumentAnnotation().equals(each)) { + runCas.removeFsFromIndexes(each); } } @@ -295,7 +306,7 @@ public class RerunActionHandler implemen String viewCasName = debugPage.getSelectedViewCasName(); String scriptName = debugPage.getResource().getLocation().lastSegment(); RerunHandlerJob job = new RerunHandlerJob(event, scriptName, viewCasName, - debugPage.getExcludedTypes(),debugPage.getIncludedTypes()); + debugPage.getExcludedTypes(), debugPage.getIncludedTypes()); job.addJobChangeListener(new DebugJobChangeAdapter(debugPage) { });