You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/08/16 17:05:28 UTC
svn commit: r566742 [1/2] - in /incubator/uima/sandbox/trunk/CasEditor: ./
META-INF/ icons/svgicons/ src/main/java/org/apache/uima/caseditor/
src/main/java/org/apache/uima/caseditor/core/
src/main/java/org/apache/uima/caseditor/core/util/ src/main/java...
Author: twgoetz
Date: Thu Aug 16 08:05:24 2007
New Revision: 566742
URL: http://svn.apache.org/viewvc?view=rev&rev=566742
Log:
Jira UIMA-526: check in Joern's patch.
https://issues.apache.org/jira/browse/UIMA-526
Added:
incubator/uima/sandbox/trunk/CasEditor/icons/svgicons/pin.png (with props)
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateArrayDialog.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ByteCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/CellEditorValidatorFacotory.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/FloatCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/IntegerCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/LongCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/validator/ShortCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/resources/
incubator/uima/sandbox/trunk/CasEditor/src/main/resources/META-INF/
incubator/uima/sandbox/trunk/CasEditor/src/main/resources/META-INF/DISCLAIMER
incubator/uima/sandbox/trunk/CasEditor/src/main/resources/META-INF/LICENSE
incubator/uima/sandbox/trunk/CasEditor/src/main/resources/META-INF/NOTICE
Removed:
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/PropertySourceAdapterFactory.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/AbstractArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/ByteArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/DoubleArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/FSPropertySourceFactory.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/FeatureStructurePropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/FloatArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/IntegerArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/LongArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/ShortArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/StringArrayPropertySource.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ByteCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/CellEditorValidatorFacotory.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/FloatCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/IntegerCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/LongCellEditorValidator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/properties/validator/ShortCellEditorValidator.java
Modified:
incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF
incubator/uima/sandbox/trunk/CasEditor/UIMA Cas Editor.launch
incubator/uima/sandbox/trunk/CasEditor/plugin.xml
incubator/uima/sandbox/trunk/CasEditor/pom.xml
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/Images.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractAnnotationDocumentListener.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/TaeError.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/util/Primitives.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationSelection.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelection.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureValue.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserView.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureBrowserViewPage.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/fsview/FeatureStructureLabelProvider.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationOutline.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/outline/AnnotationTreeNode.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/FeatureStructureTransfer.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/NlpPerspectiveFactory.java
incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/ui/ObjectTransfer.java
Modified: incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF (original)
+++ incubator/uima/sandbox/trunk/CasEditor/META-INF/MANIFEST.MF Thu Aug 16 08:05:24 2007
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: UIMA CAS Editor
Bundle-SymbolicName: org.apache.uima.caseditor;singleton:=true
-Bundle-Version: 2.1.0.incubating-SNAPSHOOT
+Bundle-Version: 2.2.0.incubating-SNAPSHOOT
Bundle-Activator: org.apache.uima.caseditor.CasEditorPlugin
Eclipse-LazyStart: true
Bundle-Vendor: The Apache Software Foundation
Modified: incubator/uima/sandbox/trunk/CasEditor/UIMA Cas Editor.launch
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/UIMA%20Cas%20Editor.launch?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/UIMA Cas Editor.launch (original)
+++ incubator/uima/sandbox/trunk/CasEditor/UIMA Cas Editor.launch Thu Aug 16 08:05:24 2007
@@ -1,27 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
-<stringAttribute key="product" value="org.apache.uima.caseditor.product"/>
-<booleanAttribute key="clearws" value="false"/>
-<booleanAttribute key="usefeatures" value="false"/>
+<booleanAttribute key="askclear" value="true"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="true"/>
<stringAttribute key="bootstrap" value=""/>
-<booleanAttribute key="useProduct" value="true"/>
-<booleanAttribute key="tracing" value="false"/>
-<stringAttribute key="deselected_workspace_plugins" value="AAAAAAAAA,net.sf.tae.uima,opennlp.tools,org.apache.uima.debug,org.apache.uima.jcas.jcasgenp,org.apache.uima.pear,org.apache.uima.desceditor"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-clean"/>
-<stringAttribute key="pde.version" value="3.2a"/>
-<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
-<booleanAttribute key="default" value="false"/>
-<stringAttribute key="selected_target_plugins" value="com.ibm.icu,org.apache.xerces,org.eclipse.ant.core,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.expressions,org.eclipse.core.filesystem,org.eclipse.core.filesystem.macosx,org.eclipse.core.jobs,org.eclipse.core.resources,org.eclipse.core.resources.compatibility,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.core.variables,org.eclipse.equinox.common,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.jface.text,org.eclipse.osgi,org.eclipse.pde.runtime,org.eclipse.swt,org.eclipse.swt.carbon.macosx,org.eclipse.text,org.eclipse.ui,org.eclipse.ui.carbon,org.eclipse.ui.forms,org.eclipse.ui.ide,org.eclipse.ui.navigator,org.eclipse.ui.views,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.workbench,org.eclipse.ui.workbench.te
xteditor,org.eclipse.update.configurator,org.eclipse.update.core,org.eclipse.update.ui"/>
+<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="false"/>
-<booleanAttribute key="automaticValidate" value="false"/>
+<booleanAttribute key="clearws" value="false"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/UIMA Cas Editor"/>
+<booleanAttribute key="default" value="false"/>
+<stringAttribute key="deselected_workspace_plugins" value="opennlp.uima,org.apache.uima.debug,opennlp.tools,null,org.apache.uima.pear,org.apache.uima.jcas.jcasgenp,org.apache.uima.desceditor"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../runtime-New_configuration"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-clean"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.apache.uima.caseditor.product"/>
+<stringAttribute key="selected_target_plugins" value="com.ibm.icu,com.ibm.icu36.data.update,javax.servlet,org.eclipse.ant.core,org.eclipse.core.commands,org.eclipse.core.contenttype,org.eclipse.core.databinding,org.eclipse.core.expressions,org.eclipse.core.filebuffers,org.eclipse.core.filesystem,org.eclipse.core.filesystem.macosx,org.eclipse.core.jobs,org.eclipse.core.net,org.eclipse.core.resources,org.eclipse.core.resources.compatibility,org.eclipse.core.runtime,org.eclipse.core.runtime.compatibility.auth,org.eclipse.core.runtime.compatibility.registry,org.eclipse.core.variables,org.eclipse.equinox.app,org.eclipse.equinox.common,org.eclipse.equinox.preferences,org.eclipse.equinox.registry,org.eclipse.help,org.eclipse.jface,org.eclipse.jface.databinding,org.eclipse.jface.text,org.eclipse.osgi,org.eclipse.osgi.services,org.eclipse.pde.runtime,org.eclipse.swt,org.eclipse.swt.carbon.macosx,org.eclipse.text,org.eclipse.ui,org.eclipse.ui.carbon,org.eclipse.ui.editors,org.eclipse.
ui.forms,org.eclipse.ui.ide,org.eclipse.ui.views,org.eclipse.ui.views.properties.tabbed,org.eclipse.ui.workbench,org.eclipse.ui.workbench.texteditor,org.eclipse.update.configurator,org.eclipse.update.core,org.eclipse.update.ui"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
-<booleanAttribute key="automaticAdd" value="true"/>
-<stringAttribute key="checked" value="[NONE]"/>
-<booleanAttribute key="askclear" value="true"/>
-<stringAttribute key="location" value="${workspace_loc}/../runtime-New_configuration"/>
-<booleanAttribute key="includeOptional" value="true"/>
-<stringAttribute key="configLocation" value=""/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<booleanAttribute key="useProduct" value="true"/>
+<booleanAttribute key="usefeatures" value="false"/>
</launchConfiguration>
Added: incubator/uima/sandbox/trunk/CasEditor/icons/svgicons/pin.png
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/icons/svgicons/pin.png?view=auto&rev=566742
==============================================================================
Binary file - no diff available.
Propchange: incubator/uima/sandbox/trunk/CasEditor/icons/svgicons/pin.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: incubator/uima/sandbox/trunk/CasEditor/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/plugin.xml?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/plugin.xml (original)
+++ incubator/uima/sandbox/trunk/CasEditor/plugin.xml Thu Aug 16 08:05:24 2007
@@ -43,7 +43,7 @@
</extension>
- <!-- ui extensions-->
+ <!-- ui extensions -->
<extension point="org.eclipse.ui.views">
<category id="org.apache.uima.caseditor.ui.views" name="NLP" />
@@ -53,6 +53,17 @@
icon="icons/svgicons/explorer.png"
category="org.apache.uima.caseditor.ui.views" />
+ <view id="org.apache.uima.caseditor.editview"
+ name="Edit View"
+ class="org.apache.uima.caseditor.editor.editview.EditView"
+ icon="icons/svgicons/explorer.png"
+ category="org.apache.uima.caseditor.ui.views" />
+
+ <view id="org.apache.uima.caseditor.editview2"
+ name="Edit View"
+ class="org.apache.uima.caseditor.editor.editview.EditView"
+ icon="icons/svgicons/explorer.png"
+ category="org.apache.uima.caseditor.ui.views" />
</extension>
<extension point="org.eclipse.ui.newWizards">
Modified: incubator/uima/sandbox/trunk/CasEditor/pom.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/pom.xml?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/pom.xml (original)
+++ incubator/uima/sandbox/trunk/CasEditor/pom.xml Thu Aug 16 08:05:24 2007
@@ -43,14 +43,14 @@
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
@@ -71,28 +71,28 @@
<dependency>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface.text</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.ui</groupId>
<artifactId>org.eclipse.ui.editors</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.ui</groupId>
<artifactId>org.eclipse.ui.workbench.texteditor</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
- <version>3.2.0</version>
+ <version>3.3.0</version>
<scope>provided</scope>
</dependency>
@@ -144,4 +144,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/Images.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/Images.java?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/Images.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/Images.java Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -22,47 +22,47 @@
import org.eclipse.jface.resource.ImageDescriptor;
/**
- * All images in the cas editor are referenced here.
- *
+ * All images in the cas editor are referenced here.
+ *
* Call {@link CasEditorPlugin#getTaeImageDescriptor(Images)} to retrive
* an actual {@link ImageDescriptor}.
*/
public enum Images {
-
+
MODEL_PROJECT_OPEN("svgicons/project-open.png"),
-
+
MODEL_PROJECT_CLOSED("svgicons/project-closed.png"),
-
+
/**
* The corpus image.
*/
MODEL_CORPUS("svgicons/corpus.png"),
-
+
/**
* The document image.
*/
MODEL_DOCUMENT("svgicons/document.png"),
-
+
/**
* The source folder image.
*/
MODEL_PROCESSOR_FOLDER("svgicons/processor.png"),
-
+
/**
* Image for the type system element.
*/
MODEL_TYPESYSTEM("typesystem.gif"),
-
+
/**
* The enabled refresh icon.
*/
EXPLORER_E_REFRESH("svgicons/refresh.png"),
-
+
/**
* The disabled refresh icon.
*/
EXPLORER_D_REFRESH("svgicons/refresh.png"),
-
+
/**
* The wide left side image.
*/
@@ -91,7 +91,9 @@
/**
* The add image.
*/
- ADD("svgicons/add.png");
+ ADD("svgicons/add.png"),
+
+ PIN("svgicons/pin.png");
private String mPath;
@@ -100,8 +102,8 @@
}
/**
- * Retrives the Path. The path is a handel for the shared image.
- *
+ * Retrieves the Path. The path is a handle for the shared image.
+ *
* @return the id
*/
String getPath() {
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractAnnotationDocumentListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractAnnotationDocumentListener.java?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractAnnotationDocumentListener.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/AbstractAnnotationDocumentListener.java Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -30,6 +30,7 @@
* {@link FeatureStructure}s are filtered.
*/
public abstract class AbstractAnnotationDocumentListener extends AbstractDocumentListener {
+
private Collection<AnnotationFS> filterAnnotations(Collection<FeatureStructure> strcutres) {
Collection<AnnotationFS> annotations = new ArrayList<AnnotationFS>(strcutres.size());
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/TaeError.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/TaeError.java?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/TaeError.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/TaeError.java Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -24,13 +24,13 @@
*/
public class TaeError extends RuntimeException {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
/**
- * Initializs the current instance.
- *
+ * Initializes the current instance.
+ *
* @param message
*/
public TaeError(String message) {
@@ -39,7 +39,7 @@
/**
* Initializes the current instance.
- *
+ *
* @param message
* @param cause
*/
Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/util/Primitives.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/util/Primitives.java?view=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/util/Primitives.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/core/util/Primitives.java Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -24,7 +24,8 @@
import org.apache.uima.cas.FeatureStructure;
/**
- * This enumeration contains all primitves and some util methods. TODO: remove all array and list
+ * This enumeration contains all primitives and some util methods.
+ * TODO: remove all array and list
* types, thats are FeatureStructures !!!
*/
public enum Primitives {
@@ -79,8 +80,8 @@
}
/**
- * Retrives the uima name of the type.
- *
+ * Retrieves the uima name of the type.
+ *
* @return the uima name.
*/
public String getTypeName() {
@@ -88,8 +89,8 @@
}
/**
- * Retrives the type.
- *
+ * Retrieves the type.
+ *
* @return the type
*/
public Class getType() {
@@ -98,7 +99,7 @@
/**
* Checks if the given feature has the same type.
- *
+ *
* @param feature
* @return true if type is the same otherwise false
*/
@@ -108,9 +109,9 @@
/**
* Checks if a given <code>Feature</code> has a primitive type.
- *
+ *
* @param f
- * @return true if primitiv otherwise false
+ * @return true if primitive otherwise false
*/
public static boolean isPrimitive(Feature f) {
if (f == null) {
@@ -122,7 +123,7 @@
/**
* Checks if the given typeName is a primitive.
- *
+ *
* @param typeName
* @return true if primitive otherwise false.
*/
@@ -135,8 +136,8 @@
}
/**
- * Retrives the {@link Class} for the current primitive.
- *
+ * Retrieves the {@link Class} for the current primitive.
+ *
* @param f
* @return the class
*/
@@ -147,10 +148,10 @@
}
/**
- * Retrives a primitive by name.
- *
+ * Retrieves a primitive by name.
+ *
* @param typeName
- * @return the prmitive or null if none
+ * @return the primitive or null if none
*/
public static Primitives getPrimitive(String typeName) {
for (Primitives primitive : values()) {
@@ -163,8 +164,8 @@
}
/**
- * Retrives the primitive value.
- *
+ * Retrieves the primitive value.
+ *
* @param structure
* @param feature
* @return the primitive value as object
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/AnnotationEditorView.java Thu Aug 16 08:05:24 2007
@@ -0,0 +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;
+
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+
+public abstract class AnnotationEditorView extends PageBookView {
+
+ private final String editorNotAvailableMessage;
+
+ public AnnotationEditorView(String editorNotAvailableMessage) {
+ this.editorNotAvailableMessage = editorNotAvailableMessage;
+ }
+
+ @Override
+ protected IPage createDefaultPage(PageBook book) {
+ MessagePage page = new MessagePage();
+ initPage(page);
+ page.createControl(book);
+ page.setMessage(editorNotAvailableMessage);
+ return page;
+ }
+
+ @Override
+ protected IWorkbenchPart getBootstrapPart() {
+ return getSite().getPage().getActiveEditor();
+ }
+
+ @Override
+ protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
+ pageRecord.page.dispose();
+
+ pageRecord.dispose();
+ }
+
+ @Override
+ protected boolean isImportant(IWorkbenchPart part) {
+ // only interested in annotation editors
+ return (part instanceof AnnotationEditor);
+ }
+
+ /**
+ * Look at {@link IPartListener#partBroughtToTop(IWorkbenchPart)}.
+ *
+ * @param part
+ */
+ @Override
+ public void partBroughtToTop(IWorkbenchPart part) {
+ partActivated(part);
+ }
+}
\ No newline at end of file
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=566742&r1=566741&r2=566742
==============================================================================
--- 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 Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -34,78 +34,80 @@
/**
* 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
+ *
+ * Its also possible to retrieve the first 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);
+ if (structure instanceof AnnotationFS) {
+ mAnnotations.add((AnnotationFS) 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
+ *
+ * Note: {@link AnnotationFS} instances will be sorted in this selection, the natural oder of
* the selection is destroyed
- *
+ *
* @param selection
*/
public AnnotationSelection(IStructuredSelection selection) {
mAnnotations = new ArrayList<AnnotationFS>(selection.size());
- for (Iterator<FeatureStructure> it = new FeatureStructureSelectionIterator(selection);
+ for (Iterator<FeatureStructure> it = new FeatureStructureSelectionIterator(selection);
it.hasNext();) {
- add(it.next());
+ FeatureStructure structure = it.next();
+
+ if (structure instanceof AnnotationFS) {
+ mAnnotations.add((AnnotationFS) structure);
+ }
}
-
+
Collections.sort(mAnnotations, new AnnotationComparator());
- }
- private void add(FeatureStructure structure) {
- if (structure instanceof AnnotationFS) {
- mAnnotations.add((AnnotationFS) structure);
- }
+ mAnnotations = Collections.unmodifiableList(mAnnotations);
}
-
+
/**
* Indicates that the selection is empty.
- *
- * @return true if emtpy
+ *
+ * @return true if empty false otherwise
*/
public boolean isEmpty() {
return size() == 0;
}
-
+
/**
- * Retrives the size of the collection.
- *
+ * Retrieves 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.
- *
+ * Retrieves the first selected element.
+ *
+ * Note: If {@link #size()} == 1 then first and last element are the same instance.
+ *
* @return the last element
*/
public AnnotationFS getFirst() {
@@ -113,30 +115,30 @@
}
/**
- * Retrives the last selected element.
- *
- * Note: If {@link #size()} == 0 then frist and last element are the same instance.
- *
- * @return the last element
+ * Retrieves the last selected element.
+ *
+ * Note: If {@link #size()} == 1 then first and last element are the same instance.
+ *
+ * @return the last element or null if {@link #size()} == 0
*/
public AnnotationFS getLast() {
return isEmpty() ? null : mAnnotations.get(size() - 1);
}
/**
- * Retrives an ordered list of {@link AnnotationFS} objects.
- *
+ * Retrieves 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);
+ return mAnnotations;
}
-
+
/**
- * Retrives a human readable string.
- * @return humand readable string
+ * Retrieves a human readable string.
+ * @return human readable string
*/
@Override
public String toString() {
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/ArrayValue.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,160 @@
+/*
+ * 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.cas.ArrayFS;
+import org.apache.uima.cas.ByteArrayFS;
+import org.apache.uima.cas.DoubleArrayFS;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.FloatArrayFS;
+import org.apache.uima.cas.IntArrayFS;
+import org.apache.uima.cas.LongArrayFS;
+import org.apache.uima.cas.ShortArrayFS;
+import org.apache.uima.caseditor.core.TaeError;
+
+public class ArrayValue {
+
+ private final FeatureStructure arrayFS;
+
+ private final int slot;
+
+ public ArrayValue(FeatureStructure arrayFS, int slot) {
+
+ if (!arrayFS.getType().isArray()) {
+ throw new IllegalArgumentException("The arrayFS parameter must contain an array type FS!");
+ }
+
+ this.arrayFS = arrayFS;
+ this.slot = slot;
+ }
+
+ public FeatureStructure getFeatureStructure() {
+ return arrayFS;
+ }
+
+ public int slot() {
+ return slot;
+ }
+
+ public void set(String value) {
+ if (arrayFS instanceof ByteArrayFS) {
+ ByteArrayFS array = (ByteArrayFS) arrayFS;
+
+ array.set(slot, Byte.parseByte(value));
+ }
+ else if (arrayFS instanceof ShortArrayFS) {
+ ShortArrayFS array = (ShortArrayFS) arrayFS;
+ array.set(slot, Short.parseShort(value));
+ }
+ else if (arrayFS instanceof IntArrayFS) {
+ IntArrayFS array = (IntArrayFS) arrayFS;
+ array.set(slot, Integer.parseInt(value));
+ }
+ else if (arrayFS instanceof LongArrayFS) {
+ LongArrayFS array = (LongArrayFS) arrayFS;
+ array.set(slot, Long.parseLong(value));
+ }
+ else if (arrayFS instanceof FloatArrayFS) {
+ FloatArrayFS array = (FloatArrayFS) arrayFS;
+ array.set(slot, Float.parseFloat(value));
+ }
+ else if (arrayFS instanceof DoubleArrayFS) {
+ DoubleArrayFS array = (DoubleArrayFS) arrayFS;
+ array.set(slot, Double.parseDouble(value));
+ }
+ else {
+ throw new TaeError("Unkown array type!");
+ }
+ }
+
+// public void set(Number value) {
+//
+// if (arrayFS instanceof ByteArrayFS) {
+// ByteArrayFS array = (ByteArrayFS) arrayFS;
+// array.set(slot, (Byte) value);
+// }
+// else if (arrayFS instanceof ShortArrayFS) {
+// ShortArrayFS array = (ShortArrayFS) arrayFS;
+// array.set(slot, (Short) value);
+// }
+// else if (arrayFS instanceof IntArrayFS) {
+// IntArrayFS array = (IntArrayFS) arrayFS;
+// array.set(slot, (Integer) value);
+// }
+// else if (arrayFS instanceof LongArrayFS) {
+// LongArrayFS array = (LongArrayFS) arrayFS;
+// array.set(slot, (Long) value);
+// }
+// else if (arrayFS instanceof FloatArrayFS) {
+// FloatArrayFS array = (FloatArrayFS) arrayFS;
+// array.set(slot, (Float) value);
+// }
+// else if (arrayFS instanceof DoubleArrayFS) {
+// DoubleArrayFS array = (DoubleArrayFS) arrayFS;
+// array.set(slot, (Double) value);
+// }
+// else if (arrayFS instanceof ArrayFS) {
+// ArrayFS array = (ArrayFS) arrayFS;
+// array.set(slot, (FeatureStructure) value);
+// }
+// else {
+// throw new TaeError("Unkown array type!");
+// }
+// }
+
+ public Object get() {
+ if (arrayFS instanceof ByteArrayFS) {
+ ByteArrayFS array = (ByteArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof ShortArrayFS) {
+ ShortArrayFS array = (ShortArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof IntArrayFS) {
+ IntArrayFS array = (IntArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof LongArrayFS) {
+ LongArrayFS array = (LongArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof FloatArrayFS) {
+ FloatArrayFS array = (FloatArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof DoubleArrayFS) {
+ DoubleArrayFS array = (DoubleArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else if (arrayFS instanceof ArrayFS) {
+ ArrayFS array = (ArrayFS) arrayFS;
+ return array.get(slot);
+ }
+ else {
+ throw new TaeError("Unkown array type!");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toString(slot()) ;
+ }
+}
\ No newline at end of file
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=566742&r1=566741&r2=566742
==============================================================================
--- 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 Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -20,27 +20,25 @@
package org.apache.uima.caseditor.editor;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.text.AnnotationFS;
+import org.eclipse.core.runtime.IAdaptable;
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
+ * Initializes a the current instance with all FeatureStructure 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 FeatureStructureSelection(IStructuredSelection selection) {
@@ -50,9 +48,52 @@
FeatureStructure annotation = (FeatureStructure) Platform.getAdapterManager().getAdapter(
item, FeatureStructure.class);
+ // TODO: fix it
+ if (annotation == null && item instanceof IAdaptable) {
+ annotation = (FeatureStructure) ((IAdaptable) item).getAdapter(FeatureStructure.class);
+ }
+
if (annotation != null) {
mFeatureStructures.add(annotation);
}
}
+
+ mFeatureStructures = Collections.unmodifiableList(mFeatureStructures);
+ }
+
+ /**
+ * Retrieves the size of the collection.
+ *
+ * @return the size
+ */
+ public int size() {
+ return mFeatureStructures.size();
+ }
+
+ /**
+ * Indicates that the selection is empty.
+ *
+ * @return true if empty false otherwise
+ */
+ public boolean isEmpty() {
+ return size() == 0;
+ }
+
+ /**
+ * Retrieves a list of {@link FeatureStructure} objects.
+ *
+ * @return all selected {@link FeatureStructure} objects
+ */
+ public List<FeatureStructure> toList() {
+ return mFeatureStructures;
+ }
+
+ /**
+ * Retrieves a human readable string.
+ * @return human readable string
+ */
+ @Override
+ public String toString() {
+ return mFeatureStructures.toString();
}
-}
+}
\ No newline at end of file
Modified: 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=diff&rev=566742&r1=566741&r2=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/FeatureStructureSelectionIterator.java Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -33,54 +33,54 @@
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.
- *
+ * Retrieves 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() {
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=566742&r1=566741&r2=566742
==============================================================================
--- 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 Thu Aug 16 08:05:24 2007
@@ -6,9 +6,9 @@
* 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
@@ -24,10 +24,8 @@
import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.caseditor.core.util.Primitives;
-import org.apache.uima.caseditor.editor.properties.FSPropertySourceFactory;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ui.views.properties.IPropertySource;
public final class FeatureValue implements IAdaptable {
private FeatureStructure mStructure;
@@ -38,7 +36,7 @@
/**
* Initializes a new instance.
- *
+ *
* @param feature
* @param value
*/
@@ -53,6 +51,10 @@
mStructure = structure;
}
+ public FeatureStructure getFeatureStructure() {
+ return mStructure;
+ }
+
public Object getValue() {
if (Primitives.isPrimitive(mFeature)) {
return Primitives.getPrimitiv(mStructure, mFeature);
@@ -62,17 +64,18 @@
}
public Object getAdapter(Class adapter) {
- if (IPropertySource.class.equals(adapter) && (getValue() instanceof FeatureStructure)) {
- return FSPropertySourceFactory.create(new ModelFeatureStructure(mDocument,
- ((FeatureStructure) getValue())));
- }
-
if (AnnotationFS.class.equals(adapter)) {
if (getValue() instanceof AnnotationFS) {
return getValue();
}
}
+ if (FeatureStructure.class.equals(adapter)) {
+ if (getValue() instanceof FeatureStructure) {
+ return getValue();
+ }
+ }
+
return null;
}
@@ -98,11 +101,12 @@
}
/**
- * Retrives the {@link Feature}.
- *
+ * Retrieves the {@link Feature}.
+ *
* @return the {@link Feature}
*/
public Feature getFeature() {
return mFeature;
}
+
}
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateArrayDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateArrayDialog.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateArrayDialog.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateArrayDialog.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,114 @@
+/*
+ * 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.editview;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IconAndMessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class CreateArrayDialog extends IconAndMessageDialog {
+
+ private int arraySize;
+
+ protected CreateArrayDialog(Shell parentShell) {
+ super(parentShell);
+
+ message = "Please enter the size of the new array.";
+ }
+
+ @Override
+ protected void configureShell(Shell newShell) {
+ newShell.setText("Array Size");
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+
+ createMessageArea(parent);
+
+ Composite labelAndText = (Composite) super.createDialogArea(parent);
+ ((GridLayout) labelAndText.getLayout()).numColumns = 2;
+
+ GridData labelAndTextData = new GridData(GridData.FILL_BOTH);
+ labelAndTextData.horizontalSpan = 2;
+ labelAndText.setLayoutData(labelAndTextData);
+
+ GridLayout labelAndTextLayout = new GridLayout();
+ labelAndTextLayout.numColumns = 2;
+
+ labelAndText.setLayout(labelAndTextLayout);
+
+ Label sizeLabel = new Label(labelAndText, SWT.NONE);
+ GridData sizeLabelData = new GridData();
+ sizeLabelData.horizontalAlignment = SWT.LEFT;
+ sizeLabelData.grabExcessHorizontalSpace = false;
+ sizeLabel.setText("Size:");
+
+ final Text sizeText = new Text(labelAndText, SWT.BORDER);
+ GridData sizeTextData = new GridData();
+ sizeTextData.grabExcessHorizontalSpace = true;
+ sizeTextData.horizontalAlignment = SWT.FILL;
+ sizeText.setLayoutData(sizeTextData);
+
+ sizeText.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent event) {
+ try {
+ arraySize = Integer.parseInt(sizeText.getText());
+ }
+ catch (NumberFormatException e) {
+ arraySize = -1;
+ }
+ }});
+
+ return labelAndText;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, "Create", true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+
+ @Override
+ protected Point getInitialSize() {
+ return new Point(500, 200);
+ }
+
+ int getArraySize() {
+ return arraySize;
+ }
+
+ @Override
+ protected Image getImage() {
+ return getShell().getDisplay().getSystemImage(SWT.ICON_QUESTION);
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditView.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.editview;
+
+
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.AnnotationEditorView;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * TODO: add javadoc here
+ */
+public final class EditView extends AnnotationEditorView {
+ /**
+ * The ID of the feature structure view.
+ */
+ public static final String ID = "org.apache.uima.caseditor.editview";
+ public static final String ID_2 = "org.apache.uima.caseditor.editview2";
+
+
+ public EditView() {
+ super("The edit view is currently not available.");
+ }
+
+ @Override
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ PageRec result;
+
+ if ((part instanceof AnnotationEditor)) {
+ AnnotationEditor editor = (AnnotationEditor) part;
+
+ EditViewPage page = new EditViewPage(editor);
+ initPage(page);
+ page.createControl(getPageBook());
+
+ result = new PageRec(part, page);
+ } else {
+ // unable to create page, cause there is no cas
+ result = null;
+ }
+
+ return result;
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,570 @@
+/*
+ * 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.editview;
+
+import java.util.Iterator;
+
+import org.apache.uima.cas.ByteArrayFS;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.DoubleArrayFS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.FloatArrayFS;
+import org.apache.uima.cas.IntArrayFS;
+import org.apache.uima.cas.LongArrayFS;
+import org.apache.uima.cas.ShortArrayFS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.caseditor.CasEditorPlugin;
+import org.apache.uima.caseditor.Images;
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.core.util.Primitives;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.AnnotationEditor;
+import org.apache.uima.caseditor.editor.ArrayValue;
+import org.apache.uima.caseditor.editor.FeatureStructureSelection;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.apache.uima.caseditor.editor.editview.validator.CellEditorValidatorFacotory;
+import org.apache.uima.caseditor.ui.FeatureStructureTransfer;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+
+/**
+ * The {@link EditViewPage} provides basic editing support for {@link FeatureStructure}s.
+ * It shows always the selected {@link FeatureStructure}, but for editing a certain
+ * {@link FeatureStructure} can be pinned to the view (selection updates disabled).
+ *
+ * For editing the {@link Feature}s of the {@link FeatureStructure} are shown in
+ * a tree with two columns. The values of the {@link Feature} can be changed with
+ * cell editors.
+ *
+ * Note: Lists type are currently not supported
+ */
+final class EditViewPage extends Page implements ISelectionListener {
+
+ private final class ValueEditingSupport extends EditingSupport {
+ private ValueEditingSupport(ColumnViewer viewer) {
+ super(viewer);
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+
+ if (element instanceof FeatureValue) {
+ FeatureValue value = (FeatureValue) element;
+
+ return value.getFeature().getRange().isPrimitive();
+ }
+ else if (element instanceof ArrayValue) {
+ return true;
+ }
+ else {
+ throw new TaeError("Unkown element type!");
+ }
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+
+ if (element instanceof FeatureValue) {
+ FeatureValue value = (FeatureValue) element;
+
+ if (Primitives.isPrimitive(value.getFeature())) {
+
+ TextCellEditor editor = new TextCellEditor(viewer.getTree());
+
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
+ .getPrimitiveClass(value.getFeature())));
+
+ return editor;
+ }
+ else {
+ return null;
+ }
+ } else if (element instanceof ArrayValue) {
+
+ ArrayValue arrayValue = (ArrayValue) element;
+
+ TextCellEditor editor = new TextCellEditor(viewer.getTree());
+
+ FeatureStructure arrayFS = arrayValue.getFeatureStructure();
+
+ if (arrayFS instanceof ByteArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Byte.class));
+ }
+ else if (arrayFS instanceof ShortArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Short.class));
+ }
+ else if (arrayFS instanceof IntArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Integer.class));
+ }
+ else if (arrayFS instanceof LongArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Long.class));
+ }
+ else if (arrayFS instanceof FloatArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Float.class));
+ }
+ else if (arrayFS instanceof DoubleArrayFS) {
+ editor.setValidator(CellEditorValidatorFacotory.createValidator(Double.class));
+ }
+ else {
+ throw new TaeError("Unkown array type!");
+ }
+ return editor;
+ }
+ else {
+ throw new TaeError("Unknown element type!");
+ }
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+
+ if (element instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) element;
+
+ return featureValue.getFeatureStructure()
+ .getFeatureValueAsString(featureValue.getFeature());
+ }
+ else if (element instanceof ArrayValue) {
+ ArrayValue value = (ArrayValue) element;
+
+ return value.get().toString();
+ }
+ else {
+ throw new TaeError("Unkown element type!");
+ }
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+
+ // if value is null, there was an invalid input
+ if (value != null) {
+ if (element instanceof FeatureValue) {
+
+ FeatureValue featureValue = (FeatureValue) element;
+
+ if (Primitives.isPrimitive(featureValue.getFeature())) {
+
+ // TODO: try to prevent setting of invalid annotation span values
+
+ featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(),
+ (String) value);
+
+ document.update(featureValue.getFeatureStructure());
+ }
+
+ viewer.update(element, null);
+
+ } else if (element instanceof ArrayValue) {
+
+ ArrayValue arrayValue = (ArrayValue) element;
+ arrayValue.set((String) value);
+
+ document.update(arrayValue.getFeatureStructure());
+
+ } else {
+ throw new TaeError("Unkown element type");
+ }
+ }
+ }
+ }
+
+ final class DeleteFeatureStructureValue extends BaseSelectionListenerAction {
+
+ protected DeleteFeatureStructureValue() {
+ super("Delete");
+
+ setEnabled(false);
+ }
+
+ @Override
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+
+ for (Iterator it = selection.iterator(); it.hasNext(); ) {
+
+ FeatureValue featureValue = (FeatureValue) it.next();
+
+ if (!featureValue.getFeature().getRange().isPrimitive()) {
+ featureValue.getFeatureStructure().setFeatureValue(featureValue.getFeature(), null);
+
+ document.update(featureValue.getFeatureStructure());
+ }
+ }
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+
+ boolean result = false;
+
+ if (selection.size() == 1) {
+ if (selection.getFirstElement() instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
+
+ result = !featureValue.getFeature().getRange().isPrimitive() &&
+ featureValue.getFeatureStructure().getFeatureValue(featureValue.getFeature()) != null;
+ }
+ }
+
+ return result;
+
+ }
+ }
+
+ private final class CreateFeatureStructrueValue extends BaseSelectionListenerAction {
+
+ protected CreateFeatureStructrueValue() {
+ super("Create");
+
+ setEnabled(false);
+ }
+
+ @Override
+ public void run() {
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+
+ FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
+
+ FeatureStructure newValue;
+
+ if (!featureValue.getFeature().getRange().isArray()) {
+ newValue = document.getCAS().createFS(featureValue.getFeature().getRange());
+ document.addFeatureStructure(newValue);
+ }
+ else {
+ CreateArrayDialog createArrayDialog = new CreateArrayDialog(
+ Display.getCurrent().getActiveShell());
+
+ int returnCode = createArrayDialog.open();
+
+ if (returnCode == IDialogConstants.OK_ID) {
+ // get size from array dialog
+ int arraySize = createArrayDialog.getArraySize();
+
+ Type arrayType = featureValue.getFeature().getRange();
+
+ if (arrayType.getName().equals(CAS.TYPE_NAME_BYTE_ARRAY)) {
+ newValue = document.getCAS().createByteArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
+ newValue = document.getCAS().createShortArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
+ newValue = document.getCAS().createIntArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
+ newValue = document.getCAS().createLongArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
+ newValue = document.getCAS().createFloatArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
+ newValue = document.getCAS().createDoubleArrayFS(arraySize);
+ }
+ else if (arrayType.getName().equals(CAS.TYPE_NAME_FS_ARRAY)) {
+ newValue = document.getCAS().createArrayFS(arraySize);
+ }
+ else {
+ throw new TaeError("Unkown array type!");
+ }
+ }
+ else {
+ return;
+ }
+ }
+
+ featureValue.getFeatureStructure().setFeatureValue(featureValue.getFeature(), newValue);
+ document.update(featureValue.getFeatureStructure());
+ }
+
+ @Override
+ protected boolean updateSelection(IStructuredSelection selection) {
+
+ boolean result = false;
+
+ if (selection.size() == 1) {
+ if (selection.getFirstElement() instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) selection.getFirstElement();
+
+ result = !featureValue.getFeature().getRange().isPrimitive() &&
+ featureValue.getFeatureStructure().getFeatureValue(featureValue.getFeature()) == null;
+ }
+ }
+
+ return result;
+ }
+ }
+
+ private static final class PinAction extends Action {
+ PinAction() {
+ super("PinAction", IAction.AS_CHECK_BOX);
+ }
+ }
+
+ TreeViewer viewer;
+
+ private AnnotationDocument document;
+
+ private PinAction pinAction;
+
+ EditViewPage(AnnotationEditor editor) {
+ document = editor.getDocument();
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+
+ Tree tree = new Tree(parent, SWT.NONE);
+
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+
+ viewer = new TreeViewer(tree);
+
+ TreeViewerColumn featureColumn = new TreeViewerColumn(viewer, SWT.LEFT);
+ featureColumn.getColumn().setText("Feature");
+ featureColumn.getColumn().setWidth(100);
+
+ featureColumn.setLabelProvider(new FeatureColumnLabelProvider());
+
+ TreeViewerColumn valueColumn = new TreeViewerColumn(viewer, SWT.LEFT);
+ valueColumn.getColumn().setText("Value");
+ valueColumn.getColumn().setWidth(100);
+
+ valueColumn.setLabelProvider(new ValueColumnLabelProvider());
+
+ valueColumn.setEditingSupport(new ValueEditingSupport(viewer)
+ );
+
+ viewer.setContentProvider(new FeatureStructureContentProvider(document));
+
+ Transfer[] typesDropSupport = new Transfer[] { FeatureStructureTransfer.getInstance() };
+
+ viewer.addDropSupport(DND.DROP_COPY, typesDropSupport, new DropTargetListener() {
+
+ public void dragEnter(DropTargetEvent event) {
+ // only the FeatureStructureTransfer is supported
+ // set currentTransferType to FeatureStructureTransfer, if possible
+ for (TransferData transferData : event.dataTypes) {
+ if (FeatureStructureTransfer.getInstance().isSupportedType(transferData)) {
+ event.currentDataType = transferData;
+ break;
+ }
+ }
+ }
+
+ public void dragLeave(DropTargetEvent event) {
+ }
+
+ public void dragOperationChanged(DropTargetEvent event) {
+ }
+
+ public void dragOver(DropTargetEvent event) {
+
+ // TODO: check range type during drag over, like its done in drop()
+
+ if (FeatureStructureTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ event.detail = DND.DROP_COPY;
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
+
+ public void drop(DropTargetEvent event) {
+ if (FeatureStructureTransfer.getInstance().isSupportedType(event.currentDataType)) {
+ Widget tableItem = event.item;
+
+ if (tableItem != null) {
+ // this can fail
+ FeatureValue value = (FeatureValue) tableItem.getData();
+
+ Type range = value.getFeature().getRange();
+
+ FeatureStructure dragFeatureStructure = (FeatureStructure) event.data;
+
+ if (range.equals(dragFeatureStructure.getType())) {
+
+ FeatureStructure target = value.getFeatureStructure();
+
+ target.setFeatureValue(value.getFeature(), dragFeatureStructure);
+
+ document.update(target);
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ } else {
+ event.detail = DND.DROP_NONE;
+ }
+ }
+
+ public void dropAccept(DropTargetEvent event) {
+ }
+ });
+
+
+ DragSource source = new DragSource(viewer.getTree(), DND.DROP_COPY);
+
+ source.setTransfer(new Transfer[] { FeatureStructureTransfer.getInstance() });
+
+ source.addDragListener(new DragSourceListener() {
+ TreeItem dragSourceItem = null;
+
+ public void dragStart(DragSourceEvent event) {
+
+ event.doit = false;
+
+ TreeItem[] selection = viewer.getTree().getSelection();
+
+ if (selection.length > 0) {
+
+ dragSourceItem = selection[0];
+ IAdaptable adaptable = (IAdaptable) dragSourceItem.getData();
+
+ if (adaptable.getAdapter(FeatureStructure.class) != null) {
+ event.doit = true;
+ }
+ }
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ IAdaptable adaptable = (IAdaptable) dragSourceItem.getData();
+
+ event.data = adaptable.getAdapter(FeatureStructure.class);
+ }
+
+ public void dragFinished(DragSourceEvent event) {
+ // not needed
+ }
+ });
+
+ // do this after viewer is ready to be used
+ getSite().setSelectionProvider(viewer);
+ getSite().getPage().addSelectionListener(this);
+ }
+
+ /**
+ * Retrieves the main control of the edit view.
+ */
+ @Override
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+
+ // pin action
+ pinAction = new PinAction();
+
+ pinAction.setText("Pin");
+ pinAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.PIN));
+ pageSite.getActionBars().getToolBarManager().add(pinAction);
+
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ CreateFeatureStructrueValue createAction = new CreateFeatureStructrueValue();
+ createAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.ADD));
+ getSite().getActionBars().getToolBarManager().add(createAction);
+
+ // TODO: setActionBars is deprecated, but registration of change listener
+ // does not work in init method
+ getSite().getSelectionProvider().addSelectionChangedListener(createAction);
+
+ // delete action
+ DeleteFeatureStructureValue deleteAction = new DeleteFeatureStructureValue();
+ getSite().getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+
+ getSite().getSelectionProvider().addSelectionChangedListener(deleteAction);
+
+ getSite().getActionBars().getToolBarManager().add(
+ ActionFactory.DELETE.create(getSite().getWorkbenchWindow()));
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ if (selection instanceof IStructuredSelection) {
+
+ FeatureStructureSelection fsSelection = new FeatureStructureSelection(
+ (IStructuredSelection) selection);
+
+ if (fsSelection.size() == 1 && !pinAction.isChecked()) {
+
+ // filter out selection which are cause by this view itself
+ if (viewer.getTree().getSelectionCount() == 1) {
+ TreeItem item = viewer.getTree().getSelection()[0];
+
+ if (item.getData() instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) item.getData();
+
+ if (!featureValue.getFeature().getRange().isPrimitive()) {
+ return; // do not update
+ }
+ }
+ }
+
+ viewer.setInput(fsSelection.toList().get(0));
+ }
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureColumnLabelProvider.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.editview;
+
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.editor.ArrayValue;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+
+final class FeatureColumnLabelProvider extends CellLabelProvider {
+ @Override
+ public void update(ViewerCell cell) {
+
+ Object element = cell.getElement();
+
+ if (element instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) cell.getElement();
+
+ cell.setText(featureValue.getFeature().getShortName());
+
+ }
+ else if (element instanceof ArrayValue) {
+ ArrayValue arrayValue = (ArrayValue) cell.getElement();
+
+ cell.setText(Integer.toString(arrayValue.slot()));
+ }
+ else {
+ throw new TaeError("Unkown element!");
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,179 @@
+/*
+ * 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.editview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.uima.cas.CommonArrayFS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.caseditor.core.AbstractDocumentListener;
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.core.util.Primitives;
+import org.apache.uima.caseditor.editor.AnnotationDocument;
+import org.apache.uima.caseditor.editor.ArrayValue;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+
+final class FeatureStructureContentProvider extends AbstractDocumentListener
+ implements ITreeContentProvider {
+
+ private AnnotationDocument mDocument;
+
+ private Viewer viewer;
+
+ FeatureStructureContentProvider(AnnotationDocument document) {
+ mDocument = document;
+ }
+
+ public Object[] getElements(Object inputElement) {
+
+ if (inputElement != null) {
+ FeatureStructure featureStructure = (FeatureStructure) inputElement;
+
+ Type type = featureStructure.getType();
+
+ List featureTypes = type.getFeatures();
+
+ Collection<FeatureValue> featureValues = new LinkedList<FeatureValue>();
+
+ Iterator featuresItertor = featureTypes.iterator();
+
+ while (featuresItertor.hasNext()) {
+ Feature feature = (Feature) featuresItertor.next();
+
+ featureValues.add(new FeatureValue(mDocument, featureStructure, feature));
+ }
+
+ return featureValues.toArray();
+ } else {
+ return new Object[0];
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) {
+
+ this.viewer = viewer;
+
+ if (oldInput != null) {
+ mDocument.removeChangeListener(this);
+ }
+
+ if (newInput == null) {
+ // this means empty input
+ return;
+ }
+
+ mDocument.addChangeListener(this);
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ viewer.refresh();
+ }
+ });
+ }
+
+ public void added(Collection<FeatureStructure> newFeatureStructure) {
+ }
+
+ public void changed() {
+ // TODO: check if fs still exists
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ viewer.setSelection(viewer.getSelection());
+ viewer.refresh();
+ }
+ });
+ }
+
+ public void removed(Collection<FeatureStructure> deletedFeatureStructure) {
+ // TODO: set viewer to null if current fs was deleted
+ }
+
+ public void updated(Collection<FeatureStructure> featureStructure) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ viewer.setSelection(viewer.getSelection());
+ viewer.refresh();
+ }
+ });
+ }
+
+ public Object[] getChildren(Object parentElement) {
+
+ FeatureValue value = (FeatureValue) parentElement;
+
+ if (!value.getFeature().getRange().isArray()) {
+ FeatureStructure childStructure = (FeatureStructure) value.getValue();
+ return getElements(childStructure);
+ }
+ else {
+ FeatureStructure arrayFS = value.getFeatureStructure().getFeatureValue(value.getFeature());
+
+ CommonArrayFS array = (CommonArrayFS) arrayFS;
+
+ // TODO: is is a bug in eclipse ??
+ if (arrayFS == null) {
+ return new Object[0];
+ }
+
+ ArrayValue arrayValues[] = new ArrayValue[array.size()];
+
+ for (int i = 0; i < array.size(); i++) {
+ arrayValues[i] = new ArrayValue(arrayFS, i);
+ }
+
+ return arrayValues;
+ }
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+
+ if (element instanceof FeatureValue) {
+ FeatureValue value = (FeatureValue) element;
+
+ if (Primitives.isPrimitive(value.getFeature())) {
+ return false;
+ }
+ else {
+ return value.getValue() != null;
+ }
+ } else if (element instanceof ArrayValue) {
+ return false;
+ }
+ else {
+ throw new TaeError("Unkown element type");
+ }
+ }
+}
\ No newline at end of file
Added: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java?view=auto&rev=566742
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java (added)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java Thu Aug 16 08:05:24 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.editview;
+
+import org.apache.uima.caseditor.core.TaeError;
+import org.apache.uima.caseditor.editor.ArrayValue;
+import org.apache.uima.caseditor.editor.FeatureValue;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ViewerCell;
+
+final class ValueColumnLabelProvider extends CellLabelProvider {
+ @Override
+ public void update(ViewerCell cell) {
+
+ Object element = cell.getElement();
+
+ if (element instanceof FeatureValue) {
+ FeatureValue featureValue = (FeatureValue) element;
+
+ if (featureValue.getFeature().getRange().isPrimitive()) {
+ cell.setText(featureValue.getFeatureStructure().getFeatureValueAsString(
+ featureValue.getFeature()));
+ }
+ else {
+
+ if (featureValue.getValue() == null) {
+ cell.setText("null");
+ } else {
+ cell.setText("");
+ }
+ }
+ }
+ else if (element instanceof ArrayValue) {
+ ArrayValue value = (ArrayValue) element;
+
+ cell.setText(value.get().toString());
+ }
+ else {
+ throw new TaeError("Unkown element!");
+ }
+ }
+}
\ No newline at end of file