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/04/28 10:12:39 UTC
svn commit: r1097350 - in /uima/uimaj/trunk/uimaj-ep-cas-editor: ./
src/main/java/org/apache/uima/caseditor/
src/main/java/org/apache/uima/caseditor/core/model/
src/main/java/org/apache/uima/caseditor/core/model/delta/
src/main/java/org/apache/uima/cas...
Author: joern
Date: Thu Apr 28 08:12:37 2011
New Revision: 1097350
URL: http://svn.apache.org/viewvc?rev=1097350&view=rev
Log:
UIMA-2123 Removed Cas Editor Project support
Removed:
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/CorpusElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DocumentElement.java
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/INlpElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.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/core/model/TypesystemElement.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/delta/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/uima/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/util/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/action/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/corpusview/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/model/
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/DocumentPropertyPage.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/FileFieldEditor.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/FolderFieldEditor.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/FolderPathEditor.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/NlpAnnotationPropertyPage.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/NlpProjectFieldEditorPage.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewNlpProjectWizard.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/NewNlpProjectWizardPage.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/WizardNewFileCreation.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/WizardNewFolderCreation.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/uima/
Modified:
uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml?rev=1097350&r1=1097349&r2=1097350&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/plugin.xml Thu Apr 28 08:12:37 2011
@@ -23,30 +23,6 @@
<plugin>
<extension-point id="org.apache.uima.caseditor.editor" name="DocumentProvider" schema="schema/org.apache.uima.caseditor.editor.exsd"/>
- <extension point="org.eclipse.core.contenttype.contentTypes">
- <content-type base-type="org.eclipse.core.runtime.xml"
- file-extensions="xml"
- id="org.apache.uima.caseditor.AnalysisEngineDescriptor"
- name="Analysis Engine Descriptor"
- priority="normal">
- <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
- <parameter name="element" value="{http://uima.apache.org/resourceSpecifier}analysisEngineDescription"/>
- <parameter name="element" value="{http://uima.apache.org/resourceSpecifier}pearSpecifier"/>
- </describer>
- </content-type>
-
- <content-type base-type="org.eclipse.core.runtime.xml"
- file-extensions="xml"
- id="org.apache.uima.caseditor.CasConsumerDescriptor"
- name="Cas Consumer Descriptor"
- priority="normal">
- <describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber">
- <parameter name="element" value="casConsumerDescription"/>
- </describer>
- </content-type>
- </extension>
-
-
<extension point="org.eclipse.ui.views">
<category id="org.apache.uima.caseditor.ui.views" name="UIMA Cas Editor" />
@@ -122,13 +98,6 @@
</runtime>
</extension>
- <extension id="problem" name="Problem"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.core.resources.problemmarker" />
- <persistent value="false" />
- </extension>
-
-
<!-- ui extensions -->
<extension point="org.eclipse.ui.views">
<category id="org.apache.uima.caseditor.ui.views" name="UIMA Cas Editor" />
@@ -140,47 +109,6 @@
category="org.apache.uima.caseditor.ui.views" />
</extension>
- <extension point="org.eclipse.ui.newWizards">
-
- <category name="UIMA Cas Editor" id="org.apache.uima.caseditor.ui.wizards" />
-
- <wizard canFinishEarly="false"
- category="org.apache.uima.caseditor.ui.wizards"
- class="org.apache.uima.caseditor.ui.wizards.NewNlpProjectWizard"
- finalPerspective="org.apache.uima.caseditor.perspective.NLP"
- hasPages="true" icon="icons/svgicons/corpus.png"
- id="org.apache.uima.caseditor.wizards.NLPProjectWizard"
- name="Cas Editor Project"
- preferredPerspectives="org.apache.uima.caseditor.perspective.NLP"
- project="true">
- <description>Create a Cas Editor Project</description>
- </wizard>
- <!--
- <wizard
- canFinishEarly="false"
- category="org.apache.uima.caseditor.ui.wizards"
- class="org.apache.uima.caseditor.ui.wizards.WizardNewFileCreation"
- finalPerspective="org.apache.uima.caseditor.perspective.NLP"
- hasPages="true"
- icon="icons/nlp.gif"
- id="org.apache.uima.caseditor.ui.wizards.WizardNewFileCreation"
- name="File"
- preferredPerspectives="org.apache.uima.caseditor.perspective.NLP"
- project="true"/>
-
- <wizard
- canFinishEarly="false"
- category="org.apache.uima.caseditor.ui.wizards"
- class="org.apache.uima.caseditor.ui.wizards.WizardNewFolderCreation"
- finalPerspective="org.apache.uima.caseditor.perspective.NLP"
- hasPages="true"
- icon="icons/nlp.gif"
- id="org.apache.uima.caseditor.ui.wizards.WizardNewFolderCreation"
- name="Folder"
- preferredPerspectives="org.apache.uima.caseditor.perspective.NLP"
- project="true"/> -->
- </extension>
-
<extension point="org.eclipse.ui.importWizards">
@@ -206,32 +134,6 @@
<extension point="org.eclipse.ui.propertyPages">
<page
- class="org.apache.uima.caseditor.ui.property.ProjectPropertyPage"
- icon="icons/svgicons/corpus.png"
- id="org.apache.uima.caseditor.corpusPropertyPage" name="Project">
- <enabledWhen>
- <instanceof value="org.apache.uima.caseditor.core.model.NlpProject"/>
- </enabledWhen>
- </page>
-
- <page
- class="org.apache.uima.caseditor.ui.property.DocumentPropertyPage"
- icon="icons/svgicons/document.png"
- id="org.apache.uima.caseditor.documentPropertyPage" name="Document">
- <enabledWhen>
- <instanceof value="org.apache.uima.caseditor.core.model.DocumentElement"/>
- </enabledWhen>
- </page>
- <page
- class="org.apache.uima.caseditor.ui.property.NlpAnnotationPropertyPage"
- icon="icons/svgicons/corpus.png"
- id="org.apache.uima.caseditor.nlpannotationspropertypage"
- name="Annotations">
- <enabledWhen>
- <instanceof value="org.apache.uima.caseditor.core.model.NlpProject"/>
- </enabledWhen>
- </page>
- <page
class="org.apache.uima.caseditor.ui.property.EditorAnnotationPropertyPage"
icon="icons/svgicons/corpus.png"
id="org.apache.uima.caseditor.annotationspropertypage"
@@ -249,62 +151,6 @@
id="org.apache.uima.caseditor.TypeSystemLocationPropertyPage">
</page>
</extension>
-
- <extension point="org.eclipse.core.runtime.adapters">
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.NlpModel"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.NlpProject"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.CorpusElement"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.TypesystemElement"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.DocumentElement"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.ConsumerElement"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.AnnotatorElement"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory
- adaptableType="org.apache.uima.caseditor.core.model.CasProcessorFolder"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory adaptableType="org.eclipse.core.resources.IFile"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory adaptableType="org.eclipse.core.resources.IFolder"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- <factory adaptableType="org.eclipse.core.resources.IProject"
- class="org.apache.uima.caseditor.ui.model.ElementWorkbenchAdapterFactory">
- <adapter type="org.eclipse.ui.model.IWorkbenchAdapter" />
- </factory>
- </extension>
-
<extension
point="org.apache.uima.caseditor.editor">
<provider
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=1097350&r1=1097349&r2=1097350&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 Thu Apr 28 08:12:37 2011
@@ -22,7 +22,6 @@ package org.apache.uima.caseditor;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.apache.uima.caseditor.core.model.NlpModel;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -48,8 +47,6 @@ public class CasEditorPlugin extends Abs
*/
private ResourceBundle mResourceBundle;
- private static NlpModel sNLPModel;
-
/**
* The constructor.
*/
@@ -148,31 +145,4 @@ public class CasEditorPlugin extends Abs
public static ImageDescriptor getTaeImageDescriptor(Images image) {
return imageDescriptorFromPlugin(ID, ICONS_PATH + image.getPath());
}
-
- /**
- * Retrieves the nlp model.
- *
- * @return the nlp model
- */
- public static NlpModel getNlpModel() {
- if (sNLPModel == null) {
- try {
- sNLPModel = new NlpModel();
- } catch (CoreException e) {
- // TODO: This should not happen, return an emtpy Model
- log(e);
- }
- }
-
- return sNLPModel;
- }
-
- /**
- * Destroy the nlp model, only for testing.
- */
- public static void destroyNlpModelForTesting() {
- sNLPModel.destroyForTesting();
-
- sNLPModel = null;
- }
}
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java?rev=1097350&r1=1097349&r2=1097350&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java Thu Apr 28 08:12:37 2011
@@ -29,19 +29,6 @@ import org.eclipse.jface.resource.ImageD
*/
public enum Images {
- MODEL_PROJECT_OPEN("svgicons/project-open.png"),
-
- MODEL_PROJECT_CLOSED("svgicons/project-closed.png"),
-
- /**
- * The corpus image.
- */
- MODEL_CORPUS("svgicons/corpus.png"),
-
- /**
- * The document image.
- */
- MODEL_DOCUMENT("svgicons/document.png"),
/**
* The source folder image.
@@ -49,21 +36,6 @@ public enum Images {
MODEL_PROCESSOR_FOLDER("svgicons/processor.png"),
/**
- * Image for the type system element.
- */
- MODEL_TYPESYSTEM("typesystem.gif"),
-
- /**
- * The enabled refresh icon.
- */
- EXPLORER_E_REFRESH("svgicons/refresh.png"),
-
- /**
- * The disabled refresh icon.
- */
- EXPLORER_D_REFRESH("svgicons/refresh.png"),
-
- /**
* The wide left side image.
*/
WIDE_LEFT_SIDE("WideLeftSide.png"),
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=1097350&r1=1097349&r2=1097350&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 Thu Apr 28 08:12:37 2011
@@ -32,13 +32,10 @@ import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.caseditor.CasEditorPlugin;
import org.apache.uima.caseditor.core.model.DefaultColors;
-import org.apache.uima.caseditor.core.model.DocumentElement;
-import org.apache.uima.caseditor.core.model.INlpElement;
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.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -85,173 +82,134 @@ public class DefaultCasDocumentProvider
IFile casFile = fileInput.getFile();
- INlpElement nlpElement = CasEditorPlugin.getNlpModel().findMember(casFile);
-
- // Thats the case if the CAS is inside a Cas Editor Project
- // and part of a corpus folder
- if (nlpElement instanceof DocumentElement) {
-
- try {
- org.apache.uima.caseditor.editor.ICasDocument workingCopy =
- ((DocumentElement) nlpElement).getDocument(true);
-
- AnnotationDocument document = new AnnotationDocument();
-
- document.setDocument(workingCopy);
-
- elementErrorStatus.remove(element);
-
- return document;
- } catch (CoreException e) {
- elementErrorStatus.put(element, new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "There is a problem with the document: " + e.getMessage(), e));
- }
- } else if (CasEditorPlugin.getNlpModel().
- findMember(casFile.getProject()) instanceof INlpElement) {
- IStatus status;
-
- if (nlpElement == null) {
- status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "Document not in a corpus folder!", null);
- } else {
- status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, "Not a cas document!",
- null);
- }
-
- elementErrorStatus.put(element, status);
- }
- // handle the non Cas Editor project case here
- else {
-
- // Try to find a type system for the CAS file
- // TODO: Change to only use full path
- 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());
-
- if (typeSystemFileString != null)
- typeSystemFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(typeSystemFileString));
-
- // If non was found get it from project
- if (typeSystemFile == null)
- typeSystemFile = TypeSystemLocationPropertyPage.getTypeSystemLocation(casFile.getProject());
+ // Try to find a type system for the CAS file
+ // TODO: Change to only use full path
+ 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());
+
+ if (typeSystemFileString != null)
+ typeSystemFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(typeSystemFileString));
+
+ // If non was found get it from project
+ if (typeSystemFile == null)
+ typeSystemFile = TypeSystemLocationPropertyPage.getTypeSystemLocation(casFile.getProject());
+
+ if (typeSystemFile != null && typeSystemFile.exists()) {
- if (typeSystemFile != null && typeSystemFile.exists()) {
-
- // Try to load a style file for the type system
- // Should be named: ts file name, prefixed with .style-
- // If it does not exist, create it when it is changed
- // Creating it after the default is changed means that
- // colors could change completely when the a type is
- // added or removed to the type system
-
- IFile styleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
- getStyleFileForTypeSystem(typeSystemFile.getFullPath().toPortableString())));
-
- DotCorpus dotCorpus = styles.get(styleFile.getFullPath().toPortableString());
+ // Try to load a style file for the type system
+ // Should be named: ts file name, prefixed with .style-
+ // If it does not exist, create it when it is changed
+ // Creating it after the default is changed means that
+ // colors could change completely when the a type is
+ // added or removed to the type system
+
+ IFile styleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
+ getStyleFileForTypeSystem(typeSystemFile.getFullPath().toPortableString())));
+
+ DotCorpus dotCorpus = styles.get(styleFile.getFullPath().toPortableString());
+
+ if (dotCorpus == null) {
+ if (styleFile.exists()) {
+ InputStream styleFileIn = null;;
+ try {
+ styleFileIn = styleFile.getContents();
+ dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);
+ }
+ finally {
+ if (styleFileIn != null)
+ try {
+ styleFileIn.close();
+ } catch (IOException e) {
+ CasEditorPlugin.log(e);
+ }
+ }
+ }
if (dotCorpus == null) {
- if (styleFile.exists()) {
- InputStream styleFileIn = null;;
- try {
- styleFileIn = styleFile.getContents();
- dotCorpus = DotCorpusSerializer.parseDotCorpus(styleFileIn);
- }
- finally {
- if (styleFileIn != null)
- try {
- styleFileIn.close();
- } catch (IOException e) {
- CasEditorPlugin.log(e);
- }
- }
- }
+ dotCorpus = new DotCorpus();
- if (dotCorpus == null) {
- dotCorpus = new DotCorpus();
-
- // Initialize colors
- CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
- TypeSystem ts = cas.getTypeSystem();
-
- Collection<AnnotationStyle> defaultStyles = dotCorpus.getAnnotationStyles();
-
- Collection<AnnotationStyle> newStyles = DefaultColors.assignColors(ts, defaultStyles);
-
- for (AnnotationStyle style : newStyles) {
- dotCorpus.setStyle(style);
- }
- }
+ // Initialize colors
+ CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
+ TypeSystem ts = cas.getTypeSystem();
+
+ Collection<AnnotationStyle> defaultStyles = dotCorpus.getAnnotationStyles();
- styles.put(styleFile.getFullPath().toPortableString(), dotCorpus);
+ Collection<AnnotationStyle> newStyles = DefaultColors.assignColors(ts, defaultStyles);
+
+ for (AnnotationStyle style : newStyles) {
+ dotCorpus.setStyle(style);
+ }
}
- documentToTypeSystemMap.put(casFile.getFullPath().toPortableString(),
- typeSystemFile.getFullPath().toPortableString());
+ styles.put(styleFile.getFullPath().toPortableString(), dotCorpus);
+ }
+
+ documentToTypeSystemMap.put(casFile.getFullPath().toPortableString(),
+ typeSystemFile.getFullPath().toPortableString());
- // TODO:
- // Preferences are bound to the type system
- // Changed in one place, then it should change in all places
-
- CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
-
- DocumentFormat documentFormat;
-
- // Which file format to use ?
- if (casFile.getName().endsWith("xmi")) {
- documentFormat = DocumentFormat.XMI;
- } else if (casFile.getName().endsWith("xcas")) {
- documentFormat = DocumentFormat.XCAS;
- } else {
- throw new CoreException(new Status(IStatus.ERROR, "org.apache.uima.dev",
- "Unkown file format!"));
- }
-
- InputStream casIn = casFile.getContents();
+ // TODO:
+ // Preferences are bound to the type system
+ // Changed in one place, then it should change in all places
+
+ CAS cas = DocumentUimaImpl.getVirginCAS(typeSystemFile);
+
+ DocumentFormat documentFormat;
+
+ // Which file format to use ?
+ if (casFile.getName().endsWith("xmi")) {
+ documentFormat = DocumentFormat.XMI;
+ } else if (casFile.getName().endsWith("xcas")) {
+ documentFormat = DocumentFormat.XCAS;
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, "org.apache.uima.dev",
+ "Unkown file format!"));
+ }
+
+ InputStream casIn = casFile.getContents();
- org.apache.uima.caseditor.editor.ICasDocument doc;
+ org.apache.uima.caseditor.editor.ICasDocument doc;
+ try {
+ doc = new DocumentUimaImpl(cas, casIn, documentFormat);
+ } finally {
try {
- doc = new DocumentUimaImpl(cas, casIn, documentFormat);
- } finally {
- try {
- casIn.close();
- } catch (IOException e) {
- // Unable to close file after loading it
- //
- // In the current implementation the user
- // does not notice the error and can just
- // edit the file, tough saving it might fail
- // if the io error persists
-
- CasEditorPlugin.log(e);
- }
+ casIn.close();
+ } catch (IOException e) {
+ // Unable to close file after loading it
+ //
+ // In the current implementation the user
+ // does not notice the error and can just
+ // edit the file, tough saving it might fail
+ // if the io error persists
+
+ CasEditorPlugin.log(e);
}
-
- AnnotationDocument document = new AnnotationDocument();
- document.setDocument(doc);
-
- elementErrorStatus.remove(element);
-
- return document;
}
- else {
-
- String message = null;
-
- if (typeSystemFile != null) {
- message = "Cannot find type system!\nPlease place a valid type system in this path:\n" +
- typeSystemFile.getFullPath().toString();
- }
- else
- message = "Type system is not set, please choose a type system to open the CAS.";
-
- IStatus status = new Status(IStatus.ERROR, "org.apache.uima.dev", 12, message, null);
-
- elementErrorStatus.put(element, status);
+
+ AnnotationDocument document = new AnnotationDocument();
+ document.setDocument(doc);
+
+ elementErrorStatus.remove(element);
+
+ return document;
+ }
+ else {
+
+ String message = null;
+
+ if (typeSystemFile != null) {
+ message = "Cannot find type system!\nPlease place a valid type system in this path:\n" +
+ typeSystemFile.getFullPath().toString();
}
+ else
+ message = "Type system is not set, please choose a type system to open the CAS.";
+
+ IStatus status = new Status(IStatus.ERROR, "org.apache.uima.dev", 12, message, null);
+
+ elementErrorStatus.put(element, status);
}
}
@@ -269,35 +227,17 @@ public class DefaultCasDocumentProvider
IFile file = fileInput.getFile();
- INlpElement nlpElement = CasEditorPlugin.getNlpModel().findMember(file);
-
- if (nlpElement instanceof DocumentElement) {
- DocumentElement documentElement = (DocumentElement) nlpElement;
-
- try {
- documentElement.saveDocument();
- } catch (CoreException e) {
- fireElementStateChangeFailed(element);
- throw e;
- }
- } else if (CasEditorPlugin.getNlpModel().
- findMember(file.getProject()) instanceof INlpElement) {
- fireElementStateChangeFailed(element);
- return;
- }
- else {
- if (document instanceof AnnotationDocument) {
-
- AnnotationDocument annotationDocument = (AnnotationDocument) document;
- DocumentUimaImpl documentImpl = (DocumentUimaImpl) annotationDocument.getDocument();
-
- ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
- documentImpl.serialize(outStream);
-
- InputStream stream = new ByteArrayInputStream(outStream.toByteArray());
+ if (document instanceof AnnotationDocument) {
+
+ AnnotationDocument annotationDocument = (AnnotationDocument) document;
+ DocumentUimaImpl documentImpl = (DocumentUimaImpl) annotationDocument.getDocument();
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
+ documentImpl.serialize(outStream);
+
+ InputStream stream = new ByteArrayInputStream(outStream.toByteArray());
- file.setContents(stream, true, false, null);
- }
+ file.setContents(stream, true, false, null);
}
}
@@ -322,18 +262,6 @@ public class DefaultCasDocumentProvider
return styles.get(getStyleFileForTypeSystem(tsId));
}
- private INlpElement getNlpElement(Object element) {
- if (element instanceof FileEditorInput) {
- FileEditorInput fileInput = (FileEditorInput) element;
-
- IFile file = fileInput.getFile();
-
- return CasEditorPlugin.getNlpModel().findMember(file);
- }
-
- return null;
- }
-
private void saveStyles(Object element) {
String styleId = getStyleFileForTypeSystem(getTypesystemId(element));
@@ -375,126 +303,58 @@ public class DefaultCasDocumentProvider
if (type == null)
throw new IllegalArgumentException("type parameter must not be null!");
- INlpElement nlpElement = getNlpElement(element);
-
- if (nlpElement != null) {
- return nlpElement.getNlpProject().getDotCorpus().getAnnotation(type);
- }
- else {
- DotCorpus dotCorpus = getStyle(element);
-
- return dotCorpus.getAnnotation(type);
- }
+ DotCorpus dotCorpus = getStyle(element);
+
+ return dotCorpus.getAnnotation(type);
}
// TODO: Disk must be accessed for every changed annotation style
// add a second method which can take all changed styles
@Override
public void setAnnotationStyle(Object element, AnnotationStyle style) {
- INlpElement nlpElement = getNlpElement(element);
- if (nlpElement != null) {
- nlpElement.getNlpProject().getDotCorpus().setStyle(style);
-
- try {
- nlpElement.getNlpProject().getDotCorpus().serialize(false);
- } catch (CoreException e) {
- CasEditorPlugin.log(e);
- }
-
- }
- else {
- DotCorpus dotCorpus = getStyle(element);
- dotCorpus.setStyle(style);
-
- saveStyles(element);
- }
+ DotCorpus dotCorpus = getStyle(element);
+ dotCorpus.setStyle(style);
+
+ saveStyles(element);
}
@Override
protected Collection<String> getShownTypes(Object element) {
- INlpElement nlpElement = getNlpElement(element);
-
- if (nlpElement != null) {
- return nlpElement.getNlpProject().getDotCorpus().getShownTypes();
- }
- else {
- DotCorpus dotCorpus = getStyle(element);
-
- return dotCorpus.getShownTypes();
- }
+ DotCorpus dotCorpus = getStyle(element);
+ return dotCorpus.getShownTypes();
}
@Override
protected void addShownType(Object element, Type type) {
- INlpElement nlpElement = getNlpElement(element);
+ DotCorpus dotCorpus = getStyle(element);
+ dotCorpus.setShownType(type.getName());
- if (nlpElement != null) {
- nlpElement.getNlpProject().getDotCorpus().addShownType(type.getName());
-
- try {
- nlpElement.getNlpProject().getDotCorpus().serialize(false);
- } catch (CoreException e) {
- CasEditorPlugin.log(e);
- }
- }
- else {
- DotCorpus dotCorpus = getStyle(element);
- dotCorpus.setShownType(type.getName());
-
- saveStyles(element);
- }
+ saveStyles(element);
}
@Override
protected void removeShownType(Object element, Type type) {
- INlpElement nlpElement = getNlpElement(element);
-
- if (nlpElement != null) {
- nlpElement.getNlpProject().getDotCorpus().removeShownType(type.getName());
-
- try {
- nlpElement.getNlpProject().getDotCorpus().serialize(false);
- } catch (CoreException e) {
- CasEditorPlugin.log(e);
- }
- }
- else {
- DotCorpus dotCorpus = getStyle(element);
- dotCorpus.removeShownType(type.getName());
-
- saveStyles(element);
- }
+ DotCorpus dotCorpus = getStyle(element);
+ dotCorpus.removeShownType(type.getName());
+
+ saveStyles(element);
}
@Override
protected EditorAnnotationStatus getEditorAnnotationStatus(Object element) {
- INlpElement nlpElement = getNlpElement(element);
-
- if (nlpElement != null) {
- return nlpElement.getNlpProject().getEditorAnnotationStatus();
- }
- else {
- EditorAnnotationStatus status = sharedEditorStatus.get(getTypesystemId(element));
-
- if (status == null)
- status = new EditorAnnotationStatus(CAS.TYPE_NAME_ANNOTATION, null, CAS.NAME_DEFAULT_SOFA);
-
- return status;
- }
+ EditorAnnotationStatus status = sharedEditorStatus.get(getTypesystemId(element));
+
+ if (status == null)
+ status = new EditorAnnotationStatus(CAS.TYPE_NAME_ANNOTATION, null, CAS.NAME_DEFAULT_SOFA);
+
+ return status;
}
@Override
protected void setEditorAnnotationStatus(Object element,
EditorAnnotationStatus editorAnnotationStatus) {
- INlpElement nlpElement = getNlpElement(element);
-
- if (nlpElement != null) {
- nlpElement.getNlpProject().setEditorAnnotationStatus(editorAnnotationStatus);
- }
- else {
- sharedEditorStatus.put(getTypesystemId(element), editorAnnotationStatus);
- }
+ sharedEditorStatus.put(getTypesystemId(element), editorAnnotationStatus);
}
void setTypeSystem(String document, String typeSystem) {
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java?rev=1097350&r1=1097349&r2=1097350&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java Thu Apr 28 08:12:37 2011
@@ -22,8 +22,6 @@ package org.apache.uima.caseditor.editor
import java.util.Collection;
import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.model.NlpModel;
-import org.apache.uima.caseditor.core.model.NlpProject;
import org.apache.uima.caseditor.editor.AnnotationEditor;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.TreeViewer;
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java?rev=1097350&r1=1097349&r2=1097350&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java Thu Apr 28 08:12:37 2011
@@ -23,10 +23,6 @@ package org.apache.uima.caseditor.ui;
import org.apache.uima.caseditor.editor.editview.EditView;
import org.apache.uima.caseditor.editor.fsview.FeatureStructureBrowserView;
import org.apache.uima.caseditor.editor.styleview.AnnotationStyleView;
-import org.apache.uima.caseditor.ui.corpusview.CorpusExplorerView;
-import org.apache.uima.caseditor.ui.wizards.NewNlpProjectWizard;
-import org.apache.uima.caseditor.ui.wizards.WizardNewFileCreation;
-import org.apache.uima.caseditor.ui.wizards.WizardNewFolderCreation;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
@@ -52,16 +48,9 @@ public class NlpPerspectiveFactory imple
}
private void defineActions(IPageLayout layout) {
- // add "new wizards"
- layout.addNewWizardShortcut(NewNlpProjectWizard.ID);
- // layout.addNewWizardShortcut(NewCorpusWizard.ID);
- layout.addNewWizardShortcut(WizardNewFolderCreation.ID);
- layout.addNewWizardShortcut(WizardNewFileCreation.ID);
-
- // layout.addNewWizardShortcut("Annotator.NewDocumentWizard");
// add "show views"
- layout.addShowViewShortcut(CorpusExplorerView.ID);
+ layout.addShowViewShortcut("org.eclipse.ui.navigator.ProjectExplore");
layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
layout.addShowViewShortcut(AnnotationStyleView.ID);
@@ -76,7 +65,7 @@ public class NlpPerspectiveFactory imple
// left views
IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
0.19f, editorArea);
- left.addView(CorpusExplorerView.ID);
+ left.addView("org.eclipse.ui.navigator.ProjectExplore");
// right views
IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT,
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java?rev=1097350&r1=1097349&r2=1097350&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java (original)
+++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizardPage.java Thu Apr 28 08:12:37 2011
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Set;
import org.apache.uima.caseditor.CasEditorPlugin;
-import org.apache.uima.caseditor.core.model.CorpusElement;
import org.apache.uima.caseditor.editor.DocumentFormat;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
@@ -85,12 +84,13 @@ final class ImportDocumentWizardPage ext
setTitle("Import Text Files");
- if (!currentResourceSelection.isEmpty()) {
- if (currentResourceSelection.getFirstElement() instanceof CorpusElement) {
- containerElement = (IContainer) currentResourceSelection.getFirstElement();
- importDestinationPath = containerElement.getFullPath();
- }
- }
+ // TODO: Pre select the selected foler ..
+// if (!currentResourceSelection.isEmpty()) {
+// if (currentResourceSelection.getFirstElement() instanceof CorpusElement) {
+// containerElement = (IContainer) currentResourceSelection.getFirstElement();
+// importDestinationPath = containerElement.getFullPath();
+// }
+// }
setPageComplete(false);
}