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 2011/02/11 12:21:35 UTC

svn commit: r1069753 - in /uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor: core/model/DotCorpusElement.java core/model/NlpProject.java editor/DefaultCasDocumentProvider.java

Author: joern
Date: Fri Feb 11 11:21:35 2011
New Revision: 1069753

URL: http://svn.apache.org/viewvc?rev=1069753&view=rev
Log:
UIMA-2049 Disabled project re-build when only styling was changed.

Modified:
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
    uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java?rev=1069753&r1=1069752&r2=1069753&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java Fri Feb 11 11:21:35 2011
@@ -285,21 +285,41 @@ public class DotCorpusElement extends Ab
   }
 
   /**
-   * Serializes the <code>DotCorpus</code> instance to the given <code>IFile</code>.
+   * Serializes the dot corpus. If updateProject is true the project structure will be re-build,
+   * otherwise not.
    * 
+   * @param updateProject
    * @throws CoreException
    */
-  public void serialize() throws CoreException {
+  public void serialize(boolean updateProject) throws CoreException {
+    
+    if (updateProject == false) getNlpProject().setDotCorpusStyleOnlyChanges(true);
+    
     ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
-
-    DotCorpusSerializer.serialize(mDotCorpus, outBuffer);
-
-    if (mResource.exists()) {
-      mResource.setContents(new ByteArrayInputStream(outBuffer.toByteArray()), true, true, null);
-    } else {
-      mResource.create(new ByteArrayInputStream(outBuffer.toByteArray()), true, null);
+    
+    try {
+      DotCorpusSerializer.serialize(mDotCorpus, outBuffer);
+  
+      if (mResource.exists()) {
+        mResource.setContents(new ByteArrayInputStream(outBuffer.toByteArray()), true, true, null);
+      } else {
+        mResource.create(new ByteArrayInputStream(outBuffer.toByteArray()), true, null);
+      }
+    }
+    finally {
+      if (updateProject == false) getNlpProject().setDotCorpusStyleOnlyChanges(false);
     }
   }
+  
+  /**
+   * Serializes the <code>DotCorpus</code> instance to the given <code>IFile</code>.
+   * 
+   * @throws CoreException
+   */
+  // BUG: When serializing do not re-create NLP Project!+
+  public void serialize() throws CoreException {
+    serialize(false);
+  }
 
   /**
    * Always returns hash code 0.

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java?rev=1069753&r1=1069752&r2=1069753&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java Fri Feb 11 11:21:35 2011
@@ -60,6 +60,8 @@ public final class NlpProject extends Ab
 
   private DotCorpusElement mDotCorpusElement;
 
+  private boolean isDotCorpusStyleChange = false;
+  
   private Collection<CorpusElement> mCopora = new LinkedList<CorpusElement>();
 
   private Collection<CasProcessorFolder> mUimaSourceFolder = new LinkedList<CasProcessorFolder>();
@@ -507,21 +509,34 @@ public final class NlpProject extends Ab
       }
     }
   }
-
+  
+  /**
+   * Used to disable/enable of the project structure when only styling was changed.
+   * Set to true before style change, and set to false afterwards.
+   * 
+   * @param isStyleOnlyChange
+   */
+  void setDotCorpusStyleOnlyChanges(boolean isStyleOnlyChange) {
+    isDotCorpusStyleChange = isStyleOnlyChange;
+  }
+  
   void postProcessResourceChanges() throws CoreException {
     if (mIsDotCorpusDirty) {
+      
       mIsDotCorpusDirty = false;
-
-      mDotCorpusElement = null;
-      loadDotCorpus();
       
-      mUimaSourceFolder.clear();
-      mCopora.clear();
-
-      mTypesystem = null;
-
-      initialize();
-
+      if (!isDotCorpusStyleChange) {
+        mDotCorpusElement = null;
+        loadDotCorpus();
+        
+        mUimaSourceFolder.clear();
+        mCopora.clear();
+  
+        mTypesystem = null;
+  
+        initialize();
+      }
+      
       updateAnnotationTypeColors();
       
       CasEditorPlugin.getNlpModel().fireRefreshEvent(this);

Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java?rev=1069753&r1=1069752&r2=1069753&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java Fri Feb 11 11:21:35 2011
@@ -267,9 +267,8 @@ public class DefaultCasDocumentProvider 
 
       IFile file = fileInput.getFile();
 
-      INlpElement nlpElement =
-              org.apache.uima.caseditor.CasEditorPlugin.getNlpModel().findMember(file);
-
+      INlpElement nlpElement = CasEditorPlugin.getNlpModel().findMember(file);
+      
       if (nlpElement instanceof DocumentElement) {
         DocumentElement documentElement = (DocumentElement) nlpElement;
 
@@ -396,7 +395,7 @@ public class DefaultCasDocumentProvider 
       nlpElement.getNlpProject().getDotCorpus().setStyle(style);
       
       try {
-        nlpElement.getNlpProject().getDotCorpus().serialize();
+        nlpElement.getNlpProject().getDotCorpus().serialize(false);
       } catch (CoreException e) {
         CasEditorPlugin.log(e);
       }
@@ -432,7 +431,7 @@ public class DefaultCasDocumentProvider 
       nlpElement.getNlpProject().getDotCorpus().addShownType(type.getName());
       
       try {
-        nlpElement.getNlpProject().getDotCorpus().serialize();
+        nlpElement.getNlpProject().getDotCorpus().serialize(false);
       } catch (CoreException e) {
         CasEditorPlugin.log(e);
       }
@@ -453,7 +452,7 @@ public class DefaultCasDocumentProvider 
       nlpElement.getNlpProject().getDotCorpus().removeShownType(type.getName());
       
       try {
-        nlpElement.getNlpProject().getDotCorpus().serialize();
+        nlpElement.getNlpProject().getDotCorpus().serialize(false);
       } catch (CoreException e) {
         CasEditorPlugin.log(e);
       }