private void configureOnChangeHandler() {
      final MonthlyRecurrenceEditor localThis = this;

      KeyboardListener keyboardListener =
          new KeyboardListener() {
            public void onKeyDown(Widget sender, char keyCode, int modifiers) {}

            public void onKeyPress(Widget sender, char keyCode, int modifiers) {}

            public void onKeyUp(Widget sender, char keyCode, int modifiers) {
              localThis.changeHandler();
            }
          };

      ClickListener clickListener =
          new ClickListener() {
            public void onClick(Widget sender) {
              localThis.changeHandler();
            }
          };

      ChangeListener changeListener =
          new ChangeListener() {
            public void onChange(Widget sender) {
              localThis.changeHandler();
            }
          };
      dayNOfMonthRb.addClickListener(clickListener);
      dayNOfMonthRb.addKeyboardListener(keyboardListener);
      nthDayNameOfMonthRb.addClickListener(clickListener);
      nthDayNameOfMonthRb.addKeyboardListener(keyboardListener);
      dayOfMonthTb.addKeyboardListener(keyboardListener);
      whichWeekLb.addChangeListener(changeListener);
      dayOfWeekLb.addChangeListener(changeListener);
    }
  public WgtEditOneTrigger() {
    VerticalPanel vpanel = new VerticalPanel();
    m_lstConditions.addChangeListener(this);
    m_lstConditions.setVisibleItemCount(10);
    vpanel.add(m_lstConditions);

    m_lstConditionsClass.setVisibleItemCount(1);
    for (ConditionClass conditionClass : ConditionClass.values()) {
      m_lstConditionsClass.addItem(conditionClass.name());
    }
    vpanel.add(m_lstConditionsClass);

    m_btnNewCondition.addClickHandler(this);
    vpanel.add(m_btnNewCondition);
    m_lstActions.addChangeListener(this);
    m_lstActions.setVisibleItemCount(10);
    vpanel.add(m_lstActions);

    m_lstActionsClass.setVisibleItemCount(1);
    for (ActionClass actionClass : ActionClass.values()) {
      m_lstActionsClass.addItem(actionClass.name());
    }
    vpanel.add(m_lstActionsClass);

    m_btnNewAction.addClickHandler(this);
    vpanel.add(m_btnNewAction);

    initWidget(vpanel);
  }
  public TournamentPoolPanel() {
    super("Pooler");

    poolCounts = new int[3];
    lblPoolCountTotal = new Label();
    lblPoolCount2 = new Label();
    lblPoolCount3 = new Label();
    lblPoolCount4 = new Label();

    poolGrid = new FlexTable();

    poolGrid.setText(0, 0, "Poolstorlek");
    lbPoolSize = new ListBox();
    lbPoolSize.addItem("2", "2");
    lbPoolSize.addItem("3", "3");
    lbPoolSize.setSelectedIndex(1);
    lbPoolSize.addChangeListener(
        new ChangeListener() {

          public void onChange(Widget sender) {
            updateControls();
          }
        });
    poolGrid.setWidget(0, 1, lbPoolSize);
    poolGrid.getFlexCellFormatter().setColSpan(0, 1, 3);

    poolGrid.setText(1, 0, "Vid udda deltagare");
    FlowPanel prefersLargerPanel = new FlowPanel();
    rbPreferLarger = new RadioButton("rePreferringLarger", "Föredrar större pooler");
    rbPreferLarger.setChecked(true);
    rbPreferSmaller = new RadioButton("rePreferringLarger", "Föredrar mindre pooler");
    prefersLargerPanel.add(rbPreferLarger);
    prefersLargerPanel.add(rbPreferSmaller);
    poolGrid.setWidget(1, 1, prefersLargerPanel);
    poolGrid.getFlexCellFormatter().setColSpan(1, 1, 3);

    poolGrid.setText(2, 0, "Antal pooler");
    poolGrid.getFlexCellFormatter().setColSpan(2, 0, 4);

    poolGrid.setText(3, 0, "Totalt");
    poolGrid.setText(3, 1, "2-man");
    poolGrid.setText(3, 2, "3-man");
    poolGrid.setText(3, 3, "4-man");
    poolGrid.setWidget(4, 0, lblPoolCountTotal);
    poolGrid.setWidget(4, 1, lblPoolCount2);
    poolGrid.setWidget(4, 2, lblPoolCount3);
    poolGrid.setWidget(4, 3, lblPoolCount4);

    for (int i = 0; i < 3; ++i) {
      poolGrid.getColumnFormatter().setWidth(i, "25%");
    }

    add(poolGrid);
  }
  private void makeWidget(final FlexTable table, final int row, final int col) {
    if (row == curRow && col == curCol) return;
    if (row >= 1) {
      curRow = row;
      curCol = col;
      if (col == 3 || col == 4) {
        TextBox t = new TextBox();
        t.setText(table.getText(row, col));
        table.setWidget(row, col, t);
        t.setFocus(true);
        t.addKeyboardListener(
            new KeyboardListener() {

              public void onKeyDown(Widget sender, char keyCode, int modifiers) {}

              public void onKeyPress(Widget sender, char keyCode, int modifiers) {
                TextBox t = (TextBox) sender;
                if (keyCode == (char) KeyboardListener.KEY_ENTER) {
                  clearCurrentSelection(table, -11, -11);
                }
              }

              public void onKeyUp(Widget sender, char keyCode, int modifiers) {}
            });
      } else if (col == 2 && !table.getText(row, col).equals("Primary")) {
        String curValue = table.getText(row, col);
        ListBox l = new ListBox();
        l.addItem("Category");
        if (curValue.equals("Category")) l.setSelectedIndex(0);
        l.addItem("Description");
        if (curValue.equals("Description")) l.setSelectedIndex(1);
        l.addItem("Numerical");
        if (curValue.equals("Numerical")) l.setSelectedIndex(2);
        l.addItem("Protected");
        if (curValue.equals("Protected")) l.setSelectedIndex(3);
        l.addItem("Tag");
        if (curValue.equals("Tag")) l.setSelectedIndex(4);
        l.addChangeListener(
            new ChangeListener() {

              public void onChange(Widget sender) {
                clearCurrentSelection(table, -11, -11);
              }
            });
        table.setWidget(row, col, l);
      }
    }
  }
示例#5
0
  public void onModuleLoad() {

    /*
     * Layout Stuff
     */

    routineSessionEditor.setVisible(false);
    RootPanel.get("fr-widgetLstRoutineSelector").add(lstRoutineSelector);
    RootPanel.get("fr-widgetTxtNewRoutine").add(txtNewRoutine);
    RootPanel.get("fr-widgetRoutineEditor").add(routineSessionEditor);
    /*
     * Register Listeners
     */

    lstRoutineSelector.addChangeListener(this);
    txtNewRoutine.addKeyboardListener(this);
    routineSessionEditor.addRoutineEditorListener(this);
    routineSessionEditor.getSessionExerciseEditor().addRoutineSessionEditorListener(this);

    routineSessionData.addDataListener(routineSessionEditor);

    sessionExerciseData.addDataListener(routineSessionEditor.getSessionExerciseEditor());

    /*
     * RPC's
     */

    exerciseService.getService().getUOMS(new CallbackScreener(callbackGetExerciseUOMS()));

    exerciseService
        .getService()
        .getUserExercises(
            User.instance().getToken(), new CallbackScreener(callbackGetUserExercises()));

    routineService
        .getService()
        .getUserRoutines(
            User.instance().getToken(), new CallbackScreener(callbackGetUserRoutines()));
  }
  /** @param node */
  public LoggerDetailTopPanel(final LoggerInfo info, String shortName, final LogTreeNode node) {
    super();
    this.info = info;
    this.shortName = shortName;
    this.node = node;
    this.topTopList = new ListPanel();
    this.topTopList.setWidth("100%");
    this.topTopList.setHeight("100%");
    this.topTopList.setCellText(0, 0, "Short name:");
    Hyperlink l = new Hyperlink(this.shortName, null);
    l.setTitle(this.info.getFullName());

    this.topTopList.setCell(0, 1, l);
    this.topTopList.setCellText(0, 2, "Use parent handlers:");

    final ListBox ups = new ListBox();
    ups.addItem("Yes", _TRUE);
    ups.addItem("No", _FALSE);
    ups.setVisibleItemCount(1);
    ups.setSelectedIndex(info.isUseParentHandlers() ? 0 : 1);
    this.topTopList.setCell(0, 3, ups);

    for (int i = 0; i < LogTreeNode._LEVELS.length; i++) {
      levelB.addItem(LogTreeNode._LEVELS[i], LogTreeNode._LEVELS[i]);
      if (LogTreeNode._LEVELS[i].equals(info.getLevel())) levelB.setSelectedIndex(i);
    }

    this.topTopList.setCellText(2, 0, "Level:");
    this.topTopList.setCell(2, 1, levelB);
    this.topTopList.setCellText(2, 2, "Filter class name:");
    this.filterClassName.setWidth("100%");
    this.filterClassName.setText(info.getFilterClass());
    this.topTopList.setCell(2, 3, this.filterClassName);

    Hyperlink saveDetails = new Hyperlink();
    saveDetails.setText("Loger details (Save)");
    this.setHeader(0, saveDetails);
    this.setCell(0, 0, this.topTopList);

    buildParamList();
    this.setColumnWidth(0, "100%");
    // Change listeners for ListBoxes:
    class UseParentHandlerListener implements ChangeListener {

      /*
       * (non-Javadoc)
       *
       * @see com.google.gwt.user.client.ui.ChangeListener#onChange(com.google .gwt.user.client.ui.Widget)
       */
      public void onChange(Widget sender) {

        final ListBox ss = (ListBox) sender;
        final String value = ss.getValue(ss.getSelectedIndex());
        final boolean sendValue;
        if (value.equals(_TRUE)) sendValue = (true);
        else sendValue = (false);

        class UseParentHandlerCallback implements AsyncCallback {

          /*
           * (non-Javadoc)
           *
           * @see com.google.gwt.user.client.rpc.AsyncCallback#onFailure (java.lang.Throwable)
           */
          public void onFailure(Throwable caught) {

            Logger.error(
                "Could not set \"UseParentHandler\" flag for logger ["
                    + info.getFullName()
                    + "] due to["
                    + caught.getMessage()
                    + "]");
            if (sendValue) {
              ss.setItemSelected(1, true);
            } else {
              ss.setItemSelected(0, true);
            }
          }

          /*
           * (non-Javadoc)
           *
           * @see com.google.gwt.user.client.rpc.AsyncCallback#onSuccess (java.lang.Object)
           */
          public void onSuccess(Object result) {}
        }

        ServerConnection.logServiceAsync.setUseParentHandlers(
            info.getFullName(), sendValue, new UseParentHandlerCallback());
      }
    }

    class LevelChangeListener implements ChangeListener {

      public void onChange(Widget sender) {
        ListBox ss = (ListBox) sender;
        final String logLevel = ss.getValue(ss.getSelectedIndex());

        class LevelChangeCallBack implements AsyncCallback {

          public void onFailure(Throwable caught) {
            Logger.error(
                "Could not set logger level for logger ["
                    + info.getFullName()
                    + "] due to["
                    + caught.getMessage()
                    + "]");
          }

          public void onSuccess(Object result) {
            if (logLevel.equals(LogTreeNode._LEVEL_OFF)) {
              node.turnOff();
            } else {
              node.turnOn();
            }
          }
        }

        ServerConnection.logServiceAsync.setLoggerLevel(
            info.getFullName(), logLevel, new LevelChangeCallBack());
      }
    }

    // add listeners
    ups.addChangeListener(new UseParentHandlerListener());
    levelB.addChangeListener(new LevelChangeListener());
  }
  /**
   * Creates a new widget. This class needs access to certain fields and methods on the application
   * enclosing it.
   *
   * @param parent the host application
   */
  public RichTextWidget(final GWTNote parent) {
    super();

    VerticalPanel top = new VerticalPanel();
    top.setWidth("100%");
    HorizontalPanel header = new HorizontalPanel();
    top.add(header);
    header.setWidth("100%");

    header.add(new Label("GWT GearsNote"));

    header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    status = new Label("Ready");
    header.add(status);

    this.bodyWidget = new RichTextArea();
    bodyWidget.addKeyboardListener(
        new KeyboardListenerAdapter() {
          @Override
          public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            String newText = bodyWidget.getText();
            if (((newText == null) && (curText != null))
                || ((newText != null) && !newText.equals(curText))) {
              curText = newText;
            }
          }
        });

    HorizontalPanel controls = new HorizontalPanel();
    RichTextToolbar tb = new RichTextToolbar(this.bodyWidget);
    name = new TextBox();
    name.setText("default");
    name.setEnabled(false);
    nameEdit = new PushButton("Edit");
    nameEdit.addClickListener(
        new ClickListener() {
          public void onClick(Widget sender) {
            String curName = name.getText();
            boolean doNotify = !oldName.equals(curName);
            if (!nameEditable) { // if becoming editable, store off current value
              oldName = curName;
            }
            if (nameEditable && (curName == null || "".equals(curName))) {
              // if becoming un-editable, check to make sure it's valid
              Window.alert("The note name cannot be blank. Please try again.");
              nameEdit.setText(oldName);
              return;
            }
            // if all else is good, just flip the state
            nameEditable = !nameEditable;
            name.setEnabled(nameEditable);
            nameEdit.getUpFace().setText((nameEditable ? "Confirm" : "Edit"));
            if (doNotify) {
              notifyNameListeners();
            }
          }
        });
    nameEdit.addStyleName("edit-button");

    options = new ListBox();
    controls.add(tb);
    options.addItem("default");
    options.setSelectedIndex(0);
    options.addChangeListener(
        new ChangeListener() {
          public void onChange(Widget sender) {
            String newName = options.getItemText(options.getSelectedIndex());
            name.setText(newName);
            notifyNameListeners();
          }
        });
    HorizontalPanel tmp = new HorizontalPanel();
    tmp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    tmp.add(new Label("Note name:"));
    tmp.add(name);
    tmp.add(nameEdit);
    tmp.add(options);
    controls.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    controls.setWidth("100%");
    controls.add(tmp);
    top.add(controls);

    top.add(bodyWidget);
    this.bodyWidget.setWidth("100%");
    top.setCellHeight(bodyWidget, ((int) (Window.getClientHeight() * .75)) + "px");
    this.bodyWidget.setHeight("100%");

    initWidget(top);
  }