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();
          }
        });
  }
 public void showError(String title, String message) {
   dialogBox.setText(title);
   errorLabel.setText(message);
   closeButton.setVisible(true);
   errorLabel.setStyleName("serverResponseLabelError");
   dialogBox.center();
 }
  private void showSetCellAlignmentDialog(final ListBox listBox, final IAlignment iAlignment) {
    final DialogBox origDialog = new DialogBox();
    DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.toString(Integer.MAX_VALUE));
    final VerticalPanel dialog = new VerticalPanel();
    origDialog.add(dialog);
    origDialog.setText("Cell Alignment Dialog");
    dialog.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    dialog.add(new Label("Please choose the Widget :"));
    final ListBox widgetIndexLb = new ListBox();
    for (Iterator<Widget> iterator = iterator(); iterator.hasNext(); ) {
      Widget next = iterator.next();
      widgetIndexLb.addItem(
          ((IVkWidget) next).getWidgetName() + " - at index - " + getWidgetIndex(next));
    }

    widgetIndexLb.setWidth("300px");
    dialog.add(widgetIndexLb);
    widgetIndexLb.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            iAlignment.doAlignment(
                widgetIndexLb.getSelectedIndex(), listBox.getValue(listBox.getSelectedIndex()));
          }
        });
    dialog.add(new Label("Please choose Alignment"));
    dialog.add(listBox);
    listBox.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            iAlignment.doAlignment(
                widgetIndexLb.getSelectedIndex(), listBox.getValue(listBox.getSelectedIndex()));
          }
        });
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    dialog.add(buttonsPanel);
    Button saveButton = new Button("OK");
    buttonsPanel.add(saveButton);
    saveButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            // iAlignment.doAlignment(widgetIndexLb.getSelectedIndex(),
            // listBox.getValue(listBox.getSelectedIndex()));
            origDialog.hide();
          }
        });
    Button cancelButton = new Button("Cancel");
    buttonsPanel.add(cancelButton);
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            origDialog.hide();
          }
        });
    origDialog.center();
  }
Esempio n. 5
0
 public Dialog(String title) {
   dialogBox.setText(title);
   VerticalPanel verticalPanel = new VerticalPanel();
   verticalPanel.add(contentPanel);
   verticalPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
   verticalPanel.add(buttonPanel);
   dialogBox.add(verticalPanel);
   dialogBox.addCloseHandler(closeHandler);
   buttonPanel.setSpacing(2);
 }
  /** 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);
  }
 public void showInfo(String title, String message) {
   dialogBox.setText(title);
   errorLabel.setText(message);
   errorLabel.setStyleName("infoText");
   closeButton.setVisible(false);
   dialogBox.center();
   new Timer() {
     public void run() {
       dialogBox.hide();
     }
   }.schedule(2000);
 }
  public void showHTMLCode(String codeSource) {
    final DialogBox codePopup = new DialogBox(true, true);
    codePopup.setGlassEnabled(true);
    codePopup.setText(constants.showCodeTitle());

    String[] lignesCode = codeSource.split("\n");

    VerticalPanel tab = new VerticalPanel();

    for (String ligneCode : lignesCode) {
      String maLigne = new String(ligneCode);

      String[] ligne = ligneCode.split("\t");
      for (String texte : ligne) {
        if (texte.equals("")) {
          maLigne = "&nbsp;&nbsp;&nbsp;&nbsp;" + maLigne;
        }
      }
      maLigne = maLigne.replace("<", "&lt;");
      maLigne = maLigne.replace("div", "<span style='color: blue;'>div</span>");
      maLigne = maLigne.replace("id=", "<span style='color: red;'>id</span>=");
      maLigne = maLigne.replace("class", "<span style='color: red;'>class</span>");

      int commentBegin = maLigne.indexOf("&lt;!--");

      if (commentBegin != -1) {
        int commentEnd = maLigne.indexOf("-->");
        String comment = maLigne.substring(commentBegin, commentEnd + 3);
        maLigne = maLigne.replace(comment, "<span style='color: #008000;'>" + comment + "</span>");
      }

      HTML htmlLine = new HTML(maLigne);
      htmlLine.setStyleName("builder-source");
      tab.add(htmlLine);
    }

    Button closeButton =
        new Button(
            constants.close(),
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                codePopup.hide();
              }
            });

    tab.add(closeButton);
    tab.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);

    codePopup.add(tab);
    codePopup.center();
    codePopup.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();
            }
          }
        });
  }
Esempio n. 10
0
    @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();
    }
 /**
  * Set the dialog box title
  *
  * @param title
  */
 public void setDialogTitle(String title) {
   dialogBox.setText(title);
 }
  // 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. 14
0
  private DialogBox createDialogBox(final BeanObject bean) {
    // Create a dialog box and set the caption text
    final DialogBox dialogBox = new DialogBox();
    dialogBox.ensureDebugId("cwDialogBox");
    dialogBox.setText("插入邮件队列");
    // Create a panel to layout the content
    ColumnPanel contentPanel = new ColumnPanel();
    final ListBox list = new ListBox();
    list.addItem("普通");
    list.addItem("高");
    contentPanel.createPanel(IEmailSendList.PRIORITY, "选择优先级", list);
    // add a button to commit
    com.google.gwt.user.client.ui.Button commitButton =
        new com.google.gwt.user.client.ui.Button(
            "确定",
            new ClickListener() {
              public void onClick(Widget sender) {
                // update the mail template
                final Map<String, Object> emails = bean.getProperties();
                emails.remove(IMailTemplate.LASTSEND);
                Date currentTime = new Date();
                final Timestamp nowTime = new Timestamp(currentTime.getTime());
                emails.put(IMailTemplate.LASTSEND, nowTime);
                BeanObject emailBean = new BeanObject(ModelNames.MAILTEMPLATE, emails);
                new UpdateService()
                    .updateBean(
                        (Long) emails.get(IMailTemplate.ID),
                        emailBean,
                        new UpdateService.Listener() {

                          @Override
                          public void onSuccess(Boolean success) {}
                        });

                new EmailSettings()
                    .getSettingsInfo(
                        new EmailSettings.Listener() {
                          public void onSuccess(HashMap<String, String> result) {
                            // create new mail send list
                            int index = list.getSelectedIndex();
                            Map<String, Object> sendlist = new HashMap<String, Object>();
                            sendlist.put(IEmailSendList.EMAIL, result.get("account"));
                            sendlist.put(IEmailSendList.TEMPLATEID, emails.get(IMailTemplate.ID));
                            sendlist.put(
                                IEmailSendList.EMAILCONTENT, emails.get(IMailTemplate.CONTENT));
                            sendlist.put(IEmailSendList.ERROR, 0);
                            sendlist.put(IEmailSendList.LASTSEND, nowTime);
                            sendlist.put(IEmailSendList.PRIORITY, index);
                            // new bean object of send list
                            BeanObject listBean =
                                new BeanObject(ModelNames.EMAILSENDLIST, sendlist);
                            new CreateService()
                                .createBean(
                                    listBean,
                                    new CreateService.Listener() {
                                      public void onSuccess(String id) {}
                                    });
                            dialogBox.hide();
                            toolBar.refresh();

                            // 采用BFS算法的原理,处理邮件队列中的邮件。
                            new ListService()
                                .listBeans(
                                    ModelNames.EMAILLIST,
                                    new ListService.Listener() {

                                      @Override
                                      public void onSuccess(List<BeanObject> beans) {
                                        // 取出所有订阅者的订阅地址,构造发送列表
                                        StringBuffer sendTo = new StringBuffer();
                                        for (BeanObject bean : beans) {
                                          Boolean isConfirm = bean.get(IEmailList.CONFIRM);
                                          if (isConfirm.booleanValue()) {
                                            sendTo.append(";" + bean.getString(IEmailList.EMAIL));
                                          }
                                        }
                                        HashMap<String, String> subscribe =
                                            new HashMap<String, String>();
                                        subscribe.put("sendTo", sendTo.substring(1));
                                        subscribe.put(
                                            "subject", (String) emails.get(IMailTemplate.SUBJECT));
                                        subscribe.put(
                                            "content", (String) emails.get(IMailTemplate.CONTENT));
                                        new EmailSettings()
                                            .sendEmailAndGetState(
                                                subscribe,
                                                new EmailSettings.Listener() {
                                                  public void onSuccess(Boolean result) {}

                                                  public void onFailure(Throwable caught) {}
                                                });
                                      }
                                    });
                          }
                        });
              }
            });
    // Add a close button at the bottom of the dialog
    com.google.gwt.user.client.ui.Button closeButton =
        new com.google.gwt.user.client.ui.Button(
            "Close",
            new ClickListener() {
              public void onClick(Widget sender) {
                dialogBox.hide();
              }
            });

    contentPanel.add(closeButton);
    contentPanel.add(commitButton);
    dialogBox.setWidget(contentPanel);
    return dialogBox;
  }
Esempio n. 15
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);
  }
Esempio n. 16
0
  public void Configure_start_time() {

    final DialogBox dialogBox = new DialogBox();
    dialogBox.addStyleName("g-DialogBox");
    DOM.setStyleAttribute(dialogBox.getElement(), "border", "0px");
    dialogBox.setText("Set Time");
    dialogBox.setSize("294", "207");

    final AbsolutePanel absolutePanel = new AbsolutePanel();
    dialogBox.setWidget(absolutePanel);
    absolutePanel.setSize("294px", "187px");

    // 自定义datebox的输出格式,在这里采用了简洁的输出格式"M/d/yy H:mm"
    final DateBox dateBox = new DateBox();
    DateTimeFormat dateTimeFormat =
        DateTimeFormat.getFormat(
            "M/d/yy H:mm"); // DateTimeFormat只能通过函数getFormat来生成满足特定pattern的对象,因为其构造函数为protected
    DateBox.DefaultFormat defaultFormat = new DateBox.DefaultFormat(dateTimeFormat);
    dateBox.setFormat(defaultFormat);
    absolutePanel.add(dateBox, 109, 35);
    dateBox.setWidth("150px");

    final Label dateLabel = new Label("Date:");
    absolutePanel.add(dateLabel, 36, 35);
    dateLabel.setSize("38px", "18px");

    final Label dateLabel_1 = new Label("Time:");
    absolutePanel.add(dateLabel_1, 36, 80);
    dateLabel_1.setSize("38px", "18px");

    final ListBox listBox = new ListBox();
    absolutePanel.add(listBox, 109, 77);
    listBox.setSize("150px", "21px");
    String[] minutes = {"00", "15", "30", "45"};
    String[] hours = {
      "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16",
      "17", "18", "19", "20", "21", "22", "23"
    };
    String[] times = new String[96];
    // System.out.println(minutes.length+"  "+hours.length+"  "+times.length);
    for (int i = 0; i < 24; i++) {
      for (int j = 0; j < 4; j++) {
        times[4 * i + j] = hours[i] + ":" + minutes[j];
      }
    }
    for (int i = 0; i < 96; i++) {
      listBox.addItem(times[i]);
    }

    final Button okButton = new Button();
    DOM.setStyleAttribute(okButton.getElement(), "fontSize", "10pt");
    okButton.removeStyleName("gwt-Button");
    okButton.addClickHandler(
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            // TODO Auto-generated method stub
            TextBox inner_textBox = dateBox.getTextBox();
            if (inner_textBox.getText() == null || inner_textBox.getText().equals("")) {
              dateBox.addStyleName("dateBoxFormatError"); // 如果用户没编辑日期,则datebox框变红,等待用户更正
            } else {
              String dateString = inner_textBox.getText();
              int index = listBox.getSelectedIndex();
              String timeString = listBox.getValue(index);
              if (timeString != null) {
                String[] date_and_time = dateString.split(" ");
                date_and_time[1] = timeString;
                dateString = date_and_time[0] + " " + date_and_time[1];
                start_time = dateString;
              }
              dialogBox.hide();
            }
            System.out.println(start_time);
          }
        });

    absolutePanel.add(okButton, 93, 129);
    okButton.setSize("105px", "21px");
    okButton.setText("OK");

    dialogBox.center();
  }
Esempio n. 17
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);
  }
Esempio n. 18
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }
  private void showAddItemAttributeDialog(final VkMenuBarHorizontal menuBar) {
    final DialogBox origDialog = new DialogBox();
    DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.toString(Integer.MAX_VALUE));
    final VerticalPanel dialog = new VerticalPanel();
    origDialog.add(dialog);
    origDialog.setText("Provide html for item name and JS to execute on its click");
    dialog.setWidth("100%");
    dialog.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    DOM.setStyleAttribute(origDialog.getElement(), "zIndex", Integer.MAX_VALUE + "");

    HorizontalPanel nameHp = new HorizontalPanel();
    nameHp.setWidth("100%");
    dialog.add(nameHp);
    nameHp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    nameHp.add(new Label("Name HTML:"));
    nameHp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    nameHp.setCellWidth(nameHp.getWidget(0), "35%");
    final TextArea nameTextArea = new TextArea();
    nameHp.add(nameTextArea);
    nameTextArea.setSize("300px", "100px");
    Timer t =
        new Timer() {
          @Override
          public void run() {
            VkDesignerUtil.centerDialog(dialog);
            nameTextArea.setFocus(true);
          }
        };
    t.schedule(100);
    HorizontalPanel jsHp = new HorizontalPanel();
    jsHp.setWidth("100%");
    dialog.add(jsHp);
    jsHp.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
    jsHp.add(new Label("Command Js:"));
    jsHp.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    jsHp.setCellWidth(jsHp.getWidget(0), "35%");
    final VkEventTextArea jsTextArea = new VkEventTextArea();
    jsTextArea.setSize("300px", "100px");
    jsHp.add(jsTextArea);
    HorizontalPanel buttonsPanel = new HorizontalPanel();
    dialog.add(buttonsPanel);
    Button saveButton = new Button("Save");
    buttonsPanel.add(saveButton);
    saveButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            menuBar.getCommandJs().put(menuBar.getItemCount(), jsTextArea.getText());
            addMenuItem(menuBar, nameTextArea.getText(), jsTextArea.getText());
            origDialog.hide();
          }
        });
    Button cancelButton = new Button("Cancel");
    buttonsPanel.add(cancelButton);
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            origDialog.hide();
          }
        });
    origDialog.center();
    origDialog.setPopupPosition(origDialog.getPopupLeft() + 1, origDialog.getPopupTop());
  }
  /** 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();
          }
        });
  }