You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/07/09 15:47:41 UTC
svn commit: r554651 - in
/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor:
core/model/NlpProject.java core/model/TypesystemElement.java
core/model/dotcorpus/EditorAnnotationStatus.java editor/AnnotationEditor.java
Author: schor
Date: Mon Jul 9 06:47:40 2007
New Revision: 554651
URL: http://svn.apache.org/viewvc?view=rev&rev=554651
Log:
[UIMA-482] committed all the changes
Modified:
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/dotcorpus/EditorAnnotationStatus.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
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=554651&r1=554650&r2=554651
==============================================================================
--- 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 Jul 9 06:47:40 2007
@@ -94,8 +94,10 @@
// sourceFolder.initialize();
//}
- if (getDotCorpus().getTypeSystemFile() != null) {
- mTypesystem = new TypesystemElement(getDotCorpus().getTypeSystemFile(), this);
+ IFile typeSystemFile = getDotCorpus().getTypeSystemFile();
+
+ if (typeSystemFile != null && typeSystemFile.exists()) {
+ mTypesystem = new TypesystemElement(typeSystemFile, this);
}
if (getTypesystemElement() != null && 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?view=diff&rev=554651&r1=554650&r2=554651
==============================================================================
--- 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 Jul 9 06:47:40 2007
@@ -60,13 +60,20 @@
}
public TypeSystem getTypeSystem() {
- return getCAS().getTypeSystem();
+
+ CAS cas = getCAS();
+
+ if (cas != null) {
+ return cas.getTypeSystem();
+ }
+
+ return null;
}
/**
- * Retrives the {@link CAS}.
+ * Retrieves the {@link CAS}.
*
- * @return the {@link CAS}
+ * @return the {@link CAS} or null if there is an error in the type system.
* @deprecated
*/
public CAS getCAS() {
@@ -94,6 +101,7 @@
}
};
((NlpModel) mProject.getParent()).asyncExcuteQueue(createMarker);
+
return null;
}
}
@@ -153,28 +161,28 @@
}
/**
- * Retrives the name.
+ * Retrieves the name.
*/
public String getName() {
return "Typesystem";
}
/**
- * Retrives the nlp project.
+ * Retrieves the nlp project.
*/
public NlpProject getNlpProject() {
return mProject;
}
/**
- * Rerives the parent.
+ * Retrieves the parent.
*/
public INlpElement getParent() {
return mProject;
}
/**
- * Retrives the resource.
+ * Retrieves the resource.
*/
public IResource getResource() {
return mTypesytemFile;
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=554651&r1=554650&r2=554651
==============================================================================
--- 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 Jul 9 06:47:40 2007
@@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import org.apache.uima.cas.Type;
@@ -30,7 +31,7 @@
public class EditorAnnotationStatus {
private Type mMode;
- private Collection<Type> mDisplayAnnotations;
+ private Collection<Type> mDisplayAnnotations = new HashSet<Type>();
/**
* Initializes a new instance.
@@ -46,10 +47,8 @@
mMode = mode;
if (displayAnnotations != null) {
- mDisplayAnnotations = Collections.unmodifiableCollection(displayAnnotations);
- } else {
- mDisplayAnnotations = Collections.emptyList();
- }
+ mDisplayAnnotations.addAll(displayAnnotations);
+ }
}
/**
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=554651&r1=554650&r2=554651
==============================================================================
--- 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 Mon Jul 9 06:47:40 2007
@@ -124,7 +124,7 @@
// get old annotations of current type for this area
// if there is something ... the delete them and add
Collection<AnnotationFS> oldAnnotations = getDocument().getAnnotation(
- mCurrentAnnotationType, new Span(selection.x, selection.y));
+ mAnnotationMode, new Span(selection.x, selection.y));
if (!oldAnnotations.isEmpty()) {
getDocument().removeAnnotations(oldAnnotations);
@@ -133,7 +133,7 @@
int start = selection.x;
int end = start + selection.y;
- AnnotationFS annotation = getDocument().getCAS().createAnnotation(mCurrentAnnotationType,
+ AnnotationFS annotation = getDocument().getCAS().createAnnotation(mAnnotationMode,
start, end);
getDocument().addFeatureStructure(annotation);
@@ -168,7 +168,7 @@
}
/**
- * Executes this action, showse context information.
+ * Executes this action, shows context information.
*/
@Override
public void run() {
@@ -341,14 +341,14 @@
});
}
}
-
+
/**
* Creates the show annotations context submenu.
*/
private class ShowAnnotationsMenu extends TypeMenu {
- private Collection<Type> mTypesToDisplay = new HashSet<Type>();
-
+ private Collection<Type> mTypesToDisplay = new HashSet<Type>();
+
/**
* Initializes a new instance.
*
@@ -384,6 +384,11 @@
// TODO: only synchronize annotation which
// must be removed/addeded
syncAnnotations();
+
+ EditorAnnotationStatus status = mDocument.getProject().getEditorAnnotationStatus();
+
+ mDocument.getProject().setEditorAnnotationStatus(
+ new EditorAnnotationStatus(status.getMode(), getSelectedTypes()));
}
});
}
@@ -391,10 +396,15 @@
Collection<Type> getSelectedTypes() {
return Collections.unmodifiableCollection(mTypesToDisplay);
}
+
+ void setSelectedTypes(Collection<Type> types) {
+ mTypesToDisplay = new HashSet<Type>();
+ mTypesToDisplay.addAll(types);
+ }
}
/**
- * Sometimes the wrong annoation is selected ... ????
+ * Sometimes the wrong annotation is selected ... ????
*/
private class FeatureStructureDragListener implements DragSourceListener {
private boolean mIsActive;
@@ -426,7 +436,7 @@
// try to get the position inside the text
int offset = textWidget.getOffsetAtLocation(new Point(e.x, e.y));
- Map<Integer, AnnotationFS> view = getDocument().getView(mCurrentAnnotationType);
+ Map<Integer, AnnotationFS> view = getDocument().getView(mAnnotationMode);
mCandidate = view.get(offset);
@@ -456,7 +466,7 @@
}
}
- private Type mCurrentAnnotationType;
+ private Type mAnnotationMode;
/**
* The outline page belonging to this editor.
@@ -466,7 +476,7 @@
private IAnnotationEditorModifyListener mEditorListener;
/**
- * TODO: Do we realy need this pos variable ?
+ * TODO: Do we really need this pos variable ?
*/
private int mCursorPosition;
@@ -614,11 +624,11 @@
mDocument.getProject().getEditorAnnotationStatus(),
getDocument().getCAS().getTypeSystem());
- EditorAnnotationStatus status = mDocument.getProject().getEditorAnnotationStatus();
- setAnnotationType(status.getMode());
+ EditorAnnotationStatus status = mDocument.getProject().getEditorAnnotationStatus();
+
+
+ setAnnotationType(status.getMode());
}
-
-
}
// TODO: still not called always, e.g. on mouse selection
@@ -677,7 +687,7 @@
// can be null directly after doSetInput()
if (statusField != null) {
- statusField.setText(mCurrentAnnotationType.getShortName());
+ statusField.setText(mAnnotationMode.getShortName());
}
}
@@ -696,7 +706,7 @@
* @return - current annotation type
*/
public Type getAnnotationMode() {
- return mCurrentAnnotationType;
+ return mAnnotationMode;
}
/**
@@ -707,7 +717,7 @@
protected void setAnnotationType(Type type) {
// TODO: check if this type is a subtype of Annotation
- mCurrentAnnotationType = type;
+ mAnnotationMode = type;
setProjectEditorStatus();
@@ -715,7 +725,7 @@
syncAnnotations();
- fireAnnotationTypeChanged(mCurrentAnnotationType);
+ fireAnnotationTypeChanged(mAnnotationMode);
}
/**
@@ -749,8 +759,8 @@
}
// if not contained in types add current mode annotations
- if (!mShowAnnotationsMenu.getSelectedTypes().contains(mCurrentAnnotationType)) {
- showAnnotationType(mCurrentAnnotationType);
+ if (!mShowAnnotationsMenu.getSelectedTypes().contains(mAnnotationMode)) {
+ showAnnotationType(mAnnotationMode);
}
mPainter.paint(AnnotationPainter.CONFIGURATION);
@@ -817,7 +827,7 @@
Span selecectedSpan = new Span(selectedText.x, selectedText.y);
Collection<AnnotationFS> selectedAnnotations = getDocument().getAnnotation(
- mCurrentAnnotationType, selecectedSpan);
+ mAnnotationMode, selecectedSpan);
for (AnnotationFS annotation : selectedAnnotations) {
selection.add(annotation);
@@ -825,7 +835,7 @@
Collections.sort(selection, new AnnotationComparator());
} else {
- Map<Integer, AnnotationFS> view = getDocument().getView(mCurrentAnnotationType);
+ Map<Integer, AnnotationFS> view = getDocument().getView(mAnnotationMode);
AnnotationFS annotation = view.get(mCursorPosition);