@Override public void onModuleLoad() { ToolbarView toolbarView = new ToolbarView(); LabelView label = new LabelView("My Application"); toolbarView.addLeftView(label); toolbarView.addLeftView(new ToolbarViewDivider()); ButtonView newBtn = new ButtonView("New"); newBtn.setIcon("fa fa-plus"); toolbarView.addLeftView(newBtn); ButtonView saveBtn = new ButtonView("Save"); saveBtn.setIcon("fa fa-save"); toolbarView.addLeftView(saveBtn); ButtonView downloadBtn = new ButtonView("Download"); downloadBtn.setIcon("fa fa-cloud"); toolbarView.addLeftView(downloadBtn); MenuButtonView menuButtonView = new MenuButtonView("Options"); menuButtonView.addMenuItem(new MenuItemView("Option 1")); menuButtonView.addMenuItem(new MenuItemView("Option 2")); MenuItemView menuItemView = new MenuItemView("Option 3"); MenuView submenu = new MenuView(); submenu.addMenuItem(new MenuItemView("Sub Item 1")); submenu.addMenuItem(new MenuItemView("Sub Item 2")); submenu.addMenuItem(new MenuItemView("Sub Item 3")); menuItemView.setSubMenu(submenu); menuButtonView.addMenuItem(menuItemView); toolbarView.addLeftView(menuButtonView); SearchTextView searchTextView = new SearchTextView(); toolbarView.addRightView(searchTextView); RootView.get().addView(toolbarView); }
public void onModuleLoad() { final View v = new View() { @Override public void render(Element element) { // checkbox checkboxView = new CheckboxView("Check Box"); checkboxView.addActionHandler( new ActionHandler<CheckboxView>() { @Override public void onAction(ActionEvent<CheckboxView> event) { Window.alert("check! " + event.getSender().getValue()); } }); addView(checkboxView); // radio View radioGroup = new View() { @Override public void render(Element element) { r1 = new RadioView("group1"); r1.setLabel("Option 1"); r2 = new RadioView("group1"); r2.setLabel("Option 2"); r3 = new RadioView("group1"); r3.setLabel("Option 3"); addViews(r1, r2, r3); r1.addActionHandler( new ActionHandler<RadioView>() { @Override public void onAction(ActionEvent<RadioView> event) { Window.alert("select!"); } }); } }; radioGroup.setStyleAttribute("marginTop", "10px"); addView(radioGroup); // select selectView = new SelectView(); selectView.addActionHandler( new ActionHandler<SelectView>() { @Override public void onAction(ActionEvent<SelectView> event) { Window.alert("selected " + event.getSender().getSelectedValue()); } }); for (int i = 0; i < 8; i++) { selectView.addOption("Option " + i); } selectView.setStyleAttribute("marginTop", "10px"); selectView.setWidth(120); addView(selectView); // text textField = new TextView(); textField.addChangeHandler( new ChangeHandler<String>() { @Override public void onChange(ChangeEvent<String> event) { GWT.log("text changing: " + event.getValue()); } }); textField.setStyleAttribute("marginTop", "10px"); textField.setWidth(200); addView(textField); multiline = new TextView(); multiline.setMultiline(true); multiline.setStyleAttribute("marginTop", "10px"); multiline.setWidth(200); multiline.setHeight(200); multiline.addChangeHandler( new ChangeHandler<String>() { @Override public void onChange(ChangeEvent<String> event) { GWT.log("text changing: " + event.getValue()); } }); addView(multiline); slider = new SliderView(); slider.setContinuous(true); slider.setShowValueTooltip(true); slider.setStyleAttribute("marginTop", "16px"); slider.setWidth(200); slider.setMaxValue(200); slider.setMinValue(100); slider.setStep(2); addView(slider); sliderV = new SliderView(); sliderV.setContinuous(true); sliderV.setShowValueTooltip(true); sliderV.setVertical(true); sliderV.setStyleAttribute("marginTop", "16px"); sliderV.setHeight(200); addView(sliderV); datePickerView = new DatePickerView(); // datePickerView.setDateFormat("MMMM dd, yyyy"); datePickerView.setWidth("238px"); datePickerView.addChangeHandler( new ChangeHandler<Date>() { @Override public void onChange(ChangeEvent<Date> event) { GWT.log("date changed"); } }); addView(datePickerView); } }; v.setStyleAttribute("margin", "25px"); ScrollView scrollView = new ScrollView(); scrollView.setContentView(v); RootView.get().addView(scrollView); final ButtonView disableAll = new ButtonView("Disable All"); disableAll.setStyleAttribute("marginTop", "15px"); disableAll.addActionHandler( new ActionHandler<ButtonView>() { @Override public void onAction(ActionEvent<ButtonView> event) { if (disableAll.getLabel().equals("Disable All")) { checkboxView.setDisabled(true); r1.setDisabled(true); r2.setDisabled(true); r3.setDisabled(true); selectView.setDisabled(true); textField.setDisabled(true); multiline.setDisabled(true); slider.setDisabled(true); sliderV.setDisabled(true); datePickerView.setDisabled(true); disableAll.setLabel("Enabled All"); } else { checkboxView.setDisabled(false); r1.setDisabled(false); r2.setDisabled(false); r3.setDisabled(false); selectView.setDisabled(false); textField.setDisabled(false); multiline.setDisabled(false); slider.setDisabled(false); sliderV.setDisabled(false); datePickerView.setDisabled(false); disableAll.setLabel("Disable All"); } } }); v.addView(disableAll); }