private void updateToggleButtonStyle() {
   if (welcomeTextPanel.isVisible()) {
     toggleWelcomeTextButton.removeStyleName("collapsed");
     toggleWelcomeTextButton.addStyleName("expanded");
   } else {
     toggleWelcomeTextButton.removeStyleName("expanded");
     toggleWelcomeTextButton.addStyleName("collapsed");
   }
 }
Exemple #2
0
 public void selectButton(Object obj) {
   for (int i = 0; i < panel.getWidgetCount(); i++) {
     Button b = (Button) panel.getWidget(i);
     if (b.getElement().getPropertyObject("object") == obj) b.addStyleName("Ribbon-selected");
     else b.removeStyleName("Ribbon-selected");
   }
 }
 private void updateStyle() {
   if (selected) {
     button.addStyleName("btn-danger");
   } else {
     button.removeStyleName("btn-danger");
   }
 }
  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();
  }