You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/02/20 20:01:20 UTC
svn commit: r509708 [4/7] - in /incubator/uima/sandbox/trunk/CasEditor: ./
META-INF/ src/main/assembly/ src/main/java/org/apache/uima/caseditor/
src/main/java/org/apache/uima/caseditor/core/
src/main/java/org/apache/uima/caseditor/core/model/ src/main/...
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationInformationProvider.java Tue Feb 20 11:01:12 2007
@@ -1,85 +1,83 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.List;
-
-import org.apache.uima.cas.text.AnnotationFS;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * TODO: move this class to external file.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- */
-class AnnotationInformationProvider implements IInformationProvider, IInformationProviderExtension {
- private AnnotationEditor mEditor;
-
- AnnotationInformationProvider(AnnotationEditor editor) {
- mEditor = editor;
- }
-
- /**
- * TODO: add comment
- *
- * @param textViewer
- * @param offset
- * @return the region
- */
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- Point selection = textViewer.getTextWidget().getSelection();
-
- int length = selection.y - selection.x;
- return new Region(offset, length);
- }
-
- /**
- * TODO: add comment
- *
- * @param textViewer
- * @param subject
- * @return null
- */
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return null;
- }
-
- /**
- * TODO: add comment
- *
- * @param textViewer
- * @param subject
- * @return the selected annoation
- */
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- List<AnnotationFS> selection = mEditor.getSelectedAnnotations();
-
- if (selection != null && selection.size() > 0) {
- return selection.get(0);
- } else {
- return null;
- }
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.List;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * TODO: move this class to external file.
+ */
+class AnnotationInformationProvider implements IInformationProvider, IInformationProviderExtension {
+ private AnnotationEditor mEditor;
+
+ AnnotationInformationProvider(AnnotationEditor editor) {
+ mEditor = editor;
+ }
+
+ /**
+ * TODO: add comment
+ *
+ * @param textViewer
+ * @param offset
+ * @return the region
+ */
+ public IRegion getSubject(ITextViewer textViewer, int offset) {
+ Point selection = textViewer.getTextWidget().getSelection();
+
+ int length = selection.y - selection.x;
+ return new Region(offset, length);
+ }
+
+ /**
+ * TODO: add comment
+ *
+ * @param textViewer
+ * @param subject
+ * @return null
+ */
+ public String getInformation(ITextViewer textViewer, IRegion subject) {
+ return null;
+ }
+
+ /**
+ * TODO: add comment
+ *
+ * @param textViewer
+ * @param subject
+ * @return the selected annoation
+ */
+ public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+ List<AnnotationFS> selection = mEditor.getSelectedAnnotations();
+
+ if (selection != null && selection.size() > 0) {
+ return selection.get(0);
+ } else {
+ return null;
+ }
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java Tue Feb 20 11:01:12 2007
@@ -1,122 +1,145 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.uima.AnnotationComparator;
-import org.eclipse.core.runtime.IAdaptable;
-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}.
- *
- * Its also possible to retrive the frist and last annotation
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:54 $
- */
-public class AnnotationSelection {
- private List<AnnotationFS> mAnnotations;
-
- /**
- * Initializes a the current instance with all AnnotationFS obejct that are contained in the
- * {@link StructuredSelection}.
- *
- * Note: {@link AnnotationFS} instances will be sorted in this selection, the natural odering of
- * the selection is destroyed
- *
- * @param selection
- */
- public AnnotationSelection(IStructuredSelection selection) {
- mAnnotations = new ArrayList<AnnotationFS>(selection.size());
-
- for (Object item : selection.toList()) {
- AnnotationFS annotation = null;
-
- if (item instanceof IAdaptable) {
- annotation = (AnnotationFS) ((IAdaptable) item).getAdapter(AnnotationFS.class);
- }
-
- if (annotation != null) {
- mAnnotations.add(annotation);
- }
- }
-
- Collections.sort(mAnnotations, new AnnotationComparator());
- }
-
- /**
- * Retrives the size of the selection.
- *
- * @return the size
- */
- public int size() {
- return mAnnotations.size();
- }
-
- /**
- * Indicates that the selection contains no elements.
- *
- * @return true if empty
- */
- public boolean isEmtpy() {
- return size() == 0;
- }
-
- /**
- * Retrives the first selected element.
- *
- * Note: If {@link #size()} == 0 then frist and last element are the same instance.
- *
- * @return the last element
- */
- public AnnotationFS getFirst() {
- return mAnnotations.isEmpty() ? null : mAnnotations.get(0);
- }
-
- /**
- * Retrives the last selected element.
- *
- * Note: If {@link #size()} == 0 then frist and last element are the same instance.
- *
- * @return the last element
- */
- public AnnotationFS getLast() {
- return mAnnotations.isEmpty() ? null : mAnnotations.get(size() - 1);
- }
-
- /**
- * Retrives an ordered list of {@link AnnotationFS} objects.
- *
- * @see AnnotationComparator is used for ordering the annotations
- *
- * @return all selected {@link AnnotationFS} objects
- */
- public List<AnnotationFS> toList() {
- return Collections.unmodifiableList(mAnnotations);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.uima.AnnotationComparator;
+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}.
+ *
+ * Its also possible to retrive the frist and last annotation
+ */
+public class AnnotationSelection {
+
+ private List<AnnotationFS> mAnnotations;
+
+ /**
+ * Initializes the current instance.
+ *
+ * @param structures
+ */
+ public AnnotationSelection(Collection<FeatureStructure> structures) {
+ mAnnotations = new ArrayList<AnnotationFS>(structures.size());
+
+ for (FeatureStructure structure : structures) {
+ add(structure);
+ }
+
+ Collections.sort(mAnnotations, 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 odering of
+ * the selection is destroyed
+ *
+ * @param selection
+ */
+ public AnnotationSelection(IStructuredSelection selection) {
+
+ mAnnotations = new ArrayList<AnnotationFS>(selection.size());
+
+ for (Iterator<FeatureStructure> it = new FeatureStructureSelectionIterator(selection);
+ it.hasNext();) {
+ add(it.next());
+ }
+
+ Collections.sort(mAnnotations, new AnnotationComparator());
+ }
+
+ private void add(FeatureStructure structure) {
+ if (structure instanceof AnnotationFS) {
+ mAnnotations.add((AnnotationFS) structure);
+ }
+ }
+
+ /**
+ * Indicates that the selection is empty.
+ *
+ * @return true if emtpy
+ */
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Retrives the size of the collection.
+ *
+ * @return the size
+ */
+ public int size() {
+ return mAnnotations.size();
+ }
+
+ /**
+ * Retrives the first selected element.
+ *
+ * Note: If {@link #size()} == 0 then frist and last element are the same instance.
+ *
+ * @return the last element
+ */
+ public AnnotationFS getFirst() {
+ return isEmpty() ? null : mAnnotations.get(0);
+ }
+
+ /**
+ * Retrives the last selected element.
+ *
+ * Note: If {@link #size()} == 0 then frist and last element are the same instance.
+ *
+ * @return the last element
+ */
+ public AnnotationFS getLast() {
+ return isEmpty() ? null : mAnnotations.get(size() - 1);
+ }
+
+ /**
+ * Retrives an ordered list of {@link AnnotationFS} objects.
+ *
+ * @see AnnotationComparator is used for ordering the annotations
+ *
+ * @return all selected {@link AnnotationFS} objects
+ */
+ public List<AnnotationFS> toList() {
+ return (List<AnnotationFS>) Collections.unmodifiableList(mAnnotations);
+ }
+
+ /**
+ * Retrives a human readable string.
+ * @return humand readable string
+ */
+ @Override
+ public String toString() {
+ return mAnnotations.toString();
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelectionListener.java Tue Feb 20 11:01:12 2007
@@ -1,46 +1,43 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.Collection;
-
-import org.apache.uima.cas.text.AnnotationFS;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:55 $
- */
-public abstract class AnnotationSelectionListener implements ISelectionListener {
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- }
-
- protected abstract void selectedAnnotation(Collection<AnnotationFS> annotations);
-
- /**
- * Indicates that the selection did not contain any annotations.
- */
- protected abstract void emptySelection();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.Collection;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * TODO: add javadoc here
+ */
+public abstract class AnnotationSelectionListener implements ISelectionListener {
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ }
+
+ protected abstract void selectedAnnotation(Collection<AnnotationFS> annotations);
+
+ /**
+ * Indicates that the selection did not contain any annotations.
+ */
+ protected abstract void emptySelection();
+}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ChangeModeAction.java Tue Feb 20 11:01:12 2007
@@ -24,9 +24,6 @@
/**
* The {@link ChangeModeAction} changes the editor annotation mode to the newly selected one.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.3.2.2 $, $Date: 2007/01/04 15:00:54 $
*/
final class ChangeModeAction extends Action {
/**
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/CustomInformationControl.java Tue Feb 20 11:01:12 2007
@@ -35,9 +35,6 @@
/**
* TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:55 $
*/
public class CustomInformationControl implements IInformationControl, IInformationControlExtension2 {
private Shell mShell;
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java Tue Feb 20 11:01:12 2007
@@ -1,61 +1,58 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:54 $
- */
-public class FeatureStructureSelection {
- private List<FeatureStructure> mFeatureStructures;
-
- /**
- * Initializes a the current instance with all AnnotationFS obejct that are contained in the
- * {@link StructuredSelection}.
- *
- * Note: {@link AnnotationFS} instances will be sorted in this selection, the natural odering of
- * the selection is destroyed
- *
- * @param selection
- */
- public FeatureStructureSelection(IStructuredSelection selection) {
- mFeatureStructures = new ArrayList<FeatureStructure>(selection.size());
-
- for (Object item : selection.toList()) {
- FeatureStructure annotation = (FeatureStructure) Platform.getAdapterManager().getAdapter(
- item, FeatureStructure.class);
-
- if (annotation != null) {
- mFeatureStructures.add(annotation);
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ * TODO: add javadoc here
+ */
+public class FeatureStructureSelection {
+ private List<FeatureStructure> mFeatureStructures;
+
+ /**
+ * Initializes a the current instance with all AnnotationFS obejct that are contained in the
+ * {@link StructuredSelection}.
+ *
+ * Note: {@link AnnotationFS} instances will be sorted in this selection, the natural odering of
+ * the selection is destroyed
+ *
+ * @param selection
+ */
+ public FeatureStructureSelection(IStructuredSelection selection) {
+ mFeatureStructures = new ArrayList<FeatureStructure>(selection.size());
+
+ for (Object item : selection.toList()) {
+ FeatureStructure annotation = (FeatureStructure) Platform.getAdapterManager().getAdapter(
+ item, FeatureStructure.class);
+
+ if (annotation != null) {
+ mFeatureStructures.add(annotation);
+ }
+ }
+ }
+}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java?view=auto&rev=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java Tue Feb 20 11:01:12 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Iterates over all selected {@link FeatureStructure}s.
+ */
+public class FeatureStructureSelectionIterator implements Iterator<FeatureStructure> {
+
+ private Iterator mSelectionIterator;
+
+ private FeatureStructure mNext;
+
+ /**
+ * Initializes the current instance.
+ *
+ * @param selection
+ */
+ public FeatureStructureSelectionIterator(IStructuredSelection selection) {
+ mSelectionIterator = selection.iterator();
+ }
+
+ /**
+ * Check if there is one more element.
+ *
+ * @return true if there is one more element.
+ */
+ public boolean hasNext() {
+ while (mSelectionIterator.hasNext() && mNext == null) {
+ Object item = mSelectionIterator.next();
+
+ if (item instanceof IAdaptable) {
+ mNext = (FeatureStructure) ((IAdaptable) item).getAdapter(AnnotationFS.class);
+ }
+ }
+
+ return mNext != null;
+ }
+
+ /**
+ * Retrives the next element.
+ *
+ * @return the next element.
+ */
+ public FeatureStructure next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+
+ FeatureStructure result = mNext;
+ mNext = null;
+
+ return result;
+ }
+
+ /**
+ * Not supported, it throws an {@link UnsupportedOperationException}.
+ *
+ * @throws UnsupportedOperationException
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionProvider.java Tue Feb 20 11:01:12 2007
@@ -1,139 +1,135 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-/**
- * This class is a {@link ISelectionProvider} and informs its listeners about the currently selected
- * {@link FeatureStructure}s.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:55 $
- */
-class FeatureStructureSelectionProvider implements ISelectionProvider {
-
- private IStructuredSelection mCurrentSelection = new StructuredSelection();
-
- private Set<ISelectionChangedListener> mListeners = new HashSet<ISelectionChangedListener>();
-
- private IDocument mDocument;
-
- public FeatureStructureSelectionProvider(IDocument document) {
- mDocument = document;
- }
-
- /**
- * Adds an {@link ISelectionChangedListener} to this provider.
- *
- * @param listener
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- Assert.isNotNull(listener);
-
- mListeners.add(listener);
- }
-
- /**
- * Retrives the current selection.
- *
- * @return selection
- */
- public ISelection getSelection() {
- return mCurrentSelection;
- }
-
- /**
- * Removes a registered selection listener.
- *
- * @param listener
- * the listener to remove
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * Sets the current selection.
- *
- * @param selection
- */
- public void setSelection(ISelection selection) {
- Assert.isNotNull(selection);
-
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
- mCurrentSelection = structuredSelection;
-
- for (ISelectionChangedListener listener : mListeners) {
- SelectionChangedEvent event = new SelectionChangedEvent(this, mCurrentSelection);
-
- listener.selectionChanged(event);
- }
- }
-
- /**
- * Sets the current selection to the given {@link AnnotationFS} object.
- *
- * @param annotation
- */
- public void setSelection(IDocument document, AnnotationFS annotation) {
- if (annotation == null) {
- throw new IllegalArgumentException("annotation must not be null!");
- }
-
- setSelection(new StructuredSelection(new ModelFeatureStructure(mDocument, annotation)));
- }
-
- public void setSelection(IDocument document, List<AnnotationFS> selection) {
- setSelection(new StructuredSelection(ModelFeatureStructure.create(document, selection)));
- }
-
- /**
- * Replaces the current selection with an emtpy selection.
- */
- public void clearSelection() {
- setSelection(new StructuredSelection());
- }
-
- /**
- * Replaces the current selection with an emtpy selectionw without notifiying listeners about it.
- *
- * Use it if the selection object is removed and a new selection was already made by an other
- * {@link ISelectionProvider} instance.
- */
- public void clearSelectionSilently() {
- mCurrentSelection = new StructuredSelection();
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ * This class is a {@link ISelectionProvider} and informs its listeners about the currently selected
+ * {@link FeatureStructure}s.
+ */
+class FeatureStructureSelectionProvider implements ISelectionProvider {
+
+ private IStructuredSelection mCurrentSelection = new StructuredSelection();
+
+ private Set<ISelectionChangedListener> mListeners = new HashSet<ISelectionChangedListener>();
+
+ private IDocument mDocument;
+
+ public FeatureStructureSelectionProvider(IDocument document) {
+ mDocument = document;
+ }
+
+ /**
+ * Adds an {@link ISelectionChangedListener} to this provider.
+ *
+ * @param listener
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ Assert.isNotNull(listener);
+
+ mListeners.add(listener);
+ }
+
+ /**
+ * Retrives the current selection.
+ *
+ * @return selection
+ */
+ public ISelection getSelection() {
+ return mCurrentSelection;
+ }
+
+ /**
+ * Removes a registered selection listener.
+ *
+ * @param listener
+ * the listener to remove
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ mListeners.remove(listener);
+ }
+
+ /**
+ * Sets the current selection.
+ *
+ * @param selection
+ */
+ public void setSelection(ISelection selection) {
+ Assert.isNotNull(selection);
+
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+ mCurrentSelection = structuredSelection;
+
+ for (ISelectionChangedListener listener : mListeners) {
+ SelectionChangedEvent event = new SelectionChangedEvent(this, mCurrentSelection);
+
+ listener.selectionChanged(event);
+ }
+ }
+
+ /**
+ * Sets the current selection to the given {@link AnnotationFS} object.
+ *
+ * @param annotation
+ */
+ public void setSelection(IDocument document, AnnotationFS annotation) {
+ if (annotation == null) {
+ throw new IllegalArgumentException("annotation must not be null!");
+ }
+
+ setSelection(new StructuredSelection(new ModelFeatureStructure(mDocument, annotation)));
+ }
+
+ public void setSelection(IDocument document, List<AnnotationFS> selection) {
+ setSelection(new StructuredSelection(ModelFeatureStructure.create(document, selection)));
+ }
+
+ /**
+ * Replaces the current selection with an emtpy selection.
+ */
+ public void clearSelection() {
+ setSelection(new StructuredSelection());
+ }
+
+ /**
+ * Replaces the current selection with an emtpy selectionw without notifiying listeners about it.
+ *
+ * Use it if the selection object is removed and a new selection was already made by an other
+ * {@link ISelectionProvider} instance.
+ */
+ public void clearSelectionSilently() {
+ mCurrentSelection = new StructuredSelection();
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java Tue Feb 20 11:01:12 2007
@@ -29,12 +29,6 @@
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.views.properties.IPropertySource;
-/**
- *
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.4.2.2 $, $Date: 2007/01/04 15:00:55 $
- */
public final class FeatureValue implements IAdaptable {
private FeatureStructure mStructure;
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IAnnotationEditorModifyListener.java Tue Feb 20 11:01:12 2007
@@ -21,12 +21,6 @@
import org.apache.uima.cas.Type;
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:54 $
- */
public interface IAnnotationEditorModifyListener {
/**
* Called if the editor annotation mode changed.
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ICustomInformationControlContentHandler.java Tue Feb 20 11:01:12 2007
@@ -19,12 +19,6 @@
package org.apache.uima.caseditor.editor;
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:55 $
- */
public interface ICustomInformationControlContentHandler {
/**
* Sets the input object.
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/IEditorSelectionListener.java Tue Feb 20 11:01:12 2007
@@ -19,12 +19,6 @@
package org.apache.uima.caseditor.editor;
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:54 $
- */
public interface IEditorSelectionListener {
/**
* Called after focus changed.
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ModelFeatureStructure.java Tue Feb 20 11:01:12 2007
@@ -1,86 +1,103 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-
-/**
- * TODO: add javadoc here
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:54 $
- */
-public class ModelFeatureStructure implements IAdaptable {
- private IDocument mDocument;
-
- private FeatureStructure mFeatureStructre;
-
- /**
- * Initializes a new instance.
- *
- * @param document
- * @param featureStructre
- */
- public ModelFeatureStructure(IDocument document, FeatureStructure featureStructre) {
- mDocument = document;
- mFeatureStructre = featureStructre;
- }
-
- public IDocument getDocument() {
- return mDocument;
- }
-
- public FeatureStructure getStructre() {
- return mFeatureStructre;
- }
-
- public static List<ModelFeatureStructure> create(IDocument document,
- List<AnnotationFS> annotations) {
- List<ModelFeatureStructure> structres = new ArrayList<ModelFeatureStructure>(annotations.size());
-
- for (AnnotationFS annotation : annotations) {
- structres.add(new ModelFeatureStructure(document, annotation));
- }
-
- return structres;
- }
-
- public Object getAdapter(Class adapter) {
- if (FeatureStructure.class.equals(adapter)) {
- return getStructre();
- } else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) {
- return (AnnotationFS) getStructre();
- } else {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
- }
-
- public void update() {
- mDocument.update(mFeatureStructre);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * TODO:
+ * set feature value to null
+ * delete feature value structure
+ * create feature value structure
+ */
+public class ModelFeatureStructure implements IAdaptable {
+ private IDocument mDocument;
+
+ private FeatureStructure mFeatureStructre;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param document
+ * @param featureStructre
+ */
+ public ModelFeatureStructure(IDocument document, FeatureStructure featureStructre) {
+ mDocument = document;
+ mFeatureStructre = featureStructre;
+ }
+
+ public IDocument getDocument() {
+ return mDocument;
+ }
+
+ public FeatureStructure getStructre() {
+ return mFeatureStructre;
+ }
+
+ public void setFeatureNull(Feature feature) {
+ mFeatureStructre.setFeatureValue(feature, null);
+ }
+
+ public void deleteFeatureValue(Feature feature) {
+ // get value and call remove
+ }
+
+ public void createFeatureValue(Feature feature) {
+ // create, add and link
+ }
+
+ public void createFeatureValueArray(Feature feature, int size) {
+ // create add and link
+ }
+
+
+ public static List<ModelFeatureStructure> create(IDocument document,
+ List<AnnotationFS> annotations) {
+ List<ModelFeatureStructure> structres = new ArrayList<ModelFeatureStructure>(annotations.size());
+
+ for (AnnotationFS annotation : annotations) {
+ structres.add(new ModelFeatureStructure(document, annotation));
+ }
+
+ return structres;
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (FeatureStructure.class.equals(adapter)) {
+ return getStructre();
+ } else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) {
+ return (AnnotationFS) getStructre();
+ } else {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+ }
+
+ public void update() {
+ mDocument.update(mFeatureStructre);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/PropertySourceAdapterFactory.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/PropertySourceAdapterFactory.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/PropertySourceAdapterFactory.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/PropertySourceAdapterFactory.java Tue Feb 20 11:01:12 2007
@@ -1,47 +1,41 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor;
-
-
-import org.apache.uima.caseditor.editor.properties.FSPropertySourceFactory;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-/**
- *
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:55 $
- */
-public class PropertySourceAdapterFactory implements IAdapterFactory {
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- ModelFeatureStructure structure = (ModelFeatureStructure) adaptableObject;
-
- if (IPropertySource.class == adapterType) {
- return FSPropertySourceFactory.create(structure);
- }
-
- return null;
- }
-
- public Class[] getAdapterList() {
- return new Class[] { IPropertySource.class };
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor;
+
+
+import org.apache.uima.caseditor.editor.properties.FSPropertySourceFactory;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+public class PropertySourceAdapterFactory implements IAdapterFactory {
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ ModelFeatureStructure structure = (ModelFeatureStructure) adaptableObject;
+
+ if (IPropertySource.class == adapterType) {
+ return FSPropertySourceFactory.create(structure);
+ }
+
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return new Class[] { IPropertySource.class };
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/DeleteFeatureStructureAction.java Tue Feb 20 11:01:12 2007
@@ -1,69 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Deletes all selected annotations.
- *
- * TODO: create a FeatureStructreSelection class (AnnotationSelection) should then extend it and use
- * it for this class
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initializes the current instance.
- *
- * @param document
- */
- public DeleteFeatureStructureAction(IDocument document) {
- super("DeleteAction");
-
- mDocument = document;
-
- setEnabled(true);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() > 0;
- }
-
- /**
- * Executes the action.
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- mDocument.removeAnnotations(annotations.toList());
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Deletes all selected annotations.
+ *
+ * TODO: create a FeatureStructreSelection class (AnnotationSelection) should then extend it and use
+ * it for this class
+ */
+public class DeleteFeatureStructureAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initializes the current instance.
+ *
+ * @param document
+ */
+ public DeleteFeatureStructureAction(IDocument document) {
+ super("DeleteAction");
+
+ mDocument = document;
+
+ setEnabled(true);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() > 0;
+ }
+
+ /**
+ * Executes the action.
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ mDocument.removeAnnotations(annotations.toList());
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerLeftAnnotationSideAction.java Tue Feb 20 11:01:12 2007
@@ -1,75 +1,74 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Lowers the left side of the currently selected annotation by one.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initializes a new instance.
- *
- */
- public LowerLeftAnnotationSideAction(IDocument document) {
- super("LowerLeftAnnotationSide");
-
- mDocument = document;
-
- setEnabled(false);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() == 1;
- }
-
- /**
- * Increases the begin index of an annotation by one.
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- AnnotationFS annotation = annotations.getFirst();
-
- Type annotationType = annotation.getType();
- Feature beginFeature = annotationType.getFeatureByBaseName("begin");
-
- annotation.setIntValue(beginFeature, annotation.getBegin() + 1);
-
- mDocument.update(annotation);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Lowers the left side of the currently selected annotation by one.
+ */
+public final class LowerLeftAnnotationSideAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param document
+ *
+ */
+ public LowerLeftAnnotationSideAction(IDocument document) {
+ super("LowerLeftAnnotationSide");
+
+ mDocument = document;
+
+ setEnabled(false);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() == 1;
+ }
+
+ /**
+ * Increases the begin index of an annotation by one.
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ AnnotationFS annotation = annotations.getFirst();
+
+ Type annotationType = annotation.getType();
+ Feature beginFeature = annotationType.getFeatureByBaseName("begin");
+
+ annotation.setIntValue(beginFeature, annotation.getBegin() + 1);
+
+ mDocument.update(annotation);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/LowerRightAnnotationSideAction.java Tue Feb 20 11:01:12 2007
@@ -1,76 +1,73 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Lowers the right side of the currently selected annotation by one.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public final class LowerRightAnnotationSideAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initializes a new instance.
- *
- * @param editor
- */
- public LowerRightAnnotationSideAction(IDocument document) {
- super("LowerRightAnnotationSide");
-
- mDocument = document;
-
- setEnabled(false);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() == 1;
- }
-
- /**
- * Decreases the end index of an annotation by one.
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- AnnotationFS annotation = annotations.getFirst();
-
- Type annotationType = annotation.getType();
- Feature endFeature = annotationType.getFeatureByBaseName("end");
-
- annotation.setIntValue(endFeature, annotation.getEnd() - 1);
-
- mDocument.update(annotation);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Lowers the right side of the currently selected annotation by one.
+ */
+public final class LowerRightAnnotationSideAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initializes the current instance.
+ *
+ * @param document
+ */
+ public LowerRightAnnotationSideAction(IDocument document) {
+ super("LowerRightAnnotationSide");
+
+ mDocument = document;
+
+ setEnabled(false);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() == 1;
+ }
+
+ /**
+ * Decreases the end index of an annotation by one.
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ AnnotationFS annotation = annotations.getFirst();
+
+ Type annotationType = annotation.getType();
+ Feature endFeature = annotationType.getFeatureByBaseName("end");
+
+ annotation.setIntValue(endFeature, annotation.getEnd() - 1);
+
+ mDocument.update(annotation);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/MergeAnnotationAction.java Tue Feb 20 11:01:12 2007
@@ -1,77 +1,74 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Merges two or more annoations.
- *
- * TODO: also merge features - if one is null or primitive has default value take the the other one -
- * in conflict case do nothing
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public class MergeAnnotationAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initalizes the current instance.
- *
- * @param document
- */
- public MergeAnnotationAction(IDocument document) {
- super("MergeAnnotationAction");
-
- mDocument = document;
-
- setEnabled(false);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() > 1;
- }
-
- /**
- * Executes the merge action
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- CAS documentCAS = mDocument.getCAS();
-
- AnnotationFS mergedAnnotation = documentCAS.createAnnotation(annotations.getFirst().getType(),
- annotations.getFirst().getBegin(), annotations.getLast().getEnd());
-
- mDocument.removeAnnotations(annotations.toList());
- mDocument.addFeatureStructure(mergedAnnotation);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Merges two or more annoations.
+ *
+ * TODO: also merge features - if one is null or primitive has default value take the the other one -
+ * in conflict case do nothing
+ */
+public class MergeAnnotationAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initalizes the current instance.
+ *
+ * @param document
+ */
+ public MergeAnnotationAction(IDocument document) {
+ super("MergeAnnotationAction");
+
+ mDocument = document;
+
+ setEnabled(false);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() > 1;
+ }
+
+ /**
+ * Executes the merge action
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ CAS documentCAS = mDocument.getCAS();
+
+ AnnotationFS mergedAnnotation = documentCAS.createAnnotation(annotations.getFirst().getType(),
+ annotations.getFirst().getBegin(), annotations.getLast().getEnd());
+
+ mDocument.removeAnnotations(annotations.toList());
+ mDocument.addFeatureStructure(mergedAnnotation);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideLeftAnnotationSideAction.java Tue Feb 20 11:01:12 2007
@@ -1,76 +1,73 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Wides the left side of the currently selected annotation by one.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initializes a new instance.
- *
- * @param editor
- */
- public WideLeftAnnotationSideAction(IDocument document) {
- super("WideLeftAnnotationSside");
-
- mDocument = document;
-
- setEnabled(false);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() == 1;
- }
-
- /**
- * Decreases the begin index of an annotation by one.
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- AnnotationFS annotation = annotations.getFirst();
-
- Type annotationType = annotation.getType();
- Feature beginFeature = annotationType.getFeatureByBaseName("begin");
-
- annotation.setIntValue(beginFeature, annotation.getBegin() - 1);
-
- mDocument.update(annotation);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Wides the left side of the currently selected annotation by one.
+ */
+public final class WideLeftAnnotationSideAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param document
+ */
+ public WideLeftAnnotationSideAction(IDocument document) {
+ super("WideLeftAnnotationSside");
+
+ mDocument = document;
+
+ setEnabled(false);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() == 1;
+ }
+
+ /**
+ * Decreases the begin index of an annotation by one.
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ AnnotationFS annotation = annotations.getFirst();
+
+ Type annotationType = annotation.getType();
+ Feature beginFeature = annotationType.getFeatureByBaseName("begin");
+
+ annotation.setIntValue(beginFeature, annotation.getBegin() - 1);
+
+ mDocument.update(annotation);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/action/WideRightAnnotationSideAction.java Tue Feb 20 11:01:12 2007
@@ -1,76 +1,73 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.caseditor.editor.action;
-
-
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
-import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.caseditor.core.IDocument;
-import org.apache.uima.caseditor.editor.AnnotationSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.actions.BaseSelectionListenerAction;
-
-/**
- * Wides the right side of the currently selected annotation by one.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.2.2.2 $, $Date: 2007/01/04 15:00:53 $
- */
-public final class WideRightAnnotationSideAction extends BaseSelectionListenerAction {
- private IDocument mDocument;
-
- /**
- * Initializes a new instance.
- *
- * @param editor
- */
- public WideRightAnnotationSideAction(IDocument document) {
- super("WideRightAnnotationSide");
-
- mDocument = document;
-
- setEnabled(false);
- }
-
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- AnnotationSelection annotation = new AnnotationSelection(selection);
-
- return annotation.size() == 1;
- }
-
- /**
- * Increases the end index of an annotation by one.
- */
- @Override
- public void run() {
- AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
-
- AnnotationFS annotation = annotations.getFirst();
-
- Type annotationType = annotation.getType();
- Feature endFeature = annotationType.getFeatureByBaseName("end");
-
- annotation.setIntValue(endFeature, annotation.getEnd() + 1);
-
- mDocument.update(annotation);
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.caseditor.editor.action;
+
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.caseditor.core.IDocument;
+import org.apache.uima.caseditor.editor.AnnotationSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+
+/**
+ * Wides the right side of the currently selected annotation by one.
+ */
+public final class WideRightAnnotationSideAction extends BaseSelectionListenerAction {
+ private IDocument mDocument;
+
+ /**
+ * Initializes a new instance.
+ *
+ * @param document
+ */
+ public WideRightAnnotationSideAction(IDocument document) {
+ super("WideRightAnnotationSide");
+
+ mDocument = document;
+
+ setEnabled(false);
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+ AnnotationSelection annotation = new AnnotationSelection(selection);
+
+ return annotation.size() == 1;
+ }
+
+ /**
+ * Increases the end index of an annotation by one.
+ */
+ @Override
+ public void run() {
+ AnnotationSelection annotations = new AnnotationSelection(getStructuredSelection());
+
+ AnnotationFS annotation = annotations.getFirst();
+
+ Type annotationType = annotation.getType();
+ Feature endFeature = annotationType.getFeatureByBaseName("end");
+
+ annotation.setIntValue(endFeature, annotation.getEnd() + 1);
+
+ mDocument.update(annotation);
+ }
}
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationDrawingStrategy.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationDrawingStrategy.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationDrawingStrategy.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationDrawingStrategy.java Tue Feb 20 11:01:12 2007
@@ -32,9 +32,6 @@
/**
* The AnnotationDrawingStrategy of this editor.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.3.2.2 $, $Date: 2007/01/04 15:00:56 $
*/
public class AnnotationDrawingStrategy implements
org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationViewerDecorationSupport.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationViewerDecorationSupport.java?view=diff&rev=509708&r1=509707&r2=509708
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationViewerDecorationSupport.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/annotation/AnnotationViewerDecorationSupport.java Tue Feb 20 11:01:12 2007
@@ -33,9 +33,6 @@
/**
* This ia a custom SourceViewerDecorationSupport to support drawing of annoations with dynamically
* (not configured in plugin.xml) chaning types. These annotations can have configured appeareance.
- *
- * @author <a href="mailto:kottmann@gmail.com">Joern Kottmann</a>
- * @version $Revision: 1.1.2.2 $, $Date: 2007/01/04 15:00:56 $
*/
public class AnnotationViewerDecorationSupport extends SourceViewerDecorationSupport {
private NlpProject mProject;