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.eclipse.ui.ide.markers.compatibility.internal.QuickFixPage.java

License:Open Source License

public void createControl(Composite parent) {

    initializeDialogUnits(parent);/*from w  w w .j  a va 2 s .co m*/

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

    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(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title);

    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(MarkerMessages.MarkerResolutionDialog_Problems_List_Title);
    FormData labelData = new FormData();
    labelData.top = new FormAttachment(resolutionsList.getControl(), 0);
    labelData.left = new FormAttachment(0);
    title.setLayoutData(labelData);

    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);

    createMarkerTable(control);

    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.setAllChecked(true);
}

From source file:org.eclipse.ui.internal.cheatsheets.dialogs.CheatSheetCategoryBasedSelectionDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    initializeDialogUnits(parent);/*  w w w  .  j av  a 2  s  . c o  m*/

    IDialogSettings workbenchSettings = CheatSheetPlugin.getPlugin().getDialogSettings();
    IDialogSettings dialogSettings = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION);
    if (dialogSettings == null)
        dialogSettings = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION);

    setDialogSettings(dialogSettings);

    // top level group
    Composite outerContainer = (Composite) super.createDialogArea(parent);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, CHEAT_SHEET_SELECTION_HELP_ID);
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    outerContainer.setLayout(gridLayout);
    outerContainer.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Create label
    createMessageArea(outerContainer);

    // Create radio button
    selectRegisteredRadio = new Button(outerContainer, SWT.RADIO);
    selectRegisteredRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_REGISTERED);

    SashForm sform = new SashForm(outerContainer, SWT.VERTICAL);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 300;
    sform.setLayoutData(data);

    // category tree pane
    treeViewer = new TreeViewer(sform, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    treeViewer.getTree().setLayoutData(data);
    treeViewer.setContentProvider(getCheatSheetProvider());
    treeViewer.setLabelProvider(new CheatsheetLabelProvider());
    treeViewer.setComparator(CheatSheetCollectionSorter.INSTANCE);
    treeViewer.addFilter(activityViewerFilter);
    treeViewer.addSelectionChangedListener(this);
    treeViewer.setInput(cheatsheetCategories);

    desc = new Text(sform, SWT.MULTI | SWT.WRAP);
    desc.setEditable(false);

    sform.setWeights(new int[] { 10, 2 });

    if (activityViewerFilter.getHasEncounteredFilteredItem())
        createShowAllButton(outerContainer);

    // Add double-click listener
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object obj = selection.getFirstElement();
            if (obj instanceof CheatSheetCollectionElement) {
                boolean state = treeViewer.getExpandedState(obj);
                treeViewer.setExpandedState(obj, !state);
            } else {
                okPressed();
            }
        }
    });

    // RAP [if] Selecting the file from the local machine is not supported
    //        // Create radio button for select from file
    //      selectFileRadio = new Button(outerContainer, SWT.RADIO);
    //      selectFileRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_FROM_FILE);
    //
    //      Composite selectFileComposite = new Composite(outerContainer, SWT.NULL);
    //      GridLayout selectFileLayout = new GridLayout();
    //      selectFileLayout.marginWidth = 0;
    //      selectFileLayout.marginHeight = 0;
    //      selectFileLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    //      selectFileLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    //      selectFileLayout.numColumns = 2;
    //      selectFileComposite.setLayout(selectFileLayout);
    //      GridData sfCompositeData = new GridData(GridData.FILL_HORIZONTAL);
    //      sfCompositeData.widthHint = 300;
    //      selectFileComposite.setLayoutData(sfCompositeData);
    //      selectFileCombo = new Combo(selectFileComposite, SWT.BORDER);
    //      GridData sfTextData = new GridData(GridData.FILL_HORIZONTAL);
    //      selectFileCombo.setLayoutData(sfTextData);
    //      browseFileButton = new Button(selectFileComposite, SWT.NULL);
    //      browseFileButton.setText(Messages.get().SELECTION_DIALOG_FILEPICKER_BROWSE);
    //      setButtonLayoutData(browseFileButton);

    // Create radio button for select from URL
    selectUrlRadio = new Button(outerContainer, SWT.RADIO);
    selectUrlRadio.setText(Messages.get().SELECTION_DIALOG_OPEN_FROM_URL);
    selectUrlCombo = new Combo(outerContainer, SWT.BORDER);
    GridData suTextData = new GridData(GridData.FILL_HORIZONTAL);
    selectUrlCombo.setLayoutData(suTextData);

    restoreWidgetValues();
    restoreFileSettings();

    if (!treeViewer.getSelection().isEmpty())
        // we only set focus if a selection was restored
        treeViewer.getTree().setFocus();

    Dialog.applyDialogFont(outerContainer);
    // RAP [if] Selecting the file from the local machine is not supported
    //      selectFileCombo.addModifyListener(new FileAndUrlListener());
    //      browseFileButton.addSelectionListener(new BrowseListener());
    selectRegisteredRadio.addSelectionListener(new RadioSelectionListener());
    selectUrlRadio.addSelectionListener(new RadioSelectionListener());
    selectUrlCombo.addModifyListener(new FileAndUrlListener());
    checkRadioButtons();
    return outerContainer;
}

From source file:org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.java

License:Open Source License

protected Control createTreeAreaContents(Composite parent) {
    Composite leftArea = new Composite(parent, SWT.NONE);
    leftArea.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    leftArea.setFont(parent.getFont());//from   w  ww .j av  a 2s  .co  m
    GridLayout leftLayout = new GridLayout();
    leftLayout.numColumns = 1;
    leftLayout.marginHeight = 0;
    leftLayout.marginTop = IDialogConstants.VERTICAL_MARGIN;
    leftLayout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN;
    leftLayout.horizontalSpacing = 0;
    leftLayout.verticalSpacing = 0;
    leftArea.setLayout(leftLayout);

    // Build the tree an put it into the composite.
    TreeViewer viewer = createTreeViewer(leftArea);
    setTreeViewer(viewer);

    updateTreeFont(JFaceResources.getDialogFont());
    GridData viewerData = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    viewer.getControl().getParent().setLayoutData(viewerData);

    layoutTreeAreaControl(leftArea);

    return leftArea;
}

From source file:org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.java

License:Open Source License

protected Composite createTitleArea(Composite parent) {

    GridLayout parentLayout = (GridLayout) parent.getLayout();
    parentLayout.numColumns = 2;/*from  w  w w . j  a  v  a  2 s.c  om*/
    parentLayout.marginHeight = 0;
    parentLayout.marginTop = IDialogConstants.VERTICAL_MARGIN;
    parent.setLayout(parentLayout);

    Composite titleComposite = super.createTitleArea(parent);

    Composite toolbarArea = new Composite(parent, SWT.NONE);
    GridLayout toolbarLayout = new GridLayout();
    toolbarLayout.marginHeight = 0;
    toolbarLayout.verticalSpacing = 0;
    toolbarArea.setLayout(toolbarLayout);
    toolbarArea.setLayoutData(new GridData(SWT.END, SWT.FILL, false, true));
    Control topBar = getContainerToolBar(toolbarArea);
    topBar.setLayoutData(new GridData(SWT.END, SWT.FILL, false, true));

    return titleComposite;
}

From source file:org.eclipse.ui.internal.dialogs.WorkbenchEditorsDialog.java

License:Open Source License

/**
 * Creates the contents of this dialog, initializes the
 * listener and the update thread./* w  w  w  .  j a  va2  s  .com*/
 */
protected Control createDialogArea(Composite parent) {

    initializeDialogUnits(parent);

    Font font = parent.getFont();

    Composite dialogArea = new Composite(parent, SWT.NONE);
    CellLayout dialogAreaLayout = new CellLayout(1)
            .setMargins(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN),
                    convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN))
            .setSpacing(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                    convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .setRow(1, Row.growing());
    dialogArea.setLayout(dialogAreaLayout);
    dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    //Label over the table
    Label l = new Label(dialogArea, SWT.NONE);
    l.setText(WorkbenchMessages.WorkbenchEditorsDialog_label);
    l.setFont(font);
    l.setLayoutData(new CellData().align(SWT.FILL, SWT.CENTER));
    //Table showing the editors name, full path and perspective
    editorsTable = new Table(dialogArea,
            SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    editorsTable.setLinesVisible(true);
    editorsTable.setHeaderVisible(true);
    editorsTable.setFont(font);

    final int height = 16 * editorsTable.getItemHeight();
    final int width = (int) (2.5 * height);

    CellData tableData = new CellData().align(SWT.FILL, SWT.FILL).setHint(CellData.OVERRIDE, width, height);

    editorsTable.setLayoutData(tableData);
    editorsTable.setLayout(new Layout() {
        protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
            return new Point(width, height);
        }

        protected void layout(Composite composite, boolean flushCache) {
            TableColumn c[] = editorsTable.getColumns();
            if (columnsWidth == null) {
                int w = editorsTable.getClientArea().width;
                c[0].setWidth(w * 1 / 3);
                c[1].setWidth(w - c[0].getWidth());
            } else {
                c[0].setWidth(columnsWidth[0]);
                c[1].setWidth(columnsWidth[1]);
            }
            editorsTable.setLayout(null);
        }
    });
    //Name column
    TableColumn tc = new TableColumn(editorsTable, SWT.NONE);
    tc.setResizable(true);
    tc.setText(WorkbenchMessages.WorkbenchEditorsDialog_name);
    tc.addSelectionListener(headerListener);
    //Full path column
    tc = new TableColumn(editorsTable, SWT.NONE);
    tc.setResizable(true);
    tc.setText(WorkbenchMessages.WorkbenchEditorsDialog_path);
    tc.addSelectionListener(headerListener);

    // A composite for selection option buttons
    Composite selectionButtons = new Composite(dialogArea, SWT.NULL);
    Label compLabel = new Label(selectionButtons, SWT.NULL);
    compLabel.setFont(font);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    selectionButtons.setLayout(layout);

    //Select clean editors button
    selectClean = new Button(selectionButtons, SWT.PUSH);
    selectClean.setText(WorkbenchMessages.WorkbenchEditorsDialog_selectClean);
    selectClean.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            editorsTable.setSelection(selectClean(editorsTable.getItems()));
            updateButtons();
        }
    });
    selectClean.setFont(font);
    setButtonLayoutData(selectClean);

    //Invert selection button
    invertSelection = new Button(selectionButtons, SWT.PUSH);
    invertSelection.setText(WorkbenchMessages.WorkbenchEditorsDialog_invertSelection);
    invertSelection.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            editorsTable.setSelection(invertedSelection(editorsTable.getItems(), editorsTable.getSelection()));
            updateButtons();
        }
    });
    invertSelection.setFont(font);
    setButtonLayoutData(invertSelection);

    //Select all button
    allSelection = new Button(selectionButtons, SWT.PUSH);
    allSelection.setText(WorkbenchMessages.WorkbenchEditorsDialog_allSelection);
    allSelection.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            editorsTable.setSelection(editorsTable.getItems());
            updateButtons();
        }
    });
    allSelection.setFont(font);
    setButtonLayoutData(allSelection);

    // A composite for selected editor action buttons
    Composite actionButtons = new Composite(dialogArea, SWT.NULL);
    Label actLabel = new Label(actionButtons, SWT.NULL);
    actLabel.setFont(font);
    GridLayout actLayout = new GridLayout();
    actLayout.numColumns = 4;
    actionButtons.setLayout(actLayout);

    // Activate selected editor button
    createButton(actionButtons, IDialogConstants.OK_ID, WorkbenchMessages.WorkbenchEditorsDialog_activate,
            true);

    //Close selected editors button
    closeSelected = new Button(actionButtons, SWT.PUSH);
    closeSelected.setText(WorkbenchMessages.WorkbenchEditorsDialog_closeSelected);
    closeSelected.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            closeItems(editorsTable.getSelection());
        }
    });
    closeSelected.setFont(font);
    setButtonLayoutData(closeSelected);

    //Save selected editors button
    saveSelected = new Button(actionButtons, SWT.PUSH);
    saveSelected.setText(WorkbenchMessages.WorkbenchEditorsDialog_saveSelected);
    saveSelected.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            saveItems(editorsTable.getSelection());
        }
    });
    saveSelected.setFont(font);
    setButtonLayoutData(saveSelected);

    //Show only active perspective button
    final Button showAllPerspButton = new Button(dialogArea, SWT.CHECK);
    showAllPerspButton.setText(WorkbenchMessages.WorkbenchEditorsDialog_showAllPersp);
    showAllPerspButton.setSelection(showAllPersp);
    showAllPerspButton.setFont(font);
    setButtonLayoutData(showAllPerspButton);
    showAllPerspButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            showAllPersp = showAllPerspButton.getSelection();
            updateItems();
        }
    });
    //Create the items and update buttons state
    updateItems();
    updateButtons();

    editorsTable.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateButtons();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            okPressed();
        }
    });
    editorsTable.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            for (Iterator images = imageCache.values().iterator(); images.hasNext();) {
                Image i = (Image) images.next();
                i.dispose();
            }
            for (Iterator images = disabledImageCache.values().iterator(); images.hasNext();) {
                Image i = (Image) images.next();
                i.dispose();
            }
        }
    });
    editorsTable.setFocus();
    applyDialogFont(dialogArea);
    return dialogArea;
}

From source file:org.eclipse.ui.internal.ide.dialogs.ResourceFilterGroup.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    parent.setLayoutData(data);/*  w ww .  j ava 2s.c om*/

    Font font = parent.getFont();
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(data);
    composite.setFont(font);

    Dialog.applyDialogFont(composite);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(),
            IIDEHelpContextIds.EDIT_RESOURCE_FILTER_PROPERTY_PAGE);

    if (!filter.isUnderAGroupFilter()) {
        Composite topComposite = new Composite(composite, SWT.NONE);
        layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = 0;
        layout.marginBottom = 0;
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = 0; // convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        topComposite.setLayout(layout);
        data = new GridData(SWT.FILL, SWT.FILL, true, false);
        topComposite.setLayoutData(data);
        topComposite.setFont(font);

        createModeArea(font, topComposite);

        createTargetArea(font, topComposite);

        createIdArea(font, topComposite);
    } else {
        layout.marginHeight = convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        createIdArea(font, composite);
    }
    return composite;
}

From source file:org.eclipse.ui.internal.ide.dialogs.ResourceFilterGroup.java

License:Open Source License

private Control dialogCreateButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    // create a layout with spacing and margins appropriate for the font
    // size./*from  ww  w. j a v a2 s  .  c  om*/
    GridLayout layout = new GridLayout();
    layout.numColumns = 0; // this is incremented by createButton
    layout.makeColumnsEqualWidth = true;
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    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);
    composite.setLayoutData(data);
    composite.setFont(parent.getFont());

    // Add the buttons to the button bar.
    createButtonsForButtonBar(composite);
    return composite;
}

From source file:org.eclipse.ui.internal.statushandlers.InternalDialog.java

License:Open Source License

/**
 * This method creates button bar that is available on the bottom of the
 * dialog./*  w ww  . j  a v  a 2  s . co m*/
 */
protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    linkComposite = createLinkComposite(composite);

    // Add the buttons to the button bar.
    createButtonsForButtonBar(composite);

    composite.layout();
    return composite;
}

From source file:org.eclipse.ui.internal.views.markers.QuickFixPage.java

License:Open Source License

public void createControl(Composite parent) {

    initializeDialogUnits(parent);//  ww w  .  j  a v  a 2s.co m

    // Create a new composite as there is the title bar seperator
    // 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(MarkerMessages.MarkerResolutionDialog_Resolutions_List_Title);

    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(MarkerMessages.MarkerResolutionDialog_Problems_List_Title);
    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.eclipse.ui.texteditor.ChangeEncodingAction.java

License:Open Source License

public void run() {
    final IResource resource = getResource();
    final Shell parentShell = getTextEditor().getSite().getShell();
    final IEncodingSupport encodingSupport = getEncodingSupport();
    if (resource == null && encodingSupport == null) {
        MessageDialog.openInformation(parentShell, fDialogTitle,
                TextEditorMessages.ChangeEncodingAction_message_noEncodingSupport);
        return;/*from  w ww. ja  v a  2s.com*/
    }

    Dialog dialog = new Dialog(parentShell) {
        private AbstractEncodingFieldEditor fEncodingEditor;
        private IPreferenceStore store = null;

        /*
         * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
         */
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText(fDialogTitle);
        }

        /*
         * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
         */
        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea(parent);

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

            GridData data = new GridData(GridData.FILL_BOTH);
            composite.setLayoutData(data);
            composite.setFont(parent.getFont());

            DialogPage page = new MessageDialogPage(composite) {
                public void setErrorMessage(String newMessage) {
                    super.setErrorMessage(newMessage);
                    setButtonEnabledState(IDialogConstants.OK_ID, newMessage == null);
                    setButtonEnabledState(APPLY_ID, newMessage == null);
                }

                private void setButtonEnabledState(int id, boolean state) {
                    Button button = getButton(id);
                    if (button != null)
                        button.setEnabled(state);
                }
            };

            if (resource != null) {
                fEncodingEditor = new ResourceEncodingFieldEditor("", composite, resource, null); //$NON-NLS-1$
                fEncodingEditor.setPage(page);
                fEncodingEditor.load();
            } else {
                fEncodingEditor = new EncodingFieldEditor(ENCODING_PREF_KEY, "", null, composite); //$NON-NLS-1$
                store = new PreferenceStore();
                String defaultEncoding = encodingSupport.getDefaultEncoding();
                store.setDefault(ENCODING_PREF_KEY, defaultEncoding);
                String encoding = encodingSupport.getEncoding();
                if (encoding != null)
                    store.setValue(ENCODING_PREF_KEY, encoding);
                fEncodingEditor.setPreferenceStore(store);

                fEncodingEditor.setPage(page);
                fEncodingEditor.load();

                if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
                    fEncodingEditor.loadDefault();
            }

            return composite;
        }

        /*
         * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
         */
        protected void createButtonsForButtonBar(Composite parent) {
            createButton(parent, APPLY_ID, TextEditorMessages.ChangeEncodingAction_button_apply_label, false);
            super.createButtonsForButtonBar(parent);
        }

        /*
         * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
         */
        protected void buttonPressed(int buttonId) {
            if (buttonId == APPLY_ID)
                apply();
            else
                super.buttonPressed(buttonId);
        }

        /*
         * @see org.eclipse.jface.dialogs.Dialog#okPressed()
         */
        protected void okPressed() {
            apply();
            super.okPressed();
        }

        private void apply() {
            fEncodingEditor.store();

            if (resource == null) {
                String encoding = fEncodingEditor.getPreferenceStore()
                        .getString(fEncodingEditor.getPreferenceName());
                encodingSupport.setEncoding(encoding);
            }
        }
    };
    dialog.open();
}