Esempio n. 1
0
  private void showLogonDialog() {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Login");
    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(true);

    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setSpacing(4);
    dialogBox.setWidget(verticalPanel);

    final TextBox username = new TextBox();
    verticalPanel.add(new HTML("Username:"******"Logon",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                dialogBox.hide();
                login(username.getValue());
              }
            });
    verticalPanel.add(closeButton);

    dialogBox.center();
    dialogBox.show();
  }
Esempio n. 2
0
  private void createDialogBox() {
    dialogBox = new DialogBox();
    dialogBox.setText("RESTful Call");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    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(HasHorizontalAlignment.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    closeButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            dialogBox.hide();
          }
        });
  }
  /** This is the entry point method. */
  public void onModuleLoad() {
    sendButton = new Button("Send");
    nameField = new TextBox();
    nameField.setText("GWT User");
    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
    dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    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
    final ClickHandler buttonClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
          }
        };
    closeButton.addClickHandler(buttonClickHandler);

    // Add a handler to send the name to the server
    ChangeEventHandler handler = new ChangeEventHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
  }
Esempio n. 4
0
 @Override
 public synchronized void inc(String reason) {
   if (waitCount.size() == 0) {
     StringBuffer reasons = new StringBuffer("<ul>Please Wait...");
     waitCount.add(reason);
     for (String wait : waitCount) {
       reasons.append("<li>" + wait + "</li>");
     }
     reasons.append("</ul>");
     wait.setHTML(reasons.toString());
     wait.setAnimationEnabled(true);
     wait.setModal(true);
     wait.center();
     wait.show();
   }
 }
  /** This is the entry point method. */
  public void onModuleLoad() {
    // Create the popup dialog box
    dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    dialogBox.setModal(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    errorLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(errorLabel);
    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();
          }
        });

    authService.isLoggedIn(
        new AsyncCallback<Boolean>() {
          public void onFailure(Throwable arg0) {
            showError("Error", Message.SERVER_ERROR);
          }

          public void onSuccess(Boolean res) {
            if (res) {
              displayMainUI();
            } else {
              displayLoginForm();
            }
          }
        });
  }
    @Override
    public void execute() {
      final DialogBox db = new DialogBox(false, true);
      db.setText("About MIT App Inventor");
      db.setStyleName("ode-DialogBox");
      db.setHeight("200px");
      db.setWidth("400px");
      db.setGlassEnabled(true);
      db.setAnimationEnabled(true);
      db.center();

      VerticalPanel DialogBoxContents = new VerticalPanel();
      HTML message =
          new HTML(
              MESSAGES.gitBuildId(GitBuildId.getDate(), GitBuildId.getVersion())
                  + "<BR/>Use Companion: "
                  + BlocklyPanel.getCompVersion()
                  + "<BR/><BR/>Please see "
                  + RELEASE_NOTES_LINK_AND_TEXT
                  + "<BR/><BR/>"
                  + termsOfServiceText);

      SimplePanel holder = new SimplePanel();
      // holder.setStyleName("DialogBox-footer");
      Button ok = new Button("Close");
      ok.addClickListener(
          new ClickListener() {
            public void onClick(Widget sender) {
              db.hide();
            }
          });
      holder.add(ok);
      DialogBoxContents.add(message);
      DialogBoxContents.add(holder);
      db.setWidget(DialogBoxContents);
      db.show();
    }
Esempio n. 7
0
 @Override
 public final void setAnimationEnabled(boolean enable) {
   super.setAnimationEnabled(false);
 }
Esempio n. 8
0
  /** This is the entry point method. */
  public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("Deepanjali");
    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);
  }
 /** @see com.google.gwt.user.client.ui.HasAnimation#setAnimationEnabled(boolean) */
 public void setAnimationEnabled(boolean animationEnabled) {
   dialogBox.setAnimationEnabled(animationEnabled);
 }
  // Popup pour les messages
  public DialogBox createDialogBoxConfirmationFormulaire(
      String msg,
      final JSONObject formAsJSONObjectAjoutDupliquer,
      final JSONObject formAsJSONObjectAjoutEcraser) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Confirmation");
    dialogBox.setAnimationEnabled(true);

    Button ouiButton = new Button("Oui");
    ouiButton.getElement().setId("ouiButton");

    Button nonButton = new Button("Non");
    nonButton.getElement().setId("nonButton");

    VerticalPanel dialogVPanel = new VerticalPanel();
    HorizontalPanel dialogHPanel = new HorizontalPanel();
    dialogHPanel.setWidth("80px");
    dialogVPanel.setWidth("300px");
    dialogVPanel.add(new HTML("<b>" + msg + "</b>"));
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogHPanel.add(ouiButton);
    dialogHPanel.add(nonButton);
    dialogVPanel.add(dialogHPanel);
    dialogBox.setWidget(dialogVPanel);
    dialogBox.setPopupPosition(450, 450);

    /** * Action de clique sur le button de valisation ** */
    ouiButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            formAsJSONObjectBis = formAsJSONObjectAjoutEcraser;
            ajoutFormulaireDirect();

            // Supprimer le formulaire
            RequestBuilder builder =
                new RequestBuilder(
                    RequestBuilder.PUT, FORMULAIRE_URL + "supprimer/" + formulaire_id);
            builder.setHeader("Content-Type", "application/json");
            try {
              builder.sendRequest(
                  null,
                  new RequestCallback() {
                    public void onError(Request request, Throwable exception) {}

                    public void onResponseReceived(Request request, Response response) {}
                  });
            } catch (RequestException e) {
              System.out.println("RequestException");
            }

            dialogBox.hide();
          }
        });

    /** * Action de clique sur le button de valisation ** */
    nonButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            formAsJSONObjectBis = formAsJSONObjectAjoutDupliquer;
            ajoutFormulaireDirect();

            dialogBox.hide();
          }
        });

    return dialogBox;
  }
  public DialogBox createDialogBoxConfirmationAllocationFormulaire(
      String msg,
      final JSONObject formAsJSONObjectAjoutDupliquer,
      final JSONObject formAsJSONObjectAjoutEcraser) {
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Confirmation");
    dialogBox.setAnimationEnabled(true);

    Button ouiButton = new Button("Enregister sous une nouvelle version");
    ouiButton.getElement().setId("ouiButton");

    Button nonButton = new Button("Changer l'allocation de cette version");
    nonButton.getElement().setId("nonButton");

    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("350px");
    HTML h = new HTML("<b>" + msg + "</b>");
    dialogVPanel.add(h);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.setCellHeight(h, "44px");
    dialogVPanel.add(ouiButton);
    dialogVPanel.setCellHeight(ouiButton, "35px");
    nonButton.setWidth("225px");
    dialogVPanel.add(nonButton);
    dialogBox.setWidget(dialogVPanel);
    dialogBox.setPopupPosition(450, 550);

    nonButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            MouseListBox mlb = dualListBox.getRight();
            ArrayList<Widget> widgets = mlb.widgetList();
            String comptes = "";
            for (int i = 0; i < widgets.size(); i++) {
              if (i == 0) comptes = widgets.get(i).getTitle();
              else comptes = comptes + "-" + widgets.get(i).getTitle();
            }
            RequestBuilder builder =
                new RequestBuilder(
                    RequestBuilder.PUT,
                    FORMULAIRE_URL + "changeAllocation/formulaire/" + formulaire_id);
            builder.setHeader("Content-Type", "application/json");
            try {
              builder.sendRequest(
                  comptes,
                  new RequestCallback() {
                    public void onError(Request request, Throwable exception) {}

                    public void onResponseReceived(Request request, Response response) {
                      Window.alert("Formulaire: Enregistrement avec succès");
                      Window.Location.reload();
                    }
                  });
            } catch (RequestException e) {
              System.out.println("RequestException");
            }

            dialogBox.hide();
          }
        });

    ouiButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            formAsJSONObjectBis = formAsJSONObjectAjoutDupliquer;
            ajoutFormulaireDirect();

            dialogBox.hide();
          }
        });

    return dialogBox;
  }
Esempio n. 12
0
  /** This is the entry point method. */
  public void onModuleLoad() {
    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("Patent ID");
    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();
    final HTML paramsLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending Patent ID to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Patent profile:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.add(new HTML("<br><b>Patent parameters:</b>"));
    dialogVPanel.add(paramsLabel);
    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) {
        sendPatentIdToServer();
      }

      /** Fired when the user types in the nameField. */
      public void onKeyUp(KeyUpEvent event) {
        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
          sendPatentIdToServer();
        }
      }

      /** Send the name from the nameField to the server and wait for a response. */
      private void sendPatentIdToServer() {
        // 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);
        			}
        		});*/
        dialogBox.setText("Reading Database...");
        serverResponseLabel.addStyleName("loadingLabel");
        serverResponseLabel.setHTML("Loading...");
        dialogBox.center();

        patentService.getInfo(
            textToServer,
            new AsyncCallback<HashMap<String, String>>() {
              public void onFailure(Throwable caught) {
                // Show the RPC error message to the user
                dialogBox.setText("Remote Procedure Call - Failure - Patent");
                serverResponseLabel.addStyleName("serverResponseLabelError");
                serverResponseLabel.setHTML(SERVER_ERROR);
                dialogBox.center();
                closeButton.setFocus(true);
              }

              public void onSuccess(HashMap<String, String> resultMap) {
                dialogBox.setText("Remote Procedure Call");
                serverResponseLabel.removeStyleName("serverResponseLabelError");
                serverResponseLabel.removeStyleName("loadingLabel");
                String id = resultMap.get("id");
                String abs = resultMap.get("abstract");
                String year = resultMap.get("year");
                String displayHTML =
                    "ID: " + id + "<br>Issued Year: " + year + "<br>Abstract: " + abs;
                serverResponseLabel.setHTML(displayHTML);
                dialogBox.center();
                closeButton.setFocus(true);
              }
            });
        paramsLabel.addStyleName("loadingLabel");
        paramsLabel.setHTML("Loading...");
        patentService.getParams(
            textToServer,
            new AsyncCallback<HashMap<String, String>>() {
              public void onFailure(Throwable caught) {
                // Show the RPC error message to the user
                dialogBox.setText("Remote Procedure Call - Failure - Patent");
                paramsLabel.addStyleName("serverResponseLabelError");
                paramsLabel.setHTML(SERVER_ERROR);
                dialogBox.center();
                closeButton.setFocus(true);
              }

              public void onSuccess(HashMap<String, String> resultMap) {
                dialogBox.setText("Remote Procedure Call");
                paramsLabel.removeStyleName("serverResponseLabelError");
                paramsLabel.removeStyleName("loadingLabel");
                String inventors = resultMap.get("inventors");
                String nobwdcite = resultMap.get("num_of_bwd_citations");
                String originality_USPC = resultMap.get("originality_USPC");
                String num_of_assignee_transfer = resultMap.get("num_of_assignee_transfer");
                String displayHTML =
                    "Inventors: "
                        + inventors
                        + "<br># of backward citations: "
                        + nobwdcite
                        + "<br>originality_USPC: "
                        + originality_USPC
                        + "<br>num_of_assignee_transfer: "
                        + num_of_assignee_transfer;
                paramsLabel.setHTML(displayHTML);
                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);
  }
  /** This is the entry point method. */
  @Override
  public void onModuleLoad() {
    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("CIS 550 HW5 - Query Results");
    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 HTML schemaLabel = new HTML();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<br><b>Relation schema:</b>"));
    dialogVPanel.add(schemaLabel);
    dialogVPanel.add(new HTML("<br><b>Returned data:</b>"));
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogBox.setWidget(dialogVPanel);

    final ScrollPanel scroller = new ScrollPanel();
    scroller.setHeight("400px");
    dialogVPanel.add(scroller);

    dialogVPanel.add(closeButton);

    // Here we are creating a dialog box to return the query results
    queryService.getRelation(
        new AsyncCallback<Relation>() {

          @Override
          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.show();
            dialogBox.center();

            closeButton.setFocus(true);
          }

          @Override
          public void onSuccess(Relation result) {
            // Add the relational schema to the output
            schemaLabel.setText(result.getSchema().toString());

            // Add the relation outputs to the output in a scrollable table
            scroller.add(result.getTableWidget());
            dialogBox.show();
            dialogBox.center();
          }
        });

    closeButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            dialogBox.hide();
          }
        });
  }