private Panel createButtons() {

    final HorizontalPanel panel = new HorizontalPanel();

    Button save = new Button("Save");
    save.setStyleName("button");
    save.addClickListener(
        new ClickListener() {

          public void onClick(Widget widget) {
            if (validateFormInput()) {
              createNote(inputNoteTitle.getText(), inputNoteText.getText());
              resetForm();
            }
          }
        });

    Button clear = new Button("Clear");
    save.setStyleName("button");
    clear.addClickListener(
        new ClickListener() {

          public void onClick(Widget widget) {
            resetForm();
          }
        });

    panel.add(save);
    panel.add(clear);

    return panel;
  }
Example #2
0
  /**
   * Create an options panel that allows users to select a widget and reposition it.
   *
   * @return the new options panel
   */
  private Widget createOptionsBar() {
    // Create a panel to move components around
    HorizontalPanel optionsBar = new HorizontalPanel();
    optionsBar.setSpacing(5);
    optionsBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    // Add a title
    optionsBar.add(new HTML("<b>Animate Logos</b>"));

    // Add start button
    startButton = new Button("Start");
    startButton.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            animation.run(2000);
          }
        });
    optionsBar.add(startButton);

    // Add cancel button
    cancelButton = new Button("Cancel");
    cancelButton.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            animation.cancel();
          }
        });
    optionsBar.add(cancelButton);

    // Return the options bar
    return optionsBar;
  }
  /**
   * Creates an empty dialog box specifying its "auto-hide" property. It should not be shown until
   * its child widget has been added using {@link #add(Widget)}.
   *
   * @param autoHide <code>true</code> if the dialog should be automatically hidden when the user
   *     clicks outside of it
   * @param modal <code>true</code> if keyboard and mouse events for widgets not contained by the
   *     dialog should be ignored
   */
  public MyDialogBox(boolean autoHide, boolean modal) {
    super(autoHide, modal);
    dock = new HorizontalPanel();
    dock.add(caption);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(0);
    dock.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

    listener = new DialogListener(this);
    minimiseBtn.addClickListener(listener);
    maximiseBtn.addClickListener(listener);
    closeBtn.addClickListener(listener);

    hp.add(minimiseBtn);
    hp.add(maximiseBtn);
    hp.add(closeBtn);
    dock.add(hp);
    panel.add(dock);

    panel.setHeight("100%");
    panel.setSpacing(0);

    sp = new ScrollPanel();
    panel.add(sp);
    super.setWidget(panel);

    setStyleName("gwt-DialogBox");
    dock.setStyleName("Caption");
    caption.addMouseListener(this);
  }
Example #4
0
  public Geocoder2Demo() {
    Panel panel = new FlowPanel();
    final FormPanel form = new FormPanel();
    form.setAction("#");
    Panel formElements = new FlowPanel();
    Label label = new Label("Search for an address:");
    formElements.add(label);
    final TextBox addressBox = new TextBox();
    addressBox.setVisibleLength(40);
    formElements.add(addressBox);
    Button submit = new Button("Search");
    submit.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            form.submit();
          }
        });
    formElements.add(submit);
    form.add(formElements);
    form.addFormHandler(
        new FormHandler() {
          public void onSubmit(FormSubmitEvent event) {
            showAddress(addressBox.getText());
            event.setCancelled(true);
          }

          public void onSubmitComplete(FormSubmitCompleteEvent event) {}
        });
    panel.add(form);

    map = new MapWidget(LatLng.newInstance(34, 0), 1);
    map.setSize("100%", "480px");
    panel.add(map);

    Grid grid = new Grid((sampleAddresses.length / NUM_ADDRESS_COLUMNS) + 1, NUM_ADDRESS_COLUMNS);

    for (int i = 0; i < sampleAddresses.length; i++) {
      final String address = sampleAddresses[i];
      Button link = new Button(address);
      // Hyperlink link = new Hyperlink(address, true,
      // "Extracting Structured Address Information");
      link.addClickListener(
          new ClickListener() {
            public void onClick(Widget sender) {
              addressBox.setText(address);
              form.submit();
            }
          });
      grid.setWidget(i / NUM_ADDRESS_COLUMNS, i % NUM_ADDRESS_COLUMNS, link);
    }
    panel.add(grid);

    initWidget(panel);
    geocoder = new Geocoder();
  }
  @Test
  public void click_ClickkListener_NestedWidget() {
    // Given
    clicked = false;
    FlexTable t = new FlexTable();

    Button b = new Button("Wide Button");
    b.addClickListener(
        new ClickListener() {

          public void onClick(Widget sender) {
            clicked = !clicked;
          }
        });
    // add the button
    t.setWidget(0, 0, b);

    // Preconditions
    assertThat(clicked).isEqualTo(false);

    // When
    Browser.click(t.getWidget(0, 0));

    // Then
    assertThat(clicked).isEqualTo(true);
  }
  /** This is used when creating a new rule. */
  public NewAssetWizard(EditItemEvent afterCreate, boolean showCats, String format, String title) {
    super("images/new_wiz.gif", title);
    this.showCats = showCats;
    this.format = format;

    this.afterCreate = afterCreate;

    addAttribute("Name:", name);

    if (showCats) {
      addAttribute("Initial category:", getCatChooser());
    }

    if (format == null) {
      addAttribute("Type (format) of rule:", this.formatChooser);
    }

    addAttribute("Package:", packageSelector);

    description.setVisibleLines(4);
    description.setWidth("100%");
    addAttribute("Initial description:", description);

    Button ok = new Button("OK");
    ok.addClickListener(
        new ClickListener() {
          public void onClick(Widget arg0) {
            ok();
          }
        });

    addAttribute("", ok);

    setStyleName("ks-popups-Popup");
  }
  public void onModuleLoad() {
    Log.setLevelToTrace("com.mycompany.proto.console.hello.client");
    firstNameTextBox.setTitle("First Name");
    firstNameTextBox.setName("firstName");
    lastNameTextBox.setTitle("Last Name");
    lastNameTextBox.setName("lastName");
    lastNameTextBox.addKeyboardListener(createCreateCustomerEnterListener());

    createCustomerButton.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            createCustomer();
            showCustomers();
          }
        });

    refreshButton.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            showCustomers();
          }
        });

    VerticalPanel panel = new VerticalPanel();
    panel.add(createCustomerButton);
    panel.add(statusLabel);
    panel.add(refreshButton);
    panel.add(firstNameTextBox);
    panel.add(lastNameTextBox);
    panel.add(tableWrapper);

    RootPanel.get().add(panel);

    // Window.alert("Starting Logging test...");
    Log.trace(this, "TRACE MESSAGE!");
    Log.debug(this, "DEBUG MESSAGE!");
    Log.info(this, "INFO MESSAGE!");
    Log.warn(this, "WARN MESSAGE!");
    Log.error(this, "ERROR MESSAGE!");
    Log.fatal(this, "FATAL MESSAGE!");
    Log.fatal(this, "FATAL WITH EXCEPTION", new RuntimeException("Example Runtime Exception!"));
    // Window.alert("Logging test concluded.");

    showCustomers();
  }
Example #8
0
  public DBInfoWidget(final InstallWizardServiceAsync wizardService, InstallWizardInfo info) {
    super(wizardService, info);
    FlowPanel layout = new FlowPanel();
    initWidget(layout);

    driverNameTextBox = new TextBox();
    driverNameTextBox.addStyleName("db-text");
    urlTextBox = new TextBox();
    urlTextBox.addStyleName("db-text");
    usernameTextBox = new TextBox();
    usernameTextBox.addStyleName("db-text");
    passwordTextBox1 = new PasswordTextBox();
    passwordTextBox1.addStyleName("db-text");
    passwordTextBox2 = new PasswordTextBox();
    passwordTextBox2.addStyleName("db-text");

    driverNameTextBox.setText("com.mysql.jdbc.Driver");
    urlTextBox.setText("jdbc:mysql://DBHOST/ALERTSCAPE_DATABASE");
    usernameTextBox.setText("alertscape");

    checkButton = new Button("Check");
    checkButton.addClickListener(new SchemaCheckClickListener());
    checkButton.setEnabled(false);

    errorLabel = new Label();

    ValidChangeListener listener = new ValidChangeListener();

    driverNameTextBox.addChangeListener(listener);
    urlTextBox.addChangeListener(listener);
    usernameTextBox.addChangeListener(listener);
    passwordTextBox1.addChangeListener(listener);
    passwordTextBox2.addChangeListener(listener);

    g = new Grid(5, 2);
    int row = 0;
    setRow(row++, "Driver class:", driverNameTextBox);
    setRow(row++, "JDBC URL:", urlTextBox);
    setRow(row++, "Username:"******"Password:"******"Password (again):", passwordTextBox2);

    layout.add(g);

    layout.add(checkButton);
    layout.add(errorLabel);
  }
  public VerticalPanel buildUserDetailsDockPanel() {

    VerticalPanel assignedRolesPanel = buildAssignedRolesPanel();

    VerticalPanel mainUserDetailsPanel = new VerticalPanel();

    VerticalPanel userPanelFieldsetContent = new VerticalPanel();
    userPanelFieldsetContent.setSpacing(4);
    userPanelFieldsetContent.add(userDetailsPanel);
    userPanelFieldsetContent.add(updateUserBtn);
    userPanelFieldsetContent.setCellWidth(userDetailsPanel, "100%"); // $NON-NLS-1$

    userPanelFieldsetContent.setCellHorizontalAlignment(updateUserBtn, VerticalPanel.ALIGN_RIGHT);

    VerticalPanel fieldsetPanel = new VerticalPanel();
    fieldsetPanel.add(new Label(Messages.getString("userDetails"))); // $NON-NLS-1$
    fieldsetPanel.add(userPanelFieldsetContent);
    userPanelFieldsetContent.setWidth("100%"); // $NON-NLS-1$

    fieldsetPanel.setWidth("100%"); // $NON-NLS-1$

    mainUserDetailsPanel.add(fieldsetPanel);
    mainUserDetailsPanel.setCellWidth(fieldsetPanel, "100%"); // $NON-NLS-1$
    SimplePanel spacerPanel = new SimplePanel();
    spacerPanel.add(new Label(" ")); // $NON-NLS-1$
    mainUserDetailsPanel.add(spacerPanel);
    mainUserDetailsPanel.setCellHeight(spacerPanel, "10px"); // $NON-NLS-1$

    mainUserDetailsPanel.add(assignedRolesPanel);

    mainUserDetailsPanel.setCellHorizontalAlignment(
        updateUserBtn, HasHorizontalAlignment.ALIGN_RIGHT);

    mainUserDetailsPanel.setCellHeight(assignedRolesPanel, "100%"); // $NON-NLS-1$
    mainUserDetailsPanel.setCellWidth(assignedRolesPanel, "100%"); // $NON-NLS-1$

    userDetailsPanel.setWidth("100%"); // $NON-NLS-1$
    assignedRolesPanel.setWidth("100%"); // $NON-NLS-1$
    assignedRolesPanel.setHeight("100%"); // $NON-NLS-1$

    updateUserBtn.addClickListener(this);
    return mainUserDetailsPanel;
  }
Example #10
0
  private void addStock() {

    final String symbol = view.newSymbolTextEntry().value().get().toUpperCase().trim();
    view.newSymbolTextEntry().focus().put(true);

    // symbol must be between 1 and 10 chars that are numbers, letters, or dots
    if (!symbol.matches("^[0-9a-zA-Z\\.]{1,10}$")) {
      Window.alert("'" + symbol + "' is not a valid symbol.");
      view.newSymbolTextEntry().selectAll();
      return;
    }

    view.newSymbolTextEntry().value().put("");

    final StockSymbol stockSymbol = new StockSymbol(symbol);

    // don't add the stock if it's already in the watch list
    if (stocks.get().exists(stockSymbol.equalsFunction())) {
      return;
    }

    // add the stock to the list
    stocks.snoc(stockSymbol);

    int row = stocksFlexTable.getRowCount();
    stocksFlexTable.setText(row, 0, symbol);

    Button removeStock = new Button("x");
    removeStock.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            int removedIndex = stocks.elementIndex(StockSymbol.EQUAL, stockSymbol).some();
            stocks.delete(stockSymbol, StockSymbol.EQUAL);
            stocksFlexTable.removeRow(removedIndex + 1);
          }
        });
    stocksFlexTable.setWidget(row, 3, removeStock);

    // get stock price
    refreshWatchList();
  }
Example #11
0
  public void showError(String message) {
    final DialogBox db = new DialogBox();
    db.setSize("200", "150");
    db.setPopupPosition(100, 100);

    FlowPanel panel = new FlowPanel();
    Label text = new Label(message);
    panel.add(text);

    Button close = new Button("close");
    close.addClickListener(
        new ClickListener() {

          @Override
          public void onClick(Widget sender) {
            db.hide();
          }
        });
    panel.add(close);

    db.add(panel);
    db.show();
  }
    @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();
    }
 /**
  * Sets a listener on the close button
  *
  * @param listen ClickListener
  */
 public void setCloseListener(ClickListener listen) {
   closeBtn.removeClickListener(listener);
   listener = listen;
   closeBtn.addClickListener(listen);
 }
Example #14
0
  public AddDesigner() {

    mainPanel = new HorizontalPanel();
    addDesignerPanel = new VerticalPanel();
    addDesignerPanel.setSpacing(10);
    addDesignerPanel.setWidth("700px");

    formPanel = new FormPanel();
    System.err.println(GWT.getModuleBaseURL());
    formPanel.setAction(GWT.getModuleBaseURL() + "addStuffServlet");
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_GET);
    formPanel.setWidget(mainPanel);
    formPanel.addFormHandler(
        new FormHandler() {

          public void onSubmit(final FormSubmitEvent event) {
            if (designerBox.getText().length() == 0) {
              Window.alert("Campo Desenhista está vazio");
              event.setCancelled(true);
              return;
            }
          }

          public void onSubmitComplete(FormSubmitCompleteEvent arg0) {
            Window.alert("Novo Desenhista cadastrado com sucesso");
            designerBox.setText("");
            titleTree.clear();

            if (titleService == null) {
              titleService = GWT.create(TitleService.class);
            }

            AsyncCallback<ArrayList<Designer>> callback =
                new AsyncCallback<ArrayList<Designer>>() {

                  public void onFailure(Throwable caught) {

                    Window.alert("DEU PAU!!!");
                  }

                  public void onSuccess(ArrayList<Designer> result) {

                    for (int i = 0; i < result.size(); i++) {
                      Designer title = result.get(i);
                      titleTree.addItem(title.getDesigner());
                    }
                  }
                };

            titleService.getDesignerList(callback);
          }
        });

    /* Escritor */
    designerPanel = new HorizontalPanel();
    designerPanel.setSpacing(5);
    designerLabel = new Label("Desenhista: ");
    designerPanel.add(designerLabel);
    designerPanel.setCellHorizontalAlignment(designerLabel, HorizontalPanel.ALIGN_LEFT);
    designerPanel.setCellVerticalAlignment(designerLabel, VerticalPanel.ALIGN_MIDDLE);
    designerBox = new TextBox();
    designerBox.setName("designer");
    designerPanel.add(designerBox);
    designerPanel.setCellHorizontalAlignment(designerBox, HorizontalPanel.ALIGN_LEFT);
    designerPanel.setCellVerticalAlignment(designerBox, VerticalPanel.ALIGN_MIDDLE);

    /* OK */
    okPanel = new HorizontalPanel();
    okPanel.setSpacing(10);
    okButton = new Button();
    okButton.setText("Cadastra");
    okButton.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            formPanel.submit();
          }
        });

    okPanel.add(okButton);
    okPanel.setCellHorizontalAlignment(okButton, HorizontalPanel.ALIGN_CENTER);
    okPanel.setCellVerticalAlignment(okButton, VerticalPanel.ALIGN_MIDDLE);

    if (titleService == null) {
      titleService = GWT.create(TitleService.class);
    }

    titleTree = new Tree();
    titleTree.setAnimationEnabled(true);

    AsyncCallback<ArrayList<Designer>> callback =
        new AsyncCallback<ArrayList<Designer>>() {

          public void onFailure(Throwable caught) {

            Window.alert("DEU PAU!!!");
          }

          public void onSuccess(ArrayList<Designer> result) {

            for (int i = 0; i < result.size(); i++) {
              Designer title = result.get(i);
              titleTree.addItem(title.getDesigner());
            }
          }
        };

    titleService.getDesignerList(callback);

    addDesignerPanel.add(designerPanel);
    addDesignerPanel.add(okPanel);
    mainPanel.add(addDesignerPanel);
    mainPanel.add(titleTree);

    initWidget(formPanel);
  }