Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java Mon Jul 22 12:23:55 2019 @@ -24,12 +24,14 @@ import java.util.Map; import org.eclipse.jface.viewers.ICellEditorValidator; + /** - * TODO: add javadoc here + * TODO: add javadoc here. */ public class CellEditorValidatorFacotory { - private static Map<Class<?>, ICellEditorValidator> sValidatorMap = - new HashMap<Class<?>, ICellEditorValidator>(); + + /** The s validator map. */ + private static Map<Class<?>, ICellEditorValidator> sValidatorMap = new HashMap<>(); static { sValidatorMap.put(Byte.class, new ByteCellEditorValidator()); @@ -39,6 +41,9 @@ public class CellEditorValidatorFacotory sValidatorMap.put(Float.class, new FloatCellEditorValidator()); } + /** + * Instantiates a new cell editor validator facotory. + */ private CellEditorValidatorFacotory() { // must not be instantiated } @@ -47,8 +52,7 @@ public class CellEditorValidatorFacotory * Retrieves the appropriate {@link ICellEditorValidator} for the given class or none if not * available. * - * @param type - * + * @param type the type * @return {@link ICellEditorValidator} or null */ public static ICellEditorValidator createValidator(Class<?> type) { @@ -58,4 +62,4 @@ public class CellEditorValidatorFacotory return sValidatorMap.get(type); } -} \ No newline at end of file +}
Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java Mon Jul 22 12:23:55 2019 @@ -21,6 +21,7 @@ package org.apache.uima.caseditor.editor import org.eclipse.jface.viewers.ICellEditorValidator; + /** * This {@link ICellEditorValidator} validates {@link String} values which represents a * {@link Float}. @@ -28,12 +29,14 @@ import org.eclipse.jface.viewers.ICellEd * For validation {@link Float#parseFloat(String)} is used. */ class FloatCellEditorValidator implements ICellEditorValidator { + /** * Checks if the given value is a valid {@link Float}. * - * @param value + * @param value the value * @return null if valid otherwise an error message */ + @Override public String isValid(Object value) { assert value instanceof String; @@ -45,4 +48,4 @@ class FloatCellEditorValidator implement return null; } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java Mon Jul 22 12:23:55 2019 @@ -21,6 +21,7 @@ package org.apache.uima.caseditor.editor import org.eclipse.jface.viewers.ICellEditorValidator; + /** * This {@link ICellEditorValidator} validates {@link String} values which represents a * {@link Integer}. @@ -28,12 +29,14 @@ import org.eclipse.jface.viewers.ICellEd * For validation {@link Integer#parseInt(String)} is used. */ class IntegerCellEditorValidator implements ICellEditorValidator { + /** * Checks if the given value is a valid {@link Integer}. * - * @param value + * @param value the value * @return null if valid otherwise an error message */ + @Override public String isValid(Object value) { assert value instanceof String; @@ -45,4 +48,4 @@ class IntegerCellEditorValidator impleme return null; } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java Mon Jul 22 12:23:55 2019 @@ -21,6 +21,7 @@ package org.apache.uima.caseditor.editor import org.eclipse.jface.viewers.ICellEditorValidator; + /** * This {@link ICellEditorValidator} validates {@link String} values which represents a {@link Long}. * @@ -31,9 +32,10 @@ public class LongCellEditorValidator imp /** * Checks if the given value is a valid {@link Long}. * - * @param value + * @param value the value * @return null if valid otherwise an error message */ + @Override public String isValid(Object value) { assert value instanceof String; @@ -45,4 +47,4 @@ public class LongCellEditorValidator imp return null; } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java Mon Jul 22 12:23:55 2019 @@ -21,6 +21,7 @@ package org.apache.uima.caseditor.editor import org.eclipse.jface.viewers.ICellEditorValidator; + /** * This {@link ICellEditorValidator} validates {@link String} values which represents a * {@link Short}. @@ -32,9 +33,10 @@ public class ShortCellEditorValidator im /** * Checks if the given value is a valid {@link Short}. * - * @param value + * @param value the value * @return null if valid otherwise an error message */ + @Override public String isValid(Object value) { assert value instanceof String; @@ -47,3 +49,4 @@ public class ShortCellEditorValidator im return null; } } + Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java Mon Jul 22 12:23:55 2019 @@ -24,6 +24,7 @@ import org.apache.uima.caseditor.editor. 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. @@ -34,6 +35,9 @@ public final class FeatureStructureBrows */ public static final String ID = "org.apache.uima.caseditor.fsview"; + /** + * Instantiates a new feature structure browser view. + */ public FeatureStructureBrowserView() { super("The instance view is currently not available."); } @@ -43,15 +47,12 @@ public final class FeatureStructureBrows IPageBookViewPage result = null; - ICasDocument document = editor.getDocument(); + ICasDocument document = editor.getDocument(); - if (document != null) { - FeatureStructureBrowserViewPage page = new FeatureStructureBrowserViewPage( - editor); + if (document != null) { + result = new FeatureStructureBrowserViewPage(editor); + } - result = page; - } - - return result; - } + return result; + } } \ No newline at end of file Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java Mon Jul 22 12:23:55 2019 @@ -22,6 +22,7 @@ package org.apache.uima.caseditor.editor import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import org.apache.uima.cas.CAS; import org.apache.uima.cas.FSIterator; @@ -60,24 +61,37 @@ 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. + */ final class FeatureStructureTreeContentProvider extends AbstractAnnotationDocumentListener implements ITreeContentProvider { + /** The m document. */ private ICasDocument mDocument; + /** The m current type. */ private Type mCurrentType; + /** + * Instantiates a new feature structure tree content provider. + * + * @param document the document + */ FeatureStructureTreeContentProvider(ICasDocument document) { mDocument = document; } + @Override public Object[] getElements(Object inputElement) { if (mCurrentType == null) { return new Object[] {}; @@ -85,29 +99,31 @@ public final class FeatureStructureBrows StrictTypeConstraint typeConstrain = new StrictTypeConstraint(mCurrentType); - FSIterator<FeatureStructure> strictTypeIterator =mDocument.getCAS().createFilteredIterator( + FSIterator<FeatureStructure> strictTypeIterator = mDocument.getCAS().createFilteredIterator( mDocument.getCAS().getIndexRepository().getAllIndexedFS(mCurrentType), typeConstrain); - LinkedList<ModelFeatureStructure> featureStrucutreList = new LinkedList<ModelFeatureStructure>(); + List<ModelFeatureStructure> featureStructureList = new LinkedList<>(); while (strictTypeIterator.hasNext()) { - featureStrucutreList.add(new ModelFeatureStructure(mDocument, + featureStructureList.add(new ModelFeatureStructure(mDocument, strictTypeIterator.next())); } - ModelFeatureStructure[] featureStructureArray = new ModelFeatureStructure[featureStrucutreList + ModelFeatureStructure[] featureStructureArray = new ModelFeatureStructure[featureStructureList .size()]; - featureStrucutreList.toArray(featureStructureArray); + featureStructureList.toArray(featureStructureArray); return featureStructureArray; } + @Override public void dispose() { if (mDocument != null) mDocument.removeChangeListener(this); } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (oldInput != null) { @@ -125,6 +141,7 @@ public final class FeatureStructureBrows mDocument.addChangeListener(this); Display.getDefault().syncExec(new Runnable() { + @Override public void run() { mFSList.refresh(); } @@ -134,11 +151,12 @@ public final class FeatureStructureBrows /** * Retrieves children for a FeatureStrcuture and for FeatureValues if they have children. * - * @param parentElement + * @param parentElement the parent element * @return the children */ + @Override public Object[] getChildren(Object parentElement) { - Collection<Object> childs = new LinkedList<Object>(); + Collection<Object> childs = new LinkedList<>(); FeatureStructure featureStructure; @@ -165,10 +183,12 @@ public final class FeatureStructureBrows return childs.toArray(); } + @Override public Object getParent(Object element) { return null; } + @Override public boolean hasChildren(Object element) { if (element instanceof IAdaptable && ((IAdaptable) element).getAdapter(FeatureStructure.class) != null) { @@ -186,16 +206,12 @@ public final class FeatureStructureBrows if (value instanceof StringArray) { StringArray array = (StringArray) featureValue.getValue(); - if (array.size() > 0) { - return true; - } else { - return false; - } + return array.size() > 0; } return false; } else { - return featureValue.getValue() != null ? true : false; + return featureValue.getValue() != null; } } else { assert false : "Unexpected element"; @@ -207,36 +223,37 @@ public final class FeatureStructureBrows @Override protected void addedAnnotation(Collection<AnnotationFS> annotations) { - final LinkedList<ModelFeatureStructure> featureStrucutreList = - new LinkedList<ModelFeatureStructure>(); + final List<ModelFeatureStructure> featureStructureList = new LinkedList<>(); for (AnnotationFS annotation : annotations) { if (annotation.getType() == mCurrentType) { - featureStrucutreList.add(new ModelFeatureStructure(mDocument, annotation)); + featureStructureList.add(new ModelFeatureStructure(mDocument, annotation)); } } Display.getDefault().syncExec(new Runnable() { + @Override public void run() { - mFSList.add(featureStrucutreList.toArray()); + mFSList.add(featureStructureList.toArray()); } }); } @Override - public void added(Collection<FeatureStructure> structres) { - final LinkedList<ModelFeatureStructure> featureStrucutreList = - new LinkedList<ModelFeatureStructure>(); + public void added(Collection<FeatureStructure> structures) { + final LinkedList<ModelFeatureStructure> featureStructureList = + new LinkedList<>(); - for (FeatureStructure structure : structres) { + for (FeatureStructure structure : structures) { if (structure.getType() == mCurrentType) { - featureStrucutreList.add(new ModelFeatureStructure(mDocument, structure)); + featureStructureList.add(new ModelFeatureStructure(mDocument, structure)); } } Display.getDefault().syncExec(new Runnable() { + @Override public void run() { - mFSList.add(featureStrucutreList.toArray()); + mFSList.add(featureStructureList.toArray()); } }); } @@ -244,37 +261,36 @@ public final class FeatureStructureBrows @Override protected void removedAnnotation(Collection<AnnotationFS> annotations) { - final LinkedList<ModelFeatureStructure> featureStrucutreList = - new LinkedList<ModelFeatureStructure>(); + final List<ModelFeatureStructure> featureStructureList = new LinkedList<>(); for (AnnotationFS annotation : annotations) { if (annotation.getType() == mCurrentType) { - featureStrucutreList.add(new ModelFeatureStructure(mDocument, annotation)); + featureStructureList.add(new ModelFeatureStructure(mDocument, annotation)); } } Display.getDefault().syncExec(new Runnable() { + @Override public void run() { - mFSList.remove(featureStrucutreList.toArray()); + mFSList.remove(featureStructureList.toArray()); } }); - } @Override - public void removed(Collection<FeatureStructure> structres) { - final LinkedList<ModelFeatureStructure> featureStrucutreList = - new LinkedList<ModelFeatureStructure>(); + public void removed(Collection<FeatureStructure> structures) { + final List<ModelFeatureStructure> featureStructureList = new LinkedList<>(); - for (FeatureStructure structure : structres) { + for (FeatureStructure structure : structures) { if (structure.getType() == mCurrentType) { - featureStrucutreList.add(new ModelFeatureStructure(mDocument, structure)); + featureStructureList.add(new ModelFeatureStructure(mDocument, structure)); } } Display.getDefault().syncExec(new Runnable() { + @Override public void run() { - mFSList.remove(featureStrucutreList.toArray()); + mFSList.remove(featureStructureList.toArray()); } }); } @@ -284,16 +300,22 @@ public final class FeatureStructureBrows // ignore } + @Override public void viewChanged(String oldViewName, String newViewName) { changed(); } - + + @Override public void changed() { mFSList.refresh(); } } + /** + * The Class CreateAction. + */ private class CreateAction extends Action { + // TOOD: extract it and add setType(...) @Override public void run() { @@ -313,7 +335,11 @@ public final class FeatureStructureBrows } } + /** + * The Class SelectAllAction. + */ private class SelectAllAction extends Action { + @Override public void run() { mFSList.getList().selectAll(); @@ -321,27 +347,34 @@ public final class FeatureStructureBrows } } + /** The m document. */ private ICasDocument mDocument; + /** The m cas editor. */ private ICasEditor mCasEditor; + /** The m FS list. */ private ListViewer mFSList; + /** The m instance composite. */ private Composite mInstanceComposite; + /** The m current type. */ private Type mCurrentType; + /** The m delete action. */ private DeleteFeatureStructureAction mDeleteAction; + /** The m select all action. */ private Action mSelectAllAction; + /** The filter types. */ private Collection<Type> filterTypes; - /** * Initializes a new instance. * - * @param editor + * @param editor the editor */ public FeatureStructureBrowserViewPage(ICasEditor editor) { @@ -358,7 +391,7 @@ public final class FeatureStructureBrows TypeSystem ts = mDocument.getCAS().getTypeSystem(); - filterTypes = new HashSet<Type>(); + filterTypes = new HashSet<>(); filterTypes.add(ts.getType(CAS.TYPE_NAME_ARRAY_BASE)); filterTypes.add(ts.getType(CAS.TYPE_NAME_BOOLEAN_ARRAY)); filterTypes.add(ts.getType(CAS.TYPE_NAME_BYTE_ARRAY)); @@ -445,6 +478,7 @@ public final class FeatureStructureBrows typeCombo.addListener(new ITypePaneListener() { + @Override public void typeChanged(Type newType) { store.setValue(LAST_SELECTED_FS_TYPE, newType.getName()); } @@ -463,6 +497,7 @@ public final class FeatureStructureBrows mFSList.setUseHashlookup(true); typeCombo.addListener(new ITypePaneListener() { + @Override public void typeChanged(Type newType) { mCurrentType = newType; @@ -477,7 +512,7 @@ public final class FeatureStructureBrows } /** - * Retrieves the control + * Retrieves the control. * * @return the control */ @@ -490,9 +525,9 @@ public final class FeatureStructureBrows * Adds the following actions to the toolbar: {@link FeatureStructureBrowserViewPage.CreateAction} * DeleteAction * - * @param menuManager - * @param toolBarManager - * @param statusLineManager + * @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, @@ -508,9 +543,9 @@ public final class FeatureStructureBrows } /** - * Sets global action handlers for: delete select all + * Sets global action handlers for: delete select all. * - * @param actionBars + * @param actionBars the new action bars */ @Override public void setActionBars(IActionBars actionBars) { Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java Mon Jul 22 12:23:55 2019 @@ -28,10 +28,13 @@ import org.eclipse.jface.viewers.ILabelP import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.swt.graphics.Image; + /** * Provide the labels for the given {@link FeatureStructure}s. */ public final class FeatureStructureLabelProvider implements ILabelProvider { + + @Override public String getText(Object element) { if (element instanceof FeatureValue) { FeatureValue featureValue = (FeatureValue) element; @@ -61,7 +64,7 @@ public final class FeatureStructureLabel } return structure.getType().getShortName() + " (id=" + - ((FeatureStructureImpl) structure).getAddress() + ")"; + ((FeatureStructureImpl) structure).getAddress() + ")"; } else { assert false : "Unexpected element!"; @@ -70,20 +73,25 @@ public final class FeatureStructureLabel } } + @Override public Image getImage(Object element) { return null; } + @Override public boolean isLabelProperty(Object element, String property) { return false; } + @Override public void addListener(ILabelProviderListener listener) { } + @Override public void removeListener(ILabelProviderListener listener) { } + @Override public void dispose() { } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/ITypePaneListener.java Mon Jul 22 12:23:55 2019 @@ -21,14 +21,16 @@ package org.apache.uima.caseditor.editor import org.apache.uima.cas.Type; + /** * Notifies clients about type changes. */ public interface ITypePaneListener { + /** * Called after the type was changed. * - * @param newType + * @param newType the new type */ void typeChanged(Type newType); } \ No newline at end of file Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/fsview/TypeCombo.java Mon Jul 22 12:23:55 2019 @@ -35,6 +35,7 @@ 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,14 +44,23 @@ import org.eclipse.swt.widgets.Composite */ public class TypeCombo extends Composite { - private Set<ITypePaneListener> listeners = new HashSet<ITypePaneListener>(); + /** The listeners. */ + private Set<ITypePaneListener> listeners = new HashSet<>(); + /** The type system. */ private TypeSystem typeSystem; + /** The type combo. */ private Combo typeCombo; + /** The type name list. */ private List<String> typeNameList; + /** + * Instantiates a new type combo. + * + * @param parent the parent + */ public TypeCombo(Composite parent) { super(parent, SWT.NONE); @@ -59,6 +69,7 @@ public class TypeCombo extends Composite typeCombo = new Combo(this, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER); typeCombo.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { Type newType = getType(); @@ -69,11 +80,18 @@ public class TypeCombo extends Composite }); } + /** + * Sets the input. + * + * @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) { this.typeSystem = typeSystem; - typeNameList = new LinkedList<String>(); + typeNameList = new LinkedList<>(); typeNameList.add(superType.getName()); @@ -90,15 +108,21 @@ public class TypeCombo extends Composite typeCombo.select(0); } + /** + * Sets the input. + * + * @param superType the super type + * @param typeSystem the type system + */ public void setInput(Type superType, TypeSystem typeSystem) { - setInput(superType, typeSystem, Collections.<Type>emptyList()); + setInput(superType, typeSystem, Collections.emptyList()); } /** * Selects the given type or does nothing if the * type is not listed. - * - * @param type + * + * @param type the type */ public void select(Type type) { Integer typeIndex = typeNameList.indexOf(type.getName()); @@ -118,10 +142,20 @@ public class TypeCombo extends Composite return typeSystem.getType(typeCombo.getText()); } + /** + * Adds the listener. + * + * @param listener the listener + */ public void addListener(ITypePaneListener listener) { listeners.add(listener); } + /** + * Removes the listener. + * + * @param listener the listener + */ public void removeListener(ITypePaneListener listener) { listeners.remove(listener); } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java Mon Jul 22 12:23:55 2019 @@ -65,6 +65,7 @@ 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. @@ -79,14 +80,16 @@ public final class AnnotationOutline ext /** * Called if the editor annotation mode was changed. - * - * @param newMode + * + * @param newMode the new mode */ + @Override public void annotationModeChanged(Type newMode) { changeAnnotationMode(); mTableViewer.refresh(); } + @Override public void showAnnotationsChanged(Collection<Type> shownAnnotationTypes) { mTableViewer.refresh(); } @@ -96,6 +99,7 @@ public final class AnnotationOutline ext * Selects all elements in the tree viewer. */ private class SelectAllAction extends Action { + /** * Selects all elements in the tree viewer. */ @@ -106,12 +110,16 @@ public final class AnnotationOutline ext } } + /** The editor change listener. */ private IAnnotationEditorModifyListener editorChangeListener; + /** The style. */ private OutlineStyles style = OutlineStyles.TYPE; + /** The m outline composite. */ private Composite mOutlineComposite; + /** The m table viewer. */ private TreeViewer mTableViewer; /** @@ -132,7 +140,7 @@ public final class AnnotationOutline ext /** * Creates the outline table control. * - * @param parent + * @param parent the parent */ @Override public void createControl(Composite parent) { @@ -157,6 +165,7 @@ public final class AnnotationOutline ext source.addDragListener(new DragSourceListener() { TreeItem dragSourceItem = null; + @Override public void dragStart(DragSourceEvent event) { TreeItem[] selection = mTableViewer.getTree().getSelection(); @@ -168,12 +177,14 @@ public final class AnnotationOutline ext } } + @Override public void dragSetData(DragSourceEvent event) { IAdaptable adaptable = (IAdaptable) dragSourceItem.getData(); event.data = adaptable.getAdapter(FeatureStructure.class); } + @Override public void dragFinished(DragSourceEvent event) { // not needed } @@ -192,9 +203,9 @@ public final class AnnotationOutline ext /** * Adds the these actions to the global action handler: {@link DeleteFeatureStructureAction} - * SelectAllAction + * SelectAllAction. * - * @param actionBars + * @param actionBars the new action bars */ @Override public void setActionBars(IActionBars actionBars) { @@ -274,10 +285,20 @@ public final class AnnotationOutline ext super.setActionBars(actionBars); } + /** + * Current style. + * + * @return the outline styles + */ OutlineStyles currentStyle() { return style; } + /** + * Switch style. + * + * @param style the style + */ void switchStyle(OutlineStyles style) { this.style = style; @@ -289,7 +310,7 @@ public final class AnnotationOutline ext mTableViewer.setContentProvider(new TypeGroupedContentProvider( editor, mTableViewer)); } else { - throw new CasEditorError("Unkown style!"); + throw new CasEditorError("Unknown style!"); } mTableViewer.refresh(); @@ -303,11 +324,19 @@ public final class AnnotationOutline ext mOutlineComposite.setFocus(); } + /** + * Change annotation mode. + */ private void changeAnnotationMode() { mTableViewer.setInput(editor.getDocument()); mTableViewer.refresh(); } + /** + * Creates the table viewer. + * + * @param parent the parent + */ private void createTableViewer(Composite parent) { int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION; @@ -345,11 +374,8 @@ public final class AnnotationOutline ext if (element instanceof AnnotationTypeTreeNode) { AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) element; - - if (shownTypes.contains(typeNode.getType())) - return true; - else - return false; + + return shownTypes.contains(typeNode.getType()); } else if (element instanceof AnnotationTreeNode) { AnnotationTreeNode annotationNode = (AnnotationTreeNode) element; @@ -357,7 +383,7 @@ public final class AnnotationOutline ext return shownTypes.contains(annotationNode.getAnnotation().getType()); } else { - throw new CasEditorError("Unxexpected element type!"); + throw new CasEditorError("Unexpected element type!"); } }}}); @@ -370,6 +396,7 @@ public final class AnnotationOutline ext // set input element here ... this is the document } + @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { boolean isForeignSelection = true; @@ -408,6 +435,11 @@ public final class AnnotationOutline ext super.dispose(); } + /** + * Gets the viewer. + * + * @return the viewer + */ Viewer getViewer() { return mTableViewer; } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java Mon Jul 22 12:23:55 2019 @@ -27,36 +27,59 @@ import org.apache.uima.caseditor.editor. import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdaptable; + /** - * TODO: add javadoc here + * TODO: add javadoc here. */ public class AnnotationTreeNode implements IAdaptable { + + /** The m parent. */ private AnnotationTreeNode mParent; + /** The m children. */ private final AnnotationTreeNodeList mChildren; + /** The m annotation. */ private final AnnotationFS mAnnotation; - private final ICasDocument mDocument; - + /** + * Instantiates a new annotation tree node. + * + * @param document the document + * @param annotation the annotation + */ AnnotationTreeNode(ICasDocument document, AnnotationFS annotation) { Assert.isNotNull(document); - mDocument = document; Assert.isNotNull(annotation); mAnnotation = annotation; - mChildren = new AnnotationTreeNodeList(mDocument); + mChildren = new AnnotationTreeNodeList(document); } + /** + * Gets the parent. + * + * @return the parent + */ AnnotationTreeNode getParent() { return mParent; } + /** + * Gets the children. + * + * @return the children + */ List<AnnotationTreeNode> getChildren() { return mChildren.getElements(); } + /** + * Gets the annotation. + * + * @return the annotation + */ AnnotationFS getAnnotation() { return mAnnotation; } @@ -64,7 +87,7 @@ public class AnnotationTreeNode implemen /** * Checks if the given node is completly contained by the current node instance. * - * @param node + * @param node the node * @return true if completly contained otherwise false */ boolean isChild(AnnotationTreeNode node) { @@ -72,6 +95,11 @@ public class AnnotationTreeNode implemen && getAnnotation().getEnd() >= node.getAnnotation().getEnd(); } + /** + * Adds the child. + * + * @param node the node + */ void addChild(AnnotationTreeNode node) { node.mParent = this; @@ -80,6 +108,8 @@ public class AnnotationTreeNode implemen mChildren.buildTree(); } + + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { // TODO: // use ModelFeatureStructure @@ -96,13 +126,6 @@ public class AnnotationTreeNode implemen @Override public int hashCode() { - -// final int PRIME = 31; -// int result = 1; -// result = PRIME * result + (mAnnotation == null ? 0 : mAnnotation.hashCode()); -// result = PRIME * result + (mChildren == null ? 0 : mChildren.hashCode()); -// result = PRIME * result + (mParent == null ? 0 : mParent.hashCode()); - return mAnnotation.hashCode(); } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNodeList.java Mon Jul 22 12:23:55 2019 @@ -27,6 +27,7 @@ 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. @@ -37,14 +38,28 @@ import org.apache.uima.caseditor.editor. * TODO: Rename this class */ public class AnnotationTreeNodeList { - private List<AnnotationTreeNode> mElements = new ArrayList<AnnotationTreeNode>(); + + /** The m elements. */ + private List<AnnotationTreeNode> mElements = new ArrayList<>(); + /** The m document. */ private ICasDocument mDocument; + /** + * Instantiates a new annotation tree node list. + * + * @param document the document + */ AnnotationTreeNodeList(ICasDocument document) { mDocument = document; } + /** + * Instantiates a new annotation tree node list. + * + * @param document the document + * @param annotations the annotations + */ AnnotationTreeNodeList(ICasDocument document, Collection<AnnotationFS> annotations) { mDocument = document; @@ -55,14 +70,29 @@ public class AnnotationTreeNodeList { // buildTree(); } + /** + * Gets the elements. + * + * @return the elements + */ List<AnnotationTreeNode> getElements() { return mElements; } + /** + * Adds the. + * + * @param node the node + */ void add(AnnotationTreeNode node) { mElements.add(node); } + /** + * Removes the. + * + * @param node the node + */ void remove(AnnotationTreeNode node) { if (mElements.contains(node)) { // insert children in the list @@ -75,6 +105,9 @@ public class AnnotationTreeNodeList { mElements.remove(node); } + /** + * Builds the tree. + */ void buildTree() { for (Iterator<AnnotationTreeNode> it = mElements.iterator(); it.hasNext();) { AnnotationTreeNode aNode = it.next(); Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTypeTreeNode.java Mon Jul 22 12:23:55 2019 @@ -25,6 +25,7 @@ import java.util.List; import org.apache.uima.cas.Type; import org.eclipse.core.runtime.IAdaptable; + /** * The {@link AnnotationTreeNode} is used to group annotations * by their type. Only the {@link TypeGroupedContentProvider} creates @@ -32,63 +33,91 @@ import org.eclipse.core.runtime.IAdaptab */ class AnnotationTypeTreeNode implements IAdaptable { - // annotation type - private Type type; - - private List<AnnotationTreeNode> annotations = new ArrayList<AnnotationTreeNode>(); - - public AnnotationTypeTreeNode(Type type) { - this.type = type; - } - - public void add(AnnotationTreeNode annotation) { - annotations.add(annotation); - } - - public AnnotationTreeNode[] getAnnotations() { - return annotations.toArray(new AnnotationTreeNode[annotations.size()]); - } - - public void remove(AnnotationTreeNode annotation) { - annotations.remove(annotation); - } - - public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - - if (Type.class.equals(adapter)) { - return type; - } - - return null; - } - - @Override - public int hashCode() { - return type.hashCode(); - } + /** The annotation type. */ + private Type type; + + /** The annotations. */ + private List<AnnotationTreeNode> annotations = new ArrayList<>(); + + /** + * Instantiates a new annotation type tree node. + * + * @param type the type + */ + public AnnotationTypeTreeNode(Type type) { + this.type = type; + } + + /** + * Adds the. + * + * @param annotation the annotation + */ + public void add(AnnotationTreeNode annotation) { + annotations.add(annotation); + } + + /** + * Gets the annotations. + * + * @return the annotations + */ + public AnnotationTreeNode[] getAnnotations() { + return annotations.toArray(new AnnotationTreeNode[annotations.size()]); + } + + /** + * Removes the. + * + * @param annotation the annotation + */ + public void remove(AnnotationTreeNode annotation) { + annotations.remove(annotation); + } - @Override - public boolean equals(Object obj) { + + @Override + public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - if (obj == this) { - return true; - } - else if (obj instanceof AnnotationTypeTreeNode) { - AnnotationTypeTreeNode otherTypeNode = (AnnotationTypeTreeNode) obj; - - return type.equals(otherTypeNode.type); - } - else { - return false; - } - } + if (Type.class.equals(adapter)) { + return type; + } + + return null; + } - @Override - public String toString() { - return type.getShortName() + " #chhildren = " + annotations.size(); - } - - public Object getType() { - return type; - } -} \ No newline at end of file + + @Override + public int hashCode() { + return type.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + else if (obj instanceof AnnotationTypeTreeNode) { + AnnotationTypeTreeNode otherTypeNode = (AnnotationTypeTreeNode) obj; + + return type.equals(otherTypeNode.type); + } + else { + return false; + } + } + + @Override + public String toString() { + return type.getShortName() + " #chhildren = " + annotations.size(); + } + + /** + * Gets the type. + * + * @return the type + */ + public Object getType() { + return type; + } +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/ModeSensitiveContentProvider.java Mon Jul 22 12:23:55 2019 @@ -27,124 +27,136 @@ import org.eclipse.core.resources.IProje import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Display; + /** * This <code>OutlineContentProvider</code> synchronizes the <code>AnnotationFS</code>s with * the <code>TableViewer</code>. */ - class ModeSensitiveContentProvider extends OutlineContentProviderBase { +class ModeSensitiveContentProvider extends OutlineContentProviderBase { - private AnnotationTreeNodeList mAnnotationNodeList; - - protected ModeSensitiveContentProvider(AnnotationEditor editor, TreeViewer viewer) { - super(editor, viewer); - this.viewer = viewer; - } - - /** - * Adds the added annotations to the viewer. - * - * @param annotations - */ - @Override - public void addedAnnotation(Collection<AnnotationFS> annotations) { - for (AnnotationFS annotation : annotations) { - if (!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) { - return; - } - - final AnnotationTreeNode annotationNode = new AnnotationTreeNode(mEditor.getDocument(), - annotation); + /** The m annotation node list. */ + private AnnotationTreeNodeList mAnnotationNodeList; - mAnnotationNodeList.add(annotationNode); - // mAnnotationNodeList.buildTree(); - - Display.getDefault().syncExec(new Runnable() { - public void run() { - viewer.add(annotationNode.getParent() != null ? annotationNode.getParent() - : mInputDocument, annotationNode); - } - }); + /** + * Instantiates a new mode sensitive content provider. + * + * @param editor the editor + * @param viewer the viewer + */ + protected ModeSensitiveContentProvider(AnnotationEditor editor, TreeViewer viewer) { + super(editor, viewer); + this.viewer = viewer; + } + + /** + * Adds the added annotations to the viewer. + * + * @param annotations the annotations + */ + @Override + public void addedAnnotation(Collection<AnnotationFS> annotations) { + for (AnnotationFS annotation : annotations) { + if (!annotation.getType().getName().equals(mEditor.getAnnotationMode().getName())) { + return; } - } - /** - * Removes the removed annotations from the viewer. - * - * @param deletedAnnotations - */ - @Override - public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) { - // TODO: what happens if someone removes an annoation which - // is not an element of this list e.g in the featruestructure view ? - final AnnotationTreeNode[] items = new AnnotationTreeNode[deletedAnnotations.size()]; - - int i = 0; - for (AnnotationFS annotation : deletedAnnotations) { - // TODO: maybe it is a problem if the parent is not correctly set! - items[i] = new AnnotationTreeNode(mEditor.getDocument(), annotation); - mAnnotationNodeList.remove(items[i]); - i++; - } + final AnnotationTreeNode annotationNode = new AnnotationTreeNode(mEditor.getDocument(), + annotation); + mAnnotationNodeList.add(annotationNode); + // mAnnotationNodeList.buildTree(); Display.getDefault().syncExec(new Runnable() { + @Override public void run() { - viewer.remove(items); + viewer.add(annotationNode.getParent() != null ? annotationNode.getParent() + : mInputDocument, annotationNode); } }); } + } - public void viewChanged(String oldViewName, String newViewName) { - changed(); + /** + * Removes the removed annotations from the viewer. + * + * @param deletedAnnotations the deleted annotations + */ + @Override + public void removedAnnotation(Collection<AnnotationFS> deletedAnnotations) { + // TODO: what happens if someone removes an annoation which + // is not an element of this list e.g in the featruestructure view ? + final AnnotationTreeNode[] items = new AnnotationTreeNode[deletedAnnotations.size()]; + + int i = 0; + for (AnnotationFS annotation : deletedAnnotations) { + // TODO: maybe it is a problem if the parent is not correctly set! + items[i] = new AnnotationTreeNode(mEditor.getDocument(), annotation); + mAnnotationNodeList.remove(items[i]); + i++; } - - public void changed() { - Collection<AnnotationFS> annotations = mEditor.getDocument().getAnnotations( - mEditor.getAnnotationMode()); - mAnnotationNodeList = annotations != null ? new AnnotationTreeNodeList(mEditor - .getDocument(), annotations) : null; - - Display.getDefault().syncExec(new Runnable() { - public void run() { - viewer.refresh(); - } - }); - } - - /** - * Retrieves all children of the {@link NlpModel}. That are the {@link NlpProject}s and - * {@link IProject}s. - * - * @param inputElement - * the {@link NlpModel} - * - * @return the nlp-projects and non-nlp projects - */ - public Object[] getElements(Object inputElement) { - if (mAnnotationNodeList == null) { - return new Object[0]; - } - - return mAnnotationNodeList.getElements().toArray(); - } - - public Object getParent(Object element) { - AnnotationTreeNode node = (AnnotationTreeNode) element; - - return node.getParent(); - } - - public boolean hasChildren(Object element) { - AnnotationTreeNode node = (AnnotationTreeNode) element; - - return node.getChildren().size() > 0; - } + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + viewer.remove(items); + } + }); + } - public Object[] getChildren(Object parentElement) { - AnnotationTreeNode node = (AnnotationTreeNode) parentElement; + @Override + public void viewChanged(String oldViewName, String newViewName) { + changed(); +} + + @Override + public void changed() { + Collection<AnnotationFS> annotations = mEditor.getDocument().getAnnotations( + mEditor.getAnnotationMode()); + + mAnnotationNodeList = annotations != null ? new AnnotationTreeNodeList(mEditor + .getDocument(), annotations) : null; + + Display.getDefault().syncExec(new Runnable() { + @Override + public void run() { + viewer.refresh(); + } + }); + } - return node.getChildren().toArray(); - } - } \ No newline at end of file + /** + * Retrieves all children of the NlpModel. That are the NlpProjects and + * {@link IProject}s. + * + * @param inputElement the input element + * + * @return the nlp-projects and non-nlp projects + */ + @Override + public Object[] getElements(Object inputElement) { + if (mAnnotationNodeList == null) { + return new Object[0]; + } + + return mAnnotationNodeList.getElements().toArray(); + } + + @Override + public Object getParent(Object element) { + AnnotationTreeNode node = (AnnotationTreeNode) element; + return node.getParent(); + } + + @Override + public boolean hasChildren(Object element) { + AnnotationTreeNode node = (AnnotationTreeNode) element; + return node.getChildren().size() > 0; + } + + @Override + public Object[] getChildren(Object parentElement) { + AnnotationTreeNode node = (AnnotationTreeNode) parentElement; + return node.getChildren().toArray(); + } +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineContentProviderBase.java Mon Jul 22 12:23:55 2019 @@ -32,23 +32,37 @@ import org.eclipse.jface.viewers.TreeVie import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Display; + +/** + * The Class OutlineContentProviderBase. + */ abstract class OutlineContentProviderBase extends AbstractAnnotationDocumentListener implements ITreeContentProvider { + /** The m editor. */ protected AnnotationEditor mEditor; + /** The m input document. */ protected ICasDocument mInputDocument; + /** The viewer. */ protected TreeViewer viewer; + /** + * Instantiates a new outline content provider base. + * + * @param editor the editor + * @param viewer the viewer + */ protected OutlineContentProviderBase(AnnotationEditor editor, TreeViewer viewer) { this.viewer = viewer; this.mEditor = editor; } /** - * not implemented + * not implemented. */ + @Override public void dispose() { // currently not implemented } @@ -57,11 +71,12 @@ abstract class OutlineContentProviderBas * Gets called if the viewer input was changed. In this case, this only happens once if the * {@link AnnotationOutline} is initialized. * - * @param viewer - * @param oldInput - * @param newInput + * @param viewer the viewer + * @param oldInput the old input + * @param newInput the new input */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + @Override + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (oldInput != null) { ((ICasDocument) oldInput).removeChangeListener(this); } @@ -78,11 +93,11 @@ abstract class OutlineContentProviderBas /** * Updates the given annotation in the viewer. * - * @param featureStructres + * @param featureStructres the feature structres */ @Override protected void updatedAnnotation(Collection<AnnotationFS> featureStructres) { - Collection<AnnotationFS> annotations = new ArrayList<AnnotationFS>(featureStructres.size()); + Collection<AnnotationFS> annotations = new ArrayList<>(featureStructres.size()); for (FeatureStructure structure : featureStructres) { if (structure instanceof AnnotationFS) { @@ -98,7 +113,8 @@ abstract class OutlineContentProviderBas } Display.getDefault().syncExec(new Runnable() { - public void run() { + @Override + public void run() { viewer.update(items, null); } }); Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineLabelProvider.java Mon Jul 22 12:23:55 2019 @@ -26,15 +26,19 @@ import org.eclipse.jface.viewers.ITableL import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; + /** * This <code>OutlineLabelProvider</code> returns the covered text of an <code>AnnotationFS</code>. */ class OutlineLabelProvider extends LabelProvider implements ITableLabelProvider { + + @Override public Image getColumnImage(Object element, int columnIndex) { // no image available, just return null return null; } + @Override public String getColumnText(Object element, int columnIndex) { // there is only one column, if column index something // else than 0, then there is an error @@ -61,6 +65,12 @@ class OutlineLabelProvider extends Label return "Unkown type"; } + /** + * Gets the string without new line. + * + * @param string the string + * @return the string without new line + */ private static String getStringWithoutNewLine(String string) { StringBuilder stringBuilder = new StringBuilder(string.length()); @@ -81,4 +91,4 @@ class OutlineLabelProvider extends Label return stringBuilder.toString(); } -} \ No newline at end of file +} Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlinePageBook.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlinePageBook.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlinePageBook.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlinePageBook.java Mon Jul 22 12:23:55 2019 @@ -29,11 +29,19 @@ import org.eclipse.ui.part.IPageBookView import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; + +/** + * The Class OutlinePageBook. + */ public class OutlinePageBook extends CasEditorViewPage implements IContentOutlinePage, ISelectionChangedListener { + /** The viewer. */ private Viewer viewer; + /** + * Instantiates a new outline page book. + */ public OutlinePageBook() { super("An outline it not available!"); } @@ -67,6 +75,11 @@ public class OutlinePageBook extends Cas } } + /** + * Gets the cas view page. + * + * @return the cas view page + */ public IPageBookViewPage getCasViewPage() { return casViewPage; } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineStyles.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineStyles.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineStyles.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineStyles.java Mon Jul 22 12:23:55 2019 @@ -19,8 +19,15 @@ package org.apache.uima.caseditor.editor.outline; + +/** + * The Enum OutlineStyles. + */ public enum OutlineStyles { + /** The mode. */ MODE, + + /** The type. */ TYPE } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/OutlineTableSorter.java Mon Jul 22 12:23:55 2019 @@ -26,6 +26,7 @@ import org.eclipse.core.runtime.IAdaptab import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; + /** * Sorts <code>AnnotationFS</code>s for a Viewer. This implementation is based on * <code>AnnotationComparator</code>. @@ -33,14 +34,18 @@ import org.eclipse.jface.viewers.ViewerS * @see AnnotationComparator */ class OutlineTableSorter extends ViewerSorter { + + /** The m comperator. */ private AnnotationComparator mComperator = new AnnotationComparator(); /** * Uses <code>AnnotationComparator</code> to compare the both objects. * + * @param viewer the viewer + * @param aObject the a object + * @param bObject the b object * @return int the return value is if aObject < bObject negative number, if aObject == bObject 0, * aObject > bObject a positive number or if both objects have different types 1. - * * @see ViewerSorter */ @Override Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/SwitchStyleAction.java Mon Jul 22 12:23:55 2019 @@ -22,22 +22,29 @@ package org.apache.uima.caseditor.editor import org.apache.uima.caseditor.editor.CasEditorError; import org.eclipse.jface.action.Action; + /** * This action triggers the switch of the outline style. */ public class SwitchStyleAction extends Action { + /** The outline. */ private AnnotationOutline outline; + /** + * Instantiates a new switch style action. + * + * @param outline the outline + */ SwitchStyleAction(AnnotationOutline outline) { this.outline = outline; } - + @Override public String getText() { return "Switch style"; } - + @Override public void run() { @@ -48,7 +55,7 @@ public class SwitchStyleAction extends A outline.switchStyle(OutlineStyles.MODE); } else { - throw new CasEditorError("Unkown style!"); + throw new CasEditorError("Unknown style!"); } } } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/outline/TypeGroupedContentProvider.java Mon Jul 22 12:23:55 2019 @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Set; import org.apache.uima.cas.CAS; -import org.apache.uima.cas.FSIterator; import org.apache.uima.cas.Type; import org.apache.uima.cas.TypeSystem; import org.apache.uima.cas.text.AnnotationFS; @@ -37,6 +36,7 @@ import org.apache.uima.caseditor.editor. import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Display; + /** * The content provider for the type grouped annotation outline. * @@ -46,14 +46,20 @@ import org.eclipse.swt.widgets.Display; */ public class TypeGroupedContentProvider extends OutlineContentProviderBase { + /** The name annotation type node map. */ // map of AnnotationTypeTreeNode - private Map<String, AnnotationTypeTreeNode> nameAnnotationTypeNodeMap = - new HashMap<String, AnnotationTypeTreeNode>(); + private Map<String, AnnotationTypeTreeNode> nameAnnotationTypeNodeMap = new HashMap<>(); + /** + * Instantiates a new type grouped content provider. + * + * @param editor the editor + * @param viewer the viewer + */ TypeGroupedContentProvider(AnnotationEditor editor, TreeViewer viewer) { super(editor, viewer); } - + @Override protected void addedAnnotation(Collection<AnnotationFS> annotations) { @@ -73,7 +79,7 @@ public class TypeGroupedContentProvider @Override protected void removedAnnotation(Collection<AnnotationFS> annotations) { - Set<AnnotationTreeNode> removeAnnotations = new HashSet<AnnotationTreeNode>(); + Set<AnnotationTreeNode> removeAnnotations = new HashSet<>(); for (AnnotationFS annotation : annotations) { String name = annotation.getType().getName(); @@ -94,12 +100,14 @@ public class TypeGroupedContentProvider viewer.remove(removeAnnotations.toArray()); } - public Object[] getElements(Object inputElement) { + @Override + public Object[] getElements(Object inputElement) { return nameAnnotationTypeNodeMap.values().toArray(); } - public Object getParent(Object element) { + @Override + public Object getParent(Object element) { if (element instanceof AnnotationTreeNode) { AnnotationTreeNode annotation = (AnnotationTreeNode) element; @@ -126,7 +134,8 @@ public class TypeGroupedContentProvider } } - public boolean hasChildren(Object element) { + @Override + public boolean hasChildren(Object element) { if (element instanceof AnnotationTypeTreeNode) { AnnotationTypeTreeNode treeNode = (AnnotationTypeTreeNode) element; @@ -136,18 +145,21 @@ public class TypeGroupedContentProvider } } - public Object[] getChildren(Object parentElement) { + @Override + public Object[] getChildren(Object parentElement) { AnnotationTypeTreeNode typeNode = (AnnotationTypeTreeNode) parentElement; return typeNode.getAnnotations(); } - public void viewChanged(String oldViewName, String newViewName) { + @Override + public void viewChanged(String oldViewName, String newViewName) { changed(); } - - public void changed() { + +@Override + public void changed() { nameAnnotationTypeNodeMap.clear(); TypeSystem typeSystem = mInputDocument.getCAS().getTypeSystem(); @@ -166,17 +178,16 @@ public class TypeGroupedContentProvider CAS cas = mInputDocument.getCAS(); AnnotationIndex<AnnotationFS> index = cas.getAnnotationIndex(type); - - for (FSIterator<AnnotationFS> it = index.iterator(); it.hasNext(); ) { - AnnotationFS annotation = it.next(); - + + for (AnnotationFS annotation : index) { if (annotation.getType().equals(type)) { - typeNode.add(new AnnotationTreeNode(mInputDocument, annotation)); + typeNode.add(new AnnotationTreeNode(mInputDocument, annotation)); } } } Display.getDefault().syncExec(new Runnable() { + @Override public void run() { viewer.refresh(); } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleView.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleView.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleView.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleView.java Mon Jul 22 12:23:55 2019 @@ -24,7 +24,11 @@ import org.apache.uima.caseditor.editor. import org.apache.uima.caseditor.editor.ICasEditor; import org.eclipse.ui.part.IPageBookViewPage; + // Tree Table, one column contains a tree, representing the tree structure +/** + * The Class AnnotationStyleView. + */ // of the uima types public class AnnotationStyleView extends CasEditorView { @@ -33,18 +37,19 @@ public class AnnotationStyleView extends */ public static final String ID = "org.apache.uima.caseditor.styleview"; + /** + * Instantiates a new annotation style view. + */ public AnnotationStyleView() { super("The annotation style view is currently not available."); } - + @Override protected IPageBookViewPage doCreatePage(ICasEditor editor) { IPageBookViewPage result = null; if (editor.getDocument() != null && editor instanceof AnnotationEditor) { - AnnotationStyleViewPage page = new AnnotationStyleViewPage((AnnotationEditor) editor); - - result = page; + result = new AnnotationStyleViewPage((AnnotationEditor) editor); } return result; Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleViewPage.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleViewPage.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleViewPage.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationStyleViewPage.java Mon Jul 22 12:23:55 2019 @@ -65,23 +65,39 @@ import org.eclipse.ui.dialogs.PropertyPa import org.eclipse.ui.internal.dialogs.PropertyDialog; import org.eclipse.ui.part.Page; + // TODO: Subscribe to style change events +/** + * The Class AnnotationStyleViewPage. + */ // create new listener interface for this class AnnotationStyleViewPage extends Page { + /** + * The Class AnnotationTypeContentProvider. + */ static class AnnotationTypeContentProvider implements ITreeContentProvider { + /** The annotation types. */ private AnnotationTypeNode[] annotationTypes; + /** The editor. */ private AnnotationEditor editor; + /** + * Instantiates a new annotation type content provider. + * + * @param editor the editor + */ AnnotationTypeContentProvider(AnnotationEditor editor) { this.editor = editor; } - + + @Override public void dispose() { } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (newInput instanceof TypeSystem) { @@ -103,51 +119,73 @@ class AnnotationStyleViewPage extends Pa } + @Override public Object[] getElements(Object inputElement) { return annotationTypes; } + @Override public Object[] getChildren(Object parentElement) { return null; } + @Override public Object getParent(Object element) { return null; } + @Override public boolean hasChildren(Object element) { return false; } } + /** + * The Class AnnotationStylingLabelProvider. + */ static class AnnotationStylingLabelProvider implements ITableLabelProvider, IColorProvider { + /** The type name column. */ private static int TYPE_NAME_COLUMN = 0; + + /** The style name column. */ private static int STYLE_NAME_COLUMN = 1; + /** The editor. */ private AnnotationEditor editor; + /** + * Instantiates a new annotation styling label provider. + * + * @param editor the editor + */ AnnotationStylingLabelProvider(AnnotationEditor editor) { this.editor = editor; } - + + @Override public void addListener(ILabelProviderListener listener) { } + @Override public void dispose() { } + @Override public boolean isLabelProperty(Object element, String property) { return false; } + @Override public void removeListener(ILabelProviderListener listener) { } + @Override public Image getColumnImage(Object element, int columnIndex) { return null; } + @Override public String getColumnText(Object element, int columnIndex) { AnnotationTypeNode typeNode = (AnnotationTypeNode) element; @@ -164,14 +202,16 @@ class AnnotationStyleViewPage extends Pa return style.getStyle().toString(); } else { - throw new IllegalStateException("Unkown column!"); + throw new IllegalStateException("Unknown column!"); } } + @Override public Color getForeground(Object element) { return null; } + @Override public Color getBackground(Object element) { AnnotationTypeNode typeNode = (AnnotationTypeNode) element; @@ -185,18 +225,34 @@ class AnnotationStyleViewPage extends Pa } } + /** The editor. */ private AnnotationEditor editor; + /** The editor listener. */ private IAnnotationEditorModifyListener editorListener; + /** The change listener. */ private AnnotationStyleChangeListener changeListener; + /** The tree viewer. */ private CheckboxTableViewer treeViewer; + /** + * Instantiates a new annotation style view page. + * + * @param editor the editor + */ AnnotationStyleViewPage(AnnotationEditor editor) { this.editor = editor; } + /** + * Types to nodes. + * + * @param types the types + * @param editor the editor + * @return the annotation type node[] + */ private static AnnotationTypeNode[] typesToNodes(Collection<Type> types, AnnotationEditor editor) { Collection<Type> shownTypes = editor.getShownAnnotationTypes(); @@ -209,7 +265,7 @@ class AnnotationStyleViewPage extends Pa return selectedNodes; } - + @Override public void createControl(Composite parent) { @@ -221,6 +277,7 @@ class AnnotationStyleViewPage extends Pa final Color defaultForegroundColor = table.getForeground(); table.addListener(SWT.EraseItem, new Listener() { + @Override public void handleEvent(Event event) { if((event.detail & SWT.SELECTED) != 0 ){ event.detail &= ~SWT.SELECTED; @@ -236,10 +293,10 @@ class AnnotationStyleViewPage extends Pa typeColumn.setText("Type"); typeColumn.setWidth(120); - TableColumn stlyeColumn = new TableColumn(table, SWT.LEFT); - stlyeColumn.setAlignment(SWT.LEFT); - stlyeColumn.setText("Style"); - stlyeColumn.setWidth(100); + TableColumn styleColumn = new TableColumn(table, SWT.LEFT); + styleColumn.setAlignment(SWT.LEFT); + styleColumn.setText("Style"); + styleColumn.setWidth(100); treeViewer.setContentProvider(new AnnotationTypeContentProvider(editor)); treeViewer.setLabelProvider(new AnnotationStylingLabelProvider(editor)); @@ -250,6 +307,7 @@ class AnnotationStyleViewPage extends Pa changeListener = new AnnotationStyleChangeListener() { + @Override public void annotationStylesChanged(Collection<AnnotationStyle> styles) { // Update all changed style elements in the table @@ -276,6 +334,7 @@ class AnnotationStyleViewPage extends Pa treeViewer.addCheckStateListener(new ICheckStateListener() { + @Override public void checkStateChanged(CheckStateChangedEvent event) { AnnotationTypeNode typeNode = (AnnotationTypeNode) event.getElement(); @@ -294,10 +353,12 @@ class AnnotationStyleViewPage extends Pa editorListener = new IAnnotationEditorModifyListener() { + @Override public void showAnnotationsChanged(Collection<Type> shownAnnotationTypes) { treeViewer.setCheckedElements(typesToNodes(shownAnnotationTypes, editor)); } + @Override public void annotationModeChanged(Type newMode) { // maybe slow if there are many types treeViewer.setAllGrayed(false); @@ -344,7 +405,7 @@ class AnnotationStyleViewPage extends Pa toolBarManager.add(action); } - + @Override public Control getControl() { return treeViewer.getControl(); @@ -354,7 +415,7 @@ class AnnotationStyleViewPage extends Pa public void setFocus() { treeViewer.getControl().setFocus(); } - + @Override public void dispose() { super.dispose(); Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java?rev=1863543&r1=1863542&r2=1863543&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/styleview/AnnotationTypeNode.java Mon Jul 22 12:23:55 2019 @@ -23,24 +23,47 @@ import org.apache.uima.cas.Type; import org.apache.uima.caseditor.editor.AnnotationEditor; import org.eclipse.core.runtime.IAdaptable; + +/** + * The Class AnnotationTypeNode. + */ public class AnnotationTypeNode implements IAdaptable{ + /** The editor. */ private AnnotationEditor editor; + + /** The type. */ private Type type; + /** + * Instantiates a new annotation type node. + * + * @param editor the editor + * @param type the type + */ AnnotationTypeNode(AnnotationEditor editor, Type type) { this.editor = editor; this.type = type; } + /** + * Gets the editor. + * + * @return the editor + */ public AnnotationEditor getEditor() { return editor; } + /** + * Gets the annotation type. + * + * @return the annotation type + */ public Type getAnnotationType() { return type; } - + @Override public boolean equals(Object obj) { @@ -53,12 +76,13 @@ public class AnnotationTypeNode implemen return false; } - + @Override public int hashCode() { return type.hashCode(); } + @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (AnnotationTypeNode.class.equals(adapter)) { Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationComparator.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationComparator.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/AnnotationComparator.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationComparator.java Mon Jul 22 12:23:55 2019 @@ -24,16 +24,23 @@ import java.util.Comparator; import org.apache.uima.cas.text.AnnotationFS; + /** * Checks two annotations for equality. */ public class AnnotationComparator implements Comparator<AnnotationFS>, Serializable { + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; /** * Compares the given annotations a and b. This implementations only compares the begin index. + * + * @param a the a + * @param b the b + * @return the int */ + @Override public int compare(AnnotationFS a, AnnotationFS b) { return a.getBegin() - b.getBegin(); } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationSelection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationSelection.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/AnnotationSelection.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/AnnotationSelection.java Mon Jul 22 12:23:55 2019 @@ -31,6 +31,7 @@ import org.apache.uima.caseditor.editor. import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; + /** * The annotation collection contains only {@link AnnotationFS}s objects which are selected by a * {@link IStructuredSelection}. @@ -39,15 +40,16 @@ import org.eclipse.jface.viewers.Structu */ public class AnnotationSelection { + /** The m annotations. */ private List<AnnotationFS> mAnnotations; /** * Initializes the current instance. * - * @param structures + * @param structures the structures */ public AnnotationSelection(Collection<FeatureStructure> structures) { - mAnnotations = new ArrayList<AnnotationFS>(structures.size()); + mAnnotations = new ArrayList<>(structures.size()); for (FeatureStructure structure : structures) { if (structure instanceof AnnotationFS) { @@ -55,21 +57,21 @@ public class AnnotationSelection { } } - Collections.sort(mAnnotations, new AnnotationComparator()); + mAnnotations.sort(new AnnotationComparator()); } /** * Initializes a the current instance with all AnnotationFS object that are contained in the * {@link StructuredSelection}. - * + * * Note: {@link AnnotationFS} instances will be sorted in this selection, the natural oder of * the selection is destroyed * - * @param selection + * @param selection the selection */ public AnnotationSelection(IStructuredSelection selection) { - mAnnotations = new ArrayList<AnnotationFS>(selection.size()); + mAnnotations = new ArrayList<>(selection.size()); for (Iterator<FeatureStructure> it = new FeatureStructureSelectionIterator(selection); it.hasNext();) { @@ -80,7 +82,7 @@ public class AnnotationSelection { } } - Collections.sort(mAnnotations, new AnnotationComparator()); + mAnnotations.sort(new AnnotationComparator()); mAnnotations = Collections.unmodifiableList(mAnnotations); } @@ -128,9 +130,8 @@ public class AnnotationSelection { /** * Retrieves an ordered list of {@link AnnotationFS} objects. * - * @see AnnotationComparator is used for ordering the annotations - * * @return all selected {@link AnnotationFS} objects + * @see AnnotationComparator is used for ordering the annotations */ public List<AnnotationFS> toList() { return mAnnotations; Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ContainingConstraint.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ContainingConstraint.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/ContainingConstraint.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/ContainingConstraint.java Mon Jul 22 12:23:55 2019 @@ -26,21 +26,24 @@ import org.apache.uima.cas.FSMatchConstr import org.apache.uima.cas.FeatureStructure; import org.apache.uima.cas.text.AnnotationFS; + /** * Filters out all annotations which are not contained by one of the provided * annotations. */ public class ContainingConstraint implements FSMatchConstraint { + /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1; - private Collection<AnnotationFS> mContainingAnnotations = new LinkedList<AnnotationFS>(); + /** The m containing annotations. */ + private Collection<AnnotationFS> mContainingAnnotations = new LinkedList<>(); /** * Adds an annotation in which the an other annotations must be contained to match this * constraint. * - * @param containingAnnotation + * @param containingAnnotation the containing annotation */ public void add(AnnotationFS containingAnnotation) { mContainingAnnotations.add(containingAnnotation); @@ -48,7 +51,11 @@ public class ContainingConstraint implem /** * Checks if the given FeatureStructure is inside the a containing annotation. + * + * @param featureStructure the feature structure + * @return true, if successful */ + @Override public boolean match(FeatureStructure featureStructure) { boolean result = false; @@ -66,16 +73,15 @@ public class ContainingConstraint implem return result; } + /** + * Checks if is containing. + * + * @param annotation the annotation + * @param containing the containing + * @return true, if is containing + */ private boolean isContaining(AnnotationFS annotation, AnnotationFS containing) { - boolean isContaining; - - if (containing.getBegin() <= annotation.getBegin() - && containing.getEnd() >= annotation.getEnd()) { - isContaining = true; - } else { - isContaining = false; - } - - return isContaining; + return containing.getBegin() <= annotation.getBegin() + && containing.getEnd() >= annotation.getEnd(); } } Modified: uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/FeatureStructureTransfer.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/FeatureStructureTransfer.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/FeatureStructureTransfer.java (original) +++ uima/uimaj/trunk/uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/editor/util/FeatureStructureTransfer.java Mon Jul 22 12:23:55 2019 @@ -19,12 +19,15 @@ package org.apache.uima.caseditor.editor.util; + /** * This class is able to transfer a {@link org.apache.uima.cas.FeatureStructure} * objects. */ public class FeatureStructureTransfer extends ObjectTransfer { + + /** The s feature structure transfer. */ private static FeatureStructureTransfer sFeatureStructureTransfer; /**