List of usage examples for com.google.gwt.user.client.ui Button Button
public Button(String html, ClickHandler handler)
From source file:com.calclab.emite.widgets.client.chat.GWTAbstractChatWidget.java
License:Open Source License
public GWTAbstractChatWidget() { this.onSendMessage = new Event<String>("widgets:room:sendMessage"); this.area = new TextArea(); this.input = new TextBox(); input.addKeyPressHandler(new KeyPressHandler() { public void onKeyPress(final KeyPressEvent event) { if (event.getNativeEvent().getKeyCode() == 13) { sendMessage();/* ww w . ja v a 2 s .co m*/ } } }); this.send = new Button("send", new ClickHandler() { public void onClick(final ClickEvent event) { sendMessage(); } }); final HorizontalPanel inputBar = new HorizontalPanel(); inputBar.add(input); inputBar.add(send); add(area, DockPanel.CENTER); add(inputBar, DockPanel.SOUTH); }
From source file:com.calclab.emite.widgets.client.logger.LoggerWidget.java
License:Open Source License
public LoggerWidget() { this.onClear = new Event0("widgets.logger:onClear"); content = new VerticalPanel(); final Button clear = new Button("clear", new ClickHandler() { public void onClick(final ClickEvent event) { onClear.fire();//ww w.j a v a 2 s .c om } }); final FlowPanel panel = new FlowPanel(); panel.add(clear); add(panel, DockPanel.SOUTH); scroll = new ScrollPanel(); scroll.addStyleName("content"); scroll.setAlwaysShowScrollBars(true); scroll.add(content); add(scroll, DockPanel.CENTER); }
From source file:com.calclab.emite.widgets.client.login.LoginWidget.java
License:Open Source License
public LoginWidget() { setStylePrimaryName("emite-LoginWidget"); this.isConnected = false; this.onLogin = new Event2<String, String>("widgets:login:onLogin"); this.onLogout = new Event0("widgets:login:onLogout"); this.jid = new TextBox(); this.password = new PasswordTextBox(); this.button = new Button("login", new ClickHandler() { public void onClick(final ClickEvent event) { if (isConnected) { onLogout.fire();/*from ww w .j av a 2s .c o m*/ } else { onLogin.fire(jid.getText(), password.getText()); } } }); this.status = new Label(); this.error = new Label("errors here!"); error.addStyleDependentName("error"); add(error); add(jid); add(password); add(button); add(status); }
From source file:com.calclab.emite.widgets.client.logout.LogoutWidget.java
License:Open Source License
public LogoutWidget() { setStylePrimaryName("emite-LogoutWidget"); this.onLogout = new Event0("widgets:logout:onLogout"); this.label = new Label(); this.button = new Button("logout", new ClickHandler() { public void onClick(final ClickEvent event) { onLogout.fire();/* w w w. jav a 2 s .co m*/ } }); add(label); add(button); }
From source file:com.canoo.gwt.contentflow4gwt.client.ContentFlowDemo.java
License:Open Source License
public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable e) { Window.alert("Exception: " + e.getMessage()); }// w w w . j ava 2 s . co m }); Button inButtonPhotos = new Button("Come in with photos!", new ClickHandler() { public void onClick(ClickEvent event) { doAnimateContentFlowIn(); } }); Panel buttonsPanel = new FlowPanel(); buttonsPanel.add(inButtonPhotos); RootPanel.get().add(buttonsPanel); }
From source file:com.cognitivemedicine.metricsdashboard.client.widgets.Alerts.java
License:Apache License
public static void notify(Panel parent, String title, String message) { final DialogBox d = new DialogBox(); d.setText(title);/* w w w.j a va 2s. c o m*/ d.setModal(false); // d.center(); Button closeButton = new Button("Close", new ClickHandler() { public void onClick(ClickEvent event) { d.hide(); } }); // d.add(closeButton); d.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(CloseEvent<PopupPanel> event) { d.hide(); } }); VerticalPanel v = new VerticalPanel(); // v.add(new Label(message)); HTML html = new HTML(); html.setHTML(message); html.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { d.hide(); } }); v.add(html); v.add(closeButton); d.setWidget(v); // d.setPopupPosition(Window.getClientWidth()-d.getOffsetWidth(), // Window.getClientHeight()-d.getOffsetWidth()); Timer t = new Timer() { @Override public void run() { d.hide(); } }; t.schedule(3000); d.setWidth("300px"); d.setHeight("200px"); d.center(); // d.setPopupPosition(Window.getClientWidth()-d.getOffsetWidth(), // Window.getClientHeight()-d.getOffsetWidth()); // d.show(); }
From source file:com.controlj.addon.gwttree.client.Dialog.java
License:Open Source License
private static void showErrorDialog(String title, String html, String text) { // Create a dialog box and set the caption text final DialogBox dialogBox = new DialogBox(false, true); dialogBox.setText(title);/*from w w w .ja v a 2 s. com*/ // Create a table to layout the content VerticalPanel dialogContents = new VerticalPanel(); dialogContents.setSpacing(4); dialogBox.setWidget(dialogContents); // Add either HTML or Text Widget details = html != null ? new HTML(html) : new Label(text); dialogContents.add(details); dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER); // Add a close button at the bottom of the dialog Button closeButton = new Button("Close", new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogContents.add(closeButton); dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER); // final configuration and show the dialog box dialogBox.setGlassEnabled(true); dialogBox.setAnimationEnabled(true); dialogBox.center(); dialogBox.show(); }
From source file:com.controlj.addon.gwttree.client.Dialog.java
License:Open Source License
private static Button createButton(String label, final DialogBox dialogBox, final boolean isCancel, final Handler handler) { return new Button(label, new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide();// w w w . j a v a 2 s.c om handler.dialogClosed(isCancel); } }); }
From source file:com.controlj.addon.gwttree.client.TreeOptions.java
License:Open Source License
public void showDialog() { VerticalPanel dialogContents = new VerticalPanel(); dialogContents.setSpacing(4);//w w w. j a v a 2 s . c o m // Add the tree type radio buttons RadioButton dynamicChoice = createTreeChoice("treeTypeGroup", "Dynamic Tree", false); RadioButton staticChoice = createTreeChoice("treeTypeGroup", "Static Tree", true); if (state.isStaticTree) staticChoice.setValue(true); else dynamicChoice.setValue(true); dialogContents.add(dynamicChoice); dialogContents.add(staticChoice); // Add filtering support dialogContents.add(new Label("Filter by trend name (leave empty to not filter)")); HorizontalPanel sourcesPanel = new HorizontalPanel(); sourcesPanel.setSpacing(10); final ListBox sourceListBox = new ListBox(true); sourceListBox.setSize("10em", "5em"); for (String sourceName : state.sourceNames) sourceListBox.addItem(sourceName); sourcesPanel.add(sourceListBox); VerticalPanel sourcesButtonPanel = new VerticalPanel(); sourcesButtonPanel.add(new Button("Add...", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { final TextBox textBox = new TextBox(); Dialog.showInputDialog("Add Filter", textBox, new Dialog.Handler() { @Override public void setupButtons(final Button ok, final Button cancel) { textBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent keyPressEvent) { if (keyPressEvent.getCharCode() == (char) 13) ok.click(); else if (keyPressEvent.getCharCode() == (char) 27) cancel.click(); } }); } @Override public void dialogClosed(boolean wasCancelled) { String name = textBox.getText().trim(); if (!wasCancelled && !name.isEmpty()) { state.sourceNames.add(name); sourceListBox.addItem(name); } } }); textBox.setFocus(true); } })); sourcesButtonPanel.add(new Button("Remove", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { int count = sourceListBox.getItemCount(); for (int i = count - 1; i >= 0; i--) if (sourceListBox.isItemSelected(i)) { state.sourceNames.remove(sourceListBox.getItemText(i)); sourceListBox.removeItem(i); } } })); sourcesPanel.add(sourcesButtonPanel); dialogContents.add(sourcesPanel); final State originalState = state.copy(); Dialog.showInputDialog("Tree Options", dialogContents, new Dialog.Handler() { @Override public void setupButtons(Button ok, Button cancel) { } @Override public void dialogClosed(boolean wasCancelled) { if (wasCancelled) state = originalState; else if (!state.equals(originalState)) handler.optionsChanged(TreeOptions.this); } }); }
From source file:com.controlj.addon.gwttree.client.TreeOptions.java
License:Open Source License
private Button createButton(String label, final DialogBox dialogBox, final boolean isCancel, final State originalState) { return new Button(label, new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide();//from ww w . j ava 2 s .c o m if (isCancel) state = originalState; else if (!state.equals(originalState)) handler.optionsChanged(TreeOptions.this); } }); }