Author: schor Date: Fri Jul 19 14:26:19 2019 New Revision: 1863399 URL: http://svn.apache.org/viewvc?rev=1863399&view=rev Log: [UIMA-6094] merge from uv3 - update to drop use of TableTree, and check when setting selection for invalid index.
Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/CapabilitySection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/IndexSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterDelegatesSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractImportablePartSection.java Fri Jul 19 14:26:19 2019 @@ -25,7 +25,6 @@ import org.apache.uima.resource.metadata import org.apache.uima.resource.metadata.TypeSystemDescription; import org.apache.uima.taeconfigurator.editors.MultiPageEditor; 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; Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AbstractSection.java Fri Jul 19 14:26:19 2019 @@ -2552,4 +2552,20 @@ implements Listener, StandardStrings { return "sorted"; return indexKind; } + + /** + * set the selection one above this item, unless it's the top one already. + * Used when removing the item + */ + public static void setSelectionOneUp(Tree tt, TreeItem item) { + int itemIndex = tt.indexOf(item); + maybeSetSelection(tt, itemIndex - 1); + } + + public static void maybeSetSelection(Tree tt, int itemIndex) { + TreeItem[] items = tt.getItems(); + if (itemIndex >= 0 && itemIndex < items.length) { + tt.setSelection(items[itemIndex]); + } + } } 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=1863399&r1=1863398&r2=1863399&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 Fri Jul 19 14:26:19 2019 @@ -44,8 +44,6 @@ import org.eclipse.swt.SWT; 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; @@ -235,7 +233,7 @@ public class CapabilitySection extends A TreeItem item = new TreeItem(tt, SWT.NONE); item.setText(TITLE_COL, CAPABILITY_SET); item.setData(cs[i]); - tt.setSelection(new TreeItem[] { item }); // set default selection + tt.setSelection( item ); // set default selection fillCapability(item, cs[i]); // if (0 == i) { item.setExpanded(true); @@ -541,7 +539,7 @@ public class CapabilitySection extends A createSofaHeaderGui(item); item.setExpanded(true); - tt.setSelection(new TreeItem[] { item }); + tt.setSelection( item ); if (tt.getItemCount() == 1) tt.getColumn(TITLE_COL).pack(); finishAction(); @@ -769,17 +767,14 @@ public class CapabilitySection extends A * @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)) { - tt.setSelection(tt.getItems()[selectionIndex + 1]); + maybeSetSelection(tt, selectionIndex + 1); return; } removeCapabilitySet(c); @@ -798,7 +793,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)) { - tt.setSelection(tt.getItems()[selectionIndex + 1]); + maybeSetSelection(tt, selectionIndex + 1); return; } String sofaName = removeItem.getText(NAME_COL); @@ -834,7 +829,7 @@ 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)) { - tt.setSelection(tt.getItems()[selectionIndex + 1]); + maybeSetSelection(tt, selectionIndex + 1); return; } TreeItem[] features = removeItem.getItems(); @@ -859,7 +854,7 @@ public class CapabilitySection extends A throw new InternalErrorCDE("invalid state"); } - tt.setSelection(tt.getItems()[previousSelection]); + maybeSetSelection(tt, selectionIndex - 1); finishAction(); } @@ -1160,7 +1155,7 @@ public class CapabilitySection extends A } parentItem.setExpanded(true); tt.getColumn(NAME_COL).pack(); - tt.setSelection(new TreeItem[] { parentItem }); + tt.setSelection( parentItem ); c.setInputs(replaceFeaturesKeepingTypes(c.getInputs(), typeName, inputsL)); c.setOutputs(replaceFeaturesKeepingTypes(c.getOutputs(), typeName, outputsL)); 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=1863399&r1=1863398&r2=1863399&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 Fri Jul 19 14:26:19 2019 @@ -34,7 +34,6 @@ 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.TableTreeItem; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Event; @@ -282,8 +281,8 @@ public class IndexSection extends Abstra updateIndexSpec(new TreeItem(tt, SWT.NONE), id); - TreeItem[] items = tt.getItems(); - tt.setSelection(items[items.length - 1]); + + maybeSetSelection(tt, tt.getItemCount() - 1); packTree(tt); setFileDirty(); } else if (event.widget == addKeyButton) { @@ -322,9 +321,8 @@ public class IndexSection extends Abstra FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent); removeFsIndexKeyDescription(fsid, (FsIndexKeyDescription) o); } - TreeItem selectionItem = tt.getSelection()[0]; + setSelectionOneUp(tt, item); // 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) { @@ -549,8 +547,9 @@ public class IndexSection extends Abstra downButton.setEnabled(false); if (selected) { if (null != parent && notBuiltInSelected) { - TreeItem firstItem = parent.getItems()[0]; - TreeItem lastItem = parent.getItems()[parent.getItems().length - 1]; + TreeItem[] items = parent.getItems(); + TreeItem firstItem = items[0]; + TreeItem lastItem = items[items.length - 1]; upButton.setEnabled(item != firstItem); downButton.setEnabled(item != lastItem); } Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterDelegatesSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterDelegatesSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterDelegatesSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterDelegatesSection.java Fri Jul 19 14:26:19 2019 @@ -45,18 +45,33 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.forms.IManagedForm; + +/** + * The Class ParameterDelegatesSection. + */ public class ParameterDelegatesSection extends AbstractSectionParm { + /** The section client. */ private Composite sectionClient; + /** The parm section. */ private ParameterSection parmSection; + /** The create non shared override. */ private boolean createNonSharedOverride; + /** The create override button. */ private Button createOverrideButton; + /** The create non shared override button. */ private Button createNonSharedOverrideButton; + /** + * Instantiates a new parameter delegates section. + * + * @param editor the editor + * @param parent the parent + */ public ParameterDelegatesSection(MultiPageEditor editor, Composite parent) { super( editor, @@ -71,6 +86,7 @@ public class ParameterDelegatesSection e * * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm) */ + @Override public void initialize(IManagedForm form) { parmSection = editor.getParameterPage().getParameterSection(); @@ -98,6 +114,7 @@ public class ParameterDelegatesSection e * * @see org.eclipse.ui.forms.IFormPart#refresh() */ + @Override public void refresh() { super.refresh(); parmSection = editor.getParameterPage().getParameterSection(); @@ -120,14 +137,16 @@ public class ParameterDelegatesSection e if (null != fcd) { addDelegateToGUI(fcd.getKey(), fcd.getSpecifier()); } - TreeItem[] items = tree.getItems(); - if (items.length > 0) - // scrolls to top, also - tree.setSelection(new TreeItem[] { items[0] }); + maybeSetSelection(tree, 0); } enable(); } + /** + * Adds the delegate to GUI. + * + * @param entry the entry + */ private void addDelegateToGUI(Map.Entry entry) { addDelegateToGUI((String) entry.getKey(), (ResourceSpecifier) entry.getValue()); // String key = (String) entry.getKey(); @@ -142,6 +161,12 @@ public class ParameterDelegatesSection e // } } + /** + * Adds the delegate to GUI. + * + * @param key the key + * @param delegate the delegate + */ private void addDelegateToGUI(String key, ResourceSpecifier delegate) { if (delegate instanceof AnalysisEngineDescription || delegate instanceof CasConsumerDescription || delegate instanceof FlowControllerDescription) { @@ -155,6 +180,12 @@ public class ParameterDelegatesSection e } } + /** + * Adds the delegate groups to GUI. + * + * @param parent the parent + * @param delegate the delegate + */ private void addDelegateGroupsToGUI(TreeItem parent, ResourceCreationSpecifier delegate) { ConfigurationParameterDeclarations cpd1 = delegate.getMetaData() .getConfigurationParameterDeclarations(); @@ -180,6 +211,12 @@ public class ParameterDelegatesSection e } } + /** + * Adds the delegate group to GUI. + * + * @param parent the parent + * @param cg the cg + */ private void addDelegateGroupToGUI(TreeItem parent, ConfigGroup cg) { ConfigurationParameter[] cps = cg.getConfigParms(); if (null != cps && cps.length > 0) { @@ -191,6 +228,12 @@ public class ParameterDelegatesSection e } } + /** + * Adds the delegate parms to GUI. + * + * @param parent the parent + * @param cps the cps + */ private void addDelegateParmsToGUI(TreeItem parent, ConfigurationParameter[] cps) { if (null != cps) { for (int i = 0; i < cps.length; i++) { @@ -206,6 +249,12 @@ public class ParameterDelegatesSection e } } + /** + * Adds the delegate parm overrides to GUI. + * + * @param parent the parent + * @param overrides the overrides + */ private void addDelegateParmOverridesToGUI(TreeItem parent, String[] overrides) { for (int i = 0; i < overrides.length; i++) { TreeItem d = new TreeItem(parent, SWT.NONE); @@ -218,6 +267,7 @@ public class ParameterDelegatesSection e * * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ + @Override public void handleEvent(Event event) { if (event.type == SWT.MouseHover) { showDescriptionAsToolTip(event); @@ -230,6 +280,11 @@ public class ParameterDelegatesSection e } } + /** + * Adds the overrides. + * + * @param nonShared the non shared + */ private void addOverrides(boolean nonShared) { TreeItem item = tree.getSelection()[0]; createNonSharedOverride = nonShared; @@ -241,35 +296,75 @@ public class ParameterDelegatesSection e addAllGroups(item.getItems()); } + /** + * Gets the configuration parameter from tree item. + * + * @param item the item + * @return the configuration parameter from tree item + */ public ConfigurationParameter getConfigurationParameterFromTreeItem(TreeItem item) { return (ConfigurationParameter) item.getData(); } + /** + * Gets the config group from tree item. + * + * @param item the item + * @return the config group from tree item + */ public ConfigGroup getConfigGroupFromTreeItem(TreeItem item) { return (ConfigGroup) item.getData(); } + /** + * Gets the key name from tree item. + * + * @param item the item + * @return the key name from tree item + */ private String getKeyNameFromTreeItem(TreeItem item) { return (String) item.getData(); } + /** + * Adds the new parameter. + * + * @param item the item + */ private void addNewParameter(TreeItem item) { addNewParameter(getConfigurationParameterFromTreeItem(item), getConfigGroupFromTreeItem(item .getParentItem()), getKeyNameFromTreeItem(item.getParentItem().getParentItem())); } + /** + * Adds the all parameters. + * + * @param items the items + */ private void addAllParameters(TreeItem[] items) { for (int i = 0; i < items.length; i++) { addNewParameter(items[i]); } } + /** + * Adds the all groups. + * + * @param items the items + */ private void addAllGroups(TreeItem[] items) { for (int i = 0; i < items.length; i++) { addAllParameters(items[i].getItems()); } } + /** + * Adds the new parameter. + * + * @param parm the parm + * @param delegateGroup the delegate group + * @param key the key + */ private void addNewParameter(ConfigurationParameter parm, ConfigGroup delegateGroup, String key) { ConfigGroup group = getCorrespondingModelGroup(delegateGroup); @@ -306,6 +401,13 @@ public class ParameterDelegatesSection e } } + /** + * Gets the overriding parm name. + * + * @param override the override + * @param cgset the cgset + * @return the overriding parm name + */ /* * Check if already have an override for this delegate parameter * If parameter is in a group-set with multiple groups, check if override is in @@ -339,6 +441,13 @@ public class ParameterDelegatesSection e return null; } + /** + * Gets the overriding parm name. + * + * @param override the override + * @param cps the cps + * @return the overriding parm name + */ private static String getOverridingParmName(String override, ConfigurationParameter[] cps) { if (null != cps) for (int i = 0; i < cps.length; i++) { @@ -353,9 +462,9 @@ public class ParameterDelegatesSection e } /** - * Add a suffix to the name to make it unique within all parameters defined for the cpd - * - * @param name + * Add a suffix to the name to make it unique within all parameters defined for the cpd. + * + * @param name the name * @return name with suffix making it unique */ private String generateUniqueName(String name) { @@ -375,6 +484,12 @@ public class ParameterDelegatesSection e return nameTry; } + /** + * Adds the parm names. + * + * @param list the list + * @param parms the parms + */ private void addParmNames(List list, ConfigurationParameter[] parms) { if (null != parms) { for (int i = 0; i < parms.length; i++) { @@ -383,6 +498,13 @@ public class ParameterDelegatesSection e } } + /** + * Gets the override index. + * + * @param parm the parm + * @param override the override + * @return the override index + */ private int getOverrideIndex(ConfigurationParameter parm, String override) { String[] overrides = parm.getOverrides(); if (null == overrides) @@ -394,6 +516,13 @@ public class ParameterDelegatesSection e return -1; } + /** + * Gets the same named parm in group. + * + * @param parm the parm + * @param group the group + * @return the same named parm in group + */ private ConfigurationParameter getSameNamedParmInGroup(ConfigurationParameter parm, ConfigGroup group) { ConfigurationParameter[] cps = group.getConfigParms(); @@ -405,6 +534,13 @@ public class ParameterDelegatesSection e return null; } + /** + * Parm spec matches. + * + * @param p the p + * @param q the q + * @return true, if successful + */ private boolean parmSpecMatches(ConfigurationParameter p, ConfigurationParameter q) { if (!p.getType().equals(q.getType())) return false; @@ -415,6 +551,12 @@ public class ParameterDelegatesSection e return true; } + /** + * Gets the corresponding model group. + * + * @param delegateGroup the delegate group + * @return the corresponding model group + */ private ConfigGroup getCorrespondingModelGroup(ConfigGroup delegateGroup) { switch (delegateGroup.getKind()) { case ConfigGroup.NOT_IN_ANY_GROUP: @@ -427,6 +569,12 @@ public class ParameterDelegatesSection e throw new InternalErrorCDE("invalid state"); } + /** + * Gets the corresponding model group. + * + * @param nameArray the name array + * @return the corresponding model group + */ private ConfigGroup getCorrespondingModelGroup(String[] nameArray) { ConfigurationGroup[] cgs = cpd.getConfigurationGroups(); for (int i = 0; i < cgs.length; i++) { @@ -438,10 +586,11 @@ public class ParameterDelegatesSection e } /** - * Compare for set equals, assuming sets have no duplicates - * - * @param a - * @param b + * Compare for set equals, assuming sets have no duplicates. + * + * @param a the a + * @param b the b + * @return true, if successful */ private boolean setEquals(Object[] a, Object[] b) { if (null == a && null == b) @@ -464,6 +613,10 @@ public class ParameterDelegatesSection e return true; } + /* (non-Javadoc) + * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSectionParm#enable() + */ + @Override public void enable() { createOverrideButton.setEnabled(tree.getSelectionCount() == 1); createNonSharedOverrideButton.setEnabled(tree.getSelectionCount() == 1); Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ParameterSection.java Fri Jul 19 14:26:19 2019 @@ -141,39 +141,53 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.forms.IManagedForm; + +/** + * The Class ParameterSection. + */ public class ParameterSection extends AbstractSectionParm { + /** The Constant NEW_OVERRIDE. */ public final static int NEW_OVERRIDE = -1; + /** The Constant REMOVE_FROM_GUI. */ public final static boolean REMOVE_FROM_GUI = true; + /** The Constant GIVE_WARNING_MESSAGE. */ public final static boolean GIVE_WARNING_MESSAGE = true; + /** The default group. */ private Text defaultGroup; + /** The search strategy. */ private CCombo searchStrategy; + /** The add button. */ private Button addButton; + /** The add group button. */ private Button addGroupButton; + /** The edit button. */ private Button editButton; + /** The remove button. */ private Button removeButton; + /** The using groups button. */ private Button usingGroupsButton; + /** The grouping control. */ private Composite groupingControl; + /** The first time. */ private boolean firstTime = true; /** - * Creates a section to show a list of all parameters - * - * @param editor - * backpointer to the main multipage editor - * @param parent - * the Composite where this section lives + * Creates a section to show a list of all parameters. + * + * @param editor backpointer to the main multipage editor + * @param parent the Composite where this section lives */ public ParameterSection(MultiPageEditor editor, Composite parent) { super(editor, parent, "Configuration Parameters", @@ -202,6 +216,10 @@ public class ParameterSection extends Ab // both incrementally updated, so rebuild is not needed. This preserves // user-specified expansion of nodes. + /* (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); @@ -255,6 +273,7 @@ public class ParameterSection extends Ab * @see org.eclipse.ui.forms.IFormPart#refresh() */ + @Override public void refresh() { super.refresh(); // clears stale and dirty bits in AbstractFormPart // superclass @@ -279,7 +298,7 @@ public class ParameterSection extends Ab splitGroupNames = false; clearAndRefillTree(usingGroupsButton.getSelection()); - tree.setSelection(new TreeItem[] { tree.getItems()[0] }); + maybeSetSelection(tree, 0); enable(); // sync settings page to catch use case of switching from sourceEditor @@ -298,6 +317,7 @@ public class ParameterSection extends Ab * * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ + @Override public void handleEvent(Event event) { cpd = getAnalysisEngineMetaData().getConfigurationParameterDeclarations(); @@ -462,6 +482,12 @@ public class ParameterSection extends Ab enable(); } + /** + * Adds the or edit override. + * + * @param parmItem the parm item + * @param overrideIndex the override index + */ private void addOrEditOverride(TreeItem parmItem, int overrideIndex) { ConfigurationParameter cp = getCorrespondingModelParm(parmItem); TreeItem groupItem = parmItem.getParentItem(); @@ -510,6 +536,13 @@ public class ParameterSection extends Ab } + /** + * Removes the items. + * + * @param itemsToRemove the items to remove + * @param giveWarningMsg the give warning msg + * @return true, if successful + */ private boolean removeItems(TreeItem[] itemsToRemove, boolean giveWarningMsg) { String[] namesToRemove = new String[itemsToRemove.length]; boolean[] isGroup = new boolean[itemsToRemove.length]; @@ -579,6 +612,12 @@ public class ParameterSection extends Ab return true; } + /** + * Removes the parameter. + * + * @param itemToRemove the item to remove + * @param nameToRemove the name to remove + */ private void removeParameter(TreeItem itemToRemove, String nameToRemove) { TreeItem parentItem = itemToRemove.getParentItem(); ConfigurationGroup cg = null; @@ -603,6 +642,12 @@ public class ParameterSection extends Ab } } + /** + * Removes the group. + * + * @param itemToRemove the item to remove + * @param nameToRemove the name to remove + */ private void removeGroup(TreeItem itemToRemove, String nameToRemove) { if (nameToRemove.equals(COMMON_GROUP)) { removeCommonParmSettingsFromMultipleGroups(); @@ -631,6 +676,14 @@ public class ParameterSection extends Ab } } + /** + * Adds the parm. + * + * @param name the name + * @param modelParm the model parm + * @param group the group + * @param override the override + */ public void addParm(String name, ConfigurationParameter modelParm, ConfigGroup group, String override) { TreeItem parentGroup = getTreeItemGroup(group); @@ -647,6 +700,12 @@ public class ParameterSection extends Ab commonActionFinish(); } + /** + * Gets the configuration group. + * + * @param groupName the group name + * @return the configuration group + */ private ConfigurationGroup getConfigurationGroup(String groupName) { if (groupName.equals(COMMON_GROUP)) throw new InternalErrorCDE("invalid call"); @@ -658,12 +717,26 @@ public class ParameterSection extends Ab throw new InternalErrorCDE("invalid state"); } + /** + * Removes the configuration group. + * + * @param groups the groups + * @param cg the cg + * @return the configuration group[] + */ private ConfigurationGroup[] removeConfigurationGroup(ConfigurationGroup[] groups, ConfigurationGroup cg) { return (ConfigurationGroup[]) Utility.removeElementFromArray(groups, cg, ConfigurationGroup.class); } + /** + * Removes the configuration parameter. + * + * @param parms the parms + * @param nameToRemove the name to remove + * @return the configuration parameter[] + */ private ConfigurationParameter[] removeConfigurationParameter(ConfigurationParameter[] parms, String nameToRemove) { ConfigurationParameter[] newParms = new ConfigurationParameter[parms.length - 1]; @@ -675,6 +748,13 @@ public class ParameterSection extends Ab return newParms; } + /** + * Removes the override. + * + * @param cp the cp + * @param i the i + * @return the string[] + */ private String[] removeOverride(ConfigurationParameter cp, int i) { String[] oldOverrides = cp.getOverrides(); String[] newOverrides = new String[oldOverrides.length - 1]; @@ -686,10 +766,10 @@ public class ParameterSection extends Ab } /** - * Called to add group to aggregate parm decl based on delegate group - * - * @param group - * the delegate group needing to be added to the aggregate + * Called to add group to aggregate parm decl based on delegate group. + * + * @param group the delegate group needing to be added to the aggregate + * @return the config group */ public ConfigGroup addGroup(ConfigGroup group) { String groupName = group.getName(); @@ -704,16 +784,19 @@ public class ParameterSection extends Ab // fill(commonParms, item); // don't add common parsm, they're added by definition addGroupToModel(cg); cg.setNames(groupNameArray); - tree.setSelection(new TreeItem[] { item }); + tree.setSelection( item ); return new ConfigGroup(cpd, cg); } // existing, if not null, doesn't point to <Common> which can't be edited /** + * Adds the new or edit existing group. + * * @param names - * a sequence of group names separated by blanks * @param existing - * null or an existing tree item being edited + * @return true, if successful */ private boolean addNewOrEditExistingGroup(String names, TreeItem existing) { valueChanged = true; // preset @@ -775,10 +858,16 @@ public class ParameterSection extends Ab } - tree.setSelection(new TreeItem[] { item }); + tree.setSelection( item ); return true; } + /** + * Fill in front of common. + * + * @param parms the parms + * @param settingsTreeGroup the settings tree group + */ private void fillInFrontOfCommon(ConfigurationParameter[] parms, TreeItem settingsTreeGroup) { if (parms != null) { for (int i = parms.length - 1; i >= 0; i--) { @@ -788,10 +877,10 @@ public class ParameterSection extends Ab } /** - * Calculate s1 - s2 set - * - * @param s1 - * @param s2 + * Calculate s1 - s2 set. + * + * @param s1 the s 1 + * @param s2 the s 2 * @return s1 - s2 set */ private String[] setDiff(String[] s1, String[] s2) { @@ -803,6 +892,13 @@ public class ParameterSection extends Ab return (String[]) result.toArray(stringArray0); } + /** + * Sets the equal. + * + * @param s1 the s 1 + * @param s2 the s 2 + * @return true, if successful + */ private boolean setEqual(String[] s1, String[] s2) { if (null == s1 && null == s2) return true; @@ -816,20 +912,20 @@ public class ParameterSection extends Ab } /** - * Called from ParameterDelegatesSection to add an override - * - * @param parmInGroup - * @param override + * Called from ParameterDelegatesSection to add an override. + * + * @param parmInGroup the parm in group + * @param override the override */ public void addOverride(ConfigurationParameter parmInGroup, String override) { addOverride(override, getTreeItemParm(parmInGroup), parmInGroup); } /** - * add an override item - * - * @param parent - * @param override + * add an override item. + * + * @param parent the parent + * @param override the override */ private void addOverrideToGUI(TreeItem parent, String override) { // addOverride(dialog.overrideSpec, parent, cp); @@ -839,11 +935,12 @@ public class ParameterSection extends Ab /** * Called by addNewConfigurationParameter, and fill (via refresh) to add overrides to the tree - * list - * - * @param parent - * @param modelCP + * list. + * + * @param parent the parent + * @param modelCP the model CP */ + @Override protected void fillOverrides(TreeItem parent, ConfigurationParameter modelCP) { if (isAggregate()) { String[] overrides = modelCP.getOverrides(); @@ -857,11 +954,11 @@ public class ParameterSection extends Ab } /** - * called from add Override action - * - * @param dialog - * @param parent - * @param cp + * called from add Override action. + * + * @param override the override + * @param parent the parent + * @param cp the cp */ private void addOverride(String override, TreeItem parent, ConfigurationParameter cp) { cp.setOverrides(addOverrideToArray(cp.getOverrides(), override)); @@ -870,6 +967,12 @@ public class ParameterSection extends Ab commonActionFinish(); } + /** + * Alter existing configuration parameter. + * + * @param dialog the dialog + * @param existingTreeItem the existing tree item + */ private void alterExistingConfigurationParameter(AddParameterDialog dialog, TreeItem existingTreeItem) { ConfigurationParameter existingCP = getCorrespondingModelParm(existingTreeItem); @@ -895,6 +998,13 @@ public class ParameterSection extends Ab commonParmUpdate(existingTreeItem, existingCP, previousCP.getName()); } + /** + * Common parm update. + * + * @param existingTreeItem the existing tree item + * @param existingCP the existing CP + * @param prevName the prev name + */ private void commonParmUpdate(TreeItem existingTreeItem, ConfigurationParameter existingCP, String prevName) { updateParmInSettingsGUI(existingCP, existingTreeItem, prevName); @@ -922,9 +1032,9 @@ public class ParameterSection extends Ab /** * Fills in the model Configuration Parm from the Add/Edit dialog. called from * addNewConfigurationParameter, and alterExistingConfigurationParameter - * - * @param dialog - * @param existingCP + * + * @param dialog the dialog + * @param existingCP the existing CP */ private void fillModelParm(AddParameterDialog dialog, ConfigurationParameter existingCP) { valueChanged = false; @@ -942,10 +1052,11 @@ public class ParameterSection extends Ab /** * Called from UI when adding a new Configuraton Parameter Called from refresh when filling params - * Called when adding override to new parm - * - * @param dialog - * @param group + * Called when adding override to new parm. + * + * @param dialog the dialog + * @param group the group + * @return the configuration parameter */ private ConfigurationParameter addNewConfigurationParameter(AddParameterDialog dialog, TreeItem group) { @@ -969,6 +1080,11 @@ public class ParameterSection extends Ab return newCP; } + /** + * Adds the group to model. + * + * @param newCg the new cg + */ private void addGroupToModel(ConfigurationGroup newCg) { ConfigurationGroup[] oldCgs = cpd.getConfigurationGroups(); ConfigurationGroup[] newCgs; @@ -982,6 +1098,13 @@ public class ParameterSection extends Ab cpd.setConfigurationGroups(newCgs); } + /** + * Adds the override to array. + * + * @param overrides the overrides + * @param newOverride the new override + * @return the string[] + */ private String[] addOverrideToArray(String[] overrides, String newOverride) { if (null == overrides) return new String[] { newOverride }; @@ -991,6 +1114,13 @@ public class ParameterSection extends Ab return newOverrides; } + /** + * Adds the parm to array. + * + * @param cps the cps + * @param newCP the new CP + * @return the configuration parameter[] + */ private ConfigurationParameter[] addParmToArray(ConfigurationParameter[] cps, ConfigurationParameter newCP) { @@ -1004,8 +1134,9 @@ public class ParameterSection extends Ab } /** - * - * @param names + * Group name already defined. + * + * @param names the names * @return true if there is a group whose names are the same set */ private boolean groupNameAlreadyDefined(String[] names) { @@ -1019,6 +1150,13 @@ public class ParameterSection extends Ab return false; } + /** + * Parameter name already defined no msg. + * + * @param name the name + * @param pCpd the cpd + * @return true, if successful + */ public static boolean parameterNameAlreadyDefinedNoMsg(String name, ConfigurationParameterDeclarations pCpd) { if (pCpd.getCommonParameters() != null) { @@ -1048,6 +1186,7 @@ public class ParameterSection extends Ab * * @param name - Parameter name * @param cgset - Group-set (may be not-in-any, common, or a named set) + * @return true, if successful */ public boolean parameterNameAlreadyDefinedNoMsg(String name, ConfigGroup cgset) { if (cgset.getKind() == ConfigGroup.NOT_IN_ANY_GROUP) { @@ -1069,6 +1208,13 @@ public class ParameterSection extends Ab return false; } + /** + * Have shared group. + * + * @param set1 the set 1 + * @param set2 the set 2 + * @return true, if successful + */ /* * Check if arrays have an element in common */ @@ -1083,6 +1229,13 @@ public class ParameterSection extends Ab return false; } + /** + * Parameter name already defined. + * + * @param name the name + * @param cgset the cgset + * @return true, if successful + */ public boolean parameterNameAlreadyDefined(String name, ConfigGroup cgset) { boolean alreadyDefined = parameterNameAlreadyDefinedNoMsg(name, cgset); if (alreadyDefined) { @@ -1095,6 +1248,13 @@ public class ParameterSection extends Ab return alreadyDefined; } + /** + * Parameter in array. + * + * @param name the name + * @param cps the cps + * @return true, if successful + */ private static boolean parameterInArray(String name, ConfigurationParameter[] cps) { for (int i = 0; i < cps.length; i++) { if (name.equals(cps[i].getName())) @@ -1103,6 +1263,9 @@ public class ParameterSection extends Ab return false; } + /** + * Common action finish. + */ private void commonActionFinish() { valueChanged = true; commonActionFinishDirtyIfChange(); @@ -1119,6 +1282,10 @@ public class ParameterSection extends Ab enable(); } + /* (non-Javadoc) + * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSectionParm#enable() + */ + @Override public void enable() { usingGroupsButton.setEnabled(!isAggregate()); @@ -1139,6 +1306,11 @@ public class ParameterSection extends Ab && isGroupSelection() && !isCommonGroupSelection()))); } + /** + * Gets the tree. + * + * @return the tree + */ public Tree getTree() { return tree; } @@ -1147,8 +1319,8 @@ public class ParameterSection extends Ab * Given a ConfigurationParameter, find the corresponding item in the tree. Note: parameters with * the same name can exist in different groups, so we don't match using the parm name, but rather * do an "EQ" test - * - * @param p + * + * @param p the p * @return the tree item corresponding to the configuration parameter */ private TreeItem getTreeItemParm(ConfigurationParameter p) { @@ -1166,8 +1338,8 @@ public class ParameterSection extends Ab /** * Given a ConfigGroup - find the corresponding tree item. Match is done against the display form * of the name(s), with special casing for the not-in-any-group and common. - * - * @param g + * + * @param g the g * @return the tree itme corresponding to a configuration group */ private TreeItem getTreeItemGroup(ConfigGroup g) { @@ -1185,6 +1357,12 @@ public class ParameterSection extends Ab throw new InternalErrorCDE("invalid state"); } + /** + * Gets the settings tree group. + * + * @param groupName the group name + * @return the settings tree group + */ private TreeItem getSettingsTreeGroup(String groupName) { TreeItem[] items = settingsTree.getItems(); for (int i = 0; i < items.length; i++) { Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/PriorityListSection.java Fri Jul 19 14:26:19 2019 @@ -35,30 +35,53 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.forms.IManagedForm; + +/** + * The Class PriorityListSection. + */ public class PriorityListSection extends AbstractSection { + /** The Constant PRIORITY_LIST. */ public static final String PRIORITY_LIST = "<Priority List>"; + /** The tree. */ private Tree tree; + /** The add set button. */ private Button addSetButton; + /** The add button. */ private Button addButton; + /** The remove button. */ private Button removeButton; + /** The up button. */ private Button upButton; + /** The down button. */ private Button downButton; + /** The type priority import section. */ private TypePriorityImportSection typePriorityImportSection; + /** The export button. */ private Button exportButton; + /** + * Instantiates a new priority list section. + * + * @param editor the editor + * @param parent the parent + */ public PriorityListSection(MultiPageEditor editor, Composite parent) { super(editor, parent, "Priority Lists", "This section shows the defined Prioirity Lists"); } + /* (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); @@ -87,6 +110,7 @@ public class PriorityListSection extends * * @see org.eclipse.ui.forms.IFormPart#refresh() */ + @Override public void refresh() { if (null == typePriorityImportSection) typePriorityImportSection = editor.getIndexesPage().getTypePriorityImportSection(); @@ -111,17 +135,26 @@ public class PriorityListSection extends item.setExpanded(true); } } - if (tree.getItemCount() > 0) - tree.setSelection(new TreeItem[] { tree.getItems()[0] }); + maybeSetSelection(tree, 0); enable(); } + /** + * Gets the type priority list from tree item. + * + * @param item the item + * @return the type priority list from tree item + */ public TypePriorityList getTypePriorityListFromTreeItem(TreeItem item) { TypePriorityList[] typePriorityLists = getAnalysisEngineMetaData().getTypePriorities() .getPriorityLists(); return typePriorityLists[tree.indexOf(item)]; } + /* (non-Javadoc) + * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) + */ + @Override public void handleEvent(Event event) { if (event.widget == addSetButton) { TypePriorityList typePriorityList = UIMAFramework.getResourceSpecifierFactory() @@ -138,7 +171,7 @@ public class PriorityListSection extends TreeItem item = new TreeItem(tree, SWT.NONE); item.setText(PRIORITY_LIST); - tree.setSelection(new TreeItem[] { item }); + tree.setSelection( item ); setFileDirty(); } else if (event.widget == addButton) { // add type to set if (editor.isTypePriorityDescriptor() && !editor.getIsContextLoaded()) { @@ -201,7 +234,7 @@ public class PriorityListSection extends TreeItem previousSelection = getPreviousSelection(parent == null ? tree.getItems() : parent .getItems(), item); if (null != previousSelection) - tree.setSelection(new TreeItem[] { previousSelection }); + tree.setSelection(previousSelection); item.dispose(); setFileDirty(); } @@ -223,7 +256,7 @@ public class PriorityListSection extends new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i])); TreeItem t = new TreeItem(parent, SWT.NONE, i + 1); t.setText(formatName(types[i + 1])); - tree.setSelection(new TreeItem[] { t }); + tree.setSelection( t); items[i].dispose(); items[i + 1].dispose(); @@ -234,7 +267,7 @@ public class PriorityListSection extends TreeItem t = new TreeItem(parent, SWT.NONE, i - 1); t.setText(formatName(types[i - 1])); - tree.setSelection(new TreeItem[] { t }); + tree.setSelection( t); new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i])); items[i - 1].dispose(); @@ -252,6 +285,10 @@ public class PriorityListSection extends enable(); } + /* (non-Javadoc) + * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable() + */ + @Override public void enable() { if (tree.getSelectionCount() == 1) { Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java Fri Jul 19 14:26:19 2019 @@ -47,29 +47,49 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.forms.IManagedForm; + +/** + * The Class SofaMapSection. + */ public class SofaMapSection extends AbstractSection { + /** The section client. */ private Composite sectionClient; + /** The add button. */ private Button addButton; + /** The edit button. */ private Button editButton; + /** The remove button. */ private Button removeButton; + /** The tree. */ private Tree tree; + /** The Constant INPUTS. */ private static final String INPUTS = "Inputs"; + /** The Constant OUTPUTS. */ private static final String OUTPUTS = "Outputs"; + /** The Constant INPUT. */ private static final boolean INPUT = true; + /** The Constant OUTPUT. */ private static final boolean OUTPUT = false; + /** The Constant titleMsg. */ private static final String titleMsg = "This section shows all defined Sofas for an Aggregate and their mappings to the component Sofas.\n" + "Add Aggregate Sofa Names using the Capabilities section; Select an Aggregate Sofa Name and Add/Edit mappings for that Sofa in this section.\n"; + /** + * Instantiates a new sofa map section. + * + * @param aEditor the a editor + * @param parent the parent + */ public SofaMapSection(MultiPageEditor aEditor, Composite parent) { super(aEditor, parent, "Sofa Mappings (Only used in aggregate Descriptors)", titleMsg); } @@ -80,6 +100,7 @@ public class SofaMapSection extends Abst * * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm) */ + @Override public void initialize(IManagedForm form) { super.initialize(form); @@ -104,6 +125,7 @@ public class SofaMapSection extends Abst * * @see org.eclipse.ui.forms.IFormPart#refresh() */ + @Override public void refresh() { super.refresh(); tree.removeAll(); @@ -124,7 +146,7 @@ public class SofaMapSection extends Abst fillMap(inputAggrSofas, INPUT); fillMap(outputSofaNames, OUTPUT); - tree.setSelection(new TreeItem[] { tree.getItems()[0] }); + maybeSetSelection(tree, 0); if (0 == (inputAggrSofas.length + outputSofaNames.length)) { getSection().setText("Sofa Mappings (No Sofas are defined)"); @@ -138,6 +160,13 @@ public class SofaMapSection extends Abst enable(); } + /** + * Gets the aggr sofas. + * + * @param inputCapabilityNames the input capability names + * @param outputCapabilityNames the output capability names + * @return the aggr sofas + */ private String[] getAggrSofas(String[] inputCapabilityNames, String[] outputCapabilityNames) { SofaMapping[] allMappings = getSofaMappings(); Set names = new TreeSet(); @@ -163,6 +192,12 @@ public class SofaMapSection extends Abst return (String[]) names.toArray(stringArray0); } + /** + * Fill map. + * + * @param aggrKeys the aggr keys + * @param isInput the is input + */ private void fillMap(String[] aggrKeys, boolean isInput) { TreeItem d = new TreeItem(tree, SWT.NONE); @@ -176,6 +211,12 @@ public class SofaMapSection extends Abst d.setExpanded(true); } + /** + * Fill bindings. + * + * @param parent the parent + * @param aggrSofa the aggr sofa + */ private void fillBindings(TreeItem parent, String aggrSofa) { // bindings are a string of key-name / sofa-name or "<default>" String[] bindings = getSofaBindingsForAggrSofa(aggrSofa); @@ -185,6 +226,12 @@ public class SofaMapSection extends Abst } } + /** + * Gets the sofa bindings for aggr sofa. + * + * @param aggrSofa the aggr sofa + * @return the sofa bindings for aggr sofa + */ private String[] getSofaBindingsForAggrSofa(String aggrSofa) { SofaMapping[] sofaMappings = getSofaMappings(); if (null == sofaMappings) @@ -209,6 +256,7 @@ public class SofaMapSection extends Abst * * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ + @Override public void handleEvent(Event event) { // Note: to add aggrSofa names, use capabilitySection. // Updates there are propagated here. @@ -246,8 +294,14 @@ public class SofaMapSection extends Abst enable(); } + /** The Constant AVAIL_ONLY. */ private static final boolean AVAIL_ONLY = true; + /** + * Edits the aggr map. + * + * @param selected the selected + */ private void editAggrMap(TreeItem selected) { // pop up window: shows all available component mappings // plus current mappings for this aggrSofa @@ -278,6 +332,11 @@ public class SofaMapSection extends Abst setFileDirty(); } + /** + * Adds the aggr map. + * + * @param selected the selected + */ private void addAggrMap(TreeItem selected) { // pop up window: shows all available component mappings // minus current mappings for this aggrSofa @@ -304,6 +363,14 @@ public class SofaMapSection extends Abst setFileDirty(); } + /** + * Adds the sofas to all component sofa map. + * + * @param allComponentSofas the all component sofas + * @param key the key + * @param delegate the delegate + * @param isInput the is input + */ private void addSofasToAllComponentSofaMap(Map allComponentSofas, String key, ResourceSpecifier delegate, boolean isInput) { // delegates can be AnalysisEngines, CasConsmers, flowControllers, or remotes @@ -326,8 +393,10 @@ public class SofaMapSection extends Abst } /** - * - * @param aggrSofa + * Gets the avail and bound sofas. + * + * @param aggrSofa the aggr sofa + * @param availOnly the avail only * @return a Map, keys = component/sofaname, value = aggrsofa or null */ private Map getAvailAndBoundSofas(String aggrSofa, boolean availOnly) { @@ -375,6 +444,12 @@ public class SofaMapSection extends Abst return allComponentSofas; } + /** + * Checks if is input. + * + * @param sofaName the sofa name + * @return true, if is input + */ private boolean isInput(String sofaName) { String[][] sns = getCapabilitySofaNames(); for (int i = 0; i < sns[0].length; i++) { @@ -384,6 +459,12 @@ public class SofaMapSection extends Abst return false; } + /** + * Adds the aggr. + * + * @param aggrSofa the aggr sofa + * @param sofaNames the sofa names + */ private void addAggr(String aggrSofa, String[] sofaNames) { SofaMapping[] newSofas = new SofaMapping[sofaNames.length]; for (int i = 0; i < sofaNames.length; i++) { @@ -399,8 +480,14 @@ public class SofaMapSection extends Abst editor.getAeDescription().setSofaMappings(result); } + /** + * Removes the aggr. + * + * @param aggrSofa the aggr sofa + */ private void removeAggr(String aggrSofa) { Comparator comparator = new Comparator() { + @Override public int compare(Object aggrSofaName, Object o2) { SofaMapping sofaMapping = (SofaMapping) o2; if (sofaMapping.getAggregateSofaName().equals(aggrSofaName)) @@ -414,6 +501,11 @@ public class SofaMapSection extends Abst SofaMapping.class, comparator)); } + /** + * Removes the aggr. + * + * @param selected the selected + */ private void removeAggr(TreeItem selected) { if (Window.CANCEL == Utility .popOkCancel( @@ -428,12 +520,13 @@ public class SofaMapSection extends Abst /** * Removes a delegate map from a particular aggr sofa mapping. - * - * @param selected + * + * @param selected the selected */ private void removeComponentFromAggr(TreeItem selected) { final String aggrName = selected.getParentItem().getText(); Comparator comparator = new Comparator() { + @Override public int compare(Object componentAndSofa, Object o2) { SofaMapping sofaMapping = (SofaMapping) o2; if (!sofaMapping.getAggregateSofaName().equals(aggrName)) @@ -465,10 +558,10 @@ public class SofaMapSection extends Abst /** * Called when removing a delegate from the aggr. Removes from the sofaMappings, any and all * mappings associated with the delegate. - * - * @param componentKey - * @param delegate - * @param pEditor + * + * @param componentKey the component key + * @param delegate the delegate + * @param pEditor the editor */ public static void removeSofaMappings(String componentKey, ResourceSpecifier delegate, MultiPageEditor pEditor) { @@ -477,6 +570,7 @@ public class SofaMapSection extends Abst inOut[0].addAll(inOut[1]); final Set allDelegateComponentSofas = inOut[0]; Comparator comparator = new Comparator() { + @Override public int compare(Object ignore, Object elementOfArray) { SofaMapping sofaMapping = (SofaMapping) elementOfArray; String key = sofaMapping.getComponentKey(); @@ -495,6 +589,12 @@ public class SofaMapSection extends Abst } } + /** + * Gets the sofa only. + * + * @param componentAndSofa the component and sofa + * @return the sofa only + */ private String getSofaOnly(String componentAndSofa) { int locOfSlash = componentAndSofa.indexOf('/'); if (locOfSlash < 0) @@ -502,6 +602,12 @@ public class SofaMapSection extends Abst return componentAndSofa.substring(locOfSlash + 1); } + /** + * Gets the component only. + * + * @param componentAndSofa the component and sofa + * @return the component only + */ private String getComponentOnly(String componentAndSofa) { int locOfSlash = componentAndSofa.indexOf('/'); if (locOfSlash < 0) @@ -509,6 +615,10 @@ public class SofaMapSection extends Abst return componentAndSofa.substring(0, locOfSlash); } + /* (non-Javadoc) + * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable() + */ + @Override public void enable() { boolean oneSelected = tree.getSelectionCount() == 1; boolean topLevelSelected = false; Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java?rev=1863399&r1=1863398&r2=1863399&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java Fri Jul 19 14:26:19 2019 @@ -548,7 +548,7 @@ public class TypeSection extends Abstrac TreeItem[] items = tt.getItems(); for (int i = 0; i < items.length; i++) { if (td.getName().equals(((TypeDescription) items[i].getData()).getName())) { - tt.setSelection(new TreeItem[] { items[i] }); + tt.setSelection( items[i]); return; } } @@ -1009,9 +1009,7 @@ public class TypeSection extends Abstrac removeAllowedValue(td, av); // update GUI - TreeItem selectedItem = tt.getSelection()[0]; - tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]); -// tt.setSelection(tt.getTable().getSelectionIndex() - 1); + setSelectionOneUp(tt, item); item.dispose(); } else { refresh(); @@ -1028,7 +1026,7 @@ public class TypeSection extends Abstrac * @param item the item */ // same - for built-in <could be created outside of the CDE> - private void handleRemoveFeature(TreeItem item) { + private void handleRemoveFeature(final TreeItem item) { TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem()); FeatureDescription fd = getFeatureDescriptionFromTableTreeItem(item); @@ -1055,8 +1053,7 @@ public class TypeSection extends Abstrac refresh(); else { // update GUI - TreeItem selectedItem = tt.getSelection()[0]; - tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]); + setSelectionOneUp(tt, item); // tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1); item.dispose(); } @@ -1156,7 +1153,7 @@ public class TypeSection extends Abstrac * * @param item the item */ - private void handleRemoveType(TreeItem item) { + private void handleRemoveType(final TreeItem item) { TypeDescription td = getTypeDescriptionFromTableTreeItem(item); @@ -1190,9 +1187,7 @@ public class TypeSection extends Abstrac } else { removeType(td, getMergedTypeSystemDescription()); // update GUI - TreeItem selectedItem = tt.getSelection()[0]; - tt.setSelection(tt.getItems()[tt.indexOf(selectedItem) - 1]); -// tt.getTable().setSelection(tt.getTable().getSelectionIndex() - 1); + setSelectionOneUp(tt, item); item.dispose(); }