예제 #1
0
  private void setup() {
    textBox = new TextBox();
    textBox.setName(name);
    textBox.setTitle(title);
    textBox.setTabIndex(0);

    oracle = new PrincipalSuggestOracle(type);
    suggestBox = new SuggestBox(oracle, textBox);
    suggestBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            setModified(true);
            String newValue = event.getValue();
            setUndefined(newValue.equals(""));
            parseValue(newValue);
          }
        });
    suggestBox.addSelectionHandler(
        new SelectionHandler<SuggestOracle.Suggestion>() {
          @Override
          public void onSelection(
              SelectionEvent<SuggestOracle.Suggestion> suggestionSelectionEvent) {
            setModified(true);
            String newValue = suggestBox.getValue();
            setUndefined(newValue.equals(""));
            parseValue(newValue);
          }
        });
    wrapper = new InputElementWrapper(suggestBox, this);
  }
예제 #2
0
  public NumberBoxItem(String name, String title, boolean allowNegativeNumber) {
    super(name, title);
    this.allowNegativeNumber = allowNegativeNumber;

    textBox = new TextBox();
    textBox.setName(name);
    textBox.setTitle(title);
    textBox.setTabIndex(0);

    textBox.addValueChangeHandler(
        new ValueChangeHandler<String>() {
          @Override
          public void onValueChange(ValueChangeEvent<String> event) {
            setModified(true);
            setUndefined(event.getValue().equals(""));
          }
        });

    textBox.setVisibleLength(6);

    wrapper = new InputElementWrapper(textBox, this);
  }
예제 #3
0
 /**
  * Sets the date box's position in the tab index. If more than one widget has the same tab index,
  * each such widget will receive focus in an arbitrary order. Setting the tab index to <code>-1
  * </code> will cause this widget to be removed from the tab order.
  *
  * @param index the date box's tab index
  */
 public void setTabIndex(int index) {
   box.setTabIndex(index);
 }
  private Widget buildLoginPanel(boolean openInNewWindowDefault) {
    userTextBox.setWidth("100%"); // $NON-NLS-1$
    passwordTextBox.setWidth("100%"); // $NON-NLS-1$
    usersListBox.setWidth("100%"); // $NON-NLS-1$

    userTextBox.setStyleName("login-panel-label");
    passwordTextBox.setStyleName("login-panel-label");
    newWindowChk.setStyleName("login-panel-label");

    VerticalPanel credentialsPanel = new VerticalPanel();

    credentialsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    credentialsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    SimplePanel spacer;
    if (showUsersList) {
      // populate default users list box
      addDefaultUsers();
      Label sampleUsersLabel = new Label(Messages.getString("sampleUser") + ":");
      sampleUsersLabel.setStyleName("login-panel-label");
      credentialsPanel.add(sampleUsersLabel); // $NON-NLS-1$ //$NON-NLS-2$
      credentialsPanel.add(usersListBox);
      spacer = new SimplePanel();
      spacer.setHeight("8px"); // $NON-NLS-1$
      credentialsPanel.add(spacer);
    }

    Label usernameLabel = new Label(Messages.getString("username") + ":");
    usernameLabel.setStyleName("login-panel-label");

    credentialsPanel.add(usernameLabel); // $NON-NLS-1$ //$NON-NLS-2$
    credentialsPanel.add(userTextBox);

    spacer = new SimplePanel();
    spacer.setHeight("8px"); // $NON-NLS-1$
    credentialsPanel.add(spacer);

    credentialsPanel.setCellHeight(spacer, "8px"); // $NON-NLS-1$
    HTML passwordLabel = new HTML(Messages.getString("password") + ":");
    passwordLabel.setStyleName("login-panel-label");
    credentialsPanel.add(passwordLabel); // $NON-NLS-1$ //$NON-NLS-2$
    credentialsPanel.add(passwordTextBox);

    boolean reallyShowNewWindowOption = showNewWindowOption;

    String showNewWindowOverride =
        Window.Location.getParameter("showNewWindowOption"); // $NON-NLS-1$
    if (showNewWindowOverride != null && !"".equals(showNewWindowOverride)) { // $NON-NLS-1$
      // if the override is set, we MUST obey it above all else
      reallyShowNewWindowOption = "true".equals(showNewWindowOverride); // $NON-NLS-1$
    } else if (getReturnLocation() != null && !"".equals(getReturnLocation())) { // $NON-NLS-1$
      StringTokenizer st = new StringTokenizer(getReturnLocation(), "?&"); // $NON-NLS-1$
      // first token will be ignored, it is 'up to the ?'
      for (int i = 1; i < st.countTokens(); i++) {
        StringTokenizer paramTokenizer = new StringTokenizer(st.tokenAt(i), "="); // $NON-NLS-1$
        if (paramTokenizer.countTokens() == 2) {
          // we've got a name=value token
          if (paramTokenizer.tokenAt(0).equalsIgnoreCase("showNewWindowOption")) { // $NON-NLS-1$
            reallyShowNewWindowOption = "true".equals(paramTokenizer.tokenAt(1)); // $NON-NLS-1$
            break;
          }
        }
      }
    }

    // New Window checkbox
    if (reallyShowNewWindowOption) {
      spacer = new SimplePanel();
      spacer.setHeight("8px"); // $NON-NLS-1$
      credentialsPanel.add(spacer);
      credentialsPanel.setCellHeight(spacer, "8px"); // $NON-NLS-1$

      newWindowChk.setText(Messages.getString("launchInNewWindow")); // $NON-NLS-1$

      String cookieCheckedVal = Cookies.getCookie("loginNewWindowChecked"); // $NON-NLS-1$
      if (cookieCheckedVal != null) {
        newWindowChk.setValue(Boolean.parseBoolean(cookieCheckedVal));
      } else {
        // default is false, per BISERVER-2384
        newWindowChk.setValue(openInNewWindowDefault);
      }

      credentialsPanel.add(newWindowChk);
    }

    userTextBox.setTabIndex(1);
    passwordTextBox.setTabIndex(2);
    if (reallyShowNewWindowOption) {
      newWindowChk.setTabIndex(3);
    }
    passwordTextBox.setText(""); // $NON-NLS-1$

    setFocusWidget(userTextBox);

    Image lockImage = new Image(GWT.getModuleBaseURL() + "images/icon_login_lock.png");
    HorizontalPanel loginPanel = new HorizontalPanel();
    loginPanel.setSpacing(5);
    loginPanel.setStyleName("login-panel");
    loginPanel.add(lockImage);
    loginPanel.add(credentialsPanel);

    return loginPanel;
  }
예제 #5
0
  /**
   * Instantiates a new location field.
   *
   * @param form is the form or other HasComponents element that contains the field.
   * @param permission that controls the visibility of the field.
   * @param fieldLabel is the optional text to identify the field.
   * @param buttonLabel the text on the field refresh button.
   * @param tab index of the field.
   */
  public LocationField(
      HasComponents form, short[] permission, String fieldLabel, String buttonLabel, int tab) {

    initialize(panel, form, permission, CSS.cbtLocationField());

    if (fieldLabel != null) {
      this.label = new Label(fieldLabel);
      this.label.addStyleName(CSS.cbtLocationFieldLabel());
      this.label.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              showHelp();
            }
          });
      panel.add(this.label);
    }

    field.addStyleName(CSS.cbtLocationFieldField());
    field.setText(Model.BLANK);
    field.setTabIndex(tab);
    panel.add(field);

    if (buttonLabel != null) {
      this.button =
          new Button(
              buttonLabel,
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  setName(field.getText());
                }
              });
      button.addStyleName(CSS.cbtLocationFieldButton());
      panel.add(button);
    } else {
      field.addBlurHandler(
          new BlurHandler() {
            @Override
            public void onBlur(BlurEvent event) {
              if (nullable && field.getText().isEmpty()) {
                setValueAndFireChange(defaultValue);
              } else {
                setName(field.getText());
              }
            }
          });
    }

    field.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
              if (nullable && field.getText().isEmpty()) {
                setValueAndFireChange(defaultValue);
              } else {
                setName(field.getText());
              }
            }
          }
        });

    panel.add(lock);
  }
예제 #6
0
 /* (non-Javadoc)
  * @see net.cbtltd.client.field.AbstractField#setTabIndex(int)
  */
 @Override
 public void setTabIndex(int tab) {
   field.setTabIndex(tab++);
 }
 public void setTabIndex(int index) {
   textBox.setTabIndex(index);
 }