The settings should be moved to a new preference page inside
uimaj-ep-cas-editor-ide, because they are specific to the
Cas Editor Ide Plugin and not the Annotation Editor (or the Cas Editor Plugin).

Please create a new preference page which is part of the Ide plugin.

The Cas Editor itself might be used without the Cas Editor Ide Plugin, and
then such settings are confusing. For example, I created a plugin to open CASes from a remote server, in this case the type system is always well defined and there is no need for a user to provide any configuration for it inside the Cas Editor.

Jörn

On 11/10/11 2:08 PM, [email protected] wrote:
Author: pkluegl
Date: Thu Nov 10 13:08:35 2011
New Revision: 1200317

URL: http://svn.apache.org/viewvc?rev=1200317&view=rev
Log:
UIMA-2280
added preference and logic. The type system will be remembered in any case, but 
only applied if preference is set.

Modified:
     
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/DefaultCasDocumentProvider.java
     
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
     
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
     
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/DefaultCasDocumentProvider.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/DefaultCasDocumentProvider.java?rev=1200317&r1=1200316&r2=1200317&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/DefaultCasDocumentProvider.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/DefaultCasDocumentProvider.java
 Thu Nov 10 13:08:35 2011
@@ -34,6 +34,7 @@ import org.apache.uima.caseditor.CasEdit
  import org.apache.uima.caseditor.core.model.DefaultColors;
  import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus;
  import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpusSerializer;
+import org.apache.uima.caseditor.editor.AnnotationEditorPreferenceConstants;
  import org.apache.uima.caseditor.editor.AnnotationStyle;
  import org.apache.uima.caseditor.editor.CasDocumentProvider;
  import org.apache.uima.caseditor.editor.DocumentFormat;
@@ -213,10 +214,16 @@ public class DefaultCasDocumentProvider
        IFile typeSystemFile = null;

        // First check if a type system is already known or was
-      // set by the editor for this specific CAS
-      String typeSystemFileString = 
documentToTypeSystemMap.get(casFile.getFullPath()
-              .toPortableString());
-
+      // set by the editor for this specific CAS.
+      // apply that type system only if the setting is active in the 
preferences
+      String typeSystemFileString = null;
+      IPreferenceStore prefStore = 
CasEditorPlugin.getDefault().getPreferenceStore();
+      boolean useLastTypesystem = prefStore
+              
.getBoolean(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_REMEMBER_TYPESYSTEM);
+      if (useLastTypesystem) {
+        typeSystemFileString = documentToTypeSystemMap
+                .get(casFile.getFullPath().toPortableString());
+      }
        if (typeSystemFileString != null)
          typeSystemFile = ResourcesPlugin.getWorkspace().getRoot()
                  .getFile(new Path(typeSystemFileString));

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java?rev=1200317&r1=1200316&r2=1200317&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
 Thu Nov 10 13:08:35 2011
@@ -28,4 +28,6 @@ public class AnnotationEditorPreferenceC

    public static final String EDITOR_LINE_LENGTH_HINT =
            "EDITOR_LINE_LENGTH_HINT";
+
+  public static final String ANNOTATION_EDITOR_REMEMBER_TYPESYSTEM = CasEditorPlugin.ID 
+".rememberTypesystem";
  }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java?rev=1200317&r1=1200316&r2=1200317&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
 Thu Nov 10 13:08:35 2011
@@ -19,16 +19,16 @@

  package org.apache.uima.caseditor.editor;

+import org.apache.uima.caseditor.CasEditorPlugin;
  import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
  import org.eclipse.jface.preference.IPreferenceStore;

-import org.apache.uima.caseditor.CasEditorPlugin;
-
  public class AnnotationEditorPreferenceInitializer extends 
AbstractPreferenceInitializer {

        public void initializeDefaultPreferences() {
                IPreferenceStore store = 
CasEditorPlugin.getDefault().getPreferenceStore();
                
store.setDefault(AnnotationEditorPreferenceConstants.EDITOR_LINE_LENGTH_HINT, 
80);
                
store.setDefault(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE,
 13);
+               
store.setDefault(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_REMEMBER_TYPESYSTEM,
 true);
        }
  }

Modified: 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java?rev=1200317&r1=1200316&r2=1200317&view=diff
==============================================================================
--- 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
 (original)
+++ 
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
 Thu Nov 10 13:08:35 2011
@@ -20,6 +20,7 @@
  package org.apache.uima.caseditor.editor;

  import org.apache.uima.caseditor.CasEditorPlugin;
+import org.eclipse.jface.preference.BooleanFieldEditor;
  import org.eclipse.jface.preference.FieldEditorPreferencePage;
  import org.eclipse.jface.preference.IntegerFieldEditor;
  import org.eclipse.ui.IWorkbench;
@@ -33,6 +34,7 @@ public class AnnotationEditorPreferenceP

    private IntegerFieldEditor mEditorLineLengthHint;
    private IntegerFieldEditor mEditorTextSize;
+  private BooleanFieldEditor mEditorRememberTypesystem;

    public AnnotationEditorPreferencePage() {
      setPreferenceStore(CasEditorPlugin.getDefault().getPreferenceStore());
@@ -53,6 +55,14 @@ public class AnnotationEditorPreferenceP
              AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE,
              "Editor Text Size", getFieldEditorParent());
      addField(mEditorTextSize);
+
+    // editor text size
+    mEditorRememberTypesystem = new BooleanFieldEditor(
+            
AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_REMEMBER_TYPESYSTEM,
+            "Use the previously selected type system to open a CAS", 
getFieldEditorParent());
+    addField(mEditorRememberTypesystem);
+
+
    }

    public void init(IWorkbench workbench) {



Reply via email to