private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); TextButton refreshButton = new TextButton("Обновить"); refreshButton.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { update(); } }); toolBar.add(refreshButton); return toolBar; }
/** * Creates button used to clear the list. * * @return button */ private TextButton createClearAllButton() { TextButton clearAllButton = new TextButton(AppPropertiesManager.CONSTANTS.myjobs_clear_button()); clearAllButton.addStyleName("eppic-default-font"); clearAllButton.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { CrkWebServiceProvider.getServiceController().deleteAllJobs(getCurrentJobsList()); } }); String iconSource = "resources/icons/clear_icon.png"; clearAllButton.setIcon( IconHelper.getImageResource(UriUtils.fromSafeConstant(iconSource), 12, 12)); return clearAllButton; }
@Override public Widget asWidget() { final Window complex = new Window(); complex.setMaximizable(true); complex.setHeadingText("Accordion Window"); complex.setWidth(200); complex.setHeight(350); AccordionLayoutContainer con = new AccordionLayoutContainer(); con.setExpandMode(ExpandMode.SINGLE_FILL); complex.add(con); AccordionLayoutAppearance appearance = GWT.<AccordionLayoutAppearance>create(AccordionLayoutAppearance.class); ContentPanel cp = new ContentPanel(appearance); cp.setAnimCollapse(false); cp.setHeadingText("Online Users"); cp.getHeader().addStyleName(ThemeStyles.getStyle().borderTop()); con.add(cp); con.setActiveWidget(cp); TreeStore<NameImageModel> store = new TreeStore<NameImageModel>(NameImageModel.KP); Tree<NameImageModel, String> tree = new Tree<NameImageModel, String>( store, new ValueProvider<NameImageModel, String>() { @Override public String getValue(NameImageModel object) { return object.getName(); } @Override public void setValue(NameImageModel object, String value) {} @Override public String getPath() { return "name"; } }); tree.setIconProvider( new IconProvider<NameImageModel>() { public ImageResource getIcon(NameImageModel model) { if (null == model.getImage()) { return null; } else if ("user-girl" == model.getImage()) { return ExampleImages.INSTANCE.userFemale(); } else if ("user-kid" == model.getImage()) { return ExampleImages.INSTANCE.userKid(); } else { return ExampleImages.INSTANCE.user(); } } }); NameImageModel m = newItem("Family", null); store.add(m); store.add(m, newItem("Darrell", "user")); store.add(m, newItem("Maro", "user-girl")); store.add(m, newItem("Lia", "user-kid")); store.add(m, newItem("Alec", "user-kid")); store.add(m, newItem("Andrew", "user-kid")); tree.setExpanded(m, true); m = newItem("Friends", null); store.add(m); store.add(m, newItem("Bob", "user")); store.add(m, newItem("Mary", "user-girl")); store.add(m, newItem("Sally", "user-girl")); store.add(m, newItem("Jack", "user")); tree.setExpanded(m, true); cp.add(tree); cp = new ContentPanel(appearance); cp.setAnimCollapse(false); cp.setBodyStyleName("pad-text"); cp.setHeadingText("Settings"); cp.add(new Label(TestData.DUMMY_TEXT_SHORT)); con.add(cp); cp = new ContentPanel(appearance); cp.setAnimCollapse(false); cp.setBodyStyleName("pad-text"); cp.setHeadingText("Stuff"); cp.add(new Label(TestData.DUMMY_TEXT_SHORT)); con.add(cp); cp = new ContentPanel(appearance); cp.setAnimCollapse(false); cp.setBodyStyleName("pad-text"); cp.setHeadingText("More Stuff"); cp.add(new Label(TestData.DUMMY_TEXT_SHORT)); con.add(cp); TextButton b = new TextButton("Open"); b.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { complex.show(); } }); VerticalPanel vp = new VerticalPanel(); vp.setSpacing(10); vp.add(b); return vp; }
@Override public Widget asWidget() { if (buttons == null) { // Simple final Dialog simple = new Dialog(); simple.setHeadingText("Dialog Test"); simple.setPredefinedButtons(PredefinedButton.YES, PredefinedButton.NO); simple.setBodyStyleName("pad-text"); simple.add(new Label(TestData.DUMMY_TEXT_SHORT)); simple.getBody().addClassName("pad-text"); simple.setHideOnButtonClick(true); simple.setWidth(300); // Layout final Dialog complex = new Dialog(); complex.setBodyBorder(false); complex.getHeader().setIcon(Resources.IMAGES.side_list()); complex.setHeadingText("BorderLayout Dialog"); complex.setWidth(400); complex.setHeight(225); complex.setHideOnButtonClick(true); BorderLayoutContainer layout = new BorderLayoutContainer(); complex.add(layout); // Layout - west ContentPanel panel = new ContentPanel(); panel.setHeadingText("West"); BorderLayoutData data = new BorderLayoutData(150); data.setMargins(new Margins(0, 5, 0, 0)); panel.setLayoutData(data); layout.setWestWidget(panel); // Layout - center panel = new ContentPanel(); panel.setHeadingText("Center"); layout.setCenterWidget(panel); // Auto Size - See the JavaDoc for Window for more information on auto size final FlowLayoutContainer flc = new FlowLayoutContainer(); flc.add(new HTML("Press Add or Remove to modify content")); final Dialog autoSize = new Dialog(); autoSize.setBodyBorder(false); autoSize.setHeadingText("Auto Size Dialog"); autoSize.setHideOnButtonClick(true); autoSize.setWidget(flc); autoSize.setPixelSize(-1, -1); autoSize.setMinWidth(0); autoSize.setMinHeight(0); autoSize.setResizable(false); autoSize.setShadow(true); autoSize.addButton( new TextButton( "Add", new SelectHandler() { @Override public void onSelect(SelectEvent event) { addAutoSizeContent(flc); autoSize.forceLayout(); } })); autoSize.addButton( new TextButton( "Remove", new SelectHandler() { @Override public void onSelect(SelectEvent event) { int lastWidget = flc.getWidgetCount() - 1; if (lastWidget > 0) { flc.remove(lastWidget); autoSize.forceLayout(); } } })); // Buttons buttons = new ButtonBar(); buttons.setWidth(400); buttons.getElement().setMargins(10); TextButton b = new TextButton("Simple"); b.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { simple.show(); } }); buttons.add(b); b = new TextButton("Layout"); b.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { complex.show(); } }); buttons.add(b); b = new TextButton("Auto Size"); b.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { autoSize.show(); } }); buttons.add(b); // Add some basic content to begin with for (int i = 0; i < 5; i++) { addAutoSizeContent(flc); } } return buttons; }
@Override public Widget asWidget() { final ListStore<Data> store = new ListStore<Data>(dataAccess.nameKey()); store.addAll(TestData.getData(12, 20, 100)); final Chart<Data> chart = new Chart<Data>(); chart.setStore(store); chart.setShadowChart(true); NumericAxis<Data> axis = new NumericAxis<Data>(); axis.setPosition(Position.BOTTOM); axis.addField(dataAccess.data1()); axis.addField(dataAccess.data2()); axis.addField(dataAccess.data3()); TextSprite title = new TextSprite("Number of Hits"); title.setFontSize(18); axis.setTitleConfig(title); axis.setDisplayGrid(true); axis.setMinimum(0); axis.setMaximum(100); chart.addAxis(axis); CategoryAxis<Data, String> catAxis = new CategoryAxis<Data, String>(); catAxis.setPosition(Position.LEFT); catAxis.setField(dataAccess.name()); title = new TextSprite("Month of the Year"); title.setFontSize(18); catAxis.setTitleConfig(title); chart.addAxis(catAxis); final BarSeries<Data> bar = new BarSeries<Data>(); bar.setYAxisPosition(Position.BOTTOM); bar.addYField(dataAccess.data1()); bar.addYField(dataAccess.data2()); bar.addYField(dataAccess.data3()); bar.addColor(new RGB(148, 174, 10)); bar.addColor(new RGB(17, 95, 166)); bar.addColor(new RGB(166, 17, 32)); chart.addSeries(bar); final Legend<Data> legend = new Legend<Data>(); legend.setPosition(Position.RIGHT); legend.setItemHighlighting(true); legend.setItemHiding(true); chart.setLegend(legend); TextButton regenerate = new TextButton("Reload Data"); regenerate.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { store.clear(); store.addAll(TestData.getData(12, 0, 100)); chart.redrawChart(); } }); ToggleButton animation = new ToggleButton("Animate"); animation.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { chart.setAnimated(event.getValue()); } }); animation.setValue(true, true); ToggleButton shadow = new ToggleButton("Shadow"); shadow.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { chart.setShadowChart(event.getValue()); chart.redrawChart(); } }); shadow.setValue(true); ToolBar toolBar = new ToolBar(); toolBar.add(regenerate); toolBar.add(animation); toolBar.add(shadow); ContentPanel panel = new FramedPanel(); panel.getElement().getStyle().setMargin(10, Unit.PX); panel.setCollapsible(true); panel.setHeadingText("Grouped Bar Chart"); panel.setPixelSize(620, 500); panel.setBodyBorder(true); final Resizable resize = new Resizable(panel, Dir.E, Dir.SE, Dir.S); resize.setMinHeight(400); resize.setMinWidth(400); panel.addExpandHandler( new ExpandHandler() { @Override public void onExpand(ExpandEvent event) { resize.setEnabled(true); } }); panel.addCollapseHandler( new CollapseHandler() { @Override public void onCollapse(CollapseEvent event) { resize.setEnabled(false); } }); new Draggable(panel, panel.getHeader()).setUseProxy(false); VerticalLayoutContainer layout = new VerticalLayoutContainer(); panel.add(layout); toolBar.setLayoutData(new VerticalLayoutData(1, -1)); layout.add(toolBar); chart.setLayoutData(new VerticalLayoutData(1, 1)); layout.add(chart); return panel; }
private ContentPanel createContent() { TEXT_AREA.setReadOnly(true); final TextButton refreshButton = new TextButton("Refresh"); refreshButton.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { refresh(); } }); final TextButton newPatButton = new TextButton("Obtain new PAT token"); newPatButton.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { final ProgressDialog progressDialog = new ProgressDialog("Perform operation..."); progressDialog.show(); getService() .obtainNewPat( new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { progressDialog.hide(); handleException(caught); GwtUtils.showError("Unable to obtain new PAT token."); refresh(); } @Override public void onSuccess(String result) { progressDialog.hide(); GwtUtils.showInformation("PAT token is obtained successfully."); refresh(); } }); } }); final TextButton clearButton = new TextButton("Clear"); clearButton.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { getService() .clearLogs( new AsyncCallback<Void>() { @Override public void onFailure(Throwable p_throwable) { handleException(p_throwable); GwtUtils.showError("Unable to clear logs."); } @Override public void onSuccess(Void p_void) { TEXT_AREA.setValue(""); } }); } }); final HBoxLayoutContainer h = new HBoxLayoutContainer(); h.add(refreshButton, new BoxLayoutContainer.BoxLayoutData(DEFAULT_MARGINS)); h.add(clearButton, new BoxLayoutContainer.BoxLayoutData(DEFAULT_MARGINS)); h.add(newPatButton, new BoxLayoutContainer.BoxLayoutData(DEFAULT_MARGINS)); final VerticalLayoutContainer v = new VerticalLayoutContainer(); v.add(h, new VerticalLayoutContainer.VerticalLayoutData(1, -1, DEFAULT_MARGINS)); v.add(TEXT_AREA, new VerticalLayoutContainer.VerticalLayoutData(1, 1, DEFAULT_MARGINS)); final ContentPanel cp = new ContentPanel(); cp.setHeadingText("Resource Server Monitor"); cp.add(v); return cp; }
public Widget getWidget() { form2 = new FramedPanel(); form2.setHeadingText(""); form2.setWidth("100%"); FieldSet fieldSet = new FieldSet(); fieldSet.setHeadingText("Emailing Setting"); fieldSet.setCollapsible(true); fieldSet.setHeight(155); form2.add(fieldSet); VerticalLayoutContainer p = new VerticalLayoutContainer(); fieldSet.add(p); HorizontalPanel hp = new HorizontalPanel(); // statusButton.setValue(true); // final TextButton refreshButton = new TextButton(); // refreshButton.setIcon(ressources.loading()); // statusButton.setWidth("60px"); hp.add(statusButton); // hp.add(refreshButton); p.add(new FieldLabel(hp, "System status")); month.setTriggerAction(TriggerAction.ALL); month.setEditable(false); month.setWidth(100); month.add(lFrequency); month.addSelectionHandler( new SelectionHandler<String>() { @Override public void onSelection(SelectionEvent<String> event) {} }); p.add(new FieldLabel(month, "Frequency"), new VerticalLayoutData(1, -1)); 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()); } }); // date.addValidator(new MinDateValidator(new Date())); p.add(new FieldLabel(date, "Starting date"), new VerticalLayoutData(1, -1)); time.addParseErrorHandler( new ParseErrorHandler() { @Override public void onParseError(ParseErrorEvent event) {} }); time.setMinValue(new DateWrapper().clearTime().addHours(8).asDate()); time.setMaxValue(new DateWrapper().clearTime().addHours(18).addSeconds(1).asDate()); p.add(new FieldLabel(time, "Starting time"), new VerticalLayoutData(1, -1)); statusButton.addValueChangeHandler( new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { statusButton.setText(statusButton.getValue() ? "On" : "Off"); } }); load(); form2.addButton(refresh); form2.addButton(save); refresh.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { refresh.setIcon(ressources.loading()); refresh.setEnabled(false); load(); } }); save.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { save.setIcon(ressources.loading()); save.setEnabled(false); save(); } }); return form2; }
/** This is the entry point method. */ public void onModuleLoad() { TextButton textButton = new TextButton("Verify GXT Works3"); RootPanel.get().add(textButton); textButton.addSelectHandler( new SelectHandler() { @Override public void onSelect(SelectEvent event) { String s = new String("test"); MessageBox messageBox = new MessageBox("GXT Works."); messageBox.show(); } }); final Button sendButton = new Button("Send"); final TextBox nameField = new TextBox(); nameField.setText("GWT User"); final Label errorLabel = new Label(); // We can add style names to widgets sendButton.addStyleName("sendButton"); // Add the nameField and sendButton to the RootPanel // Use RootPanel.get() to get the entire body element RootPanel.get("nameFieldContainer").add(nameField); RootPanel.get("sendButtonContainer").add(sendButton); RootPanel.get("errorLabelContainer").add(errorLabel); // Focus the cursor on the name field when the app loads nameField.setFocus(true); nameField.selectAll(); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); final Button closeButton = new Button("Close"); // We can set the id of a widget by accessing its Element closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendNameToServer(); } /** Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer( textToServer, new AsyncCallback<String>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); serverResponseLabel.addStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(SERVER_ERROR); dialogBox.center(); closeButton.setFocus(true); } public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); }
private void initWizardPanel() { this.setHeight(400); this.getElement().setMargins(10); // set headbar button this.getHeader() .addTool( new ToolButton( ToolButton.CLOSE, new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { cancelHandler.onCancel(); cancel(); } })); // add bottom buttons TextButton prev = new TextButton("back"); TextButton next = new TextButton("next"); TextButton finish = new TextButton("finish"); TextButton cancel = new TextButton("cancel"); this.addButton(prev); this.addButton(next); this.addButton(finish); this.addButton(cancel); // and add buttons to buttons map buttons.put(ButtonType.PREV, prev); buttons.put(ButtonType.NEXT, next); buttons.put(ButtonType.FINISH, finish); buttons.put(ButtonType.CANCEL, cancel); // set button action prev.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { try { prevHandlers.get(stepWigs.get(step)).onPrevStep(); } catch (Exception ex) { } back(); } }); next.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { try { nextHandlers.get(stepWigs.get(step)).onNextStep(); } catch (Exception ex) { } next(); } }); finish.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { try { finishHandler.onFinish(); } catch (Exception ex) { } finish(); } }); cancel.addSelectHandler( new SelectEvent.SelectHandler() { @Override public void onSelect(SelectEvent event) { try { cancelHandler.onCancel(); } catch (Exception ex) { } cancel(); } }); }