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

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

Introduction

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

Prototype

int HORIZONTAL_SPACING

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

Click Source Link

Document

Horizontal spacing in dialog units (value 4).

Usage

From source file:org.eclipse.team.svn.ui.dialog.AdvancedDialog.java

License:Open Source License

protected Control createExtendedButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size.//w  w w. j av a2 s .  c o m
    GridLayout layout = new GridLayout();
    layout.numColumns = 0; // this is incremented by createButton
    layout.makeColumnsEqualWidth = true;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setFont(parent.getFont());
    // Add the buttons to the left button bar.
    this.createButtonsForExtendedButtonBar(composite);
    return composite;
}

From source file:org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.TimeGraphFilterDialog.java

License:Open Source License

/**
 * Adds the selection and deselection buttons to the dialog.
 *
 * @param composite//from  www  .java  2  s . co  m
 *            the parent composite
 * @return Composite the composite the buttons were created in.
 */
protected Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    buttonComposite.setLayoutData(data);

    /* Create the buttons in the good order to place them as we want */
    Button checkSelectedButton = createButton(buttonComposite, BUTTON_CHECK_SELECTED_ID,
            Messages.TmfTimeFilterDialog_CHECK_SELECTED, false);
    Button checkSubtreeButton = createButton(buttonComposite, BUTTON_CHECK_SUBTREE_ID,
            Messages.TmfTimeFilterDialog_CHECK_SUBTREE, false);
    Button checkAllButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            Messages.TmfTimeFilterDialog_CHECK_ALL, false);
    Button checkActiveButton = null;
    if (fCheckActiveProvider != null) {
        checkActiveButton = createButton(buttonComposite, BUTTON_CHECK_ACTIVE_ID,
                fCheckActiveProvider.getLabel(), false);
        checkActiveButton.setToolTipText(fCheckActiveProvider.getTooltip());
    } else if (fUncheckInactiveProvider != null) {
        // Filler label to ensure correct layout.
        Label filler = new Label(buttonComposite, 0);
        filler.setText(""); //$NON-NLS-1$
    }

    Button uncheckSelectedButton = createButton(buttonComposite, BUTTON_UNCHECK_SELECTED_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_SELECTED, false);
    Button uncheckSubtreeButton = createButton(buttonComposite, BUTTON_UNCHECK_SUBTREE_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_SUBTREE, false);
    Button uncheckAllButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            Messages.TmfTimeFilterDialog_UNCHECK_ALL, false);
    Button uncheckInactiveButton = null;
    if (fUncheckInactiveProvider != null) {
        uncheckInactiveButton = createButton(buttonComposite, BUTTON_UNCHECK_INACTIVE_ID,
                fUncheckInactiveProvider.getLabel(), false);
        uncheckInactiveButton.setToolTipText(fUncheckInactiveProvider.getTooltip());
    }

    /*
     * Apply the layout again after creating the buttons to override
     * createButton messing with the columns
     */
    layout.numColumns = 3;
    if (fCheckActiveProvider != null || fUncheckInactiveProvider != null) {
        layout.numColumns++;
    }
    buttonComposite.setLayout(layout);

    /* Add a listener to each button */
    checkSelectedButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection();

            for (Object element : selection.toArray()) {
                checkElement(element);
            }

            updateOKStatus();
        }
    });

    checkSubtreeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection();

            for (Object element : selection.toArray()) {
                checkElementAndSubtree(element);
            }
        }
    });

    checkAllButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);

            for (int i = 0; i < viewerElements.length; i++) {
                fTree.setSubtreeChecked(viewerElements[i], true);
            }

            updateOKStatus();
        }
    });

    if (checkActiveButton != null) {
        checkActiveButton.addSelectionListener(new CheckActiveSelectionAdapter(true));
    }

    uncheckSelectedButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection();

            for (Object element : selection.toArray()) {
                uncheckElement(element);
            }

            updateOKStatus();
        }
    });

    uncheckSubtreeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            TreeSelection selection = (TreeSelection) fTree.getViewer().getSelection();

            for (Object element : selection.toArray()) {
                uncheckElement(element);
            }

            updateOKStatus();
        }
    });

    uncheckAllButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);
            for (Object element : viewerElements) {
                if (fTree.getViewer().testFindItem(element) != null) {
                    // uncheck only visible roots and their children
                    uncheckElement(element);
                }
            }
            updateOKStatus();
        }
    });

    if (uncheckInactiveButton != null) {
        uncheckInactiveButton.addSelectionListener(new CheckActiveSelectionAdapter(false));
    }

    return buttonComposite;
}

From source file:org.eclipse.ui.activities.ActivitiesPreferencePage.java

License:Open Source License

protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);//  w  w  w  .j  av  a2 s  .c  om

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);

    createActivityPromptPref(composite);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    activityPromptButton.setLayoutData(data);

    data = new GridData(GridData.FILL_BOTH);
    workingCopy = workbench.getActivitySupport().createWorkingCopy();
    enabler = new ActivityEnabler(workingCopy, strings);
    enabler.createControl(composite).setLayoutData(data);

    Dialog.applyDialogFont(composite);

    return composite;
}

From source file:org.eclipse.ui.activities.ActivityCategoryPreferencePage.java

License:Open Source License

protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);//from   www . j  a v a  2 s . c  o m

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.WRAP);
    label.setText(
            strings.getProperty(CAPTION_MESSAGE, ActivityMessages.ActivitiesPreferencePage_captionMessage));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = 400;
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    label = new Label(composite, SWT.NONE); //spacer
    data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    createPromptButton(composite);
    createCategoryArea(composite);
    createDetailsArea(composite);
    createButtons(composite);

    workbench.getHelpSystem().setHelp(parent, IWorkbenchHelpContextIds.CAPABILITY_PREFERENCE_PAGE);

    Dialog.applyDialogFont(composite);

    return composite;
}

From source file:org.eclipse.ui.activities.ActivityCategoryPreferencePage.java

License:Open Source License

private void createButtons(final Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(4, false);
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);/* w  ww.ja  v a2 s .c om*/
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);

    Button enableAll = new Button(composite, SWT.PUSH);
    enableAll.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            workingCopy.setEnabledActivityIds(workingCopy.getDefinedActivityIds());
        }
    });
    enableAll.setText(ActivityMessages.ActivityEnabler_selectAll);
    setButtonLayoutData(enableAll);

    Button disableAll = new Button(composite, SWT.PUSH);
    disableAll.addSelectionListener(new SelectionAdapter() {
        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            workingCopy.setEnabledActivityIds(Collections.EMPTY_SET);
        }
    });
    disableAll.setText(ActivityMessages.ActivityEnabler_deselectAll);
    setButtonLayoutData(disableAll);

    if (allowAdvanced) {
        Label spacer = new Label(composite, SWT.NONE);
        data = new GridData(GridData.GRAB_HORIZONTAL);
        spacer.setLayoutData(data);
        advancedButton = new Button(composite, SWT.PUSH);
        advancedButton.addSelectionListener(new SelectionAdapter() {

            /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            public void widgetSelected(SelectionEvent e) {
                AdvancedDialog dialog = new AdvancedDialog(parent.getShell());
                dialog.open(); // logic for updating the working copy is in the dialog class.                    
            }
        });
        advancedButton.setText(ActivityMessages.ActivitiesPreferencePage_advancedButton);
        setButtonLayoutData(advancedButton);
    }
}

From source file:org.eclipse.ui.activities.ActivityCategoryPreferencePage.java

License:Open Source License

/**
 * @param parent//from   w ww . j av  a 2s.  c  o  m
 */
private void createDetailsArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    new Label(composite, SWT.NONE).setText(ActivityMessages.ActivityEnabler_description);
    descriptionText = new Text(composite, SWT.WRAP | SWT.READ_ONLY | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 100;
    data.widthHint = 200;
    descriptionText.setLayoutData(data);

    new Label(composite, SWT.NONE).setText(ActivityMessages.ActivitiesPreferencePage_requirements);
    dependantViewer = new TableViewer(composite, SWT.BORDER);
    dependantViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    dependantViewer.setContentProvider(new CategoryContentProvider());
    dependantViewer.addFilter(new EmptyCategoryFilter());
    dependantViewer.setLabelProvider(new CategoryLabelProvider(false));
    dependantViewer.setInput(Collections.EMPTY_SET);
}

From source file:org.eclipse.ui.activities.ActivityCategoryPreferencePage.java

License:Open Source License

/**
 * @param parent/*from   w  ww .ja va 2s .  c  o  m*/
 */
private void createCategoryArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 200;
    composite.setLayoutData(data);
    Label label = new Label(composite, SWT.NONE);
    label.setText(strings.getProperty(CATEGORY_NAME, ActivityMessages.ActivityEnabler_categories) + ':');
    Table table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE);
    table.addSelectionListener(new SelectionAdapter() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                TableItem tableItem = (TableItem) e.item;

                ICategory category = (ICategory) tableItem.getData();
                if (isLocked(category)) {
                    tableItem.setChecked(true);
                    e.doit = false; // veto the check
                    return;
                }
                Set activitySet = WorkbenchActivityHelper.getActivityIdsForCategory(category);
                if (tableItem.getChecked()) {
                    activitySet.addAll(workingCopy.getEnabledActivityIds());
                } else {
                    HashSet newSet = new HashSet(workingCopy.getEnabledActivityIds());
                    newSet.removeAll(activitySet);
                    activitySet = newSet;
                }

                workingCopy.setEnabledActivityIds(activitySet);
                updateCategoryCheckState(); // even though we're reacting to
                // a check change we may need to
                // refresh a greying change.
                // Just process the whole thing.
            }
        }
    });
    categoryViewer = new CheckboxTableViewer(table);
    categoryViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    categoryViewer.setContentProvider(new CategoryContentProvider());
    CategoryLabelProvider categoryLabelProvider = new CategoryLabelProvider(true);
    workingCopy.addActivityManagerListener(categoryLabelProvider);
    categoryViewer.setLabelProvider(categoryLabelProvider);
    categoryViewer.setComparator(new ViewerComparator());
    categoryViewer.addFilter(new EmptyCategoryFilter());

    categoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
         */
        public void selectionChanged(SelectionChangedEvent event) {
            ICategory element = (ICategory) ((IStructuredSelection) event.getSelection()).getFirstElement();
            setDetails(element);
        }
    });
    categoryViewer.setInput(workingCopy.getDefinedCategoryIds());

    updateCategoryCheckState();
}

From source file:org.eclipse.ui.dialogs.CheckedTreeSelectionDialog.java

License:Open Source License

/**
 * Adds the selection and deselection buttons to the dialog.
 * /*from  ww w.jav a2 s.c  o  m*/
 * @param composite
 *            the parent composite
 * @return Composite the composite the buttons were created in.
 */
protected Composite createSelectionButtons(Composite composite) {
    Composite buttonComposite = new Composite(composite, SWT.RIGHT);
    GridLayout layout = new GridLayout();
    layout.numColumns = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonComposite.setLayout(layout);
    buttonComposite.setFont(composite.getFont());
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    buttonComposite.setLayoutData(data);
    Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID,
            WorkbenchMessages.CheckedTreeSelectionDialog_select_all, false);
    SelectionListener listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Object[] viewerElements = fContentProvider.getElements(fInput);
            if (fContainerMode) {
                fViewer.setCheckedElements(viewerElements);
            } else {
                for (int i = 0; i < viewerElements.length; i++) {
                    fViewer.setSubtreeChecked(viewerElements[i], true);
                }
            }
            updateOKStatus();
        }
    };
    selectButton.addSelectionListener(listener);
    Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID,
            WorkbenchMessages.CheckedTreeSelectionDialog_deselect_all, false);
    listener = new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            fViewer.setCheckedElements(new Object[0]);
            updateOKStatus();
        }
    };
    deselectButton.addSelectionListener(listener);
    return buttonComposite;
}

From source file:org.eclipse.ui.examples.fieldassist.FieldAssistTestDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {

    Composite outer = (Composite) super.createDialogArea(parent);

    initializeDialogUnits(outer);/* w  w  w  . ja va2  s . c o m*/
    createSecurityGroup(outer);

    // Create a simple field to show how field assist can be used for
    // autocomplete.
    Group autoComplete = new Group(outer, SWT.NONE);
    autoComplete.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    autoComplete.setLayout(layout);
    autoComplete.setText(TaskAssistExampleMessages.ExampleDialog_AutoCompleteGroup);

    Label label = new Label(autoComplete, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_UserName);

    // Create an auto-complete field representing a user name
    Text text = new Text(autoComplete, SWT.BORDER);
    text.setLayoutData(getFieldGridData());
    new AutoCompleteField(text, new TextContentAdapter(), validUsers);

    // Another one to test combos
    label = new Label(autoComplete, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_ComboUserName);

    Combo combo = new Combo(autoComplete, SWT.BORDER | SWT.DROP_DOWN);
    combo.setText(username);
    combo.setItems(validUsers);
    combo.setLayoutData(getFieldGridData());
    new AutoCompleteField(combo, new ComboContentAdapter(), validUsers);

    Dialog.applyDialogFont(outer);

    return outer;
}

From source file:org.eclipse.ui.examples.fieldassist.FieldAssistTestDialog.java

License:Open Source License

void createSecurityGroup(Composite parent) {

    Group main = new Group(parent, SWT.NONE);
    main.setLayoutData(new GridData(GridData.FILL_BOTH));
    main.setText(TaskAssistExampleMessages.ExampleDialog_SecurityGroup);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from   w  ww.  jav  a2  s.  c o  m
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    main.setLayout(layout);

    Label label = new Label(main, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_UserName);

    // Create a field representing a user name
    Text text = new Text(main, SWT.BORDER);
    ControlDecoration dec = new ControlDecoration(text, getDecorationLocationBits());
    dec.setMarginWidth(marginWidth);
    dec.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openInformation(getShell(), TaskAssistExampleMessages.ExampleDialog_SelectionTitle,
                    TaskAssistExampleMessages.ExampleDialog_SelectionMessage);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            // Nothing on default select
        }
    });

    textField = new UserField(dec, text, new TextContentAdapter());
    dec.addMenuDetectListener(new MenuDetectListener() {
        public void menuDetected(MenuDetectEvent event) {
            // no quick fix if we aren't in error state.
            if (textField.isValid()) {
                return;
            }
            if (textField.quickFixMenu == null) {
                textField.quickFixMenu = createQuickFixMenu(textField);
            }
            textField.quickFixMenu.setLocation(event.x, event.y);
            textField.quickFixMenu.setVisible(true);
        }
    });
    if (showRequiredFieldLabelIndicator && textField.isRequiredField()) {
        addRequiredFieldIndicator(label);
    }
    text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            handleModify(textField);
        }
    });

    text.setText(username);
    installContentProposalAdapter(text, new TextContentAdapter());
    text.setLayoutData(getFieldGridData());

    label = new Label(main, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_ComboUserName);

    // Create a combo field representing a user name
    Combo combo = new Combo(main, SWT.BORDER | SWT.DROP_DOWN);
    dec = new ControlDecoration(combo, getDecorationLocationBits());
    dec.setMarginWidth(marginWidth);
    comboField = new UserField(dec, combo, new ComboContentAdapter());

    dec.addMenuDetectListener(new MenuDetectListener() {
        public void menuDetected(MenuDetectEvent event) {
            // no quick fix if we aren't in error state.
            if (comboField.isValid()) {
                return;
            }
            if (comboField.quickFixMenu == null) {
                comboField.quickFixMenu = createQuickFixMenu(comboField);
            }
            comboField.quickFixMenu.setLocation(event.x, event.y);
            comboField.quickFixMenu.setVisible(true);
        }
    });
    dec.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent event) {
            MessageDialog.openInformation(getShell(),
                    TaskAssistExampleMessages.ExampleDialog_DefaultSelectionTitle,
                    TaskAssistExampleMessages.ExampleDialog_DefaultSelectionMessage);
        }

        public void widgetSelected(SelectionEvent e) {
            // Do nothing on selection
        }
    });

    if (showRequiredFieldLabelIndicator) {
        addRequiredFieldIndicator(label);
    }
    combo.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            handleModify(comboField);
        }
    });

    combo.setText(username);
    combo.setItems(validUsers);
    combo.setLayoutData(getFieldGridData());
    installContentProposalAdapter(combo, new ComboContentAdapter());

    // Create a spinner representing a user age
    label = new Label(main, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_Age);

    Spinner spinner = new Spinner(main, SWT.BORDER);
    dec = new ControlDecoration(spinner, getDecorationLocationBits());
    dec.setMarginWidth(marginWidth);

    if (showRequiredFieldLabelIndicator) {
        addRequiredFieldIndicator(label);
    }
    final SmartField spinnerField = new AgeField(dec, spinner, new SpinnerContentAdapter());
    spinner.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            handleModify(spinnerField);
        }
    });
    spinner.setSelection(40);
    spinner.setLayoutData(getFieldGridData());

    // This field has no decorator
    label = new Label(main, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.ExampleDialog_Password);
    text = new Text(main, SWT.BORDER | SWT.PASSWORD);
    text.setText("******"); //$NON-NLS-1$
    text.setLayoutData(getFieldGridData());
    if (showRequiredFieldLabelIndicator) {
        addRequiredFieldIndicator(label);
    }

    // This tests multi-line text popup placement
    label = new Label(main, SWT.LEFT);
    label.setText(TaskAssistExampleMessages.FieldAssistTestDialog_Comments);
    text = new Text(main, SWT.BORDER | SWT.MULTI | SWT.WRAP);
    text.setText(TaskAssistExampleMessages.FieldAssistTestDialog_CommentsDefaultContent);
    text.setLayoutData(getMultiLineTextFieldGridData());
    if (showRequiredFieldLabelIndicator) {
        addRequiredFieldIndicator(label);
    }
    installContentProposalAdapter(text, new TextContentAdapter());

}