Java Code Examples for com.google.gwt.event.logical.shared.ValueChangeEvent

The following examples show how to use com.google.gwt.event.logical.shared.ValueChangeEvent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: appinventor-extensions   Source File: GalleryPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Helper method called by constructor to initialize the app's title section
 * @param container   The container that title resides
 */
private void initAppTitle(Panel container) {
  if (newOrUpdateApp()) {
    // GUI for editable title container
    if (editStatus==NEWAPP) {
      // If it's new app, give a textual hint telling user this is title
      titleText.setText(app.getTitle());
    } else if (editStatus==UPDATEAPP) {
      // If it's not new, just set whatever's in the data field already
      titleText.setText(app.getTitle());
    }
    titleText.addValueChangeHandler(new ValueChangeHandler<String>() {
      @Override
      public void onValueChange(ValueChangeEvent<String> event) {
        app.setTitle(titleText.getText());
      }
    });
    titleText.addStyleName("app-desc-textarea");
    container.add(titleText);
    container.addStyleName("app-title-container");
  } else {
    Label title = new Label(app.getTitle());
    title.addStyleName("app-title");
    container.add(title);
  }
}
 
Example 2
Source Project: appinventor-extensions   Source File: GalleryPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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");
  }
}
 
Example 3
@Override
public void setSelection(T selection, boolean fireEvents) {
	T oldValue = this.selectedItem;
	NavLink currentSelection = InputSelect.this.getItemsLinks().get(this.selectedItem);
	if (currentSelection != null) {
		currentSelection.setActive(false);
	}
	NavLink newSelection = InputSelect.this.getItemsLinks().get(selection);
	if (newSelection != null) {
		newSelection.setActive(true);
	}
	this.selectedItem = selection;
	this.scrollToSelected();
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(InputSelect.this, oldValue, selection);
	}
}
 
Example 4
Source Project: gwt-material   Source File: BaseCheckBox.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks or unchecks the check box, firing {@link ValueChangeEvent} if
 * appropriate.
 * <p>
 * Note that this <em>does not</em> set the value property of the checkbox
 * input element wrapped by this widget. For access to that property, see
 * {@link #setFormValue(String)}
 *
 * @param value      true to check, false to uncheck; null value implies false
 * @param fireEvents If true, and value has changed, fire a
 *                   {@link ValueChangeEvent}
 */
@Override
public void setValue(Boolean value, boolean fireEvents) {
    if (value == null) {
        value = Boolean.FALSE;
    }

    Boolean oldValue = getValue();
    inputElem.setChecked(value);
    inputElem.setDefaultChecked(value);
    if (value.equals(oldValue)) {
        return;
    }
    if (fireEvents) {
        ValueChangeEvent.fire(this, value);
    }
}
 
Example 5
@Override
public void onItemClick(T item) {
	if (this.selectedItems == null) {
		this.selectedItems = new ArrayList<T>();
	}
	boolean selectItem = !this.selectedItems.contains(item);
	this.selectItem(item, selectItem);
	if (selectItem) {
		this.selectedItems.add(item);
	} else {
		this.selectedItems.remove(item);
		if (this.selectedItems.isEmpty()) {
			this.selectedItems = null;
		}
	}
	this.highlightByIndex(InputMultiSelect.this.getOrderedItems().indexOf(item));
	ValueChangeEvent.fire(InputMultiSelect.this, this.selectedItems);
}
 
Example 6
Source Project: unitime   Source File: PeriodPreferencesWidget.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 7
Source Project: gwt-material-demo   Source File: InfiniteDataTableView.java    License: Apache License 2.0 6 votes vote down vote up
@UiHandler("cbCategories")
void onCategories(ValueChangeEvent<Boolean> e) {
    if(e.getValue()) {
        GWT.log("Categories checked");

        table.setUseCategories(true);
        table.clearRowsAndCategories(true);
        loadCategories();
    } else {
        GWT.log("Categories not checked");

        table.setUseCategories(false);
        table.getView().setRedraw(true);
        table.getView().refresh();
    }
}
 
Example 8
Source Project: gwt-material-demo   Source File: CheckBoxView.java    License: Apache License 2.0 6 votes vote down vote up
@UiHandler("cbBoxAll")
void onCheckAll(ValueChangeEvent<Boolean> e) {
    if(e.getValue()) {
        cbBlue.setValue(true);
        cbRed.setValue(true);
        cbCyan.setValue(true);
        cbGreen.setValue(true);
        cbBrown.setValue(true);
    } else {
        cbBlue.setValue(false);
        cbRed.setValue(false);
        cbCyan.setValue(false);
        cbGreen.setValue(false);
        cbBrown.setValue(false);
    }
}
 
Example 9
Source Project: gwt-material-addins   Source File: Html5Camera.java    License: Apache License 2.0 6 votes vote down vote up
protected void captureToDataURL() {
    File file =  toFile(imageFileInput.getElement());

    FileReader reader = new FileReader();
    $(reader).on("load", e -> {
        imageUrl = reader.result;
        ValueChangeEvent.fire(this, imageUrl);
        return true;
    });

    if (file != null) {
        reader.readAsDataURL(file);
    } else {
        GWT.log("Please provide a file before reading the file.", new NullPointerException());
    }
}
 
Example 10
Source Project: mvp4g   Source File: PlaceServiceTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNavigationConfirmationForHistory() {
  String historyName = "historyName";
  placeServiceDefault.addConverter(historyName,
                                   buildHistoryConverter(true));

  MyTestNavigationConfirmation navConf = new MyTestNavigationConfirmation();
  placeServiceDefault.setNavigationConfirmation(navConf);

  ValueChangeEvent<String> event = new ValueChangeEventStub<String>(historyName);
  placeServiceDefault.onValueChange(event);
  eventBus.assertEvent(null,
                       null);

  navConf.getEvent()
         .execute();
  eventBus.assertEvent(historyName,
                       new Object[] { null });

}
 
Example 11
@Override
public void setSelection(T selection, boolean fireEvents) {
	T oldValue = this.selectedItem;
	RadioContainer newSelection = InputRadio.this.itemsContainer.get(selection);
	if (newSelection != null) {
		newSelection.select();
	}
	this.selectedItem = selection;
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(InputRadio.this, oldValue, selection);
	}
}
 
Example 12
Source Project: unitime   Source File: CourseRequestsTable.java    License: Apache License 2.0 5 votes vote down vote up
private void addAlternativeLine() {
	if (iAlternatives.isEmpty()) {
		iAltHeader = new P("alt-header");
		iAltHeaderTitle = new P("title"); iAltHeaderTitle.setText(MESSAGES.courseRequestsAlternatives());
		iAltHeaderNote = new P("note"); iAltHeaderNote.setText(MESSAGES.courseRequestsAlternativesNote());
		iAltHeader.add(iAltHeaderTitle);
		iAltHeader.add(iAltHeaderNote);
		add(iAltHeader);
	}
	int i = iAlternatives.size();
	final CourseRequestLine line = new CourseRequestLine(iOnline, iSessionProvider, i, true, iCheckForDuplicities, iSectioning, iSpecReg);
	iAlternatives.add(line);
	CourseRequestLine prev = (i == 0 ? iCourses.get(iCourses.size() - 1) : iAlternatives.get(i - 1));
	if (prev != null) {
		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 (iLastCheck != null)
				for (CourseSelectionBox box: line.getCourses()) setErrors(box, iLastCheck);
			ValueChangeEvent.fire(CourseRequestsTable.this, getValue());
			if (event.getValue() != null && iAlternatives.indexOf(line) + 1 == iAlternatives.size())
				addAlternativeLine();
		}
	});
}
 
Example 13
Source Project: unitime   Source File: SessionDatesSelector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(Boolean value, boolean fireEvents) {
	if (iSelected == value || value == null || !isEnabled()) return;
	iSelected = value;
   	if (iSelected)
   		addStyleName("selected");
   	else
   		removeStyleName("selected");
	if (fireEvents)
		ValueChangeEvent.fire(this, getValue());
}
 
Example 14
Source Project: gwt-material   Source File: AbstractButton.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(String value, boolean fireEvent) {
    if (value != null) {
        setText(value);
    }

    if (fireEvent) {
        ValueChangeEvent.fire(this, value);
    }
}
 
Example 15
Source Project: gwt-material   Source File: MaterialImage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(String value, boolean fireEvents) {
    String oldValue = getUrl();
    getImageMixin().setUrl(value);

    if(fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, value);
    }
}
 
Example 16
public RpcFilterConfig() {
  panel = new HorizontalPanel();
  panel.add(createFormLabel("RPC Pattern"));
  panel.add(textbox = createTextBox(20));
  addValueChangeHandler(new ValueChangeHandler<Config>() {
    //@Override
    public void onValueChange(ValueChangeEvent<Config> event) {
      textbox.setText(getPattern());
    }
  });
}
 
Example 17
Source Project: gwt-material   Source File: MaterialListValueBox.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void load() {
    JQueryElement listBoxElement = $(listBox.getElement());
    JsMaterialElement.$(listBox.getElement()).material_select(() -> $("input.select-dropdown").trigger("close", true));
    listBoxElement.change((e, param) -> {
        try {
            ValueChangeEvent.fire(this, getValue());
        } catch (IndexOutOfBoundsException ex) {
            GWT.log("ListBox value change handler threw an exception.", ex);
        }
        return true;
    });

    JQueryElement selectDropdown = listBoxElement.siblings("input.select-dropdown");
    selectDropdown.mousedown((event, o) -> {
        $("input[data-activates!='" + listBoxElement.attr("data-activates") + "'].select-dropdown").trigger("close", true);
        return true;
    });

    selectDropdown.blur((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createBlurEvent(), this);
        return true;
    });

    selectDropdown.focus((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createFocusEvent(), this);

        if (isAsynchronous() && !isLoaded()) {
            load(getAsyncCallback());
        }

        return true;
    });

    if (isAllowBlank()) {
        addBlankItemIfNeeded();
    }
}
 
Example 18
Source Project: proarc   Source File: Actions.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static IconMenuButton asIconMenuButton(final Action action,
        final Object source, ActionSource actionSource) {

    final IconMenuButton btn = new IconMenuButton();
    String title = action.getTitle();
    if (title != null) {
        btn.setTitle(title);
    }
    String icon = action.getIcon();
    if (icon != null) {
        btn.setIcon(icon);
    }
    String tooltip = action.getTooltip();
    if (tooltip != null) {
        btn.setTooltip(tooltip);
    }

    IconMenuButtonHandler handler = new IconMenuButtonHandler(btn, source, action);
    btn.addClickHandler(handler);
    btn.addMenuIconClickHandler(handler);

    if (actionSource != null) {
        actionSource.addValueChangeHandler(new ValueChangeHandler<ActionEvent>() {

            @Override
            public void onValueChange(ValueChangeEvent<ActionEvent> event) {
                boolean accept = action.accept(event.getValue());
                btn.setVisible(accept);
            }
        });
    }
    return btn;
}
 
Example 19
@UiHandler("switchBuild")
void onSwitch(ValueChangeEvent<String> event) {
	if ("MAVEN".equals(event.getValue())) {
		this.buildGradlePanel.setVisible(false);
		this.buildMavenPanel.setVisible(true);

	} else {
		this.buildGradlePanel.setVisible(true);
		this.buildMavenPanel.setVisible(false);
	}
}
 
Example 20
Source Project: geowe-core   Source File: DeleteTool.java    License: GNU General Public License v3.0 5 votes vote down vote up
private ValueChangeHandler<Boolean> getMultiDeletionHandler() {
	return new ValueChangeHandler<Boolean>() {
		@Override
		public void onValueChange(ValueChangeEvent<Boolean> event) {

			if (event.getValue()) {
				VectorLayer layer = (VectorLayer) getLayer();

				if (layer.getSelectedFeatures() != null) {
					confirm(Arrays.asList(layer.getSelectedFeatures()));
				}
			}
		}
	};
}
 
Example 21
Source Project: mvp4g   Source File: PlaceServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testConverterCrawlable() {
  String historyName = "historyName";
  placeServiceDefault.addConverter(historyName,
                                   buildHistoryConverter(true));
  ValueChangeEvent<String> event = new ValueChangeEventStub<String>("!" + historyName);
  placeServiceDefault.onValueChange(event);
  eventBus.assertEvent(historyName,
                       new Object[] { null });
}
 
Example 22
@Override
protected void initializePanel() {
	String fieldWidth = "125px";

	attributeTheming = new FeatureAttributeComboBox(fieldWidth);
	attributeTheming.setEnabled(false);
	enableTheming = new CheckBox();
	enableTheming.setBoxLabel(UIMessages.INSTANCE.enableColorTheming());
	enableTheming.setValue(false);
	enableTheming.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
		@Override
		public void onValueChange(ValueChangeEvent<Boolean> event) {
			attributeTheming.setEnabled(event.getValue());
			enableLegend.setValue(event.getValue());
			enableLegend.setEnabled(event.getValue());

			if(event.getValue() && isFeatureStyleApplied(selectedLayer)) {
				showColorThemingStyleWarning();
			}
		}
	});

	enableLegend = new CheckBox();
	enableLegend.setBoxLabel(UIMessages.INSTANCE.colorThemingShowLegend());
	enableLegend.setValue(false);
	enableLegend.setEnabled(false);

	VerticalLayoutContainer vlc = new VerticalLayoutContainer();
	vlc.add(enableTheming, new VerticalLayoutData(-18, -1));
	vlc.add(new FieldLabel(attributeTheming, UIMessages.INSTANCE
			.vlswLabelAttribute()), new VerticalLayoutData(-18, -1));
	vlc.add(enableLegend, new VerticalLayoutData(-18, -1));

	panel.setSpacing(5);
	panel.add(vlc);
}
 
Example 23
Source Project: unitime   Source File: FreeTimePicker.java    License: Apache License 2.0 5 votes vote down vote up
@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, "&nbsp;");
			}
	} 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());
}
 
Example 24
Source Project: dashbuilder   Source File: ValueBoxEditorView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValueBox(final ValueBoxBase<T> widget) {
    this.widget = widget;
    widget.addValueChangeHandler(new ValueChangeHandler<T>() {
        @Override
        public void onValueChange(final ValueChangeEvent<T> event) {
            presenter.onValueChanged(event.getValue());
        }
    });
    contents.add(widget);
}
 
Example 25
Source Project: gwt-material-demo   Source File: StandardDataTableView.java    License: Apache License 2.0 5 votes vote down vote up
@UiHandler("cbCategories")
void onCategories(ValueChangeEvent<Boolean> e) {
    if (e.getValue()) {
        table.setUseCategories(true);
    } else {
        table.setUseCategories(false);
    }
    table.getView().setRedraw(true);
    table.getView().refresh();
}
 
Example 26
Source Project: unitime   Source File: RoomSharingWidget.java    License: Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 27
Source Project: gwt-material-addins   Source File: MaterialSignaturePad.java    License: Apache License 2.0 5 votes vote down vote up
public SignaturePad getSignaturePad() {
    if (signaturePad == null) {
        options.onBegin = () -> SignatureStartEvent.fire(this);
        options.onEnd = () -> {
            SignatureEndEvent.fire(this);
            ValueChangeEvent.fire(this, getSignaturePad().toDataURL());
        };
        signaturePad = new SignaturePad(getElement(), options);
    }
    return signaturePad;
}
 
Example 28
Source Project: gwt-traction   Source File: UTCDateBoxImplHtml5.java    License: Apache License 2.0 5 votes vote down vote up
public UTCDateBoxImplHtml5() {
    widget = new InputWidget("date");
    setDateFormat(dateInputFormat);
    
    widget.addValueChangeHandler(new ValueChangeHandler() {

        @Override
        public void onValueChange(ValueChangeEvent event) {
            fireValueChangeEvent(getValue());
        }
        
    });
    
    initWidget(widget);        
}
 
Example 29
Source Project: unitime   Source File: EventAdd.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(List<RelatedObjectInterface> value, boolean fireEvents) {
	iLastChange = null;
	clearTable(1);
	if (value != null)
		for (RelatedObjectInterface line: value)
			addLine(line);
	addLine(null);
	addLine(null);
	if (fireEvents)
		ValueChangeEvent.fire(CourseRelatedObjectsTable.this, getValue());
}
 
Example 30
Source Project: gwtbootstrap3-extras   Source File: ToggleSwitchBase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(final Boolean value, final boolean fireEvents) {
    Boolean oldValue = getValue();
    if (isAttached()) {
        switchState(getElement(), value, true);
    } else {
        element.setChecked(value);
    }
    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(ToggleSwitchBase.this, oldValue, value);
    }
}