You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/06/12 16:27:51 UTC

svn commit: r1492221 - in /uima/sandbox/ruta/trunk/ruta-ep-addons: ./ icons/ src/main/java/org/apache/uima/ruta/testing/ui/handlers/ src/main/java/org/apache/uima/ruta/testing/ui/views/

Author: pkluegl
Date: Wed Jun 12 14:27:51 2013
New Revision: 1492221

URL: http://svn.apache.org/r1492221
Log:
UIMA-2986
- added select included types
- removed other buttons (not working or not used)

Added:
    uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_down.png   (with props)
    uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_up.png   (with props)
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java
Modified:
    uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/RerunActionHandler.java
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectTypesDialog.java
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedExcludedTypesHandler.java
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/TestViewPage.java

Added: uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_down.png
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_down.png?rev=1492221&view=auto
==============================================================================
Binary file - no diff available.

Propchange: uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_down.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_up.png
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_up.png?rev=1492221&view=auto
==============================================================================
Binary file - no diff available.

Propchange: uima/sandbox/ruta/trunk/ruta-ep-addons/icons/thumb_up.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml?rev=1492221&r1=1492220&r2=1492221&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/plugin.xml Wed Jun 12 14:27:51 2013
@@ -109,43 +109,28 @@ under the License.
                commandId="org.apache.uima.ruta.testing.rerun"
                icon="icons/13555.actionengine_play.gif"
                label="Rerun Tests"
-               style="push">
-            <visibleWhen
-                  checkEnabled="true">
-            </visibleWhen>
-         </command>
-         <command
-               commandId="org.apache.uima.ruta.testing.PreviousTestCase"
-               icon="icons/back.gif"
-               label="Previous Test Case"
-               style="push">
-            <visibleWhen
-                  checkEnabled="true">
-            </visibleWhen>
-         </command>
-         <command
-               commandId="org.apache.uima.ruta.testing.nextTestCase"
-               icon="icons/forward.gif"
-               label="Next Test Case"
-               style="push">
+               style="push"
+               tooltip="Rerun Tests">
             <visibleWhen
                   checkEnabled="true">
             </visibleWhen>
          </command>
          <command
-               commandId="org.apache.uima.ruta.testing.LoadFolderCommand"
-               icon="icons/add.gif"
-               label="Load all test files from selected folder"
-               style="push">
+               commandId="org.apache.uima.ruta.testing.excludeTypes"
+               icon="icons/thumb_down.png"
+               label="Select excluded types"
+               style="push"
+               tooltip="Select excluded types">
             <visibleWhen
                   checkEnabled="true">
             </visibleWhen>
          </command>
          <command
-               commandId="org.apache.uima.ruta.testing.excludeTypes"
-               icon="icons/exclamation.png"
-               label="Select excluded types"
-               style="push">
+               commandId="org.apache.uima.ruta.testing.includeTypes"
+               icon="icons/thumb_up.png"
+               label="Select included types"
+               style="push"
+               tooltip="Select included types">
             <visibleWhen
                   checkEnabled="true">
             </visibleWhen>
@@ -154,7 +139,8 @@ under the License.
                commandId="org.apache.uima.ruta.testing.selectEvaluator"
                icon="icons/evaluator.gif"
                label="Select Evaluator"
-               style="push">
+               style="push"
+               tooltip="Select evaluator">
             <visibleWhen
                   checkEnabled="true">
             </visibleWhen>
@@ -162,6 +148,7 @@ under the License.
          <command
                commandId="org.apache.uima.ruta.testing.ExportTabel"
                icon="icons/10892.resource_persp.gif"
+               label="to CSV"
                style="push">
             <visibleWhen
                   checkEnabled="true">
@@ -207,6 +194,11 @@ under the License.
             name="Select excluded types">
       </command>
       <command
+            defaultHandler="org.apache.uima.ruta.testing.ui.handlers.SelectedIncludedTypesHandler"
+            id="org.apache.uima.ruta.testing.includeTypes"
+            name="Select included types">
+      </command>
+      <command
             defaultHandler="org.apache.uima.ruta.testing.ui.handlers.SelectEvaluatorHandler"
             id="org.apache.uima.ruta.testing.selectEvaluator"
             name="Select Evaluator">

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=1492221&r1=1492220&r2=1492221&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 Wed Jun 12 14:27:51 2013
@@ -25,7 +25,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -107,14 +106,17 @@ public class RerunActionHandler implemen
 
     private final String viewCasName;
 
-    private final List<String> excludedTypes;
+    private List<String> excludedTypes;
+
+    private List<String> includedTypes;
 
     RerunHandlerJob(ExecutionEvent event, String scriptName, String viewCasName,
-            List<String> excludedTypes) {
+            List<String> excludedTypes,  List<String> includedTypes) {
       super("Testing " + scriptName + "...");
       this.event = event;
       this.viewCasName = viewCasName;
       this.excludedTypes = excludedTypes;
+      this.includedTypes = includedTypes;
       setUser(true);
     }
 
@@ -173,6 +175,17 @@ public class RerunActionHandler implemen
           testCas = testCas.getView(viewCasName);
           runCas = runCas.getView(viewCasName);
 
+          if(includedTypes != null && !includedTypes.isEmpty()) {
+            excludedTypes = new ArrayList<String>();
+            List<Type> types = runCas.getTypeSystem().getProperlySubsumedTypes(runCas.getAnnotationType());
+            for (Type type : types) {
+              if(!includedTypes.contains(type.getName())) {
+                excludedTypes.add(type.getName());
+              }
+            }
+          }
+          
+          
           if (excludedTypes != null && !excludedTypes.isEmpty()) {
             List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>();
             for (String eachType : excludedTypes) {
@@ -282,7 +295,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.getExcludedTypes(),debugPage.getIncludedTypes());
 
     job.addJobChangeListener(new DebugJobChangeAdapter(debugPage) {
     });

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=1492221&r1=1492220&r2=1492221&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 Wed Jun 12 14:27:51 2013
@@ -67,14 +67,21 @@ public class SelectTypesDialog extends D
 
   private List<String> types;
 
-  private List<String> excluded;
+  private List<String> selectedTypes;
 
-  public SelectTypesDialog(Shell shell, List<String> types, TestViewPage owner) {
+  private boolean excluded;
+
+  public SelectTypesDialog(Shell shell, List<String> types, boolean excluded, TestViewPage owner) {
     super(shell);
     this.shell = shell;
     this.types = types;
     this.owner = owner;
-    this.excluded = owner.getExcludedTypes();
+    if(excluded) {
+      this.selectedTypes = owner.getExcludedTypes();
+    } else {
+      this.selectedTypes = owner.getIncludedTypes();
+    }
+    this.excluded = excluded;
     createDialogArea();
     init();
   }
@@ -140,7 +147,7 @@ public class SelectTypesDialog extends D
 
     TableItem[] items = matchingTypesUI.getItems();
     for (TableItem tableItem : items) {
-      if (excluded.contains(tableItem.getText())) {
+      if (selectedTypes.contains(tableItem.getText())) {
         tableItem.setChecked(true);
       }
     }
@@ -155,7 +162,11 @@ public class SelectTypesDialog extends D
             selection.add(tableItem.getText());
           }
         }
-        owner.setExcludedTypes(selection);
+        if(excluded) {
+          owner.setExcludedTypes(selection);
+        } else {
+          owner.setIncludedTypes(selection);
+        }
         shell.dispose();
       }
     });
@@ -227,7 +238,7 @@ public class SelectTypesDialog extends D
         }
         TableItem item = new TableItem(matchingTypesUI, SWT.NULL);
         item.setText(type);
-        if (excluded.contains(item.getText())) {
+        if (selectedTypes.contains(item.getText())) {
           item.setChecked(true);
         }
 
@@ -244,9 +255,9 @@ public class SelectTypesDialog extends D
       if (item instanceof TableItem) {
         TableItem ti = (TableItem) item;
         if (ti.getChecked()) {
-          excluded.add(ti.getText());
+          selectedTypes.add(ti.getText());
         } else {
-          excluded.remove(ti.getText());
+          selectedTypes.remove(ti.getText());
         }
       }
     }

Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedExcludedTypesHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedExcludedTypesHandler.java?rev=1492221&r1=1492220&r2=1492221&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedExcludedTypesHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedExcludedTypesHandler.java Wed Jun 12 14:27:51 2013
@@ -92,7 +92,7 @@ public class SelectedExcludedTypesHandle
     Display display = Display.getDefault();
     Shell shell = new Shell(display, SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
     shell.setText("Excluded types");
-    new SelectTypesDialog(shell, types, activePage);
+    new SelectTypesDialog(shell, types, true, activePage);
     return null;
   }
 

Added: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java?rev=1492221&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java Wed Jun 12 14:27:51 2013
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.testing.ui.handlers;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.ruta.addons.RutaAddonsPlugin;
+import org.apache.uima.ruta.ide.core.builder.RutaProjectUtils;
+import org.apache.uima.ruta.testing.ui.views.TestPageBookView;
+import org.apache.uima.ruta.testing.ui.views.TestViewPage;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class SelectedIncludedTypesHandler implements IHandler {
+
+  public void addHandlerListener(IHandlerListener handlerListener) {
+
+  }
+
+  public void dispose() {
+
+  }
+
+  public Object execute(ExecutionEvent event) throws ExecutionException {
+    TestPageBookView debugView = (TestPageBookView) HandlerUtil.getActivePart(event);
+    TestViewPage activePage = (TestViewPage) debugView.getCurrentPage();
+    IResource resource = activePage.getResource();
+    IPath location = resource.getLocation();
+    String preFilePath = location.toPortableString();
+    File preFile = new File(preFilePath);
+    if (preFile.exists() == false || StringUtils.isEmpty(preFilePath)) {
+      printErrorDialog("The preprocessing file was not found!");
+      return null;
+    }
+    TypeSystemDescription defaultTypeSystemDescription = null;
+    List<String> types = new ArrayList<String>();
+    try {
+      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location,
+              resource.getProject()).toPortableString();
+
+      defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+              new XMLInputSource(new File(tsDesc)));
+      defaultTypeSystemDescription.resolveImports();
+      TypeDescription[] systemTypes = defaultTypeSystemDescription.getTypes();
+      for (TypeDescription typeDescription : systemTypes) {
+        types.add(typeDescription.getName());
+      }
+      Collections.sort(types);
+    } catch (InvalidXMLException e) {
+      RutaAddonsPlugin.error(e);
+    } catch (IOException e) {
+      RutaAddonsPlugin.error(e);
+    }
+    Display display = Display.getDefault();
+    Shell shell = new Shell(display, SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
+    shell.setText("Included types");
+    new SelectTypesDialog(shell, types, false, activePage);
+    return null;
+  }
+
+  public boolean isEnabled() {
+    return true;
+  }
+
+  public boolean isHandled() {
+    return true;
+  }
+
+  public static void printErrorDialog(String error) {
+    ErrorDialog.openError(Display.getCurrent().getActiveShell(), "File not Found!", error,
+            new Status(IStatus.ERROR, "-1", "File not found!"));
+  }
+
+  public void removeHandlerListener(IHandlerListener handlerListener) {
+
+  }
+
+}

Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/TestViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/TestViewPage.java?rev=1492221&r1=1492220&r2=1492221&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/TestViewPage.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/views/TestViewPage.java Wed Jun 12 14:27:51 2013
@@ -58,7 +58,6 @@ import org.eclipse.jface.viewers.IStruct
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.dnd.DND;
@@ -73,7 +72,6 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.IActionBars;
@@ -86,32 +84,26 @@ import org.eclipse.ui.part.Page;
 
 public class TestViewPage extends Page implements IPageBookViewPage {
 
-  private Display display;
-
   private Caretaker caretaker;
 
   private Composite overlay;
 
   private IResource script = null;
 
-  private TreeViewer fpViewer;
-
   private InfoPanel tInfoPanel;
 
   private TableViewer listviewer;
 
   private SashForm sash;
 
-  private SashForm innerSash;
-
   private TableViewer tableViewer;
 
   private IPropertyChangeListener propertyChangeListener;
 
-  private List<IResource> tempFiles;
-
   private List<String> excludedTypes = new ArrayList<String>();
 
+  private List<String> includedTypes = new ArrayList<String>();
+  
   private ListLabelProvider labelProvider;
 
   public TestViewPage(Composite parent, IResource r) {
@@ -119,7 +111,6 @@ public class TestViewPage extends Page i
     this.script = r;
     this.overlay = new Composite(parent, 0);
     this.caretaker = new Caretaker();
-    this.display = parent.getDisplay();
     this.propertyChangeListener = null;
   }
 
@@ -201,7 +192,7 @@ public class TestViewPage extends Page i
         Object obj = event.getSelection();
         if (obj instanceof IStructuredSelection) {
           StructuredSelection selection = (StructuredSelection) obj;
-          Iterator iterator = selection.iterator();
+          Iterator<?> iterator = selection.iterator();
           while (iterator.hasNext()) {
             Object element = iterator.next();
             if (element instanceof TestCasData) {
@@ -220,7 +211,7 @@ public class TestViewPage extends Page i
         Object obj = event.getSelection();
         if (obj instanceof IStructuredSelection) {
           StructuredSelection selection = (StructuredSelection) obj;
-          Iterator iterator = selection.iterator();
+          Iterator<?>iterator = selection.iterator();
           while (iterator.hasNext()) {
             Object element = iterator.next();
             if (element instanceof TestCasData) {
@@ -466,8 +457,6 @@ public class TestViewPage extends Page i
 
     IFolder testFolder = project.getFolder(testFolderPackagePath);
     IResource[] resourceArray;
-    ArrayList<String> viewNames = new ArrayList<String>();
-
     try {
       resourceArray = testFolder.members();
 
@@ -539,10 +528,6 @@ public class TestViewPage extends Page i
     return tInfoPanel.getSelectedViewCasName();
   }
 
-  private List<IResource> getTempFiles() {
-    return tempFiles;
-  }
-
   public void setExcludedTypes(List<String> excludedTypes) {
     this.excludedTypes = excludedTypes;
   }
@@ -550,4 +535,12 @@ public class TestViewPage extends Page i
   public List<String> getExcludedTypes() {
     return excludedTypes;
   }
+
+  public void setIncludedTypes(List<String> includedTypes) {
+    this.includedTypes = includedTypes;
+  }
+  
+  public List<String> getIncludedTypes() {
+    return includedTypes;
+  }
 }