You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2009/05/21 11:22:19 UTC

svn commit: r777027 - in /incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview: AnnotatorActionGroup.java ConsumerCorpusActionGroup.java CorpusExplorerUtil.java UimaRefactorActionGroup.java

Author: joern
Date: Thu May 21 09:22:18 2009
New Revision: 777027

URL: http://svn.apache.org/viewvc?rev=777027&view=rev
Log:
UIMA-546: Replaced deprecated method

Modified:
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/UimaRefactorActionGroup.java

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java?rev=777027&r1=777026&r2=777027&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java Thu May 21 09:22:18 2009
@@ -68,7 +68,7 @@
 
     LinkedList<DocumentElement> documentElements = new LinkedList<DocumentElement>();
 
-    if (!CorpusExplorerUtil.isContaingNLPProjectOrNonNLPResources(selection)) {
+    if (CorpusExplorerUtil.isContaingOnlyNlpElements(selection)) {
       Iterator resources = selection.iterator();
       while (resources.hasNext()) {
         Object resource = resources.next();

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java?rev=777027&r1=777026&r2=777027&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/ConsumerCorpusActionGroup.java Thu May 21 09:22:18 2009
@@ -54,7 +54,7 @@
   public void fillContextMenu(IMenuManager menu) {
     IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
 
-    if (!CorpusExplorerUtil.isContaingNLPProjectOrNonNLPResources(selection)) {
+    if (CorpusExplorerUtil.isContaingOnlyNlpElements(selection)) {
       // TODO: add here also single documents
       LinkedList<CorpusElement> corpora = new LinkedList<CorpusElement>();
 

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java?rev=777027&r1=777026&r2=777027&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java Thu May 21 09:22:18 2009
@@ -21,77 +21,60 @@
 
 import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.List;
 
 import org.apache.uima.caseditor.core.model.INlpElement;
-import org.apache.uima.caseditor.core.model.NlpProject;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 
-final class CorpusExplorerUtil
-{
-    /**
-     * Avoids instanciation of this utility class
-     */
-    private CorpusExplorerUtil()
-    {
-        // overridden to change access to private
+/**
+ * Utility class for the corpus explorer
+ */
+final class CorpusExplorerUtil {
+
+  /**
+   * Avoids instantiation of this utility class
+   */
+  private CorpusExplorerUtil() {
+    // overridden to change access to private
+  }
+
+  static IStructuredSelection convertNLPElementsToResources(IStructuredSelection selection) {
+
+    List<Object> newSelectionList = new LinkedList<Object>();
+
+    for (Iterator<?> elements = selection.iterator(); elements.hasNext();) {
+      Object element = elements.next();
+
+      if (element instanceof INlpElement) {
+        INlpElement nlpElement = (INlpElement) element;
+        newSelectionList.add(nlpElement.getResource());
+      } else {
+        newSelectionList.add(element);
+      }
     }
 
-	static IStructuredSelection convertNLPElementsToResources(
-			IStructuredSelection selection)
-	{
-
-		LinkedList<Object> newSelectionList = new LinkedList<Object>();
-
-        for (Iterator<?> elements = selection.iterator(); elements.hasNext();)
-        {
-			Object element = elements.next();
-
-			if (element instanceof INlpElement)
-			{
-				INlpElement nlpElement = (INlpElement) element;
-				newSelectionList.add(nlpElement.getResource());
-			}
-            else
-            {
-                newSelectionList.add(element);
-            }
-		}
-
-		return new StructuredSelection(newSelectionList);
-	}
-
-    /**
-     * TODO: Replace this method, the name is very ugly.
-     *
-     * @param selection
-     * @return true if NLPProject or NonNLPResource is included
-     *
-     * @deprecated
-     */
-    @Deprecated
-    static boolean isContaingNLPProjectOrNonNLPResources(
-            IStructuredSelection selection)
-    {
-        boolean isNLPProjectOrNonNLPResource = false;
-
-        for (Iterator<?> resources = selection.iterator() ;
-                resources.hasNext() && !isNLPProjectOrNonNLPResource;)
-        {
-            Object resource =  resources.next();
-
-            if (! (resource instanceof INlpElement))
-            {
-                isNLPProjectOrNonNLPResource = true;
-            }
-
-            // if nlp project return also
-            if ((resource instanceof NlpProject))
-            {
-                isNLPProjectOrNonNLPResource = true;
-            }
-        }
+    return new StructuredSelection(newSelectionList);
+  }
 
-        return isNLPProjectOrNonNLPResource;
+  /**
+   * TODO: Replace this method, the name is very ugly.
+   * 
+   * @param selection
+   * @return true if NLPProject or NonNLPResource is included
+   */
+  static boolean isContaingOnlyNlpElements(IStructuredSelection selection) {
+    boolean isContaingOnlyNlpElements = true;
+
+    for (Iterator<?> resources = selection.iterator(); resources.hasNext()
+            && isContaingOnlyNlpElements;) {
+      Object resource = resources.next();
+
+      if (!(resource instanceof INlpElement)) {
+        isContaingOnlyNlpElements = false;
+      }
     }
+
+    return isContaingOnlyNlpElements;
+  }
 }

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/UimaRefactorActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/UimaRefactorActionGroup.java?rev=777027&r1=777026&r2=777027&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/UimaRefactorActionGroup.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/corpusview/UimaRefactorActionGroup.java Thu May 21 09:22:18 2009
@@ -52,8 +52,8 @@
 
     LinkedList<DocumentElement> documentElements = new LinkedList<DocumentElement>();
 
-    if (!CorpusExplorerUtil.isContaingNLPProjectOrNonNLPResources(selection)) {
-      Iterator resources = selection.iterator();
+    if (CorpusExplorerUtil.isContaingOnlyNlpElements(selection)) {
+      Iterator<?> resources = selection.iterator();
       while (resources.hasNext()) {
         Object resource = resources.next();