Author: schor Date: Wed Jul 17 18:58:38 2019 New Revision: 1863233 URL: http://svn.apache.org/viewvc?rev=1863233&view=rev Log: [UIMA-6094] merge from uv3
Modified: uima/uimaj/trunk/uimaj-ep-configurator/pom.xml 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/AggregateSection.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/TypeSection.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialog.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AbstractDialogMultiColTable.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityFeatureDialog.java uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/dialogs/AddCapabilityTypeDialog.java Modified: uima/uimaj/trunk/uimaj-ep-configurator/pom.xml URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/pom.xml?rev=1863233&r1=1863232&r2=1863233&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/pom.xml (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/pom.xml Wed Jul 17 18:58:38 2019 @@ -314,7 +314,7 @@ </Export-Package> <Bundle-Activator>org.apache.uima.taeconfigurator.TAEConfiguratorPlugin</Bundle-Activator> <Bundle-SymbolicName>org.apache.uima.desceditor;singleton:=true</Bundle-SymbolicName> - <Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment> + <Bundle-RequiredExecutionEnvironment>JavaSE-1.8</Bundle-RequiredExecutionEnvironment> <!-- handle split packages in Eclipse. We do this by using Require-Bundle, and excluding from the Import-Package those 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=1863233&r1=1863232&r2=1863233&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 Wed Jul 17 18:58:38 2019 @@ -27,14 +27,21 @@ 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; + +/** + * The Class AbstractImportablePartSection. + */ public abstract class AbstractImportablePartSection extends AbstractSection { /** - * @param aEditor - * @param parent - * @param headerText - * @param description + * Instantiates a new abstract importable part section. + * + * @param aEditor the a editor + * @param parent the parent + * @param headerText the header text + * @param description the description */ public AbstractImportablePartSection(MultiPageEditor aEditor, Composite parent, String headerText, String description) { @@ -43,8 +50,14 @@ public abstract class AbstractImportable // ******************************** // * GUI methods + /** + * Checks if is local item. + * + * @param item the item + * @return true, if is local item + */ // ******************************** - protected boolean isLocalItem(TableTreeItem item) { + protected boolean isLocalItem(TreeItem item) { return !item.getForeground().equals(editor.getFadeColor()); } @@ -52,10 +65,11 @@ public abstract class AbstractImportable // * Universal Getters // ******************************** /** - * returns null if no feature by this name + * returns null if no feature by this name. * - * @param name - * @param td + * @param name the name + * @param td the td + * @return the feature from type description */ public FeatureDescription getFeatureFromTypeDescription(String name, TypeDescription td) { FeatureDescription[] fds = td.getFeatures(); @@ -68,6 +82,13 @@ public abstract class AbstractImportable return null; } + /** + * Gets the allowed value. + * + * @param value the value + * @param td the td + * @return the allowed value + */ public AllowedValue getAllowedValue(String value, TypeDescription td) { AllowedValue[] avs = td.getAllowedValues(); if (null == avs) @@ -83,6 +104,12 @@ public abstract class AbstractImportable // * Local Getters // ******************************** + /** + * Gets the local type definition. + * + * @param td the td + * @return the local type definition + */ protected TypeDescription getLocalTypeDefinition(TypeDescription td) { TypeSystemDescription tsdLocal = getTypeSystemDescription(); if (null == tsdLocal) @@ -90,10 +117,24 @@ public abstract class AbstractImportable return tsdLocal.getType(td.getName()); } + /** + * Gets the local feature definition. + * + * @param td the td + * @param fd the fd + * @return the local feature definition + */ protected FeatureDescription getLocalFeatureDefinition(TypeDescription td, FeatureDescription fd) { return getLocalFeatureDefinition(td, fd.getName()); } + /** + * Gets the local feature definition. + * + * @param td the td + * @param featureName the feature name + * @return the local feature definition + */ protected FeatureDescription getLocalFeatureDefinition(TypeDescription td, String featureName) { TypeDescription localTd = getLocalTypeDefinition(td); if (null == localTd) @@ -101,6 +142,13 @@ public abstract class AbstractImportable return getFeatureFromTypeDescription(featureName, localTd); } + /** + * Gets the local allowed value. + * + * @param td the td + * @param unchangedAv the unchanged av + * @return the local allowed value + */ protected AllowedValue getLocalAllowedValue(TypeDescription td, AllowedValue unchangedAv) { TypeDescription localTd = getLocalTypeDefinition(td); if (null == localTd) @@ -111,6 +159,12 @@ public abstract class AbstractImportable // ******************************** // * Built-in Getters // * used to do GUI "merge" with built-in things + /** + * Gets the built in type description. + * + * @param td the td + * @return the built in type description + */ // ******************************** public TypeDescription getBuiltInTypeDescription(TypeDescription td) { return (TypeDescription) BuiltInTypes.typeDescriptions.get(td.getName()); @@ -118,19 +172,45 @@ public abstract class AbstractImportable // ******************************** // * Local Testers + /** + * Checks if is local type. + * + * @param td the td + * @return true, if is local type + */ // ******************************** protected boolean isLocalType(TypeDescription td) { return (null != getLocalTypeDefinition(td)); } + /** + * Checks if is local type. + * + * @param typeName the type name + * @return true, if is local type + */ protected boolean isLocalType(String typeName) { return null != editor.getTypeSystemDescription().getType(typeName); } + /** + * Checks if is local feature. + * + * @param featureName the feature name + * @param td the td + * @return true, if is local feature + */ protected boolean isLocalFeature(String featureName, TypeDescription td) { return (null != getLocalFeatureDefinition(td, featureName)); } + /** + * Checks if is local allowed value. + * + * @param avString the av string + * @param td the td + * @return true, if is local allowed value + */ protected boolean isLocalAllowedValue(String avString, TypeDescription td) { TypeDescription localTd = getLocalTypeDefinition(td); if (null == localTd) @@ -142,14 +222,33 @@ public abstract class AbstractImportable // * Imported Testers // ******************************** + /** + * Checks if is imported type. + * + * @param typeName the type name + * @return true, if is imported type + */ public boolean isImportedType(String typeName) { return null != editor.getImportedTypeSystemDesription().getType(typeName); } + /** + * Checks if is imported type. + * + * @param td the td + * @return true, if is imported type + */ protected boolean isImportedType(TypeDescription td) { return null != editor.getImportedTypeSystemDesription().getType(td.getName()); } + /** + * Checks if is imported feature. + * + * @param name the name + * @param td the td + * @return true, if is imported feature + */ protected boolean isImportedFeature(String name, TypeDescription td) { TypeDescription importedTd = editor.getImportedTypeSystemDesription().getType(td.getName()); if (null == importedTd) @@ -157,6 +256,13 @@ public abstract class AbstractImportable return null != getFeatureFromTypeDescription(name, importedTd); } + /** + * Checks if is imported allowed value. + * + * @param td the td + * @param av the av + * @return true, if is imported allowed value + */ protected boolean isImportedAllowedValue(TypeDescription td, AllowedValue av) { TypeDescription importedTd = editor.getImportedTypeSystemDesription().getType(td.getName()); if (null == importedTd) @@ -166,15 +272,34 @@ public abstract class AbstractImportable // ******************************** // * Built-in Testers + /** + * Checks if is built in type. + * + * @param td the td + * @return true, if is built in type + */ // ******************************** protected boolean isBuiltInType(TypeDescription td) { return null != getBuiltInTypeDescription(td); } + /** + * Checks if is built in type. + * + * @param typeName the type name + * @return true, if is built in type + */ protected boolean isBuiltInType(String typeName) { return null != BuiltInTypes.typeDescriptions.get(typeName); } + /** + * Checks if is built in feature. + * + * @param name the name + * @param td the td + * @return true, if is built in feature + */ protected boolean isBuiltInFeature(String name, TypeDescription td) { TypeDescription builtInTd = (TypeDescription) BuiltInTypes.typeDescriptions.get(td.getName()); if (null == builtInTd) 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=1863233&r1=1863232&r2=1863233&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 Wed Jul 17 18:58:38 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; @@ -118,57 +117,94 @@ import org.eclipse.ui.forms.widgets.Expa import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; + +/** + * The Class AbstractSection. + */ public abstract class AbstractSection extends SectionPart /* extends FormSection */ implements Listener, StandardStrings { + /** The toolkit. */ protected FormToolkit toolkit; + /** The editor. */ public MultiPageEditor editor; + /** + * Gets the toolkit. + * + * @return the toolkit + */ public FormToolkit getToolkit() { return toolkit; } + /** The Constant IMPORTABLE_PART_CONTEXT. */ public final static String IMPORTABLE_PART_CONTEXT = "ipc"; + /** The Constant PLUGIN_ID. */ public final static String PLUGIN_ID = "org.apache.uima.desceditor"; + /** The Constant SELECTED. */ public final static boolean SELECTED = true; + /** The Constant NOT_SELECTED. */ public final static boolean NOT_SELECTED = false; + /** The Constant ENABLED. */ public final static boolean ENABLED = true; + /** The Constant EQUAL_WIDTH. */ public final static boolean EQUAL_WIDTH = true; + /** The Constant treeItemArray0. */ public final static TreeItem[] treeItemArray0 = new TreeItem[0]; + /** The Constant configurationGroup0. */ public final static ConfigurationGroup[] configurationGroup0 = new ConfigurationGroup[0]; + /** The Constant configurationParameter0. */ public final static ConfigurationParameter[] configurationParameter0 = new ConfigurationParameter[0]; + /** The Constant capabilityArray0. */ public final static Capability[] capabilityArray0 = new Capability[0]; + /** The Constant featureDescriptionArray0. */ public final static FeatureDescription[] featureDescriptionArray0 = new FeatureDescription[0]; + /** The Constant sofaMapping0. */ public final static SofaMapping[] sofaMapping0 = new SofaMapping[0]; + /** The Constant fsIndexDescription0. */ public final static FsIndexDescription[] fsIndexDescription0 = new FsIndexDescription[0]; + /** The Constant externalResourceBinding0. */ public final static ExternalResourceBinding[] externalResourceBinding0 = new ExternalResourceBinding[0]; + /** The Constant externalResourceDescription0. */ public final static ExternalResourceDescription[] externalResourceDescription0 = new ExternalResourceDescription[0]; + /** The Constant typeDescription0. */ public final static TypeDescription[] typeDescription0 = new TypeDescription[0]; + /** The Constant typePriorityList0. */ public final static TypePriorityList[] typePriorityList0 = new TypePriorityList[0]; + /** The initial form width. */ protected int initialFormWidth; // width of the form before putting controls in it + /** + * Instantiates a new abstract section. + * + * @param aEditor the a editor + * @param parent the parent + * @param headerText the header text + * @param description the description + */ public AbstractSection(MultiPageEditor aEditor, Composite parent, String headerText, String description) { super(parent, aEditor.getToolkit(), ((null != description) ? Section.DESCRIPTION : 0) - | Section.TWISTIE | Section.EXPANDED); + | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); toolkit = aEditor.getToolkit(); getSection().setText(headerText); getSection().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); @@ -178,6 +214,10 @@ implements Listener, StandardStrings { editor = aEditor; } + /* (non-Javadoc) + * @see org.eclipse.ui.forms.AbstractFormPart#initialize(org.eclipse.ui.forms.IManagedForm) + */ + @Override public void initialize(IManagedForm form) { super.initialize(form); getSection().setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -187,10 +227,16 @@ implements Listener, StandardStrings { // * Subclasses need to implement these methods // ************************************************** + /** + * Enable. + */ public abstract void enable(); // ************************************************** // * convenience methods + /** + * Sets the file dirty. + */ // ************************************************** protected void setFileDirty() { editor.setFileDirty(); @@ -198,23 +244,54 @@ implements Listener, StandardStrings { // ************************************************** // * Creating Composites + /** + * New composite. + * + * @param parent the parent + * @return the composite + */ // ************************************************** public Composite newComposite(Composite parent) { return newNcolumnComposite(parent, 1); } + /** + * New 2 column composite. + * + * @param parent the parent + * @return the composite + */ public Composite new2ColumnComposite(Composite parent) { return newNcolumnComposite(parent, 2); } + /** + * New 3 column composite. + * + * @param parent the parent + * @return the composite + */ public Composite new3ColumnComposite(Composite parent) { return newNcolumnComposite(parent, 3); } + /** + * New 4 column composite. + * + * @param parent the parent + * @return the composite + */ public Composite new4ColumnComposite(Composite parent) { return newNcolumnComposite(parent, 4); } + /** + * New ncolumn composite. + * + * @param parent the parent + * @param cols the cols + * @return the composite + */ public Composite newNcolumnComposite(Composite parent, int cols) { Composite composite = toolkit.createComposite(parent); if (parent instanceof ExpandableComposite) @@ -227,12 +304,24 @@ implements Listener, StandardStrings { return composite; } + /** + * Sets the margins. + * + * @param composite the composite + * @param height the height + * @param width the width + */ public void setMargins(Composite composite, int height, int width) { GridLayout g = (GridLayout) composite.getLayout(); g.marginHeight = height; g.marginWidth = width; } + /** + * Enable borders. + * + * @param composite the composite + */ public void enableBorders(Composite composite) { GridLayout g = (GridLayout) composite.getLayout(); if (g.marginHeight < 2) @@ -243,15 +332,31 @@ implements Listener, StandardStrings { // ************************************************** // * Special Composites to hold buttons + /** The Constant VERTICAL_BUTTONS. */ // ************************************************** final static public int VERTICAL_BUTTONS = 1; + /** The Constant HORIZONTAL_BUTTONS. */ final static public int HORIZONTAL_BUTTONS = 2; + /** + * New button container. + * + * @param parent the parent + * @return the composite + */ public Composite newButtonContainer(Composite parent) { return newButtonContainer(parent, VERTICAL_BUTTONS, 0); } + /** + * New button container. + * + * @param parent the parent + * @param style the style + * @param widthMin the width min + * @return the composite + */ public Composite newButtonContainer(Composite parent, int style, int widthMin) { Composite buttonContainer = toolkit.createComposite(parent); GridLayout gl = new GridLayout(); @@ -297,10 +402,27 @@ implements Listener, StandardStrings { // * Widgets // ************************************************** + /** + * New labeled text field. + * + * @param parent the parent + * @param label the label + * @param tip the tip + * @return the text + */ protected Text newLabeledTextField(Composite parent, String label, String tip) { return newLabeledTextField(parent, label, tip, SWT.NONE); } + /** + * New labeled text field. + * + * @param parent the parent + * @param labelKey the label key + * @param textToolTip the text tool tip + * @param style the style + * @return the text + */ protected Text newLabeledTextField(Composite parent, String labelKey, String textToolTip, int style) { enableBorders(parent); @@ -312,10 +434,27 @@ implements Listener, StandardStrings { return newTextWithTip(parent, "", style, textToolTip); //$NON-NLS-1$ } + /** + * New text with tip. + * + * @param parent the parent + * @param initialTxt the initial txt + * @param tip the tip + * @return the text + */ protected Text newTextWithTip(Composite parent, String initialTxt, String tip) { return newTextWithTip(parent, initialTxt, SWT.NONE, tip); } + /** + * New text with tip. + * + * @param parent the parent + * @param text the text + * @param style the style + * @param tip the tip + * @return the text + */ protected Text newTextWithTip(Composite parent, String text, int style, String tip) { Text t = toolkit.createText(parent, text, style); t.setToolTipText(tip); @@ -328,20 +467,52 @@ implements Listener, StandardStrings { return t; } + /** + * New label with data. + * + * @param parent the parent + * @param text the text + * @return the label + */ public Label newLabelWithData(Composite parent, String text) { return newLabelWithTip(parent, text, ""); //$NON-NLS-1$ } + /** + * New label with tip. + * + * @param parent the parent + * @param text the text + * @param tip the tip + * @return the label + */ public Label newLabelWithTip(Composite parent, String text, String tip) { return newLabelWithTip(parent, text, tip, SWT.NULL); } + /** + * New un updatable text with tip. + * + * @param parent the parent + * @param text the text + * @param tip the tip + * @return the label + */ public Label newUnUpdatableTextWithTip(Composite parent, String text, String tip) { Label label = newLabelWithTip(parent, text, tip, SWT.BORDER); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); return label; } + /** + * New label with tip. + * + * @param parent the parent + * @param text the text + * @param tip the tip + * @param style the style + * @return the label + */ public Label newLabelWithTip(Composite parent, String text, String tip, int style) { Label t = toolkit.createLabel(parent, text, style); if ((tip != null) && (tip.length()) > 0) @@ -349,11 +520,26 @@ implements Listener, StandardStrings { return t; } + /** + * New labeled C combo with tip. + * + * @param parent the parent + * @param labelKey the label key + * @param tip the tip + * @return the c combo + */ protected CCombo newLabeledCComboWithTip(Composite parent, String labelKey, String tip) { newLabelWithTip(parent, labelKey, tip); return newCComboWithTip(parent, tip); } + /** + * New C combo with tip. + * + * @param parent the parent + * @param tip the tip + * @return the c combo + */ protected CCombo newCComboWithTip(Composite parent, String tip) { CCombo ccombo = new CCombo(parent, SWT.FLAT | SWT.READ_ONLY); toolkit.adapt(ccombo, false, false); @@ -367,12 +553,28 @@ implements Listener, StandardStrings { return ccombo; } + /** + * New description text box. + * + * @param parent the parent + * @param tip the tip + * @return the text + */ protected Text newDescriptionTextBox(Composite parent, String tip) { return newLabeledTextField(parent, S_DESCRIPTION, tip, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); } // ************************************************** // * Widgets Buttons + /** + * New radio button. + * + * @param parent the parent + * @param label the label + * @param toolTip the tool tip + * @param selected the selected + * @return the button + */ // ************************************************** public Button newRadioButton(Composite parent, String label, String toolTip, boolean selected) { Button button = toolkit.createButton(parent, label, SWT.RADIO); @@ -383,11 +585,11 @@ implements Listener, StandardStrings { } /** - * add pushbutton to container, set enabled, add listener for it - * - * @param parent - * @param label - * @param tip + * add pushbutton to container, set enabled, add listener for it. + * + * @param parent the parent + * @param label the label + * @param tip the tip * @return the push button */ public Button newPushButton(Composite parent, String label, String tip) { @@ -395,17 +597,28 @@ implements Listener, StandardStrings { } /** - * Add a push button to a container, add a listener for it too - * - * @param parent - * @param label - * @param enabled + * Add a push button to a container, add a listener for it too. + * + * @param parent the parent + * @param label the label + * @param tip the tip + * @param enabled the enabled * @return the pushbutton */ public Button newPushButton(Composite parent, String label, String tip, boolean enabled) { return newPushButton(parent, label, tip, enabled, 0); } + /** + * New push button. + * + * @param parent the parent + * @param label the label + * @param tip the tip + * @param enabled the enabled + * @param style the style + * @return the button + */ public Button newPushButton(Composite parent, String label, String tip, boolean enabled, int style) { Button button = toolkit.createButton(parent, label, SWT.PUSH | style); GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); @@ -420,6 +633,14 @@ implements Listener, StandardStrings { return button; } + /** + * New check box. + * + * @param parent the parent + * @param label the label + * @param tip the tip + * @return the button + */ public Button newCheckBox(Composite parent, String label, String tip) { Button button = toolkit.createButton(parent, label, SWT.CHECK); button.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING @@ -430,6 +651,11 @@ implements Listener, StandardStrings { return button; } + /** + * Spacer. + * + * @param container the container + */ public static void spacer(Composite container) { Label label = new Label(container, SWT.NONE); label.setVisible(false); @@ -438,26 +664,54 @@ implements Listener, StandardStrings { // ************************************************** // * Tables + /** The Constant NO_MIN_HEIGHT. */ // ************************************************** final public static int NO_MIN_HEIGHT = -1; + /** The Constant NOTHING_SELECTED. */ final public static int NOTHING_SELECTED = -1; + /** The Constant LINES_VISIBLE. */ // these flags can be or-ed together final public static int LINES_VISIBLE = 1; + /** The Constant HEADER_VISIBLE. */ final public static int HEADER_VISIBLE = 2; + /** The Constant WIDTH_NOT_SPECIFIED. */ final public static int WIDTH_NOT_SPECIFIED = 0; + /** + * New table. + * + * @param parent the parent + * @return the table + */ protected Table newTable(Composite parent) { return newTable(parent, SWT.FULL_SELECTION, NO_MIN_HEIGHT, 0); } + /** + * New table. + * + * @param parent the parent + * @param style the style + * @param minHeight the min height + * @return the table + */ protected Table newTable(Composite parent, int style, int minHeight) { return newTable(parent, style, minHeight, 0); } + /** + * New table. + * + * @param parent the parent + * @param style the style + * @param minHeight the min height + * @param flags the flags + * @return the table + */ protected Table newTable(Composite parent, int style, int minHeight, int flags) { Table table = toolkit.createTable(parent, style); GridData gd = new GridData(GridData.FILL_BOTH); @@ -472,14 +726,27 @@ implements Listener, StandardStrings { return table; } + /** + * New tree. + * + * @param parent the parent + * @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; } + /** + * Gets the previous selection. + * + * @param items the items + * @param nextItem the next item + * @return the previous selection + */ protected TreeItem getPreviousSelection(TreeItem[] items, TreeItem nextItem) { TreeItem prevItem = nextItem.getParentItem(); for (int i = 0; i < items.length; i++) { @@ -490,6 +757,13 @@ implements Listener, StandardStrings { return prevItem; } + /** + * Gets the item index. + * + * @param items the items + * @param item the item + * @return the item index + */ protected int getItemIndex(TreeItem[] items, TreeItem item) { for (int i = 0; i < items.length; i++) { if (items[i] == item) @@ -499,18 +773,19 @@ implements Listener, StandardStrings { } /** - * @param parent - * @param style - * SWT.SINGLE SWT.MULTI SWT.CHECK SWT.FULL_SELECTION + * 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); @@ -520,6 +795,11 @@ implements Listener, StandardStrings { return tt; } + /** + * Pack table. + * + * @param table the table + */ public void packTable(Table table) { TableColumn[] columns = table.getColumns(); for (int i = 0; i < columns.length; i++) { @@ -527,6 +807,25 @@ 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. + * + * @param item the item + * @return the index + */ public static int getIndex(TableItem item) { Table parent = item.getParent(); TableItem[] items = parent.getItems(); @@ -537,9 +836,15 @@ implements Listener, StandardStrings { throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$ } - public static int getIndex(TableTreeItem item) { - TableTreeItem parent = item.getParentItem(); - TableTreeItem[] items = (null == parent) ? item.getParent().getItems() : parent.getItems(); + /** + * Gets the index. + * + * @param item the item + * @return the index + */ + 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; @@ -547,14 +852,24 @@ implements Listener, StandardStrings { throw new InternalErrorCDE("invalid state"); //$NON-NLS-1$ } - 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. + * + * @param item the item + */ protected void removeChildren(TreeItem item) { TreeItem[] items = item.getItems(); if (null != items) @@ -565,15 +880,61 @@ implements Listener, StandardStrings { // ********************************** // * Table Column with header setting + /** + * New table column. + * + * @param table the table + * @return the table column + */ // ********************************** 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. + * + * @param container the container + * @param header the header + * @return the table column + */ 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. + * + * @param container the container + * @param width the width + * @param alignment the alignment + * @param header the header + * @return the table column + */ protected TableColumn newTableColumn(Table container, int width, int alignment, String header) { TableColumn tc = new TableColumn(container, alignment); if (header != null && (!header.equals(""))) { //$NON-NLS-1$ @@ -582,93 +943,231 @@ 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. + * + * @param container the container + * @param width the width + * @return the table column + */ protected TableColumn newTableColumn(Table container, int width) { 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 // ************************************************** + /** + * Checks if is primitive. + * + * @return true, if is primitive + */ public boolean isPrimitive() { return editor.isPrimitive(); } + /** + * Checks if is aggregate. + * + * @return true, if is aggregate + */ public boolean isAggregate() { return editor.isAggregate(); } + /** + * Checks if is ae descriptor. + * + * @return true, if is ae descriptor + */ public boolean isAeDescriptor() { return editor.isAeDescriptor(); } + /** + * Checks if is type system descriptor. + * + * @return true, if is type system descriptor + */ public boolean isTypeSystemDescriptor() { return editor.isTypeSystemDescriptor(); } + /** + * Checks if is index descriptor. + * + * @return true, if is index descriptor + */ public boolean isIndexDescriptor() { return editor.isFsIndexCollection(); } + /** + * Checks if is type priority descriptor. + * + * @return true, if is type priority descriptor + */ public boolean isTypePriorityDescriptor() { return editor.isTypePriorityDescriptor(); } + /** + * Checks if is ext res and bindings descriptor. + * + * @return true, if is ext res and bindings descriptor + */ public boolean isExtResAndBindingsDescriptor() { return editor.isExtResAndBindingsDescriptor(); } + /** + * Checks if is collection reader descriptor. + * + * @return true, if is collection reader descriptor + */ public boolean isCollectionReaderDescriptor() { return editor.isCollectionReaderDescriptor(); } + /** + * Checks if is cas initializer descriptor. + * + * @return true, if is cas initializer descriptor + */ public boolean isCasInitializerDescriptor() { return editor.isCasInitializerDescriptor(); } + /** + * Checks if is cas consumer descriptor. + * + * @return true, if is cas consumer descriptor + */ public boolean isCasConsumerDescriptor() { return editor.isCasConsumerDescriptor(); } + /** + * Checks if is flow controller descriptor. + * + * @return true, if is flow controller descriptor + */ public boolean isFlowControllerDescriptor() { return editor.isFlowControllerDescriptor(); } + /** + * Checks if is local processing descriptor. + * + * @return true, if is local processing descriptor + */ public boolean isLocalProcessingDescriptor() { return editor.isLocalProcessingDescriptor(); } + /** + * Gets the analysis engine meta data. + * + * @return the analysis engine meta data + */ public AnalysisEngineMetaData getAnalysisEngineMetaData() { return editor.getAeDescription().getAnalysisEngineMetaData(); } + /** + * Gets the flow controller declaration. + * + * @return the flow controller declaration + */ public FlowControllerDeclaration getFlowControllerDeclaration() { return editor.getAeDescription().getFlowControllerDeclaration(); } + /** + * Sets the flow controller declaration. + * + * @param fcd the new flow controller declaration + */ public void setFlowControllerDeclaration(FlowControllerDeclaration fcd) { editor.getAeDescription().setFlowControllerDeclaration(fcd); } + /** + * Gets the operational properties. + * + * @return the operational properties + */ public OperationalProperties getOperationalProperties() { return editor.getAeDescription().getAnalysisEngineMetaData().getOperationalProperties(); } + /** + * Gets the sofa mappings. + * + * @return the sofa mappings + */ public SofaMapping[] getSofaMappings() { SofaMapping[] sofaMappings = editor.getAeDescription().getSofaMappings(); return null == sofaMappings ? sofaMapping0 : sofaMappings; } + /** + * Gets the sofa mappings. + * + * @param pEditor the editor + * @return the sofa mappings + */ public static SofaMapping[] getSofaMappings(MultiPageEditor pEditor) { SofaMapping[] sofaMappings = pEditor.getAeDescription().getSofaMappings(); return null == sofaMappings ? sofaMapping0 : sofaMappings; } + /** + * Gets the delegate analysis engine specifiers with imports. + * + * @return the delegate analysis engine specifiers with imports + */ public Map getDelegateAnalysisEngineSpecifiersWithImports() { return editor.getAeDescription().getDelegateAnalysisEngineSpecifiersWithImports(); } + /** + * Gets the capabilities. + * + * @return the capabilities + */ public Capability[] getCapabilities() { Capability[] c = getAnalysisEngineMetaData().getCapabilities(); if (null == c) @@ -676,14 +1175,29 @@ implements Listener, StandardStrings { return c; } + /** + * Gets the merged type system description. + * + * @return the merged type system description + */ protected TypeSystemDescription getMergedTypeSystemDescription() { return editor.getMergedTypeSystemDescription(); } + /** + * Gets the type system description. + * + * @return the type system description + */ protected TypeSystemDescription getTypeSystemDescription() { return editor.getTypeSystemDescription(); } + /** + * Gets the type priorities. + * + * @return the type priorities + */ protected TypePriorities getTypePriorities() { TypePriorities tps = getAnalysisEngineMetaData().getTypePriorities(); if (null == tps) { @@ -693,14 +1207,24 @@ implements Listener, StandardStrings { return tps; } + /** The Constant stringArray0. */ public final static String[] stringArray0 = new String[0]; + /** The Constant configurationParameterArray0. */ public final static ConfigurationParameter[] configurationParameterArray0 = new ConfigurationParameter[0]; + /** The Constant configurationGroupArray0. */ public final static ConfigurationGroup[] configurationGroupArray0 = new ConfigurationGroup[0]; + /** The Constant nameValuePairArray0. */ public final static NameValuePair[] nameValuePairArray0 = new NameValuePair[0]; + /** + * Gets the available type names. + * + * @param excluded the excluded + * @return the available type names + */ public String[] getAvailableTypeNames(Set excluded) { Map allTypes = editor.allTypes.get(); Collection availableTypes = new ArrayList(); @@ -715,6 +1239,11 @@ implements Listener, StandardStrings { // ************ // * Parameters + /** + * Checks if is parm group. + * + * @return true, if is parm group + */ // ************ public boolean isParmGroup() { ConfigurationParameterDeclarations lcpd = getAnalysisEngineMetaData() @@ -723,6 +1252,11 @@ implements Listener, StandardStrings { || (lcpd.getConfigurationGroups() != null && lcpd.getConfigurationGroups().length > 0); } + /** + * Gets the configuration parameter declarations. + * + * @return the configuration parameter declarations + */ public ConfigurationParameterDeclarations getConfigurationParameterDeclarations() { return editor.getAeDescription().getAnalysisEngineMetaData() .getConfigurationParameterDeclarations(); @@ -732,6 +1266,11 @@ implements Listener, StandardStrings { // * Common GUI state access // ************************************************** + /** + * Gets the resource manager configuration. + * + * @return the resource manager configuration + */ public ResourceManagerConfiguration getResourceManagerConfiguration() { ResourceManagerConfiguration rmc = editor.getAeDescription().getResourceManagerConfiguration(); if (null == rmc) { @@ -741,6 +1280,11 @@ implements Listener, StandardStrings { return rmc; } + /** + * Gets the external resource dependencies. + * + * @return the external resource dependencies + */ public ExternalResourceDependency[] getExternalResourceDependencies() { ExternalResourceDependency[] erd = editor.getAeDescription().getExternalResourceDependencies(); if (null == erd) { @@ -749,6 +1293,11 @@ implements Listener, StandardStrings { return erd; } + /** + * Gets the external resource bindings. + * + * @return the external resource bindings + */ public ExternalResourceBinding[] getExternalResourceBindings() { ExternalResourceBinding[] erb = getResourceManagerConfiguration().getExternalResourceBindings(); if (null == erb) @@ -757,6 +1306,11 @@ implements Listener, StandardStrings { return erb; } + /** + * Gets the external resources. + * + * @return the external resources + */ public ExternalResourceDescription[] getExternalResources() { ExternalResourceDescription[] erd = getResourceManagerConfiguration().getExternalResources(); if (null == erd) @@ -767,6 +1321,11 @@ implements Listener, StandardStrings { // ************************************************** // * Common Listener things + /** + * Adds the listener for pastable widget. + * + * @param w the w + */ // ************************************************** protected void addListenerForPastableWidget(Widget w) { w.addListener(SWT.KeyUp, this); @@ -777,8 +1336,16 @@ implements Listener, StandardStrings { // * Common Actions in Handlers // ************************************************** + /** The value changed. */ protected boolean valueChanged; + /** + * Sets the value changed. + * + * @param newValue the new value + * @param oldValue the old value + * @return the string + */ protected String setValueChanged(String newValue, String oldValue) { if (null == newValue) valueChanged = valueChanged || (null != oldValue); @@ -787,18 +1354,39 @@ implements Listener, StandardStrings { return newValue; } + /** + * Sets the value changed int. + * + * @param newValue the new value + * @param oldValue the old value + * @return the int + */ protected int setValueChangedInt(int newValue, int oldValue) { if (newValue != oldValue) valueChanged = true; return newValue; } + /** + * Sets the value changed boolean. + * + * @param newValue the new value + * @param oldValue the old value + * @return true, if successful + */ protected boolean setValueChangedBoolean(boolean newValue, boolean oldValue) { if (newValue != oldValue) valueChanged = true; return newValue; } + /** + * Sets the value changed capital boolean. + * + * @param newValue the new value + * @param oldValue the old value + * @return the boolean + */ protected Boolean setValueChangedCapitalBoolean(Boolean newValue, Boolean oldValue) { if (null == newValue) { valueChanged |= null != oldValue; @@ -809,6 +1397,13 @@ implements Listener, StandardStrings { return newValue; } + /** + * Sets the value changed keys. + * + * @param newKeys the new keys + * @param oldKeys the old keys + * @return the fs index key description[] + */ protected FsIndexKeyDescription[] setValueChangedKeys(FsIndexKeyDescription[] newKeys, FsIndexKeyDescription[] oldKeys) { if (valueChanged) { @@ -822,12 +1417,22 @@ implements Listener, StandardStrings { return newKeys; } + /** + * Checks if is valid ae. + * + * @return true, if is valid ae + */ protected boolean isValidAe() { if (editor.isValidAE(editor.getAeDescription())) return true; return false; } + /** + * Revert type system. + * + * @param tsd the tsd + */ protected void revertTypeSystem(TypeSystemDescription tsd) { try { editor.setTypeSystemDescription(tsd); @@ -835,6 +1440,13 @@ implements Listener, StandardStrings { } } + /** + * Revert msg. + * + * @param msgTitle the msg title + * @param msgTxt the msg txt + * @param exceptionMessage the exception message + */ protected void revertMsg(String msgTitle, String msgTxt, String exceptionMessage) { Utility.popMessage(msgTitle, msgTxt + "\r\n" + exceptionMessage, //$NON-NLS-1$ MessageDialog.ERROR); @@ -842,9 +1454,10 @@ implements Listener, StandardStrings { } /** - * - * @param msg - * @param msgDetails + * Revert or continue. + * + * @param msg the msg + * @param msgDetails the msg details * @return true to revert, false to continue */ public static boolean revertOrContinue(String msg, String msgDetails) { @@ -855,11 +1468,22 @@ implements Listener, StandardStrings { return false; } + /** + * Mark stale. + * + * @param section the section + */ public void markStale(IFormPart section) { if (section != null) ((AbstractFormPart) section).markStale(); } + /** + * Mark rest of page stale. + * + * @param mform the mform + * @param section the section + */ protected void markRestOfPageStale(IManagedForm mform, AbstractSection section) { if (null == mform) return; @@ -869,20 +1493,37 @@ implements Listener, StandardStrings { } } + /** + * Mark stale if different. + * + * @param thisOne the this one + * @param otherOne the other one + */ protected void markStaleIfDifferent(IFormPart thisOne, IFormPart otherOne) { if (thisOne != otherOne) markStale(otherOne); } + /** + * Multi line fix. + * + * @param s the s + * @return the string + */ protected String multiLineFix(String s) { if (null == s) return null; return s.replaceAll("\\r\\n", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } - /************************************************************************************************* + /** + * *********************************************************************************************** * Augment arrays (make new array, add one item to it at end - * ********************************************************* + * *********************************************************. + * + * @param a the a + * @param s the s + * @return the string[] */ public String[] stringArrayAdd(String[] a, String s) { @@ -895,6 +1536,13 @@ implements Listener, StandardStrings { return newA; } + /** + * String array remove. + * + * @param a the a + * @param s the s + * @return the string[] + */ public String[] stringArrayRemove(String[] a, String s) { String[] result = new String[a.length - 1]; for (int i = 0, j = 0; i < a.length; i++) { @@ -904,6 +1552,13 @@ implements Listener, StandardStrings { return result; } + /** + * Type or feature array add. + * + * @param a the a + * @param item the item + * @return the type or feature[] + */ public TypeOrFeature[] typeOrFeatureArrayAdd(TypeOrFeature[] a, TypeOrFeature item) { if (null == a) return new TypeOrFeature[] { item }; @@ -914,6 +1569,13 @@ implements Listener, StandardStrings { return result; } + /** + * Type or feature array remove. + * + * @param a the a + * @param item the item + * @return the type or feature[] + */ public TypeOrFeature[] typeOrFeatureArrayRemove(TypeOrFeature[] a, TypeOrFeature item) { TypeOrFeature[] result = new TypeOrFeature[a.length - 1]; for (int i = 0, j = 0; i < a.length; i++) { @@ -923,6 +1585,13 @@ implements Listener, StandardStrings { return result; } + /** + * Type or feature array remove. + * + * @param a the a + * @param s the s + * @return the type or feature[] + */ public TypeOrFeature[] typeOrFeatureArrayRemove(TypeOrFeature[] a, String s) { TypeOrFeature[] result = new TypeOrFeature[a.length - 1]; for (int i = 0, j = 0; i < a.length; i++) { @@ -936,6 +1605,13 @@ implements Listener, StandardStrings { return result; } + /** + * Gets the type or feature. + * + * @param a the a + * @param name the name + * @return the type or feature + */ public static TypeOrFeature getTypeOrFeature(TypeOrFeature[] a, String name) { if (null == a) return null; @@ -946,6 +1622,12 @@ implements Listener, StandardStrings { return null; } + /** + * Parses the to fit in tool tips. + * + * @param text the text + * @return the string + */ // tool tips seem to require no blanks following /n on Windows. protected static String parseToFitInToolTips(String text) { if (null == text) @@ -970,6 +1652,12 @@ implements Listener, StandardStrings { return new String(buffer); } + /** + * Format name. + * + * @param name the name + * @return the string + */ public String formatName(String name) { if (null == name) return ""; //$NON-NLS-1$ @@ -978,6 +1666,12 @@ implements Listener, StandardStrings { return getShortName(name); } + /** + * Gets the short name. + * + * @param name the name + * @return the short name + */ public static String getShortName(String name) { if (null == name) return ""; //$NON-NLS-1$ @@ -987,14 +1681,32 @@ implements Listener, StandardStrings { return name.substring(i + 1); } + /** + * Gets the short feature name. + * + * @param name the name + * @return the short feature name + */ public static String getShortFeatureName(String name) { return (name.substring(name.indexOf(':') + 1)); } + /** + * Gets the type from full feature name. + * + * @param name the name + * @return the type from full feature name + */ public static String getTypeFromFullFeatureName(String name) { return (name.substring(0, name.indexOf(':'))); } + /** + * Gets the name space. + * + * @param name the name + * @return the name space + */ public static String getNameSpace(String name) { int i = name.lastIndexOf('.'); if (i < 0) @@ -1004,9 +1716,9 @@ implements Listener, StandardStrings { /** * gets a feature description for a type, including supertypes. - * - * @param td - * @param featureName + * + * @param td the td + * @param featureName the feature name * @return a feature description for a type, including supertypes */ public FeatureDescription getFeature(TypeDescription td, String featureName) { @@ -1018,7 +1730,7 @@ implements Listener, StandardStrings { return features[i]; } if (null != (supertypeName = td.getSupertypeName())) - if (!CAS.TYPE_NAME_TOP.equals(supertypeName)) { //$NON-NLS-1$ + if (!CAS.TYPE_NAME_TOP.equals(supertypeName)) { TypeDescription supertype = getMergedTypeSystemDescription().getType(supertypeName); if (null == supertype) supertype = (TypeDescription) BuiltInTypes.typeDescriptions.get(supertypeName); @@ -1027,6 +1739,12 @@ implements Listener, StandardStrings { return null; } + /** + * Checks if is indexable range. + * + * @param rangeName the range name + * @return true, if is indexable range + */ // means is this range allowed in the UIMA Index Spec as a Key public static boolean isIndexableRange(String rangeName) { return CAS.TYPE_NAME_BYTE.equals(rangeName) || CAS.TYPE_NAME_SHORT.equals(rangeName) @@ -1035,11 +1753,23 @@ implements Listener, StandardStrings { || CAS.TYPE_NAME_STRING.equals(rangeName); } + /** + * Sets the tool tip text. + * + * @param w the w + * @param text the text + */ public static void setToolTipText(Control w, String text) { if (null != text) w.setToolTipText(parseToFitInToolTips(text)); } + /** + * Maybe shorten file name. + * + * @param filePathName the file path name + * @return the string + */ public static String maybeShortenFileName(String filePathName) { if (filePathName.length() > 65) { String pathName = filePathName.replace('\\', '/'); @@ -1050,23 +1780,35 @@ implements Listener, StandardStrings { return filePathName; } - public static void swapTableTreeItems(TableTreeItem itemBelow, int newSelection) { - TableTreeItem parent = itemBelow.getParentItem(); + /** + * Swap tree items. + * + * @param itemBelow the item below + * @param newSelection the new selection + */ + 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] }); } - public static void copyTableTreeItem(TableTreeItem target, TableTreeItem source) { - int columnCount = target.getParent().getTable().getColumnCount(); + /** + * Copy table tree item. + * + * @param target the target + * @param source the source + */ + 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) @@ -1075,8 +1817,14 @@ implements Listener, StandardStrings { target.setData(source.getData()); } - public static void swapIndexKeys(TableTreeItem itemBelow, int newSelection) { - TableTreeItem parent = itemBelow.getParentItem(); + /** + * Swap index keys. + * + * @param itemBelow the item below + * @param newSelection the new selection + */ + public static void swapIndexKeys(TreeItem itemBelow, int newSelection) { + TreeItem parent = itemBelow.getParentItem(); FsIndexDescription fsid = getFsIndexDescriptionFromTableTreeItem(parent); int i = getIndex(itemBelow); FsIndexKeyDescription[] keys = fsid.getKeys(); @@ -1085,9 +1833,15 @@ implements Listener, StandardStrings { keys[i - 1] = temp; // swap items in the GUI - swapTableTreeItems(itemBelow, newSelection); + swapTreeItems(itemBelow, newSelection); } + /** + * Swap table items. + * + * @param itemBelow the item below + * @param newSelection the new selection + */ public static void swapTableItems(TableItem itemBelow, int newSelection) { Table parent = itemBelow.getParent(); int i = getIndex(itemBelow); @@ -1101,6 +1855,12 @@ implements Listener, StandardStrings { parent.setSelection(newSelection); } + /** + * Copy table item. + * + * @param target the target + * @param source the source + */ public static void copyTableItem(TableItem target, TableItem source) { int columnCount = target.getParent().getColumnCount(); for (int i = 0; i < columnCount; i++) { @@ -1111,10 +1871,21 @@ implements Listener, StandardStrings { target.setData(source.getData()); } - public static FsIndexDescription getFsIndexDescriptionFromTableTreeItem(TableTreeItem item) { + /** + * Gets the fs index description from table tree item. + * + * @param item the item + * @return the fs index description from table tree item + */ + public static FsIndexDescription getFsIndexDescriptionFromTableTreeItem(TreeItem item) { return (FsIndexDescription) item.getData(); } + /** + * Gets the capability sofa names. + * + * @return the capability sofa names + */ public String[][] getCapabilitySofaNames() { Set[] inOut = getCapabilitySofaNames(editor.getAeDescription(), null); @@ -1126,6 +1897,12 @@ implements Listener, StandardStrings { return new String[][] { inputSofas, outputSofas }; } + /** + * Gets the capabilities. + * + * @param rs the rs + * @return the capabilities + */ public static Capability[] getCapabilities(ResourceSpecifier rs) { if (rs instanceof ResourceCreationSpecifier) return ((ProcessingResourceMetaData) ((ResourceCreationSpecifier) rs).getMetaData()) @@ -1133,6 +1910,13 @@ implements Listener, StandardStrings { return null; } + /** + * Gets the capability sofa names. + * + * @param rs the rs + * @param componentKey the component key + * @return the capability sofa names + */ protected static Set[] getCapabilitySofaNames(ResourceCreationSpecifier rs, String componentKey) { Capability[] cs = getCapabilities(rs); Set inputSofasSet = new TreeSet(); @@ -1145,6 +1929,13 @@ implements Listener, StandardStrings { return new Set[] { inputSofasSet, outputSofasSet }; } + /** + * Merge sofa names. + * + * @param set the set + * @param items the items + * @param componentKey the component key + */ private static void mergeSofaNames(Set set, String[] items, String componentKey) { if (null != items) { for (int i = 0; i < items.length; i++) { @@ -1157,6 +1948,11 @@ implements Listener, StandardStrings { set.add(componentKey); } + /** + * Adds the capability set. + * + * @return the capability + */ protected Capability addCapabilitySet() { Capability newCset = UIMAFramework.getResourceSpecifierFactory().createCapability(); // update the model @@ -1202,11 +1998,22 @@ implements Listener, StandardStrings { throw new InternalErrorCDE("invalid call"); } + /** + * Sets the vns host and port. + * + * @param vnsHost the vns host + * @param vnsPort the vns port + */ public static void setVnsHostAndPort(String vnsHost, String vnsPort) { MultiPageEditorContributor.setVnsHost(vnsHost); MultiPageEditorContributor.setVnsPort(vnsPort); } + /** + * Sets the vns host and port. + * + * @param descriptor the new vns host and port + */ public static void setVnsHostAndPort(Object descriptor) { String vnsHost = MultiPageEditorContributor.getCDEVnsHost(); String vnsPort = MultiPageEditorContributor.getCDEVnsPort(); @@ -1228,6 +2035,13 @@ implements Listener, StandardStrings { setVnsHostAndPort(vnsHost, vnsPort); } + /** + * Request pop up over import. + * + * @param importItem the import item + * @param control the control + * @param event the event + */ protected void requestPopUpOverImport(Import importItem, Control control, Event event) { String path = editor.getAbsolutePathFromImport(importItem); IPath iPath = new Path(path); @@ -1265,12 +2079,26 @@ implements Listener, StandardStrings { } } + /** + * Checks if is jms descriptor. + * + * @param inputDescription the input description + * @return true, if is jms descriptor + */ protected boolean isJmsDescriptor (XMLizable inputDescription) { return (inputDescription instanceof CustomResourceSpecifier) && ("org.apache.uima.aae.jms_adapter.JmsAnalysisEngineServiceAdapter".equals( ((CustomResourceSpecifier)inputDescription).getResourceClassName())); } + /** + * Gets the absolute location. + * + * @param control the control + * @param x the x + * @param y the y + * @return the absolute location + */ private Point getAbsoluteLocation(Control control, int x, int y) { Point point = new Point(x, y); Composite composite = control.getParent(); @@ -1282,12 +2110,25 @@ implements Listener, StandardStrings { return point; } + /** + * Convert null. + * + * @param s the s + * @return the string + */ public static String convertNull(String s) { if (null == s) return ""; return s; } + /** + * Creates the import. + * + * @param fileName the file name + * @param isByName the is by name + * @return the import + */ public Import createImport(String fileName, boolean isByName) { if (isByName) { return createByNameImport(fileName); @@ -1300,7 +2141,9 @@ implements Listener, StandardStrings { } /** - * @param location + * Creates the location import. + * + * @param location the location * @return a location import * @throws MalformedURLException - */ @@ -1327,6 +2170,12 @@ implements Listener, StandardStrings { return imp; } + /** + * Creates the by name import. + * + * @param fileName the file name + * @return the import + */ public Import createByNameImport(String fileName) { if (fileName.endsWith(".xml")) fileName = fileName.substring(0, fileName.length() - 4); @@ -1356,12 +2205,24 @@ implements Listener, StandardStrings { } } + /** + * Checks if is FS array or list type. + * + * @param type the type + * @return true, if is FS array or list type + */ // subtype of FSLists should not match public static boolean isFSArrayOrListType(String type) { return (null != type) && (type.equals(CAS.TYPE_NAME_FS_ARRAY) || type.equals(CAS.TYPE_NAME_FS_LIST)); } + /** + * Checks if is array or list type. + * + * @param type the type + * @return true, if is array or list type + */ public static boolean isArrayOrListType(String type) { return (null != type) && (type.equals(CAS.TYPE_NAME_FS_ARRAY) || type.equals(CAS.TYPE_NAME_FS_LIST) @@ -1379,12 +2240,13 @@ implements Listener, StandardStrings { .equals(CAS.TYPE_NAME_DOUBLE_ARRAY)); } + /** The Constant RIDICULOUSLY_LARGE. */ private final static int RIDICULOUSLY_LARGE = 10000; /** - * Produce Unique key for a newly added descriptor file - * - * @param fileName + * Produce Unique key for a newly added descriptor file. + * + * @param fileName the file name * @return Unique key for a newly added descriptor file */ protected String produceUniqueComponentKey(String fileName) { @@ -1413,6 +2275,7 @@ implements Listener, StandardStrings { return null; } + /** The url for resource specifier schema. */ private static URL urlForResourceSpecifierSchema; static { try { @@ -1422,10 +2285,25 @@ implements Listener, StandardStrings { } } + /** + * Parses the descriptor. + * + * @param input the input + * @return the XM lizable + * @throws InvalidXMLException the invalid XML exception + */ public static XMLizable parseDescriptor(XMLInputSource input) throws InvalidXMLException { return parseDescriptor(input, false); } + /** + * Parses the descriptor. + * + * @param input the input + * @param preserveComments the preserve comments + * @return the XM lizable + * @throws InvalidXMLException the invalid XML exception + */ public static XMLizable parseDescriptor(XMLInputSource input, boolean preserveComments) throws InvalidXMLException { // turn off environment variable expansion XMLParser.ParsingOptions parsingOptions = new XMLParser.ParsingOptions(false); @@ -1437,6 +2315,11 @@ implements Listener, StandardStrings { urlForResourceSpecifierSchema, parsingOptions); } + /** + * Show exception reading imported descriptor. + * + * @param e the e + */ protected void showExceptionReadingImportedDescriptor(Exception e) { StringBuffer msg = new StringBuffer(1000); msg @@ -1447,8 +2330,8 @@ implements Listener, StandardStrings { } /** - * Update the model while checking for validity If invalid - ask if want to continue or not - * + * Update the model while checking for validity If invalid - ask if want to continue or not. + * * @return validity state */ protected boolean isValidAggregateChange() { @@ -1488,6 +2371,9 @@ implements Listener, StandardStrings { return true; } + /** + * Finish aggregate change action. + */ protected void finishAggregateChangeAction() { editor.setFileDirty(); @@ -1500,6 +2386,14 @@ implements Listener, StandardStrings { editor.getResourcesPage().markStale(); } + /** + * Read import. + * + * @param imp the imp + * @param fileName the file name + * @param isImportByName the is import by name + * @return the XM lizable + */ protected XMLizable readImport(Import imp, String fileName, boolean isImportByName) { URL byNameURL; XMLInputSource input; @@ -1536,11 +2430,23 @@ implements Listener, StandardStrings { return inputDescription; } + /** + * Enable ctrl. + * + * @param c the c + * @param enabled the enabled + */ protected static void enableCtrl(Control c, boolean enabled) { if (null != c) c.setEnabled(enabled); } + /** + * Sets the button selection. + * + * @param c the c + * @param selected the selected + */ protected static void setButtonSelection(Button c, boolean selected) { if (null != c) c.setSelection(selected); @@ -1549,18 +2455,26 @@ implements Listener, StandardStrings { /** * Return a String made from the description of a given resource specifier. If the specifier is * for a remote, try and connect to the remote and get its info. - * - * @param fileRef - * @param rs + * */ private ResourceSpecifier lastResourceForDescription = null; + /** The last description from descriptor. */ private String lastDescriptionFromDescriptor = ""; + /** The last time description requested. */ private long lastTimeDescriptionRequested = 0; + /** The Constant TABLE_HOVER_REQUERY_TIME. */ private static final long TABLE_HOVER_REQUERY_TIME = 15000; + /** + * Gets the description for descriptor. + * + * @param fileRef the file ref + * @param rs the rs + * @return the description for descriptor + */ protected String getDescriptionForDescriptor(String fileRef, ResourceSpecifier rs) { if (null == fileRef || "".equals(fileRef) || null == rs) return ""; @@ -1592,6 +2506,12 @@ implements Listener, StandardStrings { return sDesc; } + /** + * Setup to print file. + * + * @param filePath the file path + * @return the prints the writer + */ protected PrintWriter setupToPrintFile(String filePath) { if (new File(filePath).exists()) if (Window.CANCEL == Utility.popOkCancel("File exists, OK to replace?", MessageFormat.format( @@ -1608,6 +2528,11 @@ implements Listener, StandardStrings { } } + /** + * Gets the fs index collection. + * + * @return the fs index collection + */ protected FsIndexCollection getFsIndexCollection() { FsIndexCollection fsic = getAnalysisEngineMetaData().getFsIndexCollection(); if (null == fsic) @@ -1616,6 +2541,12 @@ implements Listener, StandardStrings { return fsic; } + /** + * Handle default index kind. + * + * @param indexKind the index kind + * @return the string + */ public static String handleDefaultIndexKind(String indexKind) { if (null == indexKind) return "sorted"; Modified: uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java?rev=1863233&r1=1863232&r2=1863233&view=diff ============================================================================== --- uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java (original) +++ uima/uimaj/trunk/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/AggregateSection.java Wed Jul 17 18:58:38 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; @@ -56,35 +55,50 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.forms.IManagedForm; + +/** + * The Class AggregateSection. + */ public class AggregateSection extends AbstractSection { + /** The files table. */ private Table filesTable; + /** The add button. */ private Button addButton; + /** The add remote button. */ private Button addRemoteButton; + /** The find analysis engine button. */ private Button findAnalysisEngineButton; + /** The remove button. */ private Button removeButton; + /** The add to flow button. */ private Button addToFlowButton; + /** The remove from flow button. */ private Button removeFromFlowButton; + /** + * Gets the removes the from flow button. + * + * @return the removes the from flow button + */ public Button getRemoveFromFlowButton() { return removeFromFlowButton; } + /** The b disable tool tip help. */ private boolean bDisableToolTipHelp = false; /** - * Creates a section for aggregate specifiers to add their delegates - * - * @param aEditor - * backpointer to the main multipage editor - * @param parent - * the Composite where this section lives + * Creates a section for aggregate specifiers to add their delegates. + * + * @param aEditor backpointer to the main multipage editor + * @param parent the Composite where this section lives */ public AggregateSection(MultiPageEditor aEditor, Composite parent) { super(aEditor, parent, "Component Engines", @@ -97,6 +111,7 @@ public class AggregateSection extends Ab * * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm) */ + @Override public void initialize(IManagedForm form) { super.initialize(form); @@ -157,6 +172,7 @@ public class AggregateSection extends Ab * * @see org.eclipse.ui.forms.IFormPart#refresh() */ + @Override public void refresh() { super.refresh(); @@ -213,6 +229,7 @@ public class AggregateSection extends Ab * * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ + @Override public void handleEvent(Event event) { if (event.widget == addButton) handleAdd(); @@ -250,6 +267,9 @@ public class AggregateSection extends Ab } } + /** + * Handle add. + */ private void handleAdd() { MultiResourceSelectionDialogWithFlowOption dialog = new MultiResourceSelectionDialogWithFlowOption( @@ -271,6 +291,14 @@ public class AggregateSection extends Ab } } + /** + * Produce key add delegate. + * + * @param shortName the short name + * @param fullPathFileName the full path file name + * @param addToFlow the add to flow + * @param isImportByName the is import by name + */ private void produceKeyAddDelegate(String shortName, String fullPathFileName, boolean addToFlow, boolean isImportByName) { boolean bSuccess = false; @@ -293,6 +321,9 @@ public class AggregateSection extends Ab } } + /** + * Handle remove. + */ private void handleRemove() { // get the keyName to remove int nSelectionIndex = filesTable.getSelectionIndex(); @@ -375,6 +406,9 @@ public class AggregateSection extends Ab // removed delegate (if params dont appear elsewhere) } + /** + * Handle add to flow. + */ private void handleAddToFlow() { String node = filesTable.getSelection()[0].getText(1); addNodeToFlow(node); @@ -387,7 +421,9 @@ public class AggregateSection extends Ab } /** - * @param node + * Adds the node to flow. + * + * @param node the node */ private void addNodeToFlow(String node) { FlowSection fs = editor.getAggregatePage().getFlowSection(); @@ -395,6 +431,9 @@ public class AggregateSection extends Ab // fs.refresh(); // the fs.addNode does a refresh } + /** + * Handle remove from flow. + */ private void handleRemoveFromFlow() { FlowSection fs = editor.getAggregatePage().getFlowSection(); String selectedKey = fs.getFlowList().getSelection()[0].getText(); @@ -410,6 +449,7 @@ public class AggregateSection extends Ab } } + /** The Constant REMOTE_TEMPLATE. */ private final static String REMOTE_TEMPLATE = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<uriSpecifier xmlns=\"http://uima.apache.org/resourceSpecifier\">\n" + " <resourceType>{0}</resourceType>\n" + // AnalysisEngine CasConsumer @@ -418,6 +458,7 @@ public class AggregateSection extends Ab " <timeout>{3}</timeout>" + " {4}" + // <parameters> for VNS </parameters> "\n</uriSpecifier>"; + /** The Constant REMOTE_JMS_TEMPLATE. */ private final static String REMOTE_JMS_TEMPLATE = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<customResourceSpecifier xmlns=\"http://uima.apache.org/resourceSpecifier\">\n" + " <resourceClassName>org.apache.uima.aae.jms_adapter.JmsAnalysisEngineServiceAdapter</resourceClassName>\n" @@ -428,11 +469,14 @@ public class AggregateSection extends Ab + " </parameters>\n" + "</customResourceSpecifier>"; + /** + * Handle add remote. + */ private void handleAddRemote() { String sDescriptorPath = editor.getFile().getParent().getLocation().toString() + '/'; AddRemoteServiceDialog dialog = new AddRemoteServiceDialog(this, sDescriptorPath); dialog.open(); - if (dialog.getReturnCode() == InputDialog.CANCEL) + if (dialog.getReturnCode() == Window.CANCEL) return; String sServiceType = dialog.getSelectedServiceTypeName(); @@ -497,6 +541,14 @@ public class AggregateSection extends Ab } } + /** + * Adds the param. + * + * @param sb the sb + * @param name the name + * @param value the value + * @return the string builder + */ private StringBuilder addParam(StringBuilder sb, String name, String value) { if (value != null && value.length() > 0) { sb = sb.append(" <parameter name=\"").append(name).append("\" value=\"").append(value).append("\"/>\n"); @@ -504,9 +556,13 @@ public class AggregateSection extends Ab return sb; } + /** The Constant delegateComponentStringHeadersLC. */ private static final String[] delegateComponentStringHeadersLC = new String[] { "<analysisenginedescription", "<casconsumerdescription", "<taedescription" }; + /** + * Handle find analysis engine. + */ private void handleFindAnalysisEngine() { FindComponentDialog dialog1 = new FindComponentDialog( this, @@ -555,6 +611,11 @@ public class AggregateSection extends Ab finishAggregateChangeAction(); } + /** + * Handle table context menu request. + * + * @param event the event + */ private void handleTableContextMenuRequest(Event event) { TableItem item = filesTable.getItem(new Point(event.x, event.y)); if (null == item) { @@ -569,6 +630,11 @@ public class AggregateSection extends Ab bDisableToolTipHelp = false; } + /** + * Handle table hover help. + * + * @param event the event + */ private void handleTableHoverHelp(Event event) { TableItem item = filesTable.getItem(new Point(event.x, event.y)); String sDesc = ""; @@ -582,6 +648,15 @@ public class AggregateSection extends Ab filesTable.setToolTipText(sDesc); } + /** + * Adds the delegate. + * + * @param fileName the file name + * @param shortName the short name + * @param keyName the key name + * @param isImportByName the is import by name + * @return true, if successful + */ private boolean addDelegate(String fileName, String shortName, String keyName, boolean isImportByName) { Import imp; @@ -632,6 +707,12 @@ public class AggregateSection extends Ab return true; } + /** + * Checks if is new key. + * + * @param keyName the key name + * @return true, if is new key + */ private boolean isNewKey(String keyName) { for (int i = 0; i < filesTable.getItemCount(); i++) { if (filesTable.getItem(i).getText(1).equals(keyName)) { @@ -641,6 +722,11 @@ public class AggregateSection extends Ab return true; } + /** + * Adds the parameters for delegate. + * + * @param tae the tae + */ public void addParametersForDelegate(AnalysisEngineDescription tae) { ConfigurationParameter[] candidateNewParams = tae.getAnalysisEngineMetaData() .getConfigurationParameterDeclarations().getConfigurationParameters(); @@ -719,6 +805,10 @@ public class AggregateSection extends Ab } } + /* (non-Javadoc) + * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable() + */ + @Override public void enable() { boolean isPrimitive = isPrimitive(); boolean bEnable = (filesTable.getSelectionIndex() > -1); @@ -731,10 +821,10 @@ public class AggregateSection extends Ab } /** - * adds a tableItem to the table - * - * @param fileName - * @param keyName + * adds a tableItem to the table. + * + * @param o the o + * @param keyName the key name */ private void addFile(Object o, String keyName) { Import impItem = (Import) o; @@ -748,6 +838,11 @@ public class AggregateSection extends Ab item.setText(1, keyName); } + /** + * Gets the table. + * + * @return the table + */ public Table getTable() { return filesTable; }