You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2022/02/10 14:37:20 UTC
[uima-uimaj] 13/15: [UIMA-6373] Format UIMA Core Java SDK codebase
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch refactoring/UIMA-6373-Format-UIMA-Core-Java-SDK-codebase
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 695bccdd1bb5ce2455a0038a023981585a75e791
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Thu Feb 10 15:20:24 2022 +0100
[UIMA-6373] Format UIMA Core Java SDK codebase
- Auto-format
---
.../org/apache/uima/caseditor/CasEditorPlugin.java | 46 +-
.../java/org/apache/uima/caseditor/Images.java | 5 +-
.../org/apache/uima/caseditor/core/TaeError.java | 10 +-
.../uima/caseditor/core/model/DefaultColors.java | 97 ++-
.../caseditor/core/model/dotcorpus/DotCorpus.java | 45 +-
.../core/model/dotcorpus/DotCorpusSerializer.java | 65 +-
.../editor/AbstractAnnotationDocumentListener.java | 22 +-
.../uima/caseditor/editor/AbstractDocument.java | 72 +-
.../caseditor/editor/AbstractDocumentListener.java | 17 +-
.../uima/caseditor/editor/AnnotationDocument.java | 45 +-
.../uima/caseditor/editor/AnnotationEditor.java | 768 +++++++++++----------
.../editor/AnnotationEditorActionContributor.java | 7 +-
.../AnnotationEditorPreferenceConstants.java | 10 +-
.../AnnotationEditorPreferenceInitializer.java | 3 +-
.../editor/AnnotationEditorPreferencePage.java | 31 +-
.../editor/AnnotationEditorSelection.java | 14 +-
.../caseditor/editor/AnnotationEditorView.java | 13 +-
.../editor/AnnotationInformationProvider.java | 24 +-
.../editor/AnnotationSelectionListener.java | 6 +-
.../uima/caseditor/editor/AnnotationStyle.java | 163 +++--
.../editor/AnnotationStyleChangeListener.java | 11 +-
.../apache/uima/caseditor/editor/ArrayValue.java | 15 +-
.../uima/caseditor/editor/CasDocumentProvider.java | 78 ++-
.../editor/CasDocumentProviderFactory.java | 34 +-
.../uima/caseditor/editor/CasEditorError.java | 11 +-
.../uima/caseditor/editor/CasEditorView.java | 122 ++--
.../uima/caseditor/editor/CasEditorViewPage.java | 80 ++-
.../uima/caseditor/editor/ChangeModeAction.java | 10 +-
.../caseditor/editor/CustomInformationControl.java | 15 +-
.../uima/caseditor/editor/DocumentUimaImpl.java | 90 ++-
.../editor/FeatureStructureSelection.java | 12 +-
.../editor/FeatureStructureSelectionIterator.java | 7 +-
.../editor/FeatureStructureSelectionProvider.java | 19 +-
.../apache/uima/caseditor/editor/FeatureValue.java | 18 +-
.../uima/caseditor/editor/FindAnnotateAction.java | 12 +-
.../uima/caseditor/editor/FindAnnotateDialog.java | 195 +++---
.../editor/IAnnotationEditorModifyListener.java | 19 +-
.../caseditor/editor/IAnnotationStyleListener.java | 18 +-
.../apache/uima/caseditor/editor/ICasDocument.java | 25 +-
.../caseditor/editor/ICasDocumentListener.java | 14 +-
.../apache/uima/caseditor/editor/ICasEditor.java | 27 +-
.../caseditor/editor/ICasEditorInputListener.java | 37 +-
.../ICustomInformationControlContentHandler.java | 9 +-
.../caseditor/editor/IEditorSelectionListener.java | 13 +-
.../caseditor/editor/ModelFeatureStructure.java | 42 +-
.../caseditor/editor/QuickTypeSelectionDialog.java | 37 +-
.../apache/uima/caseditor/editor/SubPageSite.java | 23 +-
.../caseditor/editor/TextDocumentProvider.java | 52 +-
.../action/DeleteFeatureStructureAction.java | 14 +-
.../action/LowerLeftAnnotationSideAction.java | 17 +-
.../action/LowerRightAnnotationSideAction.java | 23 +-
.../editor/action/MergeAnnotationAction.java | 15 +-
.../action/WideLeftAnnotationSideAction.java | 22 +-
.../action/WideRightAnnotationSideAction.java | 21 +-
.../annotation/BackgroundDrawingStrategy.java | 114 +--
.../editor/annotation/BoxDrawingStrategy.java | 36 +-
.../editor/annotation/BracketDrawingStrategy.java | 33 +-
.../caseditor/editor/annotation/DrawingStyle.java | 22 +-
.../editor/annotation/EclipseAnnotationPeer.java | 17 +-
.../editor/annotation/TagDrawingStrategy.java | 117 ++--
.../annotation/TextColorDrawingStrategy.java | 4 +-
.../editor/annotation/TokenDrawingStrategy.java | 20 +-
.../annotation/UnderlineDrawingStrategy.java | 19 +-
.../editor/context/AnnotationEditingControl.java | 7 +-
.../context/AnnotationEditingControlCreator.java | 9 +-
.../editor/contextmenu/IModeMenuListener.java | 27 +-
.../contextmenu/IShowAnnotationsListener.java | 30 +-
.../caseditor/editor/contextmenu/ModeMenu.java | 35 +-
.../editor/contextmenu/ShowAnnotationsMenu.java | 318 ++++-----
.../caseditor/editor/contextmenu/TypeMenu.java | 153 ++--
.../editview/CreateFeatureStructureDialog.java | 23 +-
.../uima/caseditor/editor/editview/EditView.java | 5 +-
.../caseditor/editor/editview/EditViewPage.java | 258 +++----
.../editview/FeatureColumnLabelProvider.java | 7 +-
.../editview/FeatureStructureContentProvider.java | 28 +-
.../editor/editview/ValueColumnLabelProvider.java | 20 +-
.../validator/ByteCellEditorValidator.java | 7 +-
.../validator/CellEditorValidatorFacotory.java | 6 +-
.../validator/FloatCellEditorValidator.java | 6 +-
.../validator/IntegerCellEditorValidator.java | 6 +-
.../validator/LongCellEditorValidator.java | 7 +-
.../validator/ShortCellEditorValidator.java | 5 +-
.../editor/fsview/FeatureStructureBrowserView.java | 5 +-
.../fsview/FeatureStructureBrowserViewPage.java | 69 +-
.../fsview/FeatureStructureLabelProvider.java | 13 +-
.../caseditor/editor/fsview/ITypePaneListener.java | 6 +-
.../uima/caseditor/editor/fsview/TypeCombo.java | 61 +-
.../editor/outline/AnnotationOutline.java | 167 ++---
.../editor/outline/AnnotationTreeNode.java | 32 +-
.../editor/outline/AnnotationTreeNodeList.java | 25 +-
.../editor/outline/AnnotationTypeTreeNode.java | 40 +-
.../outline/ModeSensitiveContentProvider.java | 54 +-
.../editor/outline/OutlineContentProviderBase.java | 163 ++---
.../editor/outline/OutlineLabelProvider.java | 12 +-
.../caseditor/editor/outline/OutlinePageBook.java | 16 +-
.../caseditor/editor/outline/OutlineStyles.java | 11 +-
.../editor/outline/OutlineTableSorter.java | 19 +-
.../editor/outline/SwitchStyleAction.java | 62 +-
.../editor/outline/TypeGroupedContentProvider.java | 274 ++++----
.../editor/styleview/AnnotationStyleView.java | 3 +-
.../editor/styleview/AnnotationStyleViewPage.java | 198 +++---
.../editor/styleview/AnnotationTypeNode.java | 32 +-
.../editor/util/AnnotationComparator.java | 11 +-
.../caseditor/editor/util/AnnotationSelection.java | 16 +-
.../editor/util/ContainingConstraint.java | 20 +-
.../editor/util/FeatureStructureTransfer.java | 54 +-
.../uima/caseditor/editor/util/IDGenerator.java | 11 +-
.../uima/caseditor/editor/util/ObjectTransfer.java | 14 +-
.../uima/caseditor/editor/util/Primitives.java | 103 ++-
.../apache/uima/caseditor/editor/util/Span.java | 27 +-
.../editor/util/StrictTypeConstraint.java | 9 +-
.../uima/caseditor/editor/util/UimaUtil.java | 6 +-
.../ui/property/AnnotationPropertyPage.java | 252 +++----
.../ui/property/EditorAnnotationPropertyPage.java | 10 +-
.../core/model/dotcorpus/AnnotationStyleTest.java | 28 +-
.../model/dotcorpus/DotCorpusSerializerTest.java | 7 +-
.../apache/uima/caseditor/core/util/SpanTest.java | 48 +-
.../uima/caseditor/editor/AnnotationStyleTest.java | 24 +-
.../uima/caseditor/editor/util/SpanTest.java | 52 +-
119 files changed, 3034 insertions(+), 2879 deletions(-)
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
index 3192632..4151f14 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/CasEditorPlugin.java
@@ -28,12 +28,11 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
-
/**
* TODO: add javadoc here.
*/
public class CasEditorPlugin extends AbstractUIPlugin {
-
+
/** The Constant ID. */
public static final String ID = "org.apache.uima.caseditor";
@@ -50,10 +49,9 @@ public class CasEditorPlugin extends AbstractUIPlugin {
*/
private ResourceBundle mResourceBundle;
-
/** The show migration dialog. */
private boolean showMigrationDialog = false;
-
+
/**
* The constructor.
*/
@@ -64,8 +62,10 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* This method is called upon plug-in activation.
*
- * @param context the context
- * @throws Exception -
+ * @param context
+ * the context
+ * @throws Exception
+ * -
*/
@Override
public void start(BundleContext context) throws Exception {
@@ -75,8 +75,10 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* This method is called when the plug-in is stopped.
*
- * @param context the context
- * @throws Exception -
+ * @param context
+ * the context
+ * @throws Exception
+ * -
*/
@Override
public void stop(BundleContext context) throws Exception {
@@ -98,7 +100,8 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* Returns the string from the plugin's resource bundle, or 'key' if not found.
*
- * @param key the key
+ * @param key
+ * the key
* @return resource string
*/
public static String getResourceString(String key) {
@@ -131,17 +134,20 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* Log the throwable.
*
- * @param t the t
+ * @param t
+ * the t
*/
public static void log(Throwable t) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, IStatus.OK, t.getMessage(), t));
}
-
+
/**
* Log.
*
- * @param message the message
- * @param t the t
+ * @param message
+ * the message
+ * @param t
+ * the t
*/
public static void log(String message, Throwable t) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, IStatus.OK, message, t));
@@ -150,7 +156,8 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* Log error.
*
- * @param message the message
+ * @param message
+ * the message
*/
public static void logError(String message) {
getDefault().getLog().log(new Status(IStatus.ERROR, ID, message));
@@ -159,20 +166,21 @@ public class CasEditorPlugin extends AbstractUIPlugin {
/**
* Retrieves an image.
*
- * @param image the image
+ * @param image
+ * the image
* @return the requested image if not available null
*/
public static ImageDescriptor getTaeImageDescriptor(Images image) {
return imageDescriptorFromPlugin(ID, ICONS_PATH + image.getPath());
}
-
+
/**
* Sets the show migration dialog.
*/
public void setShowMigrationDialog() {
showMigrationDialog = true;
}
-
+
/**
* Gets the and clear show migration dialog flag.
*
@@ -183,8 +191,8 @@ public class CasEditorPlugin extends AbstractUIPlugin {
showMigrationDialog = false;
return true;
}
-
+
return false;
}
-
+
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java
index e1c3767..3bc24a5 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/Images.java
@@ -24,12 +24,11 @@ import org.eclipse.jface.resource.ImageDescriptor;
/**
* All images in the Cas Editor are referenced here.
*
- * Call {@link CasEditorPlugin#getTaeImageDescriptor(Images)} to retrieve
- * an actual {@link ImageDescriptor}.
+ * Call {@link CasEditorPlugin#getTaeImageDescriptor(Images)} to retrieve an actual
+ * {@link ImageDescriptor}.
*/
public enum Images {
-
/**
* The source folder image.
*/
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/TaeError.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/TaeError.java
index 609766d..bb11bbb 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/TaeError.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/TaeError.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.core;
-
/**
* A general {@link RuntimeException} which is thrown if something unexpected happens.
*/
@@ -31,7 +30,8 @@ public class TaeError extends RuntimeException {
/**
* Initializes the current instance.
*
- * @param message the message
+ * @param message
+ * the message
*/
public TaeError(String message) {
super(message);
@@ -40,8 +40,10 @@ public class TaeError extends RuntimeException {
/**
* Initializes the current instance.
*
- * @param message the message
- * @param cause the cause
+ * @param message
+ * the message
+ * @param cause
+ * the cause
*/
public TaeError(String message, Throwable cause) {
super(message, cause);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DefaultColors.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DefaultColors.java
index 1eb7ba3..7b585d6 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DefaultColors.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/DefaultColors.java
@@ -32,10 +32,8 @@ import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.caseditor.editor.AnnotationStyle;
-
/**
- * Utility to assign default colors to the annotation types in the
- * TypeSystem.
+ * Utility to assign default colors to the annotation types in the TypeSystem.
*/
public class DefaultColors {
@@ -43,81 +41,74 @@ public class DefaultColors {
/** The Constant BRIGHT. */
// (use high brightness for best contrast against black text)
private static final float BRIGHT = 0.95f;
-
+
/** The Constant COLORS. */
public static final Color[] COLORS = new Color[] {
- // low saturation colors are best, so put them first
- Color.getHSBColor(55f / 360, 0.25f, BRIGHT), // butter yellow?
- Color.getHSBColor(0f / 360, 0.25f, BRIGHT), // pink?
- Color.getHSBColor(210f / 360, 0.25f, BRIGHT), // baby blue?
- Color.getHSBColor(120f / 360, 0.25f, BRIGHT), // mint green?
- Color.getHSBColor(290f / 360, 0.25f, BRIGHT), // lavender?
- Color.getHSBColor(30f / 360, 0.25f, BRIGHT), // tangerine?
- Color.getHSBColor(80f / 360, 0.25f, BRIGHT), // celery green?
- Color.getHSBColor(330f / 360, 0.25f, BRIGHT), // light coral?
- Color.getHSBColor(160f / 360, 0.25f, BRIGHT), // aqua?
- Color.getHSBColor(250f / 360, 0.25f, BRIGHT), // light violet?
-
- // higher saturation colors
- Color.getHSBColor(55f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(0f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(210f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(120f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(290f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(30f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(80f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(330f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(160f / 360, 0.5f, BRIGHT),
- Color.getHSBColor(250f / 360, 0.5f, BRIGHT),
-
- // even higher saturation colors
- Color.getHSBColor(55f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(0f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(210f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(120f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(290f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(30f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(80f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(330f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(160f / 360, 0.75f, BRIGHT),
- Color.getHSBColor(250f / 360, 0.75f, BRIGHT) };
-
+ // low saturation colors are best, so put them first
+ Color.getHSBColor(55f / 360, 0.25f, BRIGHT), // butter yellow?
+ Color.getHSBColor(0f / 360, 0.25f, BRIGHT), // pink?
+ Color.getHSBColor(210f / 360, 0.25f, BRIGHT), // baby blue?
+ Color.getHSBColor(120f / 360, 0.25f, BRIGHT), // mint green?
+ Color.getHSBColor(290f / 360, 0.25f, BRIGHT), // lavender?
+ Color.getHSBColor(30f / 360, 0.25f, BRIGHT), // tangerine?
+ Color.getHSBColor(80f / 360, 0.25f, BRIGHT), // celery green?
+ Color.getHSBColor(330f / 360, 0.25f, BRIGHT), // light coral?
+ Color.getHSBColor(160f / 360, 0.25f, BRIGHT), // aqua?
+ Color.getHSBColor(250f / 360, 0.25f, BRIGHT), // light violet?
+
+ // higher saturation colors
+ Color.getHSBColor(55f / 360, 0.5f, BRIGHT), Color.getHSBColor(0f / 360, 0.5f, BRIGHT),
+ Color.getHSBColor(210f / 360, 0.5f, BRIGHT), Color.getHSBColor(120f / 360, 0.5f, BRIGHT),
+ Color.getHSBColor(290f / 360, 0.5f, BRIGHT), Color.getHSBColor(30f / 360, 0.5f, BRIGHT),
+ Color.getHSBColor(80f / 360, 0.5f, BRIGHT), Color.getHSBColor(330f / 360, 0.5f, BRIGHT),
+ Color.getHSBColor(160f / 360, 0.5f, BRIGHT), Color.getHSBColor(250f / 360, 0.5f, BRIGHT),
+
+ // even higher saturation colors
+ Color.getHSBColor(55f / 360, 0.75f, BRIGHT), Color.getHSBColor(0f / 360, 0.75f, BRIGHT),
+ Color.getHSBColor(210f / 360, 0.75f, BRIGHT), Color.getHSBColor(120f / 360, 0.75f, BRIGHT),
+ Color.getHSBColor(290f / 360, 0.75f, BRIGHT), Color.getHSBColor(30f / 360, 0.75f, BRIGHT),
+ Color.getHSBColor(80f / 360, 0.75f, BRIGHT), Color.getHSBColor(330f / 360, 0.75f, BRIGHT),
+ Color.getHSBColor(160f / 360, 0.75f, BRIGHT), Color.getHSBColor(250f / 360, 0.75f, BRIGHT) };
+
/**
- * Assigns color to the annotation types in the provided <code>TypeSystem</code>.
- * If a user provides an already existing mapping these will not be changed
- * and taken into account when mapping the not assigned types.
+ * Assigns color to the annotation types in the provided <code>TypeSystem</code>. If a user
+ * provides an already existing mapping these will not be changed and taken into account when
+ * mapping the not assigned types.
*
- * @param ts the <code>TypeSystem</code>
- * @param styles already existing styles which map an annotation to a color
+ * @param ts
+ * the <code>TypeSystem</code>
+ * @param styles
+ * already existing styles which map an annotation to a color
* @return the collection
*/
- public static Collection<AnnotationStyle> assignColors(TypeSystem ts, Collection<AnnotationStyle> styles) {
-
+ public static Collection<AnnotationStyle> assignColors(TypeSystem ts,
+ Collection<AnnotationStyle> styles) {
+
Map<String, Color> typeNameToColorMap = new HashMap<>();
-
+
for (AnnotationStyle style : styles) {
typeNameToColorMap.put(style.getAnnotation(), style.getColor());
}
-
+
for (Type type : ts.getProperlySubsumedTypes(ts.getType(CAS.TYPE_NAME_ANNOTATION))) {
if (!typeNameToColorMap.containsKey(type.getName())) {
Color c = COLORS[typeNameToColorMap.size() % COLORS.length];
typeNameToColorMap.put(type.getName(), c);
}
}
-
+
Set<AnnotationStyle> newStyles = new HashSet<>();
-
+
for (AnnotationStyle style : styles) {
typeNameToColorMap.remove(style.getAnnotation());
newStyles.add(style);
}
-
+
for (Map.Entry<String, Color> entry : typeNameToColorMap.entrySet()) {
newStyles.add(new AnnotationStyle(entry.getKey(), AnnotationStyle.Style.BACKGROUND,
entry.getValue(), 0));
}
-
+
return Collections.unmodifiableSet(newStyles);
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java
index 374419e..0750167 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpus.java
@@ -28,13 +28,12 @@ import java.util.Set;
import org.apache.uima.cas.Type;
import org.apache.uima.caseditor.editor.AnnotationStyle;
-
/**
* This class contains all project specific configuration parameters. Note: Use DotCorpusSerialzer
* to read or write an instance of this class to or from a byte stream.
*/
public class DotCorpus {
-
+
/** The default value for editor line length hint. */
public static final int EDITOR_LINE_LENGTH_HINT_DEFAULT = 80;
@@ -61,7 +60,7 @@ public class DotCorpus {
* Contains names of types which are visible/shown.
*/
private Set<String> shownTypes = new HashSet<>();
-
+
/**
* Retrieves type system name parameter.
*
@@ -107,7 +106,8 @@ public class DotCorpus {
/**
* Removes the cas processor folder.
*
- * @param folder the folder
+ * @param folder
+ * the folder
*/
@Deprecated
public void removeCasProcessorFolder(String folder) {
@@ -117,7 +117,8 @@ public class DotCorpus {
/**
* Adds a corpus folder.
*
- * @param name the name
+ * @param name
+ * the name
*/
@Deprecated
public void addCorpusFolder(String name) {
@@ -127,7 +128,8 @@ public class DotCorpus {
/**
* Removes the given corpus folder.
*
- * @param name the name
+ * @param name
+ * the name
*/
@Deprecated
public void removeCorpusFolder(String name) {
@@ -159,7 +161,8 @@ public class DotCorpus {
/**
* Sets the editor line length hint parameter.
*
- * @param lineLengthHint the new editor line length
+ * @param lineLengthHint
+ * the new editor line length
* @deprecated setting was moved to preference store
*/
@Deprecated
@@ -175,7 +178,7 @@ public class DotCorpus {
public Collection<AnnotationStyle> getAnnotationStyles() {
return Collections.unmodifiableCollection(mStyleMap.values());
}
-
+
/**
* Gets the shown types.
*
@@ -184,29 +187,32 @@ public class DotCorpus {
public Collection<String> getShownTypes() {
return Collections.unmodifiableCollection(shownTypes);
}
-
+
/**
* Sets the shown type.
*
- * @param type the new shown type
+ * @param type
+ * the new shown type
*/
public void setShownType(String type) {
shownTypes.add(type);
}
-
+
/**
* Removes the shown type.
*
- * @param type the type
+ * @param type
+ * the type
*/
public void removeShownType(String type) {
shownTypes.remove(type);
}
-
+
/**
* Adds an AnnotationStyle. TODO: move style stuff to nlp project
*
- * @param style the new style
+ * @param style
+ * the new style
*/
public void setStyle(AnnotationStyle style) {
@@ -224,7 +230,8 @@ public class DotCorpus {
/**
* Removes an AnnotationStyle for the given name, does nothing if not existent.
*
- * @param name the name
+ * @param name
+ * the name
*/
public void removeStyle(String name) {
mStyleMap.remove(name);
@@ -233,7 +240,8 @@ public class DotCorpus {
/**
* Retrieves the AnnotationStyle for the given type or null if not available.
*
- * @param type the type
+ * @param type
+ * the type
* @return the requested style or null if none
*/
public AnnotationStyle getAnnotation(Type type) {
@@ -256,11 +264,12 @@ public class DotCorpus {
public int hashCode() {
return 0;
}
-
+
/**
* Checks if the given object is equal to the current instance.
*
- * @param obj the obj
+ * @param obj
+ * the obj
* @return true, if successful
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java
index b74357d..b841cb3 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/core/model/dotcorpus/DotCorpusSerializer.java
@@ -42,7 +42,6 @@ import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
-
/**
* This class is responsible to read and write {@link DotCorpus} objects from or to a byte stream.
*/
@@ -71,7 +70,7 @@ public class DotCorpusSerializer {
/** The Constant STYLE_LAYER_ATTRIBUTE. */
private static final String STYLE_LAYER_ATTRIBUTE = "layer";
-
+
/** The Constant STYLE_CONFIG_ATTRIBUTE. */
private static final String STYLE_CONFIG_ATTRIBUTE = "config";
@@ -95,20 +94,21 @@ public class DotCorpusSerializer {
/** The Constant SHOWN_ELEMENT. */
private static final String SHOWN_ELEMENT = "shown";
-
+
/** The Constant SHOWN_TYPE_ATTRIBUTE. */
private static final String SHOWN_TYPE_ATTRIBUTE = "type";
-
+
/** The Constant SHOWN_IS_VISISBLE_ATTRIBUTE. */
private static final String SHOWN_IS_VISISBLE_ATTRIBUTE = "visible";
-
-
+
/**
* Creates a {@link DotCorpus} object from a given {@link InputStream}.
*
- * @param dotCorpusStream the dot corpus stream
+ * @param dotCorpusStream
+ * the dot corpus stream
* @return the {@link DotCorpus} instance.
- * @throws CoreException -
+ * @throws CoreException
+ * -
*/
public static DotCorpus parseDotCorpus(InputStream dotCorpusStream) throws CoreException {
DocumentBuilderFactory documentBuilderFactory = XMLUtils.createDocumentBuilderFactory();
@@ -161,7 +161,7 @@ public class DotCorpusSerializer {
// TODO: This code will emit NumberFormatExceptions if the values
// are incorrect, they should be caught, logged and replaced with default
// values
-
+
if (TYPESYSTEM_ELEMENT.equals(corporaChildElement.getNodeName())) {
dotCorpus.setTypeSystemFilename(corporaChildElement.getAttribute(TYPESYTEM_FILE_ATTRIBUTE));
} else if (CORPUS_ELEMENT.equals(corporaChildElement.getNodeName())) {
@@ -179,12 +179,12 @@ public class DotCorpusSerializer {
Color color = new Color(colorInteger);
String drawingLayerString = corporaChildElement.getAttribute(STYLE_LAYER_ATTRIBUTE);
-
+
String drawingConfigString = corporaChildElement.getAttribute(STYLE_CONFIG_ATTRIBUTE);
-
+
if (drawingConfigString.length() == 0)
drawingConfigString = null;
-
+
int drawingLayer;
try {
@@ -193,13 +193,14 @@ public class DotCorpusSerializer {
drawingLayer = 0;
}
- AnnotationStyle style = new AnnotationStyle(type, AnnotationStyle.Style
- .valueOf(styleString), color, drawingLayer, drawingConfigString);
+ AnnotationStyle style = new AnnotationStyle(type,
+ AnnotationStyle.Style.valueOf(styleString), color, drawingLayer,
+ drawingConfigString);
dotCorpus.setStyle(style);
} else if (CAS_PROCESSOR_ELEMENT.equals(corporaChildElement.getNodeName())) {
- dotCorpus.addCasProcessorFolder(corporaChildElement
- .getAttribute(CAS_PROCESSOR_FOLDER_ATTRIBUTE));
+ dotCorpus.addCasProcessorFolder(
+ corporaChildElement.getAttribute(CAS_PROCESSOR_FOLDER_ATTRIBUTE));
} else if (EDITOR_ELEMENT.equals(corporaChildElement.getNodeName())) {
String lineLengthHintString = corporaChildElement
.getAttribute(EDITOR_LINE_LENGTH_ATTRIBUTE);
@@ -209,16 +210,15 @@ public class DotCorpusSerializer {
dotCorpus.setEditorLineLength(lineLengthHint);
} else if (SHOWN_ELEMENT.equals(corporaChildElement.getNodeName())) {
String type = corporaChildElement.getAttribute(SHOWN_TYPE_ATTRIBUTE);
-
+
String isVisisbleString = corporaChildElement.getAttribute(SHOWN_IS_VISISBLE_ATTRIBUTE);
-
+
boolean isVisible = Boolean.parseBoolean(isVisisbleString);
-
+
if (isVisible) {
- dotCorpus.setShownType(type);
+ dotCorpus.setShownType(type);
}
- }
- else {
+ } else {
String message = "Unexpected element: " + corporaChildElement.getNodeName();
IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, null);
@@ -237,7 +237,8 @@ public class DotCorpusSerializer {
* the {@link DotCorpus} object to serialize.
* @param out
* - the stream to write the current <code>DotCorpus</code> instance.
- * @throws CoreException -
+ * @throws CoreException
+ * -
*/
public static void serialize(DotCorpus dotCorpus, OutputStream out) throws CoreException {
@@ -264,11 +265,11 @@ public class DotCorpusSerializer {
Color color = style.getColor();
int colorInt = new Color(color.getRed(), color.getGreen(), color.getBlue()).getRGB();
styleAttributes.addAttribute("", "", STYLE_COLOR_ATTRIBUTE, "", Integer.toString(colorInt));
- styleAttributes.addAttribute("", "", STYLE_LAYER_ATTRIBUTE, "", Integer.toString(style
- .getLayer()));
+ styleAttributes.addAttribute("", "", STYLE_LAYER_ATTRIBUTE, "",
+ Integer.toString(style.getLayer()));
if (style.getConfiguration() != null) {
- styleAttributes.addAttribute("", "", STYLE_CONFIG_ATTRIBUTE, "", style
- .getConfiguration());
+ styleAttributes.addAttribute("", "", STYLE_CONFIG_ATTRIBUTE, "",
+ style.getConfiguration());
}
xmlSerHandler.startElement("", STYLE_ELEMENT, STYLE_ELEMENT, styleAttributes);
@@ -276,19 +277,19 @@ public class DotCorpusSerializer {
}
for (String type : dotCorpus.getShownTypes()) {
-
+
AttributesImpl shownAttributes = new AttributesImpl();
shownAttributes.addAttribute("", "", SHOWN_TYPE_ATTRIBUTE, "", type);
shownAttributes.addAttribute("", "", SHOWN_IS_VISISBLE_ATTRIBUTE, "", "true");
-
+
xmlSerHandler.startElement("", SHOWN_ELEMENT, SHOWN_ELEMENT, shownAttributes);
xmlSerHandler.endElement("", SHOWN_ELEMENT, SHOWN_ELEMENT);
}
-
+
if (dotCorpus.getTypeSystemFileName() != null) {
AttributesImpl typeSystemFileAttributes = new AttributesImpl();
- typeSystemFileAttributes.addAttribute("", "", TYPESYTEM_FILE_ATTRIBUTE, "", dotCorpus
- .getTypeSystemFileName());
+ typeSystemFileAttributes.addAttribute("", "", TYPESYTEM_FILE_ATTRIBUTE, "",
+ dotCorpus.getTypeSystemFileName());
xmlSerHandler.startElement("", TYPESYSTEM_ELEMENT, TYPESYSTEM_ELEMENT,
typeSystemFileAttributes);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractAnnotationDocumentListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractAnnotationDocumentListener.java
index 9d2e8ac..204db2d 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractAnnotationDocumentListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractAnnotationDocumentListener.java
@@ -25,7 +25,6 @@ import java.util.Collection;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.text.AnnotationFS;
-
/**
* This listener listens only for {@link AnnotationFS} change events. All other change events for
* {@link FeatureStructure}s are filtered.
@@ -35,7 +34,8 @@ public abstract class AbstractAnnotationDocumentListener extends AbstractDocumen
/**
* Filter annotations.
*
- * @param structures the structures
+ * @param structures
+ * the structures
* @return the collection
*/
private Collection<AnnotationFS> filterAnnotations(Collection<FeatureStructure> structures) {
@@ -53,7 +53,8 @@ public abstract class AbstractAnnotationDocumentListener extends AbstractDocumen
/**
* Add notification.
*
- * @param structures the structures
+ * @param structures
+ * the structures
*/
@Override
public void added(Collection<FeatureStructure> structures) {
@@ -67,7 +68,8 @@ public abstract class AbstractAnnotationDocumentListener extends AbstractDocumen
/**
* Remove notification.
*
- * @param structures the structures
+ * @param structures
+ * the structures
*/
@Override
public void removed(Collection<FeatureStructure> structures) {
@@ -81,7 +83,8 @@ public abstract class AbstractAnnotationDocumentListener extends AbstractDocumen
/**
* Update notification.
*
- * @param structures the structures
+ * @param structures
+ * the structures
*/
@Override
public void updated(Collection<FeatureStructure> structures) {
@@ -95,21 +98,24 @@ public abstract class AbstractAnnotationDocumentListener extends AbstractDocumen
/**
* Added annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
protected abstract void addedAnnotation(Collection<AnnotationFS> annotations);
/**
* Removed annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
protected abstract void removedAnnotation(Collection<AnnotationFS> annotations);
/**
* Updated annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
protected abstract void updatedAnnotation(Collection<AnnotationFS> annotations);
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
index 2771690..9cdb812 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocument.java
@@ -27,7 +27,6 @@ import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.util.SafeRunnable;
-
/**
* Abstract base class for document implementations.
*/
@@ -40,7 +39,8 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Registers a change listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
@Override
public void addChangeListener(final ICasDocumentListener listener) {
@@ -50,7 +50,8 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Unregisters a change listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
@Override
public void removeChangeListener(ICasDocumentListener listener) {
@@ -60,13 +61,14 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends an added message to registered listeners.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
protected void fireAddedFeatureStructure(final FeatureStructure annotation) {
-
+
for (Object listener : mListener.getListeners()) {
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -79,13 +81,15 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends an added message to registered listeners.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
- protected void fireAddedFeatureStructure(final Collection<? extends FeatureStructure> annotations) {
+ protected void fireAddedFeatureStructure(
+ final Collection<? extends FeatureStructure> annotations) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -98,13 +102,14 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends a removed message to registered listeners.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
protected void fireRemovedFeatureStructure(final FeatureStructure annotation) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -117,13 +122,15 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends a removed message to registered listeners.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
- protected void fireRemovedFeatureStructure(final Collection<? extends FeatureStructure> annotations) {
+ protected void fireRemovedFeatureStructure(
+ final Collection<? extends FeatureStructure> annotations) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -136,13 +143,14 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends an updated message to registered listeners.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
protected void fireUpdatedFeatureStructure(final FeatureStructure annotation) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -155,13 +163,15 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Sends an updated message to registered listeners.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
- protected void fireUpdatedFeatureStructure(final Collection<? extends FeatureStructure> annotations) {
+ protected void fireUpdatedFeatureStructure(
+ final Collection<? extends FeatureStructure> annotations) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -176,9 +186,9 @@ public abstract class AbstractDocument implements ICasDocument {
*/
protected void fireChanged() {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -191,14 +201,16 @@ public abstract class AbstractDocument implements ICasDocument {
/**
* Fire view changed.
*
- * @param oldViewName the old view name
- * @param newViewName the new view name
+ * @param oldViewName
+ * the old view name
+ * @param newViewName
+ * the new view name
*/
protected void fireViewChanged(final String oldViewName, final String newViewName) {
for (Object listener : mListener.getListeners()) {
-
+
final ICasDocumentListener documentListener = (ICasDocumentListener) listener;
-
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocumentListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocumentListener.java
index 6e2fc25..3d09d0e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocumentListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AbstractDocumentListener.java
@@ -29,11 +29,12 @@ public abstract class AbstractDocumentListener implements ICasDocumentListener {
@Override
public void added(Collection<FeatureStructure> newFeatureStructure) {
}
-
+
/**
* Forwards the call.
*
- * @param newAnnotation the new annotation
+ * @param newAnnotation
+ * the new annotation
*/
@Override
public void added(FeatureStructure newAnnotation) {
@@ -43,11 +44,12 @@ public abstract class AbstractDocumentListener implements ICasDocumentListener {
@Override
public void removed(Collection<FeatureStructure> deletedFeatureStructure) {
}
-
+
/**
* Forwards the call.
*
- * @param deletedAnnotation the deleted annotation
+ * @param deletedAnnotation
+ * the deleted annotation
*/
@Override
public void removed(FeatureStructure deletedAnnotation) {
@@ -57,11 +59,12 @@ public abstract class AbstractDocumentListener implements ICasDocumentListener {
@Override
public void updated(Collection<FeatureStructure> featureStructure) {
}
-
+
/**
* Forwards the call.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void updated(FeatureStructure annotation) {
@@ -71,7 +74,7 @@ public abstract class AbstractDocumentListener implements ICasDocumentListener {
@Override
public void changed() {
}
-
+
@Override
public void viewChanged(String oldViewName, String newViewName) {
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
index e84021b..577c958 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationDocument.java
@@ -30,7 +30,6 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentEvent;
-
/**
* The <code>AnnotationDocument</code> adapts the annotation document to the eclipse Document
* (needed for the editor).
@@ -59,7 +58,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Transform text.
*
- * @param text the text
+ * @param text
+ * the text
* @return the string
*/
private String transformText(String text) {
@@ -100,7 +100,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Sets the document.
*
- * @param element the new document
+ * @param element
+ * the new document
*/
public void setDocument(ICasDocument element) {
mDocument = element;
@@ -120,7 +121,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void addFeatureStructure(FeatureStructure annotation) {
@@ -132,7 +134,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
@Override
public void addFeatureStructures(Collection<? extends FeatureStructure> annotations) {
@@ -144,7 +147,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void removeFeatureStructure(FeatureStructure annotation) {
@@ -156,7 +160,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotationsToRemove the annotations to remove
+ * @param annotationsToRemove
+ * the annotations to remove
*/
@Override
public void removeFeatureStructures(Collection<? extends FeatureStructure> annotationsToRemove) {
@@ -168,7 +173,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void update(FeatureStructure annotation) {
@@ -180,7 +186,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
@Override
public void updateFeatureStructure(Collection<? extends FeatureStructure> annotations) {
@@ -202,7 +209,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param type the type
+ * @param type
+ * the type
* @return the annotations
*/
@Override
@@ -213,7 +221,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
@Override
public void addChangeListener(ICasDocumentListener listener) {
@@ -223,7 +232,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
@Override
public void removeChangeListener(ICasDocumentListener listener) {
@@ -234,8 +244,10 @@ class AnnotationDocument extends Document implements ICasDocument {
* Wrap words at next space after lineLengthHint chars in a line. If the line is shorter than
* lineLengthHint nothing happens. The space char is replaced with an line feed char.
*
- * @param textString the text string
- * @param lineLengthHint the line length hint
+ * @param textString
+ * the text string
+ * @param lineLengthHint
+ * the line length hint
* @return input text with line breaks
*/
private String wrapWords(String textString, int lineLengthHint) {
@@ -274,7 +286,8 @@ class AnnotationDocument extends Document implements ICasDocument {
/**
* Call is forwarded to the set document.
*
- * @param type the type
+ * @param type
+ * the type
* @return the type
*/
@Override
@@ -304,7 +317,7 @@ class AnnotationDocument extends Document implements ICasDocument {
@Override
public String getTypeSystemText() {
- if(mDocument != null) {
+ if (mDocument != null) {
return mDocument.getTypeSystemText();
}
return null;
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
index 4d911d9..6f8e20a 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditor.java
@@ -143,40 +143,41 @@ import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
import org.eclipse.ui.texteditor.StatusTextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-
/**
* An editor to annotate text.
*/
-public final class AnnotationEditor extends StatusTextEditor implements ICasEditor, ISelectionListener {
-
+public final class AnnotationEditor extends StatusTextEditor
+ implements ICasEditor, ISelectionListener {
+
/**
* The Class AbstractAnnotateAction.
*/
private abstract class AbstractAnnotateAction extends Action
- implements ISelectionChangedListener {
+ implements ISelectionChangedListener {
@Override
public void selectionChanged(SelectionChangedEvent event) {
- setEnabled(AnnotationEditor.this.getSelection().y -
- AnnotationEditor.this.getSelection().x > 0);
+ setEnabled(
+ AnnotationEditor.this.getSelection().y - AnnotationEditor.this.getSelection().x > 0);
}
}
-
+
/**
* This action annotates the selected text with a defined tag.
*/
private class QuickAnnotateAction extends AbstractAnnotateAction {
-
+
/** The Constant ID. */
private static final String ID = "QuickAnnotate";
-
+
/** The m text widget. */
private StyledText mTextWidget;
/**
* Initializes a new instance.
*
- * @param textWidget the text widget
+ * @param textWidget
+ * the text widget
*/
QuickAnnotateAction(StyledText textWidget) {
mTextWidget = textWidget;
@@ -193,7 +194,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// get old annotations of current type for this area
// if there is something ... the delete them and add
Collection<AnnotationFS> oldAnnotations = getAnnotation(getDocument().getCAS(),
- getAnnotationMode(), new Span(selection.x, selection.y));
+ getAnnotationMode(), new Span(selection.x, selection.y));
if (!oldAnnotations.isEmpty()) {
getDocument().removeFeatureStructures(oldAnnotations);
@@ -228,15 +229,14 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/** The Constant ID. */
private static final String ID = "Annotate";
-
+
@Override
public void run() {
if (isSomethingSelected()) {
- QuickTypeSelectionDialog typeDialog =
- new QuickTypeSelectionDialog(Display.getCurrent().getActiveShell(),
- AnnotationEditor.this);
+ QuickTypeSelectionDialog typeDialog = new QuickTypeSelectionDialog(
+ Display.getCurrent().getActiveShell(), AnnotationEditor.this);
typeDialog.open();
}
@@ -247,7 +247,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
* Shows the annotation editing context for the active annotation.
*/
private class ShowAnnotationContextEditAction extends Action {
-
+
/** The m presenter. */
private InformationPresenter mPresenter;
@@ -299,30 +299,33 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
* document with the annotations in eclipse.
*/
private class DocumentListener extends AbstractAnnotationDocumentListener {
-
+
/**
* Adds a collection of annotations.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
@Override
public void addedAnnotation(Collection<AnnotationFS> annotations) {
- IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
-
+ IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider()
+ .getAnnotationModel(getEditorInput());
+
Map<Annotation, Position> addAnnotationMap = new HashMap<>();
-
+
for (AnnotationFS annotation : annotations) {
- addAnnotationMap.put(new EclipseAnnotationPeer(annotation), new Position(annotation.getBegin(),
- annotation.getEnd() - annotation.getBegin()));
+ addAnnotationMap.put(new EclipseAnnotationPeer(annotation),
+ new Position(annotation.getBegin(), annotation.getEnd() - annotation.getBegin()));
}
-
+
annotationModel.replaceAnnotations(null, addAnnotationMap);
}
/**
* Removes a collection of annotations.
*
- * @param deletedAnnotations the deleted annotations
+ * @param deletedAnnotations
+ * the deleted annotations
*/
@Override
public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) {
@@ -335,35 +338,38 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
highlight(0, 0); // TODO: only if removed annotation was selected
- IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
-
+ IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider()
+ .getAnnotationModel(getEditorInput());
+
Annotation removeAnnotations[] = new Annotation[deletedAnnotations.size()];
int removeAnnotationsIndex = 0;
for (AnnotationFS annotation : deletedAnnotations) {
removeAnnotations[removeAnnotationsIndex++] = new EclipseAnnotationPeer(annotation);
}
-
+
annotationModel.replaceAnnotations(removeAnnotations, null);
}
/**
* Updated annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
@Override
public void updatedAnnotation(Collection<AnnotationFS> annotations) {
-
- IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
-
+
+ IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider()
+ .getAnnotationModel(getEditorInput());
+
for (AnnotationFS annotation : annotations) {
- annotationModel.modifyAnnotationPosition(new EclipseAnnotationPeer(annotation),
+ annotationModel.modifyAnnotationPosition(new EclipseAnnotationPeer(annotation),
new Position(annotation.getBegin(), annotation.getEnd() - annotation.getBegin()));
}
-
- selectionChanged(getSite().getPage().getActivePart(), mFeatureStructureSelectionProvider.getSelection());
- }
+ selectionChanged(getSite().getPage().getActivePart(),
+ mFeatureStructureSelectionProvider.getSelection());
+ }
@Override
public void changed() {
@@ -374,7 +380,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
@Override
public void viewChanged(String oldViewName, String newViewName) {
- // TODO: Currently do nothing ...
+ // TODO: Currently do nothing ...
}
}
@@ -382,7 +388,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
* Sometimes the wrong annotation is selected ... ????
*/
private class FeatureStructureDragListener implements DragSourceListener {
-
+
/** The m is active. */
private boolean mIsActive;
@@ -392,7 +398,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Instantiates a new feature structure drag listener.
*
- * @param textWidget the text widget
+ * @param textWidget
+ * the text widget
*/
FeatureStructureDragListener(final StyledText textWidget) {
textWidget.addKeyListener(new KeyListener() {
@@ -426,8 +433,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// Workaround: It is possible check that is text under the cursor ?
try {
offset = textWidget.getOffsetAtLocation(new Point(e.x, e.y));
- }
- catch (IllegalArgumentException e2) {
+ } catch (IllegalArgumentException e2) {
return;
}
@@ -436,8 +442,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
mCandidate = view.get(offset);
if (mCandidate != null) {
- textWidget.setSelectionRange(mCandidate.getBegin(), mCandidate.getEnd()
- - mCandidate.getBegin());
+ textWidget.setSelectionRange(mCandidate.getBegin(),
+ mCandidate.getEnd() - mCandidate.getBegin());
}
}
}
@@ -494,12 +500,10 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// ask document provider for this
// getAnnotation must be added to cas document provider
- AnnotationStyle style = getAnnotationStyle(
- eclipseAnnotation.getAnnotationFS().getType());
+ AnnotationStyle style = getAnnotationStyle(eclipseAnnotation.getAnnotationFS().getType());
return style.getLayer();
- }
- else {
+ } else {
return 0;
}
}
@@ -522,11 +526,12 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
}
/**
- * This implementation imitates the behavior without the
- * {@link IAnnotationAccessExtension}.
+ * This implementation imitates the behavior without the {@link IAnnotationAccessExtension}.
*
- * @param annotationType the annotation type
- * @param potentialSupertype the potential supertype
+ * @param annotationType
+ * the annotation type
+ * @param potentialSupertype
+ * the potential supertype
* @return true, if is subtype
*/
@Override
@@ -534,8 +539,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
Type type = getDocument().getCAS().getTypeSystem().getType((String) annotationType);
- return mShowAnnotationsMenu.getSelectedTypes().contains(type) ||
- getAnnotationMode().equals(type);
+ return mShowAnnotationsMenu.getSelectedTypes().contains(type)
+ || getAnnotationMode().equals(type);
}
@Override
@@ -549,61 +554,62 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
*/
// TODO: Move to external class
static class CasViewMenu extends ContributionItem {
-
+
/** The cas editor. */
private AnnotationEditor casEditor;
-
+
/**
* Instantiates a new cas view menu.
*
- * @param casEditor the cas editor
+ * @param casEditor
+ * the cas editor
*/
public CasViewMenu(AnnotationEditor casEditor) {
this.casEditor = casEditor;
- }
+ }
@Override
public void fill(Menu parentMenu, int index) {
-
+
CAS cas = casEditor.getDocument().getCAS();
-
- for (Iterator<CAS> it = cas.getViewIterator(); it.hasNext(); ) {
-
+
+ for (Iterator<CAS> it = cas.getViewIterator(); it.hasNext();) {
+
CAS casView = it.next();
final String viewName = casView.getViewName();
-
+
final MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
actionItem.setText(viewName);
-
+
// TODO: Disable non-text views, check mime-type
try {
actionItem.setEnabled(cas.getDocumentText() != null);
} catch (Throwable t) {
// TODO: Not nice, discuss better solution on ml
- actionItem.setEnabled(false);
+ actionItem.setEnabled(false);
}
-
+
// TODO: Add support for non text views, editor has
- // to display some error message
-
+ // to display some error message
+
if (cas.getViewName().equals(viewName))
- actionItem.setSelection(true);
-
+ actionItem.setSelection(true);
+
// TODO: move this to an action
actionItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
// Trigger only if view is really changed
// TODO: Move this check to the document itself ...
- if(!casEditor.getDocument().getCAS().getViewName().equals(viewName)) {
- casEditor.showView(viewName);
+ if (!casEditor.getDocument().getCAS().getViewName().equals(viewName)) {
+ casEditor.showView(viewName);
}
}
});
}
}
}
-
+
/** The m annotation mode. */
private Type mAnnotationMode;
@@ -617,7 +623,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/** The m editor input listener. */
private ListenerList mEditorInputListener = new ListenerList();
-
+
/** TODO: Do we really need this position variable ?. */
private int mCursorPosition;
@@ -641,13 +647,13 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/** The m annotation style listener. */
private AnnotationStyleChangeListener mAnnotationStyleListener;
-
+
/** The shown annotation types. */
private Collection<Type> shownAnnotationTypes = new HashSet<>();
-
+
/** The preference store change listener. */
private IPropertyChangeListener preferenceStoreChangeListener;
-
+
/** The cas document provider. */
private CasDocumentProvider casDocumentProvider;
@@ -659,19 +665,18 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- casDocumentProvider =
- CasDocumentProviderFactory.instance().getDocumentProvider(input);
-
+ casDocumentProvider = CasDocumentProviderFactory.instance().getDocumentProvider(input);
+
setDocumentProvider(new TextDocumentProvider(casDocumentProvider));
super.init(site, input);
}
-
+
@Override
public CasDocumentProvider getCasDocumentProvider() {
return casDocumentProvider;
}
-
+
/**
* Retrieves the tooltip of the title.
*
@@ -683,7 +688,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
return super.getTitleToolTip();
}
ICasDocument document = getDocument();
- if(document == null) {
+ if (document == null) {
return super.getTitleToolTip();
}
String typeSystemText = document.getTypeSystemText();
@@ -694,23 +699,23 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
return toolTipText;
}
}
-
+
/**
* Retrieves annotation editor adapters.
*
- * @param adapter the adapter
+ * @param adapter
+ * the adapter
* @return an adapter or null
*/
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
if (IContentOutlinePage.class.equals(adapter) && getDocument() != null) {
return mOutlinePage;
- }
- else if (CAS.class.equals(adapter) && getDocument() != null) {
+ } else if (CAS.class.equals(adapter) && getDocument() != null) {
return getDocument().getCAS();
- }
- else {
+ } else {
return super.getAdapter(adapter);
}
@@ -726,29 +731,31 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
mPainter = new AnnotationPainter(sourceViewer, new AnnotationAccess());
sourceViewer.addPainter(mPainter);
-
+
return sourceViewer;
}
/**
* Sets the text size.
*
- * @param newSize the new text size
+ * @param newSize
+ * the new text size
*/
private void setTextSize(int newSize) {
Font font = getSourceViewer().getTextWidget().getFont();
-
+
if (font.getFontData().length > 0) {
FontData fd = font.getFontData()[0];
- getSourceViewer().getTextWidget().setFont(new Font(font.getDevice(),
- fd.getName(), newSize, fd.getStyle()));
+ getSourceViewer().getTextWidget()
+ .setFont(new Font(font.getDevice(), fd.getName(), newSize, fd.getStyle()));
}
}
-
+
/**
* Configures the editor.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
@Override
public void createPartControl(Composite parent) {
@@ -766,9 +773,9 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// that
//
// Until this can be used we improvise by registering a couple of listeners which
- // compute a caret offset change based on events which could change it,
+ // compute a caret offset change based on events which could change it,
// that are key and mouse listeners.
-
+
getSourceViewer().getTextWidget().addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
@@ -806,32 +813,34 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
@Override
public void mouseUp(MouseEvent e) {
int newCaretOffset = getSourceViewer().getTextWidget().getCaretOffset();
-
+
if (newCaretOffset != mCursorPosition) {
mCursorPosition = newCaretOffset;
refreshSelection();
- }
+ }
}
});
-
// UIMA-2242:
// When a single character is selected with a double click the selection
// changes but the caret does not.
// A press on enter now fails to create an annotation.
-
+
// UIMA-2247:
// Changed again to ensure that also selection from the find dialog
// can be detected
- getSourceViewer().getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- mFeatureStructureSelectionProvider.setSelection(new AnnotationEditorSelection((ITextSelection) event.getSelection(),
- new StructuredSelection(ModelFeatureStructure.create(getDocument(), getSelectedAnnotations()))));
- }
- });
-
+ getSourceViewer().getSelectionProvider()
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ mFeatureStructureSelectionProvider.setSelection(
+ new AnnotationEditorSelection((ITextSelection) event.getSelection(),
+ new StructuredSelection(ModelFeatureStructure.create(getDocument(),
+ getSelectedAnnotations()))));
+ }
+ });
+
DragSource dragSource = new DragSource(getSourceViewer().getTextWidget(), DND.DROP_COPY);
Transfer[] types = new Transfer[] { FeatureStructureTransfer.getInstance() };
@@ -844,38 +853,39 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
getSourceViewer().setEditable(false);
getSite().setSelectionProvider(mFeatureStructureSelectionProvider);
-
-
+
// Retrieve font size from preference store, default is 15
IPreferenceStore prefStore = CasEditorPlugin.getDefault().getPreferenceStore();
- int textSize = prefStore.getInt(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE);
-
+ int textSize = prefStore
+ .getInt(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE);
+
if (textSize > 0) {
setTextSize(textSize);
}
-
+
preferenceStoreChangeListener = (new IPropertyChangeListener() {
-
+
@Override
public void propertyChange(PropertyChangeEvent event) {
- if (AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE.equals(event.getProperty())) {
+ if (AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE
+ .equals(event.getProperty())) {
Integer textSize = (Integer) event.getNewValue();
-
+
if (textSize != null && textSize > 0) {
setTextSize(textSize);
}
}
}
});
-
+
prefStore.addPropertyChangeListener(preferenceStoreChangeListener);
-
+
// Note: In case the CAS could not be created the editor will be initialized with
- // a null document (getDocument() == null). Depending on the error it might be
+ // a null document (getDocument() == null). Depending on the error it might be
// possible to recover and the editor input will be set again. The createPartControl
// method might be called with a document or without one, both cases must be supported.
-
- // Perform the document dependent initialization
+
+ // Perform the document dependent initialization
initiallySynchronizeUI();
}
@@ -909,62 +919,62 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
protected void doSetInput(final IEditorInput input) throws CoreException {
final IEditorInput oldInput = getEditorInput();
final ICasDocument oldDocument = getDocument();
-
+
// Unregister the editor listeners on the old input
// TODO: Should we make methods to encapsulate the register/unregister code?
if (oldDocument != null) {
oldDocument.removeChangeListener(mAnnotationSynchronizer);
mAnnotationSynchronizer = null;
-
- getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput()).
- removePropertyChangeListener(mAnnotationStyleListener);
+
+ getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput())
+ .removePropertyChangeListener(mAnnotationStyleListener);
mAnnotationStyleListener = null;
}
super.doSetInput(input);
-
- if (CasEditorPlugin.getDefault().
- getAndClearShowMigrationDialogFlag()) {
+
+ if (CasEditorPlugin.getDefault().getAndClearShowMigrationDialogFlag()) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openInformation(getSite().getShell(),"Cas Editor Project Removed",
- "The Cas Editor Project support was removed from this release and" +
- " your existing Cas Editor Projects have been migrated. If you still want to use the " +
- "Cas Editor Project support please install the Cas Editor 2.3.1 again.\n\n" +
- "The Analysis Engine and Cas Consumer run support was also removed and " +
- "is replaced by the new Analysis Engine Launch plugin.");
- }
+ @Override
+ public void run() {
+ MessageDialog.openInformation(getSite().getShell(), "Cas Editor Project Removed",
+ "The Cas Editor Project support was removed from this release and"
+ + " your existing Cas Editor Projects have been migrated. If you still want to use the "
+ + "Cas Editor Project support please install the Cas Editor 2.3.1 again.\n\n"
+ + "The Analysis Engine and Cas Consumer run support was also removed and "
+ + "is replaced by the new Analysis Engine Launch plugin.");
+ }
});
}
-
+
if (getDocument() != null) {
-
+
AnnotationOutline outline = new AnnotationOutline(this);
mOutlinePage.setCASViewPage(outline);
shownAnnotationTypes.clear();
-
+
// Synchronize shown types with the editor
- String shownTypesString = getCasDocumentProvider().getSessionPreferenceStore(input).getString("LastShownTypes");
-
+ String shownTypesString = getCasDocumentProvider().getSessionPreferenceStore(input)
+ .getString("LastShownTypes");
+
String[] shownTypes = shownTypesString.split(";");
-
+
for (String shownType : shownTypes) {
-
+
Type type = getDocument().getType(shownType);
-
- // Types can be deleted from the type system but still be marked
+
+ // Types can be deleted from the type system but still be marked
// as shown in the .dotCorpus file, in that case the type
// name cannot be mapped to a type and should be ignored.
-
+
if (type != null)
shownAnnotationTypes.add(type);
}
-
+
if (getSourceViewer() != null) {
-
- // This branch is usually only executed when the
+
+ // This branch is usually only executed when the
// input was updated because it could not be opened the
// first time trough an error e.g. no type system available
//
@@ -980,32 +990,30 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// Send a partBroughtToTop event to the views to update their content
// on this currently active editor.
IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
-
+
for (IWorkbenchPart view : page.getViews()) {
if (view instanceof PageBookView) {
((PageBookView) view).partBroughtToTop(getEditorSite().getPart());
}
}
}
- }
- else {
+ } else {
// Makes the outline book show the not available message page
mOutlinePage.setCASViewPage(null);
}
-
+
final ICasDocument newDocument = getDocument();
-
+
if (mEditorInputListener != null) {
-
+
// Iterate over the existing listeners, listeners might be removed
// or added during notification, since views are created or destroyed
// when this event is fired.
-
+
for (Object listener : mEditorInputListener.getListeners()) {
-
- final ICasEditorInputListener inputListener =
- (ICasEditorInputListener) listener;
-
+
+ final ICasEditorInputListener inputListener = (ICasEditorInputListener) listener;
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -1023,7 +1031,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
protected boolean isErrorStatus(IStatus status) {
return super.isErrorStatus(status) || getDocument().getCAS().getDocumentText() == null;
}
-
+
/**
* Initialized the UI from the freshly set document.
*
@@ -1031,9 +1039,9 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
*/
private void initiallySynchronizeUI() {
if (getDocument() != null) {
-
- mShowAnnotationsMenu = new ShowAnnotationsMenu(
- getDocument().getCAS().getTypeSystem(), shownAnnotationTypes);
+
+ mShowAnnotationsMenu = new ShowAnnotationsMenu(getDocument().getCAS().getTypeSystem(),
+ shownAnnotationTypes);
mShowAnnotationsMenu.addListener(new IShowAnnotationsListener() {
@Override
@@ -1051,50 +1059,49 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
for (Type type : newShownTypes) {
showAnnotationType(type, true);
}
-
+
// Repaint after annotations are changed
mPainter.paint(IPainter.CONFIGURATION);
-
+
setEditorSessionPreferences();
-
+
if (mEditorListener != null) {
- for (IAnnotationEditorModifyListener listener : mEditorListener)
+ for (IAnnotationEditorModifyListener listener : mEditorListener)
listener.showAnnotationsChanged(selection);
}
}
});
-
- IPreferenceStore sessionPreferences =
- getCasDocumentProvider().getSessionPreferenceStore(getEditorInput());
-
+
+ IPreferenceStore sessionPreferences = getCasDocumentProvider()
+ .getSessionPreferenceStore(getEditorInput());
+
// TODO: Define constants for these settings!
-
- Type annotationModeType = getDocument().getType(
- sessionPreferences.getString("LastUsedModeType"));
-
+
+ Type annotationModeType = getDocument()
+ .getType(sessionPreferences.getString("LastUsedModeType"));
+
// Note: The type in the configuration might not exist anymore, or there is
// no type stored yet, in these cases the built-in uima.tcas.Annotation type is used.
// Not setting the annotation type will cause NPEs after the editor opened.
-
+
if (annotationModeType == null) {
- annotationModeType = getDocument().getType(CAS.TYPE_NAME_ANNOTATION);
+ annotationModeType = getDocument().getType(CAS.TYPE_NAME_ANNOTATION);
}
-
+
setAnnotationMode(annotationModeType);
-
+
String lastActiveViewName = sessionPreferences.getString("LastActiveCasViewName");
-
+
try {
// TODO: Missing compatibility check!!!
getDocument().getCAS().getView(lastActiveViewName);
showView(lastActiveViewName);
- }
- catch (CASRuntimeException e) {
+ } catch (CASRuntimeException e) {
// ignore, view is not available
// Note: Using exceptions for control flow is very bad practice
// TODO: Is there a way to check which views are available?!
- // Maybe we should iterate over all available views, and then
- // check if it is available!
+ // Maybe we should iterate over all available views, and then
+ // check if it is available!
showView(CAS.NAME_DEFAULT_SOFA);
}
}
@@ -1108,8 +1115,9 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new Separator());
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(SmartAnnotateAction.ID));
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(QuickAnnotateAction.ID));
- menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, getAction(IWorkbenchActionDefinitionIds.DELETE));
-
+ menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS,
+ getAction(IWorkbenchActionDefinitionIds.DELETE));
+
TypeSystem typeSystem = getDocument().getCAS().getTypeSystem();
// mode menu
@@ -1117,15 +1125,16 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, modeMenuManager);
ModeMenu modeMenu = new ModeMenu(typeSystem, this);
- modeMenu.addListener(new IModeMenuListener(){
+ modeMenu.addListener(new IModeMenuListener() {
- @Override
- public void modeChanged(Type newMode) {
- IAction actionToExecute = new ChangeModeAction(newMode, newMode.getShortName(),
- AnnotationEditor.this);
+ @Override
+ public void modeChanged(Type newMode) {
+ IAction actionToExecute = new ChangeModeAction(newMode, newMode.getShortName(),
+ AnnotationEditor.this);
- actionToExecute.run();
- }});
+ actionToExecute.run();
+ }
+ });
modeMenuManager.add(modeMenu);
@@ -1133,7 +1142,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
MenuManager showAnnotationMenu = new MenuManager("Show Annotations");
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, showAnnotationMenu);
showAnnotationMenu.add(mShowAnnotationsMenu);
-
+
// view menu
MenuManager casViewMenuManager = new MenuManager("CAS Views");
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, casViewMenuManager);
@@ -1168,7 +1177,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
public void reopenEditorWithNewTypeSystem() {
setInput(getEditorInput());
}
-
+
/**
* Returns the current annotation type.
*
@@ -1181,7 +1190,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Sets the new annotation type.
*
- * @param type the new annotation mode
+ * @param type
+ * the new annotation mode
*/
public void setAnnotationMode(Type type) {
// TODO: check if this type is a subtype of Annotation
@@ -1213,12 +1223,14 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
public Collection<Type> getShownAnnotationTypes() {
return Collections.unmodifiableCollection(shownAnnotationTypes);
}
-
+
/**
* Sets the shown annotation type.
*
- * @param type the type
- * @param isShown the is shown
+ * @param type
+ * the type
+ * @param isShown
+ * the is shown
*/
public void setShownAnnotationType(Type type, boolean isShown) {
mShowAnnotationsMenu.setSelectedType(type, isShown);
@@ -1227,7 +1239,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Sets the shown annotation types.
*
- * @param types the new shown annotation types
+ * @param types
+ * the new shown annotation types
*/
public void setShownAnnotationTypes(Collection<Type> types) {
mShowAnnotationsMenu.setSelectedTypes(types);
@@ -1236,7 +1249,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Fire annotation type changed.
*
- * @param type the type
+ * @param type
+ * the type
*/
private void fireAnnotationTypeChanged(Type type) {
if (mEditorListener != null) {
@@ -1248,84 +1262,87 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Retrieves an <code>AnnotationStyle</code> from the underlying storage.
*
- * @param type the type
+ * @param type
+ * the type
* @return the annotation style
*/
public AnnotationStyle getAnnotationStyle(Type type) {
if (type == null)
throw new IllegalArgumentException("type parameter must not be null!");
-
- IPreferenceStore prefStore = getCasDocumentProvider().
- getTypeSystemPreferenceStore(getEditorInput());
-
+
+ IPreferenceStore prefStore = getCasDocumentProvider()
+ .getTypeSystemPreferenceStore(getEditorInput());
+
return AnnotationStyle.getAnnotationStyleFromStore(prefStore, type.getName());
}
-
+
/**
* Sets an annotation style.
*
* Note: Internal usage only!
*
- * @param style the new annotation style
+ * @param style
+ * the new annotation style
*/
// TODO: Disk must be accessed for every changed annotation style
// add a second method which can take all changed styles
public void setAnnotationStyle(AnnotationStyle style) {
- IPreferenceStore prefStore = getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput());
+ IPreferenceStore prefStore = getCasDocumentProvider()
+ .getTypeSystemPreferenceStore(getEditorInput());
AnnotationStyle.putAnnotatationStyleToStore(prefStore, style);
-
+
getCasDocumentProvider().saveTypeSystemPreferenceStore(getEditorInput());
}
-
+
/**
* Set the shown annotation status of a type.
*
- * @param type the type
- * @param isVisible if true the type is shown, if false the type
- * it not shown
+ * @param type
+ * the type
+ * @param isVisible
+ * if true the type is shown, if false the type it not shown
*/
private void showAnnotationType(Type type, boolean isVisible) {
AnnotationStyle style = getAnnotationStyle(type);
-
+
if (isVisible) {
-
+
IDrawingStrategy strategy = DrawingStyle.createStrategy(style);
-
+
// It might not be possible to create the drawing strategy trough
// configuration errors, in this case the drawing strategy will be ignored
if (strategy != null) {
-
+
if (style.getStyle().equals(AnnotationStyle.Style.TAG)) {
getSourceViewer().getTextWidget().setLineSpacing(13);
}
-
+
mPainter.addDrawingStrategy(type.getName(), strategy);
mPainter.addAnnotationType(type.getName(), type.getName());
java.awt.Color color = style.getColor();
- mPainter.setAnnotationTypeColor(type.getName(), new Color(null, color.getRed(),
- color.getGreen(), color.getBlue()));
+ mPainter.setAnnotationTypeColor(type.getName(),
+ new Color(null, color.getRed(), color.getGreen(), color.getBlue()));
}
-
+
shownAnnotationTypes.add(type);
- }
- else {
+ } else {
mPainter.removeAnnotationType(type.getName());
shownAnnotationTypes.remove(type);
-
+
if (style.getStyle().equals(AnnotationStyle.Style.TAG)) {
// TODO: only if no more TAG styles are active
// How to figure that out ?!
boolean isKeepLineSpacing = false;
-
- for(Type shownType : shownAnnotationTypes) {
+
+ for (Type shownType : shownAnnotationTypes) {
AnnotationStyle potentialTagStyle = getAnnotationStyle(shownType);
-
+
if (AnnotationStyle.Style.TAG.equals(potentialTagStyle.getStyle())) {
isKeepLineSpacing = true;
break;
}
}
-
+
if (!isKeepLineSpacing)
getSourceViewer().getTextWidget().setLineSpacing(0);
}
@@ -1339,7 +1356,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
mPainter.removeAllAnnotationTypes();
getSourceViewer().getTextWidget().setLineSpacing(0);
-
+
for (Type displayType : mShowAnnotationsMenu.getSelectedTypes()) {
showAnnotationType(displayType, true);
}
@@ -1359,48 +1376,50 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
((IAnnotationModelExtension) annotationModel).removeAllAnnotations();
}
-
+
/**
* Sync annotations.
*/
private void syncAnnotations() {
-
+
removeAllAnnotations();
-
+
// Remove all annotation from the model
IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
((IAnnotationModelExtension) annotationModel).removeAllAnnotations();
-
+
// Add all annotation to the model
// copy annotations into annotation model
final Iterator<AnnotationFS> mAnnotations = getDocument().getCAS().getAnnotationIndex()
.iterator();
-
+
// TODO: Build first a map, and then pass all annotations at once
Map annotationsToAdd = new HashMap();
-
+
while (mAnnotations.hasNext()) {
AnnotationFS annotationFS = mAnnotations.next();
annotationsToAdd.put(new EclipseAnnotationPeer(annotationFS), new Position(
annotationFS.getBegin(), annotationFS.getEnd() - annotationFS.getBegin()));
}
-
+
((IAnnotationModelExtension) annotationModel).replaceAnnotations(null, annotationsToAdd);
}
-
+
/**
* Adds the annotation listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void addAnnotationListener(IAnnotationEditorModifyListener listener) {
mEditorListener.add(listener);
}
-
+
/**
* Removes the annotation listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void removeAnnotationListener(IAnnotationEditorModifyListener listener) {
mEditorListener.remove(listener);
@@ -1410,12 +1429,12 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
public void addCasEditorInputListener(ICasEditorInputListener listener) {
mEditorInputListener.add(listener);
}
-
+
@Override
public void removeCasEditorInputListener(ICasEditorInputListener listener) {
mEditorInputListener.remove(listener);
}
-
+
/**
* Returns the selection.
*
@@ -1428,8 +1447,10 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Highlights the given range in the editor.
*
- * @param start the start
- * @param length the length
+ * @param start
+ * the start
+ * @param length
+ * the length
*/
private void highlight(int start, int length) {
ISourceViewer sourceViewer = getSourceViewer();
@@ -1448,8 +1469,8 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
}
if (length != 0) {
- mCurrentStyleRange = new StyleRange(start, length, text.getSelectionForeground(), text
- .getSelectionBackground());
+ mCurrentStyleRange = new StyleRange(start, length, text.getSelectionForeground(),
+ text.getSelectionBackground());
text.setStyleRange(mCurrentStyleRange);
}
@@ -1492,7 +1513,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
return selection;
}
-
+
/**
* Returns the caret position relative to the start of the text.
*
@@ -1501,64 +1522,65 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
public int getCaretOffset() {
return getSourceViewer().getTextWidget().getCaretOffset();
}
-
+
/**
* Show view.
*
- * @param viewName the view name
+ * @param viewName
+ * the view name
*/
public void showView(String viewName) {
-
+
// TODO: Check if set view is compatible .. if not display some message!
-
+
// TODO: Consider to clear selection if this is called in the
// selectionChanged method, is that the right place?!
-
+
// Clear all old selections, references FSes of current view
mFeatureStructureSelectionProvider.clearSelection();
-
+
// Move the caret before the first char, otherwise it
// might be placed on an index which is out of bounds in
// the changed text
if (getSourceViewer().getTextWidget().getText().length() > 0)
getSourceViewer().getTextWidget().setCaretOffset(0);
-
+
// De-highlight the text in the editor, because the highlight
- // method has to remember the highlighted text area
+ // method has to remember the highlighted text area
// After the text changed the offsets might be out of bound
highlight(0, 0);
-
+
// Remove all editor annotations
// Changing the text with annotations might fail, because the
// bounds might be invalid in the new text
removeAllAnnotations();
-
+
// Change the view in the input document
// TODO: Add support for this to the interface
getDocument().switchView(viewName);
-
+
// Retrieve the new (changed) text document and refresh the source viewer
getSourceViewer().setDocument((AnnotationDocument) getDocument(),
- getDocumentProvider().getAnnotationModel(getEditorInput()));
+ getDocumentProvider().getAnnotationModel(getEditorInput()));
getSourceViewer().invalidateTextPresentation();
-
+
// All annotations will be synchronized in the document listener
-
+
// Last opened view should be remembered, in case a new editor is opened
setEditorSessionPreferences();
-
+
// Check if CAS view is compatible, only if compatible the listeners
// to update the annotations in the editor can be registered
// and the annotations can be synchronized
if (!isErrorStatus(getCasDocumentProvider().getStatus(getEditorInput()))) {
-
+
// Synchronize all annotation from the document with
// the editor
syncAnnotations();
-
+
// Note: If a change from a compatible view to a compatible view
- // occurs there is no need be register the listeners again
-
+ // occurs there is no need be register the listeners again
+
// Register listener to synchronize annotations between the
// editor and the document in case the annotations
// change e.g. updated in a view
@@ -1566,46 +1588,45 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
mAnnotationSynchronizer = new DocumentListener();
getDocument().addChangeListener(mAnnotationSynchronizer);
}
-
+
// Register listener to synchronize annotation styles
// between multiple open annotation editors
if (mAnnotationStyleListener == null) {
mAnnotationStyleListener = new AnnotationStyleChangeListener() {
-
+
@Override
public void annotationStylesChanged(Collection<AnnotationStyle> styles) {
// TODO: Only sync changed types
syncAnnotationTypes();
}
};
-
- getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput()).
- addPropertyChangeListener(mAnnotationStyleListener);
+
+ getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput())
+ .addPropertyChangeListener(mAnnotationStyleListener);
}
-
+
getSite().getPage().addSelectionListener(this);
- }
- else {
+ } else {
// if not null ... then unregister ... listener
if (mAnnotationSynchronizer != null) {
getDocument().removeChangeListener(mAnnotationSynchronizer);
mAnnotationSynchronizer = null;
}
-
+
if (mAnnotationStyleListener != null) {
- getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput()).
- removePropertyChangeListener(mAnnotationStyleListener);
+ getCasDocumentProvider().getTypeSystemPreferenceStore(getEditorInput())
+ .removePropertyChangeListener(mAnnotationStyleListener);
mAnnotationStyleListener = null;
}
-
+
getSite().getPage().removeSelectionListener(this);
}
-
+
// According to error status toggle between text editor or
// status page
updatePartControl(getEditorInput());
}
-
+
/**
* Text is not editable, cause of the nature of the annotation editor. This does not mean, that
* the annotations are not editable.
@@ -1620,53 +1641,54 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
/**
* Notifies the current instance about selection changes in the workbench.
*
- * @param part the part
- * @param selection the selection
+ * @param part
+ * the part
+ * @param selection
+ * the selection
*/
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof StructuredSelection) {
-
+
AnnotationSelection annotations = new AnnotationSelection((StructuredSelection) selection);
// only process these selection if the annotations belong
// to the current editor instance
if (getSite().getPage().getActiveEditor() == this) {
-
+
if (!annotations.isEmpty()) {
- highlight(annotations.getFirst().getBegin(), annotations.getLast().getEnd()
- - annotations.getFirst().getBegin());
-
+ highlight(annotations.getFirst().getBegin(),
+ annotations.getLast().getEnd() - annotations.getFirst().getBegin());
+
// move caret to new position when selected outside of the editor
if (AnnotationEditor.this != part) {
-
+
// Note: The caret cannot be placed between line delimiters
// See bug UIMA-1470
int newCaretOffset = annotations.getLast().getEnd();
String text = getSourceViewer().getTextWidget().getText();
-
+
if (newCaretOffset > 0 && newCaretOffset < text.length()) {
- char beforeCaret = text.charAt(newCaretOffset -1);
+ char beforeCaret = text.charAt(newCaretOffset - 1);
char afterCaret = text.charAt(newCaretOffset);
-
+
final int cr = 0x0D;
final int lf = 0x0A;
if (beforeCaret == cr && afterCaret == lf) {
// In case the caret offset is in the middle
// of a multiple-char line delimiter place caret
// before
- newCaretOffset = newCaretOffset -1;
+ newCaretOffset = newCaretOffset - 1;
}
}
-
+
// check bounds, if out of text do nothing
getSourceViewer().getTextWidget().setCaretOffset(newCaretOffset);
getSourceViewer().revealRange(newCaretOffset, 0);
-
+
mFeatureStructureSelectionProvider.setSelection(selection);
}
- }
- else {
+ } else {
// Nothing selected, clear annotation selection
highlight(0, 0);
}
@@ -1684,38 +1706,35 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
// getSourceViewer() returns null here ... but why ?
return getSourceViewer().getTextWidget().getSelectionCount() != 0;
}
-
+
/**
- * Set the session data which should be used to initalize the next Cas Editor which
- * is opened.
+ * Set the session data which should be used to initalize the next Cas Editor which is opened.
*/
private void setEditorSessionPreferences() {
-
- // TODO: Define constants with prefix for these settings ... so they don't conflict with other plugins!
-
- IPreferenceStore sessionStore = getCasDocumentProvider().
- getSessionPreferenceStore(getEditorInput());
-
+
+ // TODO: Define constants with prefix for these settings ... so they don't conflict with other
+ // plugins!
+
+ IPreferenceStore sessionStore = getCasDocumentProvider()
+ .getSessionPreferenceStore(getEditorInput());
+
sessionStore.setValue("LastActiveCasViewName", getDocument().getCAS().getViewName());
sessionStore.setValue("LastUsedModeType", getAnnotationMode().getName());
-
+
StringBuilder shownTypesString = new StringBuilder();
-
+
for (Type shownType : getShownAnnotationTypes()) {
shownTypesString.append(shownType.getName());
shownTypesString.append(";");
}
-
+
sessionStore.setValue("LastShownTypes", shownTypesString.toString());
}
/**
* Creates custom annotation actions:
*
- * Annotate Action
- * Smart Annotate Action
- * Delete Annotations Action
- * Find Annotate Action.
+ * Annotate Action Smart Annotate Action Delete Annotations Action Find Annotate Action.
*/
@Override
protected void createActions() {
@@ -1726,12 +1745,13 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
getSite().setSelectionProvider(mFeatureStructureSelectionProvider);
// create annotate action
- QuickAnnotateAction quickAnnotateAction = new QuickAnnotateAction(getSourceViewer().getTextWidget());
+ QuickAnnotateAction quickAnnotateAction = new QuickAnnotateAction(
+ getSourceViewer().getTextWidget());
quickAnnotateAction.setActionDefinitionId(QuickAnnotateAction.ID);
quickAnnotateAction.setText("Quick Annotate");
setAction(QuickAnnotateAction.ID, quickAnnotateAction);
getSite().getSelectionProvider().addSelectionChangedListener(quickAnnotateAction);
-
+
SmartAnnotateAction smartAnnotateAction = new SmartAnnotateAction();
smartAnnotateAction.setActionDefinitionId(SmartAnnotateAction.ID);
smartAnnotateAction.setText("Annotate");
@@ -1739,8 +1759,7 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
getSite().getSelectionProvider().addSelectionChangedListener(smartAnnotateAction);
// create delete action
- DeleteFeatureStructureAction deleteAnnotationAction = new DeleteFeatureStructureAction(
- this);
+ DeleteFeatureStructureAction deleteAnnotationAction = new DeleteFeatureStructureAction(this);
deleteAnnotationAction.setText("Delete Annotation");
getSite().getSelectionProvider().addSelectionChangedListener(deleteAnnotationAction);
@@ -1750,37 +1769,40 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
setActionActivationCode(IWorkbenchActionDefinitionIds.DELETE, (char) 0, SWT.CR, SWT.NONE);
// create show annotation context editing action
- ShowAnnotationContextEditAction annotationContextEditAction =
- new ShowAnnotationContextEditAction();
+ ShowAnnotationContextEditAction annotationContextEditAction = new ShowAnnotationContextEditAction();
annotationContextEditAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
setAction(ITextEditorActionDefinitionIds.QUICK_ASSIST, annotationContextEditAction);
// Create find annotate action
- FindAnnotateAction findAnnotateAction = new FindAnnotateAction(this, getSourceViewer().getFindReplaceTarget());
+ FindAnnotateAction findAnnotateAction = new FindAnnotateAction(this,
+ getSourceViewer().getFindReplaceTarget());
findAnnotateAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_REPLACE);
setAction(ITextEditorActionConstants.FIND, findAnnotateAction);
-
+
// Lower left side of annotation action
- LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction(this);
+ LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction(
+ this);
lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
setAction(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction);
getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
-
+
// Wide left side of annotation action
WideLeftAnnotationSideAction wideLeftAnnotationSide = new WideLeftAnnotationSideAction(this);
wideLeftAnnotationSide.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
setAction(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSide);
getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSide);
-
+
// Lower right side of annotation
- LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new LowerRightAnnotationSideAction(this);
+ LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new LowerRightAnnotationSideAction(
+ this);
lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
setAction(LowerRightAnnotationSideAction.ID, lowerRightAnnotationSideAction);
getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction);
-
+
// Wide right side of annotation
- WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction(this);
+ WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction(
+ this);
wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
setAction(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction);
getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);
@@ -1800,23 +1822,25 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
}
CasDocumentProvider provider = getCasDocumentProvider();
-
+
if (provider != null) {
IPreferenceStore store = provider.getTypeSystemPreferenceStore(getEditorInput());
if (store != null)
store.removePropertyChangeListener(mAnnotationStyleListener);
}
-
+
if (preferenceStoreChangeListener != null)
- CasEditorPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(preferenceStoreChangeListener);
-
+ CasEditorPlugin.getDefault().getPreferenceStore()
+ .removePropertyChangeListener(preferenceStoreChangeListener);
+
super.dispose();
}
/**
* Sets the annotation selection.
*
- * @param annotation the new annotation selection
+ * @param annotation
+ * the new annotation selection
*/
void setAnnotationSelection(AnnotationFS annotation) {
mFeatureStructureSelectionProvider.setSelection(getDocument(), annotation);
@@ -1850,85 +1874,85 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
return dirtyParts.toArray(new AnnotationEditor[dirtyParts.size()]);
}
-
+
@Override
protected Control createStatusControl(Composite parent, IStatus status) {
// Type System is missing in non Cas Editor Project case
if (status.getCode() == CasDocumentProvider.TYPE_SYSTEM_NOT_AVAILABLE_STATUS_CODE
- && getEditorInput() !=null) {
+ && getEditorInput() != null) {
// TODO: Is the null check on the editor input necessary ?!
-
+
// Show a form to select a type system in the document provider,
// afterwards the form calls reopenEditorWithNewTypesystem to reopen
// the editor on the input
return getCasDocumentProvider().createTypeSystemSelectorForm(this, parent, status);
- }
- else if (status.getCode() == IStatus.OK) {
-
+ } else if (status.getCode() == IStatus.OK) {
+
// TODO: Figure out which page should be shown
// TODO: Implement pages ...
// TODO: Each page needs an ability to switch the view back to something else ...
-
+
if (getDocument() != null && getDocument().getCAS().getDocumentText() == null) {
-
+
// TODO: Also display the current view name ...
-
+
Composite noTextComposite = new Composite(parent, SWT.NONE);
noTextComposite.setLayout(new GridLayout(1, false));
Label noTextLabel = new Label(noTextComposite, SWT.NONE);
noTextLabel.setText("Text sofa is not set!");
-
-
+
Label switchToView = new Label(noTextComposite, SWT.NONE);
switchToView.setText("Choose a view to switch to:");
-
+
final Combo viewSelectionCombo = new Combo(noTextComposite, SWT.READ_ONLY);
-
+
List<String> viewNames = new ArrayList<>();
- for (Iterator<CAS> it = getDocument().getCAS().getViewIterator(); it.hasNext(); ) {
+ for (Iterator<CAS> it = getDocument().getCAS().getViewIterator(); it.hasNext();) {
viewNames.add(it.next().getViewName());
}
-
+
viewSelectionCombo.setItems(viewNames.toArray(new String[viewNames.size()]));
-
+
// Preselect default view, will always be there
viewSelectionCombo.select(0);
-
+
Button switchView = new Button(noTextComposite, SWT.PUSH);
switchView.setText("Switch");
-
+
// TODO: Add a combo to select view ...
-
+
switchView.addSelectionListener(new SelectionListener() {
-
+
@Override
public void widgetSelected(SelectionEvent e) {
// TODO; Switch to selected view in combo ...
showView(viewSelectionCombo.getText());
}
-
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
+
return noTextComposite;
}
-
+
return super.createStatusControl(parent, status);
- }
- else {
+ } else {
return super.createStatusControl(parent, status);
}
}
-
+
/**
* Retrieves the annotations in the given span.
*
- * @param cas the cas
- * @param type the type
- * @param span the span
+ * @param cas
+ * the cas
+ * @param type
+ * the type
+ * @param span
+ * the span
* @return the annotation
*/
static Collection<AnnotationFS> getAnnotation(CAS cas, Type type, Span span) {
@@ -1954,22 +1978,22 @@ public final class AnnotationEditor extends StatusTextEditor implements ICasEdit
FSMatchConstraint annotationInSpanConstraint = cf.and(embeddedBegin, embeddedEnd);
- FSMatchConstraint annotationInSpanAndStrictTypeConstraint =
- cf.and(annotationInSpanConstraint, strictType);
+ FSMatchConstraint annotationInSpanAndStrictTypeConstraint = cf.and(annotationInSpanConstraint,
+ strictType);
FSIndex<AnnotationFS> allAnnotations = cas.getAnnotationIndex(type);
- FSIterator<AnnotationFS> annotationInsideSpanIndex =
- cas.createFilteredIterator(allAnnotations.iterator(),
- annotationInSpanAndStrictTypeConstraint);
+ FSIterator<AnnotationFS> annotationInsideSpanIndex = cas.createFilteredIterator(
+ allAnnotations.iterator(), annotationInSpanAndStrictTypeConstraint);
return DocumentUimaImpl.fsIteratorToCollection(annotationInsideSpanIndex);
}
-
+
/**
* Retrieves the view map.
*
- * @param annotationType the annotation type
+ * @param annotationType
+ * the annotation type
* @return the view
*/
private Map<Integer, AnnotationFS> getView(Type annotationType) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java
index de6ecdb..a40f66b 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorActionContributor.java
@@ -25,7 +25,6 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.texteditor.StatusLineContributionItem;
-
/**
* The <code>AnnotationEditor</code> action contributor.
*
@@ -46,7 +45,8 @@ public class AnnotationEditorActionContributor extends EditorActionBarContributo
/**
* Sets the active editor.
*
- * @param part the new active editor
+ * @param part
+ * the new active editor
*/
@Override
public void setActiveEditor(IEditorPart part) {
@@ -68,7 +68,8 @@ public class AnnotationEditorActionContributor extends EditorActionBarContributo
/**
* Contributes the status item to the status line.
*
- * @param statusLineManager the status line manager
+ * @param statusLineManager
+ * the status line manager
*/
@Override
public void contributeToStatusLine(IStatusLineManager statusLineManager) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
index 89005a1..6d98dee 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceConstants.java
@@ -21,22 +21,18 @@ package org.apache.uima.caseditor.editor;
import org.apache.uima.caseditor.CasEditorPlugin;
-
/**
* The Class AnnotationEditorPreferenceConstants.
*/
public class AnnotationEditorPreferenceConstants {
/** The Constant ANNOTATION_EDITOR_TEXT_SIZE. */
- public static final String ANNOTATION_EDITOR_TEXT_SIZE =
- CasEditorPlugin.ID + ".editor-text-size";
-
+ public static final String ANNOTATION_EDITOR_TEXT_SIZE = CasEditorPlugin.ID + ".editor-text-size";
+
/** The Constant EDITOR_LINE_LENGTH_HINT. */
- public static final String EDITOR_LINE_LENGTH_HINT =
- "EDITOR_LINE_LENGTH_HINT";
+ public static final String EDITOR_LINE_LENGTH_HINT = "EDITOR_LINE_LENGTH_HINT";
/** The Constant ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM. */
public static final String ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM = "ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM";
-
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
index 6090e17..e3fce5c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferenceInitializer.java
@@ -33,6 +33,7 @@ public class AnnotationEditorPreferenceInitializer extends AbstractPreferenceIni
IPreferenceStore store = CasEditorPlugin.getDefault().getPreferenceStore();
store.setDefault(AnnotationEditorPreferenceConstants.EDITOR_LINE_LENGTH_HINT, 80);
store.setDefault(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE, 13);
- store.setDefault(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM, false);
+ store.setDefault(AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM,
+ false);
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
index dc59824..201f301 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorPreferencePage.java
@@ -26,7 +26,6 @@ import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
/**
* Preference page to manage preferences for the Annotation Editor.
*/
@@ -35,7 +34,7 @@ public class AnnotationEditorPreferencePage extends FieldEditorPreferencePage
/** The m editor line length hint. */
private IntegerFieldEditor mEditorLineLengthHint;
-
+
/** The m editor text size. */
private IntegerFieldEditor mEditorTextSize;
@@ -51,22 +50,22 @@ public class AnnotationEditorPreferencePage extends FieldEditorPreferencePage
protected void createFieldEditors() {
// editor line length hint
mEditorLineLengthHint = new IntegerFieldEditor(
- AnnotationEditorPreferenceConstants.EDITOR_LINE_LENGTH_HINT,
- "Line Length Hint", getFieldEditorParent());
+ AnnotationEditorPreferenceConstants.EDITOR_LINE_LENGTH_HINT, "Line Length Hint",
+ getFieldEditorParent());
addField(mEditorLineLengthHint);
-
+
// editor text size
mEditorTextSize = new IntegerFieldEditor(
- AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE,
- "Editor Text Size", getFieldEditorParent());
+ AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_TEXT_SIZE, "Editor Text Size",
+ getFieldEditorParent());
addField(mEditorTextSize);
-
+
// load CAS with partial type system
BooleanFieldEditor editorPartialTypesystem = new BooleanFieldEditor(
- AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM,
- "Load CAS leniently (WARNING: only for experienced users)", getFieldEditorParent());
+ AnnotationEditorPreferenceConstants.ANNOTATION_EDITOR_PARTIAL_TYPESYSTEM,
+ "Load CAS leniently (WARNING: only for experienced users)", getFieldEditorParent());
addField(editorPartialTypesystem);
-
+
}
@Override
@@ -76,21 +75,19 @@ public class AnnotationEditorPreferencePage extends FieldEditorPreferencePage
@Override
protected void checkState() {
super.checkState();
-
+
if (mEditorLineLengthHint.getIntValue() > 0) {
setErrorMessage(null);
setValid(true);
- }
- else {
+ } else {
setErrorMessage("Line length hint must be a larger than zero!");
setValid(false);
}
-
+
if (mEditorTextSize.getIntValue() > 5) {
setErrorMessage(null);
setValid(true);
- }
- else {
+ } else {
setErrorMessage("Editor text size must be a larger than five!");
setValid(false);
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorSelection.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorSelection.java
index 4c4f947..20bbf87 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorSelection.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorSelection.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
-
/**
* The Class AnnotationEditorSelection.
*/
@@ -33,17 +32,20 @@ class AnnotationEditorSelection implements ITextSelection, IStructuredSelection
/** The text selection. */
private ITextSelection textSelection;
-
+
/** The structured selection. */
private IStructuredSelection structuredSelection;
-
+
/**
* Instantiates a new annotation editor selection.
*
- * @param textSelection the text selection
- * @param structuredSelection the structured selection
+ * @param textSelection
+ * the text selection
+ * @param structuredSelection
+ * the structured selection
*/
- AnnotationEditorSelection(ITextSelection textSelection, IStructuredSelection structuredSelection) {
+ AnnotationEditorSelection(ITextSelection textSelection,
+ IStructuredSelection structuredSelection) {
this.textSelection = textSelection;
this.structuredSelection = structuredSelection;
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
index bc3bd7a..669af64 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
@@ -27,10 +27,8 @@ import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
-
/**
- * Base view for views which show information about the {@link CAS} opened
- * in the editor.
+ * Base view for views which show information about the {@link CAS} opened in the editor.
*/
public abstract class AnnotationEditorView extends PageBookView {
@@ -40,7 +38,8 @@ public abstract class AnnotationEditorView extends PageBookView {
/**
* Instantiates a new annotation editor view.
*
- * @param editorNotAvailableMessage the editor not available message
+ * @param editorNotAvailableMessage
+ * the editor not available message
*/
public AnnotationEditorView(String editorNotAvailableMessage) {
this.editorNotAvailableMessage = editorNotAvailableMessage;
@@ -58,7 +57,8 @@ public abstract class AnnotationEditorView extends PageBookView {
/**
* Do create page.
*
- * @param editor the editor
+ * @param editor
+ * the editor
* @return the page rec
*/
protected abstract PageRec doCreatePage(ICasEditor editor);
@@ -96,7 +96,8 @@ public abstract class AnnotationEditorView extends PageBookView {
/**
* Look at {@link IPartListener#partBroughtToTop(IWorkbenchPart)}.
*
- * @param part the part
+ * @param part
+ * the part
*/
@Override
public void partBroughtToTop(IWorkbenchPart part) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java
index ca67902..2a8423e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java
@@ -29,19 +29,19 @@ import org.eclipse.jface.text.information.IInformationProvider;
import org.eclipse.jface.text.information.IInformationProviderExtension;
import org.eclipse.swt.graphics.Point;
-
/**
* TODO: move this class to external file.
*/
class AnnotationInformationProvider implements IInformationProvider, IInformationProviderExtension {
-
+
/** The m editor. */
private AnnotationEditor mEditor;
/**
* Instantiates a new annotation information provider.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
AnnotationInformationProvider(AnnotationEditor editor) {
mEditor = editor;
@@ -50,8 +50,10 @@ class AnnotationInformationProvider implements IInformationProvider, IInformatio
/**
* TODO: add comment.
*
- * @param textViewer the text viewer
- * @param offset the offset
+ * @param textViewer
+ * the text viewer
+ * @param offset
+ * the offset
* @return the region
*/
@Override
@@ -65,8 +67,10 @@ class AnnotationInformationProvider implements IInformationProvider, IInformatio
/**
* TODO: add comment.
*
- * @param textViewer the text viewer
- * @param subject the subject
+ * @param textViewer
+ * the text viewer
+ * @param subject
+ * the subject
* @return null
*/
@Override
@@ -77,8 +81,10 @@ class AnnotationInformationProvider implements IInformationProvider, IInformatio
/**
* TODO: add comment.
*
- * @param textViewer the text viewer
- * @param subject the subject
+ * @param textViewer
+ * the text viewer
+ * @param subject
+ * the subject
* @return the selected annotation
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java
index 07466b3..94cab95 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java
@@ -26,10 +26,9 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
-
/**
* TODO: add javadoc here.
-
+ *
*/
public abstract class AnnotationSelectionListener implements ISelectionListener {
@@ -40,7 +39,8 @@ public abstract class AnnotationSelectionListener implements ISelectionListener
/**
* Selected annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
protected abstract void selectedAnnotation(Collection<AnnotationFS> annotations);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyle.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyle.java
index cf55623..721017e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyle.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyle.java
@@ -27,8 +27,6 @@ import java.util.Objects;
import org.apache.uima.caseditor.core.model.DefaultColors;
import org.eclipse.jface.preference.IPreferenceStore;
-
-
/**
* The <code>AnnotationStyle</code> describes the look of an certain annotation type in the
* <code>AnnotationEditor</code>.
@@ -73,7 +71,7 @@ public final class AnnotationStyle {
* The bracket style.
*/
BRACKET,
-
+
/** The tag. */
TAG
}
@@ -105,22 +103,25 @@ public final class AnnotationStyle {
/** The configuration. */
private final String configuration;
-
+
/**
* Initialize a new instance.
*
- * @param annotation -
- * the annotation type
- * @param style -
- * the drawing style
- * @param color -
- * annotation color
+ * @param annotation
+ * - the annotation type
+ * @param style
+ * - the drawing style
+ * @param color
+ * - annotation color
*
- * @param layer - drawing layer
+ * @param layer
+ * - drawing layer
*
- * @param configuration the configuration string for the style or null if no configuration
+ * @param configuration
+ * the configuration string for the style or null if no configuration
*/
- public AnnotationStyle(String annotation, Style style, Color color, int layer, String configuration) {
+ public AnnotationStyle(String annotation, Style style, Color color, int layer,
+ String configuration) {
if (annotation == null || style == null || color == null) {
throw new IllegalArgumentException("parameters must be not null!");
@@ -141,15 +142,19 @@ public final class AnnotationStyle {
/**
* Instantiates a new annotation style.
*
- * @param annotation the annotation
- * @param style the style
- * @param color the color
- * @param layer the layer
+ * @param annotation
+ * the annotation
+ * @param style
+ * the style
+ * @param color
+ * the color
+ * @param layer
+ * the layer
*/
public AnnotationStyle(String annotation, Style style, Color color, int layer) {
this(annotation, style, color, layer, null);
}
-
+
/**
* Retrieves the annotation type.
*
@@ -194,11 +199,12 @@ public final class AnnotationStyle {
public String getConfiguration() {
return configuration;
}
-
+
/**
* Compares if current is equal to another object.
*
- * @param object the object
+ * @param object
+ * the object
* @return true, if successful
*/
@Override
@@ -209,7 +215,7 @@ public final class AnnotationStyle {
isEqual = true;
} else if (object instanceof AnnotationStyle) {
AnnotationStyle style = (AnnotationStyle) object;
-
+
boolean isConfigEqual = Objects.equals(configuration, style.configuration);
isEqual = annotation.equals(style.annotation) && this.style.equals(style.style)
@@ -245,144 +251,149 @@ public final class AnnotationStyle {
annotationStyle += " Config: " + getConfiguration();
return annotationStyle;
}
-
+
// TODO: Format must be redefined, so that only one key/string pair is needed to save it!
-
+
// key -> type name + ."style"
// value -> key/value pairs -> key=value; key=value;
// split on ";" and then split on = to parse values into a map
/**
* Serialize properties.
*
- * @param properties the properties
+ * @param properties
+ * the properties
* @return the string
*/
// maybe make a util which can save a String, String map to a line, and load it from String ...
private static String serializeProperties(Map<String, String> properties) {
-
+
StringBuilder configString = new StringBuilder();
-
+
for (Map.Entry<String, String> entry : properties.entrySet()) {
configString.append(entry.getKey().trim());
configString.append("=");
configString.append(entry.getValue().trim());
configString.append(";");
}
-
+
return configString.toString();
}
-
+
/**
* Parses the properties.
*
- * @param line the line
+ * @param line
+ * the line
* @return the map
*/
private static Map<String, String> parseProperties(String line) {
Map<String, String> properties = new HashMap<>();
-
+
String keyValueStrings[] = line.split(";");
-
+
for (String keyValueString : keyValueStrings) {
- String keyValuePair[] = keyValueString.split("=");
-
- if (keyValuePair.length == 2) {
- properties.put(keyValuePair[0], keyValuePair[1]);
- }
+ String keyValuePair[] = keyValueString.split("=");
+
+ if (keyValuePair.length == 2) {
+ properties.put(keyValuePair[0], keyValuePair[1]);
+ }
}
-
+
return properties;
}
-
+
/**
- * Note: This method must not be called by user code! It is only public because the migration
- * code in the Cas Editor Ide Plugin needs to access this method.
+ * Note: This method must not be called by user code! It is only public because the migration code
+ * in the Cas Editor Ide Plugin needs to access this method.
*
- * @param store the store
- * @param style the style
+ * @param store
+ * the store
+ * @param style
+ * the style
*/
public static void putAnnotatationStyleToStore(IPreferenceStore store, AnnotationStyle style) {
-
+
Color color = new Color(style.getColor().getRed(), style.getColor().getGreen(),
style.getColor().getBlue());
-
+
Map<String, String> styleProperties = new HashMap<>();
-
+
styleProperties.put("color", Integer.toString(color.getRGB()));
styleProperties.put("strategy", style.getStyle().toString());
styleProperties.put("layer", Integer.toString(style.getLayer()));
-
+
if (style.getConfiguration() != null) {
styleProperties.put("config", style.getConfiguration());
}
-
+
store.setValue(style.getAnnotation() + ".style", serializeProperties(styleProperties));
}
-
+
/**
* Retrieves an annotation style from the provided preference store.
* <p>
- * Note: This method must not be called by user code! It is only public because the migration
- * code in the Cas Editor Ide Plugin needs to access this method.
+ * Note: This method must not be called by user code! It is only public because the migration code
+ * in the Cas Editor Ide Plugin needs to access this method.
*
- * @param store the store
- * @param typeName the type name
+ * @param store
+ * the store
+ * @param typeName
+ * the type name
* @return an annotation style from the provided preference store
*/
- public static AnnotationStyle getAnnotationStyleFromStore(IPreferenceStore store, String typeName) {
-
+ public static AnnotationStyle getAnnotationStyleFromStore(IPreferenceStore store,
+ String typeName) {
+
Map<String, String> styleProperties = parseProperties(store.getString(typeName + ".style"));
-
- // initialize with random background style for the case if the store contains no style information
+
+ // initialize with random background style for the case if the store contains no style
+ // information
AnnotationStyle.Style style = AnnotationStyle.Style.BACKGROUND;
- int index = (int) Math.round(Math.random() * (DefaultColors.COLORS.length-1));
+ int index = (int) Math.round(Math.random() * (DefaultColors.COLORS.length - 1));
Color color = DefaultColors.COLORS[index];
-
+
String styleString = styleProperties.get("strategy");
if (styleString != null && styleString.length() != 0) {
// TODO: Might throw exception, catch it and use default!
try {
style = AnnotationStyle.Style.valueOf(styleString);
- }
- catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
}
}
-
-
+
String colorString = styleProperties.get("color");
if (colorString != null && colorString.length() != 0) {
try {
int colorInteger = Integer.parseInt(colorString);
color = new Color(colorInteger);
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
}
}
-
+
int layer = 0;
-
+
String layerString = styleProperties.get("layer");
-
+
if (layerString != null && layerString.length() != 0) {
try {
layer = Integer.parseInt(layerString);
- }
- catch (NumberFormatException e) {
+ } catch (NumberFormatException e) {
}
}
-
+
String configuration = styleProperties.get("config");
-
+
if (configuration != null && configuration.length() != 0)
configuration = null;
-
- AnnotationStyle annotationStyle = new AnnotationStyle(typeName, style, color, layer, configuration);
-
+
+ AnnotationStyle annotationStyle = new AnnotationStyle(typeName, style, color, layer,
+ configuration);
+
// store style if it is not known yet
- if(styleProperties == null || styleProperties.isEmpty()) {
+ if (styleProperties == null || styleProperties.isEmpty()) {
putAnnotatationStyleToStore(store, annotationStyle);
}
-
+
return annotationStyle;
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyleChangeListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyleChangeListener.java
index 1e34a38..b085c44 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyleChangeListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/AnnotationStyleChangeListener.java
@@ -25,23 +25,22 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-
/**
- * Annotation Style Change Listener base class which converts annotation style change events from
- * a Preference Store to AnnotationStyle object change events.
+ * Annotation Style Change Listener base class which converts annotation style change events from a
+ * Preference Store to AnnotationStyle object change events.
* <p>
* An implementing class needs to override the annotationStylesChanged method.
*/
public abstract class AnnotationStyleChangeListener
- implements IPropertyChangeListener, IAnnotationStyleListener {
+ implements IPropertyChangeListener, IAnnotationStyleListener {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().endsWith(".style")) {
// extract type name ...
String typeName = event.getProperty().substring(0, event.getProperty().lastIndexOf(".style"));
- AnnotationStyle style = AnnotationStyle.getAnnotationStyleFromStore(
- (IPreferenceStore) event.getSource(), typeName);
+ AnnotationStyle style = AnnotationStyle
+ .getAnnotationStyleFromStore((IPreferenceStore) event.getSource(), typeName);
annotationStylesChanged(Collections.singleton(style));
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java
index 7c13dd5..f612a3f 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java
@@ -32,7 +32,6 @@ import org.apache.uima.cas.StringArrayFS;
import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.core.runtime.IAdaptable;
-
/**
* The Class ArrayValue.
*/
@@ -47,8 +46,10 @@ public class ArrayValue implements IAdaptable {
/**
* Instantiates a new array value.
*
- * @param arrayFS the array FS
- * @param slot the slot
+ * @param arrayFS
+ * the array FS
+ * @param slot
+ * the slot
*/
public ArrayValue(FeatureStructure arrayFS, int slot) {
@@ -81,7 +82,8 @@ public class ArrayValue implements IAdaptable {
/**
* Sets the.
*
- * @param value the value
+ * @param value
+ * the value
*/
public void set(String value) {
@@ -161,7 +163,8 @@ public class ArrayValue implements IAdaptable {
}
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
if (FeatureStructure.class.equals(adapter)) {
if (arrayFS instanceof ArrayFS) {
@@ -184,6 +187,6 @@ public class ArrayValue implements IAdaptable {
@Override
public String toString() {
- return Integer.toString(slot()) ;
+ return Integer.toString(slot());
}
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
index 1f88e13..1f1488c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProvider.java
@@ -32,7 +32,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.IElementStateListener;
-
/**
* Provides the {@link org.apache.uima.caseditor.editor.ICasDocument} for the
* {@link AnnotationEditor}.
@@ -46,7 +45,7 @@ public abstract class CasDocumentProvider {
* The Class ElementInfo.
*/
protected static class ElementInfo {
-
+
/** The reference count. */
public int referenceCount;
@@ -56,7 +55,8 @@ public abstract class CasDocumentProvider {
/**
* Instantiates a new element info.
*
- * @param element the element
+ * @param element
+ * the element
*/
protected ElementInfo(Object element) {
this.element = element;
@@ -82,7 +82,8 @@ public abstract class CasDocumentProvider {
/**
* Creates the element info.
*
- * @param element the element
+ * @param element
+ * the element
* @return the element info
*/
protected ElementInfo createElementInfo(Object element) {
@@ -92,8 +93,10 @@ public abstract class CasDocumentProvider {
/**
* Dispose element info.
*
- * @param element the element
- * @param info the info
+ * @param element
+ * the element
+ * @param info
+ * the info
*/
protected void disposeElementInfo(Object element, ElementInfo info) {
}
@@ -102,20 +105,27 @@ public abstract class CasDocumentProvider {
* Creates the a new {@link AnnotationDocument} from the given {@link IEditorInput} element. For
* all other elements null is returned.
*
- * @param element the element
+ * @param element
+ * the element
* @return the i cas document
- * @throws CoreException the core exception
+ * @throws CoreException
+ * the core exception
*/
protected abstract ICasDocument createDocument(Object element) throws CoreException;
/**
* Do save document.
*
- * @param monitor the monitor
- * @param element the element
- * @param document the document
- * @param overwrite the overwrite
- * @throws CoreException the core exception
+ * @param monitor
+ * the monitor
+ * @param element
+ * the element
+ * @param document
+ * the document
+ * @param overwrite
+ * the overwrite
+ * @throws CoreException
+ * the core exception
*/
protected abstract void doSaveDocument(IProgressMonitor monitor, Object element,
ICasDocument document, boolean overwrite) throws CoreException;
@@ -123,7 +133,8 @@ public abstract class CasDocumentProvider {
/**
* Gets the status.
*
- * @param element the element
+ * @param element
+ * the element
* @return the status
*/
public IStatus getStatus(Object element) {
@@ -135,8 +146,10 @@ public abstract class CasDocumentProvider {
* relation to the type system, e.g. an ide plugin could save a preference file next to the type
* system file.
*
- * @param element the element
- * @return the preference store or null if it cannot be retrieved, e.g no document was created for the input.
+ * @param element
+ * the element
+ * @return the preference store or null if it cannot be retrieved, e.g no document was created for
+ * the input.
*/
// Problem: Keys maybe should be pre-fixed depending on the plugin which is storing values
// TODO: Should it be renamed to getPersistentPreferenceStore?
@@ -145,7 +158,8 @@ public abstract class CasDocumentProvider {
/**
* Save type system preference store.
*
- * @param element the element
+ * @param element
+ * the element
*/
// Might fail silently, only log an error
public abstract void saveTypeSystemPreferenceStore(Object element);
@@ -154,7 +168,8 @@ public abstract class CasDocumentProvider {
* Retrieves the session preference store. This preference store is used to store session data
* which should be used to initialize a freshly opened editor.
*
- * @param element the element
+ * @param element
+ * the element
* @return the session preference store
*/
public abstract IPreferenceStore getSessionPreferenceStore(Object element);
@@ -169,9 +184,12 @@ public abstract class CasDocumentProvider {
/**
* Creates the type system selector form.
*
- * @param editor the editor
- * @param parent the parent
- * @param status the status
+ * @param editor
+ * the editor
+ * @param parent
+ * the parent
+ * @param status
+ * the status
* @return the composite
*/
public abstract Composite createTypeSystemSelectorForm(ICasEditor editor, Composite parent,
@@ -180,7 +198,8 @@ public abstract class CasDocumentProvider {
/**
* Adds the element state listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void addElementStateListener(IElementStateListener listener) {
elementStateListeners.add(listener);
@@ -189,7 +208,8 @@ public abstract class CasDocumentProvider {
/**
* Removes the element state listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void removeElementStateListener(IElementStateListener listener) {
elementStateListeners.remove(listener);
@@ -198,7 +218,8 @@ public abstract class CasDocumentProvider {
/**
* Fire element deleted.
*
- * @param element the element
+ * @param element
+ * the element
*/
protected void fireElementDeleted(Object element) {
for (IElementStateListener listener : elementStateListeners) {
@@ -209,7 +230,8 @@ public abstract class CasDocumentProvider {
/**
* Fire element changed.
*
- * @param element the element
+ * @param element
+ * the element
*/
protected void fireElementChanged(Object element) {
for (IElementStateListener listener : elementStateListeners) {
@@ -220,8 +242,10 @@ public abstract class CasDocumentProvider {
/**
* Fire element dirty state changed.
*
- * @param element the element
- * @param isDirty the is dirty
+ * @param element
+ * the element
+ * @param isDirty
+ * the is dirty
*/
protected void fireElementDirtyStateChanged(Object element, boolean isDirty) {
for (IElementStateListener listener : elementStateListeners) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java
index eb53f6f..95b475e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasDocumentProviderFactory.java
@@ -30,7 +30,6 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.IEditorInput;
-
/**
* Factory class to produce and lookup an appropriate document provider.
*/
@@ -46,14 +45,14 @@ class CasDocumentProviderFactory {
/** The document providers. */
// map class_name to provider
private Map<String, CasDocumentProvider> documentProviders = new HashMap<>();
-
+
/**
* Instantiates a new cas document provider factory.
*/
CasDocumentProviderFactory() {
- IConfigurationElement[] config =
- Platform.getExtensionRegistry().getConfigurationElementsFor(CAS_EDITOR_EXTENSION);
+ IConfigurationElement[] config = Platform.getExtensionRegistry()
+ .getConfigurationElementsFor(CAS_EDITOR_EXTENSION);
for (IConfigurationElement element : config) {
@@ -62,7 +61,7 @@ class CasDocumentProviderFactory {
// extract id element
String id = element.getAttribute("id");
String inputType = element.getAttribute("inputType");
-
+
Object documentProviderObject;
try {
documentProviderObject = element.createExecutableExtension("class");
@@ -70,7 +69,7 @@ class CasDocumentProviderFactory {
CasEditorPlugin.log("Failed to load document provider with id: " + id, e);
documentProviderObject = null;
}
-
+
if (documentProviderObject instanceof CasDocumentProvider) {
documentProviders.put(inputType, (CasDocumentProvider) documentProviderObject);
}
@@ -80,48 +79,49 @@ class CasDocumentProviderFactory {
}
/**
- * Looks up a document provider for the provided editor input.
- * The editor input type must be cast-able to the specified inputType.
- * The implementation tries first to map class types, and then interface types.
+ * Looks up a document provider for the provided editor input. The editor input type must be
+ * cast-able to the specified inputType. The implementation tries first to map class types, and
+ * then interface types.
*
- * @param input the input
+ * @param input
+ * the input
* @return the document provider
*/
CasDocumentProvider getDocumentProvider(IEditorInput input) {
// A class can have many types, they are defined by super classes
// and implemented interfaces
-
+
// First try to match the input type to the editor input type
// or one of its super class
List<Class<?>> classList = new ArrayList<>();
-
+
for (Class<?> inputClass = input.getClass(); inputClass != null;) {
classList.add(inputClass);
inputClass = inputClass.getSuperclass();
}
-
+
CasDocumentProvider provider = null;
for (Class<?> inputClass : classList) {
provider = documentProviders.get(inputClass.getName());
-
+
if (provider != null)
return provider;
}
-
+
// Now try to match an implemented interface to the input type
// either of the editor input class or for one of its super classes
if (provider == null) {
for (Class<?> inputClass : classList) {
for (Class<?> inputClassInterface : inputClass.getInterfaces()) {
provider = documentProviders.get(inputClassInterface.getName());
-
+
if (provider != null)
return provider;
}
}
}
-
+
return provider;
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java
index a769aa6..e6dee5a 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorError.java
@@ -19,20 +19,19 @@
package org.apache.uima.caseditor.editor;
-
/**
* A general {@link RuntimeException} which is thrown if something unexpected happens.
*/
public class CasEditorError extends RuntimeException {
-
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Initializes the current instance.
*
- * @param message the message
+ * @param message
+ * the message
*/
public CasEditorError(String message) {
super(message);
@@ -41,8 +40,10 @@ public class CasEditorError extends RuntimeException {
/**
* Initializes the current instance.
*
- * @param message the message
- * @param cause the cause
+ * @param message
+ * the message
+ * @param cause
+ * the cause
*/
public CasEditorError(String message, Throwable cause) {
super(message, cause);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorView.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorView.java
index 6f9c77a..e662a8c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorView.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorView.java
@@ -34,13 +34,11 @@ import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
-
/**
- * Base class for views which show information about the {@link CAS} opened
- * in the editor.
+ * Base class for views which show information about the {@link CAS} opened in the editor.
* <p>
- * The view page created with {@link #doCreatePage(ICasEditor)} will be disposed
- * and re-created on every Cas Editor input change or CAS view change.
+ * The view page created with {@link #doCreatePage(ICasEditor)} will be disposed and re-created on
+ * every Cas Editor input change or CAS view change.
* <p>
* In the case the view should no be re-created on a CAS view change
* {@link #isRecreatePageOnCASViewSwitch()} must be overridden and return false.
@@ -52,17 +50,16 @@ public abstract class CasEditorView extends PageBookView {
private final String editorNotAvailableMessage;
/** The editor listener map. */
- private Map<ICasEditor, ICasEditorInputListener> editorListenerMap =
- new HashMap<>();
-
+ private Map<ICasEditor, ICasEditorInputListener> editorListenerMap = new HashMap<>();
+
/** The document listener map. */
- private Map<ICasEditor, ICasDocumentListener> documentListenerMap =
- new HashMap<>();
-
+ private Map<ICasEditor, ICasDocumentListener> documentListenerMap = new HashMap<>();
+
/**
* Instantiates a new cas editor view.
*
- * @param editorNotAvailableMessage the editor not available message
+ * @param editorNotAvailableMessage
+ * the editor not available message
*/
public CasEditorView(String editorNotAvailableMessage) {
this.editorNotAvailableMessage = editorNotAvailableMessage;
@@ -72,14 +69,12 @@ public abstract class CasEditorView extends PageBookView {
* Implementors should overwrite if they want that. Default is false.
* <p>
* Note:<br>
- * The implementation uses the ICasDocumentListener.viewChanged event
- * to recognize view changes. If the view implementation also listens for
- * this event the view might already be disposed when the listener is called.
- * It is therefore strongly recommended either to listen for the event and
+ * The implementation uses the ICasDocumentListener.viewChanged event to recognize view changes.
+ * If the view implementation also listens for this event the view might already be disposed when
+ * the listener is called. It is therefore strongly recommended either to listen for the event and
* update the view or don't list for the event and rely on a page re-creation.
*
- * @return true if page should be disposed/re-created on CAS view change,
- * or false if not.
+ * @return true if page should be disposed/re-created on CAS view change, or false if not.
*/
protected boolean isRecreatePageOnCASViewSwitch() {
return false;
@@ -98,7 +93,8 @@ public abstract class CasEditorView extends PageBookView {
/**
* Do create page.
*
- * @param editor the editor
+ * @param editor
+ * the editor
* @return the i page book view page
*/
// Will be recreated on view switch (need a flag to disable that) and input cas switch
@@ -107,11 +103,13 @@ public abstract class CasEditorView extends PageBookView {
/**
* Creates the view page.
*
- * @param casViewPageBookedPage the cas view page booked page
- * @param editor the editor
+ * @param casViewPageBookedPage
+ * the cas view page booked page
+ * @param editor
+ * the editor
*/
- private void createViewPage( CasEditorViewPage casViewPageBookedPage, ICasEditor editor) {
-
+ private void createViewPage(CasEditorViewPage casViewPageBookedPage, ICasEditor editor) {
+
IPageBookViewPage page = doCreatePage(editor);
if (page != null) {
try {
@@ -119,10 +117,9 @@ public abstract class CasEditorView extends PageBookView {
} catch (PartInitException e) {
CasEditorPlugin.log(e);
}
-
+
casViewPageBookedPage.setCASViewPage(page);
- }
- else {
+ } else {
casViewPageBookedPage.setCASViewPage(null);
}
}
@@ -131,12 +128,13 @@ public abstract class CasEditorView extends PageBookView {
protected final PageRec doCreatePage(final IWorkbenchPart part) {
PageRec result = null;
-
+
if (part instanceof ICasEditor) {
final ICasEditor editor = (ICasEditor) part;
-
- final CasEditorViewPage casViewPageBookedPage = new CasEditorViewPage(editorNotAvailableMessage);
-
+
+ final CasEditorViewPage casViewPageBookedPage = new CasEditorViewPage(
+ editorNotAvailableMessage);
+
if (editor.getDocument() != null) {
ICasDocumentListener documentListener = new AbstractDocumentListener() {
@Override
@@ -146,48 +144,47 @@ public abstract class CasEditorView extends PageBookView {
}
}
};
-
+
editor.getDocument().addChangeListener(documentListener);
-
+
// remember on map
documentListenerMap.put(editor, documentListener);
}
-
+
ICasEditorInputListener inputListener = new ICasEditorInputListener() {
-
+
@Override
public void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument,
IEditorInput newInput, ICasDocument newDocument) {
-
+
createViewPage(casViewPageBookedPage, editor);
-
+
ICasDocumentListener changeListener = documentListenerMap.get(editor);
-
+
if (changeListener != null) {
if (oldDocument != null)
oldDocument.removeChangeListener(changeListener);
-
+
if (newDocument != null)
newDocument.addChangeListener(changeListener);
}
-
+
}
};
editorListenerMap.put(editor, inputListener);
editor.addCasEditorInputListener(inputListener);
-
- // BUG: This does not work!
-
-
+
+ // BUG: This does not work!
+
initPage(casViewPageBookedPage);
-
+
casViewPageBookedPage.createControl(getPageBook());
-
+
createViewPage(casViewPageBookedPage, editor);
-
+
result = new PageRec(editor, casViewPageBookedPage);
}
-
+
return result;
}
@@ -198,23 +195,23 @@ public abstract class CasEditorView extends PageBookView {
@Override
protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
-
+
if (part instanceof ICasEditor) {
ICasEditor editor = (ICasEditor) part;
ICasEditorInputListener editorListener = editorListenerMap.remove(part);
-
+
if (editorListener != null) {
editor.removeCasEditorInputListener(editorListener);
}
-
+
ICasDocumentListener documentListener = documentListenerMap.remove(part);
ICasDocument document = editor.getDocument();
-
+
if (documentListener != null && document != null) {
document.removeChangeListener(documentListener);
}
}
-
+
pageRecord.page.dispose();
pageRecord.dispose();
}
@@ -228,7 +225,8 @@ public abstract class CasEditorView extends PageBookView {
/**
* Look at {@link IPartListener#partBroughtToTop(IWorkbenchPart)}.
*
- * @param part the part
+ * @param part
+ * the part
*/
@Override
public void partBroughtToTop(IWorkbenchPart part) {
@@ -237,24 +235,22 @@ public abstract class CasEditorView extends PageBookView {
@Override
public void dispose() {
-
- for (Map.Entry<ICasEditor, ICasEditorInputListener> entry :
- editorListenerMap.entrySet()) {
+
+ for (Map.Entry<ICasEditor, ICasEditorInputListener> entry : editorListenerMap.entrySet()) {
entry.getKey().removeCasEditorInputListener(entry.getValue());
}
-
+
editorListenerMap.clear();
-
- for (Map.Entry<ICasEditor, ICasDocumentListener> entry :
- documentListenerMap.entrySet()) {
-
+
+ for (Map.Entry<ICasEditor, ICasDocumentListener> entry : documentListenerMap.entrySet()) {
+
ICasDocument document = entry.getKey().getDocument();
if (document != null)
document.removeChangeListener(entry.getValue());
}
-
+
documentListenerMap.clear();
-
+
super.dispose();
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorViewPage.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorViewPage.java
index 87471cb..dc0917b 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorViewPage.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CasEditorViewPage.java
@@ -41,7 +41,6 @@ import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.part.PageBook;
-
/**
* The Class CasEditorViewPage.
*/
@@ -49,31 +48,32 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
/** The selection changed listeners. */
private ListenerList selectionChangedListeners = new ListenerList();
-
+
/** The not available message. */
private final String notAvailableMessage;
-
+
/** The book. */
protected PageBook book;
-
+
/** The cas view page. */
protected IPageBookViewPage casViewPage;
/** The sub action bar. */
private SubActionBars subActionBar;
-
+
/** The message text. */
private Text messageText;
-
+
/**
* Instantiates a new cas editor view page.
*
- * @param notAvailableMessage the not available message
+ * @param notAvailableMessage
+ * the not available message
*/
protected CasEditorViewPage(String notAvailableMessage) {
this.notAvailableMessage = notAvailableMessage;
}
-
+
/**
* Refresh action handlers.
*/
@@ -87,8 +87,7 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
if (newActionHandlers != null) {
Set<Map.Entry> keys = newActionHandlers.entrySet();
for (Map.Entry entry : keys) {
- actionBars.setGlobalActionHandler((String) entry.getKey(),
- (IAction) entry.getValue());
+ actionBars.setGlobalActionHandler((String) entry.getKey(), (IAction) entry.getValue());
}
}
}
@@ -104,19 +103,19 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
selectionChangedListeners.remove(listener);
}
-
+
/**
* Selection changed.
*
- * @param event the event
+ * @param event
+ * the event
*/
public void selectionChanged(final SelectionChangedEvent event) {
-
+
for (Object listener : selectionChangedListeners.getListeners()) {
-
- final ISelectionChangedListener selectionChangedListener =
- (ISelectionChangedListener) listener;
-
+
+ final ISelectionChangedListener selectionChangedListener = (ISelectionChangedListener) listener;
+
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
@@ -125,13 +124,12 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
});
}
}
-
+
@Override
public ISelection getSelection() {
if (casViewPage != null && casViewPage.getSite().getSelectionProvider() != null) {
return casViewPage.getSite().getSelectionProvider().getSelection();
- }
- else {
+ } else {
return StructuredSelection.EMPTY;
}
}
@@ -142,72 +140,72 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
casViewPage.getSite().getSelectionProvider().setSelection(selection);
}
}
-
+
@Override
public void createControl(Composite parent) {
book = new PageBook(parent, SWT.NONE);
-
+
messageText = new Text(book, SWT.WRAP | SWT.READ_ONLY);
messageText.setBackground(parent.getShell().getBackground());
messageText.setText(notAvailableMessage);
-
+
getSite().setSelectionProvider(this);
-
+
// Page might be set before the page is initialized
initializeAndShowPage(casViewPage);
}
-
+
/**
- * Creates and shows the page, if page is null
- * the not available message will be shown.
+ * Creates and shows the page, if page is null the not available message will be shown.
*
- * @param page the page
+ * @param page
+ * the page
*/
protected void initializeAndShowPage(IPageBookViewPage page) {
if (book != null) {
if (page != null) {
page.createControl(book);
casViewPage = page;
-
+
// Note: If page is in background event listening must be disabled!
ISelectionProvider selectionProvider = page.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(CasEditorViewPage.this::selectionChanged);
-
+
subActionBar = (SubActionBars) casViewPage.getSite().getActionBars();
-
+
casViewPage.setActionBars(subActionBar);
subActionBar.activate();
subActionBar.updateActionBars();
refreshActionHandlers();
-
+
book.showPage(page.getControl());
- }
- else {
+ } else {
book.showPage(messageText);
getSite().getActionBars().updateActionBars();
}
}
}
-
+
/**
* Sets the CAS view page.
*
- * @param page the new CAS view page
+ * @param page
+ * the new CAS view page
*/
public void setCASViewPage(IPageBookViewPage page) {
-
+
if (book != null && casViewPage != null) {
casViewPage.dispose();
subActionBar.dispose();
}
-
+
casViewPage = page;
-
+
initializeAndShowPage(page);
}
-
+
@Override
public Control getControl() {
return book;
@@ -217,7 +215,7 @@ public class CasEditorViewPage extends Page implements ISelectionProvider {
public void setFocus() {
book.setFocus();
}
-
+
@Override
public void dispose() {
super.dispose();
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java
index 0be503e..13aa48b 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java
@@ -22,7 +22,6 @@ package org.apache.uima.caseditor.editor;
import org.apache.uima.cas.Type;
import org.eclipse.jface.action.Action;
-
/**
* The {@link ChangeModeAction} changes the editor annotation mode to the newly selected one.
*/
@@ -40,9 +39,12 @@ final class ChangeModeAction extends Action {
/**
* Initializes a new instance.
*
- * @param newMode -target mode
- * @param name - name of the action
- * @param editor the editor
+ * @param newMode
+ * -target mode
+ * @param name
+ * - name of the action
+ * @param editor
+ * the editor
*/
ChangeModeAction(Type newMode, String name, AnnotationEditor editor) {
mMode = newMode;
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java
index 07a0d93..c6a8fd3 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java
@@ -33,12 +33,12 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-
/**
* TODO: add javadoc here.
*/
-public class CustomInformationControl implements IInformationControl, IInformationControlExtension2 {
-
+public class CustomInformationControl
+ implements IInformationControl, IInformationControlExtension2 {
+
/** The m shell. */
private Shell mShell;
@@ -51,8 +51,10 @@ public class CustomInformationControl implements IInformationControl, IInformati
/**
* Initializes a new instance.
*
- * @param parent the parent
- * @param contentHandler the content handler
+ * @param parent
+ * the parent
+ * @param contentHandler
+ * the content handler
*/
public CustomInformationControl(Shell parent,
ICustomInformationControlContentHandler contentHandler) {
@@ -68,7 +70,8 @@ public class CustomInformationControl implements IInformationControl, IInformati
/**
* Sets the viewer control.
*
- * @param viewerControl the new control
+ * @param viewerControl
+ * the new control
*/
public void setControl(Control viewerControl) {
mControl = viewerControl;
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
index 998ab4c..b4990e1 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/DocumentUimaImpl.java
@@ -71,7 +71,6 @@ import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.preference.IPreferenceStore;
-
/**
* This document implementation is based on an uima cas object.
*/
@@ -79,7 +78,7 @@ public class DocumentUimaImpl extends AbstractDocument {
/** The Constant JAVA_NATURE. */
public static final String JAVA_NATURE = "org.eclipse.jdt.core.javanature";
-
+
/** The m CAS. */
private CAS mCAS;
@@ -92,10 +91,14 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Initializes a new instance.
*
- * @param cas the cas
- * @param casFile the cas file
- * @param typeSystemText type system string
- * @throws CoreException the core exception
+ * @param cas
+ * the cas
+ * @param casFile
+ * the cas file
+ * @param typeSystemText
+ * type system string
+ * @throws CoreException
+ * the core exception
*/
public DocumentUimaImpl(CAS cas, IFile casFile, String typeSystemText) throws CoreException {
mCAS = cas;
@@ -123,7 +126,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Internally removes an annotation from the {@link CAS}.
*
- * @param featureStructure the feature structure
+ * @param featureStructure
+ * the feature structure
*/
private void addFeatureStructureInternal(FeatureStructure featureStructure) {
getCAS().getIndexRepository().addFS(featureStructure);
@@ -132,7 +136,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Adds the given annotation to the {@link CAS}.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void addFeatureStructure(FeatureStructure annotation) {
@@ -155,7 +160,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Internally removes an annotation from the {@link CAS}.
*
- * @param featureStructure the feature structure
+ * @param featureStructure
+ * the feature structure
*/
private void removeAnnotationInternal(FeatureStructure featureStructure) {
getCAS().getIndexRepository().removeFS(featureStructure);
@@ -164,7 +170,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Removes the annotations from the {@link CAS}.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void removeFeatureStructure(FeatureStructure annotation) {
@@ -176,7 +183,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Removes the given annotations from the {@link CAS}.
*
- * @param annotationsToRemove the annotations to remove
+ * @param annotationsToRemove
+ * the annotations to remove
*/
@Override
public void removeFeatureStructures(Collection<? extends FeatureStructure> annotationsToRemove) {
@@ -193,7 +201,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Notifies clients about the changed annotation.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
@Override
public void update(FeatureStructure annotation) {
@@ -203,7 +212,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Notifies clients about the changed annotation.
*
- * @param annotations the annotations
+ * @param annotations
+ * the annotations
*/
@Override
public void updateFeatureStructure(Collection<? extends FeatureStructure> annotations) {
@@ -218,7 +228,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Retrieves annotations of the given type from the {@link CAS}.
*
- * @param type the type
+ * @param type
+ * the type
* @return the annotations
*/
@Override
@@ -236,7 +247,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Fs iterator to collection.
*
- * @param iterator the iterator
+ * @param iterator
+ * the iterator
* @return the collection
*/
static Collection<AnnotationFS> fsIteratorToCollection(FSIterator<AnnotationFS> iterator) {
@@ -253,7 +265,8 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Retrieves the given type from the {@link TypeSystem}.
*
- * @param type the type
+ * @param type
+ * the type
* @return the type
*/
@Override
@@ -273,8 +286,10 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Sets the content. The XCAS {@link InputStream} gets parsed.
*
- * @param casFile the new content
- * @throws CoreException the core exception
+ * @param casFile
+ * the new content
+ * @throws CoreException
+ * the core exception
*/
private void setContent(IFile casFile) throws CoreException {
@@ -298,8 +313,10 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Throw core exception.
*
- * @param e the e
- * @throws CoreException the core exception
+ * @param e
+ * the e
+ * @throws CoreException
+ * the core exception
*/
private void throwCoreException(Exception e) throws CoreException {
String message = e.getMessage() != null ? e.getMessage() : "";
@@ -310,8 +327,10 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Serializes the {@link CAS} to the given {@link OutputStream} in the XCAS format.
*
- * @param out the out
- * @throws CoreException the core exception
+ * @param out
+ * the out
+ * @throws CoreException
+ * the core exception
*/
public void serialize(OutputStream out) throws CoreException {
try {
@@ -320,13 +339,15 @@ public class DocumentUimaImpl extends AbstractDocument {
throwCoreException(e);
}
}
-
+
/**
* Gets the virgin CAS.
*
- * @param extensionTypeSystemFile the type system file
+ * @param extensionTypeSystemFile
+ * the type system file
* @return the virgin CAS
- * @throws CoreException the core exception
+ * @throws CoreException
+ * the core exception
*/
public static CAS getVirginCAS(IFile extensionTypeSystemFile) throws CoreException {
ResourceSpecifierFactory resourceSpecifierFactory = UIMAFramework.getResourceSpecifierFactory();
@@ -351,16 +372,15 @@ public class DocumentUimaImpl extends AbstractDocument {
IProject project = extensionTypeSystemFile.getProject();
ClassLoader classLoader = getProjectClassLoader(project);
-
+
ResourceManager resourceManager;
- if(classLoader != null) {
+ if (classLoader != null) {
resourceManager = new ResourceManager_impl(classLoader);
} else {
resourceManager = UIMAFramework.newDefaultResourceManager();
}
-
- String dataPath = project
- .getPersistentProperty((new QualifiedName("", "CDEdataPath")));
+
+ String dataPath = project.getPersistentProperty((new QualifiedName("", "CDEdataPath")));
if (dataPath != null) {
resourceManager.setDataPath(dataPath);
}
@@ -394,15 +414,17 @@ public class DocumentUimaImpl extends AbstractDocument {
/**
* Gets the project class loader.
*
- * @param project the project
+ * @param project
+ * the project
* @return the project class loader
- * @throws CoreException the core exception
+ * @throws CoreException
+ * the core exception
*/
public static ClassLoader getProjectClassLoader(IProject project) throws CoreException {
IProjectNature javaNature = project.getNature(JAVA_NATURE);
if (javaNature != null) {
JavaProject javaProject = (JavaProject) JavaCore.create(project);
-
+
String[] runtimeClassPath = JavaRuntime.computeDefaultRuntimeClassPath(javaProject);
List<URL> urls = new ArrayList<>();
for (String cp : runtimeClassPath) {
@@ -413,7 +435,7 @@ public class DocumentUimaImpl extends AbstractDocument {
}
}
return new URLClassLoader(urls.toArray(new URL[0]));
- }
+ }
return null;
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java
index 66a14ff..9c24d98 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java
@@ -29,13 +29,11 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
-
-
/**
* The Class FeatureStructureSelection.
*/
public class FeatureStructureSelection {
-
+
/** The m feature structures. */
private List<FeatureStructure> mFeatureStructures;
@@ -43,14 +41,15 @@ public class FeatureStructureSelection {
* Initializes a the current instance with all FeatureStructure object that are contained in the
* {@link StructuredSelection}.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public FeatureStructureSelection(IStructuredSelection selection) {
mFeatureStructures = new ArrayList<>(selection.size());
for (Object item : selection.toList()) {
- FeatureStructure annotation = (FeatureStructure) Platform.getAdapterManager().getAdapter(
- item, FeatureStructure.class);
+ FeatureStructure annotation = (FeatureStructure) Platform.getAdapterManager().getAdapter(item,
+ FeatureStructure.class);
// TODO: fix it
if (annotation == null && item instanceof IAdaptable) {
@@ -94,6 +93,7 @@ public class FeatureStructureSelection {
/**
* Retrieves a human readable string.
+ *
* @return human readable string
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java
index 1bf60ad..7c8ad8c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java
@@ -27,7 +27,6 @@ import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.IStructuredSelection;
-
/**
* Iterates over all selected {@link FeatureStructure}s.
*/
@@ -42,7 +41,8 @@ public class FeatureStructureSelectionIterator implements Iterator<FeatureStruct
/**
* Initializes the current instance.
*
- * @param selection the selection
+ * @param selection
+ * the selection
*/
public FeatureStructureSelectionIterator(IStructuredSelection selection) {
mSelectionIterator = selection.iterator();
@@ -86,7 +86,8 @@ public class FeatureStructureSelectionIterator implements Iterator<FeatureStruct
/**
* Not supported, it throws an {@link UnsupportedOperationException}.
*
- * @throws UnsupportedOperationException -
+ * @throws UnsupportedOperationException
+ * -
*/
@Override
public void remove() {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java
index 59472f2..0f1bf77 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java
@@ -33,7 +33,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
-
/**
* This class is a {@link ISelectionProvider} and informs its listeners about the currently selected
* {@link FeatureStructure}s.
@@ -49,7 +48,8 @@ class FeatureStructureSelectionProvider implements ISelectionProvider {
/**
* Adds an {@link ISelectionChangedListener} to this provider.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
@@ -82,7 +82,8 @@ class FeatureStructureSelectionProvider implements ISelectionProvider {
/**
* Sets the current selection.
*
- * @param selection the new selection
+ * @param selection
+ * the new selection
*/
@Override
public void setSelection(ISelection selection) {
@@ -100,8 +101,10 @@ class FeatureStructureSelectionProvider implements ISelectionProvider {
/**
* Sets the current selection to the given {@link AnnotationFS} object.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
public void setSelection(ICasDocument document, AnnotationFS annotation) {
if (annotation == null) {
@@ -114,8 +117,10 @@ class FeatureStructureSelectionProvider implements ISelectionProvider {
/**
* Sets the selection.
*
- * @param document the document
- * @param selection the selection
+ * @param document
+ * the document
+ * @param selection
+ * the selection
*/
public void setSelection(ICasDocument document, List<AnnotationFS> selection) {
setSelection(new StructuredSelection(ModelFeatureStructure.create(document, selection)));
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java
index 0e05411..16ab07c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor;
-
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.text.AnnotationFS;
@@ -27,12 +26,11 @@ import org.apache.uima.caseditor.editor.util.Primitives;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
-
/**
* The Class FeatureValue.
*/
public final class FeatureValue implements IAdaptable {
-
+
/** The m structure. */
private FeatureStructure mStructure;
@@ -42,14 +40,17 @@ public final class FeatureValue implements IAdaptable {
/**
* Initializes a new instance.
*
- * @param document the document
- * @param structure the structure
- * @param feature the feature
+ * @param document
+ * the document
+ * @param structure
+ * the structure
+ * @param feature
+ * the feature
*/
public FeatureValue(ICasDocument document, FeatureStructure structure, Feature feature) {
Assert.isNotNull(document);
// TODO: Remove document parameter ? Not needed anymore!
-
+
Assert.isNotNull(feature);
mFeature = feature;
@@ -80,7 +81,8 @@ public final class FeatureValue implements IAdaptable {
}
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
if (AnnotationFS.class.equals(adapter)) {
if (getValue() instanceof AnnotationFS) {
return getValue();
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java
index ff5d797..bdc8bc4 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateAction.java
@@ -23,7 +23,6 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.IFindReplaceTarget;
import org.eclipse.swt.widgets.Display;
-
/**
* An Action to open the Find/Annotate Dialog.
*
@@ -33,15 +32,17 @@ public class FindAnnotateAction extends Action {
/** The editor. */
private AnnotationEditor editor;
-
+
/** The target. */
private IFindReplaceTarget target;
/**
* Instantiates a new find annotate action.
*
- * @param editor the editor
- * @param target the target
+ * @param editor
+ * the editor
+ * @param target
+ * the target
*/
FindAnnotateAction(AnnotationEditor editor, IFindReplaceTarget target) {
this.editor = editor;
@@ -50,8 +51,7 @@ public class FindAnnotateAction extends Action {
@Override
public void run() {
- FindAnnotateDialog dialog = new FindAnnotateDialog(
- Display.getCurrent().getActiveShell(),
+ FindAnnotateDialog dialog = new FindAnnotateDialog(Display.getCurrent().getActiveShell(),
editor.getDocument(), target, editor.getAnnotationMode());
dialog.open();
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java
index 72a5ba8..7c8e1c2 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/FindAnnotateDialog.java
@@ -46,80 +46,80 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
-
/**
* A dialog to find and annotate a piece of text in the document.
*
- * TODO:
- * Add option to only search in text which is not covered by the annotation type.
- * Add buttons to modify annotation bounds
- * Match whole annotation: e.g. Token
- * Scope search in annotations of type
- * Add history to search field
+ * TODO: Add option to only search in text which is not covered by the annotation type. Add buttons
+ * to modify annotation bounds Match whole annotation: e.g. Token Scope search in annotations of
+ * type Add history to search field
*/
class FindAnnotateDialog extends Dialog {
/** The Constant FIND_BUTTON. */
private static final int FIND_BUTTON = 100;
-
+
/** The Constant ANNOTATE_FIND_BUTTON. */
private static final int ANNOTATE_FIND_BUTTON = 101;
-
+
/** The Constant ANNOTATE_BUTTON. */
private static final int ANNOTATE_BUTTON = 102;
-
+
/** The Constant ANNOTATE_ALL_BUTTON. */
private static final int ANNOTATE_ALL_BUTTON = 103;
-
+
/** The close button. */
private static int CLOSE_BUTTON = 104;
-
+
/** The find replace target. */
private final IFindReplaceTarget findReplaceTarget;
-
+
/** The document. */
private final ICasDocument document;
-
+
/** The mode type. */
private final Type modeType;
-
+
/** The find field. */
private Combo findField;
-
+
/** The type field. */
private TypeCombo typeField;
-
+
/** The wide left side button. */
private Button wideLeftSideButton;
-
+
/** The lower left side button. */
private Button lowerLeftSideButton;
-
+
/** The lower right side button. */
private Button lowerRightSideButton;
-
+
/** The wide right side button. */
private Button wideRightSideButton;
-
+
/** The forward radio button. */
private Button forwardRadioButton;
-
+
/**
- * Annotation created by the user with the Annotate button.
- * Contains null if no search was done or search was continued after
- * an annotation was created.
+ * Annotation created by the user with the Annotate button. Contains null if no search was done or
+ * search was continued after an annotation was created.
*/
private AnnotationFS currentAnnotation;
-
+
/**
* Instantiates a new find annotate dialog.
*
- * @param parentShell the parent shell
- * @param document the document
- * @param findReplaceTarget the find replace target
- * @param modeType the mode type
+ * @param parentShell
+ * the parent shell
+ * @param document
+ * the document
+ * @param findReplaceTarget
+ * the find replace target
+ * @param modeType
+ * the mode type
*/
- FindAnnotateDialog(Shell parentShell, ICasDocument document, IFindReplaceTarget findReplaceTarget, Type modeType) {
+ FindAnnotateDialog(Shell parentShell, ICasDocument document, IFindReplaceTarget findReplaceTarget,
+ Type modeType) {
super(parentShell);
this.document = document;
this.findReplaceTarget = findReplaceTarget;
@@ -141,21 +141,22 @@ class FindAnnotateDialog extends Dialog {
/**
* Creates the search string input field.
*
- * @param parent the parent
+ * @param parent
+ * the parent
* @return the composite
*/
private Composite createInputPanel(Composite parent) {
- Composite panel= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ Composite panel = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
panel.setLayout(layout);
// find label
- Label findLabel= new Label(panel, SWT.LEFT);
+ Label findLabel = new Label(panel, SWT.LEFT);
findLabel.setText("Find:");
GridData labelData = new GridData();
- labelData.horizontalAlignment = SWT.LEFT;
+ labelData.horizontalAlignment = SWT.LEFT;
findLabel.setLayoutData(labelData);
// find combo box
@@ -167,10 +168,10 @@ class FindAnnotateDialog extends Dialog {
findField.setLayoutData(findFieldData);
// type label
- Label typeLabel= new Label(panel, SWT.LEFT);
+ Label typeLabel = new Label(panel, SWT.LEFT);
typeLabel.setText("Type:");
GridData typeData = new GridData();
- typeData.horizontalAlignment = SWT.LEFT;
+ typeData.horizontalAlignment = SWT.LEFT;
typeLabel.setLayoutData(typeData);
typeField = new TypeCombo(panel);
@@ -189,7 +190,8 @@ class FindAnnotateDialog extends Dialog {
/**
* Creates the group to specify the direction of the search.
*
- * @param parent the parent
+ * @param parent
+ * the parent
* @return the composite
*/
private Composite createDirectionGroup(Composite parent) {
@@ -199,9 +201,9 @@ class FindAnnotateDialog extends Dialog {
layout.marginHeight = 0;
panel.setLayout(layout);
- Group group= new Group(panel, SWT.SHADOW_ETCHED_IN);
+ Group group = new Group(panel, SWT.SHADOW_ETCHED_IN);
group.setText("Direction");
- GridLayout groupLayout= new GridLayout();
+ GridLayout groupLayout = new GridLayout();
groupLayout.numColumns = 2;
group.setLayout(groupLayout);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
@@ -210,7 +212,7 @@ class FindAnnotateDialog extends Dialog {
forwardRadioButton.setText("Forward");
forwardRadioButton.setSelection(true);
- Button backwardRadioButton= new Button(group, SWT.RADIO | SWT.LEFT);
+ Button backwardRadioButton = new Button(group, SWT.RADIO | SWT.LEFT);
backwardRadioButton.setText("Backward");
return panel;
@@ -219,7 +221,8 @@ class FindAnnotateDialog extends Dialog {
/**
* Creates the annotation buttons.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
private void createAnnotationButtons(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
@@ -228,19 +231,19 @@ class FindAnnotateDialog extends Dialog {
layout.marginHeight = 0;
panel.setLayout(layout);
- Group group= new Group(panel, SWT.SHADOW_ETCHED_IN);
+ Group group = new Group(panel, SWT.SHADOW_ETCHED_IN);
group.setText("Annotation");
- GridLayout groupLayout= new GridLayout();
+ GridLayout groupLayout = new GridLayout();
groupLayout.numColumns = 4;
group.setLayout(groupLayout);
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
wideLeftSideButton = new Button(group, SWT.PUSH | SWT.LEFT);
- wideLeftSideButton.setImage(CasEditorPlugin.getTaeImageDescriptor(
- Images.WIDE_LEFT_SIDE).createImage());
+ wideLeftSideButton
+ .setImage(CasEditorPlugin.getTaeImageDescriptor(Images.WIDE_LEFT_SIDE).createImage());
wideLeftSideButton.setEnabled(false);
-
- wideLeftSideButton.addSelectionListener(new SelectionListener(){
+
+ wideLeftSideButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// never called, do not implement
@@ -251,12 +254,12 @@ class FindAnnotateDialog extends Dialog {
WideLeftAnnotationSideAction.wideLeftAnnotationSide(document, currentAnnotation);
}
});
-
+
lowerLeftSideButton = new Button(group, SWT.PUSH | SWT.LEFT);
- lowerLeftSideButton.setImage(CasEditorPlugin.getTaeImageDescriptor(
- Images.LOWER_LEFT_SIDE).createImage());
+ lowerLeftSideButton
+ .setImage(CasEditorPlugin.getTaeImageDescriptor(Images.LOWER_LEFT_SIDE).createImage());
lowerLeftSideButton.setEnabled(false);
- lowerLeftSideButton.addSelectionListener(new SelectionListener(){
+ lowerLeftSideButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// never called, do not implement
@@ -269,10 +272,10 @@ class FindAnnotateDialog extends Dialog {
});
lowerRightSideButton = new Button(group, SWT.PUSH | SWT.LEFT);
- lowerRightSideButton.setImage(CasEditorPlugin.getTaeImageDescriptor(
- Images.LOWER_RIGHT_SIDE).createImage());
+ lowerRightSideButton
+ .setImage(CasEditorPlugin.getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE).createImage());
lowerRightSideButton.setEnabled(false);
- lowerRightSideButton.addSelectionListener(new SelectionListener(){
+ lowerRightSideButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// never called, do not implement
@@ -285,10 +288,10 @@ class FindAnnotateDialog extends Dialog {
});
wideRightSideButton = new Button(group, SWT.PUSH | SWT.LEFT);
- wideRightSideButton.setImage(CasEditorPlugin.getTaeImageDescriptor(
- Images.WIDE_RIGHT_SIDE).createImage());
+ wideRightSideButton
+ .setImage(CasEditorPlugin.getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE).createImage());
wideRightSideButton.setEnabled(false);
- wideRightSideButton.addSelectionListener(new SelectionListener(){
+ wideRightSideButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// never called, do not implement
@@ -316,7 +319,8 @@ class FindAnnotateDialog extends Dialog {
/**
* Creates the find and annotate buttons.
*
- * @param parent the parent
+ * @param parent
+ * the parent
* @return the composite
*/
private Composite createButtonSection(Composite parent) {
@@ -325,19 +329,19 @@ class FindAnnotateDialog extends Dialog {
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
+ // 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, 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;
}
@@ -345,29 +349,30 @@ class FindAnnotateDialog extends Dialog {
/**
* Creates the status and close button.
*
- * @param parent the parent
+ * @param parent
+ * the parent
* @return the composite
*/
private Composite createStatusAndCloseButton(Composite parent) {
- Composite panel= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginWidth= 0;
- layout.marginHeight= 0;
+ Composite panel = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
panel.setLayout(layout);
- Label statusLabel= new Label(panel, SWT.LEFT);
+ Label statusLabel = new Label(panel, SWT.LEFT);
GridData statusData = new GridData();
statusData.horizontalAlignment = SWT.FILL;
- statusData.grabExcessHorizontalSpace= true;
+ 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;
}
@@ -376,14 +381,14 @@ class FindAnnotateDialog extends Dialog {
protected Control createContents(Composite parent) {
Composite panel = new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- layout.makeColumnsEqualWidth= true;
+ 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;
+ inputPanelData.horizontalAlignment = SWT.FILL;
inputPanelData.grabExcessHorizontalSpace = true;
inputPanelData.verticalAlignment = SWT.TOP;
inputPanelData.grabExcessVerticalSpace = false;
@@ -392,7 +397,7 @@ class FindAnnotateDialog extends Dialog {
createDirectionGroup(panel);
createAnnotationButtons(panel);
-
+
Composite buttonFindAnnotatePanel = createButtonSection(panel);
GridData buttonFindAnnotatePanelData = new GridData();
buttonFindAnnotatePanelData.horizontalAlignment = SWT.RIGHT;
@@ -411,8 +416,7 @@ class FindAnnotateDialog extends Dialog {
}
/**
- * Finds the next occurrence of the search string and selects it in
- * the editor.
+ * Finds the next occurrence of the search string and selects it in the editor.
*/
private void findAndSelectNext() {
@@ -422,12 +426,12 @@ class FindAnnotateDialog extends Dialog {
if (isForwardSearch) {
textOffset = findReplaceTarget.getSelection().x + findReplaceTarget.getSelection().y;
- }
- else {
+ } else {
textOffset = findReplaceTarget.getSelection().x - 1;
}
- int result = findReplaceTarget.findAndSelect(textOffset, findField.getText(), isForwardSearch, false, false);
+ int result = findReplaceTarget.findAndSelect(textOffset, findField.getText(), isForwardSearch,
+ false, false);
if (result == -1) {
findReplaceTarget.findAndSelect(-1, findField.getText(), isForwardSearch, false, false);
@@ -442,11 +446,11 @@ class FindAnnotateDialog extends Dialog {
private AnnotationFS annotateSelection() {
Point selection = findReplaceTarget.getSelection();
- AnnotationFS newAnnotation = document.getCAS().createAnnotation(
- typeField.getType(), selection.x, selection.x + selection.y);
+ AnnotationFS newAnnotation = document.getCAS().createAnnotation(typeField.getType(),
+ selection.x, selection.x + selection.y);
document.getCAS().addFsToIndexes(newAnnotation);
document.addFeatureStructure(newAnnotation);
-
+
return newAnnotation;
}
@@ -456,27 +460,22 @@ class FindAnnotateDialog extends Dialog {
if (FIND_BUTTON == buttonID) {
findAndSelectNext();
currentAnnotation = null;
- }
- else if (ANNOTATE_BUTTON == buttonID) {
+ } else if (ANNOTATE_BUTTON == buttonID) {
currentAnnotation = annotateSelection();
- }
- else if (ANNOTATE_FIND_BUTTON == buttonID) {
+ } else if (ANNOTATE_FIND_BUTTON == buttonID) {
annotateSelection();
findAndSelectNext();
-
+
// TODO: Should be disabled when annotate was pressed
- }
- else if (ANNOTATE_ALL_BUTTON == buttonID) {
+ } else if (ANNOTATE_ALL_BUTTON == buttonID) {
// TODO: Should it be implemented ???
- }
- else if (CLOSE_BUTTON == buttonID) {
+ } else if (CLOSE_BUTTON == buttonID) {
close();
return;
- }
- else {
+ } else {
throw new TaeError("Unkown button!");
}
-
+
updateAnnotationButtons();
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
index c909151..03bfe71 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
@@ -23,29 +23,28 @@ import java.util.Collection;
import org.apache.uima.cas.Type;
-
/**
- * The listener interface for receiving IAnnotationEditorModify events.
- * The class that is interested in processing a IAnnotationEditorModify
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addIAnnotationEditorModifyListener</code> method. When
- * the IAnnotationEditorModify event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving IAnnotationEditorModify events. The class that is interested
+ * in processing a IAnnotationEditorModify event implements this interface, and the object created
+ * with that class is registered with a component using the component's
+ * <code>addIAnnotationEditorModifyListener</code> method. When the IAnnotationEditorModify event
+ * occurs, that object's appropriate method is invoked.
*/
public interface IAnnotationEditorModifyListener {
/**
* Called when the editor annotation mode changed.
*
- * @param newMode the new mode
+ * @param newMode
+ * the new mode
*/
void annotationModeChanged(Type newMode);
/**
* Called when the shown annotation types in the editor are changed.
*
- * @param shownAnnotationTypes the shown annotation types
+ * @param shownAnnotationTypes
+ * the shown annotation types
*/
void showAnnotationsChanged(Collection<Type> shownAnnotationTypes);
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationStyleListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationStyleListener.java
index fad810c..8897a30 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationStyleListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationStyleListener.java
@@ -21,22 +21,20 @@ package org.apache.uima.caseditor.editor;
import java.util.Collection;
-
/**
- * The listener interface for receiving IAnnotationStyle events.
- * The class that is interested in processing a IAnnotationStyle
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addIAnnotationStyleListener</code> method. When
- * the IAnnotationStyle event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving IAnnotationStyle events. The class that is interested in
+ * processing a IAnnotationStyle event implements this interface, and the object created with that
+ * class is registered with a component using the component's
+ * <code>addIAnnotationStyleListener</code> method. When the IAnnotationStyle event occurs, that
+ * object's appropriate method is invoked.
*/
public interface IAnnotationStyleListener {
-
+
/**
* Annotation styles changed.
*
- * @param styles the styles
+ * @param styles
+ * the styles
*/
void annotationStylesChanged(Collection<AnnotationStyle> styles);
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
index 74f66bf..cfa7d0f 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocument.java
@@ -26,7 +26,6 @@ import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
-
/**
* The {@link ICasDocument} represents texts with meta information.
*
@@ -43,14 +42,16 @@ public interface ICasDocument {
/**
* Adds a given change listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
void addChangeListener(ICasDocumentListener listener);
/**
* Removes the given change listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
void removeChangeListener(ICasDocumentListener listener);
@@ -72,7 +73,8 @@ public interface ICasDocument {
/**
* Adds the {@link FeatureStructure}s.
*
- * @param structures the structures
+ * @param structures
+ * the structures
*/
void addFeatureStructures(Collection<? extends FeatureStructure> structures);
@@ -87,21 +89,24 @@ public interface ICasDocument {
/**
* Removes the given {@link FeatureStructure}s.
*
- * @param structuresToRemove the structures to remove
+ * @param structuresToRemove
+ * the structures to remove
*/
void removeFeatureStructures(Collection<? extends FeatureStructure> structuresToRemove);
/**
* Updates the given {@link FeatureStructure}.
*
- * @param structure the structure
+ * @param structure
+ * the structure
*/
void update(FeatureStructure structure);
/**
* Updates the given {@link FeatureStructure}s.
*
- * @param structures the structures
+ * @param structures
+ * the structures
*/
void updateFeatureStructure(Collection<? extends FeatureStructure> structures);
@@ -123,14 +128,16 @@ public interface ICasDocument {
/**
* Switches the view of the underlying CAS to the provided view name.
*
- * @param viewName the view name
+ * @param viewName
+ * the view name
*/
void switchView(String viewName);
/**
* Retrieves the requested type.
*
- * @param type the type
+ * @param type
+ * the type
* @return the type
*/
Type getType(String type);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
index 13e9bb6..1865437 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasDocumentListener.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import org.apache.uima.cas.FeatureStructure;
-
/**
* This interface is used to notifies clients about {@link FeatureStructure} changes.
*/
@@ -63,14 +62,16 @@ public interface ICasDocumentListener {
/**
* This method is called if the {@link FeatureStructure} changed.
*
- * @param featureStructure the feature structure
+ * @param featureStructure
+ * the feature structure
*/
void updated(FeatureStructure featureStructure);
/**
* This method is called if the {@link FeatureStructure}s changed.
*
- * @param featureStructure the feature structure
+ * @param featureStructure
+ * the feature structure
*/
void updated(Collection<FeatureStructure> featureStructure);
@@ -86,10 +87,11 @@ public interface ICasDocumentListener {
* does not indicate a structural change, but usually feature structures must be completely
* synchronized afterward.
*
- * @param oldViewName the old view name
- * @param newViewName the new view name
+ * @param oldViewName
+ * the old view name
+ * @param newViewName
+ * the new view name
*/
void viewChanged(String oldViewName, String newViewName);
-
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditor.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditor.java
index 38451c9..24395da 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditor.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditor.java
@@ -22,47 +22,48 @@ package org.apache.uima.caseditor.editor;
import org.apache.uima.cas.CAS;
import org.eclipse.ui.IEditorPart;
-
/**
- * A Cas Editor is an extension to the {@link IEditorPart} interface and
- * is responsible to view and edit a {@link CAS} object.
+ * A Cas Editor is an extension to the {@link IEditorPart} interface and is responsible to view and
+ * edit a {@link CAS} object.
*/
public interface ICasEditor extends IEditorPart {
-
+
// TODO: Add a method to get the document provider, could needed
- // by various views to store configuration linked to the ts!
-
+ // by various views to store configuration linked to the ts!
+
/**
* Gets the document.
*
* @return the document
*/
ICasDocument getDocument();
-
+
/**
* Gets the cas document provider.
*
* @return the cas document provider
*/
CasDocumentProvider getCasDocumentProvider();
-
+
/**
* Reopen editor with new type system.
*/
void reopenEditorWithNewTypeSystem();
-
+
/**
* Adds the cas editor input listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
void addCasEditorInputListener(ICasEditorInputListener listener);
-
+
/**
* Removes the cas editor input listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
void removeCasEditorInputListener(ICasEditorInputListener listener);
-
+
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
index 6f3fe55..5e2c825 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICasEditorInputListener.java
@@ -21,29 +21,30 @@ package org.apache.uima.caseditor.editor;
import org.eclipse.ui.IEditorInput;
-
/**
- * The listener interface for receiving ICasEditorInput events.
- * The class that is interested in processing a ICasEditorInput
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addICasEditorInputListener</code> method. When
- * the ICasEditorInput event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving ICasEditorInput events. The class that is interested in
+ * processing a ICasEditorInput event implements this interface, and the object created with that
+ * class is registered with a component using the component's
+ * <code>addICasEditorInputListener</code> method. When the ICasEditorInput event occurs, that
+ * object's appropriate method is invoked.
*/
public interface ICasEditorInputListener {
/**
- * This method is called if an {@link ICasDocument} is exchanged.
- * The arguments of this methods can be null under certain circumstances.
- * For example, if a document is opened where the type system cannot be found
- * for, then the new document will be null.
+ * This method is called if an {@link ICasDocument} is exchanged. The arguments of this methods
+ * can be null under certain circumstances. For example, if a document is opened where the type
+ * system cannot be found for, then the new document will be null.
*
- * @param oldInput the old input
- * @param oldDocument - the replaced, old document {@link ICasDocument}.
- * @param newInput the new input
- * @param newDocument - the new, current document {@link ICasDocument}.
+ * @param oldInput
+ * the old input
+ * @param oldDocument
+ * - the replaced, old document {@link ICasDocument}.
+ * @param newInput
+ * the new input
+ * @param newDocument
+ * - the new, current document {@link ICasDocument}.
*/
- void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument, IEditorInput newInput, ICasDocument newDocument);
-
+ void casDocumentChanged(IEditorInput oldInput, ICasDocument oldDocument, IEditorInput newInput,
+ ICasDocument newDocument);
+
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java
index 3208c2c..e106871 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java
@@ -19,17 +19,18 @@
package org.apache.uima.caseditor.editor;
-
/**
* The Interface ICustomInformationControlContentHandler.
*/
public interface ICustomInformationControlContentHandler {
-
+
/**
* Sets the input object.
*
- * @param control the control
- * @param input the input
+ * @param control
+ * the control
+ * @param input
+ * the input
*/
void setInput(CustomInformationControl control, Object input);
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java
index 6c8dba2..36b2b88 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java
@@ -19,15 +19,12 @@
package org.apache.uima.caseditor.editor;
-
/**
- * The listener interface for receiving IEditorSelection events.
- * The class that is interested in processing a IEditorSelection
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addIEditorSelectionListener</code> method. When
- * the IEditorSelection event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving IEditorSelection events. The class that is interested in
+ * processing a IEditorSelection event implements this interface, and the object created with that
+ * class is registered with a component using the component's
+ * <code>addIEditorSelectionListener</code> method. When the IEditorSelection event occurs, that
+ * object's appropriate method is invoked.
*/
public interface IEditorSelectionListener {
/**
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
index 229e8e4..dd5c0a0 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
@@ -28,15 +28,11 @@ import org.apache.uima.cas.text.AnnotationFS;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
-
/**
- * TODO:
- * set feature value to null
- * delete feature value structure
- * create feature value structure.
+ * TODO: set feature value to null delete feature value structure create feature value structure.
*/
public class ModelFeatureStructure implements IAdaptable {
-
+
/** The m document. */
private ICasDocument mDocument;
@@ -46,8 +42,10 @@ public class ModelFeatureStructure implements IAdaptable {
/**
* Initializes a new instance.
*
- * @param document the document
- * @param featureStructre the feature structre
+ * @param document
+ * the document
+ * @param featureStructre
+ * the feature structre
*/
public ModelFeatureStructure(ICasDocument document, FeatureStructure featureStructre) {
mDocument = document;
@@ -75,7 +73,8 @@ public class ModelFeatureStructure implements IAdaptable {
/**
* Sets the feature null.
*
- * @param feature the new feature null
+ * @param feature
+ * the new feature null
*/
public void setFeatureNull(Feature feature) {
mFeatureStructre.setFeatureValue(feature, null);
@@ -84,7 +83,8 @@ public class ModelFeatureStructure implements IAdaptable {
/**
* Delete feature value.
*
- * @param feature the feature
+ * @param feature
+ * the feature
*/
public void deleteFeatureValue(Feature feature) {
// get value and call remove
@@ -93,7 +93,8 @@ public class ModelFeatureStructure implements IAdaptable {
/**
* Creates the feature value.
*
- * @param feature the feature
+ * @param feature
+ * the feature
*/
public void createFeatureValue(Feature feature) {
// create, add and link
@@ -102,19 +103,22 @@ public class ModelFeatureStructure implements IAdaptable {
/**
* Creates the feature value array.
*
- * @param feature the feature
- * @param size the size
+ * @param feature
+ * the feature
+ * @param size
+ * the size
*/
public void createFeatureValueArray(Feature feature, int size) {
// create add and link
}
-
/**
* Creates the.
*
- * @param document the document
- * @param annotations the annotations
+ * @param document
+ * the document
+ * @param annotations
+ * the annotations
* @return the list
*/
public static List<ModelFeatureStructure> create(ICasDocument document,
@@ -129,7 +133,8 @@ public class ModelFeatureStructure implements IAdaptable {
}
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
if (FeatureStructure.class.equals(adapter)) {
return getStructre();
} else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) {
@@ -151,8 +156,7 @@ public class ModelFeatureStructure implements IAdaptable {
if (obj == this) {
return true;
- }
- else if (obj instanceof ModelFeatureStructure) {
+ } else if (obj instanceof ModelFeatureStructure) {
ModelFeatureStructure foreignFS = (ModelFeatureStructure) obj;
return mFeatureStructre.equals(foreignFS.mFeatureStructre);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java
index 9c47e00..93fdf0e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/QuickTypeSelectionDialog.java
@@ -61,7 +61,6 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-
/**
* This is a lightweight popup dialog which creates an annotation of the chosen type.
*/
@@ -82,8 +81,10 @@ class QuickTypeSelectionDialog extends PopupDialog {
/**
* Initializes the current instance.
*
- * @param parent the parent
- * @param editor the editor
+ * @param parent
+ * the parent
+ * @param editor
+ * the editor
*/
@SuppressWarnings("deprecation")
QuickTypeSelectionDialog(Shell parent, AnnotationEditor editor) {
@@ -162,8 +163,10 @@ class QuickTypeSelectionDialog extends PopupDialog {
/**
* Put shortcut.
*
- * @param shortcut the shortcut
- * @param type the type
+ * @param shortcut
+ * the shortcut
+ * @param type
+ * the type
*/
private void putShortcut(Character shortcut, Type type) {
shortcutTypeMap.put(shortcut, type);
@@ -179,26 +182,26 @@ class QuickTypeSelectionDialog extends PopupDialog {
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));
types.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION));
-
+
return types.toArray(new Type[types.size()]);
}
/**
* Annotate and close.
*
- * @param annotationType the annotation type
+ * @param annotationType
+ * the annotation type
*/
private void annotateAndClose(Type annotationType) {
if (annotationType != null) {
Point textSelection = editor.getSelection();
- AnnotationFS annotation =
- editor.getDocument().getCAS().createAnnotation(annotationType, textSelection.x,
- textSelection.y);
+ AnnotationFS annotation = editor.getDocument().getCAS().createAnnotation(annotationType,
+ textSelection.x, textSelection.y);
editor.getDocument().addFeatureStructure(annotation);
@@ -226,8 +229,8 @@ class QuickTypeSelectionDialog extends PopupDialog {
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();
@@ -377,11 +380,11 @@ class QuickTypeSelectionDialog extends PopupDialog {
annotateAndClose((Type) selection.getFirstElement());
}
});
-
+
Collection<Type> shownAnnotationTypes = editor.getShownAnnotationTypes();
-
+
Type[] types = shownAnnotationTypes.toArray(new Type[shownAnnotationTypes.size()]);
-
+
typeTree.setInput(types);
ISelection modeSelection = new StructuredSelection(new Object[] { editor.getAnnotationMode() });
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java
index 1c8e842..ee6f108 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/SubPageSite.java
@@ -28,7 +28,6 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.SubActionBars;
import org.eclipse.ui.part.IPageSite;
-
/**
* The Class SubPageSite.
*/
@@ -36,34 +35,38 @@ public class SubPageSite implements IPageSite {
/** The site. */
private final IPageSite site;
-
+
/** The sub action bars. */
- private SubActionBars subActionBars;
-
+ private SubActionBars subActionBars;
+
/** The selection provider. */
private ISelectionProvider selectionProvider;
/**
* Instantiates a new sub page site.
*
- * @param site the site
+ * @param site
+ * the site
*/
public SubPageSite(IPageSite site) {
this.site = site;
}
-
+
@Override
- public boolean hasService(@SuppressWarnings("rawtypes") Class api) {
+ public boolean hasService(@SuppressWarnings("rawtypes")
+ Class api) {
return site.hasService(api);
}
@Override
- public Object getService(@SuppressWarnings("rawtypes") Class api) {
+ public Object getService(@SuppressWarnings("rawtypes")
+ Class api) {
return site.getService(api);
}
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
return site.getAdapter(adapter);
}
@@ -100,7 +103,7 @@ public class SubPageSite implements IPageSite {
@Override
public IActionBars getActionBars() {
-
+
if (subActionBars == null) {
subActionBars = new SubActionBars(site.getActionBars());
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/TextDocumentProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/TextDocumentProvider.java
index 3a8b4d9..d2233c6 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/TextDocumentProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/TextDocumentProvider.java
@@ -28,64 +28,66 @@ import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.texteditor.AbstractDocumentProvider;
import org.eclipse.ui.texteditor.IElementStateListener;
-
/**
* The Class TextDocumentProvider.
*/
class TextDocumentProvider extends AbstractDocumentProvider {
-
+
/**
* The Class CasElementInfo.
*/
private class CasElementInfo extends AbstractDocumentProvider.ElementInfo {
-
+
/** The cas info. */
private CasDocumentProvider.ElementInfo casInfo;
-
+
/**
* Instantiates a new cas element info.
*
- * @param document the document
- * @param model the model
+ * @param document
+ * the document
+ * @param model
+ * the model
*/
public CasElementInfo(IDocument document, IAnnotationModel model) {
super(document, model);
}
}
-
+
/** The document provider. */
private final CasDocumentProvider documentProvider;
-
+
/**
* Instantiates a new text document provider.
*
- * @param documentProvider the document provider
+ * @param documentProvider
+ * the document provider
*/
public TextDocumentProvider(CasDocumentProvider documentProvider) {
this.documentProvider = documentProvider;
-
+
this.documentProvider.addElementStateListener(new IElementStateListener() {
-
+
@Override
public void elementMoved(Object originalElement, Object movedElement) {
fireElementMoved(originalElement, movedElement);
}
-
+
@Override
public void elementDirtyStateChanged(Object element, boolean isDirty) {
fireElementDirtyStateChanged(element, isDirty);
}
-
+
@Override
public void elementDeleted(Object element) {
fireElementDeleted(element);
}
-
+
@Override
public void elementContentReplaced(Object element) {
fireElementContentReplaced(element);
}
-
+
@Override
public void elementContentAboutToBeReplaced(Object element) {
fireElementContentAboutToBeReplaced(element);
@@ -100,14 +102,13 @@ class TextDocumentProvider extends AbstractDocumentProvider {
@Override
protected IDocument createDocument(Object element) throws CoreException {
- ICasDocument casDocument = documentProvider.createDocument(element);
-
+ ICasDocument casDocument = documentProvider.createDocument(element);
+
if (casDocument != null) {
AnnotationDocument document = new AnnotationDocument();
document.setDocument(casDocument);
return document;
- }
- else {
+ } else {
return null;
}
}
@@ -115,10 +116,11 @@ class TextDocumentProvider extends AbstractDocumentProvider {
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document,
boolean overwrite) throws CoreException {
-
+
if (document instanceof AnnotationDocument) {
AnnotationDocument annotationDocument = (AnnotationDocument) document;
- documentProvider.doSaveDocument(monitor, element, annotationDocument.getDocument(), overwrite);
+ documentProvider.doSaveDocument(monitor, element, annotationDocument.getDocument(),
+ overwrite);
}
// TODO:
// else throw exception ->
@@ -131,19 +133,19 @@ class TextDocumentProvider extends AbstractDocumentProvider {
@Override
protected ElementInfo createElementInfo(Object element) throws CoreException {
-
+
ElementInfo elementInfo = super.createElementInfo(element);
CasElementInfo casElementInfo = new CasElementInfo(elementInfo.fDocument, elementInfo.fModel);
casElementInfo.casInfo = documentProvider.createElementInfo(element);
-
+
return casElementInfo;
}
@Override
protected void disposeElementInfo(Object element, ElementInfo info) {
-
+
super.disposeElementInfo(element, info);
-
+
CasElementInfo casElementInfo = (CasElementInfo) info;
documentProvider.disposeElementInfo(element, casElementInfo.casInfo);
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
index 56fcce8..bdbd57a 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
@@ -19,25 +19,24 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.caseditor.editor.FeatureStructureSelection;
import org.apache.uima.caseditor.editor.ICasEditor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Deletes all selected annotations.
*/
public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes the current instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public DeleteFeatureStructureAction(ICasEditor editor) {
super("DeleteAction");
@@ -49,8 +48,7 @@ public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
@Override
protected boolean updateSelection(IStructuredSelection selection) {
- FeatureStructureSelection featureStructures =
- new FeatureStructureSelection(selection);
+ FeatureStructureSelection featureStructures = new FeatureStructureSelection(selection);
return featureStructures.size() > 0;
}
@@ -61,8 +59,8 @@ public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
@Override
public void run() {
- FeatureStructureSelection featureStructures =
- new FeatureStructureSelection(getStructuredSelection());
+ FeatureStructureSelection featureStructures = new FeatureStructureSelection(
+ getStructuredSelection());
editor.getDocument().removeFeatureStructures(featureStructures.toList());
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
index bab3e05..418ec92 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
@@ -29,22 +28,22 @@ import org.apache.uima.caseditor.editor.util.AnnotationSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Lowers the left side of the currently selected annotation by one.
*/
public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAction {
-
+
/** The Constant ID. */
public static final String ID = "LowerLeftAnnotationSide";
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes a new instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public LowerLeftAnnotationSideAction(ICasEditor editor) {
super(ID);
@@ -64,8 +63,10 @@ public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAc
/**
* Lower left annotation side.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
public static void lowerLeftAnnotationSide(ICasDocument document, AnnotationFS annotation) {
Type annotationType = annotation.getType();
@@ -77,7 +78,7 @@ public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAc
document.update(annotation);
}
-
+
/**
* Increases the begin index of an annotation by one.
*/
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
index a29cde0..67414cb 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
@@ -29,22 +28,22 @@ import org.apache.uima.caseditor.editor.util.AnnotationSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Lowers the right side of the currently selected annotation by one.
*/
public final class LowerRightAnnotationSideAction extends BaseSelectionListenerAction {
-
+
/** The Constant ID. */
public static final String ID = "LowerRightAnnotationSide";
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes the current instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public LowerRightAnnotationSideAction(ICasEditor editor) {
super(ID);
@@ -64,21 +63,23 @@ public final class LowerRightAnnotationSideAction extends BaseSelectionListenerA
/**
* Lower right annotation side.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
public static void lowerRightAnnotationSide(ICasDocument document, AnnotationFS annotation) {
-
+
Type annotationType = annotation.getType();
Feature endFeature = annotationType.getFeatureByBaseName("end");
-
+
if (annotation.getBegin() < annotation.getEnd()) {
annotation.setIntValue(endFeature, annotation.getEnd() - 1);
}
-
+
document.update(annotation);
}
-
+
/**
* Decreases the end index of an annotation by one.
*/
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
index 5c7e9c3..a90f77c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.caseditor.editor.ICasDocument;
@@ -28,26 +27,26 @@ import org.apache.uima.caseditor.editor.util.AnnotationSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Merges two or more annotations.
*
- * TODO: also merge features - if one is null or primitive has default value take the the other one -
- * in conflict case do nothing
+ * TODO: also merge features - if one is null or primitive has default value take the the other one
+ * - in conflict case do nothing
*/
public class MergeAnnotationAction extends BaseSelectionListenerAction {
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes the current instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public MergeAnnotationAction(ICasEditor editor) {
super("MergeAnnotationAction");
-
+
this.editor = editor;
setEnabled(false);
@@ -68,7 +67,7 @@ public class MergeAnnotationAction extends BaseSelectionListenerAction {
AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
ICasDocument document = editor.getDocument();
-
+
CAS documentCAS = document.getCAS();
AnnotationFS mergedAnnotation = documentCAS.createAnnotation(annotations.getFirst().getType(),
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
index 45ccb72..0783ef4 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
@@ -29,22 +28,22 @@ import org.apache.uima.caseditor.editor.util.AnnotationSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Widens the left side of the currently selected annotation by one.
*/
public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAction {
-
+
/** The Constant ID. */
public static final String ID = "WideLeftAnnotationSide";
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes a new instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public WideLeftAnnotationSideAction(ICasEditor editor) {
super("WideLeftAnnotationSside");
@@ -62,11 +61,12 @@ public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAct
}
/**
- * Widens the annotation and sends and sends an update notification
- * to the provided document.
+ * Widens the annotation and sends and sends an update notification to the provided document.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
public static void wideLeftAnnotationSide(ICasDocument document, AnnotationFS annotation) {
Type annotationType = annotation.getType();
@@ -78,7 +78,7 @@ public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAct
document.update(annotation);
}
-
+
/**
* Decreases the begin index of an annotation by one.
*/
@@ -87,7 +87,7 @@ public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAct
AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
AnnotationFS annotation = annotations.getFirst();
-
+
wideLeftAnnotationSide(editor.getDocument(), annotation);
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
index 9f4f3ac..21df6e8 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.action;
-
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.text.AnnotationFS;
@@ -29,22 +28,22 @@ import org.apache.uima.caseditor.editor.util.AnnotationSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
/**
* Widens the right side of the currently selected annotation by one.
*/
public final class WideRightAnnotationSideAction extends BaseSelectionListenerAction {
-
+
/** The Constant ID. */
public static final String ID = "WideRightAnnotationSide";
-
+
/** The editor. */
private ICasEditor editor;
/**
* Initializes a new instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public WideRightAnnotationSideAction(ICasEditor editor) {
super(ID);
@@ -64,20 +63,22 @@ public final class WideRightAnnotationSideAction extends BaseSelectionListenerAc
/**
* Wide right annotation side.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
public static void wideRightAnnotationSide(ICasDocument document, AnnotationFS annotation) {
Type annotationType = annotation.getType();
Feature endFeature = annotationType.getFeatureByBaseName("end");
-
+
if (annotation.getEnd() < document.getCAS().getDocumentText().length()) {
annotation.setIntValue(endFeature, annotation.getEnd() + 1);
}
-
+
document.update(annotation);
}
-
+
/**
* Increases the end index of an annotation by one.
*/
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java
index f758f73..a6d9462 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BackgroundDrawingStrategy.java
@@ -33,29 +33,34 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* Fills the background of an annotation.
*/
final class BackgroundDrawingStrategy implements IDrawingStrategy {
-
+
/**
* Fill the background of the given annotation in the specified color.
*
- * @param annotation the annotation
- * @param gc the gc
- * @param textWidget the text widget
- * @param offset the offset
- * @param length the length
- * @param color the color
+ * @param annotation
+ * the annotation
+ * @param gc
+ * the gc
+ * @param textWidget
+ * the text widget
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ * @param color
+ * the color
*/
@Override
- public void draw(Annotation annotation, GC gc, StyledText textWidget, int annotationBegin, int length,
- Color color) {
+ public void draw(Annotation annotation, GC gc, StyledText textWidget, int annotationBegin,
+ int length, Color color) {
if (length != 0) {
if (gc != null) {
- int annotationEnd = annotationBegin + length;
-
+ int annotationEnd = annotationBegin + length;
+
Rectangle bounds = textWidget.getTextBounds(annotationBegin, annotationEnd - 1);
// Selection in the text widget are drawn before the annotations are drawn,
@@ -63,80 +68,79 @@ final class BackgroundDrawingStrategy implements IDrawingStrategy {
// rectangle
//
// The annotation background to be drawn is a span which has a begin and end offset.
- // Inside the background are areas (spans) which should not be over drawn.
- // That can be visualized like this (annotation goes from first to last z, an
+ // Inside the background are areas (spans) which should not be over drawn.
+ // That can be visualized like this (annotation goes from first to last z, an
// X is the selection which should not be overdrawn):
//
// zzzzXXXzzzzXXXXzzzXX
//
// The z offsets should be drawn, the X offsets should not be overdrawn. That is solved
// by drawing for every z offset area one background rectangle.
-
+
List<Span> dontOverDrawSpans = new ArrayList<>();
-
+
Span annotationSpan = new Span(annotationBegin, length);
-
+
// add all style ranges to the list in the range of the annotation
for (StyleRange styleRange : textWidget.getStyleRanges(annotationBegin, length)) {
- Span styleRangeSpan = new Span(styleRange.start, styleRange.length);
- if (styleRangeSpan.getLength() > 0)
- dontOverDrawSpans.add(styleRangeSpan);
+ Span styleRangeSpan = new Span(styleRange.start, styleRange.length);
+ if (styleRangeSpan.getLength() > 0)
+ dontOverDrawSpans.add(styleRangeSpan);
}
-
+
// add text selection to the list if intersects with annotation
Point selection = textWidget.getSelection();
Span selectionSpan = new Span(selection.x, selection.y - selection.x);
if (annotationSpan.isIntersecting(selectionSpan) && selectionSpan.getLength() > 0) {
dontOverDrawSpans.add(selectionSpan);
}
-
+
Collections.sort(dontOverDrawSpans);
// TODO: Asks on mailing list for help ...
// strange that we need that here ...
- Collections.reverse(dontOverDrawSpans);
-
+ Collections.reverse(dontOverDrawSpans);
+
gc.setBackground(color);
-
+
if (dontOverDrawSpans.size() > 0) {
- int zBegin = annotationBegin;
- for (Span xSpan : dontOverDrawSpans) {
- if (xSpan.getLength() > 0 && zBegin < xSpan.getStart()) {
- Rectangle selectionBounds = textWidget.getTextBounds(zBegin, xSpan.getStart() -1);
- gc.fillRectangle(selectionBounds);
- }
-
- if (zBegin < xSpan.getEnd())
- zBegin = xSpan.getEnd();
- }
-
- // If the annotation ends with z offsets these must still be drawn
- if (zBegin < annotationEnd) {
- Rectangle selectionBounds = textWidget.getTextBounds(zBegin, annotationEnd -1);
- gc.fillRectangle(selectionBounds);
- }
- }
- else {
- Rectangle selectionBounds = textWidget.getTextBounds(annotationBegin, annotationEnd -1);
- gc.fillRectangle(selectionBounds);
+ int zBegin = annotationBegin;
+ for (Span xSpan : dontOverDrawSpans) {
+ if (xSpan.getLength() > 0 && zBegin < xSpan.getStart()) {
+ Rectangle selectionBounds = textWidget.getTextBounds(zBegin, xSpan.getStart() - 1);
+ gc.fillRectangle(selectionBounds);
+ }
+
+ if (zBegin < xSpan.getEnd())
+ zBegin = xSpan.getEnd();
+ }
+
+ // If the annotation ends with z offsets these must still be drawn
+ if (zBegin < annotationEnd) {
+ Rectangle selectionBounds = textWidget.getTextBounds(zBegin, annotationEnd - 1);
+ gc.fillRectangle(selectionBounds);
+ }
+ } else {
+ Rectangle selectionBounds = textWidget.getTextBounds(annotationBegin, annotationEnd - 1);
+ gc.fillRectangle(selectionBounds);
}
-
+
int end = annotationBegin + length - 1;
gc.setForeground(new Color(gc.getDevice(), 0, 0, 0));
-
+
// Instead of a tab draw textWidget.getTabs() spaces
String annotationText = textWidget.getText(annotationBegin, end);
-
+
if (annotationText.contains("\t")) {
- char replacementSpaces[] = new char[textWidget.getTabs()];
- for (int i = 0; i < replacementSpaces.length; i++) {
- replacementSpaces[i] = ' ';
- }
- annotationText = annotationText.replace(new String(new char[]{'\t'}), new String(replacementSpaces));
+ char replacementSpaces[] = new char[textWidget.getTabs()];
+ for (int i = 0; i < replacementSpaces.length; i++) {
+ replacementSpaces[i] = ' ';
+ }
+ annotationText = annotationText.replace(new String(new char[] { '\t' }),
+ new String(replacementSpaces));
}
gc.drawText(annotationText, bounds.x, bounds.y, true);
- }
- else {
+ } else {
textWidget.redrawRange(annotationBegin, length, true);
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BoxDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BoxDrawingStrategy.java
index 2ff0fac..8c8bda7 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BoxDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BoxDrawingStrategy.java
@@ -26,21 +26,26 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* Draws a box around an annotation.
*/
final class BoxDrawingStrategy implements IDrawingStrategy {
-
+
/**
* Draws a box around the given annotation.
*
- * @param annotation the annotation
- * @param gc the gc
- * @param textWidget the text widget
- * @param offset the offset
- * @param length the length
- * @param color the color
+ * @param annotation
+ * the annotation
+ * @param gc
+ * the gc
+ * @param textWidget
+ * the text widget
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ * @param color
+ * the color
*/
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length,
@@ -52,21 +57,20 @@ final class BoxDrawingStrategy implements IDrawingStrategy {
gc.setForeground(color);
int correctedHeight;
-
+
if (bounds.height > 0) {
- correctedHeight = bounds.height -1;
- }
- else {
+ correctedHeight = bounds.height - 1;
+ } else {
correctedHeight = bounds.height;
}
-
+
int correctedWidth;
-
+
if (bounds.width > 0)
- correctedWidth = bounds.width -1;
+ correctedWidth = bounds.width - 1;
else
correctedWidth = bounds.width;
-
+
gc.drawRectangle(bounds.x, bounds.y, correctedWidth, correctedHeight);
} else {
textWidget.redrawRange(offset, length, true);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BracketDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BracketDrawingStrategy.java
index 7aef8f6..533e688 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BracketDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/BracketDrawingStrategy.java
@@ -27,24 +27,29 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* Draws brackets around an annotation.
*/
public class BracketDrawingStrategy implements IDrawingStrategy {
-
+
/** The Constant BRACKET_WIDTH. */
private static final int BRACKET_WIDTH = 3;
/**
* Draws an opening bracket to the begin and a closing bracket to the end of the given annotation.
*
- * @param annotation the annotation
- * @param gc the gc
- * @param textWidget the text widget
- * @param offset the offset
- * @param length the length
- * @param color the color
+ * @param annotation
+ * the annotation
+ * @param gc
+ * the gc
+ * @param textWidget
+ * the text widget
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ * @param color
+ * the color
*/
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length,
@@ -60,8 +65,8 @@ public class BracketDrawingStrategy implements IDrawingStrategy {
boolean isDrawOpenBracket = annotationFS.getBegin() == offset;
if (isDrawOpenBracket) {
- gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH, bounds.y
- + bounds.height - 1);
+ gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH,
+ bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
@@ -70,11 +75,11 @@ public class BracketDrawingStrategy implements IDrawingStrategy {
boolean isDrawCloseBracket = annotationFS.getEnd() == offset + length;
if (isDrawCloseBracket) {
- gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1, bounds.x
- + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
+ gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1,
+ bounds.x + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
- gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1, bounds.y
- + bounds.height - 1);
+ gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1,
+ bounds.y + bounds.height - 1);
gc.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width - BRACKET_WIDTH,
bounds.y);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java
index 107ea61..f144ab4 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/DrawingStyle.java
@@ -26,24 +26,22 @@ import org.apache.uima.caseditor.editor.AnnotationStyle;
import org.apache.uima.caseditor.editor.AnnotationStyle.Style;
import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy;
-
/**
* A factory for drawing styles.
*
- * @see org.apache.uima.caseditor.editor.AnnotationStyle.Style
+ * @see org.apache.uima.caseditor.editor.AnnotationStyle.Style
*/
public class DrawingStyle {
/** The stateless styles. */
- private static Map<AnnotationStyle.Style, IDrawingStrategy> statelessStyles =
- new HashMap<>();
-
+ private static Map<AnnotationStyle.Style, IDrawingStrategy> statelessStyles = new HashMap<>();
+
static {
statelessStyles.put(Style.BACKGROUND, new BackgroundDrawingStrategy());
statelessStyles.put(Style.TEXT_COLOR, new TextColorDrawingStrategy());
statelessStyles.put(Style.TOKEN, new TokenDrawingStrategy());
// deprecated since 3.4, but minimum version is 3.3
- statelessStyles.put(Style.SQUIGGLES,
+ statelessStyles.put(Style.SQUIGGLES,
new org.eclipse.jface.text.source.AnnotationPainter.SquigglesStrategy());
statelessStyles.put(Style.BOX, new BoxDrawingStrategy());
statelessStyles.put(Style.UNDERLINE, new UnderlineDrawingStrategy());
@@ -59,17 +57,19 @@ public class DrawingStyle {
/**
* Retrieves the {@link IDrawingStrategy}.
*
- * @param style the style
+ * @param style
+ * the style
* @return the {@link IDrawingStrategy} or null if does not exist.
*/
public static IDrawingStrategy createStrategy(AnnotationStyle style) {
-
+
IDrawingStrategy strategy = statelessStyles.get(style.getStyle());
-
- if (strategy == null && Style.TAG.equals(style.getStyle()) && style.getConfiguration() != null) {
+
+ if (strategy == null && Style.TAG.equals(style.getStyle())
+ && style.getConfiguration() != null) {
strategy = new TagDrawingStrategy(style.getConfiguration());
}
-
+
return strategy;
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/EclipseAnnotationPeer.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/EclipseAnnotationPeer.java
index b0cd4e6..3eb7fd5 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/EclipseAnnotationPeer.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/EclipseAnnotationPeer.java
@@ -21,10 +21,9 @@ package org.apache.uima.caseditor.editor.annotation;
import org.apache.uima.cas.text.AnnotationFS;
-
/**
- * This class is used to provide additional information about the {@link AnnotationFS}
- * object to the custom drawing strategies.
+ * This class is used to provide additional information about the {@link AnnotationFS} object to the
+ * custom drawing strategies.
*/
public class EclipseAnnotationPeer extends org.eclipse.jface.text.source.Annotation {
@@ -34,7 +33,8 @@ public class EclipseAnnotationPeer extends org.eclipse.jface.text.source.Annotat
/**
* Initializes a new instance.
*
- * @param annotation the annotation
+ * @param annotation
+ * the annotation
*/
public EclipseAnnotationPeer(AnnotationFS annotation) {
super(annotation.getType().getName(), false, "");
@@ -50,7 +50,6 @@ public class EclipseAnnotationPeer extends org.eclipse.jface.text.source.Annotat
public AnnotationFS getAnnotationFS() {
return annotation;
}
-
@Override
public int hashCode() {
@@ -61,13 +60,11 @@ public class EclipseAnnotationPeer extends org.eclipse.jface.text.source.Annotat
public boolean equals(Object obj) {
if (obj == this) {
return true;
- }
- else if (obj instanceof EclipseAnnotationPeer) {
+ } else if (obj instanceof EclipseAnnotationPeer) {
EclipseAnnotationPeer peer = (EclipseAnnotationPeer) obj;
-
+
return annotation.equals(peer.annotation);
- }
- else {
+ } else {
return false;
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TagDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TagDrawingStrategy.java
index 7a180cb..1bcf1ac 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TagDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TagDrawingStrategy.java
@@ -30,127 +30,122 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-
-
-
// TODO: Check if its possible to increase the space between characters,
/**
* The Class TagDrawingStrategy.
*/
-// or suggest to use mono space font for long tags ...
+// or suggest to use mono space font for long tags ...
class TagDrawingStrategy implements IDrawingStrategy {
/** The Constant TAG_FONT_SIZE. */
private static final int TAG_FONT_SIZE = 11;
-
+
/** The Constant MAX_LEFT_TAG_OVERLAP. */
private static final int MAX_LEFT_TAG_OVERLAP = 1;
-
+
/** The Constant MAX_RIGHT_TAG_OVERLAP. */
private static final int MAX_RIGHT_TAG_OVERLAP = 1;
-
+
/** The Constant TAG_OVERLAP. */
private static final int TAG_OVERLAP = MAX_LEFT_TAG_OVERLAP + MAX_RIGHT_TAG_OVERLAP;
-
+
/** The annotation drawing style. */
private IDrawingStrategy annotationDrawingStyle = new BoxDrawingStrategy();
-
+
/**
* The name of the feature to print.
*/
private final String featureName;
-
+
/**
* Instantiates a new tag drawing strategy.
*
- * @param featureName the feature name
+ * @param featureName
+ * the feature name
*/
TagDrawingStrategy(String featureName) {
-
+
if (featureName == null)
throw new IllegalArgumentException("featureName must not be null!");
-
+
this.featureName = featureName;
}
-
+
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length,
Color color) {
-
+
// Always draw a box around the annotation itself
-
+
// TODO: It seems that the call to the box drawing strategy is rather
// expensive, test how fast it is when the box drawing is "inlined".
// The box drawing strategy could be changed to do the drawing via
// static methods
annotationDrawingStyle.draw(annotation, gc, textWidget, offset, length, color);
-
+
if (annotation instanceof EclipseAnnotationPeer) {
AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS();
-
+
Feature feature = annotationFS.getType().getFeatureByBaseName(featureName);
-
+
if (feature != null && feature.getRange().isPrimitive()) {
-
+
String featureValue = annotationFS.getFeatureValueAsString(feature);
-
+
// Annotation can be rendered into multiple lines, always draw
// the tag in the first line where annotation starts
if (featureValue != null && annotationFS.getBegin() == offset) {
-
+
// Calculate how much overhang on both sides of the annotation for a tag is allowed
int lineIndex = textWidget.getLineAtOffset(offset);
int firstCharInLineOffset = textWidget.getOffsetAtLine(lineIndex);
-
+
int maxBeginOverhang;
if (firstCharInLineOffset == offset) {
maxBeginOverhang = 0;
- }
- else {
+ } else {
maxBeginOverhang = MAX_LEFT_TAG_OVERLAP;
}
-
+
int maxEndOverhang;
int lineLength;
int lineCount = textWidget.getLineCount();
- if (lineCount > lineIndex +1) {
+ if (lineCount > lineIndex + 1) {
int offsetNextLine = textWidget.getOffsetAtLine(lineIndex + 1);
- lineLength = offsetNextLine - firstCharInLineOffset -1;
- }
- else {
+ lineLength = offsetNextLine - firstCharInLineOffset - 1;
+ } else {
// Its the last line
lineLength = textWidget.getCharCount() - offset;
}
-
+
if ((firstCharInLineOffset + lineLength) == offset + length) {
maxEndOverhang = 0;
- }
- else {
+ } else {
maxEndOverhang = MAX_RIGHT_TAG_OVERLAP;
}
-
+
Rectangle bounds = textWidget.getTextBounds(offset, offset + length);
-
+
if (gc != null) {
int lastCharIndex;
-
+
if (length == 0)
lastCharIndex = offset;
else
lastCharIndex = offset + length - 1;
-
- Point annotationStringExtent = gc.stringExtent(
- textWidget.getText(offset, lastCharIndex));
-
+
+ Point annotationStringExtent = gc
+ .stringExtent(textWidget.getText(offset, lastCharIndex));
+
Font currentFont = gc.getFont();
-
+
// TODO: Figure out if that is safe
Font tagFont = new Font(currentFont.getDevice(), currentFont.getFontData()[0].getName(),
TAG_FONT_SIZE, currentFont.getFontData()[0].getStyle());
gc.setFont(tagFont);
gc.setForeground(color);
-
+
// Cutoffs the tag if two chars longer than annotation
// and replaces it with a scissor
int maxAllowedLength = length + maxBeginOverhang + maxEndOverhang;
@@ -159,66 +154,64 @@ class TagDrawingStrategy implements IDrawingStrategy {
// Trim featureValue to substring which is length -1 + scissor symbol
char scissorChar = (char) 0x2704;
featureValue = featureValue.substring(0, maxAllowedLength - 1) + scissorChar;
- }
- else
+ } else
// If zero length annotation, just draw nothing
featureValue = "";
}
-
+
// Drawing after the end of a line, and before the begin does not work ...
Point tagStringExtent = gc.stringExtent(featureValue);
-
+
int centerOfAnnotation = annotationStringExtent.x / 2;
int centerOfTag = tagStringExtent.x / 2;
-
+
// Tag can be positioned at three different places
// if there is an overhang on both side, its centered
int newX = bounds.x + centerOfAnnotation - centerOfTag;
-
+
// Figure out if there is an overhang allowed, and recalculate the position.
-
+
// No overhang means that the annotation is the first or last in the line,
// in this case the tag should be placed as close as possible to the begin
// or end of the annotation boundary.
-
- // if no overhang on the left side allowed,
+
+ // if no overhang on the left side allowed,
// the tag must start with the annotation bound
if (maxBeginOverhang == 0) {
newX = bounds.x;
}
- // if no overhang on the right side allowed,
+ // if no overhang on the right side allowed,
// the tag must end with the annotation bound
else if (maxEndOverhang == 0) {
newX = bounds.x + (annotationStringExtent.x - tagStringExtent.x);
}
-
+
// TODO: Might not be too safe, if bounds.height == 0,
// passed parameter could be -1
gc.drawString(featureValue, newX, bounds.y + bounds.height - 1, true);
gc.setFont(currentFont);
-
+
// After done using the tag font it must be disposed, otherwise
// eclipse on windows runs out of handles and crashes
tagFont.dispose();
} else {
-
+
// The area into which the tag will be drawn must be marked
// to be redrawn, that requires a calculation of that area.
-
+
// Note: Did not find a way to calculate the tag extent correctly here
// GC.stringExtent cannot be called, because the passed GC is null
- //
+ //
// The width is assumed to be the font size multiplied by the length
// of annotation string + TAG_OVERLAP, this is not optimal, but should give
// a little to large estimate
- //
+ //
// Note: It unknown what happens if a too big area is drawn
// Doesn't seem to cause a crash on OS X
// TODO: Test that on windows 7, Windows XP and Linux
-
- textWidget.redraw(bounds.x - TAG_FONT_SIZE * TAG_OVERLAP, bounds.y + bounds.height -1,
- TAG_FONT_SIZE * (length + TAG_OVERLAP),
- bounds.height, true);
+
+ textWidget.redraw(bounds.x - TAG_FONT_SIZE * TAG_OVERLAP, bounds.y + bounds.height - 1,
+ TAG_FONT_SIZE * (length + TAG_OVERLAP), bounds.height, true);
}
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java
index 7d3b9f5..3c5bf33 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TextColorDrawingStrategy.java
@@ -26,14 +26,14 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* The Class TextColorDrawingStrategy.
*/
public class TextColorDrawingStrategy implements IDrawingStrategy {
@Override
- public void draw(Annotation annotation, GC gc, StyledText textWidget, int start, int length, Color color) {
+ public void draw(Annotation annotation, GC gc, StyledText textWidget, int start, int length,
+ Color color) {
if (length > 0) {
if (annotation instanceof EclipseAnnotationPeer) {
if (gc != null) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java
index 6fb1add..c736405 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/TokenDrawingStrategy.java
@@ -27,20 +27,21 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* The Class TokenDrawingStrategy.
*/
public class TokenDrawingStrategy implements IDrawingStrategy {
-
+
/** The Constant BRACKET_WIDTH. */
private static final int BRACKET_WIDTH = 5;
/**
* Checks if is whitespace.
*
- * @param text the text
- * @param offset the offset
+ * @param text
+ * the text
+ * @param offset
+ * the offset
* @return true, if is whitespace
*/
private static boolean isWhitespace(String text, int offset) {
@@ -60,9 +61,10 @@ public class TokenDrawingStrategy implements IDrawingStrategy {
boolean isDrawOpenBracket = annotationFS.getBegin() == offset;
// and no space before offset
- if (isDrawOpenBracket && offset > 1 && !isWhitespace(annotationFS.getCAS().getDocumentText(), offset - 1)) {
- gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH, bounds.y
- + bounds.height - 1);
+ if (isDrawOpenBracket && offset > 1
+ && !isWhitespace(annotationFS.getCAS().getDocumentText(), offset - 1)) {
+ gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH,
+ bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
@@ -73,8 +75,8 @@ public class TokenDrawingStrategy implements IDrawingStrategy {
// and no space after offset
if (isDrawCloseBracket && offset + length < textWidget.getText().length()
&& !isWhitespace(annotationFS.getCAS().getDocumentText(), offset + length)) {
- gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1, bounds.x
- + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
+ gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1,
+ bounds.x + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x + bounds.width - 1,
bounds.y + bounds.height - 1);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/UnderlineDrawingStrategy.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/UnderlineDrawingStrategy.java
index a3e336a..af8a337 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/UnderlineDrawingStrategy.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/annotation/UnderlineDrawingStrategy.java
@@ -27,7 +27,6 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-
/**
* Draws an line under an annotation.
*/
@@ -36,12 +35,18 @@ public class UnderlineDrawingStrategy implements IDrawingStrategy {
/**
* Draws a line under under a given annotation.
*
- * @param annotation the annotation
- * @param gc the gc
- * @param textWidget the text widget
- * @param offset the offset
- * @param length the length
- * @param color the color
+ * @param annotation
+ * the annotation
+ * @param gc
+ * the gc
+ * @param textWidget
+ * the text widget
+ * @param offset
+ * the offset
+ * @param length
+ * the length
+ * @param color
+ * the color
*/
@Override
public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length,
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControl.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControl.java
index 4d07235..b3927d6 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControl.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControl.java
@@ -25,13 +25,13 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-
public class AnnotationEditingControl extends Composite {
/**
* Initializes the current instance.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
public AnnotationEditingControl(Composite parent) {
super(parent, SWT.NONE);
@@ -47,7 +47,8 @@ public class AnnotationEditingControl extends Composite {
/**
* Display this feature structure.
*
- * @param structure the structure
+ * @param structure
+ * the structure
*/
public void displayFeatureStructure(FeatureStructure structure) {
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControlCreator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControlCreator.java
index abee8d9..877e744 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControlCreator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/context/AnnotationEditingControlCreator.java
@@ -19,7 +19,6 @@
package org.apache.uima.caseditor.editor.context;
-
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.caseditor.editor.CustomInformationControl;
import org.apache.uima.caseditor.editor.ICustomInformationControlContentHandler;
@@ -27,7 +26,6 @@ import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.swt.widgets.Shell;
-
/**
* TODO: add javadoc here.
*/
@@ -36,7 +34,8 @@ public class AnnotationEditingControlCreator implements IInformationControlCreat
/**
* Creates the information control.
*
- * @param parent the parent
+ * @param parent
+ * the parent
* @return the new control
*/
@Override
@@ -57,8 +56,8 @@ public class AnnotationEditingControlCreator implements IInformationControlCreat
CustomInformationControl control = new CustomInformationControl(parent, contentHandler);
- AnnotationEditingControl annotationEditingControl = new AnnotationEditingControl(control
- .getParent());
+ AnnotationEditingControl annotationEditingControl = new AnnotationEditingControl(
+ control.getParent());
control.setControl(annotationEditingControl);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IModeMenuListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IModeMenuListener.java
index c187384..23983c5 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IModeMenuListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IModeMenuListener.java
@@ -21,22 +21,19 @@ package org.apache.uima.caseditor.editor.contextmenu;
import org.apache.uima.cas.Type;
-
/**
- * The listener interface for receiving IModeMenu events.
- * The class that is interested in processing a IModeMenu
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addIModeMenuListener</code> method. When
- * the IModeMenu event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving IModeMenu events. The class that is interested in processing
+ * a IModeMenu event implements this interface, and the object created with that class is registered
+ * with a component using the component's <code>addIModeMenuListener</code> method. When the
+ * IModeMenu event occurs, that object's appropriate method is invoked.
*/
public interface IModeMenuListener {
-
- /**
- * Mode was changed to a new mode.
- *
- * @param newMode the new mode
- */
- void modeChanged(Type newMode);
+
+ /**
+ * Mode was changed to a new mode.
+ *
+ * @param newMode
+ * the new mode
+ */
+ void modeChanged(Type newMode);
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IShowAnnotationsListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IShowAnnotationsListener.java
index 5955ba2..453e1a6 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IShowAnnotationsListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/IShowAnnotationsListener.java
@@ -23,22 +23,20 @@ import java.util.Collection;
import org.apache.uima.cas.Type;
-
/**
- * The listener interface for receiving IShowAnnotations events.
- * The class that is interested in processing a IShowAnnotations
- * event implements this interface, and the object created
- * with that class is registered with a component using the
- * component's <code>addIShowAnnotationsListener</code> method. When
- * the IShowAnnotations event occurs, that object's appropriate
- * method is invoked.
+ * The listener interface for receiving IShowAnnotations events. The class that is interested in
+ * processing a IShowAnnotations event implements this interface, and the object created with that
+ * class is registered with a component using the component's
+ * <code>addIShowAnnotationsListener</code> method. When the IShowAnnotations event occurs, that
+ * object's appropriate method is invoked.
*/
public interface IShowAnnotationsListener {
-
- /**
- * Selection changed.
- *
- * @param selection the selection
- */
- void selectionChanged(Collection<Type> selection);
- }
\ No newline at end of file
+
+ /**
+ * Selection changed.
+ *
+ * @param selection
+ * the selection
+ */
+ void selectionChanged(Collection<Type> selection);
+}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ModeMenu.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ModeMenu.java
index 14f5fc7..3c80d77 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ModeMenu.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ModeMenu.java
@@ -32,23 +32,24 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-
/**
* Creates the mode context sub menu.
*/
public class ModeMenu extends TypeMenu {
-
+
/** The editor. */
private AnnotationEditor editor;
-
+
/** The listeners. */
private Set<IModeMenuListener> listeners = new HashSet<>();
/**
* Initializes a new instance.
*
- * @param typeSystem the type system
- * @param editor the editor
+ * @param typeSystem
+ * the type system
+ * @param editor
+ * the editor
*/
public ModeMenu(TypeSystem typeSystem, AnnotationEditor editor) {
super(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION), typeSystem);
@@ -58,36 +59,38 @@ public class ModeMenu extends TypeMenu {
/**
* Adds the listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void addListener(IModeMenuListener listener) {
- listeners.add(listener);
+ listeners.add(listener);
}
-
+
/**
* Removes the listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void removeListener(IModeMenuListener listener) {
- listeners.remove(listener);
+ listeners.remove(listener);
}
@Override
protected void insertAction(final Type type, Menu parentMenu) {
MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
actionItem.setText(type.getName());
-
+
if (type.equals(editor.getAnnotationMode()))
- actionItem.setSelection(true);
-
+ actionItem.setSelection(true);
+
actionItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
- for (IModeMenuListener listener : listeners) {
- listener.modeChanged(type);
- }
+ for (IModeMenuListener listener : listeners) {
+ listener.modeChanged(type);
+ }
}
});
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ShowAnnotationsMenu.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ShowAnnotationsMenu.java
index be40786..e779f87 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ShowAnnotationsMenu.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/ShowAnnotationsMenu.java
@@ -34,167 +34,171 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-
/**
* Creates the show annotations context sub menu.
*/
public class ShowAnnotationsMenu extends TypeMenu {
- /** The listeners. */
- private Set<IShowAnnotationsListener> listeners = new HashSet<>();
-
- /**
- * This collection contains all type names which are displayed in the
- * editor.
- */
- private Collection<Type> typesToDisplay = new HashSet<>();
-
- /**
- * Editor annotation mode type. This variable is only set if the editor
- * annotation mode type is not already included in the typesToDisplay
- * collection
- */
- private Type editorAnnotationMode;
-
- /**
- * Initializes a new instance.
- *
- * @param typeSystem the type system
- * @param shownTypes the shown types
- */
- public ShowAnnotationsMenu(TypeSystem typeSystem, Collection<Type> shownTypes) {
- super(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION), typeSystem);
-
- typesToDisplay.addAll(shownTypes);
- }
-
- /**
- * Adds the listener.
- *
- * @param listener the listener
- */
- public void addListener(IShowAnnotationsListener listener) {
- listeners.add(listener);
- }
-
- /**
- * Removes the listener.
- *
- * @param listener the listener
- */
- public void removeListener(IShowAnnotationsListener listener) {
- listeners.remove(listener);
- }
-
- @Override
- protected void insertAction(final Type type, Menu parentMenu) {
- final MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
- actionItem.setText(type.getName());
-
- // TODO: find another way to select the annotation mode also
- if (editorAnnotationMode != null && editorAnnotationMode.equals(type)) {
- actionItem.setSelection(true);
- }
-
- if (typesToDisplay.contains(type)) {
- actionItem.setSelection(true);
- }
-
- // TODO: move this to an action
- // do not access mTypesToDisplay directly !!!
- actionItem.addListener(SWT.Selection, new Listener() {
- @Override
+ /** The listeners. */
+ private Set<IShowAnnotationsListener> listeners = new HashSet<>();
+
+ /**
+ * This collection contains all type names which are displayed in the editor.
+ */
+ private Collection<Type> typesToDisplay = new HashSet<>();
+
+ /**
+ * Editor annotation mode type. This variable is only set if the editor annotation mode type is
+ * not already included in the typesToDisplay collection
+ */
+ private Type editorAnnotationMode;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param typeSystem
+ * the type system
+ * @param shownTypes
+ * the shown types
+ */
+ public ShowAnnotationsMenu(TypeSystem typeSystem, Collection<Type> shownTypes) {
+ super(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION), typeSystem);
+
+ typesToDisplay.addAll(shownTypes);
+ }
+
+ /**
+ * Adds the listener.
+ *
+ * @param listener
+ * the listener
+ */
+ public void addListener(IShowAnnotationsListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Removes the listener.
+ *
+ * @param listener
+ * the listener
+ */
+ public void removeListener(IShowAnnotationsListener listener) {
+ listeners.remove(listener);
+ }
+
+ @Override
+ protected void insertAction(final Type type, Menu parentMenu) {
+ final MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
+ actionItem.setText(type.getName());
+
+ // TODO: find another way to select the annotation mode also
+ if (editorAnnotationMode != null && editorAnnotationMode.equals(type)) {
+ actionItem.setSelection(true);
+ }
+
+ if (typesToDisplay.contains(type)) {
+ actionItem.setSelection(true);
+ }
+
+ // TODO: move this to an action
+ // do not access mTypesToDisplay directly !!!
+ actionItem.addListener(SWT.Selection, new Listener() {
+ @Override
public void handleEvent(Event e) {
- if (actionItem.getSelection()) {
- typesToDisplay.add(type);
-
- } else {
- typesToDisplay.remove(type);
- }
-
- fireChanged();
- }
- });
- }
-
- /**
- * Gets the selected types.
- *
- * @return the selected types
- */
- public Collection<Type> getSelectedTypes() {
- Collection<Type> selectedTypes = new LinkedList<>();
-
- if (editorAnnotationMode != null) {
- selectedTypes.add(editorAnnotationMode);
- }
-
- selectedTypes.addAll(typesToDisplay);
-
- return Collections.unmodifiableCollection(selectedTypes);
- }
-
- /**
- * Fire changed.
- */
- private void fireChanged() {
- for (IShowAnnotationsListener listener : listeners) {
- listener.selectionChanged(getSelectedTypes());
- }
- }
-
- /**
- * Sets the selected type.
- *
- * @param type the type
- * @param isShown the is shown
- */
- public void setSelectedType(Type type, boolean isShown) {
-
- if (typesToDisplay.contains(type)) {
- if (!isShown) {
- typesToDisplay.remove(type);
- fireChanged();
- }
- }
- else {
- if (isShown) {
- typesToDisplay.add(type);
- fireChanged();
- }
- }
- }
-
- /**
- * Sets the selected types.
- *
- * @param types the new selected types
- */
- public void setSelectedTypes(Collection<Type> types) {
- typesToDisplay = new HashSet<>();
- typesToDisplay.addAll(types);
-
- for (IShowAnnotationsListener listener : listeners) {
- listener.selectionChanged(getSelectedTypes());
- }
- }
-
- /**
- * Sets the editor annotation mode.
- *
- * @param newMode the new editor annotation mode
- */
- public void setEditorAnnotationMode(Type newMode) {
-
- if (typesToDisplay.contains(newMode)) {
- if (editorAnnotationMode != null) {
- editorAnnotationMode = null;
- fireChanged();
- }
- } else {
- editorAnnotationMode = newMode;
-
- fireChanged();
- }
- }
+ if (actionItem.getSelection()) {
+ typesToDisplay.add(type);
+
+ } else {
+ typesToDisplay.remove(type);
+ }
+
+ fireChanged();
+ }
+ });
+ }
+
+ /**
+ * Gets the selected types.
+ *
+ * @return the selected types
+ */
+ public Collection<Type> getSelectedTypes() {
+ Collection<Type> selectedTypes = new LinkedList<>();
+
+ if (editorAnnotationMode != null) {
+ selectedTypes.add(editorAnnotationMode);
+ }
+
+ selectedTypes.addAll(typesToDisplay);
+
+ return Collections.unmodifiableCollection(selectedTypes);
+ }
+
+ /**
+ * Fire changed.
+ */
+ private void fireChanged() {
+ for (IShowAnnotationsListener listener : listeners) {
+ listener.selectionChanged(getSelectedTypes());
+ }
+ }
+
+ /**
+ * Sets the selected type.
+ *
+ * @param type
+ * the type
+ * @param isShown
+ * the is shown
+ */
+ public void setSelectedType(Type type, boolean isShown) {
+
+ if (typesToDisplay.contains(type)) {
+ if (!isShown) {
+ typesToDisplay.remove(type);
+ fireChanged();
+ }
+ } else {
+ if (isShown) {
+ typesToDisplay.add(type);
+ fireChanged();
+ }
+ }
+ }
+
+ /**
+ * Sets the selected types.
+ *
+ * @param types
+ * the new selected types
+ */
+ public void setSelectedTypes(Collection<Type> types) {
+ typesToDisplay = new HashSet<>();
+ typesToDisplay.addAll(types);
+
+ for (IShowAnnotationsListener listener : listeners) {
+ listener.selectionChanged(getSelectedTypes());
+ }
+ }
+
+ /**
+ * Sets the editor annotation mode.
+ *
+ * @param newMode
+ * the new editor annotation mode
+ */
+ public void setEditorAnnotationMode(Type newMode) {
+
+ if (typesToDisplay.contains(newMode)) {
+ if (editorAnnotationMode != null) {
+ editorAnnotationMode = null;
+ fireChanged();
+ }
+ } else {
+ editorAnnotationMode = newMode;
+
+ fireChanged();
+ }
+ }
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/TypeMenu.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/TypeMenu.java
index c7df532..15ca66c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/TypeMenu.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/contextmenu/TypeMenu.java
@@ -28,87 +28,92 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
-
/**
* Abstract base class for menus which display the type hierarchy.
*/
abstract class TypeMenu extends ContributionItem {
-
- /** The m parent type. */
- private Type mParentType;
-
- /** The m type system. */
- private TypeSystem mTypeSystem;
-
- /**
- * Initializes a new instance.
- *
- * @param parentType the parent type
- * @param typeSystem the type system
- */
- TypeMenu(Type parentType, TypeSystem typeSystem) {
- mParentType = parentType;
- mTypeSystem = typeSystem;
- }
- /**
- * Fills the menu with type entries.
- *
- * @param menu the menu
- * @param index the index
- */
- @Override
- public void fill(Menu menu, int index) {
- fillTypeMenu(mParentType, menu, false);
- }
+ /** The m parent type. */
+ private Type mParentType;
+
+ /** The m type system. */
+ private TypeSystem mTypeSystem;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param parentType
+ * the parent type
+ * @param typeSystem
+ * the type system
+ */
+ TypeMenu(Type parentType, TypeSystem typeSystem) {
+ mParentType = parentType;
+ mTypeSystem = typeSystem;
+ }
+
+ /**
+ * Fills the menu with type entries.
+ *
+ * @param menu
+ * the menu
+ * @param index
+ * the index
+ */
+ @Override
+ public void fill(Menu menu, int index) {
+ fillTypeMenu(mParentType, menu, false);
+ }
+
+ /**
+ * Fill type menu.
+ *
+ * @param parentType
+ * the parent type
+ * @param parentMenu
+ * the parent menu
+ * @param isParentIncluded
+ * the is parent included
+ */
+ private void fillTypeMenu(Type parentType, Menu parentMenu, boolean isParentIncluded) {
- /**
- * Fill type menu.
- *
- * @param parentType the parent type
- * @param parentMenu the parent menu
- * @param isParentIncluded the is parent included
- */
- private void fillTypeMenu(Type parentType, Menu parentMenu,
- boolean isParentIncluded) {
-
- List<Type> childs = mTypeSystem.getDirectSubtypes(parentType);
-
- Menu newSubMenu;
-
- // has this type sub types ?
- // yes
- if (childs.size() != 0) {
-
- if (isParentIncluded) {
- MenuItem subMenuItem = new MenuItem(parentMenu, SWT.CASCADE);
- subMenuItem.setText(parentType.getName());
-
- newSubMenu = new Menu(subMenuItem);
- subMenuItem.setMenu(newSubMenu);
- }
- else {
- newSubMenu = parentMenu;
- }
-
- insertAction(parentType, newSubMenu);
-
- for (Type child : childs) {
- fillTypeMenu(child, newSubMenu, true);
- }
+ List<Type> childs = mTypeSystem.getDirectSubtypes(parentType);
+
+ Menu newSubMenu;
+
+ // has this type sub types ?
+ // yes
+ if (childs.size() != 0) {
+
+ if (isParentIncluded) {
+ MenuItem subMenuItem = new MenuItem(parentMenu, SWT.CASCADE);
+ subMenuItem.setText(parentType.getName());
+
+ newSubMenu = new Menu(subMenuItem);
+ subMenuItem.setMenu(newSubMenu);
+ } else {
+ newSubMenu = parentMenu;
}
- // no
- else {
- insertAction(parentType, parentMenu);
+
+ insertAction(parentType, newSubMenu);
+
+ for (Type child : childs) {
+ fillTypeMenu(child, newSubMenu, true);
}
}
-
- /**
- * Implementing classes must implement this method to insert
- * actions into the type menu.
- *
- * @param type the type
- * @param parentMenu the parent menu
- */
- protected abstract void insertAction(final Type type, Menu parentMenu);
+ // no
+ else {
+ insertAction(parentType, parentMenu);
+ }
}
+
+ /**
+ * Implementing classes must implement this method to insert actions into the type menu.
+ *
+ * @param type
+ * the type
+ * @param parentMenu
+ * the parent menu
+ */
+ protected abstract void insertAction(final Type type, Menu parentMenu);
+}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
index f263148..a89948d 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
@@ -15,7 +15,8 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */package org.apache.uima.caseditor.editor.editview;
+ */
+package org.apache.uima.caseditor.editor.editview;
import java.util.Collection;
import java.util.HashSet;
@@ -39,7 +40,6 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-
/**
* The Class CreateFeatureStructureDialog.
*/
@@ -75,9 +75,12 @@ public class CreateFeatureStructureDialog extends IconAndMessageDialog {
/**
* Initializes a the current instance.
*
- * @param parentShell the parent shell
- * @param superType the super type
- * @param typeSystem the type system
+ * @param parentShell
+ * the parent shell
+ * @param superType
+ * the super type
+ * @param typeSystem
+ * the type system
*/
protected CreateFeatureStructureDialog(Shell parentShell, Type superType, TypeSystem typeSystem) {
@@ -118,7 +121,8 @@ public class CreateFeatureStructureDialog extends IconAndMessageDialog {
/**
* Enable size enter.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
private void enableSizeEnter(Composite parent) {
@@ -178,13 +182,13 @@ public class CreateFeatureStructureDialog extends IconAndMessageDialog {
labelAndText.setLayoutData(labelAndTextData);
if (!superType.isArray()) {
-
+
Composite typePanel = new Composite(labelAndText, SWT.NULL);
-
+
GridLayout typePanelLayout = new GridLayout();
typePanelLayout.numColumns = 2;
typePanel.setLayout(typePanelLayout);
-
+
Label typeLabel = new Label(typePanel, SWT.NONE);
typeLabel.setText("Type: ");
@@ -224,7 +228,6 @@ public class CreateFeatureStructureDialog extends IconAndMessageDialog {
return labelAndText;
}
-
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, "Create", true);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java
index cd39594..e3ae5a8 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java
@@ -24,9 +24,8 @@ import org.apache.uima.caseditor.editor.ICasDocument;
import org.apache.uima.caseditor.editor.ICasEditor;
import org.eclipse.ui.part.IPageBookViewPage;
-
public final class EditView extends CasEditorView {
-
+
/**
* The ID of the feature structure view.
*/
@@ -39,7 +38,7 @@ public final class EditView extends CasEditorView {
* Instantiates a new edits the view.
*/
public EditView() {
- super("The edit view is currently not available.");
+ super("The edit view is currently not available.");
}
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
index b8c03d8..7205fe5 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
@@ -85,15 +85,13 @@ import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.eclipse.ui.part.Page;
-
/**
- * The {@link EditViewPage} provides basic editing support for {@link FeatureStructure}s.
- * It shows always the selected {@link FeatureStructure}, but for editing a certain
- * {@link FeatureStructure} can be pinned to the view (selection updates disabled).
+ * The {@link EditViewPage} provides basic editing support for {@link FeatureStructure}s. It shows
+ * always the selected {@link FeatureStructure}, but for editing a certain {@link FeatureStructure}
+ * can be pinned to the view (selection updates disabled).
*
- * For editing the {@link Feature}s of the {@link FeatureStructure} are shown in
- * a tree with two columns. The values of the {@link Feature} can be changed with
- * cell editors.
+ * For editing the {@link Feature}s of the {@link FeatureStructure} are shown in a tree with two
+ * columns. The values of the {@link Feature} can be changed with cell editors.
*
* Note: Lists type are currently not supported
*/
@@ -103,11 +101,12 @@ final class EditViewPage extends Page implements ISelectionListener {
* The Class ValueEditingSupport.
*/
private final class ValueEditingSupport extends EditingSupport {
-
+
/**
* Instantiates a new value editing support.
*
- * @param viewer the viewer
+ * @param viewer
+ * the viewer
*/
private ValueEditingSupport(ColumnViewer viewer) {
super(viewer);
@@ -120,8 +119,7 @@ final class EditViewPage extends Page implements ISelectionListener {
FeatureValue value = (FeatureValue) element;
return value.getFeature().getRange().isPrimitive();
- }
- else if (element instanceof ArrayValue) {
+ } else if (element instanceof ArrayValue) {
ArrayValue value = (ArrayValue) element;
@@ -129,16 +127,12 @@ final class EditViewPage extends Page implements ISelectionListener {
if (arrayFS instanceof ArrayFS) {
return false;
- }
- else if (arrayFS instanceof CommonArrayFS ||
- arrayFS instanceof StringArrayFS) {
+ } else if (arrayFS instanceof CommonArrayFS || arrayFS instanceof StringArrayFS) {
return true;
- }
- else {
+ } else {
throw new CasEditorError("Unkown array type");
}
- }
- else {
+ } else {
throw new CasEditorError("Unkown element type!");
}
}
@@ -155,16 +149,15 @@ final class EditViewPage extends Page implements ISelectionListener {
if (value.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
editor = new CheckboxCellEditor(viewer.getTree(), SWT.CHECK);
- }
- else {
+ } else {
editor = new TextCellEditor(viewer.getTree());
editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
- .getPrimitiveClass(value.getFeatureStructure().getCAS().getTypeSystem(), value.getFeature())));
+ .getPrimitiveClass(value.getFeatureStructure().getCAS().getTypeSystem(),
+ value.getFeature())));
}
return editor;
- }
- else {
+ } else {
return null;
}
} else if (element instanceof ArrayValue) {
@@ -177,39 +170,30 @@ final class EditViewPage extends Page implements ISelectionListener {
if (arrayFS instanceof BooleanArrayFS) {
editor = new CheckboxCellEditor(viewer.getTree(), SWT.CHECK);
- }
- else {
+ } else {
editor = new TextCellEditor(viewer.getTree());
if (arrayFS instanceof ByteArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Byte.class));
- }
- else if (arrayFS instanceof ShortArrayFS) {
+ } else if (arrayFS instanceof ShortArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Short.class));
- }
- else if (arrayFS instanceof IntArrayFS) {
+ } else if (arrayFS instanceof IntArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Integer.class));
- }
- else if (arrayFS instanceof LongArrayFS) {
+ } else if (arrayFS instanceof LongArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Long.class));
- }
- else if (arrayFS instanceof FloatArrayFS) {
+ } else if (arrayFS instanceof FloatArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Float.class));
- }
- else if (arrayFS instanceof DoubleArrayFS) {
+ } else if (arrayFS instanceof DoubleArrayFS) {
editor.setValidator(CellEditorValidatorFacotory.createValidator(Double.class));
- }
- else if (arrayFS instanceof StringArrayFS) {
+ } else if (arrayFS instanceof StringArrayFS) {
// no validator needed
- }
- else {
+ } else {
throw new CasEditorError("Unknown array type: " + arrayFS.getClass().getName());
}
}
return editor;
- }
- else {
+ } else {
throw new CasEditorError("Unknown element type: " + element.getClass().getName());
}
}
@@ -222,28 +206,26 @@ final class EditViewPage extends Page implements ISelectionListener {
// if not a boolean return string value,
// otherwise return boolean number
- if (!featureValue.getFeature().getRange().getName().equals(
- CAS.TYPE_NAME_BOOLEAN)) {
- return Primitives.getPrimitive(featureValue.getFeatureStructure(), featureValue.getFeature()).toString();
- }
- else {
+ if (!featureValue.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
+ return Primitives
+ .getPrimitive(featureValue.getFeatureStructure(), featureValue.getFeature())
+ .toString();
+ } else {
// for booleans
- return Primitives.getPrimitive(featureValue.getFeatureStructure(), featureValue.getFeature());
+ return Primitives.getPrimitive(featureValue.getFeatureStructure(),
+ featureValue.getFeature());
}
- }
- else if (element instanceof ArrayValue) {
- ArrayValue value = (ArrayValue) element;
+ } else if (element instanceof ArrayValue) {
+ ArrayValue value = (ArrayValue) element;
- // if not a boolean array return string value
- if (!(value.getFeatureStructure() instanceof BooleanArrayFS)) {
- return value.get().toString();
- }
- else {
- return value.get();
- }
- }
- else {
+ // if not a boolean array return string value
+ if (!(value.getFeatureStructure() instanceof BooleanArrayFS)) {
+ return value.get().toString();
+ } else {
+ return value.get();
+ }
+ } else {
throw new CasEditorError("Unkown element type!");
}
}
@@ -258,18 +240,17 @@ final class EditViewPage extends Page implements ISelectionListener {
FeatureValue featureValue = (FeatureValue) element;
// for all other than boolean values
- if (!featureValue.getFeature().getRange().getName().equals(
- CAS.TYPE_NAME_BOOLEAN)) {
+ if (!featureValue.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
if (featureValue.getFeature().getRange().isPrimitive()) {
// TODO: try to prevent setting of invalid annotation span values
- featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(),
- (String) value);
+ featureValue.getFeatureStructure()
+ .setFeatureValueFromString(featureValue.getFeature(), (String) value);
}
- }
- else {
- featureValue.getFeatureStructure().setBooleanValue(featureValue.getFeature(),(Boolean) value);
+ } else {
+ featureValue.getFeatureStructure().setBooleanValue(featureValue.getFeature(),
+ (Boolean) value);
}
document.update(featureValue.getFeatureStructure());
@@ -281,8 +262,7 @@ final class EditViewPage extends Page implements ISelectionListener {
if (!(arrayValue.getFeatureStructure() instanceof BooleanArrayFS)) {
arrayValue.set((String) value);
- }
- else {
+ } else {
arrayValue.set(value.toString());
}
@@ -295,7 +275,6 @@ final class EditViewPage extends Page implements ISelectionListener {
}
}
-
/**
* The Class DeleteFeatureStructureValue.
*/
@@ -325,13 +304,13 @@ final class EditViewPage extends Page implements ISelectionListener {
document.update(featureValue.getFeatureStructure());
}
} else if (element instanceof ArrayValue) {
- ArrayValue arrayValue = (ArrayValue) element;
+ ArrayValue arrayValue = (ArrayValue) element;
- ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
+ ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
- array.set(arrayValue.slot(), null);
+ array.set(arrayValue.slot(), null);
- document.update(array);
+ document.update(array);
}
}
@@ -344,17 +323,16 @@ final class EditViewPage extends Page implements ISelectionListener {
if (selection.getFirstElement() instanceof FeatureValue) {
FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
- result = !featureValue.getFeature().getRange().isPrimitive() &&
- featureValue.getFeatureStructure().getFeatureValue(featureValue.getFeature()) != null;
- }
- else if (selection.getFirstElement() instanceof ArrayValue) {
+ result = !featureValue.getFeature().getRange().isPrimitive() && featureValue
+ .getFeatureStructure().getFeatureValue(featureValue.getFeature()) != null;
+ } else if (selection.getFirstElement() instanceof ArrayValue) {
ArrayValue arrayValue = (ArrayValue) selection.getFirstElement();
- if (arrayValue.getFeatureStructure() instanceof ArrayFS) {
- ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
+ if (arrayValue.getFeatureStructure() instanceof ArrayFS) {
+ ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
- result = array.get(arrayValue.slot()) != null;
- }
+ result = array.get(arrayValue.slot()) != null;
+ }
}
}
@@ -377,12 +355,13 @@ final class EditViewPage extends Page implements ISelectionListener {
setEnabled(false);
}
-
/**
* Creates the FS.
*
- * @param type the type
- * @param arraySize the array size
+ * @param type
+ * the type
+ * @param arraySize
+ * the array size
* @return the feature structure
*/
FeatureStructure createFS(Type type, int arraySize) {
@@ -427,28 +406,25 @@ final class EditViewPage extends Page implements ISelectionListener {
default:
throw new CasEditorError("Unkown array type: " + type.getName() + "!");
}
- }
- else if (ts.subsumes(ts.getType(CAS.TYPE_NAME_ANNOTATION), type)) {
+ } else if (ts.subsumes(ts.getType(CAS.TYPE_NAME_ANNOTATION), type)) {
- // get begin of selection from editor, if any
- // TODO: Add an interface to retrieve the span from the editor
+ // get begin of selection from editor, if any
+ // TODO: Add an interface to retrieve the span from the editor
- int begin = 0;
- int end = 0;
+ int begin = 0;
+ int end = 0;
- if (editor instanceof AnnotationEditor) {
- Point selection = ((AnnotationEditor) editor).getSelection();
+ if (editor instanceof AnnotationEditor) {
+ Point selection = ((AnnotationEditor) editor).getSelection();
- begin = selection.x;
- end = selection.y;
- }
+ begin = selection.x;
+ end = selection.y;
+ }
- fs = document.getCAS().createAnnotation(type, begin, end);
- }
- else if (!type.isArray()) {
+ fs = document.getCAS().createAnnotation(type, begin, end);
+ } else if (!type.isArray()) {
fs = document.getCAS().createFS(type);
- }
- else {
+ } else {
throw new TaeError("Unexpected error!");
}
@@ -467,29 +443,27 @@ final class EditViewPage extends Page implements ISelectionListener {
Type fsSuperType = featureValue.getFeature().getRange();
if (!fsSuperType.isArray()) {
- List<Type> subTypes =
- document.getCAS().getTypeSystem().getProperlySubsumedTypes(fsSuperType);
+ List<Type> subTypes = document.getCAS().getTypeSystem()
+ .getProperlySubsumedTypes(fsSuperType);
Type typeToCreate;
int arraySize = -1;
if (subTypes.size() == 0) {
typeToCreate = fsSuperType;
- }
- else {
- CreateFeatureStructureDialog createFsDialog =
- new CreateFeatureStructureDialog(Display.getCurrent()
- .getActiveShell(), fsSuperType, document.getCAS().getTypeSystem());
-
- int returnCode = createFsDialog.open();
-
- if (returnCode == IDialogConstants.OK_ID) {
- typeToCreate = createFsDialog.getType();
- arraySize = createFsDialog.getArraySize();
- }
- else {
- return;
- }
+ } else {
+ CreateFeatureStructureDialog createFsDialog = new CreateFeatureStructureDialog(
+ Display.getCurrent().getActiveShell(), fsSuperType,
+ document.getCAS().getTypeSystem());
+
+ int returnCode = createFsDialog.open();
+
+ if (returnCode == IDialogConstants.OK_ID) {
+ typeToCreate = createFsDialog.getType();
+ arraySize = createFsDialog.getArraySize();
+ } else {
+ return;
+ }
}
newValue = createFS(typeToCreate, arraySize);
@@ -498,8 +472,9 @@ final class EditViewPage extends Page implements ISelectionListener {
} else {
Type arrayType = featureValue.getFeature().getRange();
- CreateFeatureStructureDialog createArrayDialog = new CreateFeatureStructureDialog(Display.getCurrent()
- .getActiveShell(), arrayType, document.getCAS().getTypeSystem());
+ CreateFeatureStructureDialog createArrayDialog = new CreateFeatureStructureDialog(
+ Display.getCurrent().getActiveShell(), arrayType,
+ document.getCAS().getTypeSystem());
int returnCode = createArrayDialog.open();
@@ -512,17 +487,14 @@ final class EditViewPage extends Page implements ISelectionListener {
featureValue.getFeatureStructure().setFeatureValue(featureValue.getFeature(), newValue);
document.update(featureValue.getFeatureStructure());
- }
- else if (selection.getFirstElement() instanceof ArrayValue) {
+ } else if (selection.getFirstElement() instanceof ArrayValue) {
ArrayValue value = (ArrayValue) selection.getFirstElement();
-
TypeSystem typeSystem = document.getCAS().getTypeSystem();
- CreateFeatureStructureDialog createFsDialog =
- new CreateFeatureStructureDialog(Display.getCurrent()
- .getActiveShell(), typeSystem.getType(CAS.TYPE_NAME_TOP),
- typeSystem);
+ CreateFeatureStructureDialog createFsDialog = new CreateFeatureStructureDialog(
+ Display.getCurrent().getActiveShell(), typeSystem.getType(CAS.TYPE_NAME_TOP),
+ typeSystem);
int returnCode = createFsDialog.open();
@@ -548,10 +520,9 @@ final class EditViewPage extends Page implements ISelectionListener {
if (selection.getFirstElement() instanceof FeatureValue) {
FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
- result = !featureValue.getFeature().getRange().isPrimitive() &&
- featureValue.getFeatureStructure().getFeatureValue(featureValue.getFeature()) == null;
- }
- else if (selection.getFirstElement() instanceof ArrayValue) {
+ result = !featureValue.getFeature().getRange().isPrimitive() && featureValue
+ .getFeatureStructure().getFeatureValue(featureValue.getFeature()) == null;
+ } else if (selection.getFirstElement() instanceof ArrayValue) {
ArrayValue value = (ArrayValue) selection.getFirstElement();
if (value.getFeatureStructure() instanceof ArrayFS) {
@@ -572,7 +543,7 @@ final class EditViewPage extends Page implements ISelectionListener {
* The Class PinAction.
*/
private static final class PinAction extends Action {
-
+
/**
* Instantiates a new pin action.
*/
@@ -586,7 +557,7 @@ final class EditViewPage extends Page implements ISelectionListener {
/** The document. */
private ICasDocument document;
-
+
/** The editor. */
private ICasEditor editor;
@@ -599,15 +570,18 @@ final class EditViewPage extends Page implements ISelectionListener {
/**
* Instantiates a new edits the view page.
*
- * @param editView the edit view
- * @param editor the editor
- * @param document the document
+ * @param editView
+ * the edit view
+ * @param editor
+ * the editor
+ * @param document
+ * the document
*/
EditViewPage(EditView editView, ICasEditor editor, ICasDocument document) {
- if (editView == null || document == null) {
- throw new IllegalArgumentException("Parameters must not be null!");
- }
+ if (editView == null || document == null) {
+ throw new IllegalArgumentException("Parameters must not be null!");
+ }
this.editView = editView;
this.editor = editor;
@@ -639,9 +613,7 @@ final class EditViewPage extends Page implements ISelectionListener {
valueColumn.setEditingSupport(new ValueEditingSupport(viewer));
-
- FeatureStructureContentProvider contentProvider =
- new FeatureStructureContentProvider(document);
+ FeatureStructureContentProvider contentProvider = new FeatureStructureContentProvider(document);
viewer.setContentProvider(contentProvider);
@@ -741,7 +713,6 @@ final class EditViewPage extends Page implements ISelectionListener {
}
});
-
DragSource source = new DragSource(viewer.getTree(), DND.DROP_COPY);
source.setTransfer(new Transfer[] { FeatureStructureTransfer.getInstance() });
@@ -823,8 +794,7 @@ final class EditViewPage extends Page implements ISelectionListener {
getSite().getSelectionProvider().addSelectionChangedListener(deleteAction);
- actionBars.getToolBarManager().add(
- ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
+ actionBars.getToolBarManager().add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
}
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java
index 493ffb9..c95ad6c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java
@@ -25,7 +25,6 @@ import org.apache.uima.caseditor.editor.FeatureValue;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
-
/**
* The Class FeatureColumnLabelProvider.
*/
@@ -41,13 +40,11 @@ final class FeatureColumnLabelProvider extends CellLabelProvider {
cell.setText(featureValue.getFeature().getShortName());
- }
- else if (element instanceof ArrayValue) {
+ } else if (element instanceof ArrayValue) {
ArrayValue arrayValue = (ArrayValue) cell.getElement();
cell.setText(Integer.toString(arrayValue.slot()));
- }
- else {
+ } else {
throw new CasEditorError("Unkown element!");
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
index cfbe244..1802f08 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
@@ -37,7 +37,6 @@ import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
-
/**
* The Class FeatureStructureContentProvider.
*/
@@ -53,7 +52,8 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
/**
* Instantiates a new feature structure content provider.
*
- * @param document the document
+ * @param document
+ * the document
*/
FeatureStructureContentProvider(ICasDocument document) {
@@ -67,7 +67,8 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
/**
* Array size.
*
- * @param value the value
+ * @param value
+ * the value
* @return the int
*/
private int arraySize(FeatureStructure value) {
@@ -115,8 +116,7 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
}
return featureValues.toArray();
- }
- else {
+ } else {
int size = arraySize(featureStructure);
ArrayValue arrayValues[] = new ArrayValue[size];
@@ -170,7 +170,7 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
@Override
public void removed(Collection<FeatureStructure> deletedFeatureStructure) {
- for(FeatureStructure fs : deletedFeatureStructure) {
+ for (FeatureStructure fs : deletedFeatureStructure) {
if (viewer.getInput() == fs) {
viewer.setInput(null);
break;
@@ -210,8 +210,7 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
ArrayFS array = (ArrayFS) value.getFeatureStructure();
return getElements(array.get(value.slot()));
- }
- else {
+ } else {
throw new CasEditorError("Unexpected element type!");
}
}
@@ -224,14 +223,14 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
/**
* Checks for children.
*
- * @param value the value
+ * @param value
+ * the value
* @return true, if successful
*/
private boolean hasChildren(FeatureStructure value) {
boolean result;
-
if (value != null) {
if (value.getType().isArray()) {
@@ -255,8 +254,7 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
if (value.getFeature().getRange().isPrimitive()) {
return false;
- }
- else {
+ } else {
return hasChildren((FeatureStructure) value.getValue());
}
} else if (element instanceof ArrayValue) {
@@ -268,13 +266,11 @@ final class FeatureStructureContentProvider extends AbstractDocumentListener
ArrayFS array = (ArrayFS) value.getFeatureStructure();
return hasChildren(array.get(value.slot()));
- }
- else {
+ } else {
// false for primitive arrays
return false;
}
- }
- else {
+ } else {
throw new CasEditorError("Unkown element type");
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java
index cf756f7..77825e0 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java
@@ -28,7 +28,6 @@ import org.apache.uima.caseditor.editor.util.Primitives;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
-
/**
* Provides the labels for the edit view.
*/
@@ -43,9 +42,10 @@ final class ValueColumnLabelProvider extends CellLabelProvider {
FeatureValue featureValue = (FeatureValue) element;
if (featureValue.getFeature().getRange().isPrimitive()) {
- cell.setText(Primitives.getPrimitive(featureValue.getFeatureStructure(), featureValue.getFeature()).toString());
- }
- else {
+ cell.setText(Primitives
+ .getPrimitive(featureValue.getFeatureStructure(), featureValue.getFeature())
+ .toString());
+ } else {
FeatureStructure value = (FeatureStructure) featureValue.getValue();
if (value == null) {
@@ -54,8 +54,7 @@ final class ValueColumnLabelProvider extends CellLabelProvider {
cell.setText("[" + value.getType().getShortName() + "]");
}
}
- }
- else if (element instanceof ArrayValue) {
+ } else if (element instanceof ArrayValue) {
ArrayValue value = (ArrayValue) element;
@@ -66,16 +65,13 @@ final class ValueColumnLabelProvider extends CellLabelProvider {
if (fs == null) {
cell.setText("null");
- }
- else {
+ } else {
cell.setText("[" + fs.getType().getShortName() + "]");
}
- }
- else {
+ } else {
cell.setText(value.get().toString());
}
- }
- else {
+ } else {
throw new CasEditorError("Unknown element!");
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ByteCellEditorValidator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ByteCellEditorValidator.java
index f146a47..63f3a14 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ByteCellEditorValidator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ByteCellEditorValidator.java
@@ -21,9 +21,9 @@ package org.apache.uima.caseditor.editor.editview.validator;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
- * This {@link ICellEditorValidator} validates {@link String} values which represents a {@link Byte}.
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a
+ * {@link Byte}.
*
* For validation {@link Byte#parseByte(String)} is used.
*/
@@ -32,7 +32,8 @@ public class ByteCellEditorValidator implements ICellEditorValidator {
/**
* Checks if the given value is a valid {@link Byte}.
*
- * @param value the value
+ * @param value
+ * the value
* @return null if valid otherwise an error message
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java
index 86db772..fce4fcc 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java
@@ -24,12 +24,11 @@ import java.util.Map;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
* TODO: add javadoc here.
*/
public class CellEditorValidatorFacotory {
-
+
/** The s validator map. */
private static Map<Class<?>, ICellEditorValidator> sValidatorMap = new HashMap<>();
@@ -52,7 +51,8 @@ public class CellEditorValidatorFacotory {
* Retrieves the appropriate {@link ICellEditorValidator} for the given class or none if not
* available.
*
- * @param type the type
+ * @param type
+ * the type
* @return {@link ICellEditorValidator} or null
*/
public static ICellEditorValidator createValidator(Class<?> type) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java
index 0760ff5..aec109c 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java
@@ -21,7 +21,6 @@ package org.apache.uima.caseditor.editor.editview.validator;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
* This {@link ICellEditorValidator} validates {@link String} values which represents a
* {@link Float}.
@@ -29,11 +28,12 @@ import org.eclipse.jface.viewers.ICellEditorValidator;
* For validation {@link Float#parseFloat(String)} is used.
*/
class FloatCellEditorValidator implements ICellEditorValidator {
-
+
/**
* Checks if the given value is a valid {@link Float}.
*
- * @param value the value
+ * @param value
+ * the value
* @return null if valid otherwise an error message
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java
index 9c07c09..f87974b 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java
@@ -21,7 +21,6 @@ package org.apache.uima.caseditor.editor.editview.validator;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
* This {@link ICellEditorValidator} validates {@link String} values which represents a
* {@link Integer}.
@@ -29,11 +28,12 @@ import org.eclipse.jface.viewers.ICellEditorValidator;
* For validation {@link Integer#parseInt(String)} is used.
*/
class IntegerCellEditorValidator implements ICellEditorValidator {
-
+
/**
* Checks if the given value is a valid {@link Integer}.
*
- * @param value the value
+ * @param value
+ * the value
* @return null if valid otherwise an error message
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java
index f642950..ed188c4 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java
@@ -21,9 +21,9 @@ package org.apache.uima.caseditor.editor.editview.validator;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
- * This {@link ICellEditorValidator} validates {@link String} values which represents a {@link Long}.
+ * This {@link ICellEditorValidator} validates {@link String} values which represents a
+ * {@link Long}.
*
* For validation {@link Long#parseLong(String)} is used.
*/
@@ -32,7 +32,8 @@ public class LongCellEditorValidator implements ICellEditorValidator {
/**
* Checks if the given value is a valid {@link Long}.
*
- * @param value the value
+ * @param value
+ * the value
* @return null if valid otherwise an error message
*/
@Override
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java
index 12b142c..248d659 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java
@@ -21,7 +21,6 @@ package org.apache.uima.caseditor.editor.editview.validator;
import org.eclipse.jface.viewers.ICellEditorValidator;
-
/**
* This {@link ICellEditorValidator} validates {@link String} values which represents a
* {@link Short}.
@@ -33,7 +32,8 @@ public class ShortCellEditorValidator implements ICellEditorValidator {
/**
* Checks if the given value is a valid {@link Short}.
*
- * @param value the value
+ * @param value
+ * the value
* @return null if valid otherwise an error message
*/
@Override
@@ -49,4 +49,3 @@ public class ShortCellEditorValidator implements ICellEditorValidator {
return null;
}
}
-
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java
index 7672af5..84c6b5e 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java
@@ -24,10 +24,9 @@ import org.apache.uima.caseditor.editor.ICasDocument;
import org.apache.uima.caseditor.editor.ICasEditor;
import org.eclipse.ui.part.IPageBookViewPage;
-
/**
- * The Feature Structure Browser View displays a list of feature structures which
- * belong to the selected type.
+ * The Feature Structure Browser View displays a list of feature structures which belong to the
+ * selected type.
*/
public final class FeatureStructureBrowserView extends CasEditorView {
/**
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
index 5d89b44..baeefb5 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
@@ -61,15 +61,14 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.Page;
-
/**
* The actual view page which contains the ui code for this view.
*/
public final class FeatureStructureBrowserViewPage extends Page {
-
+
/** The Constant LAST_SELECTED_FS_TYPE. */
private static final String LAST_SELECTED_FS_TYPE = "lastSelectedFeatureStructureBrowserViewType";
-
+
/**
* The Class FeatureStructureTreeContentProvider.
*/
@@ -85,7 +84,8 @@ public final class FeatureStructureBrowserViewPage extends Page {
/**
* Instantiates a new feature structure tree content provider.
*
- * @param document the document
+ * @param document
+ * the document
*/
FeatureStructureTreeContentProvider(ICasDocument document) {
mDocument = document;
@@ -105,8 +105,7 @@ public final class FeatureStructureBrowserViewPage extends Page {
List<ModelFeatureStructure> featureStructureList = new LinkedList<>();
while (strictTypeIterator.hasNext()) {
- featureStructureList.add(new ModelFeatureStructure(mDocument,
- strictTypeIterator.next()));
+ featureStructureList.add(new ModelFeatureStructure(mDocument, strictTypeIterator.next()));
}
ModelFeatureStructure[] featureStructureArray = new ModelFeatureStructure[featureStructureList
@@ -151,7 +150,8 @@ public final class FeatureStructureBrowserViewPage extends Page {
/**
* Retrieves children for a FeatureStrcuture and for FeatureValues if they have children.
*
- * @param parentElement the parent element
+ * @param parentElement
+ * the parent element
* @return the children
*/
@Override
@@ -241,8 +241,7 @@ public final class FeatureStructureBrowserViewPage extends Page {
@Override
public void added(Collection<FeatureStructure> structures) {
- final LinkedList<ModelFeatureStructure> featureStructureList =
- new LinkedList<>();
+ final LinkedList<ModelFeatureStructure> featureStructureList = new LinkedList<>();
for (FeatureStructure structure : structures) {
if (structure.getType() == mCurrentType) {
@@ -352,7 +351,7 @@ public final class FeatureStructureBrowserViewPage extends Page {
/** The m cas editor. */
private ICasEditor mCasEditor;
-
+
/** The m FS list. */
private ListViewer mFSList;
@@ -374,17 +373,18 @@ public final class FeatureStructureBrowserViewPage extends Page {
/**
* Initializes a new instance.
*
- * @param editor the editor
+ * @param editor
+ * the editor
*/
public FeatureStructureBrowserViewPage(ICasEditor editor) {
- if (editor == null)
- throw new IllegalArgumentException("editor parameter must not be null!");
+ if (editor == null)
+ throw new IllegalArgumentException("editor parameter must not be null!");
mDocument = editor.getDocument();
mCasEditor = editor;
-
+
mDeleteAction = new DeleteFeatureStructureAction(this.mCasEditor);
mSelectAllAction = new SelectAllAction();
@@ -438,27 +438,26 @@ public final class FeatureStructureBrowserViewPage extends Page {
layout.numColumns = 1;
mInstanceComposite.setLayout(layout);
-
+
Composite typePanel = new Composite(mInstanceComposite, SWT.NULL);
-
+
GridData typePanelData = new GridData();
typePanelData.grabExcessHorizontalSpace = true;
typePanelData.grabExcessVerticalSpace = false;
typePanelData.horizontalAlignment = SWT.FILL;
typePanel.setLayoutData(typePanelData);
-
+
GridLayout typePanelLayout = new GridLayout();
typePanelLayout.numColumns = 2;
typePanel.setLayout(typePanelLayout);
-
+
Label typeLabel = new Label(typePanel, SWT.NONE);
typeLabel.setText("Type: ");
GridData typeLabelData = new GridData();
typeLabelData.horizontalAlignment = SWT.LEFT;
typeLabel.setLayoutData(typeLabelData);
-
-
+
TypeCombo typeCombo = new TypeCombo(typePanel);
typeCombo.setInput(mDocument.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_TOP),
mDocument.getCAS().getTypeSystem(), filterTypes);
@@ -466,24 +465,24 @@ public final class FeatureStructureBrowserViewPage extends Page {
typeComboData.horizontalAlignment = SWT.FILL;
typeComboData.grabExcessHorizontalSpace = true;
typeCombo.setLayoutData(typeComboData);
-
- final IPreferenceStore store = mCasEditor.getCasDocumentProvider().
- getSessionPreferenceStore(mCasEditor.getEditorInput());
-
+
+ final IPreferenceStore store = mCasEditor.getCasDocumentProvider()
+ .getSessionPreferenceStore(mCasEditor.getEditorInput());
+
Type lastUsedType = mDocument.getType(store.getString(LAST_SELECTED_FS_TYPE));
-
+
if (lastUsedType != null) {
typeCombo.select(lastUsedType);
}
-
+
typeCombo.addListener(new ITypePaneListener() {
-
+
@Override
public void typeChanged(Type newType) {
store.setValue(LAST_SELECTED_FS_TYPE, newType.getName());
}
});
-
+
mFSList = new ListViewer(mInstanceComposite, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
GridData instanceListData = new GridData();
instanceListData.grabExcessHorizontalSpace = true;
@@ -507,7 +506,7 @@ public final class FeatureStructureBrowserViewPage extends Page {
if (lastUsedType != null)
mFSList.setInput(lastUsedType);
-
+
getSite().setSelectionProvider(mFSList);
}
@@ -525,9 +524,12 @@ public final class FeatureStructureBrowserViewPage extends Page {
* Adds the following actions to the toolbar: {@link FeatureStructureBrowserViewPage.CreateAction}
* DeleteAction
*
- * @param menuManager the menu manager
- * @param toolBarManager the tool bar manager
- * @param statusLineManager the status line manager
+ * @param menuManager
+ * the menu manager
+ * @param toolBarManager
+ * the tool bar manager
+ * @param statusLineManager
+ * the status line manager
*/
@Override
public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
@@ -545,7 +547,8 @@ public final class FeatureStructureBrowserViewPage extends Page {
/**
* Sets global action handlers for: delete select all.
*
- * @param actionBars the new action bars
+ * @param actionBars
+ * the new action bars
*/
@Override
public void setActionBars(IActionBars actionBars) {
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
index ef05cc2..9cc6034 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
@@ -27,7 +27,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
-
/**
* Provide the labels for the given {@link FeatureStructure}s.
*/
@@ -48,24 +47,20 @@ public final class FeatureStructureLabelProvider implements ILabelProvider {
}
return featureValue.getFeature().getShortName();
- }
- else if (element instanceof IAdaptable) {
+ } else if (element instanceof IAdaptable) {
FeatureStructure structure = null;
if (((IAdaptable) element).getAdapter(AnnotationFS.class) != null) {
- structure = (AnnotationFS) ((IAdaptable) element)
- .getAdapter(AnnotationFS.class);
+ structure = (AnnotationFS) ((IAdaptable) element).getAdapter(AnnotationFS.class);
}
if (structure == null) {
structure = (FeatureStructure) ((IAdaptable) element).getAdapter(FeatureStructure.class);
}
- return structure.getType().getShortName() + " (id=" +
- structure._id() + ")";
- }
- else {
+ return structure.getType().getShortName() + " (id=" + structure._id() + ")";
+ } else {
assert false : "Unexpected element!";
return element.toString();
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java
index 123c686..56168fe 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java
@@ -21,16 +21,16 @@ package org.apache.uima.caseditor.editor.fsview;
import org.apache.uima.cas.Type;
-
/**
* Notifies clients about type changes.
*/
public interface ITypePaneListener {
-
+
/**
* Called after the type was changed.
*
- * @param newType the new type
+ * @param newType
+ * the new type
*/
void typeChanged(Type newType);
}
\ No newline at end of file
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
index 7eb21f8..62bb493 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java
@@ -35,7 +35,6 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-
/**
* A combo box which contains UIMA Types.
*
@@ -43,7 +42,7 @@ import org.eclipse.swt.widgets.Composite;
* @see TypeSystem
*/
public class TypeCombo extends Composite {
-
+
/** The listeners. */
private Set<ITypePaneListener> listeners = new HashSet<>();
@@ -52,14 +51,15 @@ public class TypeCombo extends Composite {
/** The type combo. */
private Combo typeCombo;
-
+
/** The type name list. */
private List<String> typeNameList;
-
+
/**
* Instantiates a new type combo.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
public TypeCombo(Composite parent) {
super(parent, SWT.NONE);
@@ -67,7 +67,7 @@ public class TypeCombo extends Composite {
setLayout(new FillLayout());
typeCombo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
-
+
typeCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -79,18 +79,20 @@ public class TypeCombo extends Composite {
}
});
}
-
+
/**
* Sets the input.
*
- * @param superType the super type
- * @param typeSystem the type system
- * @param filterTypes the filter types
+ * @param superType
+ * the super type
+ * @param typeSystem
+ * the type system
+ * @param filterTypes
+ * the filter types
*/
- public void setInput(Type superType, TypeSystem typeSystem,
- Collection<Type> filterTypes) {
+ public void setInput(Type superType, TypeSystem typeSystem, Collection<Type> filterTypes) {
this.typeSystem = typeSystem;
-
+
typeNameList = new LinkedList<>();
typeNameList.add(superType.getName());
@@ -107,54 +109,57 @@ public class TypeCombo extends Composite {
// select the super type, its the first element (and must be there)
typeCombo.select(0);
}
-
+
/**
* Sets the input.
*
- * @param superType the super type
- * @param typeSystem the type system
+ * @param superType
+ * the super type
+ * @param typeSystem
+ * the type system
*/
public void setInput(Type superType, TypeSystem typeSystem) {
setInput(superType, typeSystem, Collections.emptyList());
}
-
+
/**
- * Selects the given type or does nothing if the
- * type is not listed.
+ * Selects the given type or does nothing if the type is not listed.
*
- * @param type the type
+ * @param type
+ * the type
*/
public void select(Type type) {
Integer typeIndex = typeNameList.indexOf(type.getName());
-
+
if (typeIndex != null) {
typeCombo.select(typeIndex);
}
}
-
+
/**
- * Retrieves the selected type. Behavior is undefined when called
- * before setInput.
+ * Retrieves the selected type. Behavior is undefined when called before setInput.
*
* @return the selected type
*/
public Type getType() {
return typeSystem.getType(typeCombo.getText());
}
-
+
/**
* Adds the listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void addListener(ITypePaneListener listener) {
listeners.add(listener);
}
-
+
/**
* Removes the listener.
*
- * @param listener the listener
+ * @param listener
+ * the listener
*/
public void removeListener(ITypePaneListener listener) {
listeners.remove(listener);
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
index 2b4c860..cbf0c22 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
@@ -65,14 +65,12 @@ import org.eclipse.ui.part.IPage;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
-
/**
- * This outline view displays all <code>AnnotationFS</code>s of the current
- * mode/type from the binded editor.
+ * This outline view displays all <code>AnnotationFS</code>s of the current mode/type from the
+ * binded editor.
*/
-public final class AnnotationOutline extends ContentOutlinePage
- implements ISelectionListener {
-
+public final class AnnotationOutline extends ContentOutlinePage implements ISelectionListener {
+
/**
* This listener receive events from the bound editor.
*/
@@ -81,7 +79,8 @@ public final class AnnotationOutline extends ContentOutlinePage
/**
* Called if the editor annotation mode was changed.
*
- * @param newMode the new mode
+ * @param newMode
+ * the new mode
*/
@Override
public void annotationModeChanged(Type newMode) {
@@ -112,10 +111,10 @@ public final class AnnotationOutline extends ContentOutlinePage
/** The editor change listener. */
private IAnnotationEditorModifyListener editorChangeListener;
-
+
/** The style. */
private OutlineStyles style = OutlineStyles.TYPE;
-
+
/** The m outline composite. */
private Composite mOutlineComposite;
@@ -130,8 +129,8 @@ public final class AnnotationOutline extends ContentOutlinePage
/**
* Creates a new <code>AnnotationOutline</code> object.
*
- * @param editor -
- * the editor to bind
+ * @param editor
+ * - the editor to bind
*/
public AnnotationOutline(AnnotationEditor editor) {
this.editor = editor;
@@ -140,7 +139,8 @@ public final class AnnotationOutline extends ContentOutlinePage
/**
* Creates the outline table control.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
@Override
public void createControl(Composite parent) {
@@ -152,7 +152,7 @@ public final class AnnotationOutline extends ContentOutlinePage
getSite().getPage().addSelectionListener(this);
getSite().setSelectionProvider(mTableViewer);
-
+
changeAnnotationMode();
editorChangeListener = new EditorListener();
@@ -205,7 +205,8 @@ public final class AnnotationOutline extends ContentOutlinePage
* Adds the these actions to the global action handler: {@link DeleteFeatureStructureAction}
* SelectAllAction.
*
- * @param actionBars the new action bars
+ * @param actionBars
+ * the new action bars
*/
@Override
public void setActionBars(IActionBars actionBars) {
@@ -216,24 +217,25 @@ public final class AnnotationOutline extends ContentOutlinePage
getSite().getSelectionProvider().addSelectionChangedListener(deleteAction);
actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new SelectAllAction());
-
+
Action action = new SwitchStyleAction(this);
-
+
IMenuManager dropDownMenu = actionBars.getMenuManager();
dropDownMenu.add(action);
-
+
IToolBarManager toolBarManager = actionBars.getToolBarManager();
-
+
// wide left annotation side action
WideLeftAnnotationSideAction wideLeftAnnotationSideAction = new WideLeftAnnotationSideAction(
editor);
wideLeftAnnotationSideAction.setActionDefinitionId(WideLeftAnnotationSideAction.ID);
wideLeftAnnotationSideAction.setText("Wides the left annotation side");
- wideLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
- .getTaeImageDescriptor(Images.WIDE_LEFT_SIDE));
+ wideLeftAnnotationSideAction
+ .setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.WIDE_LEFT_SIDE));
getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSideAction);
- actionBars.setGlobalActionHandler(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSideAction);
+ actionBars.setGlobalActionHandler(WideLeftAnnotationSideAction.ID,
+ wideLeftAnnotationSideAction);
toolBarManager.add(wideLeftAnnotationSideAction);
// lower left annotation side action
@@ -241,23 +243,25 @@ public final class AnnotationOutline extends ContentOutlinePage
editor);
lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID);
lowerLeftAnnotationSideAction.setText("Lowers the left annotation side");
- lowerLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin
- .getTaeImageDescriptor(Images.LOWER_LEFT_SIDE));
+ lowerLeftAnnotationSideAction
+ .setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.LOWER_LEFT_SIDE));
getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction);
- actionBars.setGlobalActionHandler(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction);
+ actionBars.setGlobalActionHandler(LowerLeftAnnotationSideAction.ID,
+ lowerLeftAnnotationSideAction);
toolBarManager.add(lowerLeftAnnotationSideAction);
// lower right annotation side action
- LowerRightAnnotationSideAction lowerRightAnnotationSideAction =
- new LowerRightAnnotationSideAction(editor);
+ LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new LowerRightAnnotationSideAction(
+ editor);
lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID);
lowerRightAnnotationSideAction.setText("Lowers the right annotation side");
- lowerRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
- .getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE));
+ lowerRightAnnotationSideAction
+ .setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE));
getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction);
- actionBars.setGlobalActionHandler(LowerRightAnnotationSideAction.ID, lowerRightAnnotationSideAction);
+ actionBars.setGlobalActionHandler(LowerRightAnnotationSideAction.ID,
+ lowerRightAnnotationSideAction);
toolBarManager.add(lowerRightAnnotationSideAction);
// wide right annotation side action
@@ -265,11 +269,12 @@ public final class AnnotationOutline extends ContentOutlinePage
editor);
wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID);
wideRightAnnotationSideAction.setText("Wides the right annotation side");
- wideRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin
- .getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE));
+ wideRightAnnotationSideAction
+ .setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE));
getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction);
- actionBars.setGlobalActionHandler(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction);
+ actionBars.setGlobalActionHandler(WideRightAnnotationSideAction.ID,
+ wideRightAnnotationSideAction);
toolBarManager.add(wideRightAnnotationSideAction);
// merge action
@@ -281,7 +286,7 @@ public final class AnnotationOutline extends ContentOutlinePage
// delete action
toolBarManager.add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
-
+
super.setActionBars(actionBars);
}
@@ -291,31 +296,30 @@ public final class AnnotationOutline extends ContentOutlinePage
* @return the outline styles
*/
OutlineStyles currentStyle() {
- return style;
+ return style;
}
-
+
/**
* Switch style.
*
- * @param style the style
+ * @param style
+ * the style
*/
void switchStyle(OutlineStyles style) {
-
- this.style = style;
-
- if (OutlineStyles.MODE.equals(style)) {
- mTableViewer.setContentProvider(new ModeSensitiveContentProvider(
- editor, mTableViewer));
- } else if (OutlineStyles.TYPE.equals(style)) {
- mTableViewer.setContentProvider(new TypeGroupedContentProvider(
- editor, mTableViewer));
- } else {
- throw new CasEditorError("Unknown style!");
- }
-
- mTableViewer.refresh();
+
+ this.style = style;
+
+ if (OutlineStyles.MODE.equals(style)) {
+ mTableViewer.setContentProvider(new ModeSensitiveContentProvider(editor, mTableViewer));
+ } else if (OutlineStyles.TYPE.equals(style)) {
+ mTableViewer.setContentProvider(new TypeGroupedContentProvider(editor, mTableViewer));
+ } else {
+ throw new CasEditorError("Unknown style!");
+ }
+
+ mTableViewer.refresh();
}
-
+
/**
* Sets the focus.
*/
@@ -335,7 +339,8 @@ public final class AnnotationOutline extends ContentOutlinePage
/**
* Creates the table viewer.
*
- * @param parent the parent
+ * @param parent
+ * the parent
*/
private void createTableViewer(Composite parent) {
int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
@@ -363,30 +368,28 @@ public final class AnnotationOutline extends ContentOutlinePage
// Note: The type style is considered as the default
mTableViewer.setContentProvider(new TypeGroupedContentProvider(editor, mTableViewer));
-
- mTableViewer.setFilters(new ViewerFilter[]{new ViewerFilter() {
-
- // TODO: Improve this filter ... it is to sloooooooooow
- @Override
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- Collection<Type> shownTypes = editor.getShownAnnotationTypes();
-
- if (element instanceof AnnotationTypeTreeNode) {
- AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) element;
-
- return shownTypes.contains(typeNode.getType());
- }
- else if (element instanceof AnnotationTreeNode) {
- AnnotationTreeNode annotationNode = (AnnotationTreeNode) element;
-
- return shownTypes.contains(annotationNode.getAnnotation().getType());
- }
- else {
- throw new CasEditorError("Unexpected element type!");
- }
- }}});
-
+
+ mTableViewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
+
+ // TODO: Improve this filter ... it is to sloooooooooow
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ Collection<Type> shownTypes = editor.getShownAnnotationTypes();
+
+ if (element instanceof AnnotationTypeTreeNode) {
+ AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) element;
+
+ return shownTypes.contains(typeNode.getType());
+ } else if (element instanceof AnnotationTreeNode) {
+ AnnotationTreeNode annotationNode = (AnnotationTreeNode) element;
+
+ return shownTypes.contains(annotationNode.getAnnotation().getType());
+ } else {
+ throw new CasEditorError("Unexpected element type!");
+ }
+ }
+ } });
+
mTableViewer.setLabelProvider(new OutlineLabelProvider());
mTableViewer.setSorter(new OutlineTableSorter());
@@ -398,14 +401,14 @@ public final class AnnotationOutline extends ContentOutlinePage
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
+
boolean isForeignSelection = true;
-
+
if (part instanceof ContentOutline) {
ContentOutline contentOutline = (ContentOutline) part;
-
+
IPage currentPage = contentOutline.getCurrentPage();
-
+
if (currentPage instanceof OutlinePageBook) {
OutlinePageBook pageBook = (OutlinePageBook) currentPage;
isForeignSelection = pageBook.getCasViewPage() != this;
@@ -417,8 +420,8 @@ public final class AnnotationOutline extends ContentOutlinePage
AnnotationSelection annotations = new AnnotationSelection((StructuredSelection) selection);
if (!annotations.isEmpty()) {
- ISelection tableSelection = new StructuredSelection(new AnnotationTreeNode(editor
- .getDocument(), annotations.getFirst()));
+ ISelection tableSelection = new StructuredSelection(
+ new AnnotationTreeNode(editor.getDocument(), annotations.getFirst()));
mTableViewer.setSelection(tableSelection, true);
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
index 3b9755e..75634ae 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
@@ -27,12 +27,11 @@ import org.apache.uima.caseditor.editor.ICasDocument;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
-
/**
* TODO: add javadoc here.
*/
public class AnnotationTreeNode implements IAdaptable {
-
+
/** The m parent. */
private AnnotationTreeNode mParent;
@@ -45,8 +44,10 @@ public class AnnotationTreeNode implements IAdaptable {
/**
* Instantiates a new annotation tree node.
*
- * @param document the document
- * @param annotation the annotation
+ * @param document
+ * the document
+ * @param annotation
+ * the annotation
*/
AnnotationTreeNode(ICasDocument document, AnnotationFS annotation) {
Assert.isNotNull(document);
@@ -87,7 +88,8 @@ public class AnnotationTreeNode implements IAdaptable {
/**
* Checks if the given node is completly contained by the current node instance.
*
- * @param node the node
+ * @param node
+ * the node
* @return true if completly contained otherwise false
*/
boolean isChild(AnnotationTreeNode node) {
@@ -98,7 +100,8 @@ public class AnnotationTreeNode implements IAdaptable {
/**
* Adds the child.
*
- * @param node the node
+ * @param node
+ * the node
*/
void addChild(AnnotationTreeNode node) {
node.mParent = this;
@@ -108,9 +111,9 @@ public class AnnotationTreeNode implements IAdaptable {
mChildren.buildTree();
}
-
@Override
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ public Object getAdapter(@SuppressWarnings("rawtypes")
+ Class adapter) {
// TODO:
// use ModelFeatureStructure
// create a AdapterFactory which just calls the
@@ -118,8 +121,7 @@ public class AnnotationTreeNode implements IAdaptable {
if (AnnotationFS.class.equals(adapter) || FeatureStructure.class.equals(adapter)) {
return getAnnotation();
- }
- else {
+ } else {
return null;
}
}
@@ -131,16 +133,14 @@ public class AnnotationTreeNode implements IAdaptable {
@Override
public boolean equals(Object obj) {
-
+
if (this == obj) {
return true;
- }
- else if (obj instanceof AnnotationTreeNode) {
+ } else if (obj instanceof AnnotationTreeNode) {
AnnotationTreeNode other = (AnnotationTreeNode) obj;
-
+
return other.getAnnotation().equals(mAnnotation);
- }
- else {
+ } else {
return false;
}
}
diff --git a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java
index ce7cdc7..c19cffb 100644
--- a/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java
+++ b/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java
@@ -27,18 +27,16 @@ import java.util.List;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.caseditor.editor.ICasDocument;
-
/**
- * The {@link AnnotationTreeNodeList} class can build a tree of
- * {@link AnnotationTreeNode} objects.
+ * The {@link AnnotationTreeNodeList} class can build a tree of {@link AnnotationTreeNode} objects.
*
- * Currently this is not used, because it slows down the Cas Editor UI
- * if the document contains to many annotations.
... 3203 lines suppressed ...