public ValueInputField(WidgetPage<?> page, String id, Class<N> type, N defaultValue) { super(page, id); this.defaultValue = defaultValue; this.type = type; this.numberType = convertToEnum(type); }
/** * Set the number of decimal digits. Pass a negative value to show all digits. * @param nrDecimals * @param req */ public void setNrDecimals(short nrDecimals, OgemaHttpRequest req) { getData(req).setNrDecimals(nrDecimals); }
scheduleHorizonMinutes.setDefaultNumericalValue(1440L); scheduleHorizonMinutes.setDefaultLowerBound(1); this.newConfigSubmit = new Button(page, "newConfigSubmit", "Create new configuration") {
private void updateWidgets(OgemaHttpRequest req) { @SuppressWarnings("unchecked") final ArrayManipulator<N> widget = (ArrayManipulator<N>) this.widget; final N[] array = this.array; final int length = array == null ?0 : array.length; if (this.inputs.size() == length) return; final int diff = length - this.inputs.size(); if (diff > 0) { IntStream.range(this.inputs.size(), length) .forEach(i -> inputs.add(new InputWidget<N>(widget, req, ArrayManipulatorData.this, i))); } else { final List<ValueInputField<?>> subList = this.inputs.subList(length, this.inputs.size()); final List<ValueInputField<?>> toBeCleared = new ArrayList<>(subList); subList.clear(); toBeCleared.forEach(w -> { try { ArrayManipulatorData.this.removeItem(w); w.destroyWidget(); } catch (Exception e) { LoggerFactory.getLogger(ArrayManipulator.class).warn("Subwidget clearing failed",e); } }); } }
protected void setResource(A resource, OgemaHttpRequest req) { if (Objects.equals(this.resource, resource)) return; this.resource = resource; clear(); if (resource == null) return; final int length = getLength(resource); for (int i=0; i< length; i++) { final OgemaWidget in = createWidget(resource, i, widget, req); if (in instanceof ValueInputField) ((ValueInputField<?>) in).setDefaultNrDecimals(config.getNrDecimals()); in.setMargin("0.5em", false, false, true, false, req); // TODO if delete is allowed, add a delete button in.triggerAction(in, TriggeringAction.POST_REQUEST, TriggeredAction.GET_REQUEST, req); addItem(in); } }
final boolean createForecast = resSelectorCheckbox.getCheckboxList(req).get(1).isChecked(); final String forecast = createForecast ? schedulePathField.getValue(req) : null; final Long horizon = scheduleHorizonMinutes.getNumericalValue(req); if (forecast != null && !ResourceUtils.isValidResourcePath(forecast)) { alert.showAlert("Invalid schedule name: " + forecast, false, req);
public void setLowerBound(double lowerBound, OgemaHttpRequest req) { getData(req).setLowerBound(lowerBound); }
public ValueInputField(OgemaWidget parent, String id, Class<N> type, OgemaHttpRequest req) { super(parent, id, req); this.type = type; this.numberType = convertToEnum(type); }
public String getUnit(OgemaHttpRequest req) { return getData(req).getUnit(); }
public ValueInputField(WidgetPage<?> page, String id, boolean globalWidget, Class<N> type, N defaultValue) { super(page, id, globalWidget); this.defaultValue = defaultValue; this.type = type; this.numberType = convertToEnum(type); }
public void setUnit(String unit, OgemaHttpRequest req) { getData(req).setUnit(unit); }
public N getNumericalValue(OgemaHttpRequest req) { return getData(req).getNumericalValue(); }
public short getNrDecimals(OgemaHttpRequest req) { return getData(req).getNrDecimals(); }
public double getLowerBound(OgemaHttpRequest req) { return getData(req).getLowerBound(); }
public double getUpperBound(OgemaHttpRequest req) { return getData(req).getUpperBound(); }
public void setNumericalValue(N value,OgemaHttpRequest req) { getData(req).setNumericalValue(value); }
public void setUpperBound(double upperBound, OgemaHttpRequest req) { getData(req).setUpperBound(upperBound); }