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/08/30 12:24:30 UTC

svn commit: r1518931 - in /uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta: check/ testing/ui/handlers/

Author: pkluegl
Date: Fri Aug 30 10:24:29 2013
New Revision: 1518931

URL: http://svn.apache.org/r1518931
Log:
UIMA-3235
- replaced dialog implementation with ElementListSelectionDialog

Removed:
    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/testing/ui/handlers/SelectTypesDialog.java
Modified:
    uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesHandler.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/handlers/SelectedIncludedTypesHandler.java

Modified: uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesHandler.java?rev=1518931&r1=1518930&r2=1518931&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/check/SelectTypesHandler.java Fri Aug 30 10:24:29 2013
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.uima.UIMAFramework;
@@ -36,10 +37,13 @@ import org.eclipse.core.commands.Executi
 import org.eclipse.core.commands.IHandler;
 import org.eclipse.core.commands.IHandlerListener;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 public class SelectTypesHandler implements IHandler {
@@ -67,10 +71,41 @@ public class SelectTypesHandler implemen
         types.add(typeDescription.getName());
       }
       Collections.sort(types);
+
       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, composite);
+
+      ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
+      String[] allTypes = types.toArray(new String[0]);
+      String[] selectedTypes = composite.getSelectedTypes().toArray(new String[0]);
+      dialog.setIgnoreCase(false);
+      dialog.setMessage("Select types (* = any string, ? = any char)");
+      dialog.setHelpAvailable(false);
+      // dialog.setEmptySelectionMessage("Empty selection");
+      dialog.setEmptyListMessage("no types available");
+      dialog.setMultipleSelection(true);
+      dialog.setInitialSelections(selectedTypes);
+      dialog.setElements(allTypes);
+      dialog.setTitle("Type Selection");
+      int open = dialog.open();
+      if (open == Window.OK) {
+        Object[] result = dialog.getResult();
+        List<String> list = new LinkedList<String>();
+        for (Object object : result) {
+          if (object instanceof String) {
+            list.add((String) object);
+          }
+        }
+        composite.setSelectedTypes(list);
+        return Status.OK_STATUS;
+      }
+
+      // shell.setText("Included types");
+      // SelectTypesDialog dialog = new SelectTypesDialog(shell, types,
+      // composite.getSelectedTypes());
+      // if (dialog.open() != Window.OK) {
+      // composite.setSelectedTypes(dialog.getSelectedTypes());
+      // }
     } catch (InvalidXMLException e) {
       RutaAddonsPlugin.error(e);
       return Status.CANCEL_STATUS;

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=1518931&r1=1518930&r2=1518931&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 Fri Aug 30 10:24:29 2013
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
@@ -44,9 +45,12 @@ 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.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 public class SelectedExcludedTypesHandler implements IHandler {
@@ -73,8 +77,8 @@ public class SelectedExcludedTypesHandle
     TypeSystemDescription defaultTypeSystemDescription = null;
     List<String> types = new ArrayList<String>();
     try {
-      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location,
-              resource.getProject()).toPortableString();
+      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location, resource.getProject())
+              .toPortableString();
 
       defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(
               new XMLInputSource(new File(tsDesc)));
@@ -89,11 +93,34 @@ public class SelectedExcludedTypesHandle
     } 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("Excluded types");
-    new SelectTypesDialog(shell, types, true, activePage);
-    return null;
+
+    ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
+    String[] allTypes = types.toArray(new String[0]);
+    String[] selectedTypes = activePage.getExcludedTypes().toArray(new String[0]);
+    dialog.setIgnoreCase(false);
+    dialog.setMessage("Select excluded types (* = any string, ? = any char)");
+    dialog.setHelpAvailable(false);
+    // dialog.setEmptySelectionMessage("Empty selection");
+    dialog.setEmptyListMessage("no types available");
+    dialog.setMultipleSelection(true);
+    dialog.setInitialSelections(selectedTypes);
+    dialog.setElements(allTypes);
+    dialog.setTitle("Excluded Type Selection");
+    int open = dialog.open();
+    if (open == Window.OK) {
+      Object[] result = dialog.getResult();
+      List<String> list = new LinkedList<String>();
+      for (Object object : result) {
+        if (object instanceof String) {
+          list.add((String) object);
+        }
+      }
+      activePage.setExcludedTypes(list);
+    }
+    return Status.OK_STATUS;
   }
 
   public boolean isEnabled() {

Modified: 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=1518931&r1=1518930&r2=1518931&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/testing/ui/handlers/SelectedIncludedTypesHandler.java Fri Aug 30 10:24:29 2013
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.commons.lang3.StringUtils;
@@ -44,9 +45,12 @@ 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.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 public class SelectedIncludedTypesHandler implements IHandler {
@@ -91,9 +95,31 @@ public class SelectedIncludedTypesHandle
     }
     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;
+    
+    ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
+    String[] allTypes = types.toArray(new String[0]);
+    String[] selectedTypes = activePage.getIncludedTypes().toArray(new String[0]);
+    dialog.setIgnoreCase(false);
+    dialog.setMessage("Select included types (* = any string, ? = any char)");
+    dialog.setHelpAvailable(false);
+    // dialog.setEmptySelectionMessage("Empty selection");
+    dialog.setEmptyListMessage("no types available");
+    dialog.setMultipleSelection(true);
+    dialog.setInitialSelections(selectedTypes);
+    dialog.setElements(allTypes);
+    dialog.setTitle("Included Type Selection");
+    int open = dialog.open();
+    if (open == Window.OK) {
+      Object[] result = dialog.getResult();
+      List<String> list = new LinkedList<String>();
+      for (Object object : result) {
+        if (object instanceof String) {
+          list.add((String) object);
+        }
+      }
+      activePage.setIncludedTypes(list);
+    }
+    return Status.OK_STATUS;
   }
 
   public boolean isEnabled() {