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/06/28 15:34:00 UTC
svn commit: r1140598 - in /uima/uimaj/trunk: uimaj-ep-cas-editor-ide/
uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/
uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/
Author: joern
Date: Tue Jun 28 13:34:00 2011
New Revision: 1140598
URL: http://svn.apache.org/viewvc?rev=1140598&view=rev
Log:
UIMA-2151 Moved Default Cas Document Provider to ide plugin
Modified:
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/plugin.xml
uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/CasEditorIdePlugin.java
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/CasEditorPlugin.java
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor-ide/plugin.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor-ide/plugin.xml?rev=1140598&r1=1140597&r2=1140598&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor-ide/plugin.xml (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor-ide/plugin.xml Tue Jun 28 13:34:00 2011
@@ -95,7 +95,7 @@
<extension point="org.eclipse.ui.propertyPages">
<page
- class="org.apache.uima.caseditor.ui.property.EditorAnnotationPropertyPage"
+ class="org.apache.uima.caseditor.ide.property.EditorAnnotationPropertyPage"
icon="icons/svgicons/corpus.png"
id="org.apache.uima.caseditor.annotationspropertypage"
name="Annotations">
@@ -107,7 +107,7 @@
<page
adaptable="true"
objectClass="org.eclipse.core.resources.IProject"
- class="org.apache.uima.caseditor.ui.property.TypeSystemLocationPropertyPage"
+ class="org.apache.uima.caseditor.ide.property.TypeSystemLocationPropertyPage"
name="UIMA Type System"
id="org.apache.uima.caseditor.TypeSystemLocationPropertyPage">
</page>
@@ -115,7 +115,7 @@
<extension
point="org.apache.uima.caseditor.editor">
<provider
- class="org.apache.uima.caseditor.editor.DefaultCasDocumentProvider">
+ class="org.apache.uima.caseditor.ide.DefaultCasDocumentProvider">
</provider>
</extension>
</plugin>
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/CasEditorIdePlugin.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/CasEditorIdePlugin.java?rev=1140598&r1=1140597&r2=1140598&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/CasEditorIdePlugin.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/CasEditorIdePlugin.java Tue Jun 28 13:34:00 2011
@@ -21,9 +21,9 @@ package org.apache.uima.caseditor.ide;
import java.io.IOException;
import java.io.InputStream;
-import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.apache.uima.caseditor.CasEditorPlugin;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpusSerializer;
import org.apache.uima.caseditor.ui.property.TypeSystemLocationPropertyPage;
@@ -52,9 +52,6 @@ public class CasEditorIdePlugin extends
* Resource bundle.
*/
private ResourceBundle mResourceBundle;
-
-
- private boolean showMigrationDialog = false;
/**
* The constructor.
@@ -73,79 +70,79 @@ public class CasEditorIdePlugin extends
*/
@Override
public void start(BundleContext context) throws Exception {
- super.start(context);
-
- // Backward compatibility: Migrate old Cas Editor Projects
-
- // Scan for all Nlp nature projects
- IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-
- for (IProject project : projects) {
- // if nlp nature project
-
- if (project.isOpen() && project.hasNature("org.apache.uima.caseditor.NLPProject")) {
-
- // if ts property is not set ...
- String typeSystemLocation;
- try {
- typeSystemLocation = project.getPersistentProperty(new QualifiedName("",
- TypeSystemLocationPropertyPage.TYPE_SYSTEM_PROPERTY));
- } catch (CoreException e) {
- typeSystemLocation = null;
- }
-
- if (typeSystemLocation == null) {
- // 1. Read dotCorpus
- IFile dotCorpusFile = project.getFile(".corpus");
-
-
- if (dotCorpusFile.exists()) {
-
- InputStream dotCorpusIn = null;
-
- try {
- dotCorpusIn = dotCorpusFile.getContents();
- }
- catch (CoreException e) {
- log(e);
- }
-
- IFile typeSystemFile = null;
- if (dotCorpusIn != null) {
- try {
- DotCorpus dotCorpus = DotCorpusSerializer.parseDotCorpus(dotCorpusIn);
-
- if (dotCorpus.getTypeSystemFileName() != null)
- typeSystemFile = project.getFile(dotCorpus.getTypeSystemFileName());
- }
- finally {
- try {
- dotCorpusIn.close();
- }
- catch (IOException e) {
- log(e);
- }
- }
- }
-
- if (typeSystemFile != null && typeSystemFile.exists()) {
- // 2. Set type system file accordingly
- TypeSystemLocationPropertyPage.setTypeSystemLocation(project, typeSystemFile.getFullPath().toString());
-
- // 3. Try to copy dotCorpus file to type system location
- try {
- dotCorpusFile.copy(project.getFile(typeSystemFile.getParent().getProjectRelativePath() + "/"
- + ".style-" + typeSystemFile.getName()).getFullPath(), true, null);
- showMigrationDialog = true;
- } catch (CoreException e) {
- log(e);
- }
- }
- }
- }
- }
- }
- }
+ super.start(context);
+
+ // Backward compatibility: Migrate old Cas Editor Projects
+
+ // Scan for all Nlp nature projects
+ IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+ for (IProject project : projects) {
+ // if nlp nature project
+
+ if (project.isOpen() && project.hasNature("org.apache.uima.caseditor.NLPProject")) {
+
+ // if ts property is not set ...
+ String typeSystemLocation;
+ try {
+ typeSystemLocation = project.getPersistentProperty(new QualifiedName("",
+ CasEditorPlugin.TYPE_SYSTEM_PROPERTY));
+ } catch (CoreException e) {
+ typeSystemLocation = null;
+ }
+
+ if (typeSystemLocation == null) {
+ // 1. Read dotCorpus
+ IFile dotCorpusFile = project.getFile(".corpus");
+
+
+ if (dotCorpusFile.exists()) {
+
+ InputStream dotCorpusIn = null;
+
+ try {
+ dotCorpusIn = dotCorpusFile.getContents();
+ }
+ catch (CoreException e) {
+ log(e);
+ }
+
+ IFile typeSystemFile = null;
+ if (dotCorpusIn != null) {
+ try {
+ DotCorpus dotCorpus = DotCorpusSerializer.parseDotCorpus(dotCorpusIn);
+
+ if (dotCorpus.getTypeSystemFileName() != null)
+ typeSystemFile = project.getFile(dotCorpus.getTypeSystemFileName());
+ }
+ finally {
+ try {
+ dotCorpusIn.close();
+ }
+ catch (IOException e) {
+ log(e);
+ }
+ }
+ }
+
+ if (typeSystemFile != null && typeSystemFile.exists()) {
+ // 2. Set type system file accordingly
+ TypeSystemLocationPropertyPage.setTypeSystemLocation(project, typeSystemFile.getFullPath().toString());
+
+ // 3. Try to copy dotCorpus file to type system location
+ try {
+ dotCorpusFile.copy(project.getFile(typeSystemFile.getParent().getProjectRelativePath() + "/"
+ + ".style-" + typeSystemFile.getName()).getFullPath(), true, null);
+ CasEditorPlugin.getDefault().setShowMigrationDialog();
+ } catch (CoreException e) {
+ log(e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
/**
* This method is called when the plug-in is stopped.
@@ -171,39 +168,6 @@ public class CasEditorIdePlugin extends
}
/**
- * Returns the string from the plugin's resource bundle, or 'key' if not found.
- *
- * @param key
- * @return resource string
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = getDefault().getResourceBundle();
-
- try {
- return bundle != null ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle.
- *
- * @return the ResourceBbundle or null if missing
- */
- public ResourceBundle getResourceBundle() {
- try {
- if (mResourceBundle == null) {
- mResourceBundle = ResourceBundle.getBundle("Annotator.AnnotatorPluginResources");
- }
- } catch (MissingResourceException x) {
- mResourceBundle = null;
- }
-
- return mResourceBundle;
- }
-
- /**
* Log the throwable.
*
* @param t
@@ -215,14 +179,4 @@ public class CasEditorIdePlugin extends
public static void logError(String message) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, message));
}
-
- public boolean getAndClearShowMigrationDialogFlag() {
- if (showMigrationDialog) {
- showMigrationDialog = false;
- return true;
- }
-
- return false;
- }
-
}
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=1140598&r1=1140597&r2=1140598&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 Tue Jun 28 13:34:00 2011
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.uima.caseditor.editor;
+package org.apache.uima.caseditor.ide;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -34,6 +34,13 @@ 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.AnnotationDocument;
+import org.apache.uima.caseditor.editor.AnnotationStyle;
+import org.apache.uima.caseditor.editor.DocumentFormat;
+import org.apache.uima.caseditor.editor.DocumentUimaImpl;
+import org.apache.uima.caseditor.editor.EditorAnnotationStatus;
+import org.apache.uima.caseditor.editor.ICasEditor;
+import org.apache.uima.caseditor.editor.WorkspaceResourceDialog;
import org.apache.uima.caseditor.ui.property.TypeSystemLocationPropertyPage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java?rev=1140598&r1=1140597&r2=1140598&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java Tue Jun 28 13:34:00 2011
@@ -26,7 +26,6 @@ import java.util.ResourceBundle;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpusSerializer;
-import org.apache.uima.caseditor.ui.property.TypeSystemLocationPropertyPage;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -82,77 +81,6 @@ public class CasEditorPlugin extends Abs
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
-
- // Backward compatibility: Migrate old Cas Editor Projects
-
- // Scan for all Nlp nature projects
- IProject projects[] = ResourcesPlugin.getWorkspace().getRoot().getProjects();
-
- for (IProject project : projects) {
- // if nlp nature project
-
- if (project.isOpen() && project.hasNature("org.apache.uima.caseditor.NLPProject")) {
-
- // if ts property is not set ...
- String typeSystemLocation;
- try {
- typeSystemLocation = project.getPersistentProperty(new QualifiedName("",
- CasEditorPlugin.TYPE_SYSTEM_PROPERTY));
- } catch (CoreException e) {
- typeSystemLocation = null;
- }
-
- if (typeSystemLocation == null) {
- // 1. Read dotCorpus
- IFile dotCorpusFile = project.getFile(".corpus");
-
-
- if (dotCorpusFile.exists()) {
-
- InputStream dotCorpusIn = null;
-
- try {
- dotCorpusIn = dotCorpusFile.getContents();
- }
- catch (CoreException e) {
- log(e);
- }
-
- IFile typeSystemFile = null;
- if (dotCorpusIn != null) {
- try {
- DotCorpus dotCorpus = DotCorpusSerializer.parseDotCorpus(dotCorpusIn);
-
- if (dotCorpus.getTypeSystemFileName() != null)
- typeSystemFile = project.getFile(dotCorpus.getTypeSystemFileName());
- }
- finally {
- try {
- dotCorpusIn.close();
- }
- catch (IOException e) {
- log(e);
- }
- }
- }
-
- if (typeSystemFile != null && typeSystemFile.exists()) {
- // 2. Set type system file accordingly
- TypeSystemLocationPropertyPage.setTypeSystemLocation(project, typeSystemFile.getFullPath().toString());
-
- // 3. Try to copy dotCorpus file to type system location
- try {
- dotCorpusFile.copy(project.getFile(typeSystemFile.getParent().getProjectRelativePath() + "/"
- + ".style-" + typeSystemFile.getName()).getFullPath(), true, null);
- showMigrationDialog = true;
- } catch (CoreException e) {
- log(e);
- }
- }
- }
- }
- }
- }
}
/**
@@ -234,6 +162,10 @@ public class CasEditorPlugin extends Abs
return imageDescriptorFromPlugin(ID, ICONS_PATH + image.getPath());
}
+ public void setShowMigrationDialog() {
+ showMigrationDialog = true;
+ }
+
public boolean getAndClearShowMigrationDialogFlag() {
if (showMigrationDialog) {
showMigrationDialog = false;