public DefaultMutableModuleItem(final ModuleInfo info, final String name, final Class<T> type) { super(info); this.name = name; this.type = type; genericType = type; ioType = super.getIOType(); visibility = super.getVisibility(); required = super.isRequired(); persisted = super.isPersisted(); persistKey = super.getPersistKey(); initializer = super.getInitializer(); validater = super.getValidater(); callback = super.getCallback(); widgetStyle = super.getWidgetStyle(); minimumValue = super.getMinimumValue(); maximumValue = super.getMaximumValue(); stepSize = super.getStepSize(); columnCount = super.getColumnCount(); final List<T> superChoices = super.getChoices(); if (superChoices != null) choices.addAll(superChoices); label = super.getLabel(); description = super.getDescription(); }
@Override public String toString() { final StringMaker sm = new StringMaker(); sm.append("label", getLabel()); sm.append("description", getDescription()); sm.append("visibility", getVisibility(), ItemVisibility.NORMAL); sm.append("required", isRequired()); sm.append("persisted", isPersisted()); sm.append("persistKey", getPersistKey()); sm.append("callback", getCallback()); sm.append("widgetStyle", getWidgetStyle()); sm.append("default", getDefaultValue()); sm.append("min", getMinimumValue()); sm.append("max", getMaximumValue()); sm.append("softMin", getSoftMinimum()); sm.append("softMax", getSoftMaximum()); sm.append("stepSize", getStepSize(), NumberUtils.toNumber("1", getType())); sm.append("columnCount", getColumnCount(), 6); sm.append("choices", getChoices()); return getName() + ": " + sm.toString(); }
@Override @Deprecated public void saveValue(final T value) { if (!isPersisted()) return; final String sValue = value == null ? "" : value.toString(); // do not persist if object cannot be converted back from a string if (!ConversionUtils.canConvert(sValue, getType())) return; final String persistKey = getPersistKey(); if (persistKey == null || persistKey.isEmpty()) { final Class<?> prefClass = getDelegateClass(); final String prefKey = getName(); Prefs.put(prefClass, prefKey, sValue); } else Prefs.put(persistKey, sValue); }
@Override public boolean isOutput() { final ItemIO ioType = getIOType(); return ioType == ItemIO.OUTPUT || ioType == ItemIO.BOTH; }
@Override public T getSoftMaximum() { // NB: Return hard maximum by default. return getMaximumValue(); }
@Override public void callback(final Module module) throws MethodCallException { final Object delegateObject = module.getDelegateObject(); if (callbackRef == null) { callbackRef = new MethodRef(delegateObject.getClass(), getCallback()); } callbackRef.execute(delegateObject); }
@Override public List<T> getChoices() { final String[] choices = getParameter().choices(); if (choices.length == 0) return super.getChoices(); final ArrayList<T> choiceList = new ArrayList<>(); for (final String choice : choices) { choiceList.add(tValue(choice)); } return choiceList; }
@Override public void initialize(final Module module) throws MethodCallException { final Object delegateObject = module.getDelegateObject(); if (initializerRef == null) { initializerRef = new MethodRef(delegateObject.getClass(), getInitializer()); } initializerRef.execute(module.getDelegateObject()); }
@Override public String toString() { final StringMaker sm = new StringMaker(); sm.append("label", getLabel()); sm.append("description", getDescription()); sm.append("visibility", getVisibility(), ItemVisibility.NORMAL); sm.append("required", isRequired()); sm.append("persisted", isPersisted()); sm.append("persistKey", getPersistKey()); sm.append("callback", getCallback()); sm.append("widgetStyle", getWidgetStyle()); sm.append("default", getDefaultValue()); sm.append("min", getMinimumValue()); sm.append("max", getMaximumValue()); sm.append("softMin", getSoftMinimum()); sm.append("softMax", getSoftMaximum()); sm.append("stepSize", getStepSize(), NumberUtils.toNumber("1", getType())); sm.append("columnCount", getColumnCount(), 6); sm.append("choices", getChoices()); return getName() + ": " + sm.toString(); }
@Override @Deprecated public void saveValue(final T value) { if (!isPersisted()) return; final String sValue = value == null ? "" : value.toString(); // do not persist if object cannot be converted back from a string if (!ConversionUtils.canConvert(sValue, getType())) return; final String persistKey = getPersistKey(); if (persistKey == null || persistKey.isEmpty()) { final Class<?> prefClass = getDelegateClass(); final String prefKey = getName(); Prefs.put(prefClass, prefKey, sValue); } else Prefs.put(persistKey, sValue); }
@Override public boolean isOutput() { final ItemIO ioType = getIOType(); return ioType == ItemIO.OUTPUT || ioType == ItemIO.BOTH; }
@Override public T getSoftMaximum() { // NB: Return hard maximum by default. return getMaximumValue(); }
@Override public void callback(final Module module) throws MethodCallException { final Object delegateObject = module.getDelegateObject(); if (callbackRef == null) { callbackRef = new MethodRef(delegateObject.getClass(), getCallback()); } callbackRef.execute(delegateObject); }
@Override public List<T> getChoices() { final String[] choices = getParameter().choices(); if (choices.length == 0) return super.getChoices(); final ArrayList<T> choiceList = new ArrayList<>(); for (final String choice : choices) { choiceList.add(tValue(choice)); } return choiceList; }
@Override public void initialize(final Module module) throws MethodCallException { final Object delegateObject = module.getDelegateObject(); if (initializerRef == null) { initializerRef = new MethodRef(delegateObject.getClass(), getInitializer()); } initializerRef.execute(module.getDelegateObject()); }
public DefaultMutableModuleItem(final ModuleInfo info, final String name, final Class<T> type) { super(info); this.name = name; this.type = type; genericType = type; ioType = super.getIOType(); visibility = super.getVisibility(); required = super.isRequired(); persisted = super.isPersisted(); persistKey = super.getPersistKey(); initializer = super.getInitializer(); validater = super.getValidater(); callback = super.getCallback(); widgetStyle = super.getWidgetStyle(); minimumValue = super.getMinimumValue(); maximumValue = super.getMaximumValue(); stepSize = super.getStepSize(); columnCount = super.getColumnCount(); final List<T> superChoices = super.getChoices(); if (superChoices != null) choices.addAll(superChoices); label = super.getLabel(); description = super.getDescription(); }
/** * Returns the persisted value of a ModuleItem. Returns null if nothing has * been persisted. It is the API user's responsibility to check the return * value for null. */ @Override @Deprecated public T loadValue() { // if there is nothing to load from persistence return nothing if (!isPersisted()) return null; final String sValue; final String persistKey = getPersistKey(); if (persistKey == null || persistKey.isEmpty()) { final Class<?> prefClass = getDelegateClass(); final String prefKey = getName(); sValue = Prefs.get(prefClass, prefKey); } else sValue = Prefs.get(persistKey); // if persisted value has never been set before return null if (sValue == null) return null; return ConversionUtils.convert(sValue, getType()); }
@Override public boolean isInput() { final ItemIO ioType = getIOType(); return ioType == ItemIO.INPUT || ioType == ItemIO.BOTH; }
/** * Returns the persisted value of a ModuleItem. Returns null if nothing has * been persisted. It is the API user's responsibility to check the return * value for null. */ @Override @Deprecated public T loadValue() { // if there is nothing to load from persistence return nothing if (!isPersisted()) return null; final String sValue; final String persistKey = getPersistKey(); if (persistKey == null || persistKey.isEmpty()) { final Class<?> prefClass = getDelegateClass(); final String prefKey = getName(); sValue = Prefs.get(prefClass, prefKey); } else sValue = Prefs.get(persistKey); // if persisted value has never been set before return null if (sValue == null) return null; return ConversionUtils.convert(sValue, getType()); }
@Override public boolean isInput() { final ItemIO ioType = getIOType(); return ioType == ItemIO.INPUT || ioType == ItemIO.BOTH; }