[New] added Parameter.getIndex()
This commit is contained in:
parent
49df0b54da
commit
5915fe086d
|
@ -216,21 +216,27 @@ public class ModelGenerator {
|
|||
public static void addAllParameters(ParameterBag bag) {
|
||||
|
||||
BooleanParameter boolParam = new BooleanParameter(PARAM_BOOLEAN_ID, PARAM_BOOLEAN_NAME, true);
|
||||
boolParam.setIndex(1);
|
||||
bag.addParameter(boolParam);
|
||||
|
||||
FloatParameter floatParam = new FloatParameter(PARAM_FLOAT_ID, PARAM_FLOAT_NAME, 44.3);
|
||||
floatParam.setIndex(2);
|
||||
bag.addParameter(floatParam);
|
||||
|
||||
IntegerParameter integerParam = new IntegerParameter(PARAM_INTEGER_ID, PARAM_INTEGER_NAME, 77);
|
||||
integerParam.setIndex(3);
|
||||
bag.addParameter(integerParam);
|
||||
|
||||
LongParameter longParam = new LongParameter(PARAM_LONG_ID, PARAM_LONG_NAME, 4453234566L);
|
||||
longParam.setIndex(4);
|
||||
bag.addParameter(longParam);
|
||||
|
||||
StringParameter stringParam = new StringParameter(PARAM_STRING_ID, PARAM_STRING_NAME, "Strolch");
|
||||
stringParam.setIndex(5);
|
||||
bag.addParameter(stringParam);
|
||||
|
||||
DateParameter dateParam = new DateParameter(PARAM_DATE_ID, PARAM_DATE_NAME, new Date(1354295525628L));
|
||||
dateParam.setIndex(6);
|
||||
bag.addParameter(dateParam);
|
||||
|
||||
ArrayList<String> stringList = new ArrayList<String>();
|
||||
|
@ -238,6 +244,7 @@ public class ModelGenerator {
|
|||
stringList.add("World");
|
||||
StringListParameter stringListP = new StringListParameter(PARAM_LIST_STRING_ID, PARAM_LIST_STRING_NAME,
|
||||
stringList);
|
||||
stringListP.setIndex(7);
|
||||
bag.addParameter(stringListP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public class Tags {
|
|||
public static final String INTERPRETATION = "Interpretation";
|
||||
public static final String UOM = "Uom";
|
||||
public static final String HIDDEN = "Hidden";
|
||||
public static final String INDEX = "Index";
|
||||
public static final String PARAMETER = "Parameter";
|
||||
public static final String PARAMETERIZED_ELEMENT = "ParameterizedElement";
|
||||
public static final String RESOURCE = "Resource";
|
||||
|
|
|
@ -39,6 +39,7 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
private static final long serialVersionUID = 0L;
|
||||
|
||||
protected boolean hidden = false;
|
||||
protected int index;
|
||||
protected String interpretation = INTERPRETATION_NONE;
|
||||
protected String uom = UOM_NONE;
|
||||
|
||||
|
@ -99,6 +100,16 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParameterizedElement getParent() {
|
||||
return this.parent;
|
||||
|
@ -122,6 +133,8 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
element.setAttribute(Tags.UOM, this.uom);
|
||||
if (this.hidden)
|
||||
element.setAttribute(Tags.HIDDEN, Boolean.toString(this.hidden));
|
||||
if (this.index != 0)
|
||||
element.setAttribute(Tags.INDEX, Integer.toString(this.index));
|
||||
|
||||
return element;
|
||||
}
|
||||
|
@ -145,10 +158,17 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
String interpretation = element.getAttribute(Tags.INTERPRETATION);
|
||||
String hidden = element.getAttribute(Tags.HIDDEN);
|
||||
String uom = element.getAttribute(Tags.UOM);
|
||||
String index = element.getAttribute(Tags.INDEX);
|
||||
|
||||
setInterpretation(interpretation);
|
||||
setUom(uom);
|
||||
|
||||
if(StringHelper.isEmpty(index)) {
|
||||
this.index = 0;
|
||||
} else {
|
||||
this.index = Integer.valueOf(index);
|
||||
}
|
||||
|
||||
if (StringHelper.isEmpty(hidden)) {
|
||||
setHidden(false);
|
||||
} else {
|
||||
|
@ -205,6 +225,7 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
|||
clone.setHidden(this.hidden);
|
||||
clone.setInterpretation(this.interpretation);
|
||||
clone.setUom(this.uom);
|
||||
clone.setIndex(this.index);
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
|
|
|
@ -97,6 +97,21 @@ public interface Parameter<T> extends StrolchElement {
|
|||
*/
|
||||
public void setUom(String uom);
|
||||
|
||||
/**
|
||||
* Returns the index of this {@link Parameter}. This can be used to sort the parameters in a UI
|
||||
*
|
||||
* @return the index of this {@link Parameter}. This can be used to sort the parameters in a UI
|
||||
*/
|
||||
public int getIndex();
|
||||
|
||||
/**
|
||||
* Set the index of this {@link Parameter}. This can be used to sort the parameters in a UI
|
||||
*
|
||||
* @param index
|
||||
* the index to set
|
||||
*/
|
||||
public void setIndex(int index);
|
||||
|
||||
/**
|
||||
* The {@link ParameterizedElement} parent to which this {@link Parameter} belongs
|
||||
*
|
||||
|
|
|
@ -127,6 +127,8 @@ public class StrolchElementDeepEqualsVisitor {
|
|||
this.mismatchedLocators.add(dstParam.getLocator());
|
||||
if (srcParam.isHidden() != dstParam.isHidden())
|
||||
this.mismatchedLocators.add(dstParam.getLocator());
|
||||
if (srcParam.getIndex() != dstParam.getIndex())
|
||||
this.mismatchedLocators.add(dstParam.getLocator());
|
||||
|
||||
if (!srcParam.getValue().equals(dstParam.getValue()))
|
||||
this.mismatchedLocators.add(dstParam.getLocator());
|
||||
|
|
|
@ -75,6 +75,8 @@ public abstract class AbstractToSaxWriterVisitor {
|
|||
this.writer.writeAttribute(Tags.UOM, parameter.getUom());
|
||||
if (parameter.isHidden())
|
||||
this.writer.writeAttribute(Tags.HIDDEN, Boolean.toString(parameter.isHidden()));
|
||||
if (parameter.getIndex() != 0)
|
||||
this.writer.writeAttribute(Tags.INDEX, Integer.toString(parameter.getIndex()));
|
||||
|
||||
this.writer.writeAttribute(Tags.VALUE, parameter.getValueAsString());
|
||||
}
|
||||
|
|
|
@ -67,6 +67,8 @@ public abstract class StrolchElementToDomVisitor {
|
|||
attributes.addAttribute(null, null, Tags.INTERPRETATION, Tags.CDATA, parameter.getInterpretation());
|
||||
if (parameter.isHidden())
|
||||
attributes.addAttribute(null, null, Tags.HIDDEN, Tags.CDATA, Boolean.toString(parameter.isHidden()));
|
||||
if (parameter.getIndex() != 0)
|
||||
attributes.addAttribute(null, null, Tags.INDEX, Tags.CDATA, Integer.toString(parameter.getIndex()));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,9 @@ public class XmlModelSaxReader extends DefaultHandler {
|
|||
String paramType = attributes.getValue(Tags.TYPE);
|
||||
String paramValue = attributes.getValue(Tags.VALUE);
|
||||
String paramHiddenS = attributes.getValue(Tags.HIDDEN);
|
||||
boolean paramHidden = paramHiddenS == null ? false : StringHelper.parseBoolean(paramHiddenS);
|
||||
String paramIndexS = attributes.getValue(Tags.INDEX);
|
||||
int index = StringHelper.isEmpty(paramIndexS) ? 0 : Integer.valueOf(paramIndexS);
|
||||
boolean paramHidden = StringHelper.isEmpty(paramHiddenS) ? false : StringHelper.parseBoolean(paramHiddenS);
|
||||
String paramUom = attributes.getValue(Tags.UOM);
|
||||
String paramInterpretation = attributes.getValue(Tags.INTERPRETATION);
|
||||
Parameter<?> param;
|
||||
|
@ -152,6 +154,7 @@ public class XmlModelSaxReader extends DefaultHandler {
|
|||
param.setHidden(paramHidden);
|
||||
param.setUom(paramUom);
|
||||
param.setInterpretation(paramInterpretation);
|
||||
param.setIndex(index);
|
||||
this.pBag.addParameter(param);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue