@Override public void enable() { boolean mvValue = (null != selectedCP) && (selectedCP.isMultiValued()); valueText.setVisible((null != selectedCP) && (!selectedCP.isMultiValued())); valueTextCombo.setVisible((null != selectedCP) && (!selectedCP.isMultiValued())); addButton.setEnabled(mvValue); int selected = valueTable.getSelectionIndex(); editButton.setEnabled(mvValue && selected > -1); removeButton.setEnabled(mvValue && selected > -1); upButton.setEnabled(mvValue && selected > 0); downButton.setEnabled(mvValue && (selected > -1) && (selected < (valueTable.getItemCount() - 1))); valueText.getParent().redraw(); }
/** * Parm spec matches. * * @param p the p * @param q the q * @return true, if successful */ private boolean parmSpecMatches(ConfigurationParameter p, ConfigurationParameter q) { if (!p.getType().equals(q.getType())) return false; if (p.isMandatory() != q.isMandatory()) return false; if (p.isMultiValued() != q.isMultiValued()) return false; return true; }
if (aParam.isMultiValued()) { if (ConfigurationParameter.TYPE_STRING.equals(paramType)) { return String[].class;
/** * Parm gui string. * * @param parm the parm * @return the string */ protected String parmGuiString(ConfigurationParameter parm) { return ((parm.isMultiValued()) ? MULTI_VALUE_INDICATOR : SINGLE_VALUE_INDICATOR) + ((parm.isMandatory()) ? REQUIRED_INDICATOR : OPTIONAL_INDICATOR) + typeNamesW.get(parm.getType()) + ((parm.getExternalOverrideName()==null) ? NO_EXTERNAL_OVERRIDE_INDICATOR : EXTERNAL_OVERRIDE_INDICATOR) + nameHeader + parm.getName(); }
protected void validateConfigurationParameterDataTypeMatch( org.apache.uima.resource.metadata.ConfigurationParameter aParam, NameValuePair aNVP ) throws ResourceConfigurationException { String paramName = aParam.getName(); String paramType = aParam.getType(); Class valClass = aNVP.getValue().getClass(); if ( aParam.isMultiValued() ) { if ( !valClass.isArray() ) { throw new ResourceConfigurationException( "array_required", new Object[]{ paramName, this.getName() } ); } valClass = valClass.getComponentType(); if ( Array.getLength( aNVP.getValue() ) == 0 && valClass.equals( Object.class ) ) { aNVP.setValue( Array.newInstance( this.getClassForParameterType( paramType ), 0 ) ); return; } } if ( valClass != this.getClassForParameterType( paramType ) ) { throw new ResourceConfigurationException( "parameter_type_mismatch", new Object[]{ this.getName(), valClass.getName(), paramName, paramType } ); } }
/** * Validate that a value is of an appropriate data type for assignment to the given parameter. * * @param aParam * configuration parameter * @param aValue * candidate value * @param aContextName * name of context, used to generate error message * * @throws ResourceConfigurationException * if the data types do not match */ private void validateConfigurationParameterDataTypeMatch(ConfigurationParameter aParam, Object aValue, String aContextName) throws ResourceConfigurationException { if (aValue != null) { Class<?> valClass = aValue.getClass(); if (aParam.isMultiValued() && !valClass.isArray()) { throw new ResourceConfigurationException(ResourceConfigurationException.ARRAY_REQUIRED, new Object[] { aParam.getName(), aContextName }); } if (!valClass.equals(getParameterExpectedValueClass(aParam))) { throw new ResourceConfigurationException( ResourceConfigurationException.PARAMETER_TYPE_MISMATCH, new Object[] { aContextName, valClass.getName(), aParam.getName(), aParam.getType() }); } } }
boolean isMultiValued = cp.isMultiValued(); String type = cp.getType(); for (int i = 0; i < parms.length; i++) { if ((isMultiValued != parms[i].isMultiValued())) continue;
/** * Alter existing configuration parameter. * * @param dialog the dialog * @param existingTreeItem the existing tree item */ private void alterExistingConfigurationParameter(AddParameterDialog dialog, TreeItem existingTreeItem) { ConfigurationParameter existingCP = getCorrespondingModelParm(existingTreeItem); ConfigurationParameter previousCP = existingCP; previousCP = (ConfigurationParameter) previousCP.clone(); fillModelParm(dialog, existingCP); fillParmItem(existingTreeItem, existingCP); // the following may have changed in an existing param spec, that could // affect the setting: // 1) the name, 2) the type, 3) the multi-value aspect // Description or mandatory changes have no effect on the settings // If the multi-value aspect changes, drop all the settings // If the type changes, drop all the settings // If the name changes, change existing settings for that parm name in all groups if ((!previousCP.getType().equals(existingCP.getType())) || (previousCP.isMultiValued() != existingCP.isMultiValued())) { removeParmSettingFromMultipleGroups(existingTreeItem, !REMOVE_FROM_GUI); } commonParmUpdate(existingTreeItem, existingCP, previousCP.getName()); }
if ((value != null) && decl.isMultiValued() && !isMultiValue(value)) { value = Array.newInstance(value.getClass(), 1); Array.set(value, 0, configurationValues[i]);
String name = parameters[i].getName(); String type = parameters[i].getType(); boolean multiValued = parameters[i].isMultiValued();
sb.append("<li><b>type:</b> " + each.getType() + "</li>"); sb.append("<li><b>mandatory:</b> " + each.isMandatory() + "</li>"); sb.append("<li><b>multiValued:</b> " + each.isMultiValued() + "</li>"); if (each.getDescription() != null && !each.getDescription().trim().isEmpty()) { sb.append("<p>");
: modelSettings.getParameterValue(groupName, parmName); if (selectedCP.isMultiValued()) {
if (aParam.isMultiValued()) // value must be an array
String extName = aParams[i].getExternalOverrideName(); if (extName != null && aExternalOverrides != null) { if (aParams[i].isMultiValued()) { String[] propValues = aExternalOverrides.getSettingArray(extName); if (propValues != null) { continue; if (aParams[i].isMultiValued()) { try { Object[] array = (Object[]) realValue;
String type = configurationParameter.getType(); if (type.equals("String")) { if (configurationParameter.isMultiValued()) { if (value instanceof AbstractStringListExpression) { AbstractStringListExpression sle = (AbstractStringListExpression) value;
String type = configurationParameter.getType(); if (type.equals("String")) { if (configurationParameter.isMultiValued()) { if (value instanceof StringListExpression) { StringListExpression sle = (StringListExpression) value;
.getMetaData().getConfigurationParameterSettings(); boolean isMultiValue = cparam.isMultiValued();
/** * Adds the parm. * * @param name the name * @param modelParm the model parm * @param group the group * @param override the override */ public void addParm(String name, ConfigurationParameter modelParm, ConfigGroup group, String override) { TreeItem parentGroup = getTreeItemGroup(group); AddParameterDialog dialog = new AddParameterDialog(this, group); dialog.parmName = name; dialog.description = modelParm.getDescription(); dialog.mandatory = modelParm.isMandatory(); dialog.multiValue = modelParm.isMultiValued(); dialog.parmType = modelParm.getType(); // dialog.overrideSpec = override; ConfigurationParameter parmInGroup = addNewConfigurationParameter(dialog, parentGroup); addOverride(parmInGroup, override); parentGroup.setExpanded(true); commonActionFinish(); }
multiValueUI.setSelection(existingCP.isMultiValued()); mandatoryUI.setSelection(existingCP.isMandatory()); parmNameUI.setText(convertNull(existingCP.getName()));
/** * Fills in the model Configuration Parm from the Add/Edit dialog. called from * addNewConfigurationParameter, and alterExistingConfigurationParameter * * @param dialog the dialog * @param existingCP the existing CP */ private void fillModelParm(AddParameterDialog dialog, ConfigurationParameter existingCP) { valueChanged = false; existingCP.setName(setValueChanged(dialog.parmName, existingCP.getName())); existingCP.setDescription(setValueChanged(multiLineFix(dialog.description), existingCP .getDescription())); existingCP.setMandatory(setValueChangedBoolean(dialog.mandatory, existingCP.isMandatory())); existingCP .setMultiValued(setValueChangedBoolean(dialog.multiValue, existingCP.isMultiValued())); existingCP.setType(setValueChanged(dialog.parmType, existingCP.getType())); existingCP.setExternalOverrideName(setValueChanged(dialog.extParmName, existingCP.getExternalOverrideName())); if (valueChanged) setFileDirty(); }