Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/IDGenerator.java Mon Jul 22 12:23:55 2019 @@ -21,6 +21,7 @@ package org.apache.uima.caseditor.editor import java.util.Random; + /** * <p> * The IDGenerator generate unique IDs. @@ -31,6 +32,8 @@ import java.util.Random; * </p> */ public class IDGenerator { + + /** The s start value. */ private long sStartValue; /** @@ -55,10 +58,10 @@ public class IDGenerator { /** * Retrieve the next unique ID. * + * @return - the unique id * @throws IllegalStateException - * if there are more than Long.MAX_VALUE calls to * <code>IDGenerator.nextUniqueID()</code> - * @return - the unique id */ public byte[] nextUniqueID() { if (sUniqueID == sStartValue) {
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ObjectTransfer.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ObjectTransfer.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ObjectTransfer.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ObjectTransfer.java Mon Jul 22 12:23:55 2019 @@ -24,70 +24,61 @@ import java.util.Arrays; import org.eclipse.swt.dnd.ByteArrayTransfer; import org.eclipse.swt.dnd.TransferData; + /** * This class is able to transfer an {@link Object} object. The object gets * saved and only an Id is transfered. */ -public abstract class ObjectTransfer extends ByteArrayTransfer -{ - private IDGenerator mIdGenerator = IDGenerator.getInstance(); - - private String mTransferName; - - private int mTransferID; - - private byte[] mCurrentID; - - private Object mObject; - - /** - * Initializes a new instance with a name. - * - * @param name - the name of current instance. - */ - protected ObjectTransfer(String name) - { - mTransferName = name; - - mTransferID = registerType(mTransferName); - } - - @Override - protected void javaToNative(Object object, TransferData transferData) - { - mCurrentID = mIdGenerator.nextUniqueID(); - - mObject = object; - - if (transferData != null) - { - super.javaToNative(mCurrentID, transferData); - } - } - - @Override - protected Object nativeToJava(TransferData transferData) - { - byte bytes[] = (byte[]) super.nativeToJava(transferData); +public abstract class ObjectTransfer extends ByteArrayTransfer { + + /** The m id generator. */ + private IDGenerator mIdGenerator = IDGenerator.getInstance(); + + /** The m transfer name. */ + private String mTransferName; + + /** The m transfer ID. */ + private int mTransferID; + + /** The m current ID. */ + private byte[] mCurrentID; + + /** The m object. */ + private Object mObject; + + /** + * Initializes a new instance with a name. + * + * @param name - the name of current instance. + */ + protected ObjectTransfer(String name) { + mTransferName = name; + mTransferID = registerType(mTransferName); + } + + @Override + protected void javaToNative(Object object, TransferData transferData) { + mCurrentID = mIdGenerator.nextUniqueID(); + mObject = object; - return Arrays.equals(mCurrentID, bytes) ? mObject : null; + if (transferData != null) { + super.javaToNative(mCurrentID, transferData); } + } - @Override - protected int[] getTypeIds() - { - return new int[] - { - mTransferID - }; - } - - @Override - protected String[] getTypeNames() - { - return new String[] - { - mTransferName - }; - } -} \ No newline at end of file + @Override + protected Object nativeToJava(TransferData transferData) { + byte bytes[] = (byte[]) super.nativeToJava(transferData); + return Arrays.equals(mCurrentID, bytes) ? mObject : null; + } + + @Override + protected int[] getTypeIds() { + return new int[] {mTransferID}; + } + + @Override + protected String[] getTypeNames() { + return new String[] {mTransferName}; + } +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Primitives.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Primitives.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Primitives.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Primitives.java Mon Jul 22 12:23:55 2019 @@ -27,14 +27,17 @@ import org.apache.uima.cas.TypeSystem; import org.apache.uima.cas.impl.LowLevelTypeSystem; + +/** + * The Class Primitives. + */ public class Primitives { /** * Retrieve the primitive java class for a primitive type. - * - * @param ts - * @param type - * + * + * @param ts the ts + * @param type the type * @return the primitive java class */ public static Class<?> getPrimitiveClass(TypeSystem ts, Type type) { @@ -78,7 +81,8 @@ public class Primitives { /** * Retrieves the {@link Class} for the current primitive. * - * @param f + * @param ts the ts + * @param f the f * @return the class */ public static Class<?> getPrimitiveClass(TypeSystem ts, Feature f) { @@ -88,8 +92,8 @@ public class Primitives { /** * Retrieves the primitive value. * - * @param structure - * @param feature + * @param structure the structure + * @param feature the feature * @return the primitive value as object */ public static Object getPrimitive(FeatureStructure structure, Feature feature) { @@ -127,6 +131,13 @@ public class Primitives { return result; } + /** + * Checks if is restricted by allowed values. + * + * @param ts the ts + * @param type the type + * @return true, if is restricted by allowed values + */ public static boolean isRestrictedByAllowedValues(TypeSystem ts, Type type) { if (ts.getType(CAS.TYPE_NAME_STRING).equals(type) || @@ -143,6 +154,13 @@ public class Primitives { } + /** + * Gets the restricted values. + * + * @param ts the ts + * @param type the type + * @return the restricted values + */ public static String[] getRestrictedValues(TypeSystem ts, Type type) { if (isRestrictedByAllowedValues(ts, type)) { throw new IllegalArgumentException("Type " + type.getName() + " does not defines allowed values!"); Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Span.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Span.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Span.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/Span.java Mon Jul 22 12:23:55 2019 @@ -19,6 +19,7 @@ package org.apache.uima.caseditor.editor.util; + /** * This class usually specifies an continous are of text. This area has an start and end index. The * difference of the end and start is the length of the area. @@ -37,8 +38,8 @@ public class Span implements Comparable< /** * Initializes a new <code>Span</code> instance. * - * @param start - * @param length + * @param start the start + * @param length the length */ public Span(int start, int length) { mStart = start; @@ -85,14 +86,15 @@ public class Span implements Comparable< return false; } - boolean isEndContaining = getEnd() >= containingSpan.getEnd(); - if (!isEndContaining) { - return false; - } - - return true; + return getEnd() >= containingSpan.getEnd(); } + /** + * Checks if is intersecting. + * + * @param s the s + * @return true, if is intersecting + */ public boolean isIntersecting(Span s) { int sstart = s.getStart(); return this.isContaining(s) || s.isContaining(this) || @@ -102,13 +104,20 @@ public class Span implements Comparable< /** * Compares the current instance to another {@link Span} object. + * + * @param span the span + * @return the int */ + @Override public int compareTo(Span span) { return span.getStart() - getStart(); } /** - * Tests if the current instance is equal to o; + * Tests if the current instance is equal to o;. + * + * @param o the o + * @return true, if successful */ @Override public boolean equals(Object o) { @@ -126,15 +135,13 @@ public class Span implements Comparable< return false; } - if (getLength() != span.getLength()) { - return false; - } - - return true; + return getLength() == span.getLength(); } /** * Represents the current object as a <code>String</code>. + * + * @return the string */ @Override public String toString() { @@ -143,6 +150,8 @@ public class Span implements Comparable< /** * Generates a hash code of the current object. + * + * @return the int */ @Override public int hashCode() { Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/StrictTypeConstraint.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/StrictTypeConstraint.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/StrictTypeConstraint.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/StrictTypeConstraint.java Mon Jul 22 12:23:55 2019 @@ -24,26 +24,34 @@ import org.apache.uima.cas.FSMatchConstr import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.Type; + /** - * Matches all annoations of an added type. + * Matches all annotations of an added type. */ public class StrictTypeConstraint implements FSConstraint, FSMatchConstraint { + + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1; + /** The m match. */ private Type mMatch; /** * Initializes the current instance. * - * @param match + * @param match the match */ public StrictTypeConstraint(Type match) { mMatch = match; } /** - * Checks if the given {@link FeatureStructure} matchs this constraint. + * Checks if the given {@link FeatureStructure} matches this constraint. + * + * @param candidateFS the candidate FS + * @return true, if successful */ + @Override public boolean match(FeatureStructure candidateFS) { return candidateFS.getType().getName().equals(mMatch.getName()); } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/UimaUtil.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/UimaUtil.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/UimaUtil.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/UimaUtil.java Mon Jul 22 12:23:55 2019 @@ -25,14 +25,16 @@ import java.util.Collection; import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.text.AnnotationFS; + /** - * TODO: add javadoc here + * TODO: add javadoc here. */ public class UimaUtil { + /** * Casts a {@link FeatureStructure} collection to an {@link AnnotationFS} collection. * - * @param annotations + * @param annotations the annotations * @return the {@link AnnotationFS} collection */ public static Collection<FeatureStructure> cast(Collection<AnnotationFS> annotations) { Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/AnnotationPropertyPage.java Mon Jul 22 12:23:55 2019 @@ -60,57 +60,116 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.dialogs.PropertyPage; + /** * This is the <code>AnnotationPropertyPage</code>. this page configures the project dependent * and type dependent annotation appearance in the <code>AnnotationEditor</code>. */ public abstract class AnnotationPropertyPage extends PropertyPage { - private static interface CustomStyleConfigChangeListener { + /** + * The listener interface for receiving customStyleConfigChange events. + * The class that is interested in processing a customStyleConfigChange + * event implements this interface, and the object created + * with that class is registered with a component using the + * component's <code>addCustomStyleConfigChangeListener</code> method. When + * the customStyleConfigChange event occurs, that object's appropriate + * method is invoked. + */ + private interface CustomStyleConfigChangeListener { + + /** + * Style changed. + * + * @param configuration the configuration + */ void styleChanged(String configuration); } + /** + * The Class CustomStyleConfigWidget. + */ private static abstract class CustomStyleConfigWidget extends Composite { + /** The listeners. */ private Set<CustomStyleConfigChangeListener> listeners = - new HashSet<CustomStyleConfigChangeListener>(); + new HashSet<>(); + /** + * Instantiates a new custom style config widget. + * + * @param parent the parent + */ public CustomStyleConfigWidget(Composite parent) { super(parent, SWT.NONE); } + /** + * Notify change. + * + * @param newConfig the new config + */ protected void notifyChange(String newConfig) { for (CustomStyleConfigChangeListener listener : listeners) { listener.styleChanged(newConfig); } } + /** + * Adds the listener. + * + * @param listener the listener + */ void addListener(CustomStyleConfigChangeListener listener) { listeners.add(listener); } + /** + * Removes the listener. + * + * @param listener the listener + */ void removeListener(CustomStyleConfigChangeListener listener) { listeners.remove(listener); } + /** + * Sets the style. + * + * @param style the style + * @param selectedType the selected type + */ void setStyle(AnnotationStyle style, Type selectedType) { } + /** + * Gets the configuration. + * + * @return the configuration + */ abstract String getConfiguration(); } // TODO: If there is more than one config widget, do a little refactoring ... - // TODO: needs one label plus combo to select the combinded drawing style + /** + * The Class TagStyleConfigWidget. + */ + // TODO: needs one label plus combo to select the combined drawing style private static class TagStyleConfigWidget extends CustomStyleConfigWidget { + /** The feature combo. */ private Combo featureCombo; + /** + * Instantiates a new tag style config widget. + * + * @param parent the parent + */ TagStyleConfigWidget(Composite parent) { super(parent); // Add a warning, that tag style is still experimental - // group layout must fill everything .. ?! setLayout(new FillLayout()); @@ -136,10 +195,12 @@ public abstract class AnnotationProperty featureCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { notifyChange(featureCombo.getText()); } + @Override public void widgetDefaultSelected(SelectionEvent e) { // called when enter is pressed, not needed } @@ -147,7 +208,8 @@ public abstract class AnnotationProperty group.pack(); } - + + @Override String getConfiguration() { String configString = featureCombo.getText(); @@ -156,7 +218,7 @@ public abstract class AnnotationProperty else return configString; } - + @Override void setStyle(AnnotationStyle style, Type selectedType) { featureCombo.removeAll(); @@ -183,21 +245,35 @@ public abstract class AnnotationProperty } } + /** The is type system present. */ private boolean isTypeSystemPresent = true; + /** The m style combo. */ private Combo mStyleCombo; + /** The m color selector. */ private ColorSelector mColorSelector; + /** The m type list. */ private TableViewer mTypeList; + /** The move layer up button. */ private Button moveLayerUpButton; + + /** The move layer down button. */ private Button moveLayerDownButton; + /** The style configuration widget. */ private CustomStyleConfigWidget styleConfigurationWidget; - private Map<Type, AnnotationStyle> changedStyles = new HashMap<Type, AnnotationStyle>(); + /** The changed styles. */ + private Map<Type, AnnotationStyle> changedStyles = new HashMap<>(); + /** + * Gets the selected type. + * + * @return the selected type + */ private Type getSelectedType() { IStructuredSelection selection = (IStructuredSelection) mTypeList.getSelection(); @@ -205,9 +281,21 @@ public abstract class AnnotationProperty return (Type) selection.getFirstElement(); } + /** + * Gets the annotation style. + * + * @param type the type + * @return the annotation style + */ protected abstract AnnotationStyle getAnnotationStyle(Type type); - private final AnnotationStyle getWorkingCopyAnnotationStyle(Type type) { + /** + * Gets the working copy annotation style. + * + * @param type the type + * @return the working copy annotation style + */ + private AnnotationStyle getWorkingCopyAnnotationStyle(Type type) { AnnotationStyle style = changedStyles.get(type); if (style == null) @@ -217,15 +305,31 @@ public abstract class AnnotationProperty } // does not make sense, just give it a list with new annotation styles, - // to save them and notify other about the chagne + // to save them and notify other about the change + /** + * Sets the annotation style. + * + * @param style the new annotation style + */ protected final void setAnnotationStyle(AnnotationStyle style) { changedStyles.put(getSelectedType(), style); } + /** + * Gets the type system. + * + * @return the type system + */ protected abstract TypeSystem getTypeSystem(); // Depending on active style, enable custom configuration widget + /** + * Update custom style control. + * + * @param style the style + * @param selectedType the selected type + */ // and update the annotation style with custom control defaults private void updateCustomStyleControl(AnnotationStyle style, Type selectedType) { if (Style.TAG.equals(style.getStyle())) { @@ -237,6 +341,9 @@ public abstract class AnnotationProperty } } + /** + * Item selected. + */ private void itemSelected() { IStructuredSelection selection = (IStructuredSelection) mTypeList.getSelection(); @@ -274,10 +381,11 @@ public abstract class AnnotationProperty } } - - /** * Creates the annotation property page controls. + * + * @param parent the parent + * @return the control */ @Override protected Control createContents(Composite parent) { @@ -362,6 +470,7 @@ public abstract class AnnotationProperty mTypeList.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { itemSelected(); } @@ -382,6 +491,7 @@ public abstract class AnnotationProperty mStyleCombo = new Combo(settingsComposite, SWT.READ_ONLY | SWT.DROP_DOWN); mStyleCombo.setEnabled(false); mStyleCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType()); @@ -403,8 +513,8 @@ public abstract class AnnotationProperty setAnnotationStyle(newStyle); } - + @Override public void widgetDefaultSelected(SelectionEvent e) { // called when enter is pressed, not needed } @@ -423,6 +533,7 @@ public abstract class AnnotationProperty mColorSelector = new ColorSelector(settingsComposite); mColorSelector.setEnabled(false); mColorSelector.addListener(new IPropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent event) { AnnotationStyle style = getWorkingCopyAnnotationStyle( getSelectedType()); @@ -441,9 +552,11 @@ public abstract class AnnotationProperty GridDataFactory.fillDefaults().span(2, 1).applyTo(moveLayerUpButton); moveLayerUpButton.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType()); @@ -461,9 +574,11 @@ public abstract class AnnotationProperty moveLayerDownButton.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { } + @Override public void widgetSelected(SelectionEvent e) { AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType()); @@ -483,6 +598,7 @@ public abstract class AnnotationProperty GridDataFactory.fillDefaults().span(2, 1).applyTo(styleConfigurationWidget); styleConfigurationWidget.setVisible(false); styleConfigurationWidget.addListener(new CustomStyleConfigChangeListener() { + @Override public void styleChanged(String configuration) { AnnotationStyle style = getWorkingCopyAnnotationStyle(getSelectedType()); @@ -501,10 +617,18 @@ public abstract class AnnotationProperty return base; } + /** + * Save changes. + * + * @param changedStyles the changed styles + * @return true, if successful + */ protected abstract boolean saveChanges(Collection<AnnotationStyle> changedStyles); /** * Executed after the OK button was pressed. + * + * @return true, if successful */ @Override public boolean performOk() { @@ -519,4 +643,4 @@ public abstract class AnnotationProperty return true; } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/EditorAnnotationPropertyPage.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/EditorAnnotationPropertyPage.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/EditorAnnotationPropertyPage.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/ui/property/EditorAnnotationPropertyPage.java Mon Jul 22 12:23:55 2019 @@ -27,14 +27,23 @@ import org.apache.uima.caseditor.editor. import org.apache.uima.caseditor.editor.AnnotationStyle; import org.apache.uima.caseditor.editor.styleview.AnnotationTypeNode; + +/** + * The Class EditorAnnotationPropertyPage. + */ public class EditorAnnotationPropertyPage extends AnnotationPropertyPage { + /** + * Gets the editor. + * + * @return the editor + */ AnnotationEditor getEditor() { AnnotationTypeNode typeNode = (AnnotationTypeNode) getElement().getAdapter(AnnotationTypeNode.class); return typeNode.getEditor(); } - + @Override protected AnnotationStyle getAnnotationStyle(Type type) { return getEditor().getAnnotationStyle(type);