Example usage for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN

List of usage examples for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN.

Prototype

int VERTICAL_MARGIN

To view the source code for org.eclipse.jface.dialogs IDialogConstants VERTICAL_MARGIN.

Click Source Link

Document

Vertical margin in dialog units (value 7).

Usage

From source file:nl.utwente.ce.imageexport.ExceptionErrorDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    createMessageArea(composite);//ww  w. java 2  s  .  c om
    createSupportArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 2;
    composite.setLayout(layout);
    GridData childData = new GridData(GridData.FILL_BOTH);
    childData.horizontalSpan = 2;
    childData.grabExcessVerticalSpace = false;
    composite.setLayoutData(childData);
    composite.setFont(parent.getFont());

    return composite;
}

From source file:org.apache.directory.studio.connection.ui.dialogs.PasswordDialog.java

License:Apache License

/**
 * {@inheritDoc}//from w w w  .  j  a v  a 2 s  .  c o m
 */
@Override
protected Control createDialogArea(Composite parent) {
    // Composite
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    GridData compositeGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    compositeGridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    composite.setLayoutData(compositeGridData);

    // Message
    if (message != null) {
        Label messageLabel = BaseWidgetUtils.createWrappedLabel(composite, message, 1);
        GridData messageLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
        messageLabelGridData.widthHint = convertHorizontalDLUsToPixels(
                IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageLabel.setLayoutData(messageLabelGridData);
    }

    // Password Text
    passwordText = BaseWidgetUtils.createText(composite, value, 1);
    passwordText.setEchoChar('\u2022');

    // Show Password Checkbox
    showPasswordCheckbox = BaseWidgetUtils.createCheckbox(composite,
            Messages.getString("PasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showPasswordCheckbox.addSelectionListener(showPasswordCheckboxListener);

    // Setting focus
    passwordText.setFocus();
    applyDialogFont(composite);

    return composite;
}

From source file:org.apache.directory.studio.connection.ui.dialogs.ResetPasswordDialog.java

License:Apache License

/**
 * {@inheritDoc}/*w  w w. j  a v a2  s  .c  o m*/
 */
@Override
protected Control createDialogArea(Composite parent) {
    // Composite
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    GridData compositeGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    compositeGridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    composite.setLayoutData(compositeGridData);

    // Message
    if (message != null) {
        Label messageLabel = BaseWidgetUtils.createWrappedLabel(composite, message, 1);
        GridData messageLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1);
        messageLabelGridData.widthHint = convertHorizontalDLUsToPixels(
                IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageLabel.setLayoutData(messageLabelGridData);
    }

    // Current Password Group
    Group currentPasswordGroup = BaseWidgetUtils.createGroup(composite,
            Messages.getString("ResetPasswordDialog.CurrentPassword"), 1); //$NON-NLS-1$
    currentPasswordGroup.setLayout(new GridLayout(2, false));

    // Current Password Text
    BaseWidgetUtils.createLabel(currentPasswordGroup,
            Messages.getString("ResetPasswordDialog.CurrentPasswordColon"), 1); //$NON-NLS-1$
    currentPasswordText = BaseWidgetUtils.createText(currentPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    currentPasswordText.setEchoChar('\u2022');
    currentPasswordText.addModifyListener(event -> validate());

    // Show Current Password Checkbox
    BaseWidgetUtils.createLabel(currentPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    showCurrentPasswordCheckbox = BaseWidgetUtils.createCheckbox(currentPasswordGroup,
            Messages.getString("ResetPasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showCurrentPasswordCheckbox.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (showCurrentPasswordCheckbox.getSelection()) {
                currentPasswordText.setEchoChar('\0');
            } else {
                currentPasswordText.setEchoChar('\u2022');
            }
        }
    });

    // New Password Group
    Group newPasswordGroup = BaseWidgetUtils.createGroup(composite,
            Messages.getString("ResetPasswordDialog.NewPassword"), 1); //$NON-NLS-1$
    newPasswordGroup.setLayout(new GridLayout(2, false));

    // New Password Text
    BaseWidgetUtils.createLabel(newPasswordGroup, Messages.getString("ResetPasswordDialog.NewPasswordColon"), //$NON-NLS-1$
            1);
    newPasswordText = BaseWidgetUtils.createText(newPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    newPasswordText.setEchoChar('\u2022');
    newPasswordText.addModifyListener(event -> validate());

    // Show New Password Checkbox
    BaseWidgetUtils.createLabel(newPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    showNewPasswordCheckbox = BaseWidgetUtils.createCheckbox(newPasswordGroup,
            Messages.getString("ResetPasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showNewPasswordCheckbox.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (showNewPasswordCheckbox.getSelection()) {
                newPasswordText.setEchoChar('\0');
            } else {
                newPasswordText.setEchoChar('\u2022');
            }
        }
    });

    // Verify Text
    BaseWidgetUtils.createLabel(newPasswordGroup,
            Messages.getString("ResetPasswordDialog.VerifyNewPasswordColon"), 1); //$NON-NLS-1$
    verifyNewPasswordText = BaseWidgetUtils.createText(newPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    verifyNewPasswordText.setEchoChar('\u2022');
    verifyNewPasswordText.addModifyListener(event -> validate());

    // Show Verify New Password Checkbox
    BaseWidgetUtils.createLabel(newPasswordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    showVerifyNewPasswordCheckbox = BaseWidgetUtils.createCheckbox(newPasswordGroup,
            Messages.getString("ResetPasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showVerifyNewPasswordCheckbox.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (showVerifyNewPasswordCheckbox.getSelection()) {
                verifyNewPasswordText.setEchoChar('\0');
            } else {
                verifyNewPasswordText.setEchoChar('\u2022');
            }
        }
    });

    // Setting focus
    currentPasswordGroup.setFocus();

    applyDialogFont(composite);
    return composite;
}

From source file:org.apache.directory.studio.connection.ui.dialogs.SetupPasswordDialog.java

License:Apache License

/**
 * {@inheritDoc}//from  w w w.ja  v  a  2  s .  co  m
 */
@Override
protected Control createDialogArea(Composite parent) {
    // Composite
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    GridData compositeGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    compositeGridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    composite.setLayoutData(compositeGridData);

    // Message
    if (message != null) {
        Label messageLabel = BaseWidgetUtils.createWrappedLabel(composite, message, 1);
        GridData messageLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
        messageLabelGridData.widthHint = convertHorizontalDLUsToPixels(
                IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        messageLabel.setLayoutData(messageLabelGridData);
    }

    // Password Group
    Group passwordGroup = BaseWidgetUtils.createGroup(composite,
            Messages.getString("SetupPasswordDialog.Password"), 1); //$NON-NLS-1$
    passwordGroup.setLayout(new GridLayout(2, false));

    // Password Text
    BaseWidgetUtils.createLabel(passwordGroup, Messages.getString("SetupPasswordDialog.PasswordColon"), 1); //$NON-NLS-1$
    passwordText = BaseWidgetUtils.createText(passwordGroup, value, 1);
    passwordText.setEchoChar('\u2022');
    passwordText.addModifyListener(event -> validate());

    // Show Password Checkbox
    BaseWidgetUtils.createLabel(passwordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    showPasswordCheckbox = BaseWidgetUtils.createCheckbox(passwordGroup,
            Messages.getString("SetupPasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showPasswordCheckbox.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (showPasswordCheckbox.getSelection()) {
                passwordText.setEchoChar('\0');
            } else {
                passwordText.setEchoChar('\u2022');
            }
        }
    });

    // Verify Text
    BaseWidgetUtils.createLabel(passwordGroup, Messages.getString("SetupPasswordDialog.VerifyPasswordColon"), //$NON-NLS-1$
            1);
    verifyPasswordText = BaseWidgetUtils.createText(passwordGroup, value, 1);
    verifyPasswordText.setEchoChar('\u2022');
    verifyPasswordText.addModifyListener(event -> validate());

    // Show Verify Password Checkbox
    BaseWidgetUtils.createLabel(passwordGroup, StringUtils.EMPTY, 1); //$NON-NLS-1$
    showVerifyPasswordCheckbox = BaseWidgetUtils.createCheckbox(passwordGroup,
            Messages.getString("SetupPasswordDialog.ShowPassword"), 1); //$NON-NLS-1$
    showVerifyPasswordCheckbox.addSelectionListener(new SelectionAdapter() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (showVerifyPasswordCheckbox.getSelection()) {
                verifyPasswordText.setEchoChar('\0');
            } else {
                verifyPasswordText.setEchoChar('\u2022');
            }
        }
    });

    // Setting focus
    passwordText.setFocus();

    applyDialogFont(composite);
    return composite;
}

From source file:org.apache.directory.studio.valueeditors.image.ImageDialog.java

License:Apache License

/**
 * Creates a tab item composite./*from w w w . ja  v a  2 s  . c  o m*/
 *
 * @return a tab item composite
 */
private Composite createTabItemComposite() {
    Composite composite = new Composite(tabFolder, SWT.NONE);

    GridLayout compositeLayout = new GridLayout(1, false);
    compositeLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    compositeLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    compositeLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    compositeLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(compositeLayout);

    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    return composite;
}

From source file:org.apache.directory.studio.valueeditors.password.PasswordDialog.java

License:Apache License

/**
 * Creates the current password tab.//  w w  w . java2 s.c  o m
 */
private void createCurrentPasswordTab() {
    // Current password composite
    currentPasswordComposite = new Composite(tabFolder, SWT.NONE);
    GridLayout currentLayout = new GridLayout(2, false);
    currentLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    currentLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    currentLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    currentLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    currentPasswordComposite.setLayout(currentLayout);
    currentPasswordComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // Current password text
    BaseWidgetUtils.createLabel(currentPasswordComposite,
            Messages.getString("PasswordDialog.CurrentPassword") + ":", 1); //$NON-NLS-1$//$NON-NLS-2$
    currentPasswordText = BaseWidgetUtils.createReadonlyText(currentPasswordComposite, "", 1); //$NON-NLS-1$

    // Current password details composite
    new Label(currentPasswordComposite, SWT.NONE);
    Composite currentPasswordDetailsComposite = BaseWidgetUtils.createColumnContainer(currentPasswordComposite,
            2, 1);

    // Current password hash method label
    BaseWidgetUtils.createLabel(currentPasswordDetailsComposite,
            Messages.getString("PasswordDialog.HashMethod"), 1); //$NON-NLS-1$
    currentPasswordHashMethodText = BaseWidgetUtils.createLabeledText(currentPasswordDetailsComposite, "", 1); //$NON-NLS-1$

    // Current password hex label
    BaseWidgetUtils.createLabel(currentPasswordDetailsComposite,
            Messages.getString("PasswordDialog.PasswordHex"), 1); //$NON-NLS-1$
    currentPasswordValueHexText = BaseWidgetUtils.createLabeledText(currentPasswordDetailsComposite, "", 1); //$NON-NLS-1$

    // Current password salt hex label
    BaseWidgetUtils.createLabel(currentPasswordDetailsComposite, Messages.getString("PasswordDialog.SaltHex"), //$NON-NLS-1$
            1);
    currentPasswordSaltHexText = BaseWidgetUtils.createLabeledText(currentPasswordDetailsComposite, "", 1); //$NON-NLS-1$

    // Show current password details button
    showCurrentPasswordDetailsButton = BaseWidgetUtils.createCheckbox(currentPasswordDetailsComposite,
            Messages.getString("PasswordDialog.ShowCurrentPasswordDetails"), 2); //$NON-NLS-1$

    // Verify password text
    BaseWidgetUtils.createLabel(currentPasswordComposite, Messages.getString("PasswordDialog.VerifyPassword"), //$NON-NLS-1$
            1);
    testPasswordText = BaseWidgetUtils.createText(currentPasswordComposite, "", 1); //$NON-NLS-1$

    // Verify password details composite
    new Label(currentPasswordComposite, SWT.NONE);
    Composite testPasswordDetailsComposite = BaseWidgetUtils.createColumnContainer(currentPasswordComposite, 2,
            1);

    // Bind DN label
    BaseWidgetUtils.createLabel(testPasswordDetailsComposite, Messages.getString("PasswordDialog.BindDn"), 1); //$NON-NLS-1$
    testBindDnText = BaseWidgetUtils.createLabeledText(testPasswordDetailsComposite, "", 1); //$NON-NLS-1$

    // Show verify password details button
    showTestPasswordDetailsButton = BaseWidgetUtils.createCheckbox(testPasswordDetailsComposite,
            Messages.getString("PasswordDialog.ShowTestPasswordDetails"), 2); //$NON-NLS-1$

    // Verify password buttons composite
    new Label(currentPasswordComposite, SWT.NONE);
    Composite verifyPasswordButtonsComposite = BaseWidgetUtils.createColumnContainer(currentPasswordComposite,
            2, 1);

    // Verify button
    verifyPasswordButton = BaseWidgetUtils.createButton(verifyPasswordButtonsComposite,
            Messages.getString("PasswordDialog.Verify"), 1); //$NON-NLS-1$
    verifyPasswordButton.setEnabled(false);

    // Bind button
    bindPasswordButton = BaseWidgetUtils.createButton(verifyPasswordButtonsComposite,
            Messages.getString("PasswordDialog.Bind"), 1); //$NON-NLS-1$
    bindPasswordButton.setEnabled(false);

    // Current password tab
    currentPasswordTab = new TabItem(tabFolder, SWT.NONE);
    currentPasswordTab.setText(Messages.getString("PasswordDialog.CurrentPassword")); //$NON-NLS-1$
    currentPasswordTab.setControl(currentPasswordComposite);
}

From source file:org.apache.directory.studio.valueeditors.password.PasswordDialog.java

License:Apache License

/**
 * Creates the new password tab./*  w  w  w .j  a  va  2 s.  c  om*/
 */
private void createNewPasswordTab() {
    // New password composite
    newPasswordComposite = new Composite(tabFolder, SWT.NONE);
    GridLayout newLayout = new GridLayout(2, false);
    newLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    newLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    newLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    newLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    newPasswordComposite.setLayout(newLayout);

    // New password text
    BaseWidgetUtils.createLabel(newPasswordComposite, Messages.getString("PasswordDialog.EnterNewPassword"), 1); //$NON-NLS-1$
    newPasswordText = BaseWidgetUtils.createText(newPasswordComposite, "", 1); //$NON-NLS-1$

    // Confirm new password text
    BaseWidgetUtils.createLabel(newPasswordComposite, Messages.getString("PasswordDialog.ConfirmNewPassword"), //$NON-NLS-1$
            1);
    confirmNewPasswordText = BaseWidgetUtils.createText(newPasswordComposite, "", 1); //$NON-NLS-1$

    // New password hashing method combo
    BaseWidgetUtils.createLabel(newPasswordComposite, Messages.getString("PasswordDialog.SelectHashMethod"), 1); //$NON-NLS-1$
    newPasswordHashMethodComboViewer = new ComboViewer(newPasswordComposite);
    newPasswordHashMethodComboViewer.setContentProvider(new ArrayContentProvider());
    newPasswordHashMethodComboViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            String hashMethod = getHashMethodName(element);

            if (!"".equals(hashMethod)) {
                return hashMethod;
            }

            return super.getText(element);
        }
    });
    newPasswordHashMethodComboViewer.setInput(HASH_METHODS);
    newPasswordHashMethodComboViewer.getControl()
            .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    // New password preview text
    BaseWidgetUtils.createLabel(newPasswordComposite, Messages.getString("PasswordDialog.PasswordPreview"), 1); //$NON-NLS-1$
    newPasswordPreviewText = BaseWidgetUtils.createReadonlyText(newPasswordComposite, "", 1); //$NON-NLS-1$

    // New salt button
    newSaltButton = BaseWidgetUtils.createButton(newPasswordComposite,
            Messages.getString("PasswordDialog.NewSalt"), 1); //$NON-NLS-1$
    newSaltButton.setLayoutData(new GridData());
    newSaltButton.setEnabled(false);

    // New password preview details composite
    Composite newPasswordPreviewDetailsComposite = BaseWidgetUtils.createColumnContainer(newPasswordComposite,
            2, 1);

    // New password preview hex label
    BaseWidgetUtils.createLabel(newPasswordPreviewDetailsComposite,
            Messages.getString("PasswordDialog.PasswordHex"), 1); //$NON-NLS-1$
    newPasswordPreviewValueHexText = BaseWidgetUtils.createLabeledText(newPasswordPreviewDetailsComposite, ":", //$NON-NLS-1$
            1);

    // New password preview salt hex label
    BaseWidgetUtils.createLabel(newPasswordPreviewDetailsComposite,
            Messages.getString("PasswordDialog.SaltHex"), 1); //$NON-NLS-1$
    newPasswordPreviewSaltHexText = BaseWidgetUtils.createLabeledText(newPasswordPreviewDetailsComposite, "", //$NON-NLS-1$
            1);

    // Show new password details button
    showNewPasswordDetailsButton = BaseWidgetUtils.createCheckbox(newPasswordPreviewDetailsComposite,
            Messages.getString("PasswordDialog.ShowNewPasswordDetails"), 2); //$NON-NLS-1$

    // New password tab
    newPasswordTab = new TabItem(tabFolder, SWT.NONE);
    newPasswordTab.setText(Messages.getString("PasswordDialog.NewPassword")); //$NON-NLS-1$
    newPasswordTab.setControl(newPasswordComposite);
}

From source file:org.codehaus.groovy.eclipse.dsl.inferencing.suggestions.ui.AbstractDialogue.java

License:Apache License

protected int getDefaultCompositeVMargin() {
    return convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
}

From source file:org.csstudio.auth.ui.dialogs.LoginDialog.java

License:Open Source License

/**
 * Creates the contents of this dialog./* w  w w  . j  ava  2s.  co m*/
 */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    setTitle(_title);
    setMessage(_message);

    // Create the layout
    Composite contents = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parent.getFont());

    // user name
    Label label = new Label(contents, SWT.NONE);
    label.setText(Messages.LoginDialog_UserName);
    _username = new Text(contents, SWT.BORDER | SWT.FLAT);

    _username.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _username.setText(_lastUser != null ? _lastUser : "");

    // password
    label = new Label(contents, SWT.NONE);
    label.setText(Messages.LoginDialog_Password);
    _password = new Text(contents, SWT.BORDER | SWT.FLAT | SWT.PASSWORD);
    _password.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    // Anonymous login checkbox
    _loginAnonymous = new Button(contents, SWT.CHECK);
    _loginAnonymous.setText(Messages.LoginDialog_LoginAnonymous);
    _loginAnonymous.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _loginAnonymous.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (_loginAnonymous.getSelection()) {
                // Disable name/password when anonymous
                _username.setEnabled(false);
                _password.setEnabled(false);
            } else {
                // (Re-)enable name/password entry
                _username.setEnabled(true);
                _password.setEnabled(true);
                // ... and jump to name field
                _username.setFocus();
            }
        }
    });

    // remember password checkbox (invisible by default)
    _rememberLogin = new Button(contents, SWT.CHECK);
    _rememberLogin.setText("Remember my user name and password");
    _rememberLogin.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _rememberLogin.setVisible(false);

    if (_lastUser != null && _lastUser.trim().length() > 0) {
        _password.setFocus();
    } else {
        _username.setFocus();
    }
    return parentComposite;
}

From source file:org.csstudio.auth.ui.internal.preferences.AddSubnetDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w ww.  j a  v  a 2  s . com*/
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    setTitle("Add Subnet");
    setMessage("Please enter the subnet address and netmask.");

    Composite contents = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 2;
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parentComposite.getFont());

    Label addressLabel = new Label(contents, SWT.NULL);
    addressLabel.setText("Subnet address:");
    _networkAddress = new Text(contents, SWT.SINGLE | SWT.BORDER);
    _networkAddress.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _networkAddress.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (e.widget == _networkAddress) {
                autocompleteNetmask();
                checkValid();
            }
        }
    });

    Label netmaskLabel = new Label(contents, SWT.NULL);
    netmaskLabel.setText("Subnet address:");
    _netmask = new Text(contents, SWT.SINGLE | SWT.BORDER);
    _netmask.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _netmask.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (e.widget == _netmask) {
                checkValid();
            }
        }
    });

    return contents;
}