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 17:55:28 UTC
svn commit: r1863232 - in
/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui:
./ dialogs/
Author: schor
Date: Wed Jul 17 17:55:28 2019
New Revision: 1863232
URL: http://svn.apache.org/viewvc?rev=1863232&view=rev
Log:
[UIMA-6094] update Component Descriptor Editor (CDE) to stop using deprecated SWT class TableTree, which is now removed in Eclipse 2019-06.
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java
uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java Wed Jul 17 17:55:28 2019
@@ -27,6 +27,7 @@ import org.apache.uima.taeconfigurator.e
import org.apache.uima.taeconfigurator.model.BuiltInTypes;
import org.eclipse.swt.custom.TableTreeItem;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TreeItem;
/**
@@ -56,7 +57,7 @@ public abstract class AbstractImportable
* @return true, if is local item
*/
// ********************************
- protected boolean isLocalItem(TableTreeItem item) {
+ protected boolean isLocalItem(TreeItem item) {
return !item.getForeground().equals(editor.getFadeColor());
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java Wed Jul 17 17:55:28 2019
@@ -91,8 +91,6 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.PopupList;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
@@ -108,6 +106,7 @@ import org.eclipse.swt.widgets.TableColu
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.forms.AbstractFormPart;
@@ -734,11 +733,11 @@ implements Listener, StandardStrings {
* @return the tree
*/
protected Tree newTree(Composite parent) {
- Tree tree = toolkit.createTree(parent, SWT.SINGLE);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
- tree.addListener(SWT.Selection, this);
- tree.addListener(SWT.KeyUp, this);
- return tree;
+ Tree local_tree = toolkit.createTree(parent, SWT.SINGLE);
+ local_tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ local_tree.addListener(SWT.Selection, this);
+ local_tree.addListener(SWT.KeyUp, this);
+ return local_tree;
}
/**
@@ -774,19 +773,19 @@ implements Listener, StandardStrings {
}
/**
- * New table tree.
+ * New tree.
*
* @param parent the parent
* @param style SWT.SINGLE SWT.MULTI SWT.CHECK SWT.FULL_SELECTION
* @return the TableTree
*/
- protected TableTree newTableTree(Composite parent, int style) {
- TableTree tt = new TableTree(parent, style);
+ protected Tree newTree(Composite parent, int style) {
+ Tree tt = new Tree(parent, style);
tt.setLayoutData(new GridData(GridData.FILL_BOTH));
toolkit.adapt(tt, true, true);
tt.addListener(SWT.Selection, this);
- tt.getTable().addListener(SWT.KeyUp, this); // for delete key
- tt.getTable().addListener(SWT.MouseDoubleClick, this); // for edit
+ tt.addListener(SWT.KeyUp, this); // for delete key
+ tt.addListener(SWT.MouseDoubleClick, this); // for edit
tt.addListener(SWT.Expand, this);
tt.addListener(SWT.Collapse, this);
@@ -808,6 +807,19 @@ implements Listener, StandardStrings {
}
}
+
+ /**
+ * Pack tree.
+ *
+ * @param table the table
+ */
+ public void packTree(Tree p_tree) {
+ TreeColumn[] columns = p_tree.getColumns();
+ for (int i = 0; i < columns.length; i++) {
+ columns[i].pack();
+ }
+ }
+
/**
* Gets the index.
*
@@ -830,9 +842,9 @@ implements Listener, StandardStrings {
* @param item the item
* @return the index
*/
- public static int getIndex(TableTreeItem item) {
- TableTreeItem parent = item.getParentItem();
- TableTreeItem[] items = (null == parent) ? item.getParent().getItems() : parent.getItems();
+ public static int getIndex(TreeItem item) {
+ TreeItem parent = item.getParentItem();
+ TreeItem[] items = (null == parent) ? item.getParent().getItems() : parent.getItems();
for (int i = items.length - 1; i >= 0; i--) {
if (items[i] == item)
return i;
@@ -840,18 +852,18 @@ implements Listener, StandardStrings {
throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$
}
- /**
- * Removes the children.
- *
- * @param item the item
- */
- protected void removeChildren(TableTreeItem item) {
- TableTreeItem[] items = item.getItems();
- if (null != items)
- for (int i = 0; i < items.length; i++) {
- items[i].dispose();
- }
- }
+// /**
+// * Removes the children.
+// *
+// * @param item the item
+// */
+// protected void removeChildren(TreeItem item) {
+// TreeItem[] items = item.getItems();
+// if (null != items)
+// for (int i = 0; i < items.length; i++) {
+// items[i].dispose();
+// }
+// }
/**
* Removes the children.
@@ -878,6 +890,18 @@ implements Listener, StandardStrings {
protected TableColumn newTableColumn(Table table) {
return newTableColumn(table, ""); //$NON-NLS-1$
}
+
+ /**
+ * New tree column.
+ *
+ * @param p_tree the tree
+ * @return the tree column
+ */
+ // **********************************
+ protected TreeColumn newTreeColumn(Tree p_tree) {
+ return newTreeColumn(p_tree, ""); //$NON-NLS-1$
+ }
+
/**
* New table column.
@@ -889,6 +913,18 @@ implements Listener, StandardStrings {
protected TableColumn newTableColumn(Table container, String header) {
return newTableColumn(container, 50, SWT.LEFT, header);
}
+
+ /**
+ * New tree column.
+ *
+ * @param container the container
+ * @param header the header
+ * @return the tree column
+ */
+ protected TreeColumn newTreeColumn(Tree container, String header) {
+ return newTreeColumn(container, 50, SWT.LEFT, header);
+ }
+
/**
* New table column.
@@ -907,6 +943,25 @@ implements Listener, StandardStrings {
tc.setWidth(width);
return tc;
}
+
+ /**
+ * New tree column.
+ *
+ * @param container the container
+ * @param width the width
+ * @param alignment the alignment
+ * @param header the header
+ * @return the tree column
+ */
+ protected TreeColumn newTreeColumn(Tree container, int width, int alignment, String header) {
+ TreeColumn tc = new TreeColumn(container, alignment);
+ if (header != null && (!header.equals(""))) { //$NON-NLS-1$
+ tc.setText(header);
+ }
+ tc.setWidth(width);
+ return tc;
+ }
+
/**
* New table column.
@@ -919,6 +974,17 @@ implements Listener, StandardStrings {
return newTableColumn(container, width, SWT.LEFT, Messages.getString("AbstractSection.0")); //$NON-NLS-1$
}
+ /**
+ * New tree column.
+ *
+ * @param container the container
+ * @param width the width
+ * @return the tree column
+ */
+ protected TreeColumn newTreeColumn(Tree container, int width) {
+ return newTreeColumn(container, width, SWT.LEFT, Messages.getString("AbstractSection.0")); //$NON-NLS-1$
+ }
+
// **************************************************
// * Model Access
// **************************************************
@@ -1715,24 +1781,24 @@ implements Listener, StandardStrings {
}
/**
- * Swap table tree items.
+ * Swap tree items.
*
* @param itemBelow the item below
* @param newSelection the new selection
*/
- public static void swapTableTreeItems(TableTreeItem itemBelow, int newSelection) {
- TableTreeItem parent = itemBelow.getParentItem();
+ public static void swapTreeItems(TreeItem itemBelow, int newSelection) {
+ TreeItem parent = itemBelow.getParentItem();
if (null == parent)
throw new InternalErrorCDE("invalid arg");
int i = getIndex(itemBelow);
- TableTreeItem itemAbove = parent.getItems()[i - 1];
- TableTreeItem newItemAbove = new TableTreeItem(parent, SWT.NONE, i - 1);
- copyTableTreeItem(newItemAbove, itemBelow);
- TableTreeItem newItemBelow = new TableTreeItem(parent, SWT.NONE, i);
- copyTableTreeItem(newItemBelow, itemAbove);
+ TreeItem itemAbove = parent.getItems()[i - 1];
+ TreeItem newItemAbove = new TreeItem(parent, SWT.NONE, i - 1);
+ copyTreeItem(newItemAbove, itemBelow);
+ TreeItem newItemBelow = new TreeItem(parent, SWT.NONE, i);
+ copyTreeItem(newItemBelow, itemAbove);
itemAbove.dispose();
itemBelow.dispose();
- parent.getParent().setSelection(new TableTreeItem[] { parent.getItems()[newSelection] });
+ parent.getParent().setSelection(new TreeItem[] { parent.getItems()[newSelection] });
}
/**
@@ -1741,8 +1807,8 @@ implements Listener, StandardStrings {
* @param target the target
* @param source the source
*/
- public static void copyTableTreeItem(TableTreeItem target, TableTreeItem source) {
- int columnCount = target.getParent().getTable().getColumnCount();
+ public static void copyTreeItem(TreeItem target, TreeItem source) {
+ int columnCount = target.getParent().getColumnCount();
for (int i = 0; i < columnCount; i++) {
String text = source.getText(i);
if (null != text)
@@ -1757,8 +1823,8 @@ implements Listener, StandardStrings {
* @param itemBelow the item below
* @param newSelection the new selection
*/
- public static void swapIndexKeys(TableTreeItem itemBelow, int newSelection) {
- TableTreeItem parent = itemBelow.getParentItem();
+ public static void swapIndexKeys(TreeItem itemBelow, int newSelection) {
+ TreeItem parent = itemBelow.getParentItem();
FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent);
int i = getIndex(itemBelow);
FsIndexKeyDescription[] keys = fsid.getKeys();
@@ -1767,7 +1833,7 @@ implements Listener, StandardStrings {
keys[i - 1] = temp;
// swap items in the GUI
- swapTableTreeItems(itemBelow, newSelection);
+ swapTreeItems(itemBelow, newSelection);
}
/**
@@ -1811,7 +1877,7 @@ implements Listener, StandardStrings {
* @param item the item
* @return the fs index description from table tree item
*/
- public static FsIndexDescription getFsIndexDescriptionFromTableTreeItem(TableTreeItem item) {
+ public static FsIndexDescription getFsIndexDescriptionFromTableTreeItem(TreeItem item) {
return (FsIndexDescription) item.getData();
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java Wed Jul 17 17:55:28 2019
@@ -44,7 +44,6 @@ import org.apache.uima.taeconfigurator.e
import org.apache.uima.taeconfigurator.files.MultiResourceSelectionDialogWithFlowOption;
import org.apache.uima.taeconfigurator.model.FlowNodes;
import org.apache.uima.util.XMLizable;
-import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java Wed Jul 17 17:55:28 2019
@@ -41,13 +41,14 @@ 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;
@@ -129,7 +130,7 @@ public class CapabilitySection extends A
public final static int NAMESPACE_COL = 4;
/** The tt. */
- TableTree tt; // for inner class access
+ Tree tt; // for inner class access
/** The add capability button. */
private Button addCapabilityButton;
@@ -183,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);
@@ -231,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);
@@ -246,7 +247,7 @@ public class CapabilitySection extends A
// }
}
}
- packTable(tt.getTable());
+ packTree(tt);
enable();
tt.getParent().setRedraw(true);
}
@@ -287,8 +288,8 @@ public class CapabilitySection extends A
* @param parent the parent
* @return the table tree item
*/
- private TableTreeItem createLanguageHeaderGui(TableTreeItem parent) {
- TableTreeItem langHdr = new TableTreeItem(parent, SWT.NONE);
+ private TreeItem createLanguageHeaderGui(TreeItem parent) {
+ TreeItem langHdr = new TreeItem(parent, SWT.NONE);
langHdr.setText(TITLE_COL, LANGS_TITLE);
langHdr.setData(LANGS_TITLE);
return langHdr;
@@ -300,8 +301,8 @@ public class CapabilitySection extends A
* @param parent the parent
* @return the table tree item
*/
- private TableTreeItem createSofaHeaderGui(TableTreeItem parent) {
- TableTreeItem sofaHdr = new TableTreeItem(parent, SWT.NONE);
+ private TreeItem createSofaHeaderGui(TreeItem parent) {
+ TreeItem sofaHdr = new TreeItem(parent, SWT.NONE);
sofaHdr.setText(TITLE_COL, SOFAS_TITLE);
sofaHdr.setData(SOFAS_TITLE);
return sofaHdr;
@@ -313,30 +314,30 @@ public class CapabilitySection extends A
* @param parent the parent
* @param c the c
*/
- private void fillCapability(TableTreeItem parent, Capability 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);
}
@@ -394,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);
@@ -406,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)
@@ -424,7 +425,7 @@ public class CapabilitySection extends A
* @param item the item
* @param typeName the type name
*/
- private void setGuiTypeName(TableTreeItem item, String typeName) {
+ 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));
@@ -437,7 +438,7 @@ public class CapabilitySection extends A
* @param sofaName the sofa name
* @param isInput the is input
*/
- private void setGuiSofaName(TableTreeItem item, String sofaName, boolean isInput) {
+ private void setGuiSofaName(TreeItem item, String sofaName, boolean isInput) {
item.setData(SOFA_TITLE);
item.setText(NAME_COL, sofaName);
if (isInput) {
@@ -505,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) {
@@ -519,7 +520,7 @@ 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);
}
@@ -533,16 +534,16 @@ public class CapabilitySection extends A
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();
}
@@ -554,10 +555,10 @@ public class CapabilitySection extends A
* @param inOrOut the in or out
* @return the or create all feat item
*/
- private void getOrCreateAllFeatItem(TableTreeItem editItem, int column, String inOrOut) {
- TableTreeItem allFeatItem = getAllFeatItem(editItem);
+ 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);
}
@@ -570,11 +571,11 @@ public class CapabilitySection extends A
* @param editItem the edit item
* @return the all feat item
*/
- private TableTreeItem getAllFeatItem(TableTreeItem editItem) {
- TableTreeItem[] subItems = editItem.getItems();
+ 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;
@@ -586,8 +587,8 @@ public class CapabilitySection extends A
* @param editItem the edit item
* @param column the column
*/
- private void removeAllFeatItemGui(TableTreeItem editItem, int column) {
- TableTreeItem allFeatItem = getAllFeatItem(editItem);
+ 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
@@ -603,7 +604,7 @@ public class CapabilitySection extends A
* @param editItem the edit item
* @param itemKind the item kind
*/
- private void handleEdit(TableTreeItem editItem, int itemKind) {
+ private void handleEdit(TreeItem editItem, int itemKind) {
Capability c = getCapability(editItem);
switch (itemKind) {
case SOFA_ITEM: {
@@ -724,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
@@ -767,16 +768,18 @@ public class CapabilitySection extends A
* @param removeItem the remove item
* @param itemKind the item kind
*/
- private void handleRemove(TableTreeItem removeItem, int itemKind) {
- Table table = tt.getTable();
- int previousSelection = table.getSelectionIndex() - 1;
+ 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);
@@ -795,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);
@@ -831,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]);
@@ -856,7 +859,7 @@ public class CapabilitySection extends A
throw new InternalErrorCDE("invalid state");
}
- table.setSelection(previousSelection);
+ tt.setSelection(tt.getItems()[previousSelection]);
finishAction();
}
@@ -881,7 +884,7 @@ public class CapabilitySection extends A
* @param item the item
* @return true, if is input
*/
- private boolean isInput(TableTreeItem item) {
+ private boolean isInput(TreeItem item) {
return INPUT.equals(item.getText(INPUT_COL)); // works if getText() returns null
}
@@ -891,7 +894,7 @@ public class CapabilitySection extends A
* @param item the item
* @return true, if is output
*/
- private boolean isOutput(TableTreeItem item) {
+ private boolean isOutput(TreeItem item) {
return OUTPUT.equals(item.getText(OUTPUT_COL));
}
@@ -923,7 +926,7 @@ public class CapabilitySection extends A
* @param c the c
* @param removeItem the remove item
*/
- private void removeFeature(Capability c, TableTreeItem removeItem) {
+ private void removeFeature(Capability c, TreeItem removeItem) {
String shortFeatureName = removeItem.getText(NAME_COL);
if (shortFeatureName.equals(ALL_FEATURES)) {
if (isInput(removeItem)) {
@@ -953,7 +956,7 @@ public class CapabilitySection extends A
* @param item the item
* @return the capability from table tree item
*/
- public Capability getCapabilityFromTableTreeItem(TableTreeItem item) {
+ public Capability getCapabilityFromTreeItem(TreeItem item) {
return (Capability) item.getData();
}
@@ -963,7 +966,7 @@ public class CapabilitySection extends A
* @param selItem the sel item
* @param itemKind the item kind
*/
- private void handleAddLang(TableTreeItem selItem, int itemKind) {
+ 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)
@@ -972,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",
@@ -984,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);
@@ -998,12 +1001,12 @@ public class CapabilitySection extends A
* @param selItem the sel item
* @param itemKind the item kind
*/
- private void handleAddType(TableTreeItem selItem, int itemKind) {
+ 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;
@@ -1016,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 : "");
@@ -1040,7 +1043,7 @@ public class CapabilitySection extends A
* @param selItem the sel item
* @param itemKind the item kind
*/
- private void handleAddSofa(TableTreeItem selItem, int itemKind) {
+ private void handleAddSofa(TreeItem selItem, int itemKind) {
if (itemKind == CS)
selItem = selItem.getItems()[1];
else if (itemKind == LANG || itemKind == TYPE)
@@ -1048,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;
@@ -1059,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();
@@ -1074,11 +1077,11 @@ public class CapabilitySection extends A
* @param selItem the sel item
* @param itemKind the item kind
*/
- private void handleAddEditFeature(TableTreeItem selItem, int itemKind) {
+ 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
@@ -1101,7 +1104,7 @@ public class CapabilitySection extends A
*/
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
@@ -1125,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 : "");
@@ -1149,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));
@@ -1184,7 +1187,7 @@ public class CapabilitySection extends A
* @param item the item
* @return the fully qualified name
*/
- public String getFullyQualifiedName(TableTreeItem item) {
+ public String getFullyQualifiedName(TreeItem item) {
String namespace = item.getText(NAMESPACE_COL);
String name = item.getText(NAME_COL);
return "".equals(namespace) ? name : namespace + "." + name;
@@ -1266,9 +1269,9 @@ public class CapabilitySection extends A
* 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();
}
/**
@@ -1277,7 +1280,7 @@ public class CapabilitySection extends A
* @param item the item
* @return the item kind
*/
- private int getItemKind(TableTreeItem item) {
+ private int getItemKind(TreeItem item) {
String itemID = item.getText(TITLE_COL);
if (CAPABILITY_SET.equals(itemID))
@@ -1306,7 +1309,7 @@ public class CapabilitySection extends A
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);
@@ -1354,10 +1357,10 @@ public class CapabilitySection extends A
* @param item the item
* @return the capability
*/
- private Capability getCapability(TableTreeItem item) {
+ private Capability getCapability(TreeItem item) {
while (null != item.getParentItem())
item = item.getParentItem();
- return getCapabilityFromTableTreeItem(item);
+ return getCapabilityFromTreeItem(item);
}
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java Wed Jul 17 17:55:28 2019
@@ -34,12 +34,12 @@ 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;
@@ -64,7 +64,7 @@ public class IndexSection extends Abstra
public final static int INDEX_KIND_COL = 2;
/** The tt. */
- public TableTree tt; // accessed by inner class
+ public Tree tt; // accessed by inner class
/** The add index button. */
private Button addIndexButton;
@@ -115,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.");
@@ -134,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);
}
@@ -152,16 +152,16 @@ 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();
}
@@ -171,7 +171,7 @@ public class IndexSection extends Abstra
* @param item the item
* @param ndx the ndx
*/
- private void updateIndexSpec(TableTreeItem item, FsIndexDescription 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()));
@@ -180,7 +180,7 @@ 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]);
}
}
@@ -190,7 +190,7 @@ public class IndexSection extends Abstra
* @param item the item
* @param key the key
*/
- private void updateKeySpec(TableTreeItem item, FsIndexKeyDescription 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,
@@ -280,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))
@@ -299,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();
@@ -317,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) {
@@ -329,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();
@@ -348,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);
@@ -363,7 +366,7 @@ public class IndexSection extends Abstra
addOrEditIndexKey(dialog, key);
if (valueChanged) {
updateKeySpec(item, key);
- packTable(tt.getTable());
+ packTree(tt);
setFileDirty();
}
}
@@ -374,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 {
@@ -393,7 +396,7 @@ public class IndexSection extends Abstra
* @param item the item
* @return true, if successful
*/
- private boolean foolingAroundWithAnnotationIndex(TableTreeItem item) {
+ private boolean foolingAroundWithAnnotationIndex(TreeItem item) {
while (null != item.getParentItem())
item = item.getParentItem();
@@ -465,8 +468,8 @@ public class IndexSection extends Abstra
* @param ndx the ndx
* @return the already used features
*/
- public List getAlreadyUsedFeatures(FsIndexDescription ndx) {
- List result = new ArrayList();
+ public List<String> getAlreadyUsedFeatures(FsIndexDescription ndx) {
+ List<String> result = new ArrayList<>();
FsIndexKeyDescription[] items = ndx.getKeys();
if (null == items)
return result;
@@ -525,8 +528,8 @@ public class IndexSection extends Abstra
@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();
@@ -546,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);
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java Wed Jul 17 17:55:28 2019
@@ -70,13 +70,13 @@ 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.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
-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;
@@ -115,7 +115,7 @@ public class TypeSection extends Abstrac
public static final String HEADER_ALLOWED_VALUE = "Allowed Value:";
/** The tt. */
- private TableTree tt;
+ private Tree tt;
/** The add type button. */
private Button addTypeButton;
@@ -172,14 +172,14 @@ public class TypeSection extends Abstrac
enableBorders(sectionClient);
toolkit.paintBordersFor(sectionClient);
- tt = newTableTree(sectionClient, SWT.SINGLE | SWT.FULL_SELECTION);
- new TableColumn(tt.getTable(), SWT.NONE).setText("Type Name or Feature Name");
- new TableColumn(tt.getTable(), SWT.NONE).setText("SuperType or Range");
- new TableColumn(tt.getTable(), SWT.NONE).setText(" "); // space for icon
- new TableColumn(tt.getTable(), SWT.NONE).setText("Element Type");
- tt.getTable().setHeaderVisible(true);
+ tt = newTree(sectionClient, SWT.SINGLE | SWT.FULL_SELECTION);
+ new TreeColumn(tt, SWT.NONE).setText("Type Name or Feature Name");
+ new TreeColumn(tt, SWT.NONE).setText("SuperType or Range");
+ new TreeColumn(tt, SWT.NONE).setText(" "); // space for icon
+ new TreeColumn(tt, SWT.NONE).setText("Element Type");
+ tt.setHeaderVisible(true);
- tt.getTable().addListener(SWT.MouseHover, this); // to show description and more
+ tt.addListener(SWT.MouseHover, this); // to show description and more
Composite buttonContainer = newButtonContainer(sectionClient);
addTypeButton = newPushButton(buttonContainer, "Add Type", "Click here to add a new type.");
@@ -220,8 +220,8 @@ public class TypeSection extends Abstrac
}
if (tt.getItemCount() > 0)
- tt.setSelection(new TableTreeItem[] { tt.getItems()[0] });
- packTable(tt.getTable());
+ tt.setSelection(tt.getItems()[0]);
+ packTree(tt);
enable();
}
@@ -237,7 +237,7 @@ public class TypeSection extends Abstrac
return featureDescriptionArray0;
if (null == subset)
return all;
- List result = new ArrayList();
+ List<FeatureDescription> result = new ArrayList<>();
outer: for (int i = 0; i < all.length; i++) {
String name = all[i].getName();
@@ -256,7 +256,7 @@ public class TypeSection extends Abstrac
* @param td the td
*/
private void addTypeToGUI(TypeDescription td) {
- TableTreeItem item = new TableTreeItem(tt, SWT.NONE);
+ TreeItem item = new TreeItem(tt, SWT.NONE);
item.setText(NAME_COL, formatName(td.getName()));
item.setText(SUPER_COL, formatName(td.getSupertypeName()));
item.setData(td);
@@ -275,7 +275,7 @@ public class TypeSection extends Abstrac
AllowedValue[] avs = td.getAllowedValues();
if (null != avs) {
for (int i = 0; i < avs.length; i++) {
- TableTreeItem avItem = new TableTreeItem(item, SWT.NONE);
+ TreeItem avItem = new TreeItem(item, SWT.NONE);
avItem.setText(NAME_COL, HEADER_ALLOWED_VALUE);
avItem.setText(AV_COL, convertNull(avs[i].getString()));
avItem.setData(avs[i]);
@@ -293,11 +293,11 @@ public class TypeSection extends Abstrac
* @param item the item
* @param features the features
*/
- private void addFeaturesToGui(TypeDescription td, TableTreeItem item,
+ private void addFeaturesToGui(TypeDescription td, TreeItem item,
FeatureDescription[] features) {
if (null != features) {
for (int i = 0; i < features.length; i++) {
- TableTreeItem fItem = new TableTreeItem(item, SWT.NONE);
+ TreeItem fItem = new TreeItem(item, SWT.NONE);
updateGuiFeature(fItem, features[i], td);
}
}
@@ -310,7 +310,7 @@ public class TypeSection extends Abstrac
* @param fd the fd
* @param td the td
*/
- private void updateGuiFeature(TableTreeItem fItem, FeatureDescription fd, TypeDescription td) {
+ private void updateGuiFeature(TreeItem fItem, FeatureDescription fd, TypeDescription td) {
String rangeType;
fItem.setText(NAME_COL, fd.getName());
fItem.setText(RANGE_COL, formatName(rangeType = fd.getRangeTypeName()));
@@ -338,7 +338,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @param isLocal the is local
*/
- private void setItemColor(TableTreeItem item, boolean isLocal) {
+ private void setItemColor(TreeItem item, boolean isLocal) {
if (isLocal)
return;
item.setForeground(editor.getFadeColor());
@@ -354,7 +354,7 @@ public class TypeSection extends Abstrac
if (event.widget == addTypeButton) {
handleAddType();
} else if (event.widget == addButton) {
- TableTreeItem parent = tt.getSelection()[0];
+ TreeItem parent = tt.getSelection()[0];
if (null != parent.getParentItem())
parent = parent.getParentItem();
@@ -391,7 +391,7 @@ public class TypeSection extends Abstrac
*/
public void handleHover(Event event) {
// next getItem call requires that table have SWT.FULL_SELECTION Style
- TableTreeItem item = tt.getItem(new Point(event.x, event.y));
+ TreeItem item = tt.getItem(new Point(event.x, event.y));
if (null != item) {
Object o = item.getData();
if (null == o)
@@ -421,7 +421,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @return the type description from table tree item
*/
- public TypeDescription getTypeDescriptionFromTableTreeItem(TableTreeItem item) {
+ public TypeDescription getTypeDescriptionFromTableTreeItem(TreeItem item) {
return (TypeDescription) item.getData();
}
@@ -431,7 +431,7 @@ public class TypeSection extends Abstrac
* @param parent the parent
*/
// disabled unless type having String as supertype is selected
- public void handleAddAllowedValue(TableTreeItem parent) {
+ public void handleAddAllowedValue(TreeItem parent) {
boolean refreshNeeded = false;
TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
@@ -456,7 +456,7 @@ public class TypeSection extends Abstrac
if (refreshNeeded)
refresh();
else {
- TableTreeItem item = new TableTreeItem(parent, SWT.NONE);
+ TreeItem item = new TreeItem(parent, SWT.NONE);
item.setText(NAME_COL, HEADER_ALLOWED_VALUE);
item.setText(AV_COL, convertNull(av.getString()));
item.setData(av);
@@ -497,7 +497,7 @@ public class TypeSection extends Abstrac
* @param parent the parent
*/
// disabled unless type is selected
- public void handleAddFeature(TableTreeItem parent) {
+ public void handleAddFeature(TreeItem parent) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
// guaranteed non-null - otherwise add button disabled
@@ -532,7 +532,7 @@ public class TypeSection extends Abstrac
} else {
fd = td.addFeature(null, null, null);
featureUpdate(fd, dialog);
- TableTreeItem item = new TableTreeItem(parent, SWT.NONE);
+ TreeItem item = new TreeItem(parent, SWT.NONE);
updateGuiFeature(item, fd, td);
parent.setExpanded(true);
finishActionPack();
@@ -545,10 +545,10 @@ public class TypeSection extends Abstrac
* @param td the td
*/
private void selectTypeInGui(TypeDescription td) {
- TableTreeItem[] items = tt.getItems();
+ TreeItem[] items = tt.getItems();
for (int i = 0; i < items.length; i++) {
if (td.getName().equals(((TypeDescription) items[i].getData()).getName())) {
- tt.setSelection(new TableTreeItem[] { items[i] });
+ tt.setSelection(new TreeItem[] { items[i] });
return;
}
}
@@ -629,7 +629,7 @@ public class TypeSection extends Abstrac
* Finish action pack.
*/
private void finishActionPack() {
- packTable(tt.getTable());
+ packTree(tt);
finishAction();
}
@@ -649,8 +649,8 @@ public class TypeSection extends Abstrac
* Handle edit.
*/
private void handleEdit() {
- TableTreeItem item = tt.getSelection()[0];
- TableTreeItem parentType = item.getParentItem();
+ TreeItem item = tt.getSelection()[0];
+ TreeItem parentType = item.getParentItem();
if (null == parentType) { // editing a type, not a feature
editType(item);
@@ -667,7 +667,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @return the feature description from table tree item
*/
- public FeatureDescription getFeatureDescriptionFromTableTreeItem(TableTreeItem item) {
+ public FeatureDescription getFeatureDescriptionFromTableTreeItem(TreeItem item) {
return (FeatureDescription) item.getData();
}
@@ -677,7 +677,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @param parent the parent
*/
- private void editFeature(TableTreeItem item, TableTreeItem parent) {
+ private void editFeature(TreeItem item, TreeItem parent) {
boolean remergeNeeded = false;
boolean refreshNeeded = false;
TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
@@ -743,7 +743,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @return the allowed value from table tree item
*/
- public AllowedValue getAllowedValueFromTableTreeItem(TableTreeItem item) {
+ public AllowedValue getAllowedValueFromTableTreeItem(TreeItem item) {
return (AllowedValue) item.getData();
}
@@ -753,7 +753,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @param parent the parent
*/
- private void editAllowedValue(TableTreeItem item, TableTreeItem parent) {
+ private void editAllowedValue(TreeItem item, TreeItem parent) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
AllowedValue av = getAllowedValueFromTableTreeItem(item);
@@ -854,7 +854,7 @@ public class TypeSection extends Abstrac
* @param item the item
*/
// type is always local; could be merging with import(s) or built-in
- private void editType(TableTreeItem item) {
+ private void editType(TreeItem item) {
boolean mergeAndRefreshNeeded = false;
boolean refreshNeeded = false;
@@ -933,7 +933,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @param td the td
*/
- private void updateGuiType(TableTreeItem item, TypeDescription td) {
+ private void updateGuiType(TreeItem item, TypeDescription td) {
item.setText(NAME_COL, formatName(td.getName()));
item.setText(SUPER_COL, formatName(td.getSupertypeName()));
}
@@ -984,8 +984,8 @@ public class TypeSection extends Abstrac
* Note that the Remove action is disabled if the item selected is imported only
*/
private void handleRemove() {
- TableTreeItem item = tt.getSelection()[0];
- TableTreeItem parent = item.getParentItem();
+ TreeItem item = tt.getSelection()[0];
+ TreeItem parent = item.getParentItem();
if (null == parent)
handleRemoveType(item);
@@ -1000,7 +1000,7 @@ public class TypeSection extends Abstrac
*
* @param item the item
*/
- private void handleRemoveAllowedValue(TableTreeItem item) {
+ private void handleRemoveAllowedValue(TreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
AllowedValue av = getAllowedValueFromTableTreeItem(item);
// guaranteed non-null -otherwise remove button disabled
@@ -1009,7 +1009,9 @@ public class TypeSection extends Abstrac
removeAllowedValue(td, av);
// update GUI
- tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
+ TreeItem selectedItem = tt.getSelection()[0];
+ tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]);
+// tt.setSelection(tt.getTable().getSelectionIndex() - 1);
item.dispose();
} else {
refresh();
@@ -1026,7 +1028,7 @@ public class TypeSection extends Abstrac
* @param item the item
*/
// same - for built-in <could be created outside of the CDE>
- private void handleRemoveFeature(TableTreeItem item) {
+ private void handleRemoveFeature(TreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
FeatureDescription fd = getFeatureDescriptionFromTableTreeItem(item);
@@ -1053,7 +1055,9 @@ public class TypeSection extends Abstrac
refresh();
else {
// update GUI
- tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
+ TreeItem selectedItem = tt.getSelection()[0];
+ tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]);
+// tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
item.dispose();
}
}
@@ -1152,7 +1156,7 @@ public class TypeSection extends Abstrac
*
* @param item the item
*/
- private void handleRemoveType(TableTreeItem item) {
+ private void handleRemoveType(TreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item);
@@ -1186,7 +1190,9 @@ public class TypeSection extends Abstrac
} else {
removeType(td, getMergedTypeSystemDescription());
// update GUI
- tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
+ TreeItem selectedItem = tt.getSelection()[0];
+ tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]);
+// tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1);
item.dispose();
}
@@ -1351,7 +1357,7 @@ public class TypeSection extends Abstrac
* @param item the item
* @return true, if is subtype of string
*/
- private boolean isSubtypeOfString(TableTreeItem item) {
+ private boolean isSubtypeOfString(TreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item);
return CAS.TYPE_NAME_STRING.equals(td.getSupertypeName());
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java Wed Jul 17 17:55:28 2019
@@ -46,9 +46,9 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
/**
@@ -411,6 +411,8 @@ public abstract class AbstractDialog ext
Tree tree = new Tree(parent, style | SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH);
tree.setLayoutData(gd);
+ tree.addListener(SWT.Selection, this);
+ tree.addListener(SWT.KeyUp, this); // delete key
return tree;
}
@@ -437,7 +439,7 @@ public abstract class AbstractDialog ext
* @param p the p
* @return the hit column
*/
- public int getHitColumn(TableItem item, Point p) {
+ public int getHitColumn(TreeItem item, Point p) {
for (int i = item.getParent().getColumnCount() - 1; i >= 0; i--) {
Rectangle columnBounds = item.getBounds(i);
if (columnBounds.contains(p))
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java Wed Jul 17 17:55:28 2019
@@ -25,6 +25,8 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
import org.apache.uima.taeconfigurator.editors.ui.AbstractSection;
@@ -53,7 +55,7 @@ public abstract class AbstractDialogMult
protected static final String UNCHECKED = "";
/** The table. */
- Table table;
+ Tree f_tree;
/** The enable col 1. */
protected boolean enableCol1 = true;
@@ -80,9 +82,9 @@ public abstract class AbstractDialogMult
*/
@Override
public void handleEvent(Event event) {
- if (event.type == SWT.MouseDown && event.widget == table) {
+ if (event.type == SWT.MouseDown && event.widget == f_tree) {
Point mousePosition = new Point(event.x, event.y);
- TableItem item = table.getItem(mousePosition);
+ TreeItem item = f_tree.getItem(mousePosition);
if (null == item) {
jitHowTo(event.widget);
return;
@@ -132,6 +134,22 @@ public abstract class AbstractDialogMult
else
numberChecked--;
}
+
+ /**
+ * Toggle value.
+ *
+ * @param item the item
+ * @param col the col
+ */
+ protected void toggleValue(TreeItem item, int col) {
+ item.setText(col, item.getText(col).equals(checkedIndicator(col)) ? UNCHECKED
+ : checkedIndicator(col));
+ if (item.getText(col).equals(checkedIndicator(col)))
+ numberChecked++;
+ else
+ numberChecked--;
+ }
+
/* (non-Javadoc)
* @see org.apache.uima.taeconfigurator.editors.ui.dialogs.AbstractDialog#isValid()
@@ -165,4 +183,21 @@ public abstract class AbstractDialogMult
else if (!value && prevChecked)
numberChecked--;
}
+
+ /**
+ * Sets the checked.
+ *
+ * @param item the item
+ * @param col the col
+ * @param value the value
+ */
+ protected void setChecked(TreeItem item, int col, boolean value) {
+ boolean prevChecked = checkedIndicator(col).equals(item.getText(col));
+ item.setText(col, value ? checkedIndicator(col) : UNCHECKED);
+ if (value && !prevChecked)
+ numberChecked++;
+ else if (!value && prevChecked)
+ numberChecked--;
+ }
+
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java Wed Jul 17 17:55:28 2019
@@ -23,14 +23,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
import org.apache.uima.analysis_engine.TypeOrFeature;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
@@ -38,6 +30,15 @@ import org.apache.uima.resource.metadata
import org.apache.uima.taeconfigurator.editors.ui.AbstractSection;
import org.apache.uima.taeconfigurator.editors.ui.CapabilitySection;
import org.apache.uima.taeconfigurator.editors.ui.Utility;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
/**
@@ -111,15 +112,15 @@ public class AddCapabilityFeatureDialog
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
- table = newTable(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
- ((GridData) table.getLayoutData()).heightHint = 100;
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- new TableColumn(table, SWT.NONE).setText("Feature Name");
- new TableColumn(table, SWT.NONE).setText("Input");
- new TableColumn(table, SWT.NONE).setText("Output");
+ Tree tree = newTree(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ ((GridData) tree.getLayoutData()).heightHint = 100;
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+ new TreeColumn(tree, SWT.NONE).setText("Feature Name");
+ new TreeColumn(tree, SWT.NONE).setText("Input");
+ new TreeColumn(tree, SWT.NONE).setText("Output");
- TableItem item = new TableItem(table, SWT.NONE);
+ TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText(0, CapabilitySection.ALL_FEATURES);
TypeOrFeature tof = AbstractSection.getTypeOrFeature(capability.getInputs(), selectedType
.getName());
@@ -128,15 +129,15 @@ public class AddCapabilityFeatureDialog
setChecked(item, 2, null == tof ? false : tof.isAllAnnotatorFeatures());
for (int i = 0; i < allFeatures.length; i++) {
- item = new TableItem(table, SWT.NONE);
+ item = new TreeItem(tree, SWT.NONE);
item.setText(0, allFeatures[i].getShortName());
setChecked(item, 1, CapabilitySection.isInput(getTypeFeature(allFeatures[i]), capability));
setChecked(item, 2, CapabilitySection.isOutput(getTypeFeature(allFeatures[i]), capability));
}
- table.removeListener(SWT.Selection, this);
- table.addListener(SWT.MouseDown, this); // for i / o toggling
- section.packTable(table);
+ tree.removeListener(SWT.Selection, this);
+ tree.addListener(SWT.MouseDown, this); // for i / o toggling
+ section.packTree(tree);
newErrorMessage(composite);
return composite;
}
@@ -167,7 +168,7 @@ public class AddCapabilityFeatureDialog
if (item.getText(0).equals(CapabilitySection.ALL_FEATURES))
uncheckAllOtherFeatures(col);
else
- setChecked(table.getItem(0), col, false); // uncheck all-features
+ setChecked(f_tree.getItem(0), col, false); // uncheck all-features
}
/**
@@ -176,7 +177,7 @@ public class AddCapabilityFeatureDialog
* @param column the column
*/
private void uncheckAllOtherFeatures(int column) {
- TableItem[] items = table.getItems();
+ TreeItem[] items = f_tree.getItems();
for (int i = 1; i < items.length; i++) {
setChecked(items[i], column, false);
}
@@ -187,12 +188,12 @@ public class AddCapabilityFeatureDialog
*/
@Override
public void copyValuesFromGUI() {
- List names = new ArrayList();
- List ins = new ArrayList();
- List outs = new ArrayList();
+ List<String> names = new ArrayList<>();
+ List<Boolean> ins = new ArrayList<>();
+ List<Boolean> outs = new ArrayList<>();
- for (int i = table.getItemCount() - 1; i >= 1; i--) {
- TableItem item = table.getItem(i);
+ for (int i = f_tree.getItemCount() - 1; i >= 1; i--) {
+ TreeItem item = f_tree.getItem(i);
if (item.getText(1).equals(checkedIndicator(1))
|| item.getText(2).equals(checkedIndicator(2))) {
names.add(item.getText(0));
@@ -209,7 +210,7 @@ public class AddCapabilityFeatureDialog
outputs[i] = (Boolean) outs.get(i);
}
- TableItem item = table.getItem(0);
+ TreeItem item = f_tree.getItem(0);
allFeaturesInput = item.getText(1).equals(checkedIndicator(1));
allFeaturesOutput = item.getText(2).equals(checkedIndicator(2));
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java?rev=1863232&r1=1863231&r2=1863232&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java Wed Jul 17 17:55:28 2019
@@ -22,18 +22,16 @@ package org.apache.uima.taeconfigurator.
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
import org.apache.uima.analysis_engine.TypeOrFeature;
import org.apache.uima.cas.CAS;
import org.apache.uima.resource.metadata.Capability;
import org.apache.uima.taeconfigurator.editors.ui.AbstractSection;
import org.apache.uima.taeconfigurator.editors.ui.CapabilitySection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
/**
@@ -69,10 +67,10 @@ public class AddCapabilityTypeDialog ext
private Capability capability;
/** The existing. */
- private TableTreeItem existing = null;
+ private TreeItem existing = null;
/** The excluded types. */
- private static List excludedTypes = new ArrayList();
+ private static List<String> excludedTypes = new ArrayList<>();
{
excludedTypes.add(CAS.TYPE_NAME_ARRAY_BASE);
excludedTypes.add(CAS.TYPE_NAME_EMPTY_FS_LIST);
@@ -134,7 +132,7 @@ public class AddCapabilityTypeDialog ext
* @param c the c
* @param aExisting the a existing
*/
- public AddCapabilityTypeDialog(AbstractSection aSection, Capability c, TableTreeItem aExisting) {
+ public AddCapabilityTypeDialog(AbstractSection aSection, Capability c, TreeItem aExisting) {
this(aSection, c);
existing = aExisting;
}
@@ -146,14 +144,14 @@ public class AddCapabilityTypeDialog ext
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent, existing);
- table = newTable(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ f_tree = newTree(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
// ((GridData)table.getLayoutData()).heightHint = 100;
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
- new TableColumn(table, SWT.NONE).setText("Type Name");
- new TableColumn(table, SWT.NONE).setText("Input");
- new TableColumn(table, SWT.NONE).setText("Output");
- new TableColumn(table, SWT.NONE).setText("Type Namespace");
+ f_tree.setHeaderVisible(true);
+ f_tree.setLinesVisible(true);
+ new TreeColumn(f_tree, SWT.NONE).setText("Type Name");
+ new TreeColumn(f_tree, SWT.NONE).setText("Input");
+ new TreeColumn(f_tree, SWT.NONE).setText("Output");
+ new TreeColumn(f_tree, SWT.NONE).setText("Type Namespace");
if (null == existing) {
String[] allTypes = getAllTypesAsSortedArray();
@@ -161,12 +159,12 @@ public class AddCapabilityTypeDialog ext
for (int i = 0; i < allTypes.length; i++) {
if (!excludedTypes.contains(allTypes[i]) && !hasType(capability.getInputs(), allTypes[i])
&& !hasType(capability.getOutputs(), allTypes[i])) {
- TableItem item = new TableItem(table, SWT.NONE);
+ TreeItem item = new TreeItem(f_tree, SWT.NONE);
setGuiTypeName(item, allTypes[i]);
}
}
} else { // existing item being edited - just show one item
- TableItem item = new TableItem(table, SWT.NONE);
+ TreeItem item = new TreeItem(f_tree, SWT.NONE);
item.setText(NAME, existing.getText(CapabilitySection.NAME_COL));
item.setText(NAMESPACE, existing.getText(CapabilitySection.NAMESPACE_COL));
TypeOrFeature tof = AbstractSection.getTypeOrFeature(capability.getInputs(),
@@ -177,10 +175,10 @@ public class AddCapabilityTypeDialog ext
setChecked(item, 2, null != tof);
}
- section.packTable(table);
+ section.packTree(f_tree);
// can't use selection event because it doesn't return mouse position
- table.removeListener(SWT.Selection, this);
- table.addListener(SWT.MouseDown, this); // for i / o toggling
+ f_tree.removeListener(SWT.Selection, this);
+ f_tree.addListener(SWT.MouseDown, this); // for i / o toggling
newErrorMessage(composite);
return composite;
}
@@ -207,12 +205,12 @@ public class AddCapabilityTypeDialog ext
*/
@Override
public void copyValuesFromGUI() {
- List names = new ArrayList();
- List ins = new ArrayList();
- List outs = new ArrayList();
+ List<String> names = new ArrayList<>();
+ List<Boolean> ins = new ArrayList<>();
+ List<Boolean> outs = new ArrayList<>();
- for (int i = table.getItemCount() - 1; i >= 0; i--) {
- TableItem item = table.getItem(i);
+ for (int i = f_tree.getItemCount() - 1; i >= 0; i--) {
+ TreeItem item = f_tree.getItem(i);
if (item.getText(INPUT).equals(checkedIndicator(INPUT))
|| item.getText(OUTPUT).equals(checkedIndicator(OUTPUT))) {
names.add(capabilitySection.getFullyQualifiedName(item.getText(NAMESPACE), item
@@ -239,7 +237,7 @@ public class AddCapabilityTypeDialog ext
* @param typeName the type name
*/
// used by dialog
- public void setGuiTypeName(TableItem item, String typeName) {
+ public void setGuiTypeName(TreeItem item, String typeName) {
item.setText(NAME, AbstractSection.getShortName(typeName));
item.setText(NAMESPACE, AbstractSection.getNameSpace(typeName));
}