Пример #1
0
  private Composite createOwnerGroup(Composite parent, IExtendedFileInfo fileInfo) {
    Group container = new Group(parent, SWT.NONE);
    container.setText(Messages.FileInfoPropertyPage_OwnerAndGroup);
    container.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());

    Label label = new Label(container, SWT.NONE);
    label.setText(StringUtil.makeFormLabel(Messages.FileInfoPropertyPage_Owner));
    Text text = new Text(container, SWT.READ_ONLY);
    text.setText(fileInfo.getOwner());
    text.setLayoutData(
        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());

    label = new Label(container, SWT.NONE);
    label.setText(StringUtil.makeFormLabel(Messages.FileInfoPropertyPage_Group));
    text = new Text(container, SWT.READ_ONLY);
    text.setText(fileInfo.getGroup());
    text.setLayoutData(
        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());

    return container;
  }
  private Composite createLogoutComponents(Composite parent) {
    Composite logoutComp = new Composite(parent, SWT.NONE);
    logoutComp.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());

    Label label = new Label(logoutComp, SWT.NONE);
    label.setText(StringUtil.makeFormLabel(Messages.JiraPreferencePageProvider_LBL_User));
    userLabel = new Label(logoutComp, SWT.NONE);
    logoutButton = new Button(logoutComp, SWT.PUSH);
    logoutButton.setText(Messages.JiraPreferencePageProvider_LBL_Logout);
    logoutButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            logout();
          }
        });
    updateUserText();

    return logoutComp;
  }
  /**
   * @param parent
   * @param style
   */
  public SFTPAdvancedOptionsComposite(Composite parent, int style, Listener listener) {
    super(parent, style);
    this.listener = listener;

    setLayout(
        GridLayoutFactory.swtDefaults()
            .numColumns(5)
            .spacing(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                new PixelConverter(this)
                    .convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .create());

    /* row 1 */
    Label label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Compression));

    compressionCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    compressionCombo.add(ISFTPConstants.COMPRESSION_AUTO);
    compressionCombo.add(ISFTPConstants.COMPRESSION_NONE);
    compressionCombo.add(ISFTPConstants.COMPRESSION_ZLIB);
    compressionCombo.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(compressionCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT)
            .create());

    label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .align(SWT.END, SWT.CENTER)
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());

    label = new Label(this, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Port));

    portText = new Text(this, SWT.SINGLE | SWT.RIGHT | SWT.BORDER);
    portText.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                Math.max(
                    new PixelConverter(portText).convertWidthInCharsToPixels(5),
                    portText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x),
                SWT.DEFAULT)
            .create());

    /* row 2 */
    label = new Label(this, SWT.NONE);
    label.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(
                new PixelConverter(this)
                    .convertHorizontalDLUsToPixels(IDialogConstants.LABEL_WIDTH),
                SWT.DEFAULT)
            .create());
    label.setText(StringUtil.makeFormLabel(Messages.SFTPAdvancedOptionsComposite_Encoding));

    encodingCombo = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
    encodingCombo.setItems(Charset.availableCharsets().keySet().toArray(new String[0]));
    encodingCombo.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(encodingCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x, SWT.DEFAULT)
            .span(4, 1)
            .create());

    /* -- */
    addListeners();
    portText.addVerifyListener(new NumberVerifyListener());
  }
  private Composite createLoginComponents(Composite parent) {
    Composite loginComp = new Composite(parent, SWT.NONE);
    loginComp.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());

    Label label = new Label(loginComp, SWT.NONE);
    label.setText(StringUtil.makeFormLabel(Messages.JiraPreferencePageProvider_LBL_Username));
    label.setLayoutData(GridDataFactory.swtDefaults().create());

    ModifyListener modifyListener =
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            updateButtonStates();
          }
        };
    usernameText = new Text(loginComp, SWT.BORDER);
    usernameText.setLayoutData(
        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
    usernameText.addModifyListener(modifyListener);

    testButton = new Button(loginComp, SWT.NONE);
    testButton.setText(Messages.JiraPreferencePageProvider_LBL_Validate);
    testButton.setLayoutData(
        GridDataFactory.swtDefaults().hint(getButtonWidthHint(testButton), SWT.DEFAULT).create());
    testButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (login(true)) {
              // shows a success message
              MessageDialog.openInformation(
                  UIUtils.getActiveShell(),
                  Messages.JiraPreferencePageProvider_Success_Title,
                  Messages.JiraPreferencePageProvider_Success_Message);
            }
          }
        });

    label = new Label(loginComp, SWT.NONE);
    label.setText(StringUtil.makeFormLabel(Messages.JiraPreferencePageProvider_LBL_Password));
    label.setLayoutData(GridDataFactory.swtDefaults().create());

    passwordText = new Text(loginComp, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(
        GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
    passwordText.addModifyListener(modifyListener);

    createAccountButton = new Button(loginComp, SWT.NONE);
    createAccountButton.setText(
        StringUtil.ellipsify(Messages.JiraPreferencePageProvider_LBL_Signup));
    createAccountButton.setLayoutData(
        GridDataFactory.swtDefaults()
            .hint(getButtonWidthHint(createAccountButton), SWT.DEFAULT)
            .create());
    createAccountButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            WorkbenchBrowserUtil.launchExternalBrowser(SIGNUP_URL);
          }
        });

    KeyListener keyListener =
        new KeyListener() {

          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR || e.character == SWT.KEYPAD_CR) {
              if (testButton.isEnabled()) {
                login(true);
              }
            }
          }

          public void keyReleased(KeyEvent e) {}
        };
    usernameText.addKeyListener(keyListener);
    passwordText.addKeyListener(keyListener);

    updateButtonStates();
    adjustWidth();

    return loginComp;
  }