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/01/26 15:27:07 UTC

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

Author: joern
Date: Mon Jan 26 14:27:06 2009
New Revision: 737701

URL: http://svn.apache.org/viewvc?rev=737701&view=rev
Log:
UIMA-1277

Modified:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/CasDocumentProvider.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java
    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/ui/action/DocumentActionRunnable.java
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
    incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/CasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/CasDocumentProvider.java?rev=737701&r1=737700&r2=737701&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/CasDocumentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/CasDocumentProvider.java Mon Jan 26 14:27:06 2009
@@ -1,6 +1,7 @@
 package org.apache.uima.caseditor;
 
 import org.apache.uima.cas.Type;
+import org.apache.uima.caseditor.core.TaeError;
 import org.apache.uima.caseditor.core.model.DocumentElement;
 import org.apache.uima.caseditor.core.model.INlpElement;
 import org.apache.uima.caseditor.editor.AnnotationDocument;
@@ -29,18 +30,19 @@
 			if (nlpElement instanceof DocumentElement) {
 
 				try {
-					org.apache.uima.caseditor.editor.IDocument workingCopy =
+					org.apache.uima.caseditor.editor.ICasDocument workingCopy =
 						((DocumentElement) nlpElement).getDocument(true);
 
 					AnnotationDocument document = new AnnotationDocument();
-					// TODO: fix it
-					// document.setProject(nlpElement.getNlpProject());
+					
+					document.setLineLengthHint(
+							nlpElement.getNlpProject().getDotCorpus().getEditorLineLengthHint());
 
 					document.setDocument(workingCopy);
 					return document;
 				}
 				catch (CoreException e) {
-					mElementErrorStatus.put(element, new Status(IStatus.ERROR,
+					elementErrorStatus.put(element, new Status(IStatus.ERROR,
 							CasEditorPlugin.ID, IStatus.OK,
 							"There is a problem with the document: " + e.getMessage(), e));
 				}
@@ -57,30 +59,53 @@
 							"Not a cas document!", null);
 				}
 
-				mElementErrorStatus.put(element, status);
+				elementErrorStatus.put(element, status);
 			}
 		}
 
 		return null;
 	}
 
-	@Override
-	protected void doSaveDocument(IProgressMonitor monitor, Object element,
-			IDocument document, boolean overwrite) throws CoreException {
-	}
-	
 	private INlpElement getNlpElement(Object element) {
 		if (element instanceof FileEditorInput) {
 			FileEditorInput fileInput = (FileEditorInput) element;
 			
 			IFile file = fileInput.getFile();
-
+			
 			return CasEditorPlugin.getNlpModel().findMember(file);
 		}
 		
 		return null;
 	}
 	
+	@Override
+	protected void doSaveDocument(IProgressMonitor monitor, Object element,
+			IDocument document, boolean overwrite) throws CoreException {
+		fireElementStateChanging(element);
+		
+		INlpElement nlpElement = getNlpElement(element);
+		
+		DocumentElement documentElement;
+		
+		if (nlpElement instanceof DocumentElement) {
+			documentElement = (DocumentElement) nlpElement;
+		}
+		else {
+			throw new TaeError("nlpElement must be of type DocumentElement!");
+		}
+		
+		try {
+			documentElement.saveDocument();
+		}
+		catch (CoreException e) {
+			fireElementStateChangeFailed(element);
+			throw e;
+		}
+
+		fireElementDirtyStateChanged(element, false);
+	}
+	
+	
 	protected AnnotationStyle getAnnotationStyle(Object element, Type type) {
 		INlpElement nlpElement = getNlpElement(element);
 		
@@ -99,4 +124,6 @@
 		
 		nlpElement.getNlpProject().setEditorAnnotationStatus(editorAnnotationStatus);
 	}
+	
+	// provide line length to editor
 }
\ No newline at end of file

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java?rev=737701&r1=737700&r2=737701&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java Mon Jan 26 14:27:06 2009
@@ -23,7 +23,7 @@
 import java.util.LinkedList;
 
 import org.apache.uima.caseditor.core.model.delta.INlpElementDelta;
-import org.apache.uima.caseditor.editor.IDocument;
+import org.apache.uima.caseditor.editor.ICasDocument;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IResource;
@@ -31,7 +31,7 @@
 import org.eclipse.core.runtime.IAdaptable;
 
 /**
- * The CorpusElement is a container for {@link IDocument}s.
+ * The CorpusElement is a container for {@link ICasDocument}s.
  *
  * TODO: do not include defective elements!
  */

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=737701&r1=737700&r2=737701&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 Mon Jan 26 14:27:06 2009
@@ -29,7 +29,7 @@
 import org.apache.uima.caseditor.core.model.delta.INlpElementDelta;
 import org.apache.uima.caseditor.editor.DocumentFormat;
 import org.apache.uima.caseditor.editor.DocumentUimaImpl;
-import org.apache.uima.caseditor.editor.IDocument;
+import org.apache.uima.caseditor.editor.ICasDocument;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
@@ -99,7 +99,7 @@
    * @throws CoreException
    * @return the working copy
    */
-  public IDocument getDocument(boolean reload) throws CoreException {
+  public ICasDocument getDocument(boolean reload) throws CoreException {
 
     NlpProject project = (NlpProject) mParent.getParent();
 

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DocumentActionRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DocumentActionRunnable.java?rev=737701&r1=737700&r2=737701&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DocumentActionRunnable.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/DocumentActionRunnable.java Mon Jan 26 14:27:06 2009
@@ -29,7 +29,7 @@
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.core.model.DocumentElement;
 import org.apache.uima.caseditor.editor.AnnotationEditor;
-import org.apache.uima.caseditor.editor.IDocument;
+import org.apache.uima.caseditor.editor.ICasDocument;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -135,7 +135,7 @@
 
     for (DocumentElement documentElement : documents) {
 
-      final IDocument doc;
+      final ICasDocument doc;
 
       try {
         doc = documentElement.getDocument(false);

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java?rev=737701&r1=737700&r2=737701&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java Mon Jan 26 14:27:06 2009
@@ -34,24 +34,20 @@
  * The <code>AnnotationDocument</code> adapts the annotation document to the eclipse Document
  * (needed for the editor).
  *
- * Note: Before an instance can be used, the project and document must be set.
+ * Note: Before an instance can be used the  document must be set.
  */
 public class AnnotationDocument extends Document implements ICasDocument {
+	
   private ICasDocument mDocument;
-
-//  private NlpProject mProject;
+  
+  private int lineLengthHint = 80;
 
   public AnnotationDocument() {
   }
 
-//  /**
-//   * Sets the project.
-//   *
-//   * @param project
-//   */
-//  public void setProject(NlpProject project) {
-//    mProject = project;
-//  }
+  public void setLineLengthHint(int lineLengthHint) {
+	  this.lineLengthHint = lineLengthHint;
+  }
 
   /**
    * @param element
@@ -62,15 +58,6 @@
     set(getText());
   }
 
-//  /**
-//   * Retrieves the project.
-//   *
-//   * @return the project
-//   */
-//  public NlpProject getProject() {
-//    return mProject;
-//  }
-
   /**
    * Call is forwarded to the set document.
    *
@@ -179,7 +166,10 @@
     fireDocumentChanged();
   }
 
-
+  /**
+   * Called to notify that the whole document has been changed and
+   * must now synchronized.
+   */
   public void changed() {
     mDocument.changed();
 
@@ -235,16 +225,6 @@
     return mDocument.getAnnotation(type, span);
   }
 
-//  /**
-//   * Call is forwarded to the set document.
-//   *
-//   * @param out
-//   * @throws CoreException
-//   */
-//  public void save() throws CoreException {
-//    mDocument.save();
-//  }
-
   /**
    * Notifies listener about a document change.
    */
@@ -255,8 +235,9 @@
   }
 
   /**
-   * Wrap words at next space after lineLengthHint chars in a line. If the line is shorter than
-   * lineLengthHint nothing happens. The space char is replaced with an line feed char.
+   * Wrap words at next space after lineLengthHint chars in a line.
+   * If the line is shorter than lineLengthHint nothing happens.
+   * The space char is replaced with an line feed char.
    *
    * @param textString
    * @param lineLengthHint
@@ -291,8 +272,6 @@
    * @return the text
    */
   public String getText() {
-	  // TODO: fix this
-    int lineLengthHint = 200; //mProject.getDotCorpus().getEditorLineLengthHint();
 
     if (lineLengthHint != 0) {
       return wrapWords(mDocument.getText(), lineLengthHint);
@@ -306,6 +285,7 @@
    *
    * @param start
    * @param end
+   * 
    * @return the text
    */
   public String getText(int start, int end) {
@@ -315,7 +295,7 @@
   /**
    * Call is forwarded to the set document.
    *
-   * @return the TCAS
+   * @return the {@link CAS}
    */
   public CAS getCAS() {
     return mDocument.getCAS();
@@ -330,8 +310,4 @@
   public Type getType(String type) {
     return mDocument.getType(type);
   }
-
-//  public DocumentElement getDocumentElement() {
-//    return mDocument.getDocumentElement();
-//  }
 }
\ No newline at end of file

Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java?rev=737701&r1=737700&r2=737701&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java Mon Jan 26 14:27:06 2009
@@ -51,7 +51,7 @@
 	 *
 	 * The method {@link #getStatus(Object)} can then retrieve and return the status.
 	 */
-	protected Map<Object, IStatus> mElementErrorStatus =
+	protected Map<Object, IStatus> elementErrorStatus =
 			new HashMap<Object, IStatus>();
 
 	@Override
@@ -129,7 +129,7 @@
 
 	@Override
 	public IStatus getStatus(Object element) {
-	    IStatus status = mElementErrorStatus.get(element);
+	    IStatus status = elementErrorStatus.get(element);
 
 	    if (status == null) {
 	      status = super.getStatus(element);