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:org.rubypeople.rdt.internal.ui.preferences.RubyBasePreferencePage.java

License:Open Source License

protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);/*from   w  ww . jav  a 2  s . co  m*/

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

    Group doubleClickGroup = new Group(result, SWT.NONE);
    doubleClickGroup.setLayout(new GridLayout());
    doubleClickGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    doubleClickGroup.setText(PreferencesMessages.RubyBasePreferencePage_doubleclick_action);
    addRadioButton(doubleClickGroup, PreferencesMessages.RubyBasePreferencePage_doubleclick_gointo,
            DOUBLE_CLICK, DOUBLE_CLICK_GOES_INTO);
    addRadioButton(doubleClickGroup, PreferencesMessages.RubyBasePreferencePage_doubleclick_expand,
            DOUBLE_CLICK, DOUBLE_CLICK_EXPANDS);

    Group group = new Group(result, SWT.NONE);
    group.setLayout(new GridLayout());
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setText(PreferencesMessages.RubyBasePreferencePage_search);

    addCheckBox(group, PreferencesMessages.RubyBasePreferencePage_search_small_menu,
            PreferenceConstants.SEARCH_USE_REDUCED_MENU);

    layout = new GridLayout();
    layout.numColumns = 2;

    Group dontAskGroup = new Group(result, SWT.NONE);
    dontAskGroup.setLayout(layout);
    dontAskGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    dontAskGroup.setText(PreferencesMessages.RubyBasePreferencePage_dialogs);

    Label label = new Label(dontAskGroup, SWT.WRAP);
    label.setText(PreferencesMessages.RubyBasePreferencePage_do_not_hide_description);
    GridData data = new GridData(GridData.FILL, GridData.CENTER, true, false);
    data.widthHint = convertVerticalDLUsToPixels(50);
    label.setLayoutData(data);

    Button clearButton = new Button(dontAskGroup, SWT.PUSH);
    clearButton.setText(PreferencesMessages.RubyBasePreferencePage_do_not_hide_button);
    clearButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
    clearButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            unhideAllDialogs();
        }

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

    SWTUtil.setButtonDimensionHint(clearButton);
    Dialog.applyDialogFont(result);
    return result;
}

From source file:org.rubypeople.rdt.internal.ui.text.ruby.ContentAssistProcessor.java

License:Open Source License

/**
 * Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.
 * //from  w  w  w  . j av  a  2s  .c  o  m
 * @since 3.3
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = RubyPlugin.getActiveWorkbenchShell();
        String title = RubyTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = RubyTextMessages.ContentAssistProcessor_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = Messages.format(
                RubyTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        close();
                        PreferencesUtil.createPreferenceDialogOn(shell,
                                "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                                .open();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        if (restoreId == dialog.open()) {
            IPreferenceStore store = RubyPlugin.getDefault().getPreferenceStore();
            store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
            store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.sasylf.util.QuickFixPage.java

License:Open Source License

public void createControl(Composite parent) {

    initializeDialogUnits(parent);/*from w  ww .j a  v a2  s  .co m*/

    // Create a new composite as there is the title bar separator
    // to deal with
    Composite control = new Composite(parent, SWT.NONE);
    control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    setControl(control);

    /*PlatformUI.getWorkbench().getHelpSystem().setHelp(control,
        IWorkbenchHelpContextIds.PROBLEMS_VIEW);*/

    FormLayout layout = new FormLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    control.setLayout(layout);

    Label resolutionsLabel = new Label(control, SWT.NONE);
    resolutionsLabel.setText("Select a fix:");

    resolutionsLabel.setLayoutData(new FormData());

    createResolutionsList(control);

    FormData listData = new FormData();
    listData.top = new FormAttachment(resolutionsLabel, 0);
    listData.left = new FormAttachment(0);
    listData.right = new FormAttachment(100, 0);
    listData.height = convertHeightInCharsToPixels(10);
    resolutionsList.getControl().setLayoutData(listData);

    Label title = new Label(control, SWT.NONE);
    title.setText("Problems:");
    FormData labelData = new FormData();
    labelData.top = new FormAttachment(resolutionsList.getControl(), 0);
    labelData.left = new FormAttachment(0);
    title.setLayoutData(labelData);

    createMarkerTable(control);

    Composite buttons = createTableButtons(control);
    FormData buttonData = new FormData();
    buttonData.top = new FormAttachment(title, 0);
    buttonData.right = new FormAttachment(100);
    buttonData.height = convertHeightInCharsToPixels(10);
    buttons.setLayoutData(buttonData);

    FormData tableData = new FormData();
    tableData.top = new FormAttachment(buttons, 0, SWT.TOP);
    tableData.left = new FormAttachment(0);
    tableData.bottom = new FormAttachment(100);
    tableData.right = new FormAttachment(buttons, 0);
    tableData.height = convertHeightInCharsToPixels(10);
    markersTable.getControl().setLayoutData(tableData);

    Dialog.applyDialogFont(control);

    resolutionsList.setSelection(new StructuredSelection(resolutionsList.getElementAt(0)));

    markersTable.setCheckedElements(selectedMarkers);

    setPageComplete(markersTable.getCheckedElements().length > 0);
}

From source file:org.seasar.uruma.ui.dialogs.UrumaErrorDialog.java

License:Apache License

@Override
protected Control createDialogArea(final Composite parent) {
    createMessageArea(parent);//w ww.j a  v a 2  s  .  c  o m

    // 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);
    layout.numColumns = 2;
    composite.setLayout(layout);
    GridData childData = new GridData(SWT.FILL, SWT.FILL, true, false);
    childData.horizontalSpan = 2;
    composite.setLayoutData(childData);
    composite.setFont(parent.getFont());

    return composite;
}

From source file:org.springframework.ide.eclipse.wizard.template.NewSpringProjectWizardMainPage.java

License:Open Source License

protected GridLayout initGridLayout(GridLayout layout, boolean margins) {
    layout.horizontalSpacing = 0;/*from   w  w w.  j  a va 2 s.c  o m*/
    layout.verticalSpacing = 0;
    if (margins) {
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    } else {
        layout.marginWidth = 0;
        layout.marginHeight = 0;
    }
    return layout;
}

From source file:org.springsource.ide.eclipse.commons.frameworks.ui.internal.wizard.AbstractGenericWizardPage.java

License:Open Source License

/**
 * Left and right width margin in pixels. Distance between edge of page and
 * the control area.//from   w ww. j  a  va 2s.  c  o  m
 * 
 * @return
 */
protected int getPageWMargin() {
    return convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
}

From source file:org.summer.dsl.ui.codetemplates.ui.preferences.EditTemplateDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/* w w  w .j a v a2 s  .com*/
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);

    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    ModifyListener listener = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            doTextWidgetChanged(e.widget);
        }
    };

    if (fIsNameModifiable) {
        createLabel(parent, TemplateDialogMessages.EditTemplateDialog_name);

        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        layout = new GridLayout();
        layout.numColumns = 4;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        composite.setLayout(layout);

        fNameText = createText(composite);

        createLabel(composite, TemplateDialogMessages.EditTemplateDialog_context);
        fContextCombo = new Combo(composite, SWT.READ_ONLY);
        fContextCombo.setVisibleItemCount(30); // default

        for (int i = 0; i < fContextTypes.length; i++) {
            fContextCombo.add(fContextTypes[i][1]);
        }

        fContextCombo.addModifyListener(listener);

        fAutoInsertCheckbox = createCheckbox(composite, TemplateDialogMessages.EditTemplateDialog_autoinsert);
        fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
    }

    createLabel(parent, TemplateDialogMessages.EditTemplateDialog_description);

    int descFlags = fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
    fDescriptionText = new Text(parent, descFlags);
    fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fDescriptionText.addModifyListener(listener);

    Label patternLabel = createLabel(parent, TemplateDialogMessages.EditTemplateDialog_pattern);
    patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    fPatternEditor = createEditor(parent);

    Label filler = new Label(parent, SWT.NONE);
    filler.setLayoutData(new GridData());

    Composite composite = new Composite(parent, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData());

    fInsertVariableButton = new Button(composite, SWT.NONE);
    fInsertVariableButton.setLayoutData(getButtonGridData());
    fInsertVariableButton.setText(TemplateDialogMessages.EditTemplateDialog_insert_variable);
    fInsertVariableButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            fPatternEditor.getTextWidget().setFocus();
            fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        }

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

    fDescriptionText.setText(fTemplate.getDescription());
    if (fIsNameModifiable) {
        fNameText.setText(fTemplate.getName());
        fNameText.addModifyListener(listener);
        fContextCombo.select(getIndex(fTemplate.getContextTypeId()));
    } else {
        fPatternEditor.getControl().setFocus();
    }
    applyDialogFont(parent);
    return composite;
}

From source file:org.summer.sdt.internal.ui.preferences.AppearancePreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);/*from   w  ww  .  j  av a 2 s .  com*/
    int nColumns = 1;

    Composite result = new Composite(parent, SWT.NONE);
    result.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = 0;
    layout.numColumns = nColumns;
    result.setLayout(layout);

    fShowMethodReturnType.doFillIntoGrid(result, nColumns);
    fShowMethodTypeParameters.doFillIntoGrid(result, nColumns);
    fShowCategory.doFillIntoGrid(result, nColumns);
    fShowMembersInPackageView.doFillIntoGrid(result, nColumns);
    fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns);

    new Separator().doFillIntoGrid(result, nColumns);

    fCompressPackageNames.doFillIntoGrid(result, nColumns);
    fPackageNamePattern.doFillIntoGrid(result, 2);
    LayoutUtil.setHorizontalIndent(fPackageNamePattern.getLabelControl(null));
    Text packageNamePatternControl = fPackageNamePattern.getTextControl(null);
    LayoutUtil.setHorizontalIndent(packageNamePatternControl);
    LayoutUtil.setHorizontalGrabbing(packageNamePatternControl);
    LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null), convertWidthInCharsToPixels(65));

    new Separator().doFillIntoGrid(result, nColumns);
    fAbbreviatePackageNames.doFillIntoGrid(result, nColumns);
    fAbbreviatePackageNamePattern.doFillIntoGrid(result, 2);
    LayoutUtil.setHorizontalIndent(fAbbreviatePackageNamePattern.getLabelControl(null));
    Text abbreviatePackageNamePatternControl = fAbbreviatePackageNamePattern.getTextControl(null);
    LayoutUtil.setHorizontalIndent(abbreviatePackageNamePatternControl);
    LayoutUtil.setHorizontalGrabbing(abbreviatePackageNamePatternControl);
    LayoutUtil.setWidthHint(fAbbreviatePackageNamePattern.getLabelControl(null),
            convertWidthInCharsToPixels(65));
    LayoutUtil.setVerticalGrabbing(abbreviatePackageNamePatternControl);
    LayoutUtil.setHeightHint(abbreviatePackageNamePatternControl, convertHeightInCharsToPixels(3));

    new Separator().doFillIntoGrid(result, nColumns);
    fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns);

    String noteTitle = PreferencesMessages.AppearancePreferencePage_note;
    String noteMessage = PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives;
    Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = LayoutUtil.getIndent();
    noteControl.setLayoutData(gd);

    initFields();

    Dialog.applyDialogFont(result);
    return result;
}

From source file:org.summer.sdt.internal.ui.preferences.EditTemplateDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from   w w  w . j  a va2  s .  c om
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);

    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    ModifyListener listener = new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            doTextWidgetChanged(e.widget);
        }
    };

    if (fIsNameModifiable) {
        createLabel(parent, PreferencesMessages.EditTemplateDialog_name);

        Composite composite = new Composite(parent, SWT.NONE);
        composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        layout = new GridLayout();
        layout.numColumns = 4;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        composite.setLayout(layout);

        fNameText = createText(composite);
        fNameText.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
            }

            public void focusLost(FocusEvent e) {
                if (fSuppressError) {
                    fSuppressError = false;
                    updateStatusAndButtons();
                }
            }
        });
        BidiUtils.applyBidiProcessing(fNameText, BidiUtils.BTD_DEFAULT);

        createLabel(composite, PreferencesMessages.EditTemplateDialog_context);
        fContextCombo = new Combo(composite, SWT.READ_ONLY);
        SWTUtil.setDefaultVisibleItemCount(fContextCombo);

        for (int i = 0; i < fContextTypes.length; i++) {
            fContextCombo.add(fContextTypes[i][1]);
        }

        fContextCombo.addModifyListener(listener);

        fAutoInsertCheckbox = createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert);
        fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
    }

    createLabel(parent, PreferencesMessages.EditTemplateDialog_description);

    int descFlags = fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
    fDescriptionText = new Text(parent, descFlags);
    fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fDescriptionText.addModifyListener(listener);
    BidiUtils.applyBidiProcessing(fDescriptionText, BidiUtils.BTD_DEFAULT);

    Label patternLabel = createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern);
    patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    fPatternEditor = createEditor(parent);

    Label filler = new Label(parent, SWT.NONE);
    filler.setLayoutData(new GridData());

    Composite composite = new Composite(parent, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData());

    fInsertVariableButton = new Button(composite, SWT.NONE);
    fInsertVariableButton.setLayoutData(getButtonGridData());
    fInsertVariableButton.setText(PreferencesMessages.EditTemplateDialog_insert_variable);
    fInsertVariableButton.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            fPatternEditor.getTextWidget().setFocus();
            fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        }

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

    fDescriptionText.setText(fTemplate.getDescription());
    if (fIsNameModifiable) {
        fNameText.setText(fTemplate.getName());
        fNameText.addModifyListener(listener);
        fContextCombo.select(getIndex(fTemplate.getContextTypeId()));
    } else {
        fPatternEditor.getControl().setFocus();
    }
    initializeActions();

    applyDialogFont(parent);
    return composite;
}

From source file:org.summer.sdt.internal.ui.text.java.ContentAssistProcessor.java

License:Open Source License

/**
 * Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.
 *
 * @return  <code>true</code> if the default should be restored
 * @since 3.3// www.  ja  va2s  .c  o m
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = JavaPlugin.getActiveWorkbenchShell();
        String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = Messages.format(
                JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final int settingsId = IDialogConstants.CLIENT_ID + 11;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.summer.sdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        setReturnCode(settingsId);
                        close();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        int returnValue = dialog.open();
        if (restoreId == returnValue || settingsId == returnValue) {
            if (restoreId == returnValue) {
                IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue)
                PreferencesUtil
                        .createPreferenceDialogOn(shell,
                                "org.summer.sdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            fComputerRegistry.reload();
            return true;
        }
    }
    return false;
}