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/09/04 18:44:41 UTC

svn commit: r572733 - in /incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview: CreateFeatureStructureDialog.java EditViewPage.java FeatureStructureContentProvider.java ValueColumnLabelProvider.java

Author: twgoetz
Date: Tue Sep  4 09:44:39 2007
New Revision: 572733

URL: http://svn.apache.org/viewvc?rev=572733&view=rev
Log:
Jira UIMA-526: commit UIMA-526-3.patch.

https://issues.apache.org/jira/browse/UIMA-526

Modified:
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.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/FeatureStructureContentProvider.java
    incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java

Modified: incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java?rev=572733&r1=572732&r2=572733&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/CreateFeatureStructureDialog.java Tue Sep  4 09:44:39 2007
@@ -0,0 +1,202 @@
+package org.apache.uima.caseditor.editor.editview;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.caseditor.editor.fsview.ITypePaneListener;
+import org.apache.uima.caseditor.editor.fsview.TypeSelectionPane;
+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.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 CreateFeatureStructureDialog extends IconAndMessageDialog {
+
+  private final String title;
+
+  private Label sizeLabel;
+
+  private Text sizeText;
+
+  private int arraySize;
+
+  private final TypeSystem typeSystem;
+
+  private final Type superType;
+
+  private boolean isArraySizeDisplayed;
+
+  private TypeSelectionPane typeSelection;
+
+  private Type selectedType;
+
+  private Collection<Type> filterTypes;
+
+  /**
+   * Initializes a the current instance.
+   *
+   * @param parentShell
+   */
+  protected CreateFeatureStructureDialog(Shell parentShell, Type superType, TypeSystem typeSystem) {
+
+    super(parentShell);
+
+    this.superType = superType;
+
+    this.typeSystem = typeSystem;
+
+    if (!superType.isArray()) {
+      title = "Choose type";
+      message = "Please choose the type to create.";
+    } else {
+      title = "Array size";
+      message = "Please enter the size of the array.";
+    }
+
+    filterTypes = new HashSet<Type>();
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_ARRAY_BASE));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_BYTE));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_ANNOTATION_BASE));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_SHORT));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_LONG));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_FLOAT));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_DOUBLE));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_BOOLEAN));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_FLOAT));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_INTEGER));
+//    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_LIST_BASE));
+//    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST));
+//    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST));
+//    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST));
+//    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_SOFA));
+    filterTypes.add(typeSystem.getType(CAS.TYPE_NAME_STRING));
+
+  }
+
+
+  @Override
+  protected void configureShell(Shell newShell) {
+    newShell.setText(title);
+  }
+
+  private void enableSizeEnter(Composite parent) {
+
+    if (!isArraySizeDisplayed) {
+
+      sizeLabel = new Label(parent, SWT.NONE);
+      sizeLabel.setText("Size:");
+
+      GridData sizeLabelData = new GridData();
+      sizeLabelData.horizontalAlignment = SWT.LEFT;
+      sizeLabel.setLayoutData(sizeLabelData);
+
+      sizeText = new Text(parent, 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;
+          }
+        }
+      });
+
+      isArraySizeDisplayed = true;
+    }
+  }
+
+  private void disableSizeEnter() {
+
+    if (isArraySizeDisplayed) {
+      sizeLabel.dispose();
+      sizeText.dispose();
+      isArraySizeDisplayed = false;
+    }
+  }
+
+  @Override
+  protected Control createDialogArea(final Composite parent) {
+
+    createMessageArea(parent);
+
+    final Composite labelAndText = (Composite) super.createDialogArea(parent);
+    ((GridLayout) labelAndText.getLayout()).numColumns = 1;
+
+    GridData labelAndTextData = new GridData(GridData.FILL_BOTH);
+    labelAndTextData.horizontalSpan = 2;
+    labelAndText.setLayoutData(labelAndTextData);
+
+    if (!superType.isArray()) {
+
+      typeSelection = new TypeSelectionPane(labelAndText, superType, typeSystem, filterTypes);
+
+      selectedType = typeSelection.getType();
+
+      // maybe consider to show the type of the array and disable the selector
+      GridData typeSelectionData = new GridData();
+      typeSelectionData.horizontalSpan = 1;
+      typeSelectionData.horizontalAlignment = SWT.FILL;
+      typeSelectionData.grabExcessHorizontalSpace = true;
+
+      typeSelection.setLayoutData(typeSelectionData);
+
+      typeSelection.setListener(new ITypePaneListener() {
+        public void typeChanged(Type newType) {
+          selectedType = newType;
+
+          if (newType.isArray()) {
+            enableSizeEnter(labelAndText);
+          } else {
+            disableSizeEnter();
+          }
+
+          parent.pack(true);
+        }
+      });
+    }
+
+    if (superType.isArray()) {
+      enableSizeEnter(labelAndText);
+    }
+
+    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 Image getImage() {
+    return getShell().getDisplay().getSystemImage(SWT.ICON_QUESTION);
+  }
+
+  int getArraySize() {
+    return arraySize;
+  }
+
+  Type getType() {
+    return selectedType;
+  }
+}
\ No newline at end of file

Modified: 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?rev=572733&r1=572732&r2=572733&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/EditViewPage.java Tue Sep  4 09:44:39 2007
@@ -19,10 +19,10 @@
 
 package org.apache.uima.caseditor.editor.editview;
 
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.uima.cas.ArrayFS;
+import org.apache.uima.cas.BooleanArrayFS;
 import org.apache.uima.cas.ByteArrayFS;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CommonArrayFS;
@@ -33,7 +33,9 @@
 import org.apache.uima.cas.IntArrayFS;
 import org.apache.uima.cas.LongArrayFS;
 import org.apache.uima.cas.ShortArrayFS;
+import org.apache.uima.cas.StringArrayFS;
 import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.caseditor.CasEditorPlugin;
 import org.apache.uima.caseditor.Images;
 import org.apache.uima.caseditor.core.TaeError;
@@ -51,6 +53,7 @@
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
 import org.eclipse.jface.viewers.EditingSupport;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -115,7 +118,8 @@
         if (arrayFS instanceof ArrayFS) {
           return false;
         }
-        else if (arrayFS instanceof CommonArrayFS) {
+        else if (arrayFS instanceof CommonArrayFS ||
+                arrayFS instanceof StringArrayFS) {
           return true;
         }
         else {
@@ -133,12 +137,19 @@
       if (element instanceof FeatureValue) {
         FeatureValue value = (FeatureValue) element;
 
-        if (Primitives.isPrimitive(value.getFeature())) {
+        if (value.getFeature().getRange().isPrimitive()) {
 
-          TextCellEditor editor = new TextCellEditor(viewer.getTree());
+          CellEditor editor;
 
-          editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
-                  .getPrimitiveClass(value.getFeature())));
+          if (value.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
+            editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
+                    SWT.READ_ONLY);
+          }
+          else {
+            editor = new TextCellEditor(viewer.getTree());
+            editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
+                    .getPrimitiveClass(value.getFeature())));
+          }
 
           return editor;
         }
@@ -149,31 +160,44 @@
 
         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));
+        CellEditor editor;
+
+        if (arrayFS instanceof BooleanArrayFS) {
+          editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
+                  SWT.READ_ONLY);
+          editor.setStyle(SWT.READ_ONLY);
         }
         else {
-          throw new TaeError("Unkown array type!");
+          editor = new TextCellEditor(viewer.getTree());
+
+          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 if (arrayFS instanceof StringArrayFS) {
+            // no validator needed
+          }
+          else {
+            throw new TaeError("Unkown array type!");
+          }
         }
+
         return editor;
       }
       else {
@@ -181,19 +205,49 @@
       }
     }
 
+    private int booleanToInt(boolean value) {
+      if (value) {
+        return 1;
+      }
+      else {
+        return 0;
+      }
+    }
+
+    private boolean intToBoolean(int value) {
+      return value == 1;
+    }
+
     @Override
     protected Object getValue(Object element) {
 
       if (element instanceof FeatureValue) {
         FeatureValue featureValue = (FeatureValue) element;
 
-        return featureValue.getFeatureStructure()
-                .getFeatureValueAsString(featureValue.getFeature());
+        // if not a boolean return string value,
+        // otherwise return boolean number
+        if (!featureValue.getFeature().getRange().getName().equals(
+                CAS.TYPE_NAME_BOOLEAN)) {
+          return featureValue.getFeatureStructure()
+            .getFeatureValueAsString(featureValue.getFeature());
+        }
+        else {
+          // for booleans
+          return booleanToInt(featureValue.getFeatureStructure().
+              getBooleanValue(featureValue.getFeature()));
+        }
+
       }
       else if (element instanceof ArrayValue) {
           ArrayValue value = (ArrayValue) element;
 
-          return value.get().toString();
+          // if not a boolean array return string value
+          if (!(value.getFeatureStructure() instanceof BooleanArrayFS)) {
+            return value.get().toString();
+          }
+          else {
+            return booleanToInt((Boolean) value.get());
+          }
       }
       else {
         throw new TaeError("Unkown element type!");
@@ -209,22 +263,36 @@
 
           FeatureValue featureValue = (FeatureValue) element;
 
-          if (Primitives.isPrimitive(featureValue.getFeature())) {
-
-            // TODO: try to prevent setting of invalid annotation span values
+          // for all other than boolean values
+          if (!featureValue.getFeature().getRange().getName().equals(
+                  CAS.TYPE_NAME_BOOLEAN)) {
+            if (featureValue.getFeature().getRange().isPrimitive()) {
 
-            featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(),
-                    (String) value);
+              // TODO: try to prevent setting of invalid annotation span values
 
-            document.update(featureValue.getFeatureStructure());
+              featureValue.getFeatureStructure().setFeatureValueFromString(featureValue.getFeature(),
+                      (String) value);
+            }
           }
+          else {
+            featureValue.getFeatureStructure().setBooleanValue(featureValue.getFeature(),
+                    intToBoolean((Integer) value));
+          }
+          document.update(featureValue.getFeatureStructure());
 
           viewer.update(element, null);
 
         } else if (element instanceof ArrayValue) {
 
           ArrayValue arrayValue = (ArrayValue) element;
-          arrayValue.set((String) value);
+
+          if (!(arrayValue.getFeatureStructure() instanceof BooleanArrayFS)) {
+            arrayValue.set((String) value);
+          }
+          else {
+            arrayValue.set(Boolean.toString(
+                    intToBoolean((Integer) value)).toString());
+          }
 
           document.update(arrayValue.getFeatureStructure());
 
@@ -247,15 +315,24 @@
     public void run() {
       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
 
-      for (Iterator it = selection.iterator(); it.hasNext(); ) {
+      Object element = selection.getFirstElement();
 
-        FeatureValue featureValue = (FeatureValue) it.next();
+      if (element instanceof FeatureValue) {
+        FeatureValue featureValue = (FeatureValue) element;
 
         if (!featureValue.getFeature().getRange().isPrimitive()) {
           featureValue.getFeatureStructure().setFeatureValue(featureValue.getFeature(), null);
 
           document.update(featureValue.getFeatureStructure());
         }
+      } else if (element instanceof ArrayValue) {
+          ArrayValue arrayValue = (ArrayValue) element;
+
+          ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
+
+          array.set(arrayValue.slot(), null);
+
+          document.update(array);
       }
     }
 
@@ -271,6 +348,15 @@
           result = !featureValue.getFeature().getRange().isPrimitive() &&
               featureValue.getFeatureStructure().getFeatureValue(featureValue.getFeature()) != null;
         }
+        else if (selection.getFirstElement() instanceof ArrayValue) {
+          ArrayValue arrayValue = (ArrayValue) selection.getFirstElement();
+
+            if (arrayValue.getFeatureStructure() instanceof ArrayFS) {
+              ArrayFS array = (ArrayFS) arrayValue.getFeatureStructure();
+
+              result = array.get(arrayValue.slot()) != null;
+            }
+        }
       }
 
       return result;
@@ -286,6 +372,42 @@
       setEnabled(false);
     }
 
+
+    FeatureStructure createFS(Type type, int arraySize) {
+
+      FeatureStructure fs;
+
+      if (!type.isArray()) {
+        fs = document.getCAS().createFS(type);
+      }
+      else {
+
+        if (type.getName().equals(CAS.TYPE_NAME_BOOLEAN_ARRAY)) {
+          fs = document.getCAS().createBooleanArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_BYTE_ARRAY)) {
+          fs = document.getCAS().createByteArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
+          fs = document.getCAS().createShortArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
+          fs = document.getCAS().createIntArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
+          fs = document.getCAS().createLongArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
+          fs = document.getCAS().createFloatArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
+          fs = document.getCAS().createDoubleArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_STRING_ARRAY)) {
+          fs = document.getCAS().createStringArrayFS(arraySize);
+        } else if (type.getName().equals(CAS.TYPE_NAME_FS_ARRAY)) {
+          fs = document.getCAS().createArrayFS(arraySize);
+        } else {
+          throw new TaeError("Unkown array type!");
+        }
+      }
+
+      return fs;
+    }
+
     @Override
     public void run() {
       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
@@ -302,6 +424,7 @@
               document.getCAS().getTypeSystem().getProperlySubsumedTypes(fsSuperType);
 
           Type typeToCreate;
+          int arraySize = -1;
 
           if (subTypes.size() == 0) {
             typeToCreate = fsSuperType;
@@ -311,18 +434,18 @@
                  new CreateFeatureStructureDialog(Display.getCurrent()
                          .getActiveShell(), fsSuperType, document.getCAS().getTypeSystem());
 
-
              int returnCode = createFsDialog.open();
 
              if (returnCode == IDialogConstants.OK_ID) {
                typeToCreate = createFsDialog.getType();
+               arraySize = createFsDialog.getArraySize();
              }
              else {
                return;
              }
           }
 
-          newValue = document.getCAS().createFS(typeToCreate);
+          newValue = createFS(typeToCreate, arraySize);
 
           document.addFeatureStructure(newValue);
         } else {
@@ -334,30 +457,7 @@
           int returnCode = createArrayDialog.open();
 
           if (returnCode == IDialogConstants.OK_ID) {
-            // get size from array dialog
-            int arraySize = createArrayDialog.getArraySize();
-
-            FeatureStructure arrayFS;
-
-            if (arrayType.getName().equals(CAS.TYPE_NAME_BYTE_ARRAY)) {
-              arrayFS = document.getCAS().createByteArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
-              arrayFS = document.getCAS().createShortArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
-              arrayFS = document.getCAS().createIntArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)) {
-              arrayFS = document.getCAS().createLongArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
-              arrayFS = document.getCAS().createFloatArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_DOUBLE_ARRAY)) {
-              arrayFS = document.getCAS().createDoubleArrayFS(arraySize);
-            } else if (arrayType.getName().equals(CAS.TYPE_NAME_FS_ARRAY)) {
-              arrayFS = document.getCAS().createArrayFS(arraySize);
-            } else {
-              throw new TaeError("Unkown array type!");
-            }
-
-            newValue = arrayFS;
+            newValue = createFS(arrayType, createArrayDialog.getArraySize());
           } else {
             return;
           }
@@ -369,13 +469,27 @@
       else if (selection.getFirstElement() instanceof ArrayValue) {
         ArrayValue value = (ArrayValue) selection.getFirstElement();
 
-        ArrayFS array = document.getCAS().createArrayFS(2);
 
-        // create a fs of a given type
+        TypeSystem typeSystem = document.getCAS().getTypeSystem();
 
-        array.set(value.slot(), null);
-      }
+        CreateFeatureStructureDialog createFsDialog =
+          new CreateFeatureStructureDialog(Display.getCurrent()
+                  .getActiveShell(), typeSystem.getType(CAS.TYPE_NAME_TOP),
+                  typeSystem);
+
+        int returnCode = createFsDialog.open();
+
+        if (returnCode == IDialogConstants.OK_ID) {
+
+          FeatureStructure fs = createFS(createFsDialog.getType(), createFsDialog.getArraySize());
+
+          ArrayFS array = (ArrayFS) value.getFeatureStructure();
 
+          array.set(value.slot(), fs);
+
+          document.update(value.getFeatureStructure());
+        }
+      }
     }
 
     @Override
@@ -494,31 +608,50 @@
 
       public void drop(DropTargetEvent event) {
         if (FeatureStructureTransfer.getInstance().isSupportedType(event.currentDataType)) {
+
+          event.detail = DND.DROP_NONE;
+
           Widget tableItem = event.item;
 
           if (tableItem != null) {
-            // this can fail
-            FeatureValue value = (FeatureValue) tableItem.getData();
 
-            Type range = value.getFeature().getRange();
+            if (tableItem.getData() instanceof FeatureValue) {
 
-            FeatureStructure dragFeatureStructure = (FeatureStructure) event.data;
+              // this can fail
+              FeatureValue value = (FeatureValue) tableItem.getData();
 
-            if (range.equals(dragFeatureStructure.getType())) {
+              Type range = value.getFeature().getRange();
 
-              FeatureStructure target = value.getFeatureStructure();
+              FeatureStructure dragFeatureStructure = (FeatureStructure) event.data;
 
-              target.setFeatureValue(value.getFeature(), dragFeatureStructure);
+              if (range.equals(dragFeatureStructure.getType())) {
+
+                FeatureStructure target = value.getFeatureStructure();
+
+                target.setFeatureValue(value.getFeature(), dragFeatureStructure);
+
+                document.update(target);
+
+                event.detail = DND.DROP_COPY;
+              }
+            } else if (tableItem.getData() instanceof ArrayValue) {
+              ArrayValue value = (ArrayValue) tableItem.getData();
+
+              if (value.getFeatureStructure() instanceof ArrayFS) {
+
+                ArrayFS array = (ArrayFS) value.getFeatureStructure();
+
+                array.set(value.slot(), (FeatureStructure) event.data);
+
+                document.update(array);
+
+                event.detail = DND.DROP_COPY;
+              }
 
-              document.update(target);
             } else {
-              event.detail = DND.DROP_NONE;
+              throw new TaeError("Unkown item type!");
             }
-          } else {
-            event.detail = DND.DROP_NONE;
           }
-        } else {
-          event.detail = DND.DROP_NONE;
         }
       }
 

Modified: 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?rev=572733&r1=572732&r2=572733&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/FeatureStructureContentProvider.java Tue Sep  4 09:44:39 2007
@@ -28,6 +28,7 @@
 import org.apache.uima.cas.CommonArrayFS;
 import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.StringArrayFS;
 import org.apache.uima.cas.Type;
 import org.apache.uima.caseditor.core.AbstractDocumentListener;
 import org.apache.uima.caseditor.core.TaeError;
@@ -50,6 +51,33 @@
     mDocument = document;
   }
 
+  private int arraySize(FeatureStructure value) {
+
+    if (!value.getType().isArray()) {
+      throw new IllegalArgumentException();
+    }
+
+    int size;
+
+    if (value instanceof ArrayFS) {
+      ArrayFS array = (ArrayFS) value;
+
+      size = array.size();
+    } else if (value instanceof CommonArrayFS) {
+      CommonArrayFS array = (CommonArrayFS) value;
+
+      size = array.size();
+    } else if (value instanceof StringArrayFS) {
+      StringArrayFS array = (StringArrayFS) value;
+
+      size = array.size();
+    } else {
+      throw new TaeError("Unkown array type!");
+    }
+
+    return size;
+  }
+
   public Object[] getElements(Object inputElement) {
 
 
@@ -76,17 +104,7 @@
         return featureValues.toArray();
       }
       else {
-        int size;
-
-        if (featureStructure instanceof CommonArrayFS) {
-          CommonArrayFS array = (CommonArrayFS) featureStructure;
-          size = array.size();
-        } else if (featureStructure instanceof ArrayFS) {
-          ArrayFS array = (ArrayFS) featureStructure;
-          size = array.size();
-        } else {
-          throw new TaeError("Unkown array type!");
-        }
+        int size = arraySize(featureStructure);
 
         ArrayValue arrayValues[] = new ArrayValue[size];
 
@@ -179,6 +197,26 @@
     return null;
   }
 
+  private boolean hasChildren(FeatureStructure value) {
+
+    boolean result;
+
+
+    if (value != null) {
+
+      if (value.getType().isArray()) {
+        // if array it has children if size != 0
+        result = arraySize(value) > 0;
+      } else {
+        result = value.getType().getFeatures().size() > 0;
+      }
+    } else {
+      result = false;
+    }
+
+    return result;
+  }
+
   public boolean hasChildren(Object element) {
 
     if (element instanceof FeatureValue) {
@@ -188,7 +226,7 @@
         return false;
       }
       else {
-        return value.getValue() != null;
+        return hasChildren((FeatureStructure) value.getValue());
       }
     } else if (element instanceof ArrayValue) {
 
@@ -198,12 +236,7 @@
 
         ArrayFS array = (ArrayFS) value.getFeatureStructure();
 
-        if (array.get(value.slot()) != null) {
-          return true;
-        }
-        else {
-          return false;
-        }
+        return hasChildren(array.get(value.slot()));
       }
       else {
         // false for primitive arrays

Modified: 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?rev=572733&r1=572732&r2=572733&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java (original)
+++ incubator/uima/sandbox/trunk/CasEditor/src/main/java/org/apache/uima/caseditor/editor/editview/ValueColumnLabelProvider.java Tue Sep  4 09:44:39 2007
@@ -22,6 +22,7 @@
 import org.apache.uima.cas.ArrayFS;
 import org.apache.uima.cas.CommonArrayFS;
 import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.StringArrayFS;
 import org.apache.uima.caseditor.core.TaeError;
 import org.apache.uima.caseditor.editor.ArrayValue;
 import org.apache.uima.caseditor.editor.FeatureValue;
@@ -56,7 +57,8 @@
       ArrayValue value = (ArrayValue) element;
 
       // if primitive array
-      if (value.getFeatureStructure() instanceof CommonArrayFS) {
+      if (value.getFeatureStructure() instanceof CommonArrayFS ||
+              value.getFeatureStructure() instanceof StringArrayFS) {
         cell.setText(value.get().toString());
       }
       else if (value.getFeatureStructure() instanceof ArrayFS) {
@@ -68,7 +70,7 @@
           cell.setText("null");
         }
         else {
-          cell.setText("");
+          cell.setText("[" + fs.getType().getShortName() + "]");
         }
       }
       else {