You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2016/11/13 16:13:18 UTC
svn commit: r1769512 [10/15] - in /uima/uimaj/branches/experiment-v3-jcas:
uimaj-ep-cas-editor-ide/src/main/java/org/apache/uima/caseditor/ide/
uimaj-ep-cas-editor/src/main/java/org/apache/uima/caseditor/
uimaj-ep-cas-editor/src/main/java/org/apache/ui...
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourceDependencySection.java Sun Nov 13 16:13:16 2016
@@ -44,32 +44,50 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
/**
* Declaration of primitive external resource dependencies A 4 col table: bound/unbound, keys, opt
- * flag, and interface name
+ * flag, and interface name.
*/
public class ResourceDependencySection extends AbstractSection {
+ /** The Constant KEY_COL. */
public final static int KEY_COL = 2;
+ /** The Constant OPT_COL. */
public final static int OPT_COL = 1;
+ /** The Constant BOUND. */
private final static String BOUND = "Bound";
+ /** The table. */
public Table table; // accessed by inner class
+ /** The add button. */
private Button addButton;
+ /** The edit button. */
private Button editButton;
+ /** The remove button. */
private Button removeButton;
+ /**
+ * Instantiates a new resource dependency section.
+ *
+ * @param editor the editor
+ * @param parent the parent
+ */
public ResourceDependencySection(MultiPageEditor editor, Composite parent) {
super(editor, parent, "Resource Dependencies",
"Primitives declare what resources they need. A primitive can only bind to one external resource.");
}
+ /* (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);
@@ -99,6 +117,10 @@ public class ResourceDependencySection e
toolkit.paintBordersFor(sectionClient);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
+ */
+ @Override
public void refresh() {
super.refresh();
table.getParent().setRedraw(false);
@@ -119,6 +141,13 @@ public class ResourceDependencySection e
table.getParent().setRedraw(true);
}
+ /**
+ * Adds the delegate to GUI.
+ *
+ * @param keys the keys
+ * @param newKey the new key
+ * @param o the o
+ */
private void addDelegateToGUI(String keys, String newKey, ResourceSpecifier o) {
if (o instanceof AnalysisEngineDescription) {
AnalysisEngineDescription aeDescription = (AnalysisEngineDescription) o;
@@ -140,6 +169,12 @@ public class ResourceDependencySection e
}
}
+ /**
+ * Adds the primitive to GUI.
+ *
+ * @param keys the keys
+ * @param aeDescription the ae description
+ */
private void addPrimitiveToGUI(String keys, ResourceCreationSpecifier aeDescription) {
ExternalResourceDependency[] xrd = aeDescription.getExternalResourceDependencies();
if (null != xrd) {
@@ -149,6 +184,13 @@ public class ResourceDependencySection e
}
}
+ /**
+ * Update xrd to GUI.
+ *
+ * @param item the item
+ * @param xrd the xrd
+ * @param keys the keys
+ */
private void updateXrdToGUI(TableItem item, ExternalResourceDependency xrd, String keys) {
String key = keys + xrd.getKey();
item.setText(0, isBound(key) ? BOUND : "");
@@ -158,6 +200,12 @@ public class ResourceDependencySection e
item.setData(xrd);
}
+ /**
+ * Checks if is bound.
+ *
+ * @param key the key
+ * @return true, if is bound
+ */
private boolean isBound(String key) {
ResourceManagerConfiguration rmc = editor.getResolvedExternalResourcesAndBindings();
if (null == rmc) { // happens if there is no such xml element in the descriptor
@@ -172,6 +220,12 @@ public class ResourceDependencySection e
return false;
}
+ /**
+ * Propagate key change.
+ *
+ * @param newKey the new key
+ * @param oldKey the old key
+ */
private void propagateKeyChange(String newKey, String oldKey) {
ExternalResourceBinding[] xrb = getExternalResourceBindings();
if (null != xrb)
@@ -185,10 +239,10 @@ public class ResourceDependencySection e
}
/**
- *
- * @param keys
- * either "" or key/key/
- * @param xrd
+ * Adds the xrd to GUI.
+ *
+ * @param keys either "" or key/key/
+ * @param xrd the xrd
*/
private void addXrdToGUI(String keys, ExternalResourceDependency xrd) {
TableItem item = new TableItem(table, SWT.NONE);
@@ -200,6 +254,7 @@ public class ResourceDependencySection e
*
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
+ @Override
public void handleEvent(Event event) {
if (event.widget == addButton) {
handleAdd();
@@ -220,6 +275,12 @@ public class ResourceDependencySection e
enable();
}
+ /**
+ * Gets the XR dependency from table item.
+ *
+ * @param item the item
+ * @return the XR dependency from table item
+ */
public ExternalResourceDependency getXRDependencyFromTableItem(TableItem item) {
return (ExternalResourceDependency) item.getData();
}
@@ -227,6 +288,11 @@ public class ResourceDependencySection e
// *****************************************************
// * When hovering over an item in the table, show the
// * description
+ /**
+ * Handle table hover help.
+ *
+ * @param event the event
+ */
// *****************************************************
private void handleTableHoverHelp(Event event) {
TableItem item = table.getItem(new Point(event.x, event.y));
@@ -238,6 +304,9 @@ public class ResourceDependencySection e
}
}
+ /**
+ * Handle edit.
+ */
private void handleEdit() {
TableItem item = table.getSelection()[0];
ExternalResourceDependency xrd = getXRDependencyFromTableItem(item);
@@ -249,16 +318,25 @@ public class ResourceDependencySection e
updateXrdToGUI(item, xrd, "");
}
+ /**
+ * Finish action.
+ */
private void finishAction() {
packChangingColumns();
setFileDirty();
}
+ /**
+ * Pack changing columns.
+ */
private void packChangingColumns() {
table.getColumn(KEY_COL).pack();
table.getColumn(3).pack();
}
+ /**
+ * Handle remove.
+ */
private void handleRemove() {
TableItem item = table.getSelection()[0];
editor.getAeDescription().setExternalResourceDependencies(
@@ -272,8 +350,7 @@ public class ResourceDependencySection e
}
/**
- * add a external resource dependency to the model
- *
+ * add a external resource dependency to the model.
*/
private void handleAdd() {
AddExternalResourceDependencyDialog dialog = new AddExternalResourceDependencyDialog(this);
@@ -285,6 +362,12 @@ public class ResourceDependencySection e
addXrdToGUI("", xrd);
}
+ /**
+ * Alter existing external resource dependency.
+ *
+ * @param xrd the xrd
+ * @param dialog the dialog
+ */
private void alterExistingExternalResourceDependency(ExternalResourceDependency xrd,
AddExternalResourceDependencyDialog dialog) {
valueChanged = false;
@@ -302,6 +385,12 @@ public class ResourceDependencySection e
finishAction();
}
+ /**
+ * Adds the new external resource dependency.
+ *
+ * @param dialog the dialog
+ * @return the external resource dependency
+ */
private ExternalResourceDependency addNewExternalResourceDependency(
AddExternalResourceDependencyDialog dialog) {
ExternalResourceDependency[] xrds = getExternalResourceDependencies();
@@ -326,6 +415,7 @@ public class ResourceDependencySection e
*
* @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable()
*/
+ @Override
public void enable() {
packTable(table);
if (isPrimitive()) {
@@ -335,6 +425,12 @@ public class ResourceDependencySection e
}
}
+ /**
+ * Key name already defined.
+ *
+ * @param key the key
+ * @return true, if successful
+ */
public boolean keyNameAlreadyDefined(String key) {
ExternalResourceDependency[] xrds = getExternalResourceDependencies();
if (null != xrds) {
@@ -355,6 +451,11 @@ public class ResourceDependencySection e
return false;
}
+ /**
+ * Gets the table.
+ *
+ * @return the table
+ */
public Table getTable() {
return table;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ResourcesPage.java Sun Nov 13 16:13:16 2016
@@ -23,22 +23,37 @@ import org.apache.uima.taeconfigurator.e
import org.apache.uima.taeconfigurator.editors.MultiPageEditor;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ResourcesPage.
+ */
public class ResourcesPage extends HeaderPageWithSash {
+ /** The resource dependency section. */
private ResourceDependencySection resourceDependencySection;
+ /** The extnl res bind section. */
// private ExternalResourceSection externalResourceSection;
private ExtnlResBindSection extnlResBindSection;
+ /** The res bind import section. */
private ImportResBindSection resBindImportSection;
+ /**
+ * Instantiates a new resources page.
+ *
+ * @param editor the editor
+ */
public ResourcesPage(MultiPageEditor editor) {
super(editor, "Resource Definitions and Bindings");
}
/**
- * Called by the framework to fill in the contents
+ * Called by the framework to fill in the contents.
+ *
+ * @param managedForm the managed form
*/
+ @Override
protected void createFormContent(IManagedForm managedForm) {
// Only primitive engines can declare Resource Dependencies
@@ -58,14 +73,29 @@ public class ResourcesPage extends Heade
createToolBarActions(managedForm);
}
+ /**
+ * Gets the resource dependency section.
+ *
+ * @return the resource dependency section
+ */
public ResourceDependencySection getResourceDependencySection() {
return resourceDependencySection;
}
+ /**
+ * Gets the resource bindings section.
+ *
+ * @return the resource bindings section
+ */
public ExtnlResBindSection getResourceBindingsSection() {
return extnlResBindSection;
}
+ /**
+ * Gets the res bind import section.
+ *
+ * @return the res bind import section
+ */
public ImportResBindSection getResBindImportSection() {
return resBindImportSection;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SettingsPage.java Sun Nov 13 16:13:16 2016
@@ -23,19 +23,33 @@ import org.apache.uima.taeconfigurator.e
import org.apache.uima.taeconfigurator.editors.MultiPageEditor;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class SettingsPage.
+ */
public class SettingsPage extends HeaderPageWithSash {
+ /** The parameter settings section. */
private ParameterSettingsSection parameterSettingsSection;
+ /** The value section. */
private ValueSection valueSection;
+ /**
+ * Instantiates a new settings page.
+ *
+ * @param editor the editor
+ */
public SettingsPage(MultiPageEditor editor) {
super(editor, "Parameter Value Settings");
}
/**
- * Called by the framework to fill in the contents
+ * Called by the framework to fill in the contents.
+ *
+ * @param managedForm the managed form
*/
+ @Override
protected void createFormContent(IManagedForm managedForm) {
final Form2Panel form2Panel = setup2ColumnLayout(managedForm, EQUAL_WIDTH);
@@ -47,10 +61,20 @@ public class SettingsPage extends Header
createToolBarActions(managedForm);
}
+ /**
+ * Gets the parameter settings section.
+ *
+ * @return the parameter settings section
+ */
public ParameterSettingsSection getParameterSettingsSection() {
return parameterSettingsSection;
}
+ /**
+ * Gets the value section.
+ *
+ * @return the value section
+ */
public ValueSection getValueSection() {
return valueSection;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/SofaMapSection.java Sun Nov 13 16:13:16 2016
@@ -47,29 +47,49 @@ import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * 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();
@@ -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/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeImportSection.java Sun Nov 13 16:13:16 2016
@@ -33,14 +33,24 @@ import org.eclipse.jface.dialogs.Message
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Composite;
+// TODO: Auto-generated Javadoc
/**
+ * The Class TypeImportSection.
*/
public class TypeImportSection extends ImportSection {
+ /** The saved CAS. */
private CAS savedCAS;
+ /** The import was removed. */
private boolean importWasRemoved;
+ /**
+ * Instantiates a new type import section.
+ *
+ * @param editor the editor
+ * @param parent the parent
+ */
public TypeImportSection(MultiPageEditor editor, Composite parent) {
super(editor, parent, "Imported Type Systems",
"The following type systems are included as part of this one.");
@@ -50,6 +60,10 @@ public class TypeImportSection extends I
// * Code to support type import section
// **************************************
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#isAppropriate()
+ */
+ @Override
protected boolean isAppropriate() {
if (isAggregate()) {
getSection().setText("Not Used");
@@ -61,16 +75,28 @@ public class TypeImportSection extends I
return true;
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#getDescriptionFromImport(java.lang.String)
+ */
+ @Override
protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException {
TypeSystemDescription parsedImportItem = UIMAFramework.getXMLParser()
.parseTypeSystemDescription(new XMLInputSource(source));
return parsedImportItem.getDescription();
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#getModelImportArray()
+ */
+ @Override
protected Import[] getModelImportArray() {
return getTypeSystemDescription().getImports();
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#setModelImportArray(org.apache.uima.resource.metadata.Import[])
+ */
+ @Override
protected void setModelImportArray(Import[] imports) {
savedCAS = editor.getCurrentView();
Import[] oldImports = getTypeSystemDescription().getImports();
@@ -78,10 +104,18 @@ public class TypeImportSection extends I
getTypeSystemDescription().setImports(imports);
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#clearModelBaseValue()
+ */
+ @Override
protected void clearModelBaseValue() {
getTypeSystemDescription().setTypes(typeDescription0);
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#isValidImport(java.lang.String, java.lang.String)
+ */
+ @Override
protected boolean isValidImport(String title, String msg) {
TypeSystemDescription savedTSD = getMergedTypeSystemDescription();
TypeSystemDescription savedITSD = editor.getImportedTypeSystemDesription();
@@ -116,6 +150,7 @@ public class TypeImportSection extends I
* At this point, the basic type system description is updated. and validated. Validation has
* updated the merged type system description, and updated the CAS.
*/
+ @Override
protected void finishImportChangeAction() {
// at this point, the tsd validation has updated the resolved version
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePage.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePage.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePage.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePage.java Sun Nov 13 16:13:16 2016
@@ -23,19 +23,33 @@ import org.apache.uima.taeconfigurator.e
import org.apache.uima.taeconfigurator.editors.MultiPageEditor;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class TypePage.
+ */
public class TypePage extends HeaderPageWithSash {
+ /** The type section. */
private TypeSection typeSection;
+ /** The type import section. */
private TypeImportSection typeImportSection;
+ /**
+ * Instantiates a new type page.
+ *
+ * @param editor the editor
+ */
public TypePage(MultiPageEditor editor) {
super(editor, "Type Definitions");
}
/**
- * Called by the framework to fill in the contents
+ * Called by the framework to fill in the contents.
+ *
+ * @param managedForm the managed form
*/
+ @Override
protected void createFormContent(IManagedForm managedForm) {
// always show same screen layout - user could dynamically switch
managedForm.getForm().setText("Type System Definition");
@@ -45,10 +59,20 @@ public class TypePage extends HeaderPage
createToolBarActions(managedForm);
}
+ /**
+ * Gets the type section.
+ *
+ * @return the type section
+ */
public TypeSection getTypeSection() {
return typeSection;
}
+ /**
+ * Gets the type import section.
+ *
+ * @return the type import section
+ */
public TypeImportSection getTypeImportSection() {
return typeImportSection;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePriorityImportSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePriorityImportSection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePriorityImportSection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypePriorityImportSection.java Sun Nov 13 16:13:16 2016
@@ -31,10 +31,18 @@ import org.apache.uima.util.InvalidXMLEx
import org.apache.uima.util.XMLInputSource;
import org.eclipse.swt.widgets.Composite;
+// TODO: Auto-generated Javadoc
/**
+ * The Class TypePriorityImportSection.
*/
public class TypePriorityImportSection extends ImportSection {
+ /**
+ * Instantiates a new type priority import section.
+ *
+ * @param editor the editor
+ * @param parent the parent
+ */
public TypePriorityImportSection(MultiPageEditor editor, Composite parent) {
super(editor, parent, "Type Priority Imports",
"The following type priority imports are included as part of the type priorities:");
@@ -42,33 +50,59 @@ public class TypePriorityImportSection e
// **************************************
// * Code to support type import section
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#isAppropriate()
+ */
// **************************************
+ @Override
protected boolean isAppropriate() {
return true; // always show
}
/**
- * used when hovering
+ * used when hovering.
+ *
+ * @param source the source
+ * @return the description from import
+ * @throws InvalidXMLException the invalid XML exception
+ * @throws IOException Signals that an I/O exception has occurred.
*/
+ @Override
protected String getDescriptionFromImport(String source) throws InvalidXMLException, IOException {
TypePriorities parsedImportItem = UIMAFramework.getXMLParser().parseTypePriorities(
new XMLInputSource(source));
return parsedImportItem.getDescription();
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#getModelImportArray()
+ */
+ @Override
protected Import[] getModelImportArray() {
return getTypePriorities().getImports();
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#setModelImportArray(org.apache.uima.resource.metadata.Import[])
+ */
+ @Override
protected void setModelImportArray(Import[] imports) {
getTypePriorities().setImports(imports);
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#clearModelBaseValue()
+ */
+ @Override
protected void clearModelBaseValue() {
getTypePriorities().setPriorityLists(typePriorityList0);
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#isValidImport(java.lang.String, java.lang.String)
+ */
// indexes are checked and merged when the CAS is built
+ @Override
protected boolean isValidImport(String title, String message) {
CAS savedCAS = editor.getCurrentView();
TypePriorities savedTP = editor.getMergedTypePriorities();
@@ -86,6 +120,10 @@ public class TypePriorityImportSection e
return true;
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.ImportSection#finishImportChangeAction()
+ */
+ @Override
protected void finishImportChangeAction() {
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/TypeSection.java Sun Nov 13 16:13:16 2016
@@ -44,6 +44,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
+import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.TypeOrFeature;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.Type;
@@ -63,7 +64,6 @@ import org.apache.uima.resource.metadata
import org.apache.uima.taeconfigurator.InternalErrorCDE;
import org.apache.uima.taeconfigurator.TAEConfiguratorPlugin;
import org.apache.uima.taeconfigurator.editors.MultiPageEditor;
-import org.apache.uima.taeconfigurator.editors.MultiPageEditorContributor;
import org.apache.uima.taeconfigurator.editors.ui.dialogs.AddAllowedValueDialog;
import org.apache.uima.taeconfigurator.editors.ui.dialogs.AddFeatureDialog;
import org.apache.uima.taeconfigurator.editors.ui.dialogs.AddTypeDialog;
@@ -80,47 +80,76 @@ import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class TypeSection.
+ */
public class TypeSection extends AbstractImportablePartSection {
+
+ /** The Constant CASCADE_MESSAGE. */
public static final String CASCADE_MESSAGE = "This will cause a cascading deletion of an associated "
+ "input, output, index, or type priority, unless this deletion exposes a "
+ "built-in or imported type or feature of the same name. Ok to continue?";
+ /** The Constant CASCADE_DELETE_WARNING. */
public static final String CASCADE_DELETE_WARNING = "Cascade Delete Warning";
+ /** The Constant NAME_COL. */
public static final int NAME_COL = 0;
+ /** The Constant SUPER_COL. */
public static final int SUPER_COL = 1;
+ /** The Constant RANGE_COL. */
public static final int RANGE_COL = 1;
+ /** The Constant MULTIPLE_REF_OK_COL. */
public static final int MULTIPLE_REF_OK_COL = 2;
+ /** The Constant ELEMENT_TYPE_COL. */
public static final int ELEMENT_TYPE_COL = 3;
+ /** The Constant AV_COL. */
public static final int AV_COL = 1;
+ /** The Constant HEADER_ALLOWED_VALUE. */
public static final String HEADER_ALLOWED_VALUE = "Allowed Value:";
+ /** The tt. */
private TableTree tt;
+ /** The add type button. */
private Button addTypeButton;
+ /** The add button. */
private Button addButton;
+ /** The edit button. */
private Button editButton;
+ /** The remove button. */
private Button removeButton;
+ /** The jcas gen button. */
private Button jcasGenButton;
+ /** The export button. */
private Button exportButton;
+ /** The limit J cas gen to project scope. */
private Button limitJCasGenToProjectScope;
// private TypeSystemDescription tsdLocal; // for this descriptor, no imports
+ /** The Constant ALLOWED. */
private static final boolean ALLOWED = true;
+ /**
+ * Instantiates a new type section.
+ *
+ * @param editor the editor
+ * @param parent the parent
+ */
public TypeSection(MultiPageEditor editor, Composite parent) {
super(
editor,
@@ -136,6 +165,7 @@ public class TypeSection extends Abstrac
// * @see
// org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
// **********************************************************************/
+ @Override
public void initialize(IManagedForm form) {
super.initialize(form);
@@ -175,6 +205,7 @@ public class TypeSection extends Abstrac
*
* @see org.apache.uima.taeconfigurator.editors.ui.AbstractTableSection#update()
*/
+ @Override
public void refresh() {
super.refresh();
@@ -195,6 +226,13 @@ public class TypeSection extends Abstrac
enable();
}
+ /**
+ * Sets the difference.
+ *
+ * @param all the all
+ * @param subset the subset
+ * @return the feature description[]
+ */
private FeatureDescription[] setDifference(FeatureDescription[] all, FeatureDescription[] subset) {
if (null == all)
return featureDescriptionArray0;
@@ -213,6 +251,11 @@ public class TypeSection extends Abstrac
return (FeatureDescription[]) result.toArray(new FeatureDescription[result.size()]);
}
+ /**
+ * Adds the type to GUI.
+ *
+ * @param td the td
+ */
private void addTypeToGUI(TypeDescription td) {
TableTreeItem item = new TableTreeItem(tt, SWT.NONE);
item.setText(NAME_COL, formatName(td.getName()));
@@ -244,6 +287,13 @@ public class TypeSection extends Abstrac
item.setExpanded(true);
}
+ /**
+ * Adds the features to gui.
+ *
+ * @param td the td
+ * @param item the item
+ * @param features the features
+ */
private void addFeaturesToGui(TypeDescription td, TableTreeItem item,
FeatureDescription[] features) {
if (null != features) {
@@ -254,6 +304,13 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Update gui feature.
+ *
+ * @param fItem the f item
+ * @param fd the fd
+ * @param td the td
+ */
private void updateGuiFeature(TableTreeItem fItem, FeatureDescription fd, TypeDescription td) {
String rangeType;
fItem.setText(NAME_COL, fd.getName());
@@ -276,6 +333,12 @@ public class TypeSection extends Abstrac
}
+ /**
+ * Sets the item color.
+ *
+ * @param item the item
+ * @param isLocal the is local
+ */
private void setItemColor(TableTreeItem item, boolean isLocal) {
if (isLocal)
return;
@@ -287,6 +350,7 @@ public class TypeSection extends Abstrac
*
* @see org.apache.uima.taeconfigurator.editors.ui.AbstractTableSection#handleEvent(org.eclipse.swt.widgets.Event)
*/
+ @Override
public void handleEvent(Event event) {
if (event.widget == addTypeButton) {
handleAddType();
@@ -321,6 +385,11 @@ public class TypeSection extends Abstrac
enable();
}
+ /**
+ * Handle hover.
+ *
+ * @param event the event
+ */
public void handleHover(Event event) {
// next getItem call requires that table have SWT.FULL_SELECTION Style
TableTreeItem item = tt.getItem(new Point(event.x, event.y));
@@ -347,10 +416,21 @@ public class TypeSection extends Abstrac
tt.setToolTipText("");
}
+ /**
+ * Gets the type description from table tree item.
+ *
+ * @param item the item
+ * @return the type description from table tree item
+ */
public TypeDescription getTypeDescriptionFromTableTreeItem(TableTreeItem item) {
return (TypeDescription) item.getData();
}
+ /**
+ * Handle add allowed value.
+ *
+ * @param parent the parent
+ */
// disabled unless type having String as supertype is selected
public void handleAddAllowedValue(TableTreeItem parent) {
boolean refreshNeeded = false;
@@ -364,7 +444,7 @@ public class TypeSection extends Abstrac
return;
}
- AllowedValue av = UIMAFramework_impl.getResourceSpecifierFactory().createAllowedValue();
+ AllowedValue av = UIMAFramework.getResourceSpecifierFactory().createAllowedValue();
allowedValueUpdate(av, dialog);
addAllowedValue(localTd, av);
@@ -389,22 +469,34 @@ public class TypeSection extends Abstrac
finishActionPack();
}
+ /**
+ * Adds the allowed value.
+ *
+ * @param td the td
+ * @param av the av
+ */
private void addAllowedValue(TypeDescription td, AllowedValue av) {
td.setAllowedValues((AllowedValue[]) Utility.addElementToArray(td.getAllowedValues(), av,
AllowedValue.class));
}
/**
- *
+ * Removes the allowed value.
+ *
* @param td -
* local or merged (2 callers)
- * @param av
+ * @param av the av
*/
private void removeAllowedValue(TypeDescription td, AllowedValue av) {
td.setAllowedValues((AllowedValue[]) Utility.removeEqualElementFromArray(td.getAllowedValues(),
av, AllowedValue.class));
}
+ /**
+ * Handle add feature.
+ *
+ * @param parent the parent
+ */
// disabled unless type is selected
public void handleAddFeature(TableTreeItem parent) {
@@ -448,6 +540,11 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Select type in gui.
+ *
+ * @param td the td
+ */
private void selectTypeInGui(TypeDescription td) {
TableTreeItem[] items = tt.getItems();
for (int i = 0; i < items.length; i++) {
@@ -458,12 +555,24 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Allowed value update.
+ *
+ * @param av the av
+ * @param dialog the dialog
+ */
public void allowedValueUpdate(AllowedValue av, AddAllowedValueDialog dialog) {
valueChanged = false;
av.setString(setValueChanged(dialog.allowedValue, av.getString()));
av.setDescription(setValueChanged(dialog.description, av.getDescription()));
}
+ /**
+ * Feature update.
+ *
+ * @param fd the fd
+ * @param dialog the dialog
+ */
public void featureUpdate(FeatureDescription fd, AddFeatureDialog dialog) {
valueChanged = false;
String v = setValueChanged(dialog.featureName, fd.getName());
@@ -487,6 +596,9 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Handle add type.
+ */
public void handleAddType() {
AddTypeDialog dialog = new AddTypeDialog(this);
if (dialog.open() == Window.CANCEL)
@@ -514,11 +626,17 @@ public class TypeSection extends Abstrac
finishActionPack();
}
+ /**
+ * Finish action pack.
+ */
private void finishActionPack() {
packTable(tt.getTable());
finishAction();
}
+ /**
+ * Finish action.
+ */
private void finishAction() {
if (isLocalProcessingDescriptor()) {
@@ -528,6 +646,9 @@ public class TypeSection extends Abstrac
setFileDirty();
}
+ /**
+ * Handle edit.
+ */
private void handleEdit() {
TableTreeItem item = tt.getSelection()[0];
TableTreeItem parentType = item.getParentItem();
@@ -541,10 +662,22 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Gets the feature description from table tree item.
+ *
+ * @param item the item
+ * @return the feature description from table tree item
+ */
public FeatureDescription getFeatureDescriptionFromTableTreeItem(TableTreeItem item) {
return (FeatureDescription) item.getData();
}
+ /**
+ * Edits the feature.
+ *
+ * @param item the item
+ * @param parent the parent
+ */
private void editFeature(TableTreeItem item, TableTreeItem parent) {
boolean remergeNeeded = false;
boolean refreshNeeded = false;
@@ -605,10 +738,22 @@ public class TypeSection extends Abstrac
finishActionPack();
}
+ /**
+ * Gets the allowed value from table tree item.
+ *
+ * @param item the item
+ * @return the allowed value from table tree item
+ */
public AllowedValue getAllowedValueFromTableTreeItem(TableTreeItem item) {
return (AllowedValue) item.getData();
}
+ /**
+ * Edits the allowed value.
+ *
+ * @param item the item
+ * @param parent the parent
+ */
private void editAllowedValue(TableTreeItem item, TableTreeItem parent) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
@@ -631,10 +776,10 @@ public class TypeSection extends Abstrac
}
/**
- * New Feature test: return null if OK, error message otherwise
- *
- * @param td
- * @param dialog
+ * New Feature test: return null if OK, error message otherwise.
+ *
+ * @param td the td
+ * @param dialog the dialog
* @return error message or null
*/
private String newFeatureTests(TypeDescription td, AddFeatureDialog dialog) {
@@ -662,10 +807,10 @@ public class TypeSection extends Abstrac
* do "remove" test on old name: If used in an index or capability, but merged/built-in name not
* still there, warn about index being invalidated (not done here - done during feature update
* itself). If name used in index, and range is not indexable - error
- *
- * @param dialog
- * @param td
- * @param oldFd
+ *
+ * @param dialog the dialog
+ * @param td the td
+ * @param oldFd the old fd
* @return error message or null
*/
public String checkFeature(AddFeatureDialog dialog, TypeDescription td, FeatureDescription oldFd) {
@@ -689,6 +834,14 @@ public class TypeSection extends Abstrac
return null;
}
+ /**
+ * Check allowed value.
+ *
+ * @param dialog the dialog
+ * @param td the td
+ * @param av the av
+ * @return the string
+ */
public String checkAllowedValue(AddAllowedValueDialog dialog, TypeDescription td, AllowedValue av) {
if (isLocalAllowedValue(dialog.allowedValue, td)) {
return "Duplicate Allowed Value in this Descriptor";
@@ -696,6 +849,11 @@ public class TypeSection extends Abstrac
return null;
}
+ /**
+ * Edits the type.
+ *
+ * @param item the item
+ */
// type is always local; could be merging with import(s) or built-in
private void editType(TableTreeItem item) {
@@ -717,7 +875,7 @@ public class TypeSection extends Abstrac
return;
if (isImportedType(oldTypeName)
- && MessageDialog.CANCEL == Utility
+ && Window.CANCEL == Utility
.popOkCancel(
"Type define via Import",
"The type '"
@@ -726,7 +884,7 @@ public class TypeSection extends Abstrac
MessageDialog.WARNING))
return;
if (isBuiltInType(oldTypeName)
- && MessageDialog.CANCEL == Utility
+ && Window.CANCEL == Utility
.popOkCancel(
"Type was extending a built-in",
"The type '"
@@ -770,11 +928,20 @@ public class TypeSection extends Abstrac
finishActionPack();
}
+ /**
+ * Update gui type.
+ *
+ * @param item the item
+ * @param td the td
+ */
private void updateGuiType(TableTreeItem item, TypeDescription td) {
item.setText(NAME_COL, formatName(td.getName()));
item.setText(SUPER_COL, formatName(td.getSupertypeName()));
}
+ /**
+ * Rebuild merged type system.
+ */
private void rebuildMergedTypeSystem() {
try {
editor.setMergedTypeSystemDescription();
@@ -783,6 +950,12 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Type update.
+ *
+ * @param td the td
+ * @param dialog the dialog
+ */
private void typeUpdate(TypeDescription td, AddTypeDialog dialog) {
td.setName(setValueChanged(dialog.typeName, td.getName()));
td.setDescription(setValueChanged(multiLineFix(dialog.description), td.getDescription()));
@@ -794,6 +967,9 @@ public class TypeSection extends Abstrac
* returns null or error message about a duplicate type name Cases: Dupl type in local descriptor
* not allowed. Type that duplicates imported type is OK. Type that duplicates built-in type is
* OK.
+ *
+ * @param newTypeName the new type name
+ * @return the string
*/
public String checkDuplTypeName(String newTypeName) {
if (isLocalType(newTypeName)) {
@@ -802,6 +978,9 @@ public class TypeSection extends Abstrac
return null;
}
+ /**
+ * Handle remove.
+ */
/*
* Note that the Remove action is disabled if the item selected is imported only
*/
@@ -817,6 +996,11 @@ public class TypeSection extends Abstrac
handleRemoveFeature(item);
}
+ /**
+ * Handle remove allowed value.
+ *
+ * @param item the item
+ */
private void handleRemoveAllowedValue(TableTreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
AllowedValue av = getAllowedValueFromTableTreeItem(item);
@@ -837,6 +1021,11 @@ public class TypeSection extends Abstrac
}
// cases: removing a feature which is merged with an identical named imported feature
+ /**
+ * Handle remove feature.
+ *
+ * @param item the item
+ */
// same - for built-in <could be created outside of the CDE>
private void handleRemoveFeature(TableTreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
@@ -879,17 +1068,30 @@ public class TypeSection extends Abstrac
finishAction();
}
+ /**
+ * The Class TypeFeature.
+ */
private static class TypeFeature {
+
+ /** The type name. */
String typeName;
+ /** The feature name. */
String featureName; // short feature name
+ /**
+ * Instantiates a new type feature.
+ *
+ * @param type the type
+ * @param feat the feat
+ */
TypeFeature(String type, String feat) {
typeName = type;
featureName = feat;
}
}
+ /** The Constant typeFeature0. */
private static final TypeFeature[] typeFeature0 = new TypeFeature[0];
/**
@@ -898,10 +1100,9 @@ public class TypeSection extends Abstrac
* for this type, but for all subtypes of this type. NOTE: if mergeTd is null, it means the type
* is removed completely (no shadowing of built-in or imported types), so no special feature
* removal is needed.
- *
- * @param localTd
- * @param mergedTd
- * The "remerged" value of the type.
+ *
+ * @param localTd the local td
+ * @param mergedTd The "remerged" value of the type.
* @return array of string names of features to be removed
*/
@@ -947,6 +1148,11 @@ public class TypeSection extends Abstrac
return (TypeFeature[]) result.toArray(typeFeature0);
}
+ /**
+ * Handle remove type.
+ *
+ * @param item the item
+ */
private void handleRemoveType(TableTreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item);
@@ -1006,10 +1212,10 @@ public class TypeSection extends Abstrac
}
/**
- * Called when removing a type (or renaming a type - treating old value like remove)
- *
- * @param existingTypeName
- * @param allowed
+ * Called when removing a type (or renaming a type - treating old value like remove).
+ *
+ * @param existingTypeName the existing type name
+ * @param allowed the allowed
* @return null means "cancel", stringArray0 means no problem, stringArrayN = dependent types
*/
private String[] showTypesRequiringThisOneMessage(String existingTypeName, boolean allowed) {
@@ -1033,7 +1239,7 @@ public class TypeSection extends Abstrac
}
sMsg += ". If you proceed, the dependent types which are updatable will be updated."
+ " Non-updatable types (imported, etc.) you will have to update manually. Please confirm.";
- if (MessageDialog.OK == Utility.popOkCancel("Confirm renaming type update actions", sMsg,
+ if (Window.OK == Utility.popOkCancel("Confirm renaming type update actions", sMsg,
MessageDialog.WARNING))
return typesRequiringThisOne;
return null;
@@ -1041,16 +1247,34 @@ public class TypeSection extends Abstrac
return stringArray0;
}
+ /**
+ * Removes the type.
+ *
+ * @param td the td
+ * @param tsd the tsd
+ */
private void removeType(TypeDescription td, TypeSystemDescription tsd) {
tsd.setTypes((TypeDescription[]) Utility.removeElementFromArray(tsd.getTypes(), td,
TypeDescription.class));
}
+ /**
+ * Removes the feature.
+ *
+ * @param td the td
+ * @param fd the fd
+ */
private void removeFeature(TypeDescription td, FeatureDescription fd) {
td.setFeatures((FeatureDescription[]) Utility.removeElementFromArray(td.getFeatures(), fd,
FeatureDescription.class));
}
+ /**
+ * Gets the types requiring this one.
+ *
+ * @param typeName the type name
+ * @return the types requiring this one
+ */
private String[] getTypesRequiringThisOne(String typeName) {
List upstreamTypeNames = new ArrayList();
@@ -1067,6 +1291,13 @@ public class TypeSection extends Abstrac
return (String[]) upstreamTypeNames.toArray(new String[upstreamTypeNames.size()]);
}
+ /**
+ * Type requires type.
+ *
+ * @param upstreamType the upstream type
+ * @param typeName the type name
+ * @return true, if successful
+ */
private boolean typeRequiresType(TypeDescription upstreamType, String typeName) {
if (null == typeName)
return false;
@@ -1087,6 +1318,10 @@ public class TypeSection extends Abstrac
return false;
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSection#enable()
+ */
+ @Override
public void enable() {
jcasGenButton.setEnabled(tt.getItemCount() > 0);
TypeSystemDescription tsd = getTypeSystemDescription();
@@ -1111,11 +1346,23 @@ public class TypeSection extends Abstrac
}
+ /**
+ * Checks if is subtype of string.
+ *
+ * @param item the item
+ * @return true, if is subtype of string
+ */
private boolean isSubtypeOfString(TableTreeItem item) {
TypeDescription td = getTypeDescriptionFromTableTreeItem(item);
return CAS.TYPE_NAME_STRING.equals(td.getSupertypeName());
}
+ /**
+ * Checks if is type in use elsewhere.
+ *
+ * @param sTypeName the s type name
+ * @return true, if is type in use elsewhere
+ */
private boolean isTypeInUseElsewhere(final String sTypeName) {
if (!isLocalProcessingDescriptor()) {
return false;
@@ -1123,6 +1370,7 @@ public class TypeSection extends Abstrac
final String sTypeName_Colon = sTypeName + ":";
CapabilityVisitor cv = new CapabilityVisitor() {
+ @Override
boolean visit(TypeOrFeature i_o) {
if (i_o.isType() && i_o.getName().equals(sTypeName))
return true;
@@ -1147,21 +1395,32 @@ public class TypeSection extends Abstrac
return typePriorityListsVisit(FIND_EQUAL_TYPE, sTypeName);
}
+ /** The Constant FIND_EQUAL_TYPE. */
private final static int FIND_EQUAL_TYPE = 1;
+ /** The Constant REMOVE_EQUAL_TYPE. */
private final static int REMOVE_EQUAL_TYPE = 2;
+ /** The Constant UPDATE_TYPE_NAME. */
private final static int UPDATE_TYPE_NAME = 4;
+ /**
+ * Type priority lists visit.
+ *
+ * @param kind the kind
+ * @param typeName the type name
+ * @return true, if successful
+ */
private boolean typePriorityListsVisit(int kind, String typeName) {
return typePriorityListsVisit(kind, typeName, null);
}
/**
- *
- * @param kind
- * @param typeName
- * @param newTypeName
+ * Type priority lists visit.
+ *
+ * @param kind the kind
+ * @param typeName the type name
+ * @param newTypeName the new type name
* @return FIND_EQUAL_TYPE: true if found, false otherwise REMOVE_EQUAL_TYPE: true if found, false
* if nothing done UPDATE_TYPE_NAME: true if found & updated, false if nothing done
*/
@@ -1208,6 +1467,15 @@ public class TypeSection extends Abstrac
return returnValue;
}
+ /**
+ * Delete type or feature from capability.
+ *
+ * @param io_s the io s
+ * @param isType the is type
+ * @param name the name
+ * @param typeName the type name
+ * @return the type or feature[]
+ */
private TypeOrFeature[] deleteTypeOrFeatureFromCapability(TypeOrFeature[] io_s,
final boolean isType, String name, String typeName) {
@@ -1217,23 +1485,31 @@ public class TypeSection extends Abstrac
isType ? capabilityTypeCompare : capabilityFeatureCompare);
}
+ /** The Constant TYPES. */
private final static boolean TYPES = true;
+ /** The Constant FEATURES. */
private final static boolean FEATURES = false;
+ /** The Constant fsIndexDescCompare. */
private static final Comparator fsIndexDescCompare = new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
return ((FsIndexDescription) o2).getTypeName().equals(o1) ? 0 : 1;
}
};
+ /** The Constant fsIndexKeyDescCompare. */
private static final Comparator fsIndexKeyDescCompare = new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
return (o1.equals(((FsIndexKeyDescription) o2).getFeatureName())) ? 0 : 1;
}
};
+ /** The Constant capabilityTypeCompare. */
private static final Comparator capabilityTypeCompare = new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
TypeOrFeature tf = (TypeOrFeature) o2;
return ((tf.isType() == true && tf.getName().equals(o1)) ||
@@ -1242,7 +1518,9 @@ public class TypeSection extends Abstrac
}
};
+ /** The Constant capabilityFeatureCompare. */
private static final Comparator capabilityFeatureCompare = new Comparator() {
+ @Override
public int compare(Object o1, Object o2) {
TypeOrFeature tf = (TypeOrFeature) o2;
return (tf.isType() == false && tf.getName().equals(o1)) ? 0 : 1;
@@ -1250,13 +1528,12 @@ public class TypeSection extends Abstrac
};
/**
- * feature name if used, is short-name
- *
+ * feature name if used, is short-name.
+ *
* @param typeOrFeatureName -
* if feature is short feature name
- * @param isType
- * @param String
- * type name (used when feature name passed above
+ * @param isType the is type
+ * @param typeName the type name
*/
private void deleteTypeOrFeatureMentions(final String typeOrFeatureName, boolean isType,
final String typeName) {
@@ -1328,10 +1605,10 @@ public class TypeSection extends Abstrac
}
/**
- * return true if refresh is needed
- *
- * @param oldTypeName
- * @param newTypeName
+ * return true if refresh is needed.
+ *
+ * @param oldTypeName the old type name
+ * @param newTypeName the new type name
* @return true if refresh is needed
*/
private boolean alterTypeMentionsInOtherTypes(String oldTypeName, String newTypeName) {
@@ -1410,6 +1687,13 @@ public class TypeSection extends Abstrac
return refreshNeeded;
}
+ /**
+ * Sets the named feature description range.
+ *
+ * @param localFds the local fds
+ * @param featureName the feature name
+ * @param rangeName the range name
+ */
// this function to set the corresponding feature in the "local" type's fd array
private void setNamedFeatureDescriptionRange(FeatureDescription[] localFds, String featureName,
final String rangeName) {
@@ -1424,6 +1708,12 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Warn and skip if imported.
+ *
+ * @param typeName the type name
+ * @return true, if successful
+ */
private boolean warnAndSkipIfImported(String typeName) {
if (isLocalType(typeName)) {
if (isImportedType(typeName)) {
@@ -1449,6 +1739,12 @@ public class TypeSection extends Abstrac
}
}
+ /**
+ * Alter type mentions.
+ *
+ * @param sOldTypeName the s old type name
+ * @param sNewTypeName the s new type name
+ */
private void alterTypeMentions(final String sOldTypeName, final String sNewTypeName) {
if (sOldTypeName.equals(sNewTypeName) || (!isLocalProcessingDescriptor()))
return;
@@ -1461,6 +1757,7 @@ public class TypeSection extends Abstrac
capabilityChanged[0] = false;
final String oldTypeName_colon = sOldTypeName + ':';
CapabilityVisitor cv = new CapabilityVisitor() {
+ @Override
boolean visit(TypeOrFeature i_o) {
if (i_o.isType() && i_o.getName().equals(sOldTypeName)) {
capabilityChanged[0] = true;
@@ -1522,10 +1819,23 @@ public class TypeSection extends Abstrac
}
+ /**
+ * Checks if is feature used in index.
+ *
+ * @param td the td
+ * @param featureName the feature name
+ * @return true, if is feature used in index
+ */
private boolean isFeatureUsedInIndex(TypeDescription td, String featureName) {
return isFeatureUsedInIndex(td.getName() + ":" + featureName);
}
+ /**
+ * Checks if is feature used in index.
+ *
+ * @param fullFeatureName the full feature name
+ * @return true, if is feature used in index
+ */
private boolean isFeatureUsedInIndex(String fullFeatureName) {
if (!isLocalProcessingDescriptor()) {
return false;
@@ -1547,15 +1857,29 @@ public class TypeSection extends Abstrac
return false;
}
+ /**
+ * Checks if is feature in use elsewhere.
+ *
+ * @param td the td
+ * @param featureName the feature name
+ * @return true, if is feature in use elsewhere
+ */
private boolean isFeatureInUseElsewhere(TypeDescription td, String featureName) {
return isFeatureInUseElsewhere(td.getName() + ':' + featureName);
}
+ /**
+ * Checks if is feature in use elsewhere.
+ *
+ * @param typePlusFeature the type plus feature
+ * @return true, if is feature in use elsewhere
+ */
private boolean isFeatureInUseElsewhere(final String typePlusFeature) {
if (!isLocalProcessingDescriptor()) { // not strictly true for imports....
return false;
}
CapabilityVisitor v = new CapabilityVisitor() {
+ @Override
boolean visit(TypeOrFeature i_o) {
if ((!i_o.isType()) && i_o.getName().equals(typePlusFeature)) {
return true;
@@ -1570,10 +1894,26 @@ public class TypeSection extends Abstrac
return isFeatureUsedInIndex(typePlusFeature);
}
+ /**
+ * The Class CapabilityVisitor.
+ */
private abstract class CapabilityVisitor {
+
+ /**
+ * Visit.
+ *
+ * @param i_o the i o
+ * @return true, if successful
+ */
abstract boolean visit(TypeOrFeature i_o);
}
+ /**
+ * Capability visit.
+ *
+ * @param v the v
+ * @return true, if successful
+ */
private boolean capabilityVisit(CapabilityVisitor v) {
Capability[] c = getCapabilities();
for (int ic = 0; ic < c.length; ic++) {
@@ -1594,6 +1934,13 @@ public class TypeSection extends Abstrac
return false;
}
+ /**
+ * Alter feature mentions.
+ *
+ * @param sOldFeatureName the s old feature name
+ * @param sNewFeatureName the s new feature name
+ * @param typeName the type name
+ */
private void alterFeatureMentions(final String sOldFeatureName, final String sNewFeatureName,
final String typeName) {
final boolean[] somethingChanged = new boolean[1];
@@ -1603,6 +1950,7 @@ public class TypeSection extends Abstrac
final String oldFullFeatureName = typeName + ':' + sOldFeatureName;
final String newFullFeatureName = typeName + ':' + sNewFeatureName;
CapabilityVisitor v = new CapabilityVisitor() {
+ @Override
boolean visit(TypeOrFeature i_o) {
if (!i_o.isType() && i_o.getName().equals(oldFullFeatureName)) {
somethingChanged[0] = true;
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/Utility.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/Utility.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/Utility.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/Utility.java Sun Nov 13 16:13:16 2016
@@ -30,17 +30,23 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Utility.
+ */
// MessageDialog extended only to enable resize
public class Utility extends MessageDialog {
/**
- * @param parentShell
- * @param dialogTitle
- * @param dialogTitleImage
- * @param dialogMessage
- * @param dialogImageType
- * @param dialogButtonLabels
- * @param defaultIndex
+ * Instantiates a new utility.
+ *
+ * @param parentShell the parent shell
+ * @param dialogTitle the dialog title
+ * @param dialogTitleImage the dialog title image
+ * @param dialogMessage the dialog message
+ * @param dialogImageType the dialog image type
+ * @param dialogButtonLabels the dialog button labels
+ * @param defaultIndex the default index
*/
public Utility(Shell parentShell, String dialogTitle, Image dialogTitleImage,
String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) {
@@ -49,34 +55,33 @@ public class Utility extends MessageDial
// TODO Auto-generated constructor stub
}
+ /** The Constant OK_CANCEL. */
final private static String[] OK_CANCEL = { "OK", "Cancel" };
+ /** The Constant OKstring. */
final private static String[] OKstring = { "OK" };
/**
- * Pops up a warning message with an "OK" and "Cancel" button
- *
- * @param title
- * of the warning
- * @param message
- * @param type
- * one of MessageDialog.NONE for a dialog with no image MessageDialog.ERROR for a dialog
+ * Pops up a warning message with an "OK" and "Cancel" button.
+ *
+ * @param title of the warning
+ * @param message the message
+ * @param type one of MessageDialog.NONE for a dialog with no image MessageDialog.ERROR for a dialog
* with an error image MessageDialog.INFORMATION for a dialog with an information image
* MessageDialog.QUESTION for a dialog with a question image MessageDialog.WARNING for a
* dialog with a warning image
+ * @return the int
*/
public static int popOkCancel(String title, String message, int type) {
return popMessage(title, message, type, OK_CANCEL);
}
/**
- * Pops up a warning message with an "OK" button
- *
- * @param title
- * of the warning
- * @param message
- * @param type
- * one of MessageDialog.NONE for a dialog with no image MessageDialog.ERROR for a dialog
+ * Pops up a warning message with an "OK" button.
+ *
+ * @param title of the warning
+ * @param message the message
+ * @param type one of MessageDialog.NONE for a dialog with no image MessageDialog.ERROR for a dialog
* with an error image MessageDialog.INFORMATION for a dialog with an information image
* MessageDialog.QUESTION for a dialog with a question image MessageDialog.WARNING for a
* dialog with a warning image
@@ -86,10 +91,27 @@ public class Utility extends MessageDial
popMessage(title, message, type, OKstring);
}
+ /**
+ * Pop message.
+ *
+ * @param w the w
+ * @param title the title
+ * @param message the message
+ * @param type the type
+ */
public static void popMessage(Widget w, String title, String message, int type) {
popMessage(w, title, message, type, OKstring);
}
+ /**
+ * Pop message.
+ *
+ * @param title the title
+ * @param message the message
+ * @param type the type
+ * @param buttons the buttons
+ * @return the int
+ */
public static int popMessage(String title, String message, int type, String[] buttons) {
return popMessage(new Shell(), title,message, type, buttons);
// Utility dialog = new Utility(new Shell(), title, null, message, type, buttons, 0);
@@ -101,6 +123,16 @@ public class Utility extends MessageDial
// return returnCode;
}
+ /**
+ * Pop message.
+ *
+ * @param parent the parent
+ * @param title the title
+ * @param message the message
+ * @param type the type
+ * @param buttons the buttons
+ * @return the int
+ */
public static int popMessage(Shell parent, String title, String message, int type, String[] buttons) {
Utility dialog = new Utility(parent, title, null, message, type, buttons, 0);
dialog.setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
@@ -110,16 +142,27 @@ public class Utility extends MessageDial
return returnCode;
}
+ /**
+ * Pop message.
+ *
+ * @param w the w
+ * @param title the title
+ * @param message the message
+ * @param type the type
+ * @param buttons the buttons
+ * @return the int
+ */
// https://issues.apache.org/jira/browse/UIMA-2114
public static int popMessage(Widget w, String title, String message, int type, String[] buttons) {
return popMessage(w.getDisplay().getActiveShell(), title, message, type, buttons);
}
+
/**
- * remove element(s) (must be present) using == test
- *
- * @param source
- * @param element
- * @param componentClass
+ * remove element(s) (must be present) using == test.
+ *
+ * @param source the source
+ * @param element the element
+ * @param componentClass the component class
* @return a copy of the array with == element(s) removed
*/
@@ -134,11 +177,11 @@ public class Utility extends MessageDial
}
/**
- * remove element(s) (must be present) using equals test
- *
- * @param source
- * @param element
- * @param componentClass
+ * remove element(s) (must be present) using equals test.
+ *
+ * @param source the source
+ * @param element the element
+ * @param componentClass the component class
* @return a copy of the array with equal element(s) removed
*/
@@ -155,6 +198,14 @@ public class Utility extends MessageDial
return result;
}
+ /**
+ * Removes the elements from array.
+ *
+ * @param source the source
+ * @param element the element
+ * @param componentClass the component class
+ * @return the object[]
+ */
public static Object[] removeElementsFromArray(Object[] source, Object element,
Class componentClass) {
if (null == source)
@@ -175,6 +226,15 @@ public class Utility extends MessageDial
return result;
}
+ /**
+ * Removes the elements from array.
+ *
+ * @param source the source
+ * @param element the element
+ * @param componentClass the component class
+ * @param comp the comp
+ * @return the object[]
+ */
public static Object[] removeElementsFromArray(Object[] source, Object element,
Class componentClass, Comparator comp) {
if (null == source)
@@ -195,6 +255,14 @@ public class Utility extends MessageDial
return result;
}
+ /**
+ * Adds the element to array.
+ *
+ * @param source the source
+ * @param element the element
+ * @param componentClass the component class
+ * @return the object[]
+ */
public static Object[] addElementToArray(Object[] source, Object element, Class componentClass) {
final int newLength = (null == source) ? 1 : source.length + 1;
Object[] result = (Object[]) Array.newInstance(componentClass, newLength);
@@ -203,6 +271,13 @@ public class Utility extends MessageDial
return result;
}
+ /**
+ * Array contains.
+ *
+ * @param array the array
+ * @param element the element
+ * @return true, if successful
+ */
public static boolean arrayContains(Object[] array, Object element) {
if (null == element)
throw new InternalErrorCDE("null not allowed as an argument");
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ValueSection.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ValueSection.java?rev=1769512&r1=1769511&r2=1769512&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ValueSection.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-ep-configurator/src/main/java/org/apache/uima/taeconfigurator/editors/ui/ValueSection.java Sun Nov 13 16:13:16 2016
@@ -42,40 +42,66 @@ import org.eclipse.swt.widgets.TableItem
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IManagedForm;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ValueSection.
+ */
public class ValueSection extends AbstractSectionParm {
+ /** The value text stack. */
private Composite valueTextStack;
+ /** The value text stack layout. */
private StackLayout valueTextStackLayout;
+ /** The value text. */
private Text valueText;
+ /** The value text combo. */
private CCombo valueTextCombo;
+ /** The vtc 1. */
private Composite vtc1;
+ /** The vtc 2. */
private Composite vtc2;
+ /** The value table. */
private Table valueTable;
+ /** The master. */
private ParameterSettingsSection master;
+ /** The add button. */
private Button addButton;
+ /** The edit button. */
private Button editButton;
+ /** The remove button. */
private Button removeButton;
+ /** The up button. */
private Button upButton;
+ /** The down button. */
private Button downButton;
+ /** The button container. */
private Composite buttonContainer;
+ /** The selected CP. */
private ConfigurationParameter selectedCP;
+ /** The model settings. */
private ConfigurationParameterSettings modelSettings;
+ /**
+ * Instantiates a new value section.
+ *
+ * @param editor the editor
+ * @param parent the parent
+ */
public ValueSection(MultiPageEditor editor, Composite parent) {
super(editor, parent, "Values", "Specify the value of the selected configuration parameter.");
}
@@ -86,6 +112,7 @@ public class ValueSection extends Abstra
*
* @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
*/
+ @Override
public void initialize(IManagedForm form) {
super.initialize(form);
@@ -138,6 +165,7 @@ public class ValueSection extends Abstra
*
* @see org.eclipse.ui.forms.IFormPart#refresh()
*/
+ @Override
public void refresh() {
super.refresh();
master = editor.getSettingsPage().getParameterSettingsSection();
@@ -184,6 +212,10 @@ public class ValueSection extends Abstra
enable();
}
+ /* (non-Javadoc)
+ * @see org.apache.uima.taeconfigurator.editors.ui.AbstractSectionParm#enable()
+ */
+ @Override
public void enable() {
boolean mvValue = (null != selectedCP) && (selectedCP.isMultiValued());
@@ -205,6 +237,7 @@ public class ValueSection extends Abstra
*
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
+ @Override
public void handleEvent(Event event) {
if (event.widget == valueText) {
@@ -275,6 +308,11 @@ public class ValueSection extends Abstra
enable();
}
+ /**
+ * Sets the parm value.
+ *
+ * @param value the new parm value
+ */
private void setParmValue(String value) {
if (null != value) {
if ("".equals(value))
@@ -283,24 +321,49 @@ public class ValueSection extends Abstra
}
}
+ /**
+ * Handle remove.
+ *
+ * @param event the event
+ */
public void handleRemove(Event event) {
valueTable.remove(valueTable.getSelectionIndices());
// update model
setCurrentParameterValue(valueTable.getItems());
}
+ /**
+ * Gets the adds the button.
+ *
+ * @return the adds the button
+ */
public Button getAddButton() {
return addButton;
}
+ /**
+ * Gets the removes the button.
+ *
+ * @return the removes the button
+ */
public Button getRemoveButton() {
return removeButton;
}
+ /**
+ * Gets the value table.
+ *
+ * @return the value table
+ */
public Table getValueTable() {
return valueTable;
}
+ /**
+ * Gets the value text.
+ *
+ * @return the value text
+ */
public Text getValueText() {
return valueText;
}
@@ -308,8 +371,8 @@ public class ValueSection extends Abstra
/**
* Sets the currently selected parameter to the specified value. The string value will be
* converted to the appropriate data type. This method works only for single-valued parameters.
- *
- * @param aValueString
+ *
+ * @param aValueString the new current parameter value
*/
private void setCurrentParameterValue(String aValueString) {
@@ -384,6 +447,11 @@ public class ValueSection extends Abstra
setModelValue(valueArr);
}
+ /**
+ * Sets the model value.
+ *
+ * @param value the new model value
+ */
private void setModelValue(Object value) {
String groupName = master.getSelectedParamGroupName();
boolean changed = false;
@@ -415,6 +483,13 @@ public class ValueSection extends Abstra
editor.setFileDirty();
}
+ /**
+ * Checks if is same value.
+ *
+ * @param v1 the v 1
+ * @param v2 the v 2
+ * @return true, if is same value
+ */
private boolean isSameValue(Object v1, Object v2) {
if (v1 instanceof Object[]) {
return (Arrays.equals((Object[]) v1, (Object[]) v2));