You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/09/10 13:23:21 UTC
svn commit: r574204 - in /incubator/uima/sandbox/trunk/CasEditor: META-INF/
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/caseditor/core/model/dotcorpus/ src/...
Author: twgoetz
Date: Mon Sep 10 04:23:19 2007
New Revision: 574204
URL: http://svn.apache.org/viewvc?rev=574204&view=rev
Log:
Jira UIMA-450: apply UIMA-450.patch.
https://issues.apache.org/jira/browse/UIMA-450
Modified:
incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.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/core/model/DotCorpusElement.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/TypesystemElement.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/EditorAnnotationStatus.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java
incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java
Modified: incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF (original)
+++ incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF Mon Sep 10 04:23:19 2007
@@ -17,7 +17,9 @@
org.eclipse.jface.text,
org.eclipse.core.filesystem,
com.ibm.icu,
- org.junit4
+ org.junit4,
+ org.eclipse.equinox.launcher,
+ org.eclipse.equinox.http.registry
Eclipse-RegisterBuddy: org.apache.uima.runtime
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-LazyStart: true
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AbstractNlpElement.java Mon Sep 10 04:23:19 2007
@@ -77,21 +77,23 @@
/**
* Adds resources after the element was initialized.
- *
- * @param resource
+ * @param delta TODO
+ * @param resource
* the added resource
+ *
* @throws CoreException
*/
- abstract void addResource(IResource resource) throws CoreException;
+ abstract void addResource(INlpElementDelta delta, IResource resource) throws CoreException;
/**
* Removes resources after the element was initialized.
- *
- * @param resource
+ * @param delta TODO
+ * @param resource
* the removed resource
+ *
* @throws CoreException
*/
- abstract void removeResource(IResource resource) throws CoreException;
+ abstract void removeResource(INlpElementDelta delta, IResource resource) throws CoreException;
/**
* Changed resource after the element was initialized.
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/AnnotatorElement.java Mon Sep 10 04:23:19 2007
@@ -128,7 +128,7 @@
// private void createMarker()
@Override
- void addResource(IResource resource) {
+ void addResource(INlpElementDelta delta, IResource resource) {
// just do nothing, no children
}
@@ -138,7 +138,7 @@
}
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
// just do nothing, no children
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/CasProcessorFolder.java Mon Sep 10 04:23:19 2007
@@ -209,7 +209,7 @@
* Not implemented.
*/
@Override
- void addResource(IResource resource) throws CoreException {
+ void addResource(INlpElementDelta delta, IResource resource) throws CoreException {
if (resource instanceof IFile) {
// if .con file notify it
if (resource.getName().endsWith(".con")) {
@@ -253,7 +253,7 @@
* Not implemented.
*/
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
if (resource instanceof IFile) {
// if .con file notify it
if (resource.getName().endsWith(".con")) {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/ConsumerElement.java Mon Sep 10 04:23:19 2007
@@ -124,7 +124,7 @@
}
@Override
- void addResource(IResource resource) {
+ void addResource(INlpElementDelta delta, IResource resource) {
// just do nothing, no children
}
@@ -134,7 +134,7 @@
}
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
// just do nothing, no children
}
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=574204&r1=574203&r2=574204&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 Sep 10 04:23:19 2007
@@ -174,11 +174,10 @@
/**
* Adds the given resource.
- *
- * @param resource
+ * @param resource
*/
@Override
- void addResource(IResource resource) {
+ void addResource(INlpElementDelta delta, IResource resource) {
if (resource instanceof IFile) {
mDocuments.add(new DocumentElement(this, (IFile) resource));
}
@@ -196,11 +195,10 @@
/**
* Removes the given resource.
- *
- * @param resource
+ * @param resource
*/
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
for (DocumentElement document : mDocuments) {
if (document.getResource().equals(resource)) {
mDocuments.remove(document);
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=574204&r1=574203&r2=574204&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 Sep 10 04:23:19 2007
@@ -156,7 +156,7 @@
* Not implemented.
*/
@Override
- void addResource(IResource resource) {
+ void addResource(INlpElementDelta delta, IResource resource) {
// not needed here, there are no resources
}
@@ -179,7 +179,7 @@
* Not implemented.
*/
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
// not needed here, there are no resources
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/DotCorpusElement.java Mon Sep 10 04:23:19 2007
@@ -27,6 +27,7 @@
import org.apache.uima.cas.Type;
import org.apache.uima.caseditor.CasEditorPlugin;
+import org.apache.uima.caseditor.core.model.delta.INlpElementDelta;
import org.apache.uima.caseditor.core.model.dotcorpus.AnnotationStyle;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpus;
import org.apache.uima.caseditor.core.model.dotcorpus.DotCorpusSerializer;
@@ -66,7 +67,7 @@
/**
* Retrieves the name of the type system file.
*
- * @return - type system file name
+ * @return - type system file name or null if no set
*/
public IFile getTypeSystemFile() {
IFile result;
@@ -389,7 +390,7 @@
* Not implemented.
*/
@Override
- void addResource(IResource resource) {
+ void addResource(INlpElementDelta delta, IResource resource) {
// not needed here, there are no child resources
}
@@ -397,7 +398,7 @@
* Not implemented.
*/
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
// not needed here, there are no child resources
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpModel.java Mon Sep 10 04:23:19 2007
@@ -132,7 +132,7 @@
* Executes the current action.
*/
public void handle(NlpModelDeltaImpl delta) {
- CasEditorPlugin.getNlpModel().addInternal(delta.getResource());
+ CasEditorPlugin.getNlpModel().addInternal(delta, delta.getResource());
/*
* Note: If a project is added, it is closed (isOpen() == false). Tough, the .project file is
@@ -167,7 +167,7 @@
INlpElement parent = delta.getNlpElement().getParent();
if (parent != null) {
- CasEditorPlugin.getNlpModel().removeInternal(delta.getResource());
+ CasEditorPlugin.getNlpModel().removeInternal(delta, delta.getResource());
}
}
}
@@ -384,7 +384,7 @@
}
}
- void addInternal(IResource resource) {
+ void addInternal(INlpElementDelta delta, IResource resource) {
// TODO: why is this possible ?
if (resource.equals(mWorkspaceRoot)) {
return;
@@ -396,7 +396,7 @@
if (parentElement != null) {
try {
- parentElement.addResource(resource);
+ parentElement.addResource(delta, resource);
} catch (CoreException e) {
handleExceptionDuringResoruceChange(e);
}
@@ -404,7 +404,7 @@
}
@Override
- void addResource(IResource resource) throws CoreException {
+ void addResource(INlpElementDelta delta, IResource resource) throws CoreException {
if (resource instanceof IProject) {
IProject project = (IProject) resource;
@@ -413,14 +413,14 @@
}
}
- void removeInternal(IResource resource) {
+ void removeInternal(INlpElementDelta delta, IResource resource) {
IResource parent = resource.getParent();
AbstractNlpElement parentElement = (AbstractNlpElement) findMember(parent);
if (parentElement != null) {
try {
- parentElement.removeResource(resource);
+ parentElement.removeResource(delta, resource);
} catch (CoreException e) {
handleExceptionDuringResoruceChange(e);
}
@@ -428,7 +428,7 @@
}
@Override
- void removeResource(IResource resource) {
+ void removeResource(INlpElementDelta delta, IResource resource) {
for (NlpProject project : mNlpProjects) {
if (project.getResource().equals(resource)) {
mNlpProjects.remove(project);
@@ -624,7 +624,7 @@
*
* @param worker
*/
- void asyncExcuteQueue(Runnable worker) {
+ public void asyncExcuteQueue(Runnable worker) {
mAsynchronExecutor.submit(worker);
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/NlpProject.java Mon Sep 10 04:23:19 2007
@@ -35,6 +35,8 @@
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
@@ -77,8 +79,9 @@
/**
* Initializes the current instance. This method is called before this instance can be used.
- * Currently it recognizes and loads all nlp resources. Node: This method should only be called
- * during static {@link NlpModel} creation.
+ * Currently it recognizes and loads all nlp resources.
+ *
+ * Note: This method should only be called during static {@link NlpModel} creation.
*
* @throws CoreException
*/
@@ -190,7 +193,7 @@
mDotCorpusElement = DotCorpusElement.createDotCorpus((IFile) dotCorpusResource, this);
}
- // TODO: What happens when ther is a folder with the name ".corpus"
+ // TODO: What happens when there is a folder with the name ".corpus"
// then load default .corpus ...
}
@@ -360,12 +363,15 @@
* @return the {@link DotCorpusElement}
*/
public DotCorpusElement getDotCorpus() {
- return mDotCorpusElement;
- }
+
+ Assert.isTrue(mDotCorpusElement != null);
+
+ return mDotCorpusElement;
+ }
/**
- * Retrieves the {@link NlpProject}.
- */
+ * Retrieves the {@link NlpProject}.
+ */
public NlpProject getNlpProject() {
return this;
}
@@ -386,15 +392,40 @@
* Adds a resource to the current project instance.
*/
@Override
- public void addResource(IResource resource) throws CoreException {
+ public void addResource(INlpElementDelta delta, IResource resource) throws CoreException {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
if (DOT_CORPUS_FILENAME.equals(file.getName())) {
mIsDotCorpusDirty = true;
}
+ // if type system is set, it could had been renamed
+ else if (mDotCorpusElement.getTypeSystemFile() != null
+ && (delta.getFlags() & IResourceDelta.MOVED_FROM) > 0
+ && mDotCorpusElement.getTypeSystemFile().getFullPath()
+ .equals(delta.getMovedFromPath())) {
+ // rename type system in dot corpus
+ mDotCorpusElement.setTypeSystemFilename(resource.getName());
+
+ // dot corpus was changed and must be writen
+ // do this after the delta processing
+
+
+ Runnable serialze = new Runnable() {
+
+ public void run() {
+ try {
+ mDotCorpusElement.serialize();
+ } catch (CoreException e) {
+ CasEditorPlugin.log(e);
+ }
+ }};
+
+ ((NlpModel) getNlpProject().getParent()).asyncExcuteQueue(serialze);
+ }
// check if file is type system
- else if (mDotCorpusElement.getTypeSystemFile() != null) {
+ else if (mDotCorpusElement.getTypeSystemFile() != null &&
+ mDotCorpusElement.getTypeSystemFile().equals(resource)) {
mTypesystem = new TypesystemElement((IFile) resource, this);
}
} else if (resource instanceof IFolder) {
@@ -411,7 +442,7 @@
* Removes a resource form the current project instance.
*/
@Override
- public void removeResource(IResource resource) {
+ public void removeResource(INlpElementDelta delta, IResource resource) {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
@@ -444,8 +475,7 @@
if (DOT_CORPUS_FILENAME.equals(resource.getName())) {
mIsDotCorpusDirty = true;
}
-
- if (mTypesystem != null && resource.equals(mTypesystem.getResource())) {
+ else if (mTypesystem != null && resource.equals(mTypesystem.getResource())) {
mTypesystem.changedResource(resource, delta);
if (getTypesystemElement().getTypeSystem() != null) {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/TypesystemElement.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/TypesystemElement.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/TypesystemElement.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/TypesystemElement.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -60,22 +60,22 @@
}
public TypeSystem getTypeSystem() {
-
+
CAS cas = getCAS();
-
+
if (cas != null) {
return cas.getTypeSystem();
}
-
- return null;
+
+ return null;
}
-
+
/**
- * Retrieves the {@link CAS}.
- *
- * @return the {@link CAS} or null if there is an error in the type system.
- * @deprecated
- */
+ * Retrieves the {@link CAS}.
+ *
+ * @return the {@link CAS} or null if there is an error in the type system.
+ * @deprecated
+ */
@Deprecated
public CAS getCAS() {
Runnable clearMarkers = new Runnable() {
@@ -102,7 +102,7 @@
}
};
((NlpModel) mProject.getParent()).asyncExcuteQueue(createMarker);
-
+
return null;
}
}
@@ -195,12 +195,12 @@
}
@Override
- void addResource(IResource resource) throws CoreException {
+ void addResource(INlpElementDelta delta, IResource resource) throws CoreException {
// not needed here, there are no child resources
}
@Override
- void removeResource(IResource resource) throws CoreException {
+ void removeResource(INlpElementDelta delta, IResource resource) throws CoreException {
// not needed here, there are no child resources
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/AbstractResourceDelta.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpElementDelta.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,19 +19,22 @@
package org.apache.uima.caseditor.core.model.delta;
-
import org.apache.uima.caseditor.core.model.INlpElement;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.IPath;
/**
* A element delta represents changes in the state of a element tree between two discrete points in
* time.
+ *
+ * @see IResourceDelta
*/
public interface INlpElementDelta {
/**
* Accepts the given visitor. The only kinds of resource deltas visited are <code>ADDED</code>,
* <code>REMOVED</code>, and <code>CHANGED</code>.
- *
+ *
* @param visotor
*/
void accept(INlpModelDeltaVisitor visotor);
@@ -39,43 +42,56 @@
/**
* Returns resource deltas for all children of this resource which were added, removed, or
* changed. Returns an empty array if there are no affected children.
- *
- * @return - childs or empty array
+ *
+ * @return - children or empty array
*/
public INlpElementDelta[] getAffectedChildren();
/**
* Returns true if the given element is an nlp element.
- *
+ *
* @return true if an nlp element otherwise false
*/
boolean isNlpElement();
/**
- * Retrives the nlp element.
- *
+ * Retrieves the nlp element.
+ *
* @return the nlp element or if non null.
*/
INlpElement getNlpElement();
/**
- * Retrives the resource belonging to this delta.
- *
+ * Retrieves the resource belonging to this delta.
+ *
* @return the resource
*/
IResource getResource();
/**
- * Retrives the kind.
- *
+ * Retrieves the kind.
+ *
* @return the kind
*/
Kind getKind();
/**
- * Retrives the flags.
- *
+ * Retrieves the flags.
+ *
* @return the flags
*/
int getFlags();
+
+ /**
+ * Retrieves the moved to path.
+ *
+ * @return
+ */
+ IPath getMovedToPath();
+
+ /**
+ * Retrieves the moved from path.
+ * @return
+ */
+ IPath getMovedFromPath();
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelChangeListener.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -22,12 +22,12 @@
import org.apache.uima.caseditor.core.model.INlpElement;
/**
- * This listener is notfied when the nlp model changes.
+ * This listener is notified when the nlp model changes.
*/
public interface INlpModelChangeListener {
/**
* Called if the nlp model changed.
- *
+ *
* @param delta
* contains the change from one point in time to the next.
*/
@@ -35,7 +35,7 @@
/**
* The given {@link INlpElement} was changed. Clients must refresh.
- *
+ *
* @param element
*/
void refresh(INlpElement element);
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/INlpModelDeltaVisitor.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,9 +25,9 @@
public interface INlpModelDeltaVisitor {
/**
* Called to visit the given delta.
- *
+ *
* @param delta
- * @return true if the implemntor wants to visit childs.
+ * @return true if the implementor wants to visit children.
*/
public boolean visit(INlpElementDelta delta);
-}
+}
\ No newline at end of file
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/Kind.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -34,7 +34,7 @@
REMOVED,
/**
- * Chnaged a resource or one of its childs.
+ * Changed a resource or one of its children.
*/
CHANGED;
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/delta/NlpModelDeltaImpl.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -25,10 +25,11 @@
import org.apache.uima.caseditor.core.model.INlpElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.IPath;
/**
* The internal implementation of the nlp model delta interface.
- *
+ *
* TODO: Add a filter to avoid node with Kind.NOTHING.
*/
public final class NlpModelDeltaImpl implements INlpElementDelta {
@@ -50,7 +51,7 @@
/**
* Initializes a new instance.
- *
+ *
* @param parent
* @param resourceDelta
*/
@@ -72,7 +73,7 @@
/**
* Sets the nlp element Note: do not call this method from ouside code
- *
+ *
* @param element
*/
public void setNlpElement(INlpElement element) {
@@ -80,8 +81,8 @@
}
/**
- * Retrives the parent element or null if this is the root delta.
- *
+ * Retrieves the parent element or null if this is the root delta.
+ *
* @return parent element or null
*/
public INlpElementDelta getParent() {
@@ -90,7 +91,7 @@
/**
* Adds a child to the current element instance.
- *
+ *
* @param child
*/
public void addChild(NlpModelDeltaImpl child) {
@@ -111,7 +112,7 @@
}
/**
- * Retrives the affected children.
+ * Retrieves the affected children.
*/
public INlpElementDelta[] getAffectedChildren() {
return mChildren.toArray(new INlpElementDelta[mChildren.size()]);
@@ -125,21 +126,21 @@
}
/**
- * Retrives the nlp element.
+ * Retrieves the nlp element.
*/
public INlpElement getNlpElement() {
return mNlpElement;
}
/**
- * Retrives the resource.
+ * Retrieves the resource.
*/
public IResource getResource() {
return mResourceDelta.getResource();
}
/**
- * Retrives the kind
+ * Retrieves the kind
*/
public Kind getKind() {
return mKind;
@@ -148,7 +149,7 @@
/**
* Sets the new kind. This method should only be called from the event handlers snd not by any
* client.
- *
+ *
* @param kind
*/
public void setKind(Kind kind) {
@@ -156,23 +157,31 @@
}
/**
- * Retrives the original flags of the {@link IResourceDelta} object.
+ * Retrieves the original flags of the {@link IResourceDelta} object.
*/
public int getFlags() {
return mResourceDelta.getFlags();
}
/**
- * Retrives the resource delta.
- *
+ * Retrieves the resource delta.
+ *
* @return the resource delta
*/
public IResourceDelta getResourceDelta() {
return mResourceDelta;
}
+ public IPath getMovedFromPath() {
+ return mResourceDelta.getMovedFromPath();
+ }
+
+ public IPath getMovedToPath() {
+ return mResourceDelta.getMovedToPath();
+ }
+
/**
- * Retrives a human-readable string of the current instance.
+ * Retrieves a human-readable string of the current instance.
*/
@Override
public String toString() {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/AnnotationStyle.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,11 +31,11 @@
* The styles that can be used to draw an annotation.
*/
public enum Style {
-
+
TEXT_COLOR,
-
+
TOKEN,
-
+
/**
* The squiggles style.
*/
@@ -75,7 +75,7 @@
/**
* Initialize a new instance.
- *
+ *
* @param annotation -
* the annotation type
* @param style -
@@ -108,7 +108,7 @@
/**
* Retrives the annoation type.
- *
+ *
* @return - annotation type.
*/
public String getAnnotation() {
@@ -117,7 +117,7 @@
/**
* Retrives the drawing style of the annotation.
- *
+ *
* @return - annotation drawing style
*/
public Style getStyle() {
@@ -126,7 +126,7 @@
/**
* Retrives the color of the annotation.
- *
+ *
* @return - annotation color
*/
public Color getColor() {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -64,7 +64,7 @@
/**
* Retrives type system name parameter.
- *
+ *
* @return type system name parameter
*/
public String getTypeSystemFileName() {
@@ -73,7 +73,7 @@
/**
* Sets type system name parameter.
- *
+ *
* @param name
* type system name parameter
*/
@@ -83,7 +83,7 @@
/**
* Retrvies the uima config folder name parameter.
- *
+ *
* @return uima config folder name parameter.
*/
public Collection<String> getCasProcessorFolderNames() {
@@ -92,21 +92,21 @@
/**
* Sets the uima config folder name parameter.
- *
+ *
* @param folder
* uima config folder name parameter.
*/
public void addCasProcessorFolder(String folder) {
mCasProcessorFolders.add(folder);
}
-
+
public void removeCasProcessorFolder(String folder) {
mCasProcessorFolders.remove(folder);
}
/**
* Adds a corpus folder
- *
+ *
* @param name
*/
public void addCorpusFolder(String name) {
@@ -115,7 +115,7 @@
/**
* Removes the given corpus folder.
- *
+ *
* @param name
*/
public void removeCorpusFolder(String name) {
@@ -124,7 +124,7 @@
/**
* Retrives the list of all corpus fodlers.
- *
+ *
* @return corpus folder list
*/
public Collection<String> getCorpusFolderNameList() {
@@ -133,7 +133,7 @@
/**
* Retrvies the editor line length hint parameter.
- *
+ *
* @return line length hint
*/
public int getEditorLineLengthHint() {
@@ -142,7 +142,7 @@
/**
* Sets the editor line length hint parameter.
- *
+ *
* @param lineLengthHint
*/
public void setEditorLineLength(int lineLengthHint) {
@@ -151,7 +151,7 @@
/**
* Retrives the annotation styles.
- *
+ *
* @return - the annoation styles
*/
public Collection<AnnotationStyle> getAnnotationStyles() {
@@ -160,7 +160,7 @@
/**
* Adds an AnnotationStyle. TODO: move style stuff to nlp project
- *
+ *
* @param style
*/
public void setStyle(AnnotationStyle style) {
@@ -174,7 +174,7 @@
/**
* Removes an AnnotationStyle for the given name, does nothing if not existent.
- *
+ *
* @param name
*/
public void removeStyle(String name) {
@@ -183,7 +183,7 @@
/**
* Retrives the AnnotationStyle for the given type or null if not available.
- *
+ *
* @param type
* @return the requested style or null if none
*/
@@ -203,9 +203,9 @@
*/
@Override
public boolean equals(Object obj) {
-
- boolean result;
-
+
+ boolean result;
+
if (obj == this) {
result = true;
}
@@ -222,13 +222,13 @@
else {
result = false;
}
-
+
return result;
}
/**
* Compares two objects for equality.
- *
+ *
* @param a -
* the first object or null
* @param b -
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -72,7 +72,7 @@
/**
* Creats a {@link DotCorpus} object from a given {@link InputStream}.
- *
+ *
* @param dotCorpusStream
* @return the {@link DotCorpus} instance.
* @throws CoreException
@@ -174,7 +174,7 @@
/**
* Writes the <code>DotCorpus</code> instance to the given <code>OutputStream</code>.
- *
+ *
* @param dotCorpus
* the {@link DotCorpus} object to serialize.
* @param out -
@@ -185,7 +185,7 @@
XMLSerializer xmlSerializer = new XMLSerializer(out, true);
ContentHandler xmlSerHandler = xmlSerializer.getContentHandler();
-
+
try {
xmlSerHandler.startDocument();
xmlSerHandler.startElement("", CONFIG_ELEMENT, CONFIG_ELEMENT, new AttributesImpl());
@@ -225,7 +225,7 @@
for (String folder : dotCorpus.getCasProcessorFolderNames()) {
AttributesImpl taggerConfigAttributes = new AttributesImpl();
taggerConfigAttributes.addAttribute("", "", CAS_PROCESSOR_FOLDER_ATTRIBUTE, "", folder);
-
+
xmlSerHandler.startElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT, taggerConfigAttributes);
xmlSerHandler.endElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT);
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/EditorAnnotationStatus.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/EditorAnnotationStatus.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/EditorAnnotationStatus.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/EditorAnnotationStatus.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -34,7 +34,7 @@
/**
* Initializes a new instance.
- *
+ *
* @param mode
* @param displayAnnotations
*/
@@ -47,12 +47,12 @@
if (displayAnnotations != null) {
mDisplayAnnotations.addAll(displayAnnotations);
- }
+ }
}
/**
* Retrives the editor mode.
- *
+ *
* @return the editor mode
*/
public Type getMode() {
@@ -61,7 +61,7 @@
/**
* Retrives the annotations wich a displayed in the editor.
- *
+ *
* @return the display annotations
*/
public Collection<Type> getDisplayAnnotations() {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java Mon Sep 10 04:23:19 2007
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,6 +24,7 @@
import org.apache.uima.cas.CAS;
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.DotCorpusElement;
import org.apache.uima.caseditor.core.model.INlpElement;
import org.apache.uima.caseditor.core.model.NlpProject;
@@ -47,246 +48,212 @@
import org.eclipse.ui.dialogs.PropertyPage;
/**
- * This is the <code>AnnotationPropertyPage</code>. this page configures
- * the project dependent and type dependent annotation appearance in the
+ * This is the <code>AnnotationPropertyPage</code>. this page configures the
+ * project dependent and type dependent annotation appearance in the
* <code>AnnotationEditor</code>.
*/
-public class AnnotationPropertyPage extends PropertyPage
-{
- private DotCorpusElement mDotCorpusElement;
-
- private Combo mStyleCombo;
-
- private ColorSelector mColorSelector;
-
- private List mTypeList;
-
- private AnnotationStyle mCurrentSelectedAnnotation = null;
-
- private NlpProject mProject;
-
- /**
- * Creates the annotation property page controls.
- */
- @Override
- protected Control createContents(Composite parent)
- {
- mProject = ((INlpElement) getElement()).getNlpProject();
-
- TypesystemElement typesystem = mProject.getTypesystemElement();
-
- if (typesystem == null)
- {
- Label message = new Label(parent, SWT.NONE);
- message.setText("Please set a valid typesystem file first.");
-
- return message;
- }
-
- mDotCorpusElement = mProject.getDotCorpus();
-
- Composite base = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- base.setLayout(layout);
-
- // type text
- Label typeText = new Label(base, SWT.NONE);
- typeText.setText("Annotation types:");
-
- GridData typeTextGridData = new GridData();
- typeTextGridData.horizontalSpan = 2;
- typeText.setLayoutData(typeTextGridData);
-
- // type list
- mTypeList = new List(base, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
- GridData typeListGridData = new GridData();
- typeListGridData.horizontalAlignment = SWT.FILL;
- typeListGridData.grabExcessVerticalSpace = true;
- typeListGridData.verticalAlignment = SWT.FILL;
- typeListGridData.verticalSpan = 2;
- mTypeList.setLayoutData(typeListGridData);
-
-
- TypeSystem typeSytstem = mProject.getTypesystemElement().getTypeSystem();
-
- Type annotationType = typeSytstem.getType(CAS.TYPE_NAME_ANNOTATION);
-
- java.util.List types = typeSytstem.getProperlySubsumedTypes(annotationType);
- // Vector types = typeSytstem.getDirectlySubsumedTypes(annotationType);
-
- for (Object typeObject : types)
- {
- Type type = (Type) typeObject;
-
- mTypeList.add(type.getName());
- }
-
- mTypeList.addSelectionListener(new SelectionListener()
- {
-
- public void widgetSelected(SelectionEvent e)
- {
- itemSelected();
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- // not needed
- }
-
- });
-
- Composite settingsComposite = new Composite(base, SWT.NONE);
-
- GridLayout settingsLayout = new GridLayout();
- settingsLayout.numColumns = 2;
- settingsComposite.setLayout(settingsLayout);
-
- // text style combo
- Label styleText = new Label(settingsComposite, SWT.READ_ONLY);
-
- styleText.setText("Style:");
-
- // style combo
- mStyleCombo = new Combo(settingsComposite, SWT.READ_ONLY | SWT.DROP_DOWN);
- mStyleCombo.setEnabled(false);
- mStyleCombo.addSelectionListener(new SelectionListener()
- {
- public void widgetSelected(SelectionEvent e)
- {
- styleChanged();
- }
-
- public void widgetDefaultSelected(SelectionEvent e)
- {
- // not needed
- }
-
- });
- AnnotationStyle.Style possibleStyles[] = AnnotationStyle.Style.values();
-
- for (AnnotationStyle.Style style : possibleStyles)
- {
- mStyleCombo.add(style.name());
- }
-
- // text color label
- Label colorText = new Label(settingsComposite, SWT.NONE);
- colorText.setText("Color:");
-
- mColorSelector = new ColorSelector(settingsComposite);
- mColorSelector.setEnabled(false);
- mColorSelector.addListener(new IPropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent event)
- {
- colorChanged();
- }
- });
-
- mTypeList.select(0);
-
- if (mTypeList.getSelectionIndex() != -1)
- {
- itemSelected();
- }
-
- return base;
+public class AnnotationPropertyPage extends PropertyPage {
+ private DotCorpusElement mDotCorpusElement;
+
+ private Combo mStyleCombo;
+
+ private ColorSelector mColorSelector;
+
+ private List mTypeList;
+
+ private AnnotationStyle mCurrentSelectedAnnotation = null;
+
+ private NlpProject mProject;
+
+ /**
+ * Creates the annotation property page controls.
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ mProject = ((INlpElement) getElement()).getNlpProject();
+
+ mDotCorpusElement = mProject.getDotCorpus();
+
+ TypesystemElement typesystem = mProject.getTypesystemElement();
+
+ if (typesystem == null) {
+ Label message = new Label(parent, SWT.NONE);
+ message.setText("Please set a valid typesystem file first.");
+
+ return message;
}
-
- private void colorChanged()
- {
- if (mCurrentSelectedAnnotation == null)
- {
- mCurrentSelectedAnnotation = getDefaultAnnotation();
- }
-
- RGB colorRGB = mColorSelector.getColorValue();
-
- Color color = new Color(colorRGB.red, colorRGB.green, colorRGB.blue);
-
- mCurrentSelectedAnnotation = new AnnotationStyle(
- mCurrentSelectedAnnotation.getAnnotation(),
- mCurrentSelectedAnnotation.getStyle(),
- color);
-
- mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
+
+
+ Composite base = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ base.setLayout(layout);
+
+ // type text
+ Label typeText = new Label(base, SWT.NONE);
+ typeText.setText("Annotation types:");
+
+ GridData typeTextGridData = new GridData();
+ typeTextGridData.horizontalSpan = 2;
+ typeText.setLayoutData(typeTextGridData);
+
+ // type list
+ mTypeList = new List(base, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+ GridData typeListGridData = new GridData();
+ typeListGridData.horizontalAlignment = SWT.FILL;
+ typeListGridData.grabExcessVerticalSpace = true;
+ typeListGridData.verticalAlignment = SWT.FILL;
+ typeListGridData.verticalSpan = 2;
+ mTypeList.setLayoutData(typeListGridData);
+
+ TypeSystem typeSytstem = mProject.getTypesystemElement().getTypeSystem();
+
+ Type annotationType = typeSytstem.getType(CAS.TYPE_NAME_ANNOTATION);
+
+ java.util.List types = typeSytstem.getProperlySubsumedTypes(annotationType);
+ // Vector types = typeSytstem.getDirectlySubsumedTypes(annotationType);
+
+ for (Object typeObject : types) {
+ Type type = (Type) typeObject;
+
+ mTypeList.add(type.getName());
}
-
- private void styleChanged()
- {
- if (mCurrentSelectedAnnotation == null)
- {
- mCurrentSelectedAnnotation = getDefaultAnnotation();
- }
-
- mCurrentSelectedAnnotation = new AnnotationStyle(
- mCurrentSelectedAnnotation.getAnnotation(),
- AnnotationStyle.Style.valueOf(mStyleCombo.getText()),
- mCurrentSelectedAnnotation.getColor());
-
- mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
+
+ mTypeList.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ itemSelected();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // not needed
+ }
+
+ });
+
+ Composite settingsComposite = new Composite(base, SWT.NONE);
+
+ GridLayout settingsLayout = new GridLayout();
+ settingsLayout.numColumns = 2;
+ settingsComposite.setLayout(settingsLayout);
+
+ // text style combo
+ Label styleText = new Label(settingsComposite, SWT.READ_ONLY);
+
+ styleText.setText("Style:");
+
+ // style combo
+ mStyleCombo = new Combo(settingsComposite, SWT.READ_ONLY | SWT.DROP_DOWN);
+ mStyleCombo.setEnabled(false);
+ mStyleCombo.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ styleChanged();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // not needed
+ }
+
+ });
+ AnnotationStyle.Style possibleStyles[] = AnnotationStyle.Style.values();
+
+ for (AnnotationStyle.Style style : possibleStyles) {
+ mStyleCombo.add(style.name());
}
-
- private void itemSelected()
- {
- String name =
- mTypeList.getItem(mTypeList.getSelectionIndex());
-
- TypeSystem typesystem = mProject.getTypesystemElement().getTypeSystem();
-
- AnnotationStyle style = mDotCorpusElement.getAnnotation(
- typesystem.getType(name));
-
- mCurrentSelectedAnnotation = style;
-
- if (style == null)
- {
- style = new AnnotationStyle(name,
- AnnotationStyle.DEFAULT_STYLE,
- AnnotationStyle.DEFAULT_COLOR);
- }
-
- mStyleCombo.setText(style.getStyle().name());
- mStyleCombo.setEnabled(true);
-
- Color color = style.getColor();
- mColorSelector.setColorValue(new RGB(color.getRed(), color.getGreen(),
- color.getBlue()));
- mColorSelector.setEnabled(true);
+
+ // text color label
+ Label colorText = new Label(settingsComposite, SWT.NONE);
+ colorText.setText("Color:");
+
+ mColorSelector = new ColorSelector(settingsComposite);
+ mColorSelector.setEnabled(false);
+ mColorSelector.addListener(new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ colorChanged();
+ }
+ });
+
+ mTypeList.select(0);
+
+ if (mTypeList.getSelectionIndex() != -1) {
+ itemSelected();
}
-
- private AnnotationStyle getDefaultAnnotation()
- {
- return new AnnotationStyle(mTypeList.getItem(
- mTypeList.getSelectionIndex()), AnnotationStyle.DEFAULT_STYLE,
- AnnotationStyle.DEFAULT_COLOR);
+
+ return base;
+ }
+
+ private void colorChanged() {
+ if (mCurrentSelectedAnnotation == null) {
+ mCurrentSelectedAnnotation = getDefaultAnnotation();
}
-
- /**
- * Executed after the OK button was pressed.
- */
- @Override
- public boolean performOk()
- {
- // workaround for typesystem not present problem
- if (mProject.getTypesystemElement() == null ||
- mProject.getTypesystemElement().getTypeSystem() == null)
- {
- return true;
- }
-
- try
- {
- mDotCorpusElement.serialize();
- }
- catch (CoreException e)
- {
- e.printStackTrace();
- return false;
- }
-
- return true;
+
+ RGB colorRGB = mColorSelector.getColorValue();
+
+ Color color = new Color(colorRGB.red, colorRGB.green, colorRGB.blue);
+
+ mCurrentSelectedAnnotation = new AnnotationStyle(mCurrentSelectedAnnotation.getAnnotation(),
+ mCurrentSelectedAnnotation.getStyle(), color);
+
+ mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
+ }
+
+ private void styleChanged() {
+ if (mCurrentSelectedAnnotation == null) {
+ mCurrentSelectedAnnotation = getDefaultAnnotation();
}
-}
+
+ mCurrentSelectedAnnotation = new AnnotationStyle(mCurrentSelectedAnnotation.getAnnotation(),
+ AnnotationStyle.Style.valueOf(mStyleCombo.getText()), mCurrentSelectedAnnotation
+ .getColor());
+
+ mDotCorpusElement.setStyle(mCurrentSelectedAnnotation);
+ }
+
+ private void itemSelected() {
+ String name = mTypeList.getItem(mTypeList.getSelectionIndex());
+
+ TypeSystem typesystem = mProject.getTypesystemElement().getTypeSystem();
+
+ AnnotationStyle style = mDotCorpusElement.getAnnotation(typesystem.getType(name));
+
+ mCurrentSelectedAnnotation = style;
+
+ if (style == null) {
+ style = new AnnotationStyle(name, AnnotationStyle.DEFAULT_STYLE,
+ AnnotationStyle.DEFAULT_COLOR);
+ }
+
+ mStyleCombo.setText(style.getStyle().name());
+ mStyleCombo.setEnabled(true);
+
+ Color color = style.getColor();
+ mColorSelector.setColorValue(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
+ mColorSelector.setEnabled(true);
+ }
+
+ private AnnotationStyle getDefaultAnnotation() {
+ return new AnnotationStyle(mTypeList.getItem(mTypeList.getSelectionIndex()),
+ AnnotationStyle.DEFAULT_STYLE, AnnotationStyle.DEFAULT_COLOR);
+ }
+
+ /**
+ * Executed after the OK button was pressed.
+ */
+ @Override
+ public boolean performOk() {
+ // workaround for type system not present problem
+ if (mProject.getTypesystemElement() == null
+ || mProject.getTypesystemElement().getTypeSystem() == null) {
+ return true;
+ }
+
+ try {
+ mDotCorpusElement.serialize();
+ } catch (CoreException e) {
+ CasEditorPlugin.log(e);
+ return false;
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
Modified: incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java?rev=574204&r1=574203&r2=574204&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/plugintest/java/org/apache/uima/caseditor/core/test/NlpModelTest.java Mon Sep 10 04:23:19 2007
@@ -27,11 +27,14 @@
import org.apache.uima.caseditor.CasEditorPlugin;
import org.apache.uima.caseditor.core.model.DocumentElement;
import org.apache.uima.caseditor.core.model.INlpElement;
+import org.apache.uima.caseditor.core.model.NlpProject;
import org.apache.uima.caseditor.core.model.delta.INlpElementDelta;
import org.apache.uima.caseditor.core.model.delta.INlpModelChangeListener;
import org.apache.uima.caseditor.core.model.delta.Kind;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.junit.Before;
import org.junit.Test;
@@ -41,6 +44,12 @@
private TestProject mProject;
/**
+ * This flag is used by the {@link NlpModelTest#testTypesystemRename()} method.
+ * It indicates that the rename of the type system is completed.
+ */
+ private volatile boolean finishedRenameOfTypesystem;
+
+ /**
* Initializes the current instance.
*/
public NlpModelTest() {
@@ -242,4 +251,50 @@
CasEditorPlugin.getNlpModel().removeNlpModelChangeListener(listener);
}
}
-}
+
+ @Test
+ public void testTypesystemRename() throws CoreException {
+ mProject.createProject();
+ mProject.createProjectContent();
+ mProject.createDotCorpus();
+
+ IPath typesystemPath = mProject.getTypesystem().getFullPath();
+
+ IPath renamedTypesystemPath = new Path(typesystemPath.removeLastSegments(1).toPortableString() + "/" +
+ "NewTS.xml");
+
+ mProject.getTypesystem()
+ .move(renamedTypesystemPath, true, null);
+
+ // wait until the nlp model was update
+ // during the update the internal change listeners post a runnable which serializes the
+ // dotCorpus to the execute queue of the nlp model
+
+ // Now post a runnable after the runnable from the change listener
+ CasEditorPlugin.getNlpModel().asyncExcuteQueue(new Runnable() {
+
+ public void run() {
+ synchronized (NlpModelTest.this) {
+ finishedRenameOfTypesystem = true;
+ NlpModelTest.this.notifyAll();
+ }
+ }
+ });
+
+ // wait until this runnable was executed, to make sure the changes where processed
+ synchronized (this) {
+ while (!finishedRenameOfTypesystem) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ NlpProject nlpProject = (NlpProject) CasEditorPlugin.getNlpModel().findMember(
+ mProject.getProject());
+
+ assertTrue(nlpProject.getTypesystemElement().getResource().
+ getFullPath().equals(renamedTypesystemPath));
+ }
+}
\ No newline at end of file