Example usage for org.eclipse.jface.layout GridDataFactory indent

List of usage examples for org.eclipse.jface.layout GridDataFactory indent

Introduction

In this page you can find the example usage for org.eclipse.jface.layout GridDataFactory indent.

Prototype

public GridDataFactory indent(int hIndent, int vIndent) 

Source Link

Document

Sets the indent of the control within the cell.

Usage

From source file:com.amazonaws.eclipse.core.ui.setupwizard.ConfigureAccountWizardPage.java

License:Apache License

public void createControl(Composite parent) {
    parent.setLayout(new GridLayout());

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(450, 250));
    composite.setLayout(new GridLayout(2, false));
    setControl(composite);//from  w  w  w . ja v a2 s.  c  o m

    WebLinkListener linkListener = new WebLinkListener();
    GridDataFactory fullRowGridDataFactory = GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.TOP)
            .grab(true, false).span(2, 1);
    GridDataFactory firstColumnGridDataFactory = GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER);
    GridDataFactory secondColumnGridDataFactory = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP)
            .grab(true, false);

    Label label = new Label(composite, SWT.WRAP);
    label.setText("Before you can start using the toolkit, you need to configure an AWS account.");
    fullRowGridDataFactory.applyTo(label);

    Link link = new Link(composite, SWT.WRAP);
    link.addListener(SWT.Selection, linkListener);
    link.setText("Use your <a href=\"" + SECURITY_CREDENTIALS_URL + "\">existing credentials</a> or "
            + "<a href=\"" + CREATE_ACCOUNT_URL + "\">create a new AWS account</a>.");
    fullRowGridDataFactory.applyTo(link);

    // AWS Access Key ID row
    Label accessKeyLabel = new Label(composite, SWT.NONE);
    accessKeyLabel.setText("Access Key ID:");
    firstColumnGridDataFactory.copy().indent(10, 5).applyTo(accessKeyLabel);
    Text accessKeyText = new Text(composite, SWT.BORDER);
    secondColumnGridDataFactory.copy().indent(0, 5).applyTo(accessKeyText);
    accessKeyText.setFocus();

    IObservableValue accessKeyModelObservable = PojoObservables.observeValue(dataModel,
            dataModel.ACCESS_KEY_ID);
    bindingContext.bindValue(SWTObservables.observeText(accessKeyText, SWT.Modify), accessKeyModelObservable);
    bindingContext.addValidationStatusProvider(new ChainValidator<String>(accessKeyModelObservable,
            new NotEmptyValidator("Please provide an AWS Access Key ID")));

    // AWS Secret Key row
    Label secretKeyLabel = new Label(composite, SWT.NONE);
    secretKeyLabel.setText("Secret Access Key:");
    firstColumnGridDataFactory.copy().indent(10, 0).applyTo(secretKeyLabel);
    Text secretKeyText = new Text(composite, SWT.BORDER);
    secondColumnGridDataFactory.applyTo(secretKeyText);

    IObservableValue secretKeyModelObservable = PojoObservables.observeValue(dataModel,
            dataModel.SECRET_ACCESS_KEY);
    bindingContext.bindValue(SWTObservables.observeText(secretKeyText, SWT.Modify), secretKeyModelObservable);
    bindingContext.addValidationStatusProvider(new ChainValidator<String>(secretKeyModelObservable,
            new NotEmptyValidator("Please provide an AWS Secret Access Key")));

    // Open Explorer view row
    openExplorerCheckBox = new Button(composite, SWT.CHECK);
    openExplorerCheckBox.setText("Open the AWS Explorer view");
    openExplorerCheckBox.setSelection(true);
    fullRowGridDataFactory.indent(0, 5).applyTo(openExplorerCheckBox);
    bindingContext.bindValue(SWTObservables.observeSelection(openExplorerCheckBox),
            PojoObservables.observeValue(dataModel, dataModel.OPEN_EXPLORER));

    Composite spacer = new Composite(composite, SWT.NONE);
    spacer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1));

    link = new Link(composite, SWT.WRAP);
    link.addListener(SWT.Selection, linkListener);
    link.setText("For a full walkthrough of the features available in the AWS Toolkit for Eclipse, "
            + "see the <a href=\"" + GETTING_STARTED_GUIDE_URL
            + "\">AWS Toolkit for Eclipse Getting Started Guide</a>.");
    fullRowGridDataFactory.applyTo(link);

    aggregateValidationStatus.addChangeListener(new IChangeListener() {
        public void handleChange(ChangeEvent event) {
            Object value = aggregateValidationStatus.getValue();
            if (value instanceof IStatus == false)
                return;

            IStatus status = (IStatus) value;
            setPageComplete(status.isOK());
        }
    });

    setPageComplete(false);
    parent.getShell().pack(true);

    Rectangle workbenchBounds = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getBounds();
    Point dialogSize = this.getShell().getSize();

    this.getShell().setLocation(workbenchBounds.x + (workbenchBounds.width - dialogSize.x) / 2,
            workbenchBounds.y + (workbenchBounds.height - dialogSize.y) / 2);
}