List of usage examples for com.google.gwt.user.client.ui DialogBox setWidget
@Override public void setWidget(Widget w)
From source file:com.gwt.conn.client.Communicate.java
public static void showDialog(String text) { final DialogBox errorBox = new DialogBox(); errorBox.setAnimationEnabled(true);// ww w . j a v a 2 s .c o m 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(text)); errorHPanel.add(errorButton); errorVPanel.add(errorHPanel); errorBox.setWidget(errorVPanel); errorBox.center(); errorButton.setFocus(true); class ErrorHandler implements ClickHandler, KeyUpHandler { public void onClick(ClickEvent event) { // button clicked cont(); } public void onKeyUp(KeyUpEvent event) { // ENTER key if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) cont(); } private void cont() { errorButton.setEnabled(false); errorBox.hide(); } } final ErrorHandler errorHandler = new ErrorHandler(); errorButton.addClickHandler(errorHandler); }
From source file:com.gwt.conn.client.Communicate.java
public static void authenticate(final String restID, final String license, final HTML commError, final DialogBox startupBox, final Button submitButton, final TextBox submitLicense, final TextBox submitRestID) { // attempt to sync with server storage.setItem("authenticated?", "null"); String result = sync("menu", restID, true); // true because authenticating if (!result.equals("")) { commError.setText("<br>No internet connection detected."); return;//from w w w .ja v a 2 s . c o m } // hide authentication submission form and replace with an "Authenticating..." message submitButton.setEnabled(false); submitLicense.setEnabled(false); submitRestID.setEnabled(false); startupBox.hide(); final DialogBox authBox = new DialogBox(); authBox.setAnimationEnabled(true); final VerticalPanel authPanel = new VerticalPanel(); authPanel.addStyleName("marginPanel"); // interacts with Connfrontend.css authPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); authPanel.add(new HTML("Authenticating...")); authBox.setWidget(authPanel); authBox.center(); // repeat a timer until the value of "authenticated?" changes final Timer timer = new Timer() { public void run() { // authentication unsuccessful if (storage.getItem("authenticated?").equals("no")) { // report error and show authentication form again authBox.hide(); commError.setText("<br>Something went wrong. Please try again."); submitButton.setEnabled(true); submitLicense.setEnabled(true); submitRestID.setEnabled(true); startupBox.center(); this.cancel(); } // authentication successful else if (storage.getItem("authenticated?").equals("yes")) { // save license and restaurant id and setup storage authBox.hide(); storage.setItem("license", license); // secret key for security storage.setItem("restID", restID); // used for almost every call to the backend storage.setItem("numMenus", Integer.toString(0)); StorageContainer.initStorage(); // go to dashboard (true meaning there is internet since we were able to authenticate) // "firstTime" causes a popup box to appear explaining how to use Connoisseur this.cancel(); Dashboard.loadMenu(deserialize(storage.getItem("menu")), "firstTime", true); } } }; // repeat once every half second timer.scheduleRepeating(500); // 500 milliseconds }
From source file:com.gwt.conn.client.Dashboard.java
/** Called when no internet connection is detected in order to inform the user. */ public static void showNoInternetError() { // put everything in a popup dialog box final DialogBox errorBox = new DialogBox(); errorBox.setAnimationEnabled(true);//w w w . j a v a 2 s . co m 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 { public void onClick(ClickEvent event) { // button clicked cont(); } public void onKeyUp(KeyUpEvent event) { // ENTER key if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) cont(); } private void cont() { errorButton.setEnabled(false); errorBox.hide(); } } final ErrorHandler errorHandler = new ErrorHandler(); errorButton.addClickHandler(errorHandler); errorButton.addKeyUpHandler(errorHandler); }
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 v a 2 s .co 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.gwt.conn.client.Dashboard.java
/** Called when the dashboard needs to be loaded. */ private void finishLoad(final DialogBox dashboardBox, final HTML statusLabel) { final VerticalPanel dashboardVPanel = new VerticalPanel(); dashboardVPanel.addStyleName("marginPanel"); // interacts with // Connfrontend.css dashboardVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); // addStyleName makes buttons look pretty (interacts with // Connfrontend.css) final Button newButton = new Button("New"); final Button editButton = new Button("Edit"); final Button scheduleButton = new Button("Schedule"); newButton.addStyleName("myButton"); editButton.addStyleName("myButton"); scheduleButton.addStyleName("myButton"); // setup vertical panel dashboardVPanel.add(statusLabel);// w w w. j a v a 2 s . com dashboardVPanel.add(newButton); dashboardVPanel.add(editButton); dashboardVPanel.add(scheduleButton); dashboardBox.setWidget(dashboardVPanel); dashboardBox.center(); // handler for newButton class NewHandler implements ClickHandler { public void onClick(ClickEvent event) { dashboardBox.hide(); newMenu(dashboardBox); // void method below } } // handler for editButton class EditHandler implements ClickHandler { public void onClick(ClickEvent event) { dashboardBox.hide(); getMenus(dashboardBox); // void method below } } // handler for scheduleButton class ScheduleHandler implements ClickHandler { public void onClick(ClickEvent event) { dashboardBox.hide(); // scheduler.loadScheduler(dashboardBox); // implemented in // Scheduler.java } } // attach the handlers to their respective buttons final NewHandler newHandler = new NewHandler(); final EditHandler editHandler = new EditHandler(); final ScheduleHandler scheduleHandler = new ScheduleHandler(); newButton.addClickHandler(newHandler); editButton.addClickHandler(editHandler); scheduleButton.addClickHandler(scheduleHandler); }
From source file:com.gwt.conn.client.Dashboard.java
/** Called when the user wants to create a new menu. */ private void newMenu(final DialogBox dashboardBox) { // declarations final DialogBox submitBox = new DialogBox(); submitBox.setAnimationEnabled(true); final VerticalPanel submitVPanel = new VerticalPanel(); submitVPanel.addStyleName("marginPanel"); submitVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); final Label errorLabel = new Label(); errorLabel.addStyleName("errorLabel"); final Button sendButton = new Button("Submit"); sendButton.addStyleName("myButton"); final Button cancelButton = new Button("Cancel"); sendButton.addStyleName("myButton"); final TextBox submitField = new TextBox(); // user can input text using // this/*from ww w . j ava 2 s. c om*/ submitField.setText("menu name..."); // default text to be seen on load final HorizontalPanel submitHPanel = new HorizontalPanel(); // organize UI submitVPanel.add(new HTML("Please enter a name for your new menu:")); submitHPanel.add(submitField); submitHPanel.add(sendButton); submitHPanel.add(cancelButton); submitVPanel.add(submitHPanel); submitVPanel.add(errorLabel); submitBox.setWidget(submitVPanel); submitBox.center(); submitField.setFocus(true); submitField.selectAll(); // handler for the sendButton and submitField class SubmitHandler implements ClickHandler, KeyUpHandler { /** Fired when the user clicks submit. */ public void onClick(ClickEvent event) { submit(); } /** Fired when the user presses Enter in submitField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) submit(); } /** * Checks the submitted menu name for validity. If valid, loads a * new menu object and starts the visual editor. */ private void submit() { // validate menu name String menuName = submitField.getText(); String test = FieldVerifier.isValidMenuName(menuName); if (!test.equals("")) { errorLabel.setText(test); submitField.selectAll(); return; } String json = "";// createDefaultJSON(); // get default JSON // object StorageContainer.addMenu(menuName, json); // to storage sendButton.setEnabled(false); submitBox.hide(); // visualEditor.loadVisualEditor(dashboardBox, json); // start // editing } } // handler for the cancel button class CancelHandler implements ClickHandler { /** Fired when the user clicks cancel. */ public void onClick(ClickEvent event) { submitBox.hide(); dashboardBox.center(); } } // attach the handlers final SubmitHandler submitHandler = new SubmitHandler(); final CancelHandler cancelHandler = new CancelHandler(); sendButton.addClickHandler(submitHandler); submitField.addKeyUpHandler(submitHandler); cancelButton.addClickHandler(cancelHandler); }
From source file:com.gwt.conn.client.Dashboard.java
/** Called when the user wants to edit an existing menu. */ private void getMenus(final DialogBox dashboardBox) { // declarations final DialogBox editBox = new DialogBox(); editBox.setAnimationEnabled(true);// w w w. j a va 2 s . c o m final VerticalPanel editVPanel = new VerticalPanel(); editVPanel.addStyleName("marginPanel"); editVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER); final Button cancelButton = new Button("Cancel"); cancelButton.addStyleName("myButton"); // from StorageContainer.java int numMenus = StorageContainer.getNumMenus(); final String[] menus = StorageContainer.getMenus(); // organize UI for (int i = 0; i < numMenus; ++i) { final String menuName = menus[i]; final Button button = new Button(menuName); button.addStyleName("myButton"); editVPanel.add(button); // handler for the buttons class ButtonHandler implements ClickHandler { /** Fired when the user clicks cancel. */ public void onClick(ClickEvent event) { editBox.hide(); // String json = StorageContainer.getMenu(menuName); // visualEditor.loadVisualEditor(dashboardBox, json); // // start editing } } // attach handler final ButtonHandler buttonHandler = new ButtonHandler(); button.addClickHandler(buttonHandler); } editVPanel.add(cancelButton); editBox.setWidget(editVPanel); editBox.center(); // handler for the cancel button class CancelHandler implements ClickHandler { /** Fired when the user clicks cancel. */ public void onClick(ClickEvent event) { editBox.hide(); dashboardBox.center(); } } // attach cancel handler final CancelHandler cancelHandler = new CancelHandler(); cancelButton.addClickHandler(cancelHandler); }
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 w w .ja v a2 s . com*/ 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;/*from w w w . 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);//from w ww . ja va2 s .c o m 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(); }