/** * Checks or unchecks the text box, firing {@link ValueChangeEvent} if appropriate. * <p/> * Note that this <em>does not</em> set the value property of the AccessibleCheckBox input element wrapped by this widget. For access to that property, see * {@link #setFormValue(String)} * * @param value true to check, false to uncheck; must not be null * @param fireEvents If true, and value has changed, fire a {@link ValueChangeEvent} * @throws IllegalArgumentException if value is null */ @Override public void setValue(Boolean value, boolean fireEvents) { if (value == null) { throw new IllegalArgumentException("value must not be null"); } Boolean oldValue = getValue(); inputElem.setChecked(value); inputElem.setDefaultChecked(value); if (value.equals(oldValue)) { return; } if (fireEvents) { ValueChangeEvent.fire(this, value); } }
public void initializeWMTSFields() { urlWMTSField.setEmptyText("http://..."); nameWMTSField.setEmptyText(UIMessages.INSTANCE .lrasterdLayerNameField("WMTS")); formatWMTSField.setEmptyText("image/png, image/jpg..."); tileMatrixSetField.setEmptyText("matrix set identifier"); urlWMTSField.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (!event.getValue().startsWith("http")) { showAlert("URL"); } } }); }
public void setInstructors(List<InstructorInterface> instructors) { iInstructors.clearTable(1); iInstructors.resetVisibility(); iHeader.clearMessage(); ValueChangeHandler<Boolean> clearErrorMessage = new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iHeader.clearMessage(); } }; if (instructors != null) for (InstructorInterface i: instructors) { int row = iInstructors.addInstructor(i); boolean selected = i.hasAttribute(iAttribute.getId()); iInstructors.selectInstructor(row, selected); iInstructors.setSelected(row, selected); iInstructors.getInstructorSelection(row).addValueChangeHandler(clearErrorMessage); } int sort = InstructorCookie.getInstance().getSortInstructorsBy(); if (sort != 0) iInstructors.setSortBy(sort); iInstructors.setVisible(iInstructors.getRowCount() > 1); }
private VerticalPanel getFoot() { slider.setWidth("290px"); slider.disable(); slider.setIncrement(1); slider.addValueChangeHandler(new ValueChangeHandler<Integer>() { @Override public void onValueChange(final ValueChangeEvent<Integer> event) { final Layer layer = getSelectedLayer(getSelectedTabName()); layer.setOpacity((float) (event.getValue().intValue() / 100.0)); } }); final VerticalPanel panel = new VerticalPanel(); panel.setWidth("300px"); panel.addStyleName(ThemeStyles.get().style().borderTop()); panel.add(new HTML(UIMessages.INSTANCE.lmOpacityHtmlLabel())); panel.add(slider); panel.add(statusBar); return panel; }
Item(T id, String name, boolean asHTML) { super(name, asHTML); iId = id; addStyleName("item"); addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { ValueChangeEvent.fire(MultiSelect.this, MultiSelect.this.getValue()); } }); }
private void onChange(ValueChangeEvent<String> event) { Integer travel = null; try { if (!event.getValue().isEmpty()) travel = Integer.valueOf(event.getValue()); } catch (Exception e) {} iR1.setTravelTime(iR2, travel); if (travel != null) { if (iDefault) { iDefault = false; removeStyleName("default"); } } else { Integer distance = iR1.getDistance(iR2.getId()); if (distance != null) { setValue(distance.toString()); iDefault = true; addStyleName("default"); } } }
public void setRooms(List<Entity> rooms) { iRooms.clearTable(1); iHeader.clearMessage(); ValueChangeHandler<Boolean> clearErrorMessage = new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iHeader.clearMessage(); } }; for (Entity e: rooms) { RoomDetailInterface room = (RoomDetailInterface)e; int row = iRooms.addRoom(room); boolean selected = room.hasGroup(iGroup.getId()); iRooms.selectRoom(row, selected); iRooms.setSelected(row, selected); iRooms.getRoomSelection(row).addValueChangeHandler(clearErrorMessage); } int sort = RoomCookie.getInstance().getRoomsSortBy(); if (sort != 0) iRooms.setSortBy(sort); }
public void setRooms(List<Entity> rooms) { iRooms.clearTable(1); iHeader.clearMessage(); ValueChangeHandler<Boolean> clearErrorMessage = new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iHeader.clearMessage(); } }; for (Entity e: rooms) { RoomDetailInterface room = (RoomDetailInterface)e; int row = iRooms.addRoom(room); boolean selected = room.hasFeature(iFeature.getId()); iRooms.selectRoom(row, selected); iRooms.setSelected(row, selected); iRooms.getRoomSelection(row).addValueChangeHandler(clearErrorMessage); } int sort = RoomCookie.getInstance().getRoomsSortBy(); if (sort != 0) iRooms.setSortBy(sort); }
public void setRooms(List<Entity> rooms, Integer sortBy) { iRooms.clearTable(1); iHeader.clearMessage(); ValueChangeHandler<Boolean> clearErrorMessage = new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iHeader.clearMessage(); } }; for (Entity e: rooms) { RoomDetailInterface room = (RoomDetailInterface)e; int row = iRooms.addRoom(room); boolean selected = false; if (iDepartment != null) { selected = (room.getDepartment(iDepartment.getId()) != null); } else if (iExamType != null) { selected = (room.getExamType(iExamType.getId()) != null); } iRooms.selectRoom(row, selected); iRooms.setSelected(row, selected); iRooms.getRoomSelection(row).addValueChangeHandler(clearErrorMessage); } if (sortBy != null) iRooms.setSortBy(sortBy); }
public PeriodPreferencesWidget(boolean editable) { iEditable = editable; iPanel = new AbsolutePanel(); iHorizontal = new CheckBox(MESSAGES.periodPreferenceHorizontal()); iHorizontal.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { RoomCookie.getInstance().setHorizontal(iHorizontal.getValue()); render(); } }); initWidget(iPanel); }
@Override public void setValue(final Integer value, boolean fireEvents) { iValue = value; if (value != null && value.intValue() != 0) { final int column = (value > 0 ? value - 1 : -value - 1); final UniTimeTableHeader h = getHeader(column); if (h != null) sort(h, new Comparator<TableInterface.TableRowInterface>() { @Override public int compare(TableInterface.TableRowInterface r1, TableInterface.TableRowInterface r2) { return r1.compareTo(r2, column, true); } }, value > 0); } if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
public PageFilter() { addStyleName("unitime-PageFilter"); iHeader = new UniTimeHeaderPanel(MESSAGES.sectFilter()); iHeader.setCollapsible(true); iHeader.addCollapsibleHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { for (int row: iCollapsibleRows) { getRowFormatter().setVisible(row, event.getValue()); } } }); iFilterHeaderRow = addHeaderRow(iHeader); iFilterLastRow = iFilterHeaderRow; iFooter = iHeader.clonePanel(null); }
/** * Helper method called by constructor to initialize the app's description * @param c1 The container that description resides (editable state) * @param c2 The container that description resides (public state) */ private void initAppDesc(Panel c1, Panel c2) { desc.getElement().setPropertyString("placeholder", MESSAGES.galleryDescriptionHint()); if (newOrUpdateApp()) { desc.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { app.setDescription(desc.getText()); } }); if(editStatus==UPDATEAPP){ desc.setText(app.getDescription()); } desc.addStyleName("app-desc-textarea"); c1.add(desc); } else { Label description = new Label(app.getDescription()); c2.add(description); c2.addStyleName("app-description"); } }
@Override public void addChip(Chip chip, boolean fireEvents) { final ChipPanel panel = new ChipPanel(chip, getChipColor(chip)); panel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { remove(panel); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); ValueChangeEvent.fire(CourseRequestFilterBox.this, getValue()); } }); insert(panel, getWidgetIndex(iFilterFinder)); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
public static AriaSuggestBox insert(RootPanel panel) { String config = panel.getElement().getAttribute("configuration"); final String onchange = panel.getElement().getAttribute("onchange"); AriaTextBox text = new AriaTextBox(panel.getElement().getFirstChildElement()); text.getElement().setAttribute("autocomplete", "off"); AriaSuggestBox box = new AriaSuggestBox(text, new CourseNumbersSuggestBox(config)); if (onchange != null) box.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { ToolBox.eval(onchange); } }); panel.add(box); return box; }
@Override public void setValue(IntervalSelector<T>.Interval value, boolean fireEvents) { iValue = value; if (iValue == null) { iFilter.setText(""); iPrev.setEnabled(false); iNext.setEnabled(false); } else { if (iValue.isAll()) iFilterEnabled = iValue.isEnableFilter(); iFilter.setText(getReplaceString(iValue)); iPrev.setEnabled(previous(iValue) != null); iNext.setEnabled(next(iValue) != null); } createSuggestions(); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
public void addChip(Chip chip, boolean fireEvents) { final ChipPanel panel = new ChipPanel(chip, getChipColor(chip)); panel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { remove(panel); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); ValueChangeEvent.fire(FilterBox.this, getValue()); } }); insert(panel, getWidgetIndex(iFilter)); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
@Override public void setValue(String text, final boolean fireEvents) { removeAllChips(); iParser.parse(text, getFilters(), new AsyncCallback<Parser.Results>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Parser.Results result) { for (Chip chip: result.getChips()) addChip(chip, false); iFilter.setText(result.getFilter()); resizeFilterIfNeeded(); setAriaLabel(toAriaString()); if (fireEvents) ValueChangeEvent.fire(FilterBox.this, getValue()); } }); }
public static void peopleLookup(String query, final JavaScriptObject callback, String options) { final Lookup lookup = new Lookup(); if (query != null && !query.trim().isEmpty()) lookup.setQuery(query); lookup.addValueChangeHandler(new ValueChangeHandler<PersonInterface>() { @Override public void onValueChange(ValueChangeEvent<PersonInterface> event) { if (event.getValue() != null) lookup.fireCallback(callback, event.getValue().getId(), event.getValue().getFirstName(), event.getValue().getMiddleName(), event.getValue().getLastName(), event.getValue().getEmail(), event.getValue().getPhone(), event.getValue().getAcademicTitle(), event.getValue().getName()); } }); lookup.setOptions(options); lookup.center(); }
@Override protected ValueChangeHandler<Boolean> getSelectChangeHandler() { return new ValueChangeHandler<Boolean>() { @Override public void onValueChange(final ValueChangeEvent<Boolean> event) { if (event.getValue()) { setActive(true); basicToolBar.setAnchorVisible(true); basicToolBar.setAnchorColor(GREEN); basicToolBar.setWhat3Words(""); createW3wLayer(); } else { setActive(false); basicToolBar.setAnchorVisible(false); basicToolBar.setAnchorColor(RED); } } }; }
protected void addMeetings(List<MeetingInterface> meetings) { List<MeetingInterface> existingMeetings = iMeetings.getMeetings(); if (!iEventType.isReadOnly()) iEvent.setType(getEventType()); if (meetings != null && !meetings.isEmpty()) meetings: for (MeetingInterface meeting: meetings) { if (meeting.getApprovalStatus() != ApprovalStatus.Pending && meeting.getApprovalStatus() != ApprovalStatus.Approved) continue; for (MeetingInterface existing: existingMeetings) { if (existing.getApprovalStatus() != ApprovalStatus.Pending && existing.getApprovalStatus() != ApprovalStatus.Approved) continue; if (existing.inConflict(meeting)) { UniTimeNotifications.warn(MESSAGES.warnNewMeetingOverlaps(meeting.toString(), existing.toString())); continue meetings; } } iMeetings.add(new EventMeetingRow(iEvent, meeting)); } ValueChangeEvent.fire(iMeetings, iMeetings.getValue()); }
public CourseRelatedObjectsTable(AcademicSessionProvider session) { iSession = session; setStyleName("unitime-EventOwners"); List<Widget> header = new ArrayList<Widget>(); header.add(new UniTimeTableHeader(MESSAGES.colSubject())); header.add(new UniTimeTableHeader(MESSAGES.colCourseNumber())); header.add(new UniTimeTableHeader(MESSAGES.colConfigOrSubpart())); header.add(new UniTimeTableHeader(MESSAGES.colClassNumber())); header.add(new UniTimeTableHeader(" ")); addRow(null, header); iChangeTimer = new Timer() { @Override public void run() { List<RelatedObjectInterface> value = getValue(); if (iLastChange != null && iLastChange.equals(value)) return; iLastChange = value; ValueChangeEvent.fire(CourseRelatedObjectsTable.this, value); } }; }
private void addCourseLine() { int i = iCourses.size(); final CourseRequestLine line = new CourseRequestLine(iSessionProvider, i, false, iCheckForDuplicities); iCourses.add(line); CourseRequestLine prev = iCourses.get(i - 1); prev.getCourses().get(0).setHint(""); line.getCourses().get(0).setHint(MESSAGES.courseRequestsHint8()); CourseRequestLine next = iAlternatives.get(0); line.setPrevious(prev); prev.setNext(line); line.setNext(next); next.setPrevious(line); line.setArrowsVisible(iArrowsVisible); line.setWaitListVisible(iCanWaitList); insert(line, 1 + i); line.addValueChangeHandler(new ValueChangeHandler<CourseRequestInterface.Request>() { @Override public void onValueChange(ValueChangeEvent<Request> event) { if (event.getValue() != null && iCourses.indexOf(line) + 1 == iCourses.size()) addCourseLine(); } }); }
private void addAlternativeLine() { int i = iAlternatives.size(); final CourseRequestLine line = new CourseRequestLine(iSessionProvider, i, true, iCheckForDuplicities); iAlternatives.add(line); CourseRequestLine prev = iAlternatives.get(i - 1); line.setPrevious(prev); prev.setNext(line); line.setArrowsVisible(iArrowsVisible); insert(line, 3 + iCourses.size() + i); line.addValueChangeHandler(new ValueChangeHandler<CourseRequestInterface.Request>() { @Override public void onValueChange(ValueChangeEvent<Request> event) { if (event.getValue() != null && iAlternatives.indexOf(line) + 1 == iAlternatives.size()) addAlternativeLine(); } }); }
/** * Overridden to send ValueChangeEvents only when appropriate. */ @Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONMOUSEUP: case Event.ONBLUR: case Event.ONKEYDOWN: // Note the old value for onValueChange purposes (in ONCLICK case) oldValue = getValue(); break; case Event.ONCLICK: EventTarget target = event.getEventTarget(); if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) { // They clicked the label. Note our pre-click value, and // short circuit event routing so that other click handlers // don't hear about it oldValue = getValue(); return; } // It's not the label. Let our handlers hear about the // click... super.onBrowserEvent(event); // ...and now maybe tell them about the change ValueChangeEvent.fireIfNotEqual(AccessibleRadioButton.this, oldValue, getValue()); return; } super.onBrowserEvent(event); }
@Override public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler) { // Is this the first value change handler? If so, time to add handlers if (!valueChangeHandlerInitialized) { ensureDomEventHandlers(); valueChangeHandlerInitialized = true; } return addHandler(handler, ValueChangeEvent.getType()); }
protected void ensureDomEventHandlers() { addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // AccessibleCheckBoxes always toggle their value, no need to compare // with old value. Radio buttons are not so lucky, see // overrides in RadioButton ValueChangeEvent.fire(AccessibleCheckBox.this, getValue()); } }); }
@Override public void onValueChange(ValueChangeEvent<String> event) { final String token = event.getValue(); logger.info("value change:" + token); loginController.go(token); }
@Override public void setValue(Integer value, boolean fireEvents) { if (value == null) { int row = iRequestsTable.getSelectedRow(); if (row >= 0) iRequestsTable.setSelected(row, false); } else { iRequestsTable.setSelected(value + 1, true); } if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
@Override public void setValue(Integer value, boolean fireEvents) { if (value == null) { int row = iInstructorsTable.getSelectedRow(); if (row >= 0) iInstructorsTable.setSelected(row, false); } else { iInstructorsTable.setSelected(value + 1, true); } if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
@Override public void setValue(List<T> value, boolean fireEvents) { for (Item item: iItems) item.setValue(value.contains(item.getId())); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
@Override public void setValue(Boolean value, boolean fireEvents) { if (value == null) value = false; iValue = value; setResource(iValue ? iCheckedFace : iUncheckedFace); Roles.getCheckboxRole().setAriaCheckedState(getElement(), iValue ? CheckedValue.TRUE : CheckedValue.FALSE); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
public void setOption(RoomSharingOption option) { if (!isEditable(iDay, iSlot)) return; iModel.setOption(iDay, iSlot, iMode.getStep(), option); if (option == null) { getElement().getStyle().clearBackgroundColor(); setHTML(""); setTitle(""); } else { getElement().getStyle().setBackgroundColor(option.getColor()); setHTML(option.getCode() == null ? "" : option.getCode()); setTitle(CONSTANTS.longDays()[iDay] + " " + slot2short(iSlot) + " - " + slot2short(iSlot + iMode.getStep()) + ": " + option.getName()); } ValueChangeEvent.fire(RoomSharingWidget.this, getValue()); }
public void setOption(PreferenceInterface preference) { if (!isEditable() || iPeriod == null) return; iModel.setPreference(iDay, iSlot, preference); if (preference == null) { getElement().getStyle().clearBackgroundColor(); setTitle(""); } else { getElement().getStyle().setBackgroundColor(preference.getColor()); setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(iDate) + " " + slot2short(iSlot) + " - " + slot2short(iSlot + iPeriod.getLength()) + ": " + preference.getName()); } ValueChangeEvent.fire(PeriodPreferencesWidget.this, getValue()); }
@Override public void setValue(Integer value, boolean fireEvents) { if (value == null) iText.setText(""); else { if (iStart != null && iStart.getValue() != null) iDiff = value - iStart.getValue(); iText.setText(TimeUtils.slot2time(value)); } if (fireEvents) ValueChangeEvent.fire(this, value); }
@Override public void setValue(Boolean value, boolean fireEvents) { if (value == null) return; iValue = value; setResource(iValue ? RESOURCES.treeOpen() : RESOURCES.treeClosed()); if (fireEvents) ValueChangeEvent.fire(this, iValue); }
public CheckboxCell(boolean check, String ariaLabel, final String onTitle, final String offTitle) { this(check, null, ariaLabel); iCheck.setTitle(iCheck.getValue() ? onTitle : offTitle); iCheck.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iCheck.setTitle(event.getValue() ? onTitle : offTitle); } }); }
public LockCell(boolean check, String ariaLabel, final String onTitle, final String offTitle) { this(check, null, ariaLabel); getWidget().setTitle(iCheck.getValue() ? onTitle : offTitle); iCheck.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { getWidget().setTitle(event.getValue() ? onTitle : offTitle); } }); }
@Override public void setValue(List<FreeTime> value, boolean fireEvents) { if (value == null || value.isEmpty()) { for (int d=0; d<CONSTANTS.freeTimeDays().length; d++) for (int p=0; p<CONSTANTS.freeTimePeriods().length - 1; p++) { iSelected[d][p] = false; td(d, p).getStyle().setBackgroundColor(bg(d, p)); setHTML(1 + d, 1 + p, " "); } } else { for (int d=0; d<CONSTANTS.freeTimeDays().length; d++) for (int p=0; p<CONSTANTS.freeTimePeriods().length - 1; p++) iSelected[d][p] = false; for (CourseRequestInterface.FreeTime f: value) { for (int day: f.getDays()) { if (day < CONSTANTS.freeTimeDays().length) { for (int p = toPeriod(f.getStart()); p < toPeriod(f.getStart() + f.getLength()); p++) iSelected[day][p] = true; } } } generatePriorities(); update(); } if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
@Override public void onBrowserEvent(Event event) { Element target = DOM.eventGetTarget(event); switch (DOM.eventGetType(event)) { case Event.ONMOUSEDOWN: boolean open = iFilterOpen.getElement().equals(target); boolean close = iFilterClose.getElement().equals(target); boolean clear = iFilterClear.getElement().equals(target); boolean filter = iFilter.getElement().equals(target); if (isFilterPopupShowing() || close) { hideFilterPopup(); } else if (open) { hideSuggestions(); showFilterPopup(); } if (clear) { iFilter.setText(""); removeAllChips(); setAriaLabel(toAriaString()); ValueChangeEvent.fire(FilterBox.this, getValue()); } if (!filter) { event.stopPropagation(); event.preventDefault(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iFilter.setFocus(true); } }); } break; } }