List of usage examples for com.google.gwt.user.client.ui DialogBox setText
public void setText(String text)
From source file:com.googlecode.konamigwt.hadoken.client.Hadoken.java
License:BEER-WARE LICENSE
/** * This is the entry point method./*from w w w. j av a 2 s .co m*/ */ public void onModuleLoad() { 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); } }); // Quick and Dirty implementation new Konami(new KonamiHandler() { @Override public void onKonamiCodePerformed() { final Image image = new Image("media/ryu.gif"); DOM.appendChild(RootPanel.get().getElement(), image.getElement()); final Audio audio = Audio.createIfSupported(); if (audio != null) { audio.setSrc("media/hadoken.ogg"); DOM.appendChild(RootPanel.get().getElement(), audio.getElement()); audio.play(); } Timer timer = new Timer() { @Override public void run() { DOM.removeChild(RootPanel.get().getElement(), image.getElement()); if (audio != null) { DOM.removeChild(RootPanel.get().getElement(), audio.getElement()); } } }; timer.schedule(1100); } }).start(); // 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(""); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML("Hello " + textToServer); 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); }
From source file:com.googlecode.simplegwt.tbg.client.TbgEntryPoint.java
License:Apache License
/** * @see com.google.gwt.core.client.EntryPoint#onModuleLoad() *///from w w w . j a v a 2s . c om public void onModuleLoad() { final ButtonGrid buttonGrid = new ButtonGrid(DEFAULT_GRID_HEIGHT, DEFAULT_GRID_WIDTH); final GridControls gridControls = new GridControls(buttonGrid); final DialogBox dialog = new DialogBox(false, false); dialog.setWidget(new Label( "Click a button to toggle it on/off. " + "Adjacent buttons will also reverse their state.", true)); dialog.setText("Help - ToggleButtonGame"); dialog.addStyleName("tbg-help-dialog"); final FlowPanel gridHeaderBar = new FlowPanel(); final Label helpLabel = new CommandLabel("Help", new Command() { boolean shownOnce = false; public void execute() { if (dialog.isShowing()) { dialog.hide(); } else { if (shownOnce) { dialog.show(); } else { dialog.center(); shownOnce = true; } } } }); helpLabel.setStylePrimaryName("tbg-help"); gridHeaderBar.add(new LoginWidget(gridControls)); gridHeaderBar.add(helpLabel); final DecoratorPanel decoration = new DecoratorPanel(); final FlowPanel wrapper = new FlowPanel(); wrapper.add(gridHeaderBar); wrapper.add(gridControls); wrapper.add(buttonGrid); decoration.add(wrapper); RootPanel.get("gwt").add(decoration); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { resize(event.getHeight(), event.getWidth()); } }); resize(Window.getClientHeight(), Window.getClientWidth()); }
From source file:com.gwt.conn.client.Authenticate.java
/** This is essentially the main method for the editor app. */ public static void go() { storage.clear(); // uncomment to completely reset app final DialogBox startupBox = new DialogBox(); // movable box that contains widgets startupBox.setAnimationEnabled(true); startupBox.setText("Connoisseur"); final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets startupPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); // check to see if storage is supported if (storage != null) { // load dashboard if license key has been submitted before if (storage.getLength() > 0) { boolean internet = Communicate.hasInternet(); StorageContainer.initStorage(); // prepares storage for interaction Dashboard.loadMenu(Communicate.deserialize(storage.getItem("menu")), "", internet); //Dashboard.loadDashboard(); }//from ww w .j av a 2s.c o m // otherwise load authentication UI in order to receive license key input else { final Button submitButton = new Button("Submit"); // "Submit" appears on button submitButton.addStyleName("myButton"); // interacts with Connfrontend.css final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button buttonPanel.addStyleName("marginlessPanel"); // license widgets final Label licenseErrorLabel = new Label(); // dynamic text licenseErrorLabel.addStyleName("errorLabel"); // interacts with Connfrontend.css final TextBox submitLicense = new TextBox(); // user can input text using this submitLicense.setText("license key..."); // default text to be seen on load // restaurant ID widgets final Label restErrorLabel = new Label(); restErrorLabel.addStyleName("errorLabel"); final TextBox submitRestID = new TextBox(); submitRestID.setText("restaurant ID..."); // organize UI startupPanel.add(new HTML("Please enter your license key:")); startupPanel.add(submitLicense); startupPanel.add(licenseErrorLabel); startupPanel.add(new HTML("<br>Please enter your restaurant ID:")); startupPanel.add(submitRestID); startupPanel.add(restErrorLabel); startupPanel.add(new HTML("<br>")); buttonPanel.add(submitButton); final HTML commError = new HTML(); commError.addStyleName("errorLabel"); buttonPanel.add(commError); startupPanel.add(buttonPanel); // setup startupBox, which is what will be seen by the user startupBox.setWidget(startupPanel); // connects the two widgets startupBox.center(); // also shows the box // focus the cursor on submitLicense when startupBox appears submitLicense.setFocus(true); submitLicense.selectAll(); // create a handler for the submitButton and submitLicense class MyHandler implements ClickHandler, KeyUpHandler { /** Fired when the user clicks submit. */ public void onClick(ClickEvent event) { submit(); } /** Fired when the user presses Enter in submitLicense. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) submit(); } /** Checks the submitted license key for validity. Loads the dashboard if valid. */ private void submit() { // check submit fields String license = submitLicense.getText(); String restID = submitRestID.getText(); int returnFlag = 0; // so that both tests can be done licenseErrorLabel.setText(""); restErrorLabel.setText(""); // validate license String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java if (!result.equals("")) { // error licenseErrorLabel.setText(result); returnFlag = 1; } // validate restID result = FieldVerifier.isValidRestaurantID(restID); if (!result.equals("")) { // error restErrorLabel.setText(result); returnFlag = 1; } // don't do anything until the errors are resolved if (returnFlag == 1) return; storage.setItem("menu", ""); // attempt to authenticate Communicate.authenticate(restID, license, commError, startupBox, submitButton, submitLicense, submitRestID); } // end submit } // MyHandler // attach the handler final MyHandler handler = new MyHandler(); submitButton.addClickHandler(handler); submitLicense.addKeyUpHandler(handler); submitRestID.addKeyUpHandler(handler); } // else load authentication UI } // if storage supported // storage is not supported, so report error else { startupPanel.add(new HTML("<font color=red>The app will not function because local<br>" + "storage is not supported on this platform.</font>")); startupBox.setWidget(startupPanel); startupBox.center(); } }
From source file:com.gwt.conn.client.Dashboard.java
/** * Called by Authenticate.java when successfully authenticated. (multiple * menus version)/*from w w w. j a va 2 s.c o m*/ */ public void loadDashboard() { final HTML statusLabel = new HTML(); // dynamic HTML final DialogBox dashboardBox = new DialogBox(); dashboardBox.setAnimationEnabled(true); // send the license to the server greetingService.greetServer(storage.getItem("license"), new AsyncCallback<String>() { public void onFailure(Throwable caught) { // show the RPC error message to the user dashboardBox.setText("Dashboard - Offline Mode"); // statusLabel.setHTML(???); final DialogBox errorBox = new DialogBox(); errorBox.setAnimationEnabled(true); final VerticalPanel errorVPanel = new VerticalPanel(); errorVPanel.addStyleName("marginPanel"); // interacts // with // Connfrontend.css errorVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); final Button errorButton = new Button("Continue"); errorButton.addStyleName("myButton"); final HorizontalPanel errorHPanel = new HorizontalPanel(); errorVPanel.add(new HTML(SERVER_ERROR)); errorHPanel.add(errorButton); errorVPanel.add(errorHPanel); errorBox.setWidget(errorVPanel); errorBox.center(); errorButton.setFocus(true); // handler for errorButton class ErrorHandler implements ClickHandler, KeyUpHandler { // Fired when the user clicks Continue. public void onClick(ClickEvent event) { cont(); } // Fired when the user presses Enter. public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) cont(); } private void cont() { errorButton.setEnabled(false); errorBox.hide(); finishLoad(dashboardBox, statusLabel); // void // method // below } } // attach the handler final ErrorHandler errorHandler = new ErrorHandler(); errorButton.addClickHandler(errorHandler); } // end onFailure public void onSuccess(String result) { // StorageContainer.synchronizeWithBackend(); // // implemented in StorageContainer.java dashboardBox.setText("Dashboard"); statusLabel.setHTML(result); finishLoad(dashboardBox, statusLabel); // void method // below } }); // end greetServer }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private void createImageDialog(String imgurl) { final DialogBox imageDb = new DialogBox(); imageDb.setText("Image Capture of Chart"); VerticalPanel dbContents = new VerticalPanel(); dbContents.setSpacing(4);//from w ww . ja va 2s.co m imageDb.setWidget(dbContents); Image chartImg = new Image(imgurl); chartImg.setSize("250", "200"); dbContents.add(chartImg); Button closeButton = new Button("Close", new ClickHandler() { public void onClick(ClickEvent event) { imageDb.hide(); } }); dbContents.add(closeButton); dbContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT); imageDb.center(); imageDb.show(); }
From source file:com.mecatran.otp.gwt.client.PlannerWidgetEntryPoint.java
License:Open Source License
private void showIntroDialogBox() { if (config.getIntroMessage() == null) return;// w ww . j a v a 2s .c om final DialogBox dialogBox = new DialogBox(true, true); VerticalPanel dialogBoxContents = new VerticalPanel(); dialogBox.setText(I18nUtils.tr("welcome")); HTML message = new HTML(config.getIntroMessage()); Button button = new Button(I18nUtils.tr("ok"), new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBox.setWidth("400px"); dialogBoxContents.add(message); dialogBoxContents.add(button); dialogBox.setWidget(dialogBoxContents); dialogBox.center(); }
From source file:com.mecatran.otp.gwt.client.view.PlannerFormWidget.java
License:Open Source License
private void linkTo() { // Create URL String url = new PlannerState(getPlanRequestBean()).getUrl(); // Display dialog box final DialogBox dialogBox = new DialogBox(true, true); VerticalPanel dialogBoxContents = new VerticalPanel(); dialogBoxContents.setWidth("100%"); dialogBox.setText(I18nUtils.tr("link.to.this.page")); Label message = new Label(I18nUtils.tr("copy.paste.link.hint")); dialogBoxContents.add(message);/*ww w. ja v a2 s. c om*/ final TextBox urlTextBox = new TextBox(); urlTextBox.setText(url); urlTextBox.setWidth("100%"); dialogBoxContents.add(urlTextBox); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { urlTextBox.selectAll(); urlTextBox.setFocus(true); } }); Button button = new Button(I18nUtils.tr("ok"), new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); } }); dialogBoxContents.add(button); dialogBox.setWidth("400px"); dialogBox.setWidget(dialogBoxContents); dialogBox.center(); }
From source file:com.microdg.gwt.monitor.client.control.ApplicationGeneralErrorHandler.java
License:Apache License
@Override public void handle(String message) { final DialogBox dialog = new DialogBox(); dialog.setText("Application Error"); VerticalPanel vp = new VerticalPanel(); vp.setWidth("100%"); vp.add(new Label(message)); Button b = new Button("OK"); vp.add(b);// w w w. j a va2 s. c o m b.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { dialog.hide(); } }); dialog.setGlassEnabled(true); dialog.getElement().setAttribute("style", "background-color:white"); dialog.setAnimationEnabled(true); dialog.setWidget(vp); dialog.center(); }
From source file:com.objetdirect.tatami.demo.client.GfxDemo.java
License:Open Source License
/** * Show some properties about a <code>GraphicObjectw</code> * @param object the <code>GraphicObject</code> to show the properties * TODO change the layout of the dialog/*from ww w. j a v a 2 s. co m*/ */ private void showProperties(GraphicObject object) { final DialogBox dialog = new DialogBox(false); dialog.setText("Properties"); Grid panel = new Grid(5, 4); panel.setCellPadding(5); panel.setCellSpacing(10); panel.setWidget(0, 0, new HTML("<b>Position</b>")); panel.setWidget(0, 1, new Label(object.getX() + "," + object.getY())); panel.setWidget(0, 2, new HTML("<b>Center</b>")); panel.setWidget(0, 3, new Label(object.getCenterX() + "," + object.getCenterY())); panel.setWidget(1, 0, new HTML("<b>Size</b>")); panel.setWidget(1, 1, new Label("? x ? px")); panel.setWidget(2, 0, new HTML("<b>Color of the stroke</b>")); final String color = lastStrokeColor.toHex(); final Label label = new Label(color); label.setTitle(color); DOM.setStyleAttribute(label.getElement(), "color", color); panel.setWidget(2, 1, label); panel.setWidget(2, 2, new HTML("<b>Size of the stroke</b>")); panel.setWidget(2, 3, new Label(lastStrokeSize + "px")); panel.setWidget(3, 0, new HTML("<b>Fill color</b>")); final String fillColor = object.getFillColor().toHex(); final Label labelFill = new Label(fillColor); labelFill.setTitle(fillColor); panel.setWidget(3, 1, labelFill); DOM.setStyleAttribute(labelFill.getElement(), "color", fillColor); Button close = new Button("Close"); close.addClickListener(new ClickListener() { public void onClick(Widget sender) { dialog.hide(); } }); panel.setWidget(4, 0, close); dialog.setPopupPosition(Window.getClientWidth() / 2, Window.getClientHeight() / 2); dialog.addStyleName("GfxDemo-properties"); dialog.setWidget(panel); dialog.show(); System.out.println("bounds " + object.getBounds()); }
From source file:com.oracle.wci.portlet168.client.WciJsr168StartUpPortlet.java
License:Apache License
/** * This is the entry point method.// ww w.j a v a 2 s.com */ public void onModuleLoad() { final Button sendButton = new Button("Send ME"); 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); }