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/07/20 14:02:31 UTC
svn commit: r557975 - in
/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor:
./ core/ core/model/ core/model/delta/ core/model/dotcorpus/ core/uima/
editor/ editor/fsview/ editor/outline/ ui/action/ ui/corpusview/ ui/model/...
Author: twgoetz
Date: Fri Jul 20 05:02:29 2007
New Revision: 557975
URL: http://svn.apache.org/viewvc?view=rev&rev=557975
Log:
Jira UIMA-504: apply UIMA-504.patch.
https://issues.apache.org/jira/browse/UIMA-504
Modified:
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationActionBarAdvisor.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchAdvisor.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchWindowAdvisor.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/FileEditorInput.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractDocument.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocument.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocumentListener.java
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/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/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/NlpModelDeltaImpl.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/core/uima/DocumentUimaImpl.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerView.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/PasteAction.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ResourceAction.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/model/TypesystemAdapter.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationActionBarAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationActionBarAdvisor.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationActionBarAdvisor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationActionBarAdvisor.java Fri Jul 20 05:02:29 2007
@@ -49,6 +49,7 @@
super(configurer);
}
+ @Override
protected void makeActions(IWorkbenchWindow window) {
this.window = window;
@@ -99,6 +100,7 @@
// openWorkspaceAction = new OpenWorkspaceAction(window);
}
+ @Override
protected void fillMenuBar(IMenuManager menuBar) {
// File menu
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchAdvisor.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchAdvisor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchAdvisor.java Fri Jul 20 05:02:29 2007
@@ -34,6 +34,7 @@
private static final String PERSPECTIVE_ID = "org.apache.uima.caseditor.perspective.NLP";
+ @Override
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
return new ApplicationWorkbenchWindowAdvisor(configurer);
}
@@ -43,6 +44,7 @@
configurer.setSaveAndRestore(true);
}
+ @Override
public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchWindowAdvisor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchWindowAdvisor.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchWindowAdvisor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ApplicationWorkbenchWindowAdvisor.java Fri Jul 20 05:02:29 2007
@@ -31,10 +31,12 @@
super(configurer);
}
+ @Override
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
return new ApplicationActionBarAdvisor(configurer);
}
+ @Override
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(400, 300));
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/FileEditorInput.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/FileEditorInput.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/FileEditorInput.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/FileEditorInput.java Fri Jul 20 05:02:29 2007
@@ -83,6 +83,7 @@
return mFile.hashCode();
}
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractDocument.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractDocument.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractDocument.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractDocument.java Fri Jul 20 05:02:29 2007
@@ -44,7 +44,7 @@
private Set<IDocumentListener> mListener = new HashSet<IDocumentListener>();
/**
- * Registers a change listerner.
+ * Registers a change listener.
*
* @param listener
*/
@@ -148,8 +148,14 @@
}
}
+ protected void fireChanged() {
+ for (IDocumentListener listener : mListener) {
+ listener.changed();
+ }
+ }
+
/**
- * Retrives the view map.
+ * Retrieves the view map.
*/
public Map<Integer, AnnotationFS> getView(Type annotationType) {
Collection<AnnotationFS> annotations = getAnnotations(annotationType);
@@ -166,14 +172,14 @@
}
/**
- * Retrives the text in the given bounds.
+ * Retrieves the text in the given bounds.
*/
public String getText(int start, int end) {
return getText().substring(start, end);
}
/**
- * Retrives annotions of the given type in the given bounds.
+ * Retrieves annotations of the given type in the given bounds.
*/
public Collection<AnnotationFS> getAnnotation(Type type, Span span) {
Map<Integer, AnnotationFS> view = getView(type);
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocument.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocument.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocument.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocument.java Fri Jul 20 05:02:29 2007
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.core;
-import java.io.InputStream;
import java.util.Collection;
import java.util.Map;
@@ -27,11 +26,22 @@
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.model.DocumentElement;
import org.apache.uima.caseditor.core.util.Span;
import org.eclipse.core.runtime.CoreException;
/**
- * TODO: add javadoc here
+ * The {@link IDocument} represents texts with meta information.
+ *
+ * A {@link IDocument} allows manipulation of its meta information
+ * the text must not be changed.
+ *
+ * Meta information can be retrieved over the {@link CAS} object.
+ *
+ * Note: All changes to meta information should be done with
+ * calls to the manipulation methods of the document.
+ * If this is not possible, change the {@link CAS} and after
+ * the change call the {@link IDocument#changed()} method.
*/
public interface IDocument {
@@ -50,7 +60,7 @@
void removeChangeListener(IDocumentListener listener);
/**
- * Retrives the CAS.
+ * Retrieves the CAS.
*
* @return the CAS
*/
@@ -105,6 +115,7 @@
*
* @deprecated
*/
+ @Deprecated
void removeAnnotation();
/**
@@ -129,6 +140,11 @@
void updateAnnotations(Collection<AnnotationFS> annotations);
/**
+ * The document was changed. Its unknown what changed.
+ */
+ void changed();
+
+ /**
* Returns all <code>Annotation</code>s of the given type.
*
* @param type -
@@ -139,7 +155,7 @@
Collection<AnnotationFS> getAnnotations(Type type);
/**
- * Retrives the view map.
+ * Retrieves the view map.
*
* @param annotationType
* @return the view map
@@ -147,7 +163,7 @@
Map<Integer, AnnotationFS> getView(Type annotationType);
/**
- * Retrives the annotations of the given type inside the given span.
+ * Retrieves the annotations of the given type inside the given span.
*
* @param type
* @param span
@@ -156,14 +172,14 @@
Collection<AnnotationFS> getAnnotation(Type type, Span span);
/**
- * Retrvies the text.
+ * Retrieves the text.
*
* @return the text as string
*/
String getText();
/**
- * Retrives the text betweene start and end offstes.
+ * Retrieves the text between start and end offsets.
*
* @param start
* @param end
@@ -172,7 +188,7 @@
String getText(int start, int end);
/**
- * Retrives the requested type.
+ * Retrieves the requested type.
*
* @param type
* @return the type
@@ -180,10 +196,15 @@
Type getType(String type);
/**
- * Serializes the doucment to the given OutputStream.
+ * Serializes the document to the given OutputStream.
*
* @param out
* @throws CoreException
*/
void save() throws CoreException;
+
+ /**
+ * Retrieves the document element belonging to the document.
+ */
+ DocumentElement getDocumentElement();
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocumentListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocumentListener.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocumentListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/IDocumentListener.java Fri Jul 20 05:02:29 2007
@@ -72,4 +72,12 @@
* @param featureStructure
*/
void updated(Collection<FeatureStructure> featureStructure);
+
+ /**
+ * This method is called if {@link FeatureStructure}s in the
+ * document are changed.
+ *
+ * Note: The text can not be changed
+ */
+ void changed();
}
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -44,6 +44,7 @@
/**
* Retrives the {@link IResource} of the current instance.
*/
+ @Override
public Object getAdapter(Class adapter) {
Object result;
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -142,6 +142,7 @@
* Retrives the nlp element for the given resource. If contained by the current element or one of
* its childs.
*/
+ @Override
public INlpElement findMember(IResource resource) {
if (mCorpusFolder.equals(resource)) {
return this;
@@ -176,6 +177,7 @@
*
* @param resource
*/
+ @Override
void addResource(IResource resource) {
if (resource instanceof IFile) {
mDocuments.add(new DocumentElement(this, (IFile) resource));
@@ -197,6 +199,7 @@
*
* @param resource
*/
+ @Override
void removeResource(IResource resource) {
for (DocumentElement document : mDocuments) {
if (document.getResource().equals(resource)) {
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -51,6 +51,8 @@
private SoftReference<DocumentUimaImpl> mWorkingCopy =
new SoftReference<DocumentUimaImpl>(null);
+ private boolean isSavingWorkingCopy;
+
/**
* Initializes a new instance.
*
@@ -69,14 +71,14 @@
}
/**
- * Retrives the coresponding resource.
+ * Retrieves the corresponding resource.
*/
public IFile getResource() {
return mDocumentFile;
}
/**
- * Retrives the name.
+ * Retrieves the name.
*/
public String getName() {
return mDocumentFile.getName();
@@ -84,14 +86,14 @@
/**
- * Retrives the parent.
+ * Retrieves the parent.
*/
public INlpElement getParent() {
return mParent;
}
/**
- * Retrives the working copy.
+ * Retrieves the working copy.
*
* @return the working copy
* @throws CoreException
@@ -129,6 +131,9 @@
* @throws CoreException
*/
public void saveDocument() throws CoreException {
+
+ isSavingWorkingCopy = true;
+
ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
((DocumentUimaImpl) getDocument()).serialize(outStream);
@@ -139,7 +144,7 @@
}
/**
- * Retrives the coresponding {@link NlpProject} instance.
+ * Retrieves the corresponding {@link NlpProject} instance.
*
* @return the {@link NlpProject} instance
*/
@@ -157,9 +162,17 @@
@Override
void changedResource(IResource resource, INlpElementDelta delta) {
- // TODO: What should happen if the doucment is changed externally
- // e.g. with a texteditor ?
- mWorkingCopy = new SoftReference<DocumentUimaImpl>(null);
+ // TODO: What should happen if the document is changed externally
+ // e.g. with a text editor ?
+
+ // if saveDocument() was called, we receive a changedResource event
+ // in this case do not remove a reference to the working copy, cause its in sync
+ if (!isSavingWorkingCopy) {
+ mWorkingCopy = new SoftReference<DocumentUimaImpl>(null);
+ } else {
+ isSavingWorkingCopy = false;
+ }
+
}
/**
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -411,6 +411,7 @@
}
}
+ @Override
void addResource(IResource resource) throws CoreException {
if (resource instanceof IProject) {
IProject project = (IProject) resource;
@@ -434,6 +435,7 @@
}
}
+ @Override
void removeResource(IResource resource) {
for (NlpProject project : mNlpProjects) {
if (project.getResource().equals(resource)) {
@@ -517,6 +519,7 @@
/**
* Retrives the parent of the given resource.
*/
+ @Override
public INlpElement getParent(IResource resource) throws CoreException {
INlpElement result = super.getParent(resource);
@@ -542,6 +545,7 @@
/**
* Search the {@link INlpElement} for the given resoruce.
*/
+ @Override
public INlpElement findMember(IResource resource) {
INlpElement result = super.findMember(resource);
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -216,26 +216,26 @@
LinkedList<IResource> resourceList = new LinkedList<IResource>();
- for (int i = 0; i < resources.length; i++) {
- if (isSpecialResource(resources[i])) {
+ for (IResource element : resources) {
+ if (isSpecialResource(element)) {
continue;
}
- if (resources[i] instanceof IFolder) {
- if (mDotCorpusElement.isCorpusFolder((IFolder) resources[i])) {
+ if (element instanceof IFolder) {
+ if (mDotCorpusElement.isCorpusFolder((IFolder) element)) {
continue;
}
- if (mDotCorpusElement.isCasProcessorFolder((IFolder) resources[i])) {
+ if (mDotCorpusElement.isCasProcessorFolder((IFolder) element)) {
continue;
}
}
- if (mTypesystem != null && mTypesystem.getResource().equals(resources[i])) {
+ if (mTypesystem != null && mTypesystem.getResource().equals(element)) {
continue;
}
- resourceList.add(resources[i]);
+ resourceList.add(element);
}
IResource[] filteredResources = new IResource[resourceList.size()];
@@ -246,6 +246,7 @@
/**
* Retrives the parent element for the given resource.
*/
+ @Override
public INlpElement getParent(IResource resource) throws CoreException {
INlpElement result = super.getParent(resource);
@@ -291,6 +292,7 @@
/**
* Searchs the {@link INlpElement} for the given resource.
*/
+ @Override
public INlpElement findMember(IResource resource) {
INlpElement result = super.findMember(resource);
@@ -361,8 +363,8 @@
private boolean isSpecialResource(IResource resource) {
String specialResource[] = { ".project", DOT_CORPUS_FILENAME };
- for (int i = 0; i < specialResource.length; i++) {
- if (resource.getName().equals(specialResource[i])) {
+ for (String element : specialResource) {
+ if (resource.getName().equals(element)) {
return true;
}
}
@@ -373,6 +375,7 @@
/**
* Adds a resource to the current project instance.
*/
+ @Override
public void addResource(IResource resource) throws CoreException {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
@@ -397,6 +400,7 @@
/**
* Removes a resource form the current porject instance.
*/
+ @Override
public void removeResource(IResource resource) {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -76,6 +76,7 @@
* @return the {@link CAS} or null if there is an error in the type system.
* @deprecated
*/
+ @Deprecated
public CAS getCAS() {
Runnable clearMarkers = new Runnable() {
public void run() {
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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -63,9 +63,9 @@
IResourceDelta deltas[] = mResourceDelta.getAffectedChildren();
- for (int i = 0; i < deltas.length; i++) {
- if (deltas[i].getFlags() != IResourceDelta.MARKERS) {
- mChildren.add(new NlpModelDeltaImpl(this, deltas[i]));
+ for (IResourceDelta element : deltas) {
+ if (element.getFlags() != IResourceDelta.MARKERS) {
+ mChildren.add(new NlpModelDeltaImpl(this, 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?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- 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 Fri Jul 20 05:02:29 2007
@@ -20,7 +20,6 @@
package org.apache.uima.caseditor.core.model.dotcorpus;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import org.apache.uima.cas.Type;
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/uima/DocumentUimaImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/uima/DocumentUimaImpl.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/uima/DocumentUimaImpl.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/uima/DocumentUimaImpl.java Fri Jul 20 05:02:29 2007
@@ -19,8 +19,6 @@
package org.apache.uima.caseditor.core.uima;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -59,35 +57,37 @@
* TODO: add javdoc here
*/
public class DocumentUimaImpl extends AbstractDocument {
-
- private DocumentElement mDocumentElement;
- private TypeSystem mTypeSystem;
- private CAS mCAS;
+
+ private final DocumentElement mDocumentElement;
+
+ private final TypeSystem mTypeSystem;
+
+ private final CAS mCAS;
/**
* Initializes a new instance.
*
* @param project
*/
- public DocumentUimaImpl(NlpProject project, DocumentElement element, InputStream in)
- throws CoreException{
-
- mTypeSystem = project.getTypesystemElement().getTypeSystem();
-
- if (mTypeSystem == null) {
- throw new CoreException(new Status(IStatus.INFO, CasEditorPlugin.ID,
- IStatus.ERROR, "Invalid typesystem!", null));
- }
-
- mCAS = project.getTypesystemElement().getCAS();
-
- mDocumentElement = element;
+ public DocumentUimaImpl(NlpProject project, DocumentElement element, InputStream in)
+ throws CoreException {
+
+ mTypeSystem = project.getTypesystemElement().getTypeSystem();
+
+ if (mTypeSystem == null) {
+ throw new CoreException(new Status(IStatus.INFO, CasEditorPlugin.ID, IStatus.ERROR,
+ "Invalid typesystem!", null));
+ }
+
+ mCAS = project.getTypesystemElement().getCAS();
+
+ mDocumentElement = element;
- setContent(in);
+ setContent(in);
}
/**
- * Retrives the {@link CAS}.
+ * Retrieves the {@link CAS}.
*/
public CAS getCAS() {
return mCAS;
@@ -119,7 +119,7 @@
}
/**
- * Internally removes an annoation from the {@link CAS}.
+ * Internally removes an annotation from the {@link CAS}.
*
* @param featureStructure
*/
@@ -128,7 +128,7 @@
}
/**
- * Removes the annoations from the {@link CAS}.
+ * Removes the annotations from the {@link CAS}.
*/
public void removeFeatureStructure(FeatureStructure annotation) {
removeAnnotationInternal(annotation);
@@ -140,14 +140,14 @@
* Removes the given annotations from the {@link CAS}.
*/
public void removeFeatureStructures(Collection<FeatureStructure> annotationsToRemove) {
-
- for (FeatureStructure annotationToRemove : annotationsToRemove) {
+
+ for (FeatureStructure annotationToRemove : annotationsToRemove) {
removeAnnotationInternal(annotationToRemove);
}
- if (annotationsToRemove.size() > 0) {
- fireRemovedAnnotations(annotationsToRemove);
- }
+ if (annotationsToRemove.size() > 0) {
+ fireRemovedAnnotations(annotationsToRemove);
+ }
}
/**
@@ -164,8 +164,12 @@
fireUpdatedFeatureStructures(annotations);
}
+ public void changed() {
+ fireChanged();
+ }
+
/**
- * Retrives annoations of the given type from the {@link CAS}.
+ * Retrieves annotations of the given type from the {@link CAS}.
*/
public Collection<AnnotationFS> getAnnotations(Type type) {
FSIndex annotationIndex = mCAS.getAnnotationIndex(type);
@@ -190,7 +194,7 @@
}
/**
- * Retrives the annotations in the given span.
+ * Retrieves the annotations in the given span.
*/
@Override
public Collection<AnnotationFS> getAnnotation(Type type, Span span) {
@@ -228,14 +232,14 @@
}
/**
- * Retrives the given type from the {@link TypeSystem}.
+ * Retrieves the given type from the {@link TypeSystem}.
*/
public Type getType(String type) {
return getCAS().getTypeSystem().getType(type);
}
/**
- * Retrvies the text.
+ * Retrieves the text.
*/
public String getText() {
return mCAS.getDocumentText();
@@ -245,7 +249,7 @@
* Sets the content. The XCAS {@link InputStream} gets parsed.
*/
private void setContent(InputStream content) throws CoreException {
-
+
XCASDeserializer dezerializer = new XCASDeserializer(mTypeSystem);
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
@@ -302,13 +306,11 @@
}
}
- public void save() throws CoreException {
- ByteArrayOutputStream outStream = new ByteArrayOutputStream(40000);
-
- serialize(outStream);
-
- InputStream stream = new ByteArrayInputStream(outStream.toByteArray());
+ public DocumentElement getDocumentElement() {
+ return mDocumentElement;
+ }
- mDocumentElement.getResource().setContents(stream, true, false, null);
+ public void save() throws CoreException {
+ getDocumentElement().saveDocument();
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java Fri Jul 20 05:02:29 2007
@@ -28,6 +28,7 @@
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.caseditor.core.IDocument;
import org.apache.uima.caseditor.core.IDocumentListener;
+import org.apache.uima.caseditor.core.model.DocumentElement;
import org.apache.uima.caseditor.core.model.NlpProject;
import org.apache.uima.caseditor.core.util.Span;
import org.eclipse.core.runtime.CoreException;
@@ -38,7 +39,7 @@
* The <code>AnnotationDocument</code> adapts the annotation document to the eclipse Document
* (needed for the editor).
*
- * Note: Befor an instance can be used, the project and document must be set.
+ * Note: Before an instance can be used, the project and document must be set.
*/
public class AnnotationDocument extends Document implements IDocument {
private IDocument mDocument;
@@ -67,7 +68,7 @@
}
/**
- * Retrives the project.
+ * Retrieves the project.
*
* @return the project
*/
@@ -76,7 +77,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotation
*/
@@ -87,7 +88,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotations
*/
@@ -98,7 +99,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotations
*/
@@ -109,7 +110,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*/
public void removeAnnotation() {
mDocument.removeAnnotation();
@@ -118,7 +119,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotation
*/
@@ -129,7 +130,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotationsToRemove
*/
@@ -140,7 +141,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotationsToRemove
*/
@@ -151,7 +152,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotation
*/
@@ -162,7 +163,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotations
*/
@@ -173,7 +174,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotations
*/
@@ -183,8 +184,15 @@
fireDocumentChanged();
}
+
+ public void changed() {
+ mDocument.changed();
+
+ fireDocumentChanged();
+ }
+
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param type
* @return the annotations
@@ -194,7 +202,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param annotationType
* @return the view map
@@ -204,7 +212,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param listener
*/
@@ -213,7 +221,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param listener
*/
@@ -222,7 +230,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param type
* @param span
@@ -233,7 +241,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param out
* @throws CoreException
@@ -283,7 +291,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @return the text
*/
@@ -298,7 +306,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param start
* @param end
@@ -309,7 +317,7 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @return the TCAS
*/
@@ -318,12 +326,16 @@
}
/**
- * Call is forwared to the set document.
+ * Call is forwarded to the set document.
*
* @param type
* @return the type
*/
public Type getType(String type) {
return mDocument.getType(type);
+ }
+
+ public DocumentElement getDocumentElement() {
+ return mDocument.getDocumentElement();
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java Fri Jul 20 05:02:29 2007
@@ -209,6 +209,7 @@
*
* @param annotations
*/
+ @Override
public void addedAnnotation(Collection<AnnotationFS> annotations) {
mPainter.paint(AnnotationPainter.CONFIGURATION);
}
@@ -218,6 +219,7 @@
*
* @param deletedAnnotations
*/
+ @Override
public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) {
if (getSite().getPage().getActivePart() == AnnotationEditor.this) {
@@ -235,6 +237,7 @@
*
* @param annotations
*/
+ @Override
public void updatedAnnotation(Collection<AnnotationFS> annotations) {
removedAnnotation(annotations);
@@ -248,6 +251,14 @@
selectionChanged(getSite().getPage().getActivePart(), new StructuredSelection(structures));
}
+
+ public void changed() {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ syncAnnotations();
+ }
+ });
+ }
}
/**
@@ -924,7 +935,7 @@
annotateAction.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER);
setAction(ITextEditorActionDefinitionIds.SMART_ENTER, annotateAction);
- setActionActivationCode(ITextEditorActionDefinitionIds.SMART_ENTER, (char) '\r', SWT.CR,
+ setActionActivationCode(ITextEditorActionDefinitionIds.SMART_ENTER, '\r', SWT.CR,
SWT.DEFAULT);
// create delete action
@@ -957,5 +968,9 @@
if (document != null) {
document.removeChangeListener(mAnnotationSynchronizer);
}
+ }
+
+ public void setDirty() {
+ getDocument().fireDocumentChanged();
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java Fri Jul 20 05:02:29 2007
@@ -131,7 +131,7 @@
* @return all selected {@link AnnotationFS} objects
*/
public List<AnnotationFS> toList() {
- return (List<AnnotationFS>) Collections.unmodifiableList(mAnnotations);
+ return Collections.unmodifiableList(mAnnotations);
}
/**
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java Fri Jul 20 05:02:29 2007
@@ -91,7 +91,7 @@
if (FeatureStructure.class.equals(adapter)) {
return getStructre();
} else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) {
- return (AnnotationFS) getStructre();
+ return getStructre();
} else {
return Platform.getAdapterManager().getAdapter(this, adapter);
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java Fri Jul 20 05:02:29 2007
@@ -267,10 +267,15 @@
protected void updatedAnnotation(Collection<AnnotationFS> annotations) {
// ignore
}
+
+ public void changed() {
+ mFSList.refresh();
+ }
}
private class CreateAction extends Action {
// TOOD: extract it and add setType(...)
+ @Override
public void run() {
// TODO: check if an AnnotationFS was created, if so
// add it to the document
@@ -407,6 +412,7 @@
*
* @param actionBars
*/
+ @Override
public void setActionBars(IActionBars actionBars) {
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), mDeleteAction);
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java Fri Jul 20 05:02:29 2007
@@ -82,8 +82,6 @@
public final class AnnotationOutline extends ContentOutlinePage implements ISelectionListener {
/**
* This listener receive events from the bound editor.
- *
- * @author <a href="mailto:jkottmann@calcucare.com">Joern Kottmann</a>
*/
protected class EditorListener implements IAnnotationEditorModifyListener {
/**
@@ -99,8 +97,6 @@
/**
* This <code>OutlineContentProvider</code> synchronizes the <code>AnnotationFS</code>s with
* the <code>TableViewer</code>.
- *
- * @author <a href="mailto:jkottmann@calcucare.com">Joern Kottmann</a>
*/
private class OutlineContentProvider extends AbstractAnnotationDocumentListener implements
ITreeContentProvider {
@@ -108,7 +104,8 @@
private AnnotationTreeNodeList mAnnotationNodeList;
- private Map<AnnotationFS, AnnotationTreeNode> mParentNodeLookup = new HashMap<AnnotationFS, AnnotationTreeNode>();
+ private Map<AnnotationFS, AnnotationTreeNode> mParentNodeLookup =
+ new HashMap<AnnotationFS, AnnotationTreeNode>();
/**
* not implemented
@@ -149,7 +146,6 @@
Display.getDefault().syncExec(new Runnable() {
public void run() {
mTableViewer.refresh();
-
}
});
}
@@ -157,7 +153,7 @@
}
/**
- * Retrives all children of the {@link NlpModel}. That are the {@link NlpProject}s and
+ * Retrieves all children of the {@link NlpModel}. That are the {@link NlpProject}s and
* {@link IProject}s.
*
* @param inputElement
@@ -177,6 +173,7 @@
*
* @param annotations
*/
+ @Override
public void addedAnnotation(Collection<AnnotationFS> annotations) {
for (AnnotationFS annotation : annotations) {
if (!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) {
@@ -196,18 +193,6 @@
}
});
}
-
- /*
- * final Object[] items = new Object[annotations.size()];
- *
- * int i = 0;
- *
- * for (AnnotationFS annotation : annotations) { items[i++] = new
- * AnnotationTreeNode(annotation); }
- *
- * Display.getDefault().syncExec(new Runnable() { public void run() { mTableViewer.add(items); }
- * });
- */
}
/**
@@ -215,6 +200,7 @@
*
* @param deletedAnnotations
*/
+ @Override
public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) {
// TODO: what happens if someone removes an annoation which
// is not an element of this list e.g in the featruestructure view ?
@@ -228,6 +214,7 @@
i++;
}
+
Display.getDefault().syncExec(new Runnable() {
public void run() {
mTableViewer.remove(items);
@@ -240,6 +227,7 @@
*
* @param annotations
*/
+ @Override
public void updatedAnnotation(Collection<AnnotationFS> featureStructres) {
Collection<AnnotationFS> annotations = new ArrayList<AnnotationFS>(featureStructres.size());
@@ -270,6 +258,23 @@
}
}
+ public void changed() {
+
+ Collection<AnnotationFS> annotations = mEditor.getDocument().getAnnotations(
+ mEditor.getAnnotationMode());
+
+ mAnnotationNodeList = annotations != null ? new AnnotationTreeNodeList(mEditor
+ .getDocument(), annotations) : null;
+
+ mParentNodeLookup.clear();
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ mTableViewer.refresh();
+ }
+ });
+ }
+
public Object[] getChildren(Object parentElement) {
AnnotationTreeNode node = (AnnotationTreeNode) parentElement;
@@ -414,8 +419,8 @@
toolBarManager.add(lowerLeftAnnotationSideAction);
// lower right annotation side action
- LowerRightAnnotationSideAction lowerRightAnnotionSideAction = new LowerRightAnnotationSideAction(
- mEditor.getDocument());
+ LowerRightAnnotationSideAction lowerRightAnnotionSideAction =
+ new LowerRightAnnotationSideAction(mEditor.getDocument());
lowerRightAnnotionSideAction.setText("Lowers the right annotation side");
lowerRightAnnotionSideAction.setImageDescriptor(CasEditorPlugin
.getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE));
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java Fri Jul 20 05:02:29 2007
@@ -52,17 +52,17 @@
char stringChars[] = string.toCharArray();
- for (int i = 0; i < stringChars.length; i++) {
- if ((stringChars[i] == '\r')) {
+ for (char element : stringChars) {
+ if ((element == '\r')) {
continue;
}
- if (stringChars[i] == '\n') {
+ if (element == '\n') {
stringBuilder.append(' ');
continue;
}
- stringBuilder.append(stringChars[i]);
+ stringBuilder.append(element);
}
return stringBuilder.toString();
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/action/AnnotatorActionRunnable.java Fri Jul 20 05:02:29 2007
@@ -20,102 +20,135 @@
package org.apache.uima.caseditor.ui.action;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.caseditor.core.IDocument;
import org.apache.uima.caseditor.core.model.DocumentElement;
import org.apache.uima.caseditor.core.uima.AnnotatorConfiguration;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
import org.apache.uima.resource.ResourceInitializationException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
/**
- * TODO: synchronize filesystem after annotator run.
- * TODO: move this over to core plugin
*/
-public final class AnnotatorActionRunnable implements IRunnableWithProgress
-{
- private AnnotatorConfiguration mAnnotatorConfiguration;
-
- private Collection<DocumentElement> mDocuments;
+public final class AnnotatorActionRunnable implements IRunnableWithProgress {
+ private AnnotatorConfiguration mAnnotatorConfiguration;
+
+ private Collection<DocumentElement> mDocuments;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param annotator
+ * @param documents
+ * @param shell
+ */
+ public AnnotatorActionRunnable(AnnotatorConfiguration annotator,
+ Collection<DocumentElement> documents) {
+ mAnnotatorConfiguration = annotator;
+ mDocuments = documents;
+ }
+
+ /**
+ * Creates a list of all {@link AnnotationEditor} which are currently opened.
+ */
+ private AnnotationEditor[] getAnnotationEditors() {
+
+ ArrayList dirtyParts = new ArrayList();
+ IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (IWorkbenchWindow element : windows) {
+ IWorkbenchPage pages[] = element.getPages();
+ for (IWorkbenchPage page : pages) {
+ IEditorPart[] parts = page.getEditors();
+
+ for (IEditorPart part : parts) {
+ if (part instanceof AnnotationEditor) {
+ AnnotationEditor editor = (AnnotationEditor) part;
+ dirtyParts.add(editor);
+ }
+ }
+ }
+ }
+
+ return (AnnotationEditor[]) dirtyParts.toArray(new AnnotationEditor[dirtyParts.size()]);
+ }
+
+ /**
+ * Executes the action.
+ */
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask("Tagging", IProgressMonitor.UNKNOWN);
+
+ monitor.subTask("Initializing tagger, " + "please stand by.");
+
+ AnalysisEngine annotatorInstance;
- /**
- * Initializes a new instance.
- *
- * @param annotator
- * @param documents
- * @param shell
- */
- public AnnotatorActionRunnable(AnnotatorConfiguration annotator,
- Collection<DocumentElement> documents)
- {
- mAnnotatorConfiguration = annotator;
- mDocuments = documents;
+ try {
+ annotatorInstance = mAnnotatorConfiguration.createAnnotator();
+ } catch (final ResourceInitializationException e) {
+ throw new InvocationTargetException(e);
+ }
+
+ monitor.subTask("Tagging, please stand by.");
+
+ Map<DocumentElement, AnnotationEditor> editorMap =
+ new HashMap<DocumentElement, AnnotationEditor>();
+
+ for (AnnotationEditor annotationEditor : getAnnotationEditors()) {
+ editorMap.put(annotationEditor.getDocument().getDocumentElement(), annotationEditor);
}
- /**
- * Excecutes the action.
- */
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException
- {
- monitor.beginTask("Tagging", IProgressMonitor.UNKNOWN);
-
- monitor.subTask("Initializing tagger, "
- + "please stand by.");
-
- AnalysisEngine annotatorInstance;
-
- try
- {
- annotatorInstance = mAnnotatorConfiguration
- .createAnnotator();
+ for (DocumentElement element : mDocuments) {
+
+ IDocument document = null;
+ try {
+ document = element.getDocument(); // retrieve the working copy
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+
+ try {
+ annotatorInstance.process(document.getCAS());
+ } catch (AnalysisEngineProcessException e) {
+ throw new InvocationTargetException(e);
+ }
+
+ document.changed();
+
+ try {
+
+ if (editorMap.get(element) == null) {
+ // file is not opened in any editor, just save the changes
+ element.saveDocument();
}
- catch (final ResourceInitializationException e)
- {
- throw new InvocationTargetException(e);
+ else if (!editorMap.get(element).isDirty()) {
+ // element is opened in editor and not dirty
+ AnnotationEditor editor = editorMap.get(element);
+ editor.setDirty();
}
-
- monitor.subTask("Tagging, please stand by.");
-
- for (DocumentElement element : mDocuments)
- {
-
- IDocument document = null;
- try {
- document = element.getDocument();
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
-
- try
- {
- annotatorInstance.process(document.getCAS());
- }
- catch (AnalysisEngineProcessException e)
- {
- throw new InvocationTargetException(e);
- }
-
- // TODO: save it and notify other about changes
-
- try
- {
- element.saveDocument();
- }
- catch (CoreException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ else {
+ // element is opened in editor and dirty, do nothing
}
-
- annotatorInstance.destroy();
- annotatorInstance = null;
-
- monitor.done();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
+
+ annotatorInstance.destroy();
+ annotatorInstance = null;
+
+ monitor.done();
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/AnnotatorActionGroup.java Fri Jul 20 05:02:29 2007
@@ -83,8 +83,8 @@
}
// TODO: refactor this
- // how to retrive the project of the selected elements ?
- // what happends if someone selectes DocumentElements form
+ // how to retrieve the project of the selected elements ?
+ // what happens if someone selects DocumentElements form
// different projects ?
if (!documentElements.isEmpty()) {
DocumentElement aDocument = documentElements.getFirst();
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerUtil.java Fri Jul 20 05:02:29 2007
@@ -69,6 +69,7 @@
*
* @deprecated
*/
+ @Deprecated
static boolean isContaingNLPProjectOrNonNLPResources(
IStructuredSelection selection)
{
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerView.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerView.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerView.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/CorpusExplorerView.java Fri Jul 20 05:02:29 2007
@@ -101,7 +101,7 @@
mActions.fillActionBars(getViewSite().getActionBars());
mActions.setContext(new ActionContext(
- (IStructuredSelection) mTreeViewer.getSelection()));
+ mTreeViewer.getSelection()));
mActions.updateActionBars();
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/PasteAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/PasteAction.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/PasteAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/PasteAction.java Fri Jul 20 05:02:29 2007
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.ui.corpusview;
-import java.io.File;
import java.util.List;
import org.eclipse.core.resources.IContainer;
@@ -94,8 +93,8 @@
CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(mShell);
operation.copyResources(resourceData, getNewParent());
} else {
- for (int i = 0; i < resourceData.length; i++) {
- new CopyProjectOperation(mShell).copyProject((IProject) resourceData[i]);
+ for (IResource element : resourceData) {
+ new CopyProjectOperation(mShell).copyProject((IProject) element);
}
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ResourceAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ResourceAction.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ResourceAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/corpusview/ResourceAction.java Fri Jul 20 05:02:29 2007
@@ -102,8 +102,8 @@
return false;
}
- for (Iterator e = getSelectedResources().iterator(); e.hasNext();) {
- IResource next = (IResource) e.next();
+ for (Object element : getSelectedResources()) {
+ IResource next = (IResource) element;
if (!resourceIsType(next, resourceMask)) {
return false;
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/model/TypesystemAdapter.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/model/TypesystemAdapter.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/model/TypesystemAdapter.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/model/TypesystemAdapter.java Fri Jul 20 05:02:29 2007
@@ -9,6 +9,7 @@
/**
* Retrives the document element <code>ImageDescriptor</code>.
*/
+ @Override
public ImageDescriptor getImageDescriptor(Object object) {
return CasEditorPlugin.getTaeImageDescriptor(Images.MODEL_TYPESYSTEM);
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/DotCorpusPreferenceStore.java Fri Jul 20 05:02:29 2007
@@ -21,7 +21,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.Collection;
import java.util.StringTokenizer;
import org.apache.uima.caseditor.core.model.DotCorpusElement;
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java?view=diff&rev=557975&r1=557974&r2=557975
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/property/ProjectPropertyPage.java Fri Jul 20 05:02:29 2007
@@ -23,8 +23,6 @@
import org.apache.uima.caseditor.core.model.INlpElement;
import org.apache.uima.caseditor.core.model.NlpProject;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;