You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2009/05/21 14:38:59 UTC
svn commit: r777093 [1/2] - in
/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor:
./ core/ editor/ editor/util/ ui/ ui/wizards/
Author: joern
Date: Thu May 21 12:38:53 2009
New Revision: 777093
URL: http://svn.apache.org/viewvc?rev=777093&view=rev
Log:
UIMA-546: Changed formation to be compliant to UIMA code conventions
Modified:
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/TaeError.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentFormat.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/EditorAnnotationStatus.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/wizards/ImportDocumentWizard.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/wizards/NewNlpProjectWizardPage.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/wizards/WizardNewFileCreation.java
incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/wizards/WizardNewFolderCreation.java
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java Thu May 21 12:38:53 2009
@@ -49,7 +49,7 @@
private ResourceBundle mResourceBundle;
private static NlpModel sNLPModel;
-
+
/**
* The constructor.
*/
@@ -134,7 +134,7 @@
public static void log(Throwable t) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, IStatus.OK, t.getMessage(), t));
}
-
+
public static void logError(String message) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, message));
}
@@ -166,7 +166,7 @@
return sNLPModel;
}
-
+
/**
* Destroy the nlp model, only for testing.
*/
@@ -175,4 +175,4 @@
sNLPModel = null;
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/TaeError.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/TaeError.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/TaeError.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/core/TaeError.java Thu May 21 12:38:53 2009
@@ -23,9 +23,7 @@
* A general {@link RuntimeException} which is thrown if something unexpected happens.
*/
public class TaeError extends RuntimeException {
- /**
- *
- */
+
private static final long serialVersionUID = 1L;
/**
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java Thu May 21 12:38:53 2009
@@ -37,16 +37,16 @@
* Note: Before an instance can be used the document must be set.
*/
public class AnnotationDocument extends Document implements ICasDocument {
-
+
private ICasDocument mDocument;
-
+
private int lineLengthHint = 80;
public AnnotationDocument() {
}
public void setLineLengthHint(int lineLengthHint) {
- this.lineLengthHint = lineLengthHint;
+ this.lineLengthHint = lineLengthHint;
}
/**
@@ -301,4 +301,4 @@
public Type getType(String type) {
return mDocument.getType(type);
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java Thu May 21 12:38:53 2009
@@ -324,7 +324,7 @@
// Workaround: It is possible check that is text under the cursor ?
try {
- offset = textWidget.getOffsetAtLocation(new Point(e.x, e.y));
+ offset = textWidget.getOffsetAtLocation(new Point(e.x, e.y));
}
catch (IllegalArgumentException e2) {
return;
@@ -382,7 +382,7 @@
// ask document provider for this
// getAnnotation must be added to cas document provider
-
+
AnnotationStyle style = getDocumentProvider().getAnnotationStyle(getEditorInput(),
eclipseAnnotation.getAnnotationFS().getType());
@@ -431,11 +431,11 @@
private class CloseEditorListener implements IResourceChangeListener {
private AnnotationEditor editor;
-
+
public CloseEditorListener(AnnotationEditor editor) {
this.editor = editor;
}
-
+
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
try {
@@ -468,7 +468,7 @@
}
}
}
-
+
private Type mAnnotationMode;
/**
@@ -498,22 +498,22 @@
private DocumentListener mAnnotationSynchronizer;
private CloseEditorListener closeEditorListener;
-
+
/**
* Creates an new AnnotationEditor object.
*/
public AnnotationEditor() {
CasDocumentProvider provider =
CasDocumentProviderFactory.instance().getDocumentProvider();
-
+
setDocumentProvider(provider);
}
-
+
@Override
public CasDocumentProvider getDocumentProvider() {
return (CasDocumentProvider) super.getDocumentProvider();
}
-
+
/**
* Retrieves annotation editor adapters.
*
@@ -622,36 +622,35 @@
getSite().setSelectionProvider(mFeatureStructureSelectionProvider);
if (getDocument() != null) {
- mShowAnnotationsMenu = new ShowAnnotationsMenu(
- getDocumentProvider().getEditorAnnotationStatus(getEditorInput()),
- getDocument().getCAS().getTypeSystem());
- mShowAnnotationsMenu.addListener(new IShowAnnotationsListener() {
-
- public void selectionChanged(Collection<Type> selection) {
- // TODO: only synchronize annotation which
- // must be removed/added
- syncAnnotations();
-
- // TODO:
- // get and set editor annotation status must
- // be added to document provider
-
- EditorAnnotationStatus status =
- getDocumentProvider().getEditorAnnotationStatus(getEditorInput());
-
- getDocumentProvider().setEditorAnnotationStatus(getEditorInput(),
- new EditorAnnotationStatus(status.getMode(), selection));
-
- if (mEditorListener != null)
- mEditorListener.showAnnotationsChanged(selection);
- }
- });
+ mShowAnnotationsMenu = new ShowAnnotationsMenu(
+ getDocumentProvider().getEditorAnnotationStatus(getEditorInput()),
+ getDocument().getCAS().getTypeSystem());
+ mShowAnnotationsMenu.addListener(new IShowAnnotationsListener() {
+
+ public void selectionChanged(Collection<Type> selection) {
+ // TODO: only synchronize annotation which
+ // must be removed/added
+ syncAnnotations();
+
+ // TODO:
+ // get and set editor annotation status must
+ // be added to document provider
- EditorAnnotationStatus status =
- getDocumentProvider().getEditorAnnotationStatus(getEditorInput());
+ EditorAnnotationStatus status =
+ getDocumentProvider().getEditorAnnotationStatus(getEditorInput());
+ getDocumentProvider().setEditorAnnotationStatus(getEditorInput(),
+ new EditorAnnotationStatus(status.getMode(), selection));
- setAnnotationMode(getDocument().getType(status.getMode()));
+ if (mEditorListener != null)
+ mEditorListener.showAnnotationsChanged(selection);
+ }
+ });
+
+ EditorAnnotationStatus status = getDocumentProvider()
+ .getEditorAnnotationStatus(getEditorInput());
+
+ setAnnotationMode(getDocument().getType(status.getMode()));
}
}
@@ -677,11 +676,11 @@
mDocument = (AnnotationDocument) getDocumentProvider().getDocument(input);
if (mDocument != null) {
-
+
closeEditorListener = new CloseEditorListener(this);
ResourcesPlugin.getWorkspace().addResourceChangeListener(
closeEditorListener, IResourceChangeEvent.POST_CHANGE);
-
+
// mAnnotationModel = getDocumentProvider().getAnnotationModel(input);
mAnnotationSynchronizer = new DocumentListener();
@@ -699,18 +698,17 @@
// mode menu
MenuManager modeMenuManager = new MenuManager("Mode");
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, modeMenuManager);
-
+
ModeMenu modeMenu = new ModeMenu(typeSytem);
modeMenu.addListener(new IModeMenuListener(){
public void modeChanged(Type newMode) {
- IAction actionToExecute = new ChangeModeAction(newMode,
- newMode.getShortName(),
- AnnotationEditor.this);
+ IAction actionToExecute = new ChangeModeAction(newMode, newMode.getShortName(),
+ AnnotationEditor.this);
- actionToExecute.run();
+ actionToExecute.run();
}});
-
+
modeMenuManager.add(modeMenu);
// annotation menu
@@ -759,7 +757,7 @@
// TODO: check if this type is a subtype of Annotation
mAnnotationMode = type;
-
+
highlight(0, 0);
setProjectEditorStatus();
@@ -769,14 +767,14 @@
syncAnnotations();
fireAnnotationTypeChanged(getAnnotationMode());
-
+
mShowAnnotationsMenu.setEditorAnnotationMode(type);
}
public Collection<Type> getShownAnnotationTypes() {
return mShowAnnotationsMenu.getSelectedTypes();
}
-
+
/**
* @param type
*/
@@ -787,12 +785,12 @@
}
private void showAnnotationType(Type type) {
- AnnotationStyle style = getDocumentProvider().getAnnotationStyle(getEditorInput(), type);
- mPainter.addDrawingStrategy(type.getName(),
- DrawingStyle.valueOf(style.getStyle().name()).getStrategy());
- mPainter.addAnnotationType(type.getName(), type.getName());
+ AnnotationStyle style = getDocumentProvider().getAnnotationStyle(getEditorInput(), type);
+ mPainter.addDrawingStrategy(type.getName(),
+ DrawingStyle.valueOf(style.getStyle().name()).getStrategy());
+ mPainter.addAnnotationType(type.getName(), type.getName());
java.awt.Color color = style.getColor();
- mPainter.setAnnotationTypeColor(type.getName(), new Color(null, color.getRed(),
+ mPainter.setAnnotationTypeColor(type.getName(), new Color(null, color.getRed(),
color.getGreen(), color.getBlue()));
}
@@ -813,7 +811,7 @@
mPainter.paint(IPainter.CONFIGURATION);
}
-
+
/**
* @param listener
*/
@@ -875,7 +873,7 @@
Span selecectedSpan = new Span(selectedText.x, selectedText.y);
Collection<AnnotationFS> selectedAnnotations = getDocument().getAnnotation(
- getAnnotationMode(), selecectedSpan);
+ getAnnotationMode(), selecectedSpan);
for (AnnotationFS annotation : selectedAnnotations) {
selection.add(annotation);
@@ -945,13 +943,13 @@
// TODO: do not replace if equal ... check this
EditorAnnotationStatus status = new EditorAnnotationStatus(getAnnotationMode().getName(),
mShowAnnotationsMenu.getSelectedTypes());
-
+
getDocumentProvider().setEditorAnnotationStatus(getEditorInput(), status);
}
/**
* Creates custom annotation actions:
- *
+ *
* Annotate Action
* Smart Annotate Action
* Delete Annotations Action
@@ -959,7 +957,7 @@
*/
@Override
protected void createActions() {
-
+
super.createActions();
mFeatureStructureSelectionProvider = new FeatureStructureSelectionProvider();
@@ -1000,7 +998,7 @@
annotationContextEditAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
setAction(ITextEditorActionDefinitionIds.QUICK_ASSIST, annotationContextEditAction);
-
+
// create find annotate action
FindAnnotateAction findAnnotateAction = new FindAnnotateAction(this, getSourceViewer().getFindReplaceTarget());
findAnnotateAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE);
@@ -1013,18 +1011,18 @@
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
getSite().getPage().removeSelectionListener(this);
-
+
ICasDocument document = getDocument();
if (document != null) {
document.removeChangeListener(mAnnotationSynchronizer);
}
-
+
if (closeEditorListener != null) {
ResourcesPlugin.getWorkspace()
.removeResourceChangeListener(closeEditorListener);
}
-
+
super.dispose();
}
@@ -1035,7 +1033,7 @@
void setAnnotationSelection(AnnotationFS annotation) {
mFeatureStructureSelectionProvider.setSelection(getDocument(), annotation);
}
-
+
/**
* Creates a list of all {@link AnnotationEditor} which are currently opened.
*/
@@ -1049,9 +1047,9 @@
IEditorReference[] references = page.getEditorReferences();
for (IEditorReference reference : references) {
-
+
IEditorPart part = reference.getEditor(false);
-
+
if (part instanceof AnnotationEditor) {
AnnotationEditor editor = (AnnotationEditor) part;
dirtyParts.add(editor);
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java Thu May 21 12:38:53 2009
@@ -57,7 +57,7 @@
Type annotationType = mActiveEditorPart.getAnnotationMode();
if (annotationType != null) {
- mStatusLineModeItem.setText(annotationType.getShortName());
+ mStatusLineModeItem.setText(annotationType.getShortName());
}
}
}
@@ -77,4 +77,4 @@
statusLineManager.add(mStatusLineModeItem);
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java Thu May 21 12:38:53 2009
@@ -49,19 +49,19 @@
}
protected abstract PageRec doCreatePage(AnnotationEditor editor);
-
+
@Override
- protected final PageRec doCreatePage(IWorkbenchPart part) {
-
- if (part instanceof AnnotationEditor) {
- AnnotationEditor editor = (AnnotationEditor) part;
-
- return doCreatePage(editor);
- }
-
- return null;
- }
-
+ protected final PageRec doCreatePage(IWorkbenchPart part) {
+
+ if (part instanceof AnnotationEditor) {
+ AnnotationEditor editor = (AnnotationEditor) part;
+
+ return doCreatePage(editor);
+ }
+
+ return null;
+ }
+
@Override
protected IWorkbenchPart getBootstrapPart() {
return getSite().getPage().getActiveEditor();
@@ -89,4 +89,4 @@
public void partBroughtToTop(IWorkbenchPart part) {
partActivated(part);
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java Thu May 21 12:38:53 2009
@@ -40,110 +40,108 @@
import org.eclipse.ui.texteditor.AbstractDocumentProvider;
/**
- * Provides the {@link org.apache.uima.caseditor.editor.ICasDocument} for
- * the {@link AnnotationEditor}.
+ * Provides the {@link org.apache.uima.caseditor.editor.ICasDocument} for the
+ * {@link AnnotationEditor}.
*/
public abstract class CasDocumentProvider extends AbstractDocumentProvider {
- /**
- * The method {@link #createDocument(Object)} put error status
- * objects for the given element in this map, if something with document creation
- * goes wrong.
- *
- * The method {@link #getStatus(Object)} can then retrieve and return the status.
- */
- protected Map<Object, IStatus> elementErrorStatus =
- new HashMap<Object, IStatus>();
-
- @Override
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- return new IAnnotationModel() {
-
- private org.apache.uima.caseditor.editor.ICasDocument mDocument;
-
- public void addAnnotation(Annotation annotation, Position position) {
- }
-
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
- }
-
- public void connect(IDocument document) {
- mDocument = (org.apache.uima.caseditor.editor.ICasDocument) document;
- }
-
- public void disconnect(IDocument document) {
- mDocument = null;
- }
-
- public Iterator<EclipseAnnotationPeer> getAnnotationIterator() {
- return new Iterator<EclipseAnnotationPeer>() {
- private Iterator<FeatureStructure> mAnnotations =
- mDocument.getCAS().getAnnotationIndex().iterator();
-
- public boolean hasNext() {
- return mAnnotations.hasNext();
- }
-
- public EclipseAnnotationPeer next() {
- AnnotationFS annotation = (AnnotationFS) mAnnotations.next();
-
- EclipseAnnotationPeer peer = new EclipseAnnotationPeer(annotation.getType().getName(), false, "");
- peer.setAnnotation(annotation);
- return peer;
- }
-
- public void remove() {
- }};
- }
-
- public Position getPosition(Annotation annotation) {
- EclipseAnnotationPeer peer = (EclipseAnnotationPeer) annotation;
- AnnotationFS annotationFS = peer.getAnnotationFS();
- return new Position(annotationFS.getBegin(),
- annotationFS.getEnd() - annotationFS.getBegin());
- }
-
- public void removeAnnotation(Annotation annotation) {
- }
-
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- }
- };
- }
-
- /**
- * Creates the a new {@link AnnotationDocument} from the given {@link FileEditorInput}
- * element. For all other elements null is returned.
- */
- @Override
- protected abstract IDocument createDocument(Object element) throws CoreException;
-
- @Override
- protected abstract void doSaveDocument(IProgressMonitor monitor,
- Object element, IDocument document, boolean overwrite) throws CoreException;
-
-
- @Override
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- return null;
- }
-
- @Override
- public IStatus getStatus(Object element) {
- IStatus status = elementErrorStatus.get(element);
-
- if (status == null) {
- status = super.getStatus(element);
- }
-
- return status;
- }
-
- protected abstract AnnotationStyle getAnnotationStyle(Object element, Type type);
-
- protected abstract EditorAnnotationStatus getEditorAnnotationStatus(
- Object element);
-
- protected abstract void setEditorAnnotationStatus(Object element,
- EditorAnnotationStatus editorAnnotationStatus);
-}
\ No newline at end of file
+ /**
+ * The method {@link #createDocument(Object)} put error status objects for the given element in
+ * this map, if something with document creation goes wrong.
+ *
+ * The method {@link #getStatus(Object)} can then retrieve and return the status.
+ */
+ protected Map<Object, IStatus> elementErrorStatus = new HashMap<Object, IStatus>();
+
+ @Override
+ protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
+ return new IAnnotationModel() {
+
+ private org.apache.uima.caseditor.editor.ICasDocument mDocument;
+
+ public void addAnnotation(Annotation annotation, Position position) {
+ }
+
+ public void addAnnotationModelListener(IAnnotationModelListener listener) {
+ }
+
+ public void connect(IDocument document) {
+ mDocument = (org.apache.uima.caseditor.editor.ICasDocument) document;
+ }
+
+ public void disconnect(IDocument document) {
+ mDocument = null;
+ }
+
+ public Iterator<EclipseAnnotationPeer> getAnnotationIterator() {
+ return new Iterator<EclipseAnnotationPeer>() {
+ private Iterator<FeatureStructure> mAnnotations =
+ mDocument.getCAS().getAnnotationIndex().iterator();
+
+ public boolean hasNext() {
+ return mAnnotations.hasNext();
+ }
+
+ public EclipseAnnotationPeer next() {
+ AnnotationFS annotation = (AnnotationFS) mAnnotations.next();
+
+ EclipseAnnotationPeer peer =
+ new EclipseAnnotationPeer(annotation.getType().getName(), false, "");
+ peer.setAnnotation(annotation);
+ return peer;
+ }
+
+ public void remove() {
+ }
+ };
+ }
+
+ public Position getPosition(Annotation annotation) {
+ EclipseAnnotationPeer peer = (EclipseAnnotationPeer) annotation;
+ AnnotationFS annotationFS = peer.getAnnotationFS();
+ return new Position(annotationFS.getBegin(), annotationFS.getEnd()
+ - annotationFS.getBegin());
+ }
+
+ public void removeAnnotation(Annotation annotation) {
+ }
+
+ public void removeAnnotationModelListener(IAnnotationModelListener listener) {
+ }
+ };
+ }
+
+ /**
+ * Creates the a new {@link AnnotationDocument} from the given {@link FileEditorInput} element.
+ * For all other elements null is returned.
+ */
+ @Override
+ protected abstract IDocument createDocument(Object element) throws CoreException;
+
+ @Override
+ protected abstract void doSaveDocument(IProgressMonitor monitor, Object element,
+ IDocument document, boolean overwrite) throws CoreException;
+
+ @Override
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ return null;
+ }
+
+ @Override
+ public IStatus getStatus(Object element) {
+ IStatus status = elementErrorStatus.get(element);
+
+ if (status == null) {
+ status = super.getStatus(element);
+ }
+
+ return status;
+ }
+
+ protected abstract AnnotationStyle getAnnotationStyle(Object element, Type type);
+
+ protected abstract EditorAnnotationStatus getEditorAnnotationStatus(Object element);
+
+ protected abstract void setEditorAnnotationStatus(Object element,
+ EditorAnnotationStatus editorAnnotationStatus);
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java Thu May 21 12:38:53 2009
@@ -24,49 +24,49 @@
import org.eclipse.core.runtime.Platform;
class CasDocumentProviderFactory {
-
- private static final String CAS_EDITOR_EXTENSION = "org.apache.uima.caseditor.editor";
-
- private static CasDocumentProviderFactory instance;
-
- private CasDocumentProvider documentProvider;
-
- CasDocumentProviderFactory() {
-
- IConfigurationElement[] config = Platform.getExtensionRegistry()
- .getConfigurationElementsFor(CAS_EDITOR_EXTENSION);
-
- for (IConfigurationElement e : config) {
-
- if ("provider".equals(e.getName())) {
-
- Object o;
- try {
- o = e.createExecutableExtension("class");
- } catch (CoreException e1) {
- // TODO: Log error, extension point was not specified correctly !!!
- e1.printStackTrace();
- o = null;
- }
-
- if (o instanceof CasDocumentProvider) {
- documentProvider = (CasDocumentProvider) o;
- }
- }
- }
-
- }
-
- CasDocumentProvider getDocumentProvider() {
- return documentProvider;
- }
-
- static CasDocumentProviderFactory instance() {
-
- if (instance == null) {
- instance = new CasDocumentProviderFactory();
- }
-
- return instance;
- }
-}
\ No newline at end of file
+
+ private static final String CAS_EDITOR_EXTENSION = "org.apache.uima.caseditor.editor";
+
+ private static CasDocumentProviderFactory instance;
+
+ private CasDocumentProvider documentProvider;
+
+ CasDocumentProviderFactory() {
+
+ IConfigurationElement[] config =
+ Platform.getExtensionRegistry().getConfigurationElementsFor(CAS_EDITOR_EXTENSION);
+
+ for (IConfigurationElement e : config) {
+
+ if ("provider".equals(e.getName())) {
+
+ Object o;
+ try {
+ o = e.createExecutableExtension("class");
+ } catch (CoreException e1) {
+ // TODO: Log error, extension point was not specified correctly !!!
+ e1.printStackTrace();
+ o = null;
+ }
+
+ if (o instanceof CasDocumentProvider) {
+ documentProvider = (CasDocumentProvider) o;
+ }
+ }
+ }
+
+ }
+
+ CasDocumentProvider getDocumentProvider() {
+ return documentProvider;
+ }
+
+ static CasDocumentProviderFactory instance() {
+
+ if (instance == null) {
+ instance = new CasDocumentProviderFactory();
+ }
+
+ return instance;
+ }
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java Thu May 21 12:38:53 2009
@@ -23,28 +23,28 @@
* A general {@link RuntimeException} which is thrown if something unexpected happens.
*/
public class CasEditorError extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- /**
- * Initializes the current instance.
- *
- * @param message
- */
- public CasEditorError(String message) {
- super(message);
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
- /**
- * Initializes the current instance.
- *
- * @param message
- * @param cause
- */
- public CasEditorError(String message, Throwable cause) {
- super(message, cause);
- }
- }
+ /**
+ * Initializes the current instance.
+ *
+ * @param message
+ */
+ public CasEditorError(String message) {
+ super(message);
+ }
+
+ /**
+ * Initializes the current instance.
+ *
+ * @param message
+ * @param cause
+ */
+ public CasEditorError(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DefaultCasDocumentProvider.java Thu May 21 12:38:53 2009
@@ -12,122 +12,116 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.part.FileEditorInput;
-public class DefaultCasDocumentProvider
- extends org.apache.uima.caseditor.editor.CasDocumentProvider {
+public class DefaultCasDocumentProvider extends
+ org.apache.uima.caseditor.editor.CasDocumentProvider {
- @Override
- protected IDocument createDocument(Object element) throws CoreException {
- if (element instanceof FileEditorInput) {
- FileEditorInput fileInput = (FileEditorInput) element;
-
- IFile file = fileInput.getFile();
-
- INlpElement nlpElement = org.apache.uima.caseditor.CasEditorPlugin.getNlpModel().findMember(file);
-
- if (nlpElement instanceof DocumentElement) {
-
- try {
- org.apache.uima.caseditor.editor.ICasDocument workingCopy =
- ((DocumentElement) nlpElement).getDocument(true);
-
- AnnotationDocument document = new AnnotationDocument();
-
- document.setDocument(workingCopy);
-
- elementErrorStatus.remove(element);
-
- return document;
- }
- catch (CoreException e) {
- elementErrorStatus.put(element, new Status(IStatus.ERROR,
- CasEditorPlugin.ID, IStatus.OK,
- "There is a problem with the document: " + e.getMessage(), e));
- }
- }
- else {
- IStatus status;
-
- if (nlpElement == null) {
- status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "Document not in a corpus folder!", null);
- }
- else {
- status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "Not a cas document!", null);
- }
-
- elementErrorStatus.put(element, status);
- }
- }
-
- return null;
- }
-
- @Override
- protected void doSaveDocument(IProgressMonitor monitor, Object element,
- IDocument document, boolean overwrite) throws CoreException {
-
- fireElementStateChanging(element);
-
-
- if (element instanceof FileEditorInput) {
- FileEditorInput fileInput = (FileEditorInput) element;
-
- IFile file = fileInput.getFile();
-
- INlpElement nlpElement = org.apache.uima.caseditor.CasEditorPlugin.getNlpModel().findMember(file);
-
- if (nlpElement instanceof DocumentElement) {
- DocumentElement documentElement = (DocumentElement) nlpElement;
-
- try {
- documentElement.saveDocument();
- }
- catch (CoreException e) {
- fireElementStateChangeFailed(element);
- throw e;
- }
- }
- else {
- fireElementStateChangeFailed(element);
- return;
- }
- }
-
- fireElementDirtyStateChanged(element, false);
- }
-
- private INlpElement getNlpElement(Object element) {
- if (element instanceof FileEditorInput) {
- FileEditorInput fileInput = (FileEditorInput) element;
-
- IFile file = fileInput.getFile();
-
- return org.apache.uima.caseditor.CasEditorPlugin.getNlpModel().findMember(file);
- }
-
- return null;
- }
-
- @Override
+ @Override
+ protected IDocument createDocument(Object element) throws CoreException {
+ if (element instanceof FileEditorInput) {
+ FileEditorInput fileInput = (FileEditorInput) element;
+
+ IFile file = fileInput.getFile();
+
+ INlpElement nlpElement = CasEditorPlugin.getNlpModel().findMember(file);
+
+ if (nlpElement instanceof DocumentElement) {
+
+ try {
+ org.apache.uima.caseditor.editor.ICasDocument workingCopy =
+ ((DocumentElement) nlpElement).getDocument(true);
+
+ AnnotationDocument document = new AnnotationDocument();
+
+ document.setDocument(workingCopy);
+
+ elementErrorStatus.remove(element);
+
+ return document;
+ } catch (CoreException e) {
+ elementErrorStatus.put(element, new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
+ "There is a problem with the document: " + e.getMessage(), e));
+ }
+ } else {
+ IStatus status;
+
+ if (nlpElement == null) {
+ status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
+ "Document not in a corpus folder!", null);
+ } else {
+ status = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, "Not a cas document!",
+ null);
+ }
+
+ elementErrorStatus.put(element, status);
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document,
+ boolean overwrite) throws CoreException {
+
+ fireElementStateChanging(element);
+
+ if (element instanceof FileEditorInput) {
+ FileEditorInput fileInput = (FileEditorInput) element;
+
+ IFile file = fileInput.getFile();
+
+ INlpElement nlpElement =
+ org.apache.uima.caseditor.CasEditorPlugin.getNlpModel().findMember(file);
+
+ if (nlpElement instanceof DocumentElement) {
+ DocumentElement documentElement = (DocumentElement) nlpElement;
+
+ try {
+ documentElement.saveDocument();
+ } catch (CoreException e) {
+ fireElementStateChangeFailed(element);
+ throw e;
+ }
+ } else {
+ fireElementStateChangeFailed(element);
+ return;
+ }
+ }
+
+ fireElementDirtyStateChanged(element, false);
+ }
+
+ private INlpElement getNlpElement(Object element) {
+ if (element instanceof FileEditorInput) {
+ FileEditorInput fileInput = (FileEditorInput) element;
+
+ IFile file = fileInput.getFile();
+
+ return CasEditorPlugin.getNlpModel().findMember(file);
+ }
+
+ return null;
+ }
+
+ @Override
protected AnnotationStyle getAnnotationStyle(Object element, Type type) {
- INlpElement nlpElement = getNlpElement(element);
-
- return nlpElement.getNlpProject().getDotCorpus().getAnnotation(type);
- }
-
- @Override
+ INlpElement nlpElement = getNlpElement(element);
+
+ return nlpElement.getNlpProject().getDotCorpus().getAnnotation(type);
+ }
+
+ @Override
protected EditorAnnotationStatus getEditorAnnotationStatus(Object element) {
- INlpElement nlpElement = getNlpElement(element);
-
- return nlpElement.getNlpProject().getEditorAnnotationStatus();
- }
+ INlpElement nlpElement = getNlpElement(element);
+
+ return nlpElement.getNlpProject().getEditorAnnotationStatus();
+ }
- @Override
+ @Override
protected void setEditorAnnotationStatus(Object element,
- EditorAnnotationStatus editorAnnotationStatus) {
- INlpElement nlpElement = getNlpElement(element);
-
- nlpElement.getNlpProject().setEditorAnnotationStatus(editorAnnotationStatus);
- }
+ EditorAnnotationStatus editorAnnotationStatus) {
+ INlpElement nlpElement = getNlpElement(element);
+
+ nlpElement.getNlpProject().setEditorAnnotationStatus(editorAnnotationStatus);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentFormat.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentFormat.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentFormat.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentFormat.java Thu May 21 12:38:53 2009
@@ -23,6 +23,6 @@
* Specifies the format of the uima document.
*/
public enum DocumentFormat {
- XCAS,
- XMI
-}
\ No newline at end of file
+ XCAS,
+ XMI
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java Thu May 21 12:38:53 2009
@@ -58,320 +58,299 @@
*/
public class DocumentUimaImpl extends AbstractDocument {
- // TODO: Remove field not needed anymore
- private final TypeSystem mTypeSystem;
+ // TODO: Remove field not needed anymore
+ private final TypeSystem mTypeSystem;
- private final CAS mCAS;
+ private final CAS mCAS;
- private final DocumentFormat format;
+ private final DocumentFormat format;
- /**
- * Initializes a new instance.
- *
- * @param project
- */
- public DocumentUimaImpl(CAS cas, InputStream in,
- DocumentFormat format) throws CoreException {
-
- mCAS = cas;
-
- mTypeSystem = cas.getTypeSystem();
-
- this.format = format;
-
- setContent(in);
- }
-
- /**
- * Retrieves the {@link CAS}.
- */
- public CAS getCAS() {
- return mCAS;
- }
-
- /**
- * Adds the given annotation to the {@link CAS}.
- */
- public void addFeatureStructure(FeatureStructure annotation) {
- mCAS.getIndexRepository().addFS(annotation);
-
- fireAddedAnnotation(annotation);
- }
-
- /**
- *
- */
- public void addFeatureStructures(Collection<FeatureStructure> annotations) {
- for (FeatureStructure annotation : annotations) {
- addFeatureStructure(annotation);
- }
- }
-
- /**
- * Remove all annotations. TODO: implement it
- */
- public void removeAnnotation() {
- // must be implemented
- }
-
- /**
- * Internally removes an annotation from the {@link CAS}.
- *
- * @param featureStructure
- */
- private void removeAnnotationInternal(FeatureStructure featureStructure) {
- getCAS().getIndexRepository().removeFS(featureStructure);
- }
-
- /**
- * Removes the annotations from the {@link CAS}.
- */
- public void removeFeatureStructure(FeatureStructure annotation) {
- removeAnnotationInternal(annotation);
-
- fireRemovedAnnotation(annotation);
- }
-
- /**
- * Removes the given annotations from the {@link CAS}.
- */
- public void removeFeatureStructures(
- Collection<FeatureStructure> annotationsToRemove) {
-
- for (FeatureStructure annotationToRemove : annotationsToRemove) {
- removeAnnotationInternal(annotationToRemove);
- }
-
- if (annotationsToRemove.size() > 0) {
- fireRemovedAnnotations(annotationsToRemove);
- }
- }
-
- /**
- * Notifies clients about the changed annotation.
- */
- public void update(FeatureStructure annotation) {
- fireUpdatedFeatureStructure(annotation);
- }
-
- /**
- * Notifies clients about the changed annotation.
- */
- public void updateFeatureStructure(Collection<FeatureStructure> annotations) {
- fireUpdatedFeatureStructures(annotations);
- }
-
- public void changed() {
- fireChanged();
- }
-
- /**
- * Retrieves annotations of the given type from the {@link CAS}.
- */
- public Collection<AnnotationFS> getAnnotations(Type type) {
- FSIndex annotationIndex = mCAS.getAnnotationIndex(type);
-
- StrictTypeConstraint typeConstrain = new StrictTypeConstraint(type);
-
- FSIterator strictTypeIterator = mCAS.createFilteredIterator(
- annotationIndex.iterator(), typeConstrain);
-
- return fsIteratorToCollection(strictTypeIterator);
- }
-
- private Collection<AnnotationFS> fsIteratorToCollection(FSIterator iterator) {
- LinkedList<AnnotationFS> annotations = new LinkedList<AnnotationFS>();
- while (iterator.hasNext()) {
- AnnotationFS annotation = (AnnotationFS) iterator.next();
-
- annotations.addFirst(annotation);
- }
-
- return annotations;
- }
-
- /**
- * Retrieves the annotations in the given span.
- */
- @Override
- public Collection<AnnotationFS> getAnnotation(Type type, Span span) {
- ConstraintFactory cf = getCAS().getConstraintFactory();
-
- Type annotationType = getCAS().getAnnotationType();
-
- FeaturePath beginPath = getCAS().createFeaturePath();
- beginPath.addFeature(annotationType.getFeatureByBaseName("begin"));
- FSIntConstraint beginConstraint = cf.createIntConstraint();
- beginConstraint.geq(span.getStart());
+ /**
+ * Initializes a new instance.
+ *
+ * @param project
+ */
+ public DocumentUimaImpl(CAS cas, InputStream in, DocumentFormat format) throws CoreException {
- FSMatchConstraint embeddedBegin = cf.embedConstraint(beginPath,
- beginConstraint);
+ mCAS = cas;
- FeaturePath endPath = getCAS().createFeaturePath();
- endPath.addFeature(annotationType.getFeatureByBaseName("end"));
- FSIntConstraint endConstraint = cf.createIntConstraint();
- endConstraint.leq(span.getEnd());
+ mTypeSystem = cas.getTypeSystem();
- FSMatchConstraint embeddedEnd = cf.embedConstraint(endPath,
- endConstraint);
+ this.format = format;
- FSMatchConstraint strictType = new StrictTypeConstraint(type);
+ setContent(in);
+ }
- FSMatchConstraint annotatioInSpanConstraint = cf.and(embeddedBegin,
- embeddedEnd);
+ /**
+ * Retrieves the {@link CAS}.
+ */
+ public CAS getCAS() {
+ return mCAS;
+ }
- FSMatchConstraint annotationInSpanAndStrictTypeConstraint = cf.and(
- annotatioInSpanConstraint, strictType);
+ /**
+ * Adds the given annotation to the {@link CAS}.
+ */
+ public void addFeatureStructure(FeatureStructure annotation) {
+ mCAS.getIndexRepository().addFS(annotation);
- FSIndex allAnnotations = getCAS().getAnnotationIndex(type);
+ fireAddedAnnotation(annotation);
+ }
- FSIterator annotationInsideSpanIndex = getCAS().createFilteredIterator(
- allAnnotations.iterator(),
- annotationInSpanAndStrictTypeConstraint);
-
- return fsIteratorToCollection(annotationInsideSpanIndex);
- }
-
- /**
- * Retrieves the given type from the {@link TypeSystem}.
- */
- public Type getType(String type) {
- return getCAS().getTypeSystem().getType(type);
- }
-
- /**
- * Retrieves the text.
- */
- public String getText() {
- return mCAS.getDocumentText();
- }
-
- /**
- * Sets the content. The XCAS {@link InputStream} gets parsed.
- */
- private void setContent(InputStream content) throws CoreException {
-
- SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
- saxParserFactory.setValidating(false);
-
- SAXParser saxParser;
-
- try {
- saxParser = saxParserFactory.newSAXParser();
- } catch (ParserConfigurationException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- } catch (SAXException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- }
-
- if (DocumentFormat.XCAS.equals(format)) {
- XCASDeserializer dezerializer = new XCASDeserializer(mTypeSystem);
-
- try {
- saxParser.parse(content, dezerializer.getXCASHandler(mCAS));
- } catch (IOException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- } catch (SAXException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- }
- } else if (DocumentFormat.XMI.equals(format)) {
- XmiCasDeserializer dezerializer = new XmiCasDeserializer(
- mTypeSystem);
-
- try {
- saxParser.parse(content, dezerializer.getXmiCasHandler(mCAS));
- } catch (IOException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- } catch (SAXException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- }
- } else {
- throw new CoreException(
- new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "Unkown file format!", null));
- }
- }
-
- /**
- * Serializes the {@link CAS} to the given {@link OutputStream} in the XCAS
- * format.
+ /**
+ *
*/
- public void serialize(OutputStream out) throws CoreException {
-
- if (DocumentFormat.XCAS.equals(format)) {
- XCASSerializer xcasSerializer = new XCASSerializer(mCAS
- .getTypeSystem());
-
- XMLSerializer xmlSerialzer = new XMLSerializer(out, true);
-
- try {
- xcasSerializer
- .serialize(mCAS, xmlSerialzer.getContentHandler());
- } catch (IOException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- } catch (SAXException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- }
- } else if (DocumentFormat.XMI.equals(format)) {
- XmiCasSerializer xmiSerializer = new XmiCasSerializer(mCAS
- .getTypeSystem());
-
- XMLSerializer xmlSerialzer = new XMLSerializer(out, true);
-
- try {
- xmiSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
- } catch (SAXException e) {
- String message = e.getMessage() != null ? e.getMessage() : "";
-
- IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID,
- IStatus.OK, message, e);
-
- throw new CoreException(s);
- }
- } else {
- throw new CoreException(
- new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
- "Unkown file format!", null));
- }
- }
-}
\ No newline at end of file
+ public void addFeatureStructures(Collection<FeatureStructure> annotations) {
+ for (FeatureStructure annotation : annotations) {
+ addFeatureStructure(annotation);
+ }
+ }
+
+ /**
+ * Remove all annotations. TODO: implement it
+ */
+ public void removeAnnotation() {
+ // must be implemented
+ }
+
+ /**
+ * Internally removes an annotation from the {@link CAS}.
+ *
+ * @param featureStructure
+ */
+ private void removeAnnotationInternal(FeatureStructure featureStructure) {
+ getCAS().getIndexRepository().removeFS(featureStructure);
+ }
+
+ /**
+ * Removes the annotations from the {@link CAS}.
+ */
+ public void removeFeatureStructure(FeatureStructure annotation) {
+ removeAnnotationInternal(annotation);
+
+ fireRemovedAnnotation(annotation);
+ }
+
+ /**
+ * Removes the given annotations from the {@link CAS}.
+ */
+ public void removeFeatureStructures(Collection<FeatureStructure> annotationsToRemove) {
+
+ for (FeatureStructure annotationToRemove : annotationsToRemove) {
+ removeAnnotationInternal(annotationToRemove);
+ }
+
+ if (annotationsToRemove.size() > 0) {
+ fireRemovedAnnotations(annotationsToRemove);
+ }
+ }
+
+ /**
+ * Notifies clients about the changed annotation.
+ */
+ public void update(FeatureStructure annotation) {
+ fireUpdatedFeatureStructure(annotation);
+ }
+
+ /**
+ * Notifies clients about the changed annotation.
+ */
+ public void updateFeatureStructure(Collection<FeatureStructure> annotations) {
+ fireUpdatedFeatureStructures(annotations);
+ }
+
+ public void changed() {
+ fireChanged();
+ }
+
+ /**
+ * Retrieves annotations of the given type from the {@link CAS}.
+ */
+ public Collection<AnnotationFS> getAnnotations(Type type) {
+ FSIndex annotationIndex = mCAS.getAnnotationIndex(type);
+
+ StrictTypeConstraint typeConstrain = new StrictTypeConstraint(type);
+
+ FSIterator strictTypeIterator =
+ mCAS.createFilteredIterator(annotationIndex.iterator(), typeConstrain);
+
+ return fsIteratorToCollection(strictTypeIterator);
+ }
+
+ private Collection<AnnotationFS> fsIteratorToCollection(FSIterator iterator) {
+ LinkedList<AnnotationFS> annotations = new LinkedList<AnnotationFS>();
+ while (iterator.hasNext()) {
+ AnnotationFS annotation = (AnnotationFS) iterator.next();
+
+ annotations.addFirst(annotation);
+ }
+
+ return annotations;
+ }
+
+ /**
+ * Retrieves the annotations in the given span.
+ */
+ @Override
+ public Collection<AnnotationFS> getAnnotation(Type type, Span span) {
+ ConstraintFactory cf = getCAS().getConstraintFactory();
+
+ Type annotationType = getCAS().getAnnotationType();
+
+ FeaturePath beginPath = getCAS().createFeaturePath();
+ beginPath.addFeature(annotationType.getFeatureByBaseName("begin"));
+ FSIntConstraint beginConstraint = cf.createIntConstraint();
+ beginConstraint.geq(span.getStart());
+
+ FSMatchConstraint embeddedBegin = cf.embedConstraint(beginPath, beginConstraint);
+
+ FeaturePath endPath = getCAS().createFeaturePath();
+ endPath.addFeature(annotationType.getFeatureByBaseName("end"));
+ FSIntConstraint endConstraint = cf.createIntConstraint();
+ endConstraint.leq(span.getEnd());
+
+ FSMatchConstraint embeddedEnd = cf.embedConstraint(endPath, endConstraint);
+
+ FSMatchConstraint strictType = new StrictTypeConstraint(type);
+
+ FSMatchConstraint annotatioInSpanConstraint = cf.and(embeddedBegin, embeddedEnd);
+
+ FSMatchConstraint annotationInSpanAndStrictTypeConstraint =
+ cf.and(annotatioInSpanConstraint, strictType);
+
+ FSIndex allAnnotations = getCAS().getAnnotationIndex(type);
+
+ FSIterator annotationInsideSpanIndex =
+ getCAS().createFilteredIterator(allAnnotations.iterator(),
+ annotationInSpanAndStrictTypeConstraint);
+
+ return fsIteratorToCollection(annotationInsideSpanIndex);
+ }
+
+ /**
+ * Retrieves the given type from the {@link TypeSystem}.
+ */
+ public Type getType(String type) {
+ return getCAS().getTypeSystem().getType(type);
+ }
+
+ /**
+ * Retrieves the text.
+ */
+ public String getText() {
+ return mCAS.getDocumentText();
+ }
+
+ /**
+ * Sets the content. The XCAS {@link InputStream} gets parsed.
+ */
+ private void setContent(InputStream content) throws CoreException {
+
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ saxParserFactory.setValidating(false);
+
+ SAXParser saxParser;
+
+ try {
+ saxParser = saxParserFactory.newSAXParser();
+ } catch (ParserConfigurationException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ } catch (SAXException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ }
+
+ if (DocumentFormat.XCAS.equals(format)) {
+ XCASDeserializer dezerializer = new XCASDeserializer(mTypeSystem);
+
+ try {
+ saxParser.parse(content, dezerializer.getXCASHandler(mCAS));
+ } catch (IOException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ } catch (SAXException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ }
+ } else if (DocumentFormat.XMI.equals(format)) {
+ XmiCasDeserializer dezerializer = new XmiCasDeserializer(mTypeSystem);
+
+ try {
+ saxParser.parse(content, dezerializer.getXmiCasHandler(mCAS));
+ } catch (IOException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ } catch (SAXException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ }
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
+ "Unkown file format!", null));
+ }
+ }
+
+ /**
+ * Serializes the {@link CAS} to the given {@link OutputStream} in the XCAS format.
+ */
+ public void serialize(OutputStream out) throws CoreException {
+
+ if (DocumentFormat.XCAS.equals(format)) {
+ XCASSerializer xcasSerializer = new XCASSerializer(mCAS.getTypeSystem());
+
+ XMLSerializer xmlSerialzer = new XMLSerializer(out, true);
+
+ try {
+ xcasSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
+ } catch (IOException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ } catch (SAXException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ }
+ } else if (DocumentFormat.XMI.equals(format)) {
+ XmiCasSerializer xmiSerializer = new XmiCasSerializer(mCAS.getTypeSystem());
+
+ XMLSerializer xmlSerialzer = new XMLSerializer(out, true);
+
+ try {
+ xmiSerializer.serialize(mCAS, xmlSerialzer.getContentHandler());
+ } catch (SAXException e) {
+ String message = e.getMessage() != null ? e.getMessage() : "";
+
+ IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
+
+ throw new CoreException(s);
+ }
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK,
+ "Unkown file format!", null));
+ }
+ }
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/EditorAnnotationStatus.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/EditorAnnotationStatus.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/EditorAnnotationStatus.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/EditorAnnotationStatus.java Thu May 21 12:38:53 2009
@@ -33,7 +33,7 @@
* as the previously opened editor.
*/
public class EditorAnnotationStatus {
-
+
private String mode;
private Collection<String> displayAnnotations = new HashSet<String>();
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java Thu May 21 12:38:53 2009
@@ -32,18 +32,18 @@
private AnnotationEditor editor;
private IFindReplaceTarget target;
-
+
FindAnnotateAction(AnnotationEditor editor, IFindReplaceTarget target) {
this.editor = editor;
this.target = target;
}
-
+
@Override
public void run() {
FindAnnotateDialog dialog = new FindAnnotateDialog(
Display.getCurrent().getActiveShell(),
editor.getDocument(), target);
-
+
dialog.open();
}
}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java Thu May 21 12:38:53 2009
@@ -54,15 +54,15 @@
private static final int ANNOTATE_BUTTON = 102;
private static final int ANNOTATE_ALL_BUTTON = 103;
private static int CLOSE_BUTTON = 104;
-
+
private final IFindReplaceTarget findReplaceTarget;
private final ICasDocument document;
-
+
private Combo findField;
private TypeCombo typeField;
-
+
private Button forwardRadioButton;
-
+
FindAnnotateDialog(Shell parentShell, ICasDocument document, IFindReplaceTarget findReplaceTarget) {
super(parentShell);
this.document = document;
@@ -73,14 +73,14 @@
public void create() {
// calls createContents first
super.create();
-
+
getShell().setText("Find/Annotate");
-
+
findField.setText(findReplaceTarget.getSelectionText());
-
+
// TODO: set history
}
-
+
/**
* Creates the search string input field.
*
@@ -93,42 +93,42 @@
GridLayout layout= new GridLayout();
layout.numColumns= 2;
panel.setLayout(layout);
-
+
// find label
Label findLabel= new Label(panel, SWT.LEFT);
findLabel.setText("Find:");
-
+
GridData labelData = new GridData();
labelData.horizontalAlignment = SWT.LEFT;
findLabel.setLayoutData(labelData);
-
+
// find combo box
findField = new Combo(panel, SWT.DROP_DOWN | SWT.BORDER);
-
+
GridData findFieldData = new GridData();
findFieldData.horizontalAlignment = SWT.FILL;
findFieldData.grabExcessHorizontalSpace = true;
findField.setLayoutData(findFieldData);
-
+
// type label
Label typeLabel= new Label(panel, SWT.LEFT);
typeLabel.setText("Type:");
GridData typeData = new GridData();
typeData.horizontalAlignment = SWT.LEFT;
typeLabel.setLayoutData(typeData);
-
+
typeField = new TypeCombo(panel,
document.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_ANNOTATION),
document.getCAS().getTypeSystem());
-
+
GridData typeFieldData = new GridData();
typeFieldData.horizontalAlignment = SWT.FILL;
typeFieldData.grabExcessHorizontalSpace = true;
typeField.setLayoutData(typeFieldData);
-
+
return panel;
}
-
+
/**
* Creates the group to specify the direction of the search.
*
@@ -142,24 +142,24 @@
layout.marginWidth= 0;
layout.marginHeight= 0;
panel.setLayout(layout);
-
+
Group group= new Group(panel, SWT.SHADOW_ETCHED_IN);
group.setText("Direction");
GridLayout groupLayout= new GridLayout();
groupLayout.numColumns = 2;
group.setLayout(groupLayout);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
forwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT);
forwardRadioButton.setText("Forward");
forwardRadioButton.setSelection(true);
-
+
Button backwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
backwardRadioButton.setText("Backward");
-
+
return panel;
}
-
+
/**
* Creates the find and annotate buttons.
*
@@ -169,27 +169,27 @@
*/
private Composite createButtonSection(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
-
+
GridLayout layout = new GridLayout();
-
+
// Number of columns should be 2, for each button added to the panel the
// createButton methods increments numColumns. That means after adding
// 3 buttons numColumns is 2.
layout.numColumns = -1;
-
+
panel.setLayout(layout);
-
+
createButton(panel, FIND_BUTTON, "Fi&nd",true);
-
+
createButton(panel, ANNOTATE_FIND_BUTTON, "Annotate/Fin&d", false);
-
+
createButton(panel, ANNOTATE_BUTTON, "&Annotate", false);
-
-// createButton(panel, ANNOTATE_ALL_BUTTON, "Anno&tate All", false);
-
+
+ // createButton(panel, ANNOTATE_ALL_BUTTON, "Anno&tate All", false);
+
return panel;
}
-
+
private Composite createStatusAndCloseButton(Composite parent) {
Composite panel= new Composite(parent, SWT.NULL);
@@ -204,25 +204,25 @@
statusData.horizontalAlignment = SWT.FILL;
statusData.grabExcessHorizontalSpace= true;
statusLabel.setLayoutData(statusData);
-
+
Button closeButton = createButton(panel, CLOSE_BUTTON, "Close", false);
GridData closeData = new GridData();
closeData.horizontalAlignment = SWT.RIGHT;
closeButton.setLayoutData(closeData);
-// setGridData(closeButton, SWT.RIGHT, false, SWT.BOTTOM, false);
+ // setGridData(closeButton, SWT.RIGHT, false, SWT.BOTTOM, false);
return panel;
}
-
+
@Override
protected Control createContents(Composite parent) {
-
+
Composite panel = new Composite(parent, SWT.NULL);
GridLayout layout= new GridLayout();
layout.numColumns= 1;
layout.makeColumnsEqualWidth= true;
panel.setLayout(layout);
-
+
Composite inputPanel = createInputPanel(panel);
GridData inputPanelData = new GridData();
inputPanelData.horizontalAlignment = SWT.FILL;
@@ -230,62 +230,62 @@
inputPanelData.verticalAlignment = SWT.TOP;
inputPanelData.grabExcessVerticalSpace = false;
inputPanel.setLayoutData(inputPanelData);
-
+
createDirectionGroup(panel);
-
+
Composite buttonFindAnnotatePanel = createButtonSection(panel);
GridData buttonFindAnnotatePanelData = new GridData();
buttonFindAnnotatePanelData.horizontalAlignment = SWT.RIGHT;
buttonFindAnnotatePanelData.grabExcessHorizontalSpace = true;
buttonFindAnnotatePanel.setLayoutData(buttonFindAnnotatePanelData);
-
+
Composite statusAndClosePanel = createStatusAndCloseButton(panel);
GridData statusAndClosePanelData = new GridData();
statusAndClosePanelData.horizontalAlignment = SWT.FILL;
statusAndClosePanelData.grabExcessVerticalSpace = true;
statusAndClosePanel.setLayoutData(statusAndClosePanelData);
-
+
applyDialogFont(panel);
-
+
return panel;
}
-
+
/**
* Finds the next occurrence of the search string and selects it in
* the editor.
*/
private void findAndSelectNext() {
-
+
boolean isForwardSearch = forwardRadioButton.getSelection();
-
+
int textOffset = -1;
-
+
if (isForwardSearch) {
textOffset = findReplaceTarget.getSelection().x + findReplaceTarget.getSelection().y;
}
else {
textOffset = findReplaceTarget.getSelection().x - 1;
}
-
+
int result = findReplaceTarget.findAndSelect(textOffset, findField.getText(), isForwardSearch, false, false);
-
+
if (result == -1) {
findReplaceTarget.findAndSelect(-1, findField.getText(), isForwardSearch, false, false);
}
}
-
+
private void annotateSelection() {
Point selection = findReplaceTarget.getSelection();
-
+
FeatureStructure newAnnotation = document.getCAS().createAnnotation(
typeField.getType(), selection.x, selection.x + selection.y);
document.getCAS().addFsToIndexes(newAnnotation);
document.addFeatureStructure(newAnnotation);
}
-
+
@Override
protected void buttonPressed(int buttonID) {
-
+
if (FIND_BUTTON == buttonID) {
findAndSelectNext();
}
@@ -293,8 +293,8 @@
annotateSelection();
}
else if (ANNOTATE_FIND_BUTTON == buttonID) {
- annotateSelection();
- findAndSelectNext();
+ annotateSelection();
+ findAndSelectNext();
}
else if (ANNOTATE_ALL_BUTTON == buttonID) {
}
@@ -302,7 +302,7 @@
close();
}
else {
- throw new TaeError("Unkown button!");
+ throw new TaeError("Unkown button!");
}
}
}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java Thu May 21 12:38:53 2009
@@ -24,14 +24,14 @@
import org.apache.uima.cas.Type;
public interface IAnnotationEditorModifyListener {
-
+
/**
* Called when the editor annotation mode changed.
*
* @param newMode
*/
public void annotationModeChanged(Type newMode);
-
+
/**
* Called when the shown annotation types in the editor are changed.
*
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java Thu May 21 12:38:53 2009
@@ -61,8 +61,7 @@
import org.eclipse.swt.widgets.TreeItem;
/**
- * This is a lightweight popup dialog which creates an annotation of the
- * chosen type.
+ * This is a lightweight popup dialog which creates an annotation of the chosen type.
*/
class QuickTypeSelectionDialog extends PopupDialog {
@@ -76,14 +75,13 @@
/**
* Initializes the current instance.
- *
+ *
* @param parent
* @param editor
*/
@SuppressWarnings("deprecation")
QuickTypeSelectionDialog(Shell parent, AnnotationEditor editor) {
- super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true,
- false, true, null, null);
+ super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true, false, true, null, null);
this.editor = editor;
@@ -95,100 +93,100 @@
Set<Character> shortcuts = new HashSet<Character>();
for (int i = 0; i < shortcutsString.length(); i++) {
- shortcuts.add(shortcutsString.charAt(i));
+ shortcuts.add(shortcutsString.charAt(i));
}
List<Type> types = new ArrayList<Type>();
- Collections.addAll(types, getTypes());
- Collections.sort(types, new Comparator<Type>() {
- public int compare(Type o1, Type o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
-
- // Try to create mappings with first letter of the type name as shortcut
- for (Iterator<Type> it = types.iterator(); it.hasNext();) {
-
- Type type = it.next();
-
- String name = type.getShortName();
-
- Character candidateChar = Character.toLowerCase(name.charAt(0));
-
- if (shortcuts.contains(candidateChar)) {
- putShortcut(candidateChar, type);
-
- shortcuts.remove(candidateChar);
- it.remove();
- }
- }
-
- // Try to create mappings with second letter of the type name as shortcut
- for (Iterator<Type> it = types.iterator(); it.hasNext();) {
-
- Type type = it.next();
-
- String name = type.getShortName();
-
- if (name.length() > 2) {
- Character candidateChar = Character.toLowerCase(name.charAt(1));
-
- if (shortcuts.contains(candidateChar)) {
- putShortcut(candidateChar, type);
-
- shortcuts.remove(candidateChar);
- it.remove();
- }
- }
- }
-
- // Now assign letters to the remaining types
- for (Iterator<Type> it = types.iterator(); it.hasNext();) {
-
- if (shortcuts.size() > 0) {
-
- Character candidateChar = shortcuts.iterator().next();
-
- putShortcut(candidateChar, it.next());
-
- shortcuts.remove(candidateChar);
- it.remove();
- }
- }
+ Collections.addAll(types, getTypes());
+ Collections.sort(types, new Comparator<Type>() {
+ public int compare(Type o1, Type o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+
+ // Try to create mappings with first letter of the type name as shortcut
+ for (Iterator<Type> it = types.iterator(); it.hasNext();) {
+
+ Type type = it.next();
+
+ String name = type.getShortName();
+
+ Character candidateChar = Character.toLowerCase(name.charAt(0));
+
+ if (shortcuts.contains(candidateChar)) {
+ putShortcut(candidateChar, type);
+
+ shortcuts.remove(candidateChar);
+ it.remove();
+ }
+ }
+
+ // Try to create mappings with second letter of the type name as shortcut
+ for (Iterator<Type> it = types.iterator(); it.hasNext();) {
+
+ Type type = it.next();
+
+ String name = type.getShortName();
+
+ if (name.length() > 2) {
+ Character candidateChar = Character.toLowerCase(name.charAt(1));
+
+ if (shortcuts.contains(candidateChar)) {
+ putShortcut(candidateChar, type);
+
+ shortcuts.remove(candidateChar);
+ it.remove();
+ }
+ }
+ }
+
+ // Now assign letters to the remaining types
+ for (Iterator<Type> it = types.iterator(); it.hasNext();) {
+
+ if (shortcuts.size() > 0) {
+
+ Character candidateChar = shortcuts.iterator().next();
+
+ putShortcut(candidateChar, it.next());
+
+ shortcuts.remove(candidateChar);
+ it.remove();
+ }
+ }
}
private void putShortcut(Character shortcut, Type type) {
- shortcutTypeMap.put(shortcut, type);
- typeShortcutMap.put(type, shortcut);
+ shortcutTypeMap.put(shortcut, type);
+ typeShortcutMap.put(type, shortcut);
}
private Type[] getTypes() {
- TypeSystem typeSystem = editor.getDocument().getCAS().getTypeSystem();
+ TypeSystem typeSystem = editor.getDocument().getCAS().getTypeSystem();
- List<Type> types = typeSystem.getProperlySubsumedTypes(typeSystem
- .getType(CAS.TYPE_NAME_ANNOTATION));
+ List<Type> types =
+ typeSystem.getProperlySubsumedTypes(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
- return types.toArray(new Type[types.size()]);
+ return types.toArray(new Type[types.size()]);
}
private void annotateAndClose(Type annotationType) {
- if (annotationType != null) {
- Point textSelection = editor.getSelection();
+ if (annotationType != null) {
+ Point textSelection = editor.getSelection();
- AnnotationFS annotation = editor.getDocument().getCAS()
- .createAnnotation(annotationType, textSelection.x,
- textSelection.y);
-
- editor.getDocument().addFeatureStructure(annotation);
-
- if (annotation.getType().equals(editor.getAnnotationMode())) {
- editor.setAnnotationSelection(annotation);
- }
- }
+ AnnotationFS annotation =
+ editor.getDocument().getCAS().createAnnotation(annotationType, textSelection.x,
+ textSelection.y);
- QuickTypeSelectionDialog.this.close();
- }
+ editor.getDocument().addFeatureStructure(annotation);
+
+ if (annotation.getType().equals(editor.getAnnotationMode())) {
+ editor.setAnnotationSelection(annotation);
+ }
+ }
+
+ QuickTypeSelectionDialog.this.close();
+ }
@Override
protected Control createDialogArea(Composite parent) {
@@ -206,8 +204,8 @@
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final TreeViewer typeTree = new TreeViewer(composite, SWT.SINGLE | SWT.V_SCROLL);
- typeTree.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL |
- GridData.FILL_VERTICAL));
+ typeTree.getControl().setLayoutData(
+ new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
typeTree.getControl().setFocus();
@@ -221,7 +219,7 @@
if (tree.getItemCount() > 0) {
- tree.setSelection(tree.getItem(0));
+ tree.setSelection(tree.getItem(0));
}
}
}
@@ -246,7 +244,7 @@
}
public Object[] getElements(Object inputElement) {
- return (Type[]) inputElement;
+ return (Type[]) inputElement;
}
public void dispose() {
@@ -267,54 +265,53 @@
}
} });
+ typeTree.setLabelProvider(new ILabelProvider() {
- typeTree.setLabelProvider(new ILabelProvider(){
-
- public Image getImage(Object element) {
- return null;
- }
+ public Image getImage(Object element) {
+ return null;
+ }
- public String getText(Object element) {
+ public String getText(Object element) {
- Type type = (Type) element;
+ Type type = (Type) element;
- Character key = typeShortcutMap.get(type);
+ Character key = typeShortcutMap.get(type);
- if (typeShortcutMap != null) {
- return "[" + key +"] " + type.getShortName();
- }
- else {
- return type.getShortName();
- }
- }
+ if (typeShortcutMap != null) {
+ return "[" + key + "] " + type.getShortName();
+ } else {
+ return type.getShortName();
+ }
+ }
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener listener) {
- }
+ }
- public void dispose() {
- }
+ public void dispose() {
+ }
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
- public void removeListener(ILabelProviderListener listener) {
- }});
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ });
typeTree.getControl().addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent e) {
- Type type = shortcutTypeMap.get(Character.toLowerCase(e.character));
-
- if (type != null) {
- annotateAndClose(type);
- }
- }
+ public void keyPressed(KeyEvent e) {
+ Type type = shortcutTypeMap.get(Character.toLowerCase(e.character));
- public void keyReleased(KeyEvent e) {
- }});
+ if (type != null) {
+ annotateAndClose(type);
+ }
+ }
+ public void keyReleased(KeyEvent e) {
+ }
+ });
typeTree.getControl().addMouseMoveListener(new MouseMoveListener() {
@@ -343,8 +340,7 @@
typeTree.setInput(getTypes());
- ISelection modeSelection = new StructuredSelection(new Object[] {
- editor.getAnnotationMode()});
+ ISelection modeSelection = new StructuredSelection(new Object[] { editor.getAnnotationMode() });
typeTree.setSelection(modeSelection, true);
@@ -355,4 +351,4 @@
protected Point getInitialSize() {
return new Point(250, 300);
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java Thu May 21 12:38:53 2009
@@ -65,8 +65,8 @@
}
byte[] id = new byte[] { (byte) (sUniqueID >> 56), (byte) (sUniqueID >> 48),
- (byte) (sUniqueID >> 40), (byte) (sUniqueID >> 32), (byte) (sUniqueID >> 24),
- (byte) (sUniqueID >> 16), (byte) (sUniqueID >> 8), (byte) sUniqueID, };
+ (byte) (sUniqueID >> 40), (byte) (sUniqueID >> 32), (byte) (sUniqueID >> 24),
+ (byte) (sUniqueID >> 16), (byte) (sUniqueID >> 8), (byte) sUniqueID, };
sUniqueID++;
return id;
@@ -84,4 +84,4 @@
return sIdGeneratorInstance;
}
-}
\ No newline at end of file
+}
Modified: incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java?rev=777093&r1=777092&r2=777093&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java (original)
+++ incubator/uima/sandbox/trunk/CasEditorEclipsePlugin/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java Thu May 21 12:38:53 2009
@@ -36,65 +36,65 @@
*/
public class NlpPerspectiveFactory implements IPerspectiveFactory
{
- /**
- * ID of the perspective factory. Use this ID for example in the plugin.xml
- * file.
- */
- public static String ID = "Annotator.perspective.NLP";
-
- /**
- * Define the initial layout of the nlp perspective
- */
- public void createInitialLayout(IPageLayout layout)
- {
- defineActions(layout);
- defineLayout(layout);
- }
-
- private void defineActions(IPageLayout layout)
- {
- // add "new wizards"
- layout.addNewWizardShortcut(NewNlpProjectWizard.ID);
-// layout.addNewWizardShortcut(NewCorpusWizard.ID);
- layout.addNewWizardShortcut(WizardNewFolderCreation.ID);
- layout.addNewWizardShortcut(WizardNewFileCreation.ID);
-
- // layout.addNewWizardShortcut("Annotator.NewDocumentWizard");
-
- // add "show views"
- layout.addShowViewShortcut(CorpusExplorerView.ID);
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
-
- // add "open perspective"
- layout.addPerspectiveShortcut(NlpPerspectiveFactory.ID);
- }
-
- private void defineLayout(IPageLayout layout)
- {
- String editorArea = layout.getEditorArea();
-
- // left views
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
- 0.19f, editorArea);
- left.addView(CorpusExplorerView.ID);
-
- // right views
- IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT,
- 0.70f, editorArea);
-
- right.addView(IPageLayout.ID_OUTLINE);
- right.addView(FeatureStructureBrowserView.ID);
- right.addView("org.eclipse.pde.runtime.LogView");
-
- // bottom views
- IFolderLayout rightBottom = layout.createFolder("rightBottom",
- IPageLayout.BOTTOM, 0.75f, editorArea);
-
- rightBottom.addView(EditView.ID);
-
- IFolderLayout leftBottom = layout.createFolder("leftBottom",
- IPageLayout.RIGHT, 0.5f, EditView.ID);
-
- leftBottom.addView(EditView.ID_2);
- }
-}
\ No newline at end of file
+ /**
+ * ID of the perspective factory. Use this ID for example in the plugin.xml
+ * file.
+ */
+ public static String ID = "Annotator.perspective.NLP";
+
+ /**
+ * Define the initial layout of the nlp perspective
+ */
+ public void createInitialLayout(IPageLayout layout)
+ {
+ defineActions(layout);
+ defineLayout(layout);
+ }
+
+ private void defineActions(IPageLayout layout)
+ {
+ // add "new wizards"
+ layout.addNewWizardShortcut(NewNlpProjectWizard.ID);
+ // layout.addNewWizardShortcut(NewCorpusWizard.ID);
+ layout.addNewWizardShortcut(WizardNewFolderCreation.ID);
+ layout.addNewWizardShortcut(WizardNewFileCreation.ID);
+
+ // layout.addNewWizardShortcut("Annotator.NewDocumentWizard");
+
+ // add "show views"
+ layout.addShowViewShortcut(CorpusExplorerView.ID);
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+
+ // add "open perspective"
+ layout.addPerspectiveShortcut(NlpPerspectiveFactory.ID);
+ }
+
+ private void defineLayout(IPageLayout layout)
+ {
+ String editorArea = layout.getEditorArea();
+
+ // left views
+ IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
+ 0.19f, editorArea);
+ left.addView(CorpusExplorerView.ID);
+
+ // right views
+ IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT,
+ 0.70f, editorArea);
+
+ right.addView(IPageLayout.ID_OUTLINE);
+ right.addView(FeatureStructureBrowserView.ID);
+ right.addView("org.eclipse.pde.runtime.LogView");
+
+ // bottom views
+ IFolderLayout rightBottom = layout.createFolder("rightBottom",
+ IPageLayout.BOTTOM, 0.75f, editorArea);
+
+ rightBottom.addView(EditView.ID);
+
+ IFolderLayout leftBottom = layout.createFolder("leftBottom",
+ IPageLayout.RIGHT, 0.5f, EditView.ID);
+
+ leftBottom.addView(EditView.ID_2);
+ }
+}