public DegreePlanTable(TakesValue<CourseRequestInterface> requests, AssignmentProvider assignments) { iRequests = requests; iAssignments = assignments; addStyleName("unitine-DegreePlanTable"); setAllowSelection(true); setAllowMultiSelect(false); List<UniTimeTableHeader> header = new ArrayList<UniTimeTableHeader>(); UniTimeTableHeader hIndent = new UniTimeTableHeader(""); header.add(hIndent); UniTimeTableHeader hName = new UniTimeTableHeader(MESSAGES.colDegreeItemName(), 2); header.add(hName); UniTimeTableHeader hTitle = new UniTimeTableHeader(MESSAGES.colDegreeItemDescription()); header.add(hTitle); UniTimeTableHeader hLimit = new UniTimeTableHeader(MESSAGES.colLimit()); header.add(hLimit); UniTimeTableHeader hCredit = new UniTimeTableHeader(MESSAGES.colCredit()); header.add(hCredit); UniTimeTableHeader hNote = new UniTimeTableHeader(MESSAGES.colNote()); header.add(hNote); UniTimeTableHeader hReq = new UniTimeTableHeader(MESSAGES.colRequestPriority(), 2); header.add(hReq); addRow(null, header); }
/** * Set the widget that the EditorPanel will display. This method will automatically call * {@link #setEditor}. * * @param pwidget a {@link IsEditor} widget */ @Override @UiChild(limit = 1, tagname = "widget") public void setChildWidget(final TakesValue<T> pwidget) { this.widget = (Widget) pwidget; this.contents.add(this.widget); this.setEditor(new ExtendedValueBoxEditor<>(pwidget, this)); if (pwidget instanceof HasFocusHandlers) { ((HasFocusHandlers) pwidget) .addFocusHandler(pevent -> AbstractDecoratorWithLabel.this.addStyleToLabel()); } if (pwidget instanceof HasBlurHandlers) { ((HasBlurHandlers) pwidget).addBlurHandler(pevent -> { boolean hide = true; if (AbstractDecoratorWithLabel.this.widget instanceof TakesValue<?>) { hide = StringUtils.isEmpty(Objects .toString(((TakesValue<?>) AbstractDecoratorWithLabel.this.widget).getValue(), null)); } if (hide) { AbstractDecoratorWithLabel.this.removeStyleFromLabel(); } }); } }
public FormItemEditor(FormItem formItem) { item = formItem; item.setValidators(validator); editor = TakesValueEditor.of(new TakesValue<T>() { @Override public void setValue(T value) { item.setValue(value); } @Override public T getValue() { return (T) item.getValue(); } }); }
/** * constructor uses widget as base. * * @param ptakesValues widget which is able to set and get value from/to * @param pdecorator corresponding decorator */ public ExtendedValueBoxEditor(final TakesValue<T> ptakesValues, final AbstractDecorator<T> pdecorator) { super(null); this.messages = GWT.create(ExtendedValueBoxEditorMessages.class); this.takesValues = ptakesValues; this.decorator = pdecorator; if (this.takesValues instanceof ValueBoxBase<?>) { this.delegate = ((ValueBoxBase<T>) this.takesValues).asEditor().getDelegate(); } }
/** * Set the widget that the EditorPanel will display. This method will automatically call * {@link #setEditor}. * * @param pwidget a {@link IsEditor} widget */ @UiChild(limit = 1, tagname = "widget") public void setChildWidget(final TakesValue<T> pwidget) { this.widget = (Widget) pwidget; this.contents.add(this.widget); this.setEditor(new ExtendedValueBoxEditor<>(pwidget, this)); }
@SuppressWarnings("unchecked") @Override public final T getValue() { if (this.contents.getWidget() instanceof TakesValue<?>) { return ((TakesValue<T>) this.contents.getWidget()).getValue(); } else { return null; } }
@SuppressWarnings("unchecked") @Override public void setValue(final T pvalue, final boolean pfireEvents) { if (this.contents.getWidget() instanceof TakesValue<?>) { this.clearErrors(); if (this.contents.getWidget() instanceof HasValue<?>) { ((HasValue<T>) this.contents.getWidget()).setValue(pvalue, pfireEvents); } else { ((TakesValue<T>) this.contents.getWidget()).setValue(pvalue); } } }
@Override public void clearErrors() { super.clearErrors(); if (this.contents.getWidget() instanceof TakesValue<?>) { if (StringUtils.isEmpty( Objects.toString(((TakesValue<?>) this.contents.getWidget()).getValue(), null))) { this.removeStyleFromLabel(); } else { this.addStyleToLabel(); } } }
@Override public <F> F getValue(String id) { final WidgetBinding widgetBinding = bindings.get(id); if (widgetBinding != null) { TakesValue<?> hasValue = widgetBinding.widget; if (hasValue != null) { return (F) hasValue.getValue(); } } return null; }
@Override public <F> void setValue(String id, F value) { final WidgetBinding widgetBinding = bindings.get(id); if (widgetBinding != null) { TakesValue<?> hasValue = widgetBinding.widget; if (hasValue != null) { ((TakesValue<F>) hasValue).setValue(value); } } }
public void testBindReadOnlyWidget() { doTestBindWidget(new BindWidgetCallback() { @Override @SuppressWarnings("unchecked") public HandlerRegistration bind(ViewEngine engine, String propertyId, IsWidget widget) { return engine.bind(propertyId, (TakesValue<Object>) widget); } }); }
public void testUnbindReadOnlyWidget() { doTestUnbindWidget(new BindWidgetCallback() { @Override @SuppressWarnings("unchecked") public HandlerRegistration bind(ViewEngine engine, String propertyId, IsWidget widget) { return engine.bind(propertyId, (TakesValue<Object>) widget); } }); }
protected Object getFieldValue(FormField field) { if (field.getWidget() instanceof HasValue) { return ((HasValue) field.getWidget()).getValue(); } else if (field.getWidget() instanceof TakesValue) { return ((TakesValue) field.getWidget()).getValue(); } else if (field.getWidget() instanceof HasText) { return ((HasText) field.getWidget()).getText(); } throw new IllegalStateException("Unexpected widget type: impossible to read the value"); }
public void setDefaultValueProvider(TakesValue<String> defaultValue) { iDefaultValueProvider = defaultValue; }
public TakesValue<String> getDefaultValueProvider() { return iDefaultValueProvider; }
public void setDefaultValueProvider(TakesValue<String> defaultValue) { iFilter.getWidget().setDefaultValueProvider(defaultValue); }
public TakesValue<String> getDefaultValueProvider() { return iFilter.getWidget().getDefaultValueProvider(); }
public <S extends TakesValue<T> & TakesComment> void from(S obj) { this.setComment(obj.getComment()); this.setValue(obj.getValue()); }
public <S extends TakesValue<T> & TakesComment> void to(S obj) { obj.setComment(this.getComment()); obj.setValue(this.getValue()); }
@Override public TakesValue<String> getQueryEditor() { return queryEditor; }
@Override public TakesValue<String> getAppearanceEditor() { return appearanceEditor; }
@Override public <F> Registration bind(String id, TakesValue<F> widget) { return engine.bind(id, widget); }
WidgetBinding(TakesValue widget, HandlerRegistration widgetHandlerRegistration) { this.widget = widget; this.widgetHandlerRegistration = widgetHandlerRegistration; }
WidgetBinding(TakesValue widget) { this.widget = widget; }
/** * getter for the widget which takes the values. * * @return the takesValues */ public final TakesValue<T> getTakesValues() { return this.takesValues; }
/** * Bind a widget with default strategy (NONE). This binding will behavior like a read-only widget. * * @param id identification of property * @param widget widget to bind * @param <F> value type * * @return HandlerRegistration of this binding */ <F> Registration bind(String id, TakesValue<F> widget);
TakesValue<String> getQueryEditor();
TakesValue<String> getAppearanceEditor();