You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/09/11 19:44:42 UTC

svn commit: r574647 - in /incubator/uima/sandbox/trunk/CasEditor/src: main/java/org/apache/uima/caseditor/core/model/ main/java/org/apache/uima/caseditor/editor/ main/java/org/apache/uima/caseditor/ui/action/ main/java/org/apache/uima/caseditor/ui/prop...

Author: twgoetz
Date: Tue Sep 11 10:44:42 2007
New Revision: 574647

URL: http://svn.apache.org/viewvc?rev=574647&view=rev
Log:
Jira UIMA-558: apply UIMA-558.patch and UIMA-558-2.patch.

https://issues.apache.org/jira/browse/UIMA-558

Modified:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java
    incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/DefectiveNlpModelTest.java
    incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java Tue Sep 11 10:44:42 2007
@@ -63,7 +63,6 @@
 
 	if (corpus == null || documentFile == null) {
 	  throw new IllegalArgumentException("Parameters must not be null!");
-
 	}
 
     mParent = corpus;
@@ -95,10 +94,10 @@
   /**
    * Retrieves the working copy.
    *
-   * @return the working copy
    * @throws CoreException
+   * @return the working copy
    */
-  public IDocument getDocument() throws CoreException {
+  public IDocument getDocument(boolean reload) throws CoreException {
 
     NlpProject project = (NlpProject) mParent.getParent();
 
@@ -110,7 +109,7 @@
 
 	  DocumentUimaImpl document = mWorkingCopy.get();
 
-    if (document == null) {
+    if (reload || document == null) {
 
     	InputStream in = mDocumentFile.getContents();
 
@@ -136,7 +135,7 @@
 
     ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
 
-    ((DocumentUimaImpl) getDocument()).serialize(outStream);
+    ((DocumentUimaImpl) getDocument(false)).serialize(outStream);
 
     InputStream stream = new ByteArrayInputStream(outStream.toByteArray());
 

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java Tue Sep 11 10:44:42 2007
@@ -34,7 +34,7 @@
 	 * objects for the given element in this map, if something with document creation
 	 * goes wrong.
 	 *
-	 * The method {@link #getStatus(Object)} can than retrive and return the status.
+	 * The method {@link #getStatus(Object)} can then retrieve and return the status.
 	 */
 	private Map<Object, IStatus> mElementErrorStatus = new HashMap<Object, IStatus>();
 
@@ -111,7 +111,7 @@
 
 				try {
 					org.apache.uima.caseditor.core.IDocument workingCopy =
-						((DocumentElement) nlpElement).getDocument();
+						((DocumentElement) nlpElement).getDocument(true);
 
 					AnnotationDocument document = new AnnotationDocument();
 					document.setProject(nlpElement.getNlpProject());
@@ -177,4 +177,4 @@
 
 	    return status;
 	}
-}
+}
\ No newline at end of file

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java Tue Sep 11 10:44:42 2007
@@ -27,6 +27,7 @@
 
 import org.apache.uima.analysis_engine.AnalysisEngine;
 import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.core.IDocument;
 import org.apache.uima.caseditor.core.model.DocumentElement;
 import org.apache.uima.caseditor.core.uima.AnnotatorConfiguration;
@@ -114,7 +115,7 @@
 
       final IDocument document;
       try {
-        document = element.getDocument(); // retrieve the working copy
+        document = element.getDocument(false); // retrieve the working copy
       } catch (CoreException e1) {
         throw new InvocationTargetException(e1);
       }
@@ -148,8 +149,10 @@
           // element is opened in editor and dirty, do nothing
         }
       } catch (CoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+
+        // TODO: Show the user an error dialog
+
+        CasEditorPlugin.log(e);
       }
     }
 

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java Tue Sep 11 10:44:42 2007
@@ -6,9 +6,9 @@
  * 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
@@ -38,81 +38,81 @@
 public class DocumentPropertyPage extends PropertyPage
 {
     private Text mLanguageText;
-    
+
     private CAS mCAS;
-    
+
     @Override
     protected Control createContents(Composite parent)
     {
         DocumentElement document = (DocumentElement) getElement();
-        
+
         try {
-			mCAS = document.getDocument().getCAS();
+			mCAS = document.getDocument(false).getCAS();
 		} catch (CoreException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-        
+
         Composite base = new Composite(parent, SWT.NONE);
-        
+
         GridLayout layout = new GridLayout();
         layout.numColumns = 2;
         layout.horizontalSpacing = 10;
         base.setLayout(layout);
-        
+
         Label charNumberLabel = new Label(base, SWT.NONE);
         charNumberLabel.setText("Characters:");
-        
+
         // char number
         Label charNumberValue = new Label(base, SWT.NONE);
         charNumberValue.setText(Integer.toString(mCAS.getDocumentText()
                 .length()));
-        
+
         // tokens
         /*
         Label tokenNumberLabel = new Label(base, SWT.NONE);
         tokenNumberLabel.setText("Tokens:");
-        
+
         Label tokenNumberValueLabel = new Label(base, SWT.NONE);
-        
+
         Type tokenType = mTCAS.getTypeSystem().getType(
                 "com.calcucare.nlp.Token");
-        
+
         int numberOfTokens = mTCAS.getAnnotationIndex(tokenType).size();
-        
+
         tokenNumberValueLabel.setText(Integer.toString(numberOfTokens));
         */
-        
+
         // sentences
         /*
         Label sentenceNumberLabel = new Label(base, SWT.NONE);
         sentenceNumberLabel.setText("Sentences:");
-        
+
         Label sentenceNumberValueLabel = new Label(base, SWT.NONE);
-        
+
         Type sentenceType = mTCAS.getTypeSystem().getType(
                 "com.calcucare.nlp.Sentence");
-        
+
         int numberOfSentences = mTCAS.getAnnotationIndex(sentenceType).size();
-        
+
         sentenceNumberValueLabel.setText(Integer.toString(numberOfSentences));
         */
-        
+
         // document language
         Label languageLabel = new Label(base, SWT.NONE);
         languageLabel.setText("Language:");
-        
+
         mLanguageText = new Text(base, SWT.BORDER);
         mLanguageText.setText(mCAS.getDocumentLanguage());
-        
+
         return base;
     }
-    
+
     @Override
     public boolean performOk()
     {
         mCAS.setDocumentLanguage(mLanguageText.getText());
-        
+
         return super.performOk();
     }
 }

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/uima/CorporaCollectionReader.java Tue Sep 11 10:44:42 2007
@@ -6,9 +6,9 @@
  * 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
@@ -42,7 +42,7 @@
 
   /**
    * Sets the <code>CorpusElement</code>s to be read.
-   * 
+   *
    * @param corpora
    */
   public void setCorpora(Collection<CorpusElement> corpora) {
@@ -59,7 +59,7 @@
 
   /**
    * Copies the next text with all annotation to the given cas object.
-   * 
+   *
    * @throws CollectionException -
    */
   public void getNext(CAS cas) throws CollectionException {
@@ -68,7 +68,7 @@
     CAS documentCas = null;
 
     try {
-      documentCas = document.getDocument().getCAS();
+      documentCas = document.getDocument(false).getCAS();
     } catch (CoreException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
@@ -94,7 +94,7 @@
 
   /**
    * Currently not implemented
-   * 
+   *
    * @return Progress[] - just returns null
    */
   public Progress[] getProgress() {

Modified: incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/DefectiveNlpModelTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/DefectiveNlpModelTest.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/DefectiveNlpModelTest.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/DefectiveNlpModelTest.java Tue Sep 11 10:44:42 2007
@@ -102,7 +102,7 @@
 
     // throws a core exception since the document cannot be parsed
     ((DocumentElement) CasEditorPlugin.getNlpModel().findMember(mProject.getDocument()))
-            .getDocument();
+            .getDocument(true);
   }
 
   @Test

Modified: incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java?rev=574647&r1=574646&r2=574647&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java Tue Sep 11 10:44:42 2007
@@ -73,7 +73,7 @@
     DocumentElement document = ((DocumentElement) CasEditorPlugin.getNlpModel().findMember(
             mProject.getDocument()));
 
-    assertTrue(document.getDocument().getCAS().getDocumentText().length() > 0);
+    assertTrue(document.getDocument(true).getCAS().getDocumentText().length() > 0);
   }
 
   /**