You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2019/07/17 18:58:38 UTC

svn commit: r1863233 [2/3] - in /uima/uimaj/trunk/uimaj-ep-configurator: ./ src/main/java/org/apache/uima/taeconfigurator/editors/ui/ src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/

Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java?rev=1863233&r1=1863232&r2=1863233&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java (original)
+++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java Wed Jul 17 18:58:38 2019
@@ -41,85 +41,130 @@ import org.apache.uima.taeconfigurator.e
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.ui.forms.IManagedForm;
 
+
+/**
+ * The Class CapabilitySection.
+ */
 public class CapabilitySection extends AbstractSection {
 
+  /** The Constant CAPABILITY_SET. */
   private final static String CAPABILITY_SET = "Set";
 
+  /** The Constant INPUT. */
   private final static String INPUT = "Input";
 
+  /** The Constant OUTPUT. */
   private final static String OUTPUT = "Output";
 
+  /** The Constant ALL_FEATURES. */
   public final static String ALL_FEATURES = "<all features>";
 
+  /** The Constant TYPE_TITLE. */
   private final static String TYPE_TITLE = "Type:";
 
+  /** The Constant FEAT_TITLE. */
   private final static String FEAT_TITLE = "F:"; // not shown, in data field
 
+  /** The Constant NAME_TITLE. */
   private final static String NAME_TITLE = "Name                ";
 
+  /** The Constant NAMESPACE_TITLE. */
   private final static String NAMESPACE_TITLE = "Name Space";
 
+  /** The Constant LANGS_TITLE. */
   private final static String LANGS_TITLE = "Languages";
 
+  /** The Constant LANG_TITLE. */
   private final static String LANG_TITLE = "L:"; // not shown, in datafield
 
+  /** The Constant SOFAS_TITLE. */
   private final static String SOFAS_TITLE = "Sofas";
 
+  /** The Constant SOFA_TITLE. */
   private final static String SOFA_TITLE = "S:"; // not shown, in data field
 
+  /** The Constant CS. */
   private final static int CS = 1;
 
+  /** The Constant TYPE. */
   private final static int TYPE = 1 << 1;
 
+  /** The Constant FEAT. */
   private final static int FEAT = 1 << 2;
 
+  /** The Constant LANG. */
   private final static int LANG = 1 << 3;
 
+  /** The Constant LANG_ITEM. */
   private final static int LANG_ITEM = 1 << 4;
 
+  /** The Constant SOFA. */
   private final static int SOFA = 1 << 5;
 
+  /** The Constant SOFA_ITEM. */
   private final static int SOFA_ITEM = 1 << 6;
 
+  /** The Constant TITLE_COL. */
   public final static int TITLE_COL = 0;
 
+  /** The Constant NAME_COL. */
   public final static int NAME_COL = 1;
 
+  /** The Constant INPUT_COL. */
   public final static int INPUT_COL = 2;
 
+  /** The Constant OUTPUT_COL. */
   public final static int OUTPUT_COL = 3;
 
+  /** The Constant NAMESPACE_COL. */
   public final static int NAMESPACE_COL = 4;
 
-  TableTree tt; // for inner class access
+  /** The tt. */
+  Tree tt; // for inner class access
 
+  /** The add capability button. */
   private Button addCapabilityButton;
 
+  /** The add lang button. */
   private Button addLangButton;
 
+  /** The add type button. */
   private Button addTypeButton;
 
+  /** The add sofa button. */
   private Button addSofaButton;
 
+  /** The add edit feature button. */
   private Button addEditFeatureButton;
 
+  /** The edit button. */
   private Button editButton;
 
+  /** The remove button. */
   private Button removeButton;
 
+  /** The type info. */
   private Map typeInfo;
 
+  /** The sofa map section. */
   private SofaMapSection sofaMapSection;
 
+  /**
+   * Instantiates a new capability section.
+   *
+   * @param aEditor the a editor
+   * @param parent the parent
+   */
   public CapabilitySection(MultiPageEditor aEditor, Composite parent) {
     super(
             aEditor,
@@ -128,6 +173,10 @@ public class CapabilitySection extends A
             "This section describes the languages handled, and the inputs needed and outputs provided in terms of the Types and Features.");
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#initialize(org.eclipse.ui.forms.IManagedForm)
+   */
+  @Override
   public void initialize(IManagedForm form) {
     super.initialize(form);
 
@@ -135,18 +184,18 @@ public class CapabilitySection extends A
     enableBorders(sectionClient);
     toolkit.paintBordersFor(sectionClient);
 
-    tt = newTableTree(sectionClient, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
-    Table table = tt.getTable();
+    tt = newTree(sectionClient, SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION);
+//    Table table = tt.getTable();
 
     // work around for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=65865
-    new TableColumn(table, SWT.NONE).setText("                 ");
+    new TreeColumn(tt, SWT.NONE).setText("                 ");
 
-    newTableColumn(table, SWT.NONE).setText(NAME_TITLE); // type or feat name
-    newTableColumn(table, SWT.NONE).setText(INPUT);
-    newTableColumn(table, SWT.NONE).setText(OUTPUT);
-    newTableColumn(table, SWT.NONE).setText(NAMESPACE_TITLE); // rest of typename
-    table.setHeaderVisible(true);
-    table.setLinesVisible(true);
+    newTreeColumn(tt, SWT.NONE).setText(NAME_TITLE); // type or feat name
+    newTreeColumn(tt, SWT.NONE).setText(INPUT);
+    newTreeColumn(tt, SWT.NONE).setText(OUTPUT);
+    newTreeColumn(tt, SWT.NONE).setText(NAMESPACE_TITLE); // rest of typename
+    tt.setHeaderVisible(true);
+    tt.setLinesVisible(true);
     tt.addListener(SWT.MouseHover, this); // to show description
 
     final Composite buttonContainer = newButtonContainer(sectionClient);
@@ -173,6 +222,7 @@ public class CapabilitySection extends A
    * 
    * @see org.eclipse.ui.forms.IFormPart#refresh()
    */
+  @Override
   public void refresh() {
     super.refresh();
     sofaMapSection = editor.getCapabilityPage().getSofaMapSection();
@@ -182,14 +232,14 @@ public class CapabilitySection extends A
     Capability[] cs = getCapabilities();
     if (null != cs) {
       for (int i = 0; i < cs.length; i++) {
-        TableTreeItem item = new TableTreeItem(tt, SWT.NONE);
+        TreeItem item = new TreeItem(tt, SWT.NONE);
         item.setText(TITLE_COL, CAPABILITY_SET);
         item.setData(cs[i]);
-        tt.setSelection(new TableTreeItem[] { item }); // set default selection
+        tt.setSelection(new TreeItem[] { item }); // set default selection
         fillCapability(item, cs[i]);
         // if (0 == i) {
         item.setExpanded(true);
-        TableTreeItem[] types = item.getItems();
+        TreeItem[] types = item.getItems();
         if (types != null)
           for (int j = 0; j < types.length; j++) {
             types[j].setExpanded(true);
@@ -197,68 +247,97 @@ public class CapabilitySection extends A
         // }
       }
     }
-    packTable(tt.getTable());
+    packTree(tt);
     enable();
     tt.getParent().setRedraw(true);
   }
 
   /**
-   * value of hash table keyed on type name
+   * value of hash table keyed on type name.
    */
   private static class TypeCapability {
+    
+    /** The is input type. */
     boolean isInputType; // true if mentioned in <type>
 
+    /** The is output type. */
     boolean isOutputType; // true if mentioned in <type>
 
+    /** The features. */
     Map features = new TreeMap();
   }
 
+  /**
+   * The Class FeatureCapability.
+   */
   private static class FeatureCapability {
+    
+    /** The is input feature. */
     boolean isInputFeature = false;
 
+    /** The is output type. */
     boolean isOutputType = false;
 
+    /** The is output update. */
     boolean isOutputUpdate = false;
   }
 
-  private TableTreeItem createLanguageHeaderGui(TableTreeItem parent) {
-    TableTreeItem langHdr = new TableTreeItem(parent, SWT.NONE);
+  /**
+   * Creates the language header gui.
+   *
+   * @param parent the parent
+   * @return the table tree item
+   */
+  private TreeItem createLanguageHeaderGui(TreeItem parent) {
+    TreeItem langHdr = new TreeItem(parent, SWT.NONE);
     langHdr.setText(TITLE_COL, LANGS_TITLE);
     langHdr.setData(LANGS_TITLE);
     return langHdr;
   }
 
-  private TableTreeItem createSofaHeaderGui(TableTreeItem parent) {
-    TableTreeItem sofaHdr = new TableTreeItem(parent, SWT.NONE);
+  /**
+   * Creates the sofa header gui.
+   *
+   * @param parent the parent
+   * @return the table tree item
+   */
+  private TreeItem createSofaHeaderGui(TreeItem parent) {
+    TreeItem sofaHdr = new TreeItem(parent, SWT.NONE);
     sofaHdr.setText(TITLE_COL, SOFAS_TITLE);
     sofaHdr.setData(SOFAS_TITLE);
     return sofaHdr;
   }
 
-  private void fillCapability(TableTreeItem parent, Capability c) {
+  /**
+   * Fill capability.
+   *
+   * @param parent the parent
+   * @param c the c
+   */
+  private void fillCapability(TreeItem parent, Capability c) {
     // first output language capabilities
-    TableTreeItem langHdr = createLanguageHeaderGui(parent);
+    TreeItem langHdr = createLanguageHeaderGui(parent);
     String[] languages = c.getLanguagesSupported();
     if (null != languages) {
       for (int i = 0; i < languages.length; i++) {
-        TableTreeItem lItem = new TableTreeItem(langHdr, SWT.NONE);
+        TreeItem lItem = new TreeItem(langHdr, SWT.NONE);
         lItem.setData(LANG_TITLE);
         lItem.setText(NAME_COL, languages[i]);
       }
     }
 
     // second, output Sofas
-    TableTreeItem sofaHdr = createSofaHeaderGui(parent);
+    TreeItem sofaHdr = createSofaHeaderGui(parent);
     String[] inputSofaNames = c.getInputSofas();
     String[] outputSofaNames = c.getOutputSofas();
     Arrays.sort(inputSofaNames);
     Arrays.sort(outputSofaNames);
     for (int i = 0; i < inputSofaNames.length; i++) {
-      TableTreeItem item = new TableTreeItem(sofaHdr, SWT.NONE);
+      TreeItem item = new TreeItem(sofaHdr, SWT.NONE);
       setGuiSofaName(item, inputSofaNames[i], true);
     }
     for (int i = 0; i < outputSofaNames.length; i++) {
-      TableTreeItem item = new TableTreeItem(sofaHdr, SWT.NONE);
+      TreeItem item = new TreeItem(sofaHdr, SWT.NONE);
       setGuiSofaName(item, outputSofaNames[i], false);
     }
 
@@ -316,7 +395,7 @@ public class CapabilitySection extends A
       String typeName = (String) entry.getKey();
       tc = (TypeCapability) entry.getValue();
 
-      TableTreeItem item = new TableTreeItem(parent, SWT.NONE);
+      TreeItem item = new TreeItem(parent, SWT.NONE);
       setGuiTypeName(item, typeName);
       if (tc.isInputType)
         item.setText(INPUT_COL, INPUT);
@@ -328,7 +407,7 @@ public class CapabilitySection extends A
         String featName = (String) fEntry.getKey();
         fc = (FeatureCapability) fEntry.getValue();
 
-        TableTreeItem fItem = new TableTreeItem(item, SWT.NONE);
+        TreeItem fItem = new TreeItem(item, SWT.NONE);
         fItem.setData(FEAT_TITLE);
         fItem.setText(NAME_COL, featName);
         if (fc.isInputFeature)
@@ -340,13 +419,26 @@ public class CapabilitySection extends A
     }
   }
 
-  private void setGuiTypeName(TableTreeItem item, String typeName) {
+  /**
+   * Sets the gui type name.
+   *
+   * @param item the item
+   * @param typeName the type name
+   */
+  private void setGuiTypeName(TreeItem item, String typeName) {
     item.setText(TITLE_COL, TYPE_TITLE);
     item.setText(NAME_COL, getShortName(typeName));
     item.setText(NAMESPACE_COL, getNameSpace(typeName));
   }
 
-  private void setGuiSofaName(TableTreeItem item, String sofaName, boolean isInput) {
+  /**
+   * Sets the gui sofa name.
+   *
+   * @param item the item
+   * @param sofaName the sofa name
+   * @param isInput the is input
+   */
+  private void setGuiSofaName(TreeItem item, String sofaName, boolean isInput) {
     item.setData(SOFA_TITLE);
     item.setText(NAME_COL, sofaName);
     if (isInput) {
@@ -358,6 +450,12 @@ public class CapabilitySection extends A
     }
   }
 
+  /**
+   * Gets the type capability.
+   *
+   * @param typeName the type name
+   * @return the type capability
+   */
   private TypeCapability getTypeCapability(String typeName) {
     TypeCapability typeCapability = (TypeCapability) typeInfo.get(typeName);
     if (null == typeCapability) {
@@ -366,6 +464,13 @@ public class CapabilitySection extends A
     return typeCapability;
   }
 
+  /**
+   * Gets the feature capability.
+   *
+   * @param tc the tc
+   * @param featureShortName the feature short name
+   * @return the feature capability
+   */
   private FeatureCapability getFeatureCapability(TypeCapability tc, String featureShortName) {
     FeatureCapability fc = (FeatureCapability) tc.features.get(featureShortName);
     if (null == fc) {
@@ -374,6 +479,12 @@ public class CapabilitySection extends A
     return fc;
   }
 
+  /**
+   * Gets the type name from full feature name.
+   *
+   * @param name the name
+   * @return the type name from full feature name
+   */
   public String getTypeNameFromFullFeatureName(String name) {
     return (name.substring(0, name.indexOf(":")));
   }
@@ -383,6 +494,7 @@ public class CapabilitySection extends A
    * 
    * @see org.apache.uima.taeconfigurator.editors.ui.AbstractTableSection#handleEvent(org.eclipse.swt.widgets.Event)
    */
+  @Override
   public void handleEvent(Event event) {
     if (event.type == SWT.Expand || event.type == SWT.Collapse) {
       pack04();
@@ -394,7 +506,7 @@ public class CapabilitySection extends A
       return;
     }
 
-    TableTreeItem selItem = tt.getSelection()[0];
+    TreeItem selItem = tt.getSelection()[0];
     int itemKind = getItemKind(selItem);
 
     if (event.widget == addLangButton) {
@@ -408,52 +520,75 @@ public class CapabilitySection extends A
     } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
       handleEdit(selItem, itemKind);
     } else if (event.widget == removeButton
-            || (event.widget == tt.getTable() && event.type == SWT.KeyUp && event.character == SWT.DEL)) {
+            || (event.widget == tt && event.type == SWT.KeyUp && event.character == SWT.DEL)) {
       handleRemove(selItem, itemKind);
     }
 
     enable();
   }
 
+  /**
+   * Handle add capability.
+   */
   private void handleAddCapability() {
     Capability newCset = addCapabilitySet();
 
     // update the GUI
-    TableTreeItem item = new TableTreeItem(tt, SWT.NONE);
+    TreeItem item = new TreeItem(tt, SWT.NONE);
     item.setText(CAPABILITY_SET);
     item.setData(newCset);
     createLanguageHeaderGui(item);
     createSofaHeaderGui(item);
 
     item.setExpanded(true);
-    tt.setSelection(new TableTreeItem[] { item });
+    tt.setSelection(new TreeItem[] { item });
     if (tt.getItemCount() == 1)
-      tt.getTable().getColumn(TITLE_COL).pack();
+      tt.getColumn(TITLE_COL).pack();
     finishAction();
   }
 
-  private void getOrCreateAllFeatItem(TableTreeItem editItem, int column, String inOrOut) {
-    TableTreeItem allFeatItem = getAllFeatItem(editItem);
+  /**
+   * Gets the or create all feat item.
+   *
+   * @param editItem the edit item
+   * @param column the column
+   * @param inOrOut the in or out
+   * @return the or create all feat item
+   */
+  private void getOrCreateAllFeatItem(TreeItem editItem, int column, String inOrOut) {
+    TreeItem allFeatItem = getAllFeatItem(editItem);
     if (null == allFeatItem) {
-      allFeatItem = new TableTreeItem(editItem, SWT.NONE, 0);
+      allFeatItem = new TreeItem(editItem, SWT.NONE, 0);
       allFeatItem.setData(FEAT_TITLE);
       allFeatItem.setText(NAME_COL, ALL_FEATURES);
     }
     allFeatItem.setText(column, inOrOut);
   }
 
-  private TableTreeItem getAllFeatItem(TableTreeItem editItem) {
-    TableTreeItem[] subItems = editItem.getItems();
+  /**
+   * Gets the all feat item.
+   *
+   * @param editItem the edit item
+   * @return the all feat item
+   */
+  private TreeItem getAllFeatItem(TreeItem editItem) {
+    TreeItem[] subItems = editItem.getItems();
     if (null == subItems || subItems.length == 0)
       return null;
-    TableTreeItem item = subItems[0];
+    TreeItem item = subItems[0];
     if (ALL_FEATURES.equals(item.getText(NAME_COL)))
       return item;
     return null;
   }
 
-  private void removeAllFeatItemGui(TableTreeItem editItem, int column) {
-    TableTreeItem allFeatItem = getAllFeatItem(editItem);
+  /**
+   * Removes the all feat item gui.
+   *
+   * @param editItem the edit item
+   * @param column the column
+   */
+  private void removeAllFeatItemGui(TreeItem editItem, int column) {
+    TreeItem allFeatItem = getAllFeatItem(editItem);
     if (null == allFeatItem)
       // throw new InternalErrorCDE("invalid state");
       return; // happens when no allfeat is set
@@ -463,7 +598,13 @@ public class CapabilitySection extends A
       allFeatItem.dispose();
   }
 
-  private void handleEdit(TableTreeItem editItem, int itemKind) {
+  /**
+   * Handle edit.
+   *
+   * @param editItem the edit item
+   * @param itemKind the item kind
+   */
+  private void handleEdit(TreeItem editItem, int itemKind) {
     Capability c = getCapability(editItem);
     switch (itemKind) {
       case SOFA_ITEM: {
@@ -584,7 +725,7 @@ public class CapabilitySection extends A
       }
 
       case FEAT: {
-        TableTreeItem typeItem = editItem.getParentItem();
+        TreeItem typeItem = editItem.getParentItem();
         String typeName = getFullyQualifiedName(typeItem);
 
         // using the CAS to get all the inherited features
@@ -602,6 +743,13 @@ public class CapabilitySection extends A
     }
   }
 
+  /**
+   * Any capability set declares sofa.
+   *
+   * @param name the name
+   * @param isInput the is input
+   * @return true, if successful
+   */
   private boolean anyCapabilitySetDeclaresSofa(String name, boolean isInput) {
     final Capability[] cSets = getAnalysisEngineMetaData().getCapabilities();
     for (int i = 0; i < cSets.length; i++) {
@@ -614,16 +762,24 @@ public class CapabilitySection extends A
     return false;
   }
 
-  private void handleRemove(TableTreeItem removeItem, int itemKind) {
-    Table table = tt.getTable();
-    int previousSelection = table.getSelectionIndex() - 1;
+  /**
+   * Handle remove.
+   *
+   * @param removeItem the remove item
+   * @param itemKind the item kind
+   */
+  private void handleRemove(TreeItem removeItem, int itemKind) {
+//    Table table = tt.getTable();
+//    int previousSelection = tt.getSelectionIndex() - 1;
+    int selectionIndex = tt.indexOf(tt.getSelection()[0]);
+    int previousSelection = selectionIndex - 1;
     Capability c = getCapability(removeItem);
     switch (itemKind) {
       case CS: {
         if (Window.CANCEL == Utility.popOkCancel("Confirm Remove",
                 "This action will remove an entire capability set.  Please confirm.",
                 MessageDialog.WARNING)) {
-          table.setSelection(table.getSelectionIndex() + 1);
+          tt.setSelection(tt.getItems()[selectionIndex + 1]);
           return;
         }
         removeCapabilitySet(c);
@@ -642,7 +798,7 @@ public class CapabilitySection extends A
                         "Confirm Removal of Sofa",
                         "This action will remove this Sofa as a capability, and delete its mappings if no other capability set declares this Sofa."
                                 + "  Please confirm.", MessageDialog.WARNING)) {
-          table.setSelection(table.getSelectionIndex() + 1);
+          tt.setSelection(tt.getItems()[selectionIndex + 1]);
           return;
         }
         String sofaName = removeItem.getText(NAME_COL);
@@ -657,6 +813,7 @@ public class CapabilitySection extends A
 
         if (!anyCapabilitySetDeclaresSofa(sofaName, isInput)) {
           Comparator comparator = new Comparator() {
+            @Override
             public int compare(Object o1, Object o2) {
               String name = (String) o1;
               SofaMapping sofaMapping = (SofaMapping) o2;
@@ -677,10 +834,10 @@ public class CapabilitySection extends A
         if (Window.CANCEL == Utility.popOkCancel("Confirm Removal of Type",
                 "This action will remove this type as a capability.  Please confirm.",
                 MessageDialog.WARNING)) {
-          table.setSelection(table.getSelectionIndex() + 1);
+          tt.setSelection(tt.getItems()[selectionIndex + 1]);
           return;
         }
-        TableTreeItem[] features = removeItem.getItems();
+        TreeItem[] features = removeItem.getItems();
         if (null != features)
           for (int i = 0; i < features.length; i++) {
             removeFeature(c, features[i]);
@@ -702,10 +859,15 @@ public class CapabilitySection extends A
         throw new InternalErrorCDE("invalid state");
     }
 
-    table.setSelection(previousSelection);
+    tt.setSelection(tt.getItems()[previousSelection]);
     finishAction();
   }
 
+  /**
+   * Removes the capability set.
+   *
+   * @param c the c
+   */
   private void removeCapabilitySet(Capability c) {
     Capability[] cs = getAnalysisEngineMetaData().getCapabilities();
     Capability[] newCs = new Capability[cs.length - 1];
@@ -716,23 +878,55 @@ public class CapabilitySection extends A
     getAnalysisEngineMetaData().setCapabilities(newCs);
   }
 
-  private boolean isInput(TableTreeItem item) {
+  /**
+   * Checks if is input.
+   *
+   * @param item the item
+   * @return true, if is input
+   */
+  private boolean isInput(TreeItem item) {
     return INPUT.equals(item.getText(INPUT_COL)); // works if getText() returns null
   }
 
-  private boolean isOutput(TableTreeItem item) {
+  /**
+   * Checks if is output.
+   *
+   * @param item the item
+   * @return true, if is output
+   */
+  private boolean isOutput(TreeItem item) {
     return OUTPUT.equals(item.getText(OUTPUT_COL));
   }
 
+  /**
+   * Checks if is input.
+   *
+   * @param fullFeatureName the full feature name
+   * @param c the c
+   * @return true, if is input
+   */
   public static boolean isInput(String fullFeatureName, Capability c) {
     return null != getTypeOrFeature(c.getInputs(), fullFeatureName);
   }
 
+  /**
+   * Checks if is output.
+   *
+   * @param fullFeatureName the full feature name
+   * @param c the c
+   * @return true, if is output
+   */
   public static boolean isOutput(String fullFeatureName, Capability c) {
     return null != getTypeOrFeature(c.getOutputs(), fullFeatureName);
   }
 
-  private void removeFeature(Capability c, TableTreeItem removeItem) {
+  /**
+   * Removes the feature.
+   *
+   * @param c the c
+   * @param removeItem the remove item
+   */
+  private void removeFeature(Capability c, TreeItem removeItem) {
     String shortFeatureName = removeItem.getText(NAME_COL);
     if (shortFeatureName.equals(ALL_FEATURES)) {
       if (isInput(removeItem)) {
@@ -756,11 +950,23 @@ public class CapabilitySection extends A
     removeItem.dispose();
   }
 
-  public Capability getCapabilityFromTableTreeItem(TableTreeItem item) {
+  /**
+   * Gets the capability from table tree item.
+   *
+   * @param item the item
+   * @return the capability from table tree item
+   */
+  public Capability getCapabilityFromTreeItem(TreeItem item) {
     return (Capability) item.getData();
   }
 
-  private void handleAddLang(TableTreeItem selItem, int itemKind) {
+  /**
+   * Handle add lang.
+   *
+   * @param selItem the sel item
+   * @param itemKind the item kind
+   */
+  private void handleAddLang(TreeItem selItem, int itemKind) {
     if (itemKind == CS)
       selItem = selItem.getItems()[0]; // lang is 1st item in capability set
     else if (itemKind == LANG_ITEM)
@@ -769,7 +975,7 @@ public class CapabilitySection extends A
       selItem = selItem.getParentItem().getItems()[0];
     else if (itemKind == FEAT || itemKind == SOFA_ITEM)
       selItem = selItem.getParentItem().getParentItem().getItems()[0];
-    Capability c = getCapabilityFromTableTreeItem(selItem.getParentItem());
+    Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
     CommonInputDialog dialog = new CommonInputDialog(
             this,
             "Add Language",
@@ -781,7 +987,7 @@ public class CapabilitySection extends A
     c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue()));
 
     // update GUI
-    TableTreeItem lItem = new TableTreeItem(selItem, SWT.NONE);
+    TreeItem lItem = new TreeItem(selItem, SWT.NONE);
     lItem.setData(LANG_TITLE);
     lItem.setText(NAME_COL, dialog.getValue());
     selItem.setExpanded(true);
@@ -789,12 +995,18 @@ public class CapabilitySection extends A
     finishAction();
   }
 
-  private void handleAddType(TableTreeItem selItem, int itemKind) {
+  /**
+   * Handle add type.
+   *
+   * @param selItem the sel item
+   * @param itemKind the item kind
+   */
+  private void handleAddType(TreeItem selItem, int itemKind) {
     if (itemKind == LANG || itemKind == TYPE || itemKind == SOFA)
       selItem = selItem.getParentItem();
     else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM)
       selItem = selItem.getParentItem().getParentItem();
-    Capability c = getCapabilityFromTableTreeItem(selItem);
+    Capability c = getCapabilityFromTreeItem(selItem);
     AddCapabilityTypeDialog dialog = new AddCapabilityTypeDialog(this, c);
     if (dialog.open() == Window.CANCEL)
       return;
@@ -807,12 +1019,12 @@ public class CapabilitySection extends A
       if (dialog.outputs[i])
         c.addOutputType(dialog.types[i], dialog.outputs[i]);
 
-      TableTreeItem item = new TableTreeItem(selItem, SWT.NONE);
+      TreeItem item = new TreeItem(selItem, SWT.NONE);
       setGuiTypeName(item, dialog.types[i]);
       item.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
       item.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");
 
-      TableTreeItem fItem = new TableTreeItem(item, SWT.NONE);
+      TreeItem fItem = new TreeItem(item, SWT.NONE);
       fItem.setData(FEAT_TITLE);
       fItem.setText(NAME_COL, ALL_FEATURES);
       fItem.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
@@ -825,7 +1037,13 @@ public class CapabilitySection extends A
     finishAction();
   }
 
-  private void handleAddSofa(TableTreeItem selItem, int itemKind) {
+  /**
+   * Handle add sofa.
+   *
+   * @param selItem the sel item
+   * @param itemKind the item kind
+   */
+  private void handleAddSofa(TreeItem selItem, int itemKind) {
     if (itemKind == CS)
       selItem = selItem.getItems()[1];
     else if (itemKind == LANG || itemKind == TYPE)
@@ -833,7 +1051,7 @@ public class CapabilitySection extends A
     else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM)
       selItem = selItem.getParentItem().getParentItem().getItems()[1];
 
-    Capability c = getCapabilityFromTableTreeItem(selItem.getParentItem());
+    Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
     AddSofaDialog dialog = new AddSofaDialog(this, c);
     if (dialog.open() == Window.CANCEL)
       return;
@@ -844,7 +1062,7 @@ public class CapabilitySection extends A
     else
       c.setOutputSofas(stringArrayAdd(c.getOutputSofas(), dialog.sofaName));
 
-    TableTreeItem item = new TableTreeItem(selItem, SWT.NONE);
+    TreeItem item = new TreeItem(selItem, SWT.NONE);
     setGuiSofaName(item, dialog.sofaName, dialog.isInput);
     selItem.setExpanded(true);
     pack04();
@@ -853,11 +1071,17 @@ public class CapabilitySection extends A
     finishAction();
   }
 
-  private void handleAddEditFeature(TableTreeItem selItem, int itemKind) {
+  /**
+   * Handle add edit feature.
+   *
+   * @param selItem the sel item
+   * @param itemKind the item kind
+   */
+  private void handleAddEditFeature(TreeItem selItem, int itemKind) {
     if (itemKind == FEAT)
       selItem = selItem.getParentItem();
 
-    Capability c = getCapabilityFromTableTreeItem(selItem.getParentItem());
+    Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
     String typeName = getFullyQualifiedName(selItem);
 
     // using the CAS to get all the inherited features
@@ -870,9 +1094,17 @@ public class CapabilitySection extends A
     addOrEditFeature(dialog, typeName, selItem, c);
   }
 
+  /**
+   * Adds the or edit feature.
+   *
+   * @param dialog the dialog
+   * @param typeName the type name
+   * @param parentItem the parent item
+   * @param c the c
+   */
   private void addOrEditFeature(AddCapabilityFeatureDialog dialog, String typeName, // fully
           // qualified
-          TableTreeItem parentItem, Capability c) {
+          TreeItem parentItem, Capability c) {
     // set the <all features> flag on the type in the model, for input and output
     c.setInputs(setAllFeatures(c.getInputs(), typeName, dialog.allFeaturesInput));
     // The logic for output features is complicated. Output features are always listed in the
@@ -896,14 +1128,14 @@ public class CapabilitySection extends A
     } else
       c.setOutputs(setAllFeatures(c.getOutputs(), typeName, dialog.allFeaturesOutput));
 
-    TableTreeItem[] prevFeatGUI = parentItem.getItems();
+    TreeItem[] prevFeatGUI = parentItem.getItems();
     for (int i = 0; i < prevFeatGUI.length; i++) {
       prevFeatGUI[i].dispose();
     }
 
     // update GUI for <all features> - add element if needed
     if (dialog.allFeaturesInput || dialog.allFeaturesOutput) {
-      TableTreeItem item = new TableTreeItem(parentItem, SWT.NONE);
+      TreeItem item = new TreeItem(parentItem, SWT.NONE);
       item.setData(FEAT_TITLE);
       item.setText(NAME_COL, ALL_FEATURES);
       item.setText(INPUT_COL, dialog.allFeaturesInput ? INPUT : "");
@@ -920,15 +1152,15 @@ public class CapabilitySection extends A
       if (dialog.outputs[i])
         outputsL.add(newFeature(fullName));
       // update the GUI
-      TableTreeItem item = new TableTreeItem(parentItem, SWT.NONE);
+      TreeItem item = new TreeItem(parentItem, SWT.NONE);
       item.setData(FEAT_TITLE);
       item.setText(NAME_COL, dialog.features[i]);
       item.setText(INPUT_COL, dialog.inputs[i] ? INPUT : "");
       item.setText(OUTPUT_COL, dialog.outputs[i] ? OUTPUT : "");
     }
     parentItem.setExpanded(true);
-    tt.getTable().getColumn(NAME_COL).pack();
-    tt.setSelection(new TableTreeItem[] { parentItem });
+    tt.getColumn(NAME_COL).pack();
+    tt.setSelection(new TreeItem[] { parentItem });
 
     c.setInputs(replaceFeaturesKeepingTypes(c.getInputs(), typeName, inputsL));
     c.setOutputs(replaceFeaturesKeepingTypes(c.getOutputs(), typeName, outputsL));
@@ -936,6 +1168,12 @@ public class CapabilitySection extends A
     finishAction();
   }
 
+  /**
+   * New feature.
+   *
+   * @param name the name
+   * @return the type or feature
+   */
   private TypeOrFeature newFeature(String name) {
     TypeOrFeature result = new TypeOrFeature_impl();
     result.setType(false);
@@ -943,12 +1181,25 @@ public class CapabilitySection extends A
     return result;
   }
 
-  public String getFullyQualifiedName(TableTreeItem item) {
+  /**
+   * Gets the fully qualified name.
+   *
+   * @param item the item
+   * @return the fully qualified name
+   */
+  public String getFullyQualifiedName(TreeItem item) {
     String namespace = item.getText(NAMESPACE_COL);
     String name = item.getText(NAME_COL);
     return "".equals(namespace) ? name : namespace + "." + name;
   }
 
+  /**
+   * Gets the fully qualified name.
+   *
+   * @param namespace the namespace
+   * @param name the name
+   * @return the fully qualified name
+   */
   // used by dialog table -has different columns
   public String getFullyQualifiedName(String namespace, String name) {
     return (null == namespace || "".equals(namespace)) ? name : namespace + "." + name;
@@ -957,13 +1208,13 @@ public class CapabilitySection extends A
   /**
    * Given a current list of inputs/ outputs, made up of "Types" and "features", make a new list
    * keeping all the types, and keeping all the features that belong to other types, and adding the
-   * features that are passed in for one particular type in the "features" parameter
-   * 
-   * @param items
-   * @param type
-   *          A string representing the fully qualified type name
+   * features that are passed in for one particular type in the "features" parameter.
+   *
+   * @param items the items
+   * @param typeName the type name
    * @param features -
    *          associated with the type
+   * @return the type or feature[]
    */
   private TypeOrFeature[] replaceFeaturesKeepingTypes(TypeOrFeature[] items, String typeName,
           List features) {
@@ -982,12 +1233,12 @@ public class CapabilitySection extends A
   }
 
   /**
-   * 
-   * @param items
-   *          Existing array of TypeOrFeature items (input or output)
-   * @param typeName
-   * @param isAllFeatures
-   *          AllFeatures value
+   * Sets the all features.
+   *
+   * @param items          Existing array of TypeOrFeature items (input or output)
+   * @param typeName the type name
+   * @param isAllFeatures          AllFeatures value
+   * @return the type or feature[]
    */
   private TypeOrFeature[] setAllFeatures(TypeOrFeature[] items, String typeName,
           boolean isAllFeatures) {
@@ -1007,17 +1258,29 @@ public class CapabilitySection extends A
     return items;
   }
 
+  /**
+   * Finish action.
+   */
   private void finishAction() {
     setFileDirty();
   }
 
+  /**
+   * Pack 04.
+   */
   private void pack04() {
-    tt.getTable().getColumn(TITLE_COL).pack();
-    tt.getTable().getColumn(NAME_COL).pack();
-    tt.getTable().getColumn(NAMESPACE_COL).pack();
+    tt.getColumn(TITLE_COL).pack();
+    tt.getColumn(NAME_COL).pack();
+    tt.getColumn(NAMESPACE_COL).pack();
   }
 
-  private int getItemKind(TableTreeItem item) {
+  /**
+   * Gets the item kind.
+   *
+   * @param item the item
+   * @return the item kind
+   */
+  private int getItemKind(TreeItem item) {
     String itemID = item.getText(TITLE_COL);
 
     if (CAPABILITY_SET.equals(itemID))
@@ -1038,11 +1301,15 @@ public class CapabilitySection extends A
     throw new InternalErrorCDE("invalid state");
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable()
+   */
+  @Override
   public void enable() {
     addCapabilityButton.setEnabled(true);
 
     boolean selectOK = tt.getSelectionCount() == 1;
-    TableTreeItem item = selectOK ? tt.getSelection()[0] : null;
+    TreeItem item = selectOK ? tt.getSelection()[0] : null;
     int kind = selectOK ? getItemKind(item) : 0;
 
     addLangButton.setEnabled(selectOK);
@@ -1053,6 +1320,13 @@ public class CapabilitySection extends A
     removeButton.setEnabled((kind & (CS + SOFA_ITEM + LANG_ITEM + FEAT + TYPE)) > 0);
   }
 
+  /**
+   * Dialog for language.
+   *
+   * @param c the c
+   * @param dialog the dialog
+   * @return the int
+   */
   private int dialogForLanguage(Capability c, CommonInputDialog dialog) {
     for (;;) {
       if (dialog.open() == Window.CANCEL)
@@ -1077,10 +1351,16 @@ public class CapabilitySection extends A
     return Window.OK;
   }
 
-  private Capability getCapability(TableTreeItem item) {
+  /**
+   * Gets the capability.
+   *
+   * @param item the item
+   * @return the capability
+   */
+  private Capability getCapability(TreeItem item) {
     while (null != item.getParentItem())
       item = item.getParentItem();
-    return getCapabilityFromTableTreeItem(item);
+    return getCapabilityFromTreeItem(item);
   }
 
 }

Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java?rev=1863233&r1=1863232&r2=1863233&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java (original)
+++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java Wed Jul 17 18:58:38 2019
@@ -34,51 +34,80 @@ import org.apache.uima.taeconfigurator.w
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableTree;
 import org.eclipse.swt.custom.TableTreeItem;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.ui.forms.IManagedForm;
 
+
+/**
+ * The Class IndexSection.
+ */
 public class IndexSection extends AbstractSection {
 
+  /** The Constant ANNOTATION_INDEX_BUILT_IN. */
   public static final String ANNOTATION_INDEX_BUILT_IN = "Annotation Index (Built-in)";
 
+  /** The Constant INDEX_NAME_COL. */
   public final static int INDEX_NAME_COL = 0;
 
+  /** The Constant INDEX_TYPE_COL. */
   public final static int INDEX_TYPE_COL = 1;
 
+  /** The Constant ASC_DES_COL. */
   public final static int ASC_DES_COL = 1;
 
+  /** The Constant INDEX_KIND_COL. */
   public final static int INDEX_KIND_COL = 2;
 
-  public TableTree tt; // accessed by inner class
+  /** The tt. */
+  public Tree tt; // accessed by inner class
 
+  /** The add index button. */
   private Button addIndexButton;
 
+  /** The add key button. */
   private Button addKeyButton;
 
+  /** The edit button. */
   private Button editButton;
 
+  /** The remove button. */
   private Button removeButton;
 
+  /** The up button. */
   private Button upButton;
 
+  /** The down button. */
   private Button downButton;
 
+  /** The m built in index description. */
   FsIndexDescription m_builtInIndexDescription = null;
 
+  /** The export button. */
   private Button exportButton;
 
+  /** The index import section. */
   private IndexImportSection indexImportSection;
 
+  /**
+   * Instantiates a new index section.
+   *
+   * @param editor the editor
+   * @param parent the parent
+   */
   public IndexSection(MultiPageEditor editor, Composite parent) {
     super(editor, parent, "Indexes",
             "The following indexes are defined on the type system for this engine.");
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#initialize(org.eclipse.ui.forms.IManagedForm)
+   */
+  @Override
   public void initialize(IManagedForm form) {
     super.initialize(form);
 
@@ -86,13 +115,13 @@ public class IndexSection extends Abstra
     Composite sectionClient = new2ColumnComposite(getSection());
     enableBorders(sectionClient);
 
-    tt = newTableTree(sectionClient, SWT.SINGLE | SWT.FULL_SELECTION);
+    tt = newTree(sectionClient, SWT.SINGLE | SWT.FULL_SELECTION);
 
-    final Table table = tt.getTable();
-    table.setHeaderVisible(true);
-    newTableColumn(table).setText("Name");
-    newTableColumn(table).setText("Type");
-    newTableColumn(table).setText("Kind");
+//    final Table table = tt.getTable();
+    tt.setHeaderVisible(true);
+    newTreeColumn(tt).setText("Name");
+    newTreeColumn(tt).setText("Type");
+    newTreeColumn(tt).setText("Kind");
 
     final Composite buttonContainer = newButtonContainer(sectionClient);
     addIndexButton = newPushButton(buttonContainer, "Add Index", "Click here to add a new index.");
@@ -105,7 +134,7 @@ public class IndexSection extends Abstra
     exportButton = newPushButton(buttonContainer, S_EXPORT, S_EXPORT_TIP);
 
     // in addition to normal keyup and mouse up:
-    table.addListener(SWT.MouseHover, this);
+    tt.addListener(SWT.MouseHover, this);
 
     toolkit.paintBordersFor(sectionClient);
   }
@@ -115,6 +144,7 @@ public class IndexSection extends Abstra
    * 
    * @see org.eclipse.ui.forms.IFormPart#refresh()
    */
+  @Override
   public void refresh() {
     if (null == indexImportSection)
       indexImportSection = editor.getIndexesPage().getIndexImportSection();
@@ -122,20 +152,26 @@ public class IndexSection extends Abstra
     tt.removeAll();
 
     // add built-in annotation index
-    updateIndexSpec(new TableTreeItem(tt, SWT.NONE), getBuiltInIndexDescription());
+    updateIndexSpec(new TreeItem(tt, SWT.NONE), getBuiltInIndexDescription());
 
     FsIndexDescription[] fsIndexes = getAnalysisEngineMetaData().getFsIndexes();
 
     if (fsIndexes != null) {
       for (int i = 0; i < fsIndexes.length; i++) {
-        updateIndexSpec(new TableTreeItem(tt, SWT.NONE), fsIndexes[i]);
+        updateIndexSpec(new TreeItem(tt, SWT.NONE), fsIndexes[i]);
       }
     }
-    packTable(tt.getTable());
+    packTree(tt);
     enable();
   }
 
-  private void updateIndexSpec(TableTreeItem item, FsIndexDescription ndx) {
+  /**
+   * Update index spec.
+   *
+   * @param item the item
+   * @param ndx the ndx
+   */
+  private void updateIndexSpec(TreeItem item, FsIndexDescription ndx) {
     item.setText(INDEX_NAME_COL, ndx.getLabel());
     item.setText(INDEX_TYPE_COL, formatName(ndx.getTypeName()));
     item.setText(INDEX_KIND_COL, handleDefaultIndexKind(ndx.getKind()));
@@ -144,11 +180,17 @@ public class IndexSection extends Abstra
     FsIndexKeyDescription[] keys = ndx.getKeys();
     if (null != keys)
       for (int i = 0; i < keys.length; i++) {
-        updateKeySpec(new TableTreeItem(item, SWT.NONE), keys[i]);
+        updateKeySpec(new TreeItem(item, SWT.NONE), keys[i]);
       }
   }
 
-  private void updateKeySpec(TableTreeItem item, FsIndexKeyDescription key) {
+  /**
+   * Update key spec.
+   *
+   * @param item the item
+   * @param key the key
+   */
+  private void updateKeySpec(TreeItem item, FsIndexKeyDescription key) {
     String name = key.getFeatureName();
     item.setText(INDEX_NAME_COL, null == name ? "TYPE PRIORITY" : name);
     item.setText(ASC_DES_COL,
@@ -156,10 +198,20 @@ public class IndexSection extends Abstra
     item.setData(key);
   }
 
+  /**
+   * Creates the fs index key description.
+   *
+   * @return the fs index key description
+   */
   public FsIndexKeyDescription createFsIndexKeyDescription() {
     return UIMAFramework.getResourceSpecifierFactory().createFsIndexKeyDescription();
   }
 
+  /**
+   * Gets the built in index description.
+   *
+   * @return the built in index description
+   */
   public FsIndexDescription getBuiltInIndexDescription() {
     if (m_builtInIndexDescription == null) {
       m_builtInIndexDescription = UIMAFramework.getResourceSpecifierFactory()
@@ -184,6 +236,12 @@ public class IndexSection extends Abstra
     return m_builtInIndexDescription;
   }
 
+  /**
+   * Not allowed.
+   *
+   * @param message the message
+   * @return true, if successful
+   */
   private boolean notAllowed(String message) {
     if (isIndexDescriptor() && !editor.getIsContextLoaded()) {
       Utility
@@ -201,6 +259,7 @@ public class IndexSection extends Abstra
    * 
    * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
    */
+  @Override
   public void handleEvent(Event event) {
 
     if (event.widget == addIndexButton) {
@@ -221,15 +280,16 @@ public class IndexSection extends Abstra
 
       addFsIndexDescription(id);
 
-      updateIndexSpec(new TableTreeItem(tt, SWT.NONE), id);
+      updateIndexSpec(new TreeItem(tt, SWT.NONE), id);
 
-      tt.getTable().setSelection(tt.getTable().getItemCount() - 1);
-      packTable(tt.getTable());
+      TreeItem[] items = tt.getItems();
+      tt.setSelection(items[items.length - 1]);
+      packTree(tt);
       setFileDirty();
     } else if (event.widget == addKeyButton) {
       if (notAllowed("Adding an Index"))
         return;
-      TableTreeItem parent = tt.getSelection()[0];
+      TreeItem parent = tt.getSelection()[0];
       if (null != parent.getParentItem())
         parent = parent.getParentItem();
       if (foolingAroundWithAnnotationIndex(parent))
@@ -240,12 +300,12 @@ public class IndexSection extends Abstra
       FsIndexKeyDescription newKey = addOrEditIndexKey(dialog, null);
       if (null != newKey) {
         addFsIndexKeyDescription(fsid, newKey);
-        updateKeySpec(new TableTreeItem(parent, SWT.NONE), newKey);
+        updateKeySpec(new TreeItem(parent, SWT.NONE), newKey);
         parent.setExpanded(true);
         setFileDirty();
       }
     } else if (event.widget == removeButton) {
-      TableTreeItem item = tt.getSelection()[0];
+      TreeItem item = tt.getSelection()[0];
       if (foolingAroundWithAnnotationIndex(item))
         return;
       Object o = item.getData();
@@ -258,11 +318,13 @@ public class IndexSection extends Abstra
         if (Window.CANCEL == Utility.popOkCancel("Confirm Remove",
                 "Do you want to remove this key?", MessageDialog.WARNING))
           return;
-        TableTreeItem parent = item.getParentItem();
+        TreeItem parent = item.getParentItem();
         FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent);
         removeFsIndexKeyDescription(fsid, (FsIndexKeyDescription) o);
       }
-      tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
+      TreeItem selectionItem = tt.getSelection()[0];
+//      tt.setSelection(tt.getTable().getSelectionIndex() - 1);
+      tt.setSelection(tt.getItems()[tt.indexOf(selectionItem) - 1]);
       item.dispose();
       setFileDirty();
     } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
@@ -270,7 +332,7 @@ public class IndexSection extends Abstra
         return;
       if (tt.getSelectionCount() != 1)
         return;
-      TableTreeItem item = tt.getSelection()[0];
+      TreeItem item = tt.getSelection()[0];
       if (foolingAroundWithAnnotationIndex(item))
         return;
       Object o = item.getData();
@@ -289,14 +351,14 @@ public class IndexSection extends Abstra
         updateIndexSpec(item, fsid);
 
         if (valueChanged) {
-          packTable(tt.getTable());
+          packTree(tt);
           setFileDirty();
         }
       } else { // editing a key
         if (notAllowed("Adding an Index"))
           return;
         FsIndexKeyDescription key = (FsIndexKeyDescription) o;
-        TableTreeItem parent = item.getParentItem();
+        TreeItem parent = item.getParentItem();
         FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent);
         AddIndexKeyDialog dialog = new AddIndexKeyDialog(this, fsid.getTypeName(),
                 handleDefaultIndexKind(fsid.getKind()), getAlreadyUsedFeatures(fsid), key);
@@ -304,7 +366,7 @@ public class IndexSection extends Abstra
         addOrEditIndexKey(dialog, key);
         if (valueChanged) {
           updateKeySpec(item, key);
-          packTable(tt.getTable());
+          packTree(tt);
           setFileDirty();
         }
       }
@@ -315,7 +377,7 @@ public class IndexSection extends Abstra
     } else if (event.widget == downButton) {
       int i = getIndex(tt.getSelection()[0]);
 
-      TableTreeItem[] items = tt.getSelection()[0].getParentItem().getItems();
+      TreeItem[] items = tt.getSelection()[0].getParentItem().getItems();
       swapIndexKeys(items[i + 1], i + 1);
     } else if (event.widget == exportButton) {
       try {
@@ -328,7 +390,13 @@ public class IndexSection extends Abstra
     enable();
   }
 
-  private boolean foolingAroundWithAnnotationIndex(TableTreeItem item) {
+  /**
+   * Fooling around with annotation index.
+   *
+   * @param item the item
+   * @return true, if successful
+   */
+  private boolean foolingAroundWithAnnotationIndex(TreeItem item) {
     while (null != item.getParentItem())
       item = item.getParentItem();
 
@@ -341,6 +409,12 @@ public class IndexSection extends Abstra
     return false;
   }
 
+  /**
+   * Adds the fs index key description.
+   *
+   * @param fsid the fsid
+   * @param key the key
+   */
   public void addFsIndexKeyDescription(FsIndexDescription fsid, FsIndexKeyDescription key) {
     FsIndexKeyDescription[] prevKeys = fsid.getKeys();
     FsIndexKeyDescription[] newKeys = new FsIndexKeyDescription[prevKeys == null ? 1
@@ -351,6 +425,11 @@ public class IndexSection extends Abstra
     fsid.setKeys(newKeys);
   }
 
+  /**
+   * Adds the fs index description.
+   *
+   * @param fsid the fsid
+   */
   public void addFsIndexDescription(FsIndexDescription fsid) {
     FsIndexDescription[] oldFsIndexes = getAnalysisEngineMetaData().getFsIndexes();
     FsIndexDescription[] newFsIndexes = new FsIndexDescription[oldFsIndexes == null ? 1
@@ -361,19 +440,36 @@ public class IndexSection extends Abstra
     getAnalysisEngineMetaData().setFsIndexes(newFsIndexes);
   }
 
+  /**
+   * Removes the fs index description.
+   *
+   * @param fsid the fsid
+   */
   public void removeFsIndexDescription(FsIndexDescription fsid) {
     getAnalysisEngineMetaData().setFsIndexes(
             (FsIndexDescription[]) Utility.removeElementFromArray(getAnalysisEngineMetaData()
                     .getFsIndexes(), fsid, FsIndexDescription.class));
   }
 
+  /**
+   * Removes the fs index key description.
+   *
+   * @param fsid the fsid
+   * @param key the key
+   */
   public void removeFsIndexKeyDescription(FsIndexDescription fsid, FsIndexKeyDescription key) {
     fsid.setKeys((FsIndexKeyDescription[]) Utility.removeElementFromArray(fsid.getKeys(), key,
             FsIndexKeyDescription.class));
   }
 
-  public List getAlreadyUsedFeatures(FsIndexDescription ndx) {
-    List result = new ArrayList();
+  /**
+   * Gets the already used features.
+   *
+   * @param ndx the ndx
+   * @return the already used features
+   */
+  public List<String> getAlreadyUsedFeatures(FsIndexDescription ndx) {
+    List<String> result = new ArrayList<>();
     FsIndexKeyDescription[] items = ndx.getKeys();
     if (null == items)
       return result;
@@ -383,6 +479,13 @@ public class IndexSection extends Abstra
     return result;
   }
 
+  /**
+   * Adds the or edit index key.
+   *
+   * @param dialog the dialog
+   * @param key the key
+   * @return the fs index key description
+   */
   public FsIndexKeyDescription addOrEditIndexKey(AddIndexKeyDialog dialog, FsIndexKeyDescription key) {
     if (dialog.open() == Window.CANCEL) {
       return null;
@@ -401,9 +504,10 @@ public class IndexSection extends Abstra
   }
 
   /**
-   * This has to check the resolvedImports, mergedWithDelegates version of the fsindexes
-   * 
-   * @param indexLabel
+   * This has to check the resolvedImports, mergedWithDelegates version of the fsindexes.
+   *
+   * @param indexLabel the index label
+   * @return true, if is duplicate index label
    */
   public boolean isDuplicateIndexLabel(String indexLabel) {
     FsIndexDescription[] indexes = getAnalysisEngineMetaData().getFsIndexes();
@@ -418,10 +522,14 @@ public class IndexSection extends Abstra
     return false;
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable()
+   */
+  @Override
   public void enable() {
     boolean selected = tt.getSelectionCount() == 1;
-    TableTreeItem item = null;
-    TableTreeItem parent = null;
+    TreeItem item = null;
+    TreeItem parent = null;
     if (selected) {
       item = tt.getSelection()[0];
       parent = item.getParentItem();
@@ -441,8 +549,8 @@ public class IndexSection extends Abstra
     downButton.setEnabled(false);
     if (selected) {
       if (null != parent && notBuiltInSelected) {
-        TableTreeItem firstItem = parent.getItems()[0];
-        TableTreeItem lastItem = parent.getItems()[parent.getItems().length - 1];
+        TreeItem firstItem = parent.getItems()[0];
+        TreeItem lastItem = parent.getItems()[parent.getItems().length - 1];
         upButton.setEnabled(item != firstItem);
         downButton.setEnabled(item != lastItem);
       }