List of usage examples for com.google.gwt.event.logical.shared ValueChangeEvent getValue
public T getValue()
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.forms.FormsExample.java
License:sencha.com license
private void createForm1() { FramedPanel panel = new FramedPanel(); panel.setHeadingText("Simple Form"); panel.setWidth(350);//from ww w .j a v a 2 s . co m panel.setBodyStyle("background: none; padding: 5px"); VerticalLayoutContainer p = new VerticalLayoutContainer(); panel.add(p); TextField firstName = new TextField(); firstName.setAllowBlank(false); firstName.setEmptyText("Enter your name..."); firstName.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { Info.display("Value Changed", "First name changed to " + event.getValue() == null ? "blank" : event.getValue()); } }); p.add(new FieldLabel(firstName, "Name"), new VerticalLayoutData(1, -1)); TextField email = new TextField(); email.setAllowBlank(false); p.add(new FieldLabel(email, "Email"), new VerticalLayoutData(1, -1)); PasswordField password = new PasswordField(); p.add(new FieldLabel(password, "Password"), new VerticalLayoutData(1, -1)); NumberField<Integer> age = new NumberField<Integer>(new IntegerPropertyEditor()); age.addParseErrorHandler(new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) { Info.display("Parse Error", event.getErrorValue() + " could not be parsed as a number"); } }); age.setAllowBlank(false); p.add(new FieldLabel(age, "Age"), new VerticalLayoutData(1, -1)); StockProperties props = GWT.create(StockProperties.class); ListStore<Stock> store = new ListStore<Stock>(props.key()); store.addAll(TestData.getStocks()); ComboBox<Stock> combo = new ComboBox<Stock>(store, props.nameLabel()); combo.addValueChangeHandler(new ValueChangeHandler<Stock>() { @Override public void onValueChange(ValueChangeEvent<Stock> event) { Info.display("Selected", "You selected " + event.getValue()); } }); combo.setAllowBlank(true); combo.setForceSelection(true); combo.setTriggerAction(TriggerAction.ALL); p.add(new FieldLabel(combo, "Company"), new VerticalLayoutData(1, -1)); DateField date = new DateField(); date.addParseErrorHandler(new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) { Info.display("Parse Error", event.getErrorValue() + " could not be parsed as a date"); } }); date.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { String v = event.getValue() == null ? "nothing" : DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM).format(event.getValue()); Info.display("Selected", "You selected " + v); } }); date.addValidator(new MinDateValidator(new Date())); p.add(new FieldLabel(date, "Birthday"), new VerticalLayoutData(1, -1)); TimeField time = new TimeField(); time.addParseErrorHandler(new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) { Info.display("Parse Error", event.getErrorValue() + " could not be parsed as a valid time"); } }); time.setMinValue(new DateWrapper().clearTime().addHours(8).asDate()); time.setMaxValue(new DateWrapper().clearTime().addHours(18).addSeconds(1).asDate()); p.add(new FieldLabel(time, "Time"), new VerticalLayoutData(1, -1)); Slider slider = new Slider(); slider.setMinValue(40); slider.setMaxValue(90); slider.setValue(0); slider.setIncrement(5); slider.setMessage("{0} inches tall"); p.add(new FieldLabel(slider, "Size"), new VerticalLayoutData(1, -1)); ValueChangeHandler<Boolean> musicHandler = new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { CheckBox check = (CheckBox) event.getSource(); Info.display("Music Changed", check.getBoxLabel() + " " + (event.getValue() ? "selected" : "not selected")); } }; CheckBox check1 = new CheckBox(); check1.setEnabled(false); check1.setBoxLabel("Classical"); check1.addValueChangeHandler(musicHandler); CheckBox check2 = new CheckBox(); check2.setBoxLabel("Rock"); check2.addValueChangeHandler(musicHandler); check2.setValue(true); CheckBox check3 = new CheckBox(); check3.setBoxLabel("Blues"); check3.addValueChangeHandler(musicHandler); HorizontalPanel hp = new HorizontalPanel(); hp.add(check1); hp.add(check2); hp.add(check3); p.add(new FieldLabel(hp, "Music")); Radio radio = new Radio(); radio.setBoxLabel("Red"); Radio radio2 = new Radio(); radio2.setBoxLabel("Blue"); radio2.setValue(true); hp = new HorizontalPanel(); hp.add(radio); hp.add(radio2); p.add(new FieldLabel(hp, "Color")); // we can set name on radios or use toggle group ToggleGroup toggle = new ToggleGroup(); toggle.add(radio); toggle.add(radio2); toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() { @Override public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) { ToggleGroup group = (ToggleGroup) event.getSource(); Radio radio = (Radio) group.getValue(); Info.display("Color Changed", "You selected " + radio.getBoxLabel()); } }); TextArea description = new TextArea(); description.setAllowBlank(false); description.addValidator(new MinLengthValidator(10)); p.add(new FieldLabel(description, "Description"), new VerticalLayoutData(1, 100)); final SpinnerField<Double> spinnerField = new SpinnerField<Double>(new DoublePropertyEditor()); spinnerField.setIncrement(.1d); spinnerField.setMinValue(-10d); spinnerField.setMaxValue(10d); spinnerField.setAllowNegative(true); spinnerField.setAllowBlank(false); spinnerField.getPropertyEditor().setFormat(NumberFormat.getFormat("0.0")); spinnerField.addValueChangeHandler(new ValueChangeHandler<Double>() { @Override public void onValueChange(ValueChangeEvent<Double> event) { Info.display("Duration Changed", "Duration changed to " + event.getValue() == null ? "nothing" : event.getValue() + ""); } }); spinnerField.addSelectionHandler(new SelectionHandler<Double>() { @Override public void onSelection(SelectionEvent<Double> event) { String msg = "nothing"; if (event.getSelectedItem() != null) { msg = spinnerField.getPropertyEditor().render(event.getSelectedItem()); } Info.display("Spin Change", "Current value changed to " + msg); } }); FieldLabel spinLabel = new FieldLabel(spinnerField, "Duration(s)"); p.add(spinLabel, new VerticalLayoutData(1, -1)); panel.addButton(new TextButton("Save")); panel.addButton(new TextButton("Cancel")); vp.add(panel); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.forms.FormsUiBinderExample.java
License:sencha.com license
@UiHandler("firstName") public void firstNameChanged(ValueChangeEvent<String> event) { Info.display("Value Changed", "First name changed to " + event.getValue() == null ? "blank" : event.getValue()); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.forms.FormsUiBinderExample.java
License:sencha.com license
@UiHandler("date") public void onDateChanged(ValueChangeEvent<Date> event) { String v = event.getValue() == null ? "nothing" : DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM).format(event.getValue()); Info.display("Selected", "You selected " + v); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.grid.CheckBoxGridExample.java
License:sencha.com license
@Override public Widget asWidget() { final NumberFormat number = NumberFormat.getFormat("0.00"); IdentityValueProvider<Stock> identity = new IdentityValueProvider<Stock>(); final CheckBoxSelectionModel<Stock> sm = new CheckBoxSelectionModel<Stock>(identity); ColumnConfig<Stock, String> nameCol = new ColumnConfig<Stock, String>(props.name(), 200, "Company"); ColumnConfig<Stock, String> symbolCol = new ColumnConfig<Stock, String>(props.symbol(), 100, "Symbol"); ColumnConfig<Stock, Double> lastCol = new ColumnConfig<Stock, Double>(props.last(), 75, "Last"); ColumnConfig<Stock, Double> changeCol = new ColumnConfig<Stock, Double>(props.change(), 100, "Change"); changeCol.setCell(new AbstractCell<Double>() { @Override//from w w w .j a v a2s. c o m public void render(Context context, Double value, SafeHtmlBuilder sb) { String style = "style='color: " + (value < 0 ? "red" : "green") + "'"; String v = number.format(value); sb.appendHtmlConstant("<span " + style + " qtitle='Change' qtip='" + v + "'>" + v + "</span>"); } }); ColumnConfig<Stock, Date> lastTransCol = new ColumnConfig<Stock, Date>(props.lastTrans(), 100, "Last Updated"); lastTransCol.setCell(new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy"))); List<ColumnConfig<Stock, ?>> l = new ArrayList<ColumnConfig<Stock, ?>>(); l.add(sm.getColumn()); l.add(nameCol); l.add(symbolCol); l.add(lastCol); l.add(changeCol); l.add(lastTransCol); ColumnModel<Stock> cm = new ColumnModel<Stock>(l); ListStore<Stock> store = new ListStore<Stock>(props.key()); store.addAll(TestData.getStocks()); ContentPanel cp = new ContentPanel(); cp.setHeadingText("CheckBox Grid"); cp.getHeader().setIcon(ExampleImages.INSTANCE.table()); cp.setPixelSize(600, 320); cp.addStyleName("margin-10"); final Grid<Stock> grid = new Grid<Stock>(store, cm); grid.setSelectionModel(sm); grid.getView().setAutoExpandColumn(nameCol); grid.setBorders(false); grid.getView().setStripeRows(true); grid.getView().setColumnLines(true); ToolBar toolBar = new ToolBar(); toolBar.add(new LabelToolItem("Selection Mode: ")); SimpleComboBox<String> type = new SimpleComboBox<String>(new StringLabelProvider<String>()); type.setTriggerAction(TriggerAction.ALL); type.setEditable(false); type.setWidth(100); type.add("Multi"); type.add("Simple"); type.setValue("Multi"); type.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { boolean simple = event.getValue().equals("Simple"); sm.deselectAll(); sm.setSelectionMode(simple ? SelectionMode.SIMPLE : SelectionMode.MULTI); } }); toolBar.add(type); VerticalLayoutContainer con = new VerticalLayoutContainer(); cp.setWidget(con); con.add(toolBar, new VerticalLayoutData(1, -1)); con.add(grid, new VerticalLayoutData(1, 1)); return cp; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.layout.HBoxLayoutExample.java
License:sencha.com license
@Override public Widget asWidget() { ScrollPanel con = new ScrollPanel(); con.getElement().getStyle().setMargin(10, Unit.PX); ContentPanel panel = new ContentPanel(); panel.setHeadingText("HorizontalBox Example"); panel.setPixelSize(600, 500);/* www. j a v a2 s.c om*/ BorderLayoutContainer border = new BorderLayoutContainer(); panel.setWidget(border); VBoxLayoutContainer lcwest = new VBoxLayoutContainer(); lcwest.setPadding(new Padding(5)); lcwest.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH); BorderLayoutData west = new BorderLayoutData(150); west.setMargins(new Margins(5)); // west.setSplit(true); border.setWestWidget(lcwest, west); lccenter = new ContentPanel(); lccenter.setHeaderVisible(false); lccenter.add(new HTML( "<p style=\"padding:10px;color:#556677;font-size:11px;\">Select a configuration on the left</p>")); MarginData center = new MarginData(new Margins(5)); border.setCenterWidget(lccenter, center); BoxLayoutData vBoxData = new BoxLayoutData(new Margins(5, 5, 5, 5)); vBoxData.setFlex(1); lcwest.add(createToggleButton("Spaced", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.TOP); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 5, 0, 0)); flex.setFlex(1); c.add(new Label(), flex); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Multi-Spaced", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.TOP); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 5, 0, 0)); flex.setFlex(1); c.add(new Label(), flex); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new Label(), flex); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new Label(), flex); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: top", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.TOP); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: middle", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: bottom", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.BOTTOM); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: stretch", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.STRETCH); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: stretchmax", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.STRETCHMAX); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 5, 0, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex: All even", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 5, 0, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(1); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex: ratio", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 5, 0, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(3); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex + Stretch", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.STRETCH); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 5, 0, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(3); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: start", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); c.setPack(BoxLayoutPack.START); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 5, 0, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: center", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); c.setPack(BoxLayoutPack.CENTER); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 5, 0, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: end", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { HBoxLayoutContainer c = new HBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); c.setPack(BoxLayoutPack.END); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 5, 0, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); con.add(panel); return con; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.layout.VBoxLayoutExample.java
License:sencha.com license
@Override public Widget asWidget() { ScrollPanel con = new ScrollPanel(); con.getElement().getStyle().setMargin(10, Unit.PX); ContentPanel panel = new ContentPanel(); panel.setHeadingText("VerticalBox Example"); panel.setPixelSize(600, 500);/*from w w w . j a v a 2 s . co m*/ BorderLayoutContainer border = new BorderLayoutContainer(); panel.setWidget(border); VBoxLayoutContainer lcwest = new VBoxLayoutContainer(); lcwest.setPadding(new Padding(5)); lcwest.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH); BorderLayoutData west = new BorderLayoutData(150); west.setMargins(new Margins(5)); // west.setSplit(true); border.setWestWidget(lcwest, west); lccenter = new ContentPanel(); lccenter.setHeaderVisible(false); lccenter.add(new HTML( "<p style=\"padding:10px;color:#556677;font-size:11px;\">Select a configuration on the left</p>")); MarginData center = new MarginData(new Margins(5)); border.setCenterWidget(lccenter, center); BoxLayoutData vBoxData = new BoxLayoutData(new Margins(5, 5, 5, 5)); vBoxData.setFlex(1); lcwest.add(createToggleButton("Spaced", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0)); flex.setFlex(1); c.add(new Label(), flex); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Multi-Spaced", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0)); flex.setFlex(1); c.add(new Label(), flex); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new Label(), flex); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new Label(), flex); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: left", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.LEFT); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: center", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: right", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.RIGHT); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: stretch", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Align: stretchmax", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCHMAX); c.add(new TextButton(button1Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button2Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button3Text), new BoxLayoutData(new Margins(0, 0, 5, 0))); c.add(new TextButton(button4Text), new BoxLayoutData(new Margins(0))); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex: All even", new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(1); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex: ratio", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(3); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Flex + Stretch", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.STRETCH); BoxLayoutData flex = new BoxLayoutData(new Margins(0, 0, 5, 0)); flex.setFlex(1); c.add(new TextButton(button1Text), flex); c.add(new TextButton(button2Text), flex); c.add(new TextButton(button3Text), flex); BoxLayoutData flex2 = new BoxLayoutData(new Margins(0)); flex2.setFlex(3); c.add(new TextButton(button4Text), flex2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: start", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); c.setPack(BoxLayoutPack.START); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: center", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); c.setPack(BoxLayoutPack.CENTER); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); lcwest.add(createToggleButton("Pack: end", new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) { VBoxLayoutContainer c = new VBoxLayoutContainer(); c.setPadding(new Padding(5)); c.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); c.setPack(BoxLayoutPack.END); BoxLayoutData layoutData = new BoxLayoutData(new Margins(0, 0, 5, 0)); c.add(new TextButton(button1Text), layoutData); c.add(new TextButton(button2Text), layoutData); c.add(new TextButton(button3Text), layoutData); BoxLayoutData layoutData2 = new BoxLayoutData(new Margins(0)); c.add(new TextButton(button4Text), layoutData2); addToCenter(c); } } }), vBoxData); con.add(panel); return con; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.misc.DatePickerExample.java
License:sencha.com license
@Override public Widget asWidget() { VerticalPanel vp = new VerticalPanel(); vp.setSpacing(10);/*from w w w . java 2 s . co m*/ DatePicker picker = new DatePicker(); picker.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { Date d = event.getValue(); DateTimeFormat f = DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT); Info.display("Value Changed", "You selected " + f.format(d)); } }); vp.add(picker); return vp; }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.misc.DatePickerUiBinderExample.java
License:sencha.com license
@UiHandler("picker") public void onValueChange(ValueChangeEvent<Date> event) { Date d = event.getValue(); DateTimeFormat f = DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT); Info.display("Value Changed", "You selected " + f.format(d)); }
From source file:com.msco.mil.client.com.sencha.gxt.explorer.client.toolbar.ToolBarUiBinderExample.java
License:sencha.com license
public Widget asWidget() { Widget component = uiBinder.createAndBindUi(this); for (int i = 0; i < 40; i++) { scrollMenu.add(new MenuItem("Item " + i)); }//from w w w . j av a 2 s. c o m dateMenu.getDatePicker().addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { Date d = event.getValue(); DateTimeFormat f = DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT); Info.display("Value Changed", "You selected " + f.format(d)); dateMenu.hide(true); } }); colorMenu.getPalette().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { String color = event.getValue(); Info.display("Color Changed", "You selected " + color); colorMenu.hide(true); } }); return component; }
From source file:com.murrayc.murraycgwtpexample.client.application.thing.ThingView.java
License:Open Source License
@Override public void setThing(final Thing thing) { Window.setTitle("murrayc GWTP AppEngine Example" + ": " + "Thing" + ": " + thing.getText()); choicesPanel.clear();/* w ww . j a va 2s . c o m*/ if (thing == null) { thingLabel.setText(""); return; } thingLabel.setText(thing.getText()); List<String> choices = new ArrayList<>(); choices.add("Yes"); choices.add("No"); final String groupName = "choices"; for (final String choice : choices) { final RadioButton radioButton = new RadioButton(groupName, choice); radioButton.addStyleName("thing-radio-button"); radioButton.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(final ValueChangeEvent<Boolean> event) { if (event.getValue()) { submitAnswer(choice); } } }); choicesPanel.add(radioButton); } updateResultPanelUi(State.WAITING_FOR_ANSWER); resultLabel.setText(""); }