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

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

Introduction

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

Prototype

int MINIMUM_MESSAGE_AREA_WIDTH

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

Click Source Link

Document

Minimum width of message area in dialog units (value 300).

Usage

From source file:com.ibm.research.tours.dialogs.TimeDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // create a composite with standard margins and spacing
    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);//from  w  w  w  .ja v  a  2 s  .  c  o  m
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    fTimeCheckButton = new Button(composite, SWT.CHECK);
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    fTimeCheckButton.setLayoutData(data);
    fTimeCheckButton.setText(fMessage);
    fTimeCheckButton.setSelection(fIsTimeSet);

    fTimeCheckButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            fIsTimeSet = fTimeCheckButton.getSelection();
            fMinuteSpinner.setEnabled(fIsTimeSet);
            fSecondSpinner.setEnabled(fIsTimeSet);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });

    Group timeGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
    GridLayout groupLayout = new GridLayout(4, false);
    timeGroup.setLayout(groupLayout);
    GridData timeGroupData = new GridData(GridData.FILL_BOTH);
    timeGroupData.horizontalSpan = 2;
    timeGroup.setLayoutData(timeGroupData);
    timeGroup.setText("Time Limit");

    Label minuteLabel = new Label(timeGroup, SWT.NONE);
    minuteLabel.setText("Minutes");
    fMinuteSpinner = new Spinner(timeGroup, SWT.BORDER);

    if (fTimeLimit != null)
        fMinuteSpinner.setSelection(fTimeLimit.getMinutes());

    fMinuteSpinner.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (fTimeLimit != null)
                fTimeLimit.setMinutes(fMinuteSpinner.getSelection());
        }
    });

    Label secondLabel = new Label(timeGroup, SWT.NONE);
    secondLabel.setText("Seconds");
    fSecondSpinner = new Spinner(timeGroup, SWT.BORDER);
    fSecondSpinner.setMaximum(60);

    if (fTimeLimit != null)
        fSecondSpinner.setSelection(fTimeLimit.getSeconds());

    fSecondSpinner.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (fTimeLimit != null)
                fTimeLimit.setSeconds(fSecondSpinner.getSelection());
        }
    });

    fMinuteSpinner.setEnabled(fIsTimeSet);
    fSecondSpinner.setEnabled(fIsTimeSet);

    return parent;
}

From source file:com.microsoft.tfs.client.common.ui.controls.generic.BaseControl.java

License:Open Source License

public BaseControl(final Composite parent, final int style) {
    super(parent, style);

    /* Compute metrics in pixels */
    final GC gc = new GC(this);
    final FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();//from w  ww . j a  v a 2 s.c om

    horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING);
    verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);

    spacing = Math.max(horizontalSpacing, verticalSpacing);

    horizontalMargin = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    verticalMargin = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);

    minimumMessageAreaWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.connect.CredentialsDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = getHorizontalMargin();
    layout.marginHeight = getVerticalMargin();
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing();
    dialogArea.setLayout(layout);// www .ja  v a 2 s  .  c  om

    if (errorMessage != null) {
        String profileMessage = ""; //$NON-NLS-1$

        if (serverURI != null) {
            final String subMessageFormat = Messages.getString("CredentialsDialog.EnterPasswordFormat"); //$NON-NLS-1$
            profileMessage = MessageFormat.format(subMessageFormat, serverURI.toString());
        }

        final String message = (serverURI == null) ? errorMessage : errorMessage + "\n\n" + profileMessage; //$NON-NLS-1$

        final ConnectionErrorControl errorControl = new ConnectionErrorControl(dialogArea, SWT.NONE);
        errorControl.setServerURI(serverURI);
        errorControl.setMessage(message);
        errorControl.setMessageWidthHint(
                convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH));
        GridDataBuilder.newInstance().hSpan(2).hGrab().hFill().applyTo(errorControl);

        final Label spacerLabel = new Label(dialogArea, SWT.NONE);
        spacerLabel.setText(""); //$NON-NLS-1$
        GridDataBuilder.newInstance().hSpan(2).applyTo(spacerLabel);
    } else {
        final String messageFormat = Messages.getString("CredentialsDialog.EnterPasswordFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, serverURI.toString());

        final Label promptLabel = new Label(dialogArea, SWT.NONE);
        promptLabel.setText(message);
        GridDataBuilder.newInstance().hSpan(2).hGrab().hFill()
                .wHint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH))
                .applyTo(promptLabel);

        final Label spacerLabel = new Label(dialogArea, SWT.NONE);
        spacerLabel.setText(""); //$NON-NLS-1$
        GridDataBuilder.newInstance().hSpan(2).applyTo(spacerLabel);
    }

    final Label usernameLabel = new Label(dialogArea, SWT.NONE);
    usernameLabel.setText(Messages.getString("CredentialsDialog.UserNameLabelText")); //$NON-NLS-1$

    usernameText = new Text(dialogArea, SWT.BORDER);
    AutomationIDHelper.setWidgetID(usernameText, USERNAME_TEXT_ID);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(usernameText);

    if (credentials != null && credentials instanceof UsernamePasswordCredentials) {
        final String username = ((UsernamePasswordCredentials) credentials).getUsername();

        usernameText.setText(username);
    }

    final Label passwordLabel = new Label(dialogArea, SWT.NONE);
    passwordLabel.setText(Messages.getString("CredentialsDialog.PasswordLabelText")); //$NON-NLS-1$

    passwordText = new Text(dialogArea, SWT.PASSWORD | SWT.BORDER);
    AutomationIDHelper.setWidgetID(passwordText, PASSWORD_TEXT_ID);
    GridDataBuilder.newInstance().hGrab().hFill().wCHint(passwordText, 16).applyTo(passwordText);

    if (allowSavePassword) {
        SWTUtil.createGridLayoutSpacer(dialogArea, 1, 1);

        savePasswordButton = new Button(dialogArea, SWT.CHECK);
        AutomationIDHelper.setWidgetID(savePasswordButton, SAVE_PASSWORD_BUTTON_ID);
        savePasswordButton.setText(Messages.getString("CredentialsDialog.SavePasswordButtonText")); //$NON-NLS-1$

        if (!CredentialsManagerFactory.getCredentialsManager(DefaultPersistenceStoreProvider.INSTANCE)
                .isSecure()) {
            savePasswordButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(final SelectionEvent e) {
                    toggleInsecureWarning();
                }
            });

            insecureComposite = dialogArea;
        }
    }

    if (alwaysSavePassword) {
        if (!CredentialsManagerFactory.getCredentialsManager(DefaultPersistenceStoreProvider.INSTANCE)
                .isSecure()) {
            insecureComposite = dialogArea;
            createInsecureWarning();
        }

        if (credentials != null && credentials instanceof UsernamePasswordCredentials) {
            final String password = ((UsernamePasswordCredentials) credentials).getPassword();

            if (password != null && password.length() > 0) {
                passwordText.setText(password);
            }
        }
    }

    if (usernameText.getText().length() > 0) {
        passwordText.setFocus();
    }
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.connect.CredentialsDialog.java

License:Open Source License

private void createInsecureWarning() {
    insecureSaveSpacer = new Label(insecureComposite, SWT.NONE);
    GridDataBuilder.newInstance().hSpan(2).applyTo(insecureSaveSpacer);

    insecureSaveImageLabel = new Label(insecureComposite, SWT.NONE);
    insecureSaveImageLabel/*from   w  ww. ja v a  2s  .  c o  m*/
            .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    GridDataBuilder.newInstance().hAlign(SWT.RIGHT).vAlign(SWT.TOP).applyTo(insecureSaveImageLabel);

    insecureSaveTextLabel = new Label(insecureComposite, SWT.WRAP);
    insecureSaveTextLabel.setText(Messages.getString("CredentialsDialog.InsecureStorageWarning")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().align(SWT.FILL, SWT.BEGINNING).hGrab()
            .wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH).applyTo(insecureSaveTextLabel);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.BranchBranchDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    final GridLayout layout = new GridLayout(3, false);
    layout.marginWidth = getHorizontalMargin();
    layout.marginHeight = getVerticalMargin();
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing();
    dialogArea.setLayout(layout);//from w  ww  . j a  v  a  2s .c  o m

    final Label sourceNameLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("BranchBranchDialog.SourceNameLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hSpan(layout).hFill().hGrab().applyTo(sourceNameLabel);

    sourceText = new Text(dialogArea, SWT.READ_ONLY | SWT.BORDER);
    GridDataBuilder.newInstance().hSpan(layout).hFill().applyTo(sourceText);
    sourceText.setText(branchFromPath);

    final Label branchFromLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("BranchBranchDialog.BranchFromLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hSpan(layout).hFill().hGrab().applyTo(branchFromLabel);

    versionDropdownWidget = new VersionPickerControl(dialogArea, SWT.NONE);
    GridDataBuilder.newInstance().hSpan(layout).hFill().hGrab().applyTo(versionDropdownWidget);
    versionDropdownWidget.setText(Messages.getString("BranchBranchDialog.VersionPickerLabelText")); //$NON-NLS-1$
    versionDropdownWidget.setRepository(repository);
    versionDropdownWidget.setVersionSpec(LatestVersionSpec.INSTANCE);

    final Label targetNameLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("BranchBranchDialog.TargetNameLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hSpan(layout).hFill().hGrab().applyTo(targetNameLabel);
    targetText = new Text(dialogArea, SWT.BORDER);
    GridDataBuilder.newInstance().hSpan(2).hFill().hGrab().applyTo(targetText);
    targetText.setText(branchToPath);
    targetText.setSelection(ServerPath.getParent(targetText.getText()).length() + 1,
            targetText.getText().length());
    targetText.forceFocus();

    final Button browseButton = new Button(dialogArea, SWT.NONE);
    browseButton.setText(Messages.getString("BranchBranchDialog.BrowseButtonText")); //$NON-NLS-1$
    browseButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            browseClicked();
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            browseClicked();
        }
    });

    final Label descriptionLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("BranchBranchDialog.DescriptionLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hSpan(layout).hGrab().hFill().applyTo(descriptionLabel);

    descriptionText = new Text(dialogArea, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
    GridDataBuilder.newInstance().hSpan(layout).grab().fill().applyTo(descriptionText);
    descriptionText.setText(Messages.getString("BranchBranchDialog.BranchedFromTexboxText") + branchFromPath); //$NON-NLS-1$
    ControlSize.setCharSizeHints(descriptionText, 80, 10);

    final Label infoImage = SWTUtil.createLabel(dialogArea, imageHelper.getImage("images/vc/info.gif")); //$NON-NLS-1$
    GridDataBuilder.newInstance().vAlignTop().applyTo(infoImage);

    final Label infoText = SWTUtil.createLabel(dialogArea, SWT.WRAP,
            Messages.getString("BranchBranchDialog.InfoLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().align(SWT.FILL, SWT.BEGINNING).hGrab()
            .wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH).hSpan(2).applyTo(infoText);

}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.SelectFilesWizardPage.java

License:Open Source License

@Override
public void doCreateControl(final Composite parent, final IDialogSettings dialogSettings) {
    final SizeConstrainedComposite container = new SizeConstrainedComposite(parent, SWT.NONE);
    container.setDefaultSize(SWT.DEFAULT, SWT.DEFAULT);
    setControl(container);//from  ww  w  .j av a2s.c o m

    final GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = getHorizontalMargin();
    layout.marginHeight = getVerticalMargin();
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing() - 2;
    container.setLayout(layout);

    setControl(container);

    copyNeededLabel = new Label(container, SWT.WRAP);
    GridDataBuilder.newInstance().hSpan(2).hFill().hGrab().wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH)
            .applyTo(copyNeededLabel);

    final Label addSelectedFilesLabel = new Label(container, SWT.WRAP);
    addSelectedFilesLabel.setText(Messages.getString("SelectFilesWizardPage.ExcludeItemsLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().hSpan(2).hFill().hGrab().wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH)
            .applyTo(addSelectedFilesLabel);

    final Table table = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.MULTI);
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    GridDataBuilder.newInstance().hFill().hHint(200).hGrab().hSpan(2).applyTo(table);

    tableLayout.addColumnData(new ColumnWeightData(40, 20, true));
    final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE);
    nameTableColumn.setText(Messages.getString("SelectFilesWizardPage.ColumnNameName")); //$NON-NLS-1$

    tableLayout.addColumnData(new ColumnWeightData(60, 30, true));
    final TableColumn folderTableColumn = new TableColumn(table, SWT.NONE);
    folderTableColumn.setText(Messages.getString("SelectFilesWizardPage.ColumnNameFolder")); //$NON-NLS-1$

    table.setLinesVisible(true);
    table.setHeaderVisible(true);

    tableViewer = new CheckboxTableViewer(table);
    tableViewer.setContentProvider(new GenericElementsContentProvider());
    tableViewer.setLabelProvider(new AddFilesDialogLabelProvider());
    tableViewer.setSorter(new ViewerSorter());
    tableViewer.setInput(files);

    // If files are pre-populated, then select all items
    if (files.size() > 0) {
        tableViewer.setCheckedElements(files.toArray());
    }

    tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            toggleFinishState();
        }
    });

    ControlSize.setCharSizeHints(table, 15, 10);

    final Label excludeLabel = new Label(container, SWT.NONE);
    excludeLabel.setText(Messages.getString("SelectFilesWizardPage.ExcludeLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().applyTo(excludeLabel);

    final Text excludeText = new Text(container, SWT.BORDER);
    AutomationIDHelper.setWidgetID(excludeText, EXCLUDE_TEXT_ID);
    GridDataBuilder.newInstance().hFill().applyTo(excludeText);

    SWTUtil.createGridLayoutSpacer(container);

    final Label exampleLabel = new Label(container, SWT.NONE);
    exampleLabel.setText(Messages.getString("SelectFilesWizardPage.ExampleLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().applyTo(exampleLabel);

    excludeText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            excludes = excludeText.getText();
            updateTable();
        }
    });

    final Label label = new Label(container, SWT.WRAP);
    label.setText(Messages.getString("SelectFilesWizardPage.DestinationServerPathText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().applyTo(label);

    serverPathText = new Text(container, SWT.BORDER);
    serverPathText.setEditable(false);
    GridDataBuilder.newInstance().hFill().hGrab().applyTo(serverPathText);
}

From source file:com.microsoft.tfs.client.common.ui.framework.dialog.BaseDialog.java

License:Open Source License

/**
 * This method will return the "minimum message area width" (in pixels) for
 * dialogs on this platform. This number is typically better used as a
 * default width for shells./*  w w w. j a va2s  .  co m*/
 *
 * @return Width of the minimum message area in a shell
 */
public int getMinimumMessageAreaWidth() {
    return convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
}

From source file:com.microsoft.tfs.client.common.ui.framework.table.tooltip.TableTooltipManager.java

License:Open Source License

protected Point getTooltipSize(final Shell tooltipShell) {
    if (maxTooltipSize == null) {
        final GC gc = new GC(tooltipShell);

        final int max = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(),
                IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        maxTooltipSize = new Point(max, max);

        gc.dispose();//from ww w .j  a va 2  s  .  co m
    }

    Point tooltipSize = tooltipShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    if (tooltipSize.x > maxTooltipSize.x) {
        tooltipSize = tooltipShell.computeSize(maxTooltipSize.x, SWT.DEFAULT);
    }
    if (tooltipSize.y > maxTooltipSize.y) {
        tooltipSize = tooltipShell.computeSize(maxTooltipSize.x, maxTooltipSize.y);
    }

    return tooltipSize;
}

From source file:com.microsoft.tfs.client.common.ui.teambuild.dialogs.DeleteOptionsDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    this.getShell().setMinimumSize(600, 200);
    final GridLayout layout = SWTUtil.gridLayout(dialogArea);
    layout.marginWidth = getHorizontalMargin();
    layout.marginHeight = getVerticalMargin();
    layout.verticalSpacing = 10;//  www . j  a  va 2  s  .com

    Label label = new Label(dialogArea, SWT.NONE);
    label.setText(getDescriptionText());
    GridDataBuilder.newInstance().applyTo(label);

    final FontData[] fontData = label.getFont().getFontData();
    fontData[0].setStyle(SWT.BOLD);
    final Font boldFont = new Font(label.getFont().getDevice(), fontData[0]);
    detailsCheckbox = new Button(dialogArea, SWT.CHECK);
    detailsCheckbox.setText(detailsButtonLabel());
    detailsCheckbox.setFont(boldFont);
    GridDataBuilder.newInstance().applyTo(detailsCheckbox);

    final GridDataBuilder labelGridDataBuilder = GridDataBuilder.newInstance().hIndent(24).hFill().hGrab()
            .wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.getString("DeleteOptionsDialog.DetailsButtonTooltipText")); //$NON-NLS-1$
    labelGridDataBuilder.applyTo(label);

    if (isDetailsDefault()) {
        detailsCheckbox.setEnabled(false);
        label.setEnabled(false);
    }

    dropCheckbox = new Button(dialogArea, SWT.CHECK);
    dropCheckbox.setText(Messages.getString("DeleteOptionsDialog.DropButtonLabel")); //$NON-NLS-1$
    dropCheckbox.setFont(boldFont);
    GridDataBuilder.newInstance().applyTo(dropCheckbox);

    label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.getString("DeleteOptionsDialog.DropButtonTooltipText")); //$NON-NLS-1$
    labelGridDataBuilder.applyTo(label);

    testResultsCheckbox = new Button(dialogArea, SWT.CHECK);
    testResultsCheckbox.setText(Messages.getString("DeleteOptionsDialog.TestResultsButtonLabel")); //$NON-NLS-1$
    testResultsCheckbox.setFont(boldFont);
    GridDataBuilder.newInstance().applyTo(detailsCheckbox);

    label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.getString("DeleteOptionsDialog.TestResultsButtonTooltipText")); //$NON-NLS-1$
    labelGridDataBuilder.applyTo(label);

    labelCheckbox = new Button(dialogArea, SWT.CHECK);
    labelCheckbox.setText(Messages.getString("DeleteOptionsDialog.LabelButtonLabel")); //$NON-NLS-1$
    labelCheckbox.setFont(boldFont);
    GridDataBuilder.newInstance().applyTo(detailsCheckbox);

    label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.getString("DeleteOptionsDialog.LabelButtonTooltipText")); //$NON-NLS-1$
    labelGridDataBuilder.applyTo(label);

    symbolsCheckbox = new Button(dialogArea, SWT.CHECK);
    symbolsCheckbox.setText(Messages.getString("DeleteOptionsDialog.SymbolsButtonLabel")); //$NON-NLS-1$
    symbolsCheckbox.setFont(boldFont);
    GridDataBuilder.newInstance().applyTo(detailsCheckbox);

    label = new Label(dialogArea, SWT.WRAP);
    label.setText(Messages.getString("DeleteOptionsDialog.SymbolsButtonTooltipText")); //$NON-NLS-1$
    labelGridDataBuilder.applyTo(label);

    attachSelectionListener(detailsCheckbox);
    attachSelectionListener(dropCheckbox);
    attachSelectionListener(testResultsCheckbox);
    attachSelectionListener(labelCheckbox);
    attachSelectionListener(symbolsCheckbox);

    dialogArea.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent arg0) {
            boldFont.dispose();
        }
    });

    if (!isV3OrGreater) {
        detailsCheckbox.setSelection(true);
        dropCheckbox.setSelection(true);
        testResultsCheckbox.setSelection(true);
        labelCheckbox.setSelection(true);
        symbolsCheckbox.setSelection(true);
        disableComposite(dialogArea);
    } else {
        setSelections();
    }
}

From source file:com.microsoft.tfs.client.common.ui.teambuild.dialogs.QueueBuildDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    GridLayout layout = SWTUtil.gridLayout(dialogArea, 3);
    layout.marginWidth = getHorizontalMargin();
    layout.marginHeight = getVerticalMargin();
    layout.horizontalSpacing = getHorizontalSpacing();
    layout.verticalSpacing = getVerticalSpacing();

    if (image != null) {
        final Label imageLabel = new Label(dialogArea, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);//from  ww  w  .  j av  a 2  s  .c  o  m

        GridDataBuilder.newInstance().fill().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }

    final Label messageLabel = new Label(dialogArea, SWT.WRAP);
    messageLabel.setText(Messages.getString("QueueBuildDialog.MessageLabelText")); //$NON-NLS-1$

    GridDataBuilder.newInstance().fill().align(SWT.FILL, SWT.BEGINNING).hGrab()
            .wHint(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH).hSpan(2).applyTo(messageLabel);

    SWTUtil.createLabel(dialogArea, ""); //$NON-NLS-1$
    SWTUtil.createLabel(dialogArea, ""); //$NON-NLS-1$
    SWTUtil.createLabel(dialogArea, ""); //$NON-NLS-1$

    final Label buildDefLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("QueueBuildDialog.BuildDefinitionLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buildDefLabel);

    buildDefinitionCombo = new Combo(dialogArea, SWT.READ_ONLY);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buildDefinitionCombo);
    AutomationIDHelper.setWidgetID(buildDefinitionCombo, BUILDDEF_COMBO_ID);
    buildDefinitionCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Combo combo = (Combo) e.widget;
            final int ix = combo.getSelectionIndex();
            newBuildDefinitionSelected(ix);
            enableControls();
        }
    });

    descriptionText = new Text(dialogArea, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP);
    GridDataBuilder.newInstance().fill().grab().hSpan(3).applyTo(descriptionText);
    ControlSize.setCharHeightHint(descriptionText, 2);
    AutomationIDHelper.setWidgetID(descriptionText, DESCRIPTION_TEXT_ID);

    final String buddyLabelText = Messages.getString("QueueBuildDialog.BuddyBuildLabelText"); //$NON-NLS-1$
    final Label buddyBuildLabel = SWTUtil.createLabel(dialogArea, buddyLabelText);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buddyBuildLabel);

    buddyBuildCombo = new Combo(dialogArea, SWT.READ_ONLY);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buddyBuildCombo);
    AutomationIDHelper.setWidgetID(buddyBuildCombo, BUDDY_BUILD_COMBO_ID);

    buddyBuildCombo.add(Messages.getString("QueueBuildDialog.LatestSourcesComboChoice")); //$NON-NLS-1$
    buddyBuildCombo.add(Messages.getString("QueueBuildDialog.LatestSourcesWithShelveComboChoice")); //$NON-NLS-1$
    buddyBuildCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            enableControls();
        }
    });

    if (!buildServer.getBuildServerVersion().isV3OrGreater()
            || !BuildSourceProviders.isTfVersionControl(selectedBuildDefinition.getDefaultSourceProvider())) {
        buddyBuildCombo.select(0);
        buddyBuildCombo.setEnabled(false);
    } else {
        shelvesetComposite = new Composite(dialogArea, SWT.NONE);
        GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(shelvesetComposite);
        layout = SWTUtil.gridLayout(shelvesetComposite, 3);
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.horizontalSpacing = getHorizontalSpacing();
        layout.verticalSpacing = getVerticalSpacing();

        final String shelvesetLabelText = Messages.getString("QueueBuildDialog.ShelvesetLabelText"); //$NON-NLS-1$
        shelvesetLabel = SWTUtil.createLabel(shelvesetComposite, shelvesetLabelText);
        GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(shelvesetLabel);
        AutomationIDHelper.setWidgetID(shelvesetLabel, SHELVESET_NAME_LABEL_ID);

        shelvesetNameText = new Text(shelvesetComposite, SWT.BORDER);
        GridDataBuilder.newInstance().hFill().hGrab().applyTo(shelvesetNameText);
        AutomationIDHelper.setWidgetID(shelvesetNameText, SHELVESET_TEXT_ID);

        findShelvesetButton = new Button(shelvesetComposite, SWT.PUSH);
        findShelvesetButton.setText(Messages.getString("QueueBuildDialog.FindShelveButtonText")); //$NON-NLS-1$
        GridDataBuilder.newInstance().applyTo(findShelvesetButton);
        findShelvesetButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                findShelveset();
            }
        });
        AutomationIDHelper.setWidgetID(findShelvesetButton, FIND_SHELVESET_BUTTON_ID);

        createShelvesetButton = new Button(shelvesetComposite, SWT.PUSH);
        createShelvesetButton.setText(Messages.getString("QueueBuildDialog.CreateShelveButtonText")); //$NON-NLS-1$
        GridDataBuilder.newInstance().applyTo(createShelvesetButton);
        createShelvesetButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                createShelveset();
            }
        });
        AutomationIDHelper.setWidgetID(createShelvesetButton, CREATE_SHELVESET_BUTTON_ID);

        checkinAfterSuccessButton = new Button(shelvesetComposite, SWT.CHECK);
        checkinAfterSuccessButton.setText(Messages.getString("QueueBuildDialog.CheckinAfterSuccessButtonText")); //$NON-NLS-1$
        GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(checkinAfterSuccessButton);
        checkinAfterSuccessButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                enableControls();
            }
        });
        AutomationIDHelper.setWidgetID(checkinAfterSuccessButton, CHECKIN_AFTER_SUCCESS_BUTTON_ID);
    }

    final String controllerLabel = buildServer.getBuildServerVersion().isLessThanV3()
            ? Messages.getString("QueueBuildDialog.BuildAgentLabelText") //$NON-NLS-1$
            : Messages.getString("QueueBuildDialog.BuildControllerLabelText"); //$NON-NLS-1$

    final Label buildAgentLabel = SWTUtil.createLabel(dialogArea, controllerLabel);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buildAgentLabel);

    buildControllerCombo = new Combo(dialogArea, SWT.READ_ONLY);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(buildControllerCombo);
    AutomationIDHelper.setWidgetID(buildControllerCombo, CONTROLLER_COMBO_ID);
    buildControllerCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            final int selection = buildControllerCombo.getSelectionIndex();

            if (selection >= 0 && selection < buildControllers.length) {
                selectedBuildController = buildControllers[selection];
            } else {
                selectedBuildController = null;
            }

            calculatePosition();
            enableControls();
        }
    });

    final Label dropFolderLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("QueueBuildDialog.DropFolderLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(dropFolderLabel);

    dropText = new Text(dialogArea, SWT.BORDER);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(dropText);
    AutomationIDHelper.setWidgetID(dropText, DROP_LOCATION_TEXT_ID);

    final Label queueLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("QueueBuildDialog.PriorityLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().hGrab().hSpan(2).applyTo(queueLabel);

    SWTUtil.createLabel(dialogArea, Messages.getString("QueueBuildDialog.PositionLabelText")); //$NON-NLS-1$

    priority = new Combo(dialogArea, SWT.READ_ONLY);
    GridDataBuilder.newInstance().fill().hGrab().hSpan(2).applyTo(priority);
    AutomationIDHelper.setWidgetID(priority, PRIORITY_COMBO_ID);
    priority.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            calculatePosition();
        }
    });

    position = new Text(dialogArea, SWT.BORDER | SWT.READ_ONLY);
    GridDataBuilder.newInstance().fill().applyTo(position);
    ControlSize.setCharWidthHint(position, 20);
    AutomationIDHelper.setWidgetID(position, QUEUE_POSITION_TEXT_ID);

    final Label commandArgsLabel = SWTUtil.createLabel(dialogArea,
            Messages.getString("QueueBuildDialog.CommandArgsLabelText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().fill().hGrab().hSpan(3).applyTo(commandArgsLabel);

    commandLineArgs = new Text(dialogArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
    AutomationIDHelper.setWidgetID(commandLineArgs, COMMAND_ARGS_TEXT_ID);
    commandLineArgs.addTraverseListener(new TraverseListener() {
        @Override
        public void keyTraversed(final TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = true;
            }
        }
    });
    GridDataBuilder.newInstance().fill().grab().hSpan(3).applyTo(commandLineArgs);
    ControlSize.setCharHeightHint(commandLineArgs, 2);

    if (buildServer.getBuildServerVersion().isV1()) {
        buildControllerCombo.setEnabled(false);
        dropText.setEnabled(false);
        priority.setEnabled(false);
        position.setEnabled(false);
        commandLineArgs.setEnabled(false);
    }

    // populate drop downs.
    loadBuildControllers();
    loadQueuePriorities();
    final int selectedIndex = loadBuildDefinitions();

    // Populate with default values.
    newBuildDefinitionSelected(selectedIndex);
    enableControls();
}