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.edt.ide.ui.preferences.CompilerAndGeneratorControls.java

License:Open Source License

protected GridLayout createGridLayout(int numColumns, boolean margins) {
    GridLayout layout = new GridLayout(numColumns, false);
    layout.verticalSpacing = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = fPixelConverter
            .convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    if (margins) {
        layout.marginHeight = fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    } else {//from www . j  a v a  2 s. c  o  m
        layout.marginHeight = 0;
        layout.marginWidth = 0;
    }
    return layout;
}

From source file:org.eclipse.edt.ide.ui.preferences.CompilerPropertyAndPreferencePage.java

License:Open Source License

/**
 * Create a composite to hold generator tabs for a property
 * page or a preference page for a compiler.
 * //from w w  w. java2s .co m
 * @param composite
 */
protected void createGeneratorTabsComposite(Composite composite) {
    this.tabComposite = new Composite(composite, SWT.NONE);

    GridLayout tabLayout = new GridLayout();
    tabLayout.marginWidth = 0;
    tabLayout.numColumns = 1;
    PixelConverter pixelConverter = new PixelConverter(composite);
    tabLayout.verticalSpacing = (int) (1.5
            * pixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
    tabLayout.horizontalSpacing = pixelConverter
            .convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    tabLayout.marginTop = 3;
    tabLayout.marginWidth = pixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);

    this.tabComposite.setLayout(tabLayout);
    this.tabComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.tabFolder = new TabFolder(this.tabComposite, SWT.NONE);
    this.tabFolder.setLayout(new TabFolderLayout());
    this.tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
}

From source file:org.eclipse.egit.gitflow.ui.internal.dialogs.FinishFeatureDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    final Composite customButtonBar = new Composite(parent, SWT.NONE);

    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(horizontalSpacing, 0)
            .applyTo(customButtonBar);//from   w  ww .ja  va2 s.c o m

    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.BOTTOM).applyTo(customButtonBar);

    customButtonBar.setFont(parent.getFont());

    rememberOptionsButton = new Button(customButtonBar, SWT.CHECK);
    rememberOptionsButton.setText(UIText.FinishFeatureDialog_saveAsDefault);

    // TODO: Checkbox "Don't ask again"

    int horizontlIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.CENTER).indent(horizontlIndent, 0)
            .applyTo(rememberOptionsButton);

    // add the dialog's button bar to the right
    final Control buttonControl = super.createButtonBar(customButtonBar);
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.RIGHT, SWT.CENTER).applyTo(buttonControl);

    return customButtonBar;
}

From source file:org.eclipse.egit.ui.internal.SWTUtils.java

License:Open Source License

/**
 * Creates a grid layout with the specified number of columns and the
 * standard spacings.//from w w w . j a  va  2s . c o  m
 *
 * @param numColumns
 *            the number of columns
 * @param converter
 *            the pixel converter
 * @param margins
 *            one of <code>MARGINS_DEFAULT</code>, <code>MARGINS_NONE</code>
 *            or <code>MARGINS_DIALOG</code>.
 *
 * @return the created grid layout
 */
public static GridLayout createGridLayout(int numColumns, PixelConverter converter, int margins) {
    Assert.isTrue(margins == MARGINS_DEFAULT || margins == MARGINS_NONE || margins == MARGINS_DIALOG);

    final GridLayout layout = new GridLayout(numColumns, false);
    layout.horizontalSpacing = converter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = converter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);

    switch (margins) {
    case MARGINS_NONE:
        layout.marginLeft = layout.marginRight = 0;
        layout.marginTop = layout.marginBottom = 0;
        break;
    case MARGINS_DIALOG:
        layout.marginLeft = layout.marginRight = converter
                .convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.marginTop = layout.marginBottom = converter
                .convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        break;
    case MARGINS_DEFAULT:
        layout.marginLeft = layout.marginRight = layout.marginWidth;
        layout.marginTop = layout.marginBottom = layout.marginHeight;
    }
    layout.marginWidth = layout.marginHeight = 0;
    return layout;
}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.ElementSelectionDialog.java

License:Open Source License

/**
 * Used to display a page/*ww w. j a v a  2  s. c o m*/
 * 
 * @param parent
 *            composite which contains the tree
 * @return the composite of this page
 */
public Control fillModelpage(Composite parent) {
    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);

    // use pattern filter
    PatternFilter patternFilter = new TreeSelectionPatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);

    FilteredTree filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.RESIZE,
            patternFilter, true);
    // use of EMF facilities
    final TreeViewer treeViewer = filteredTree.getViewer();
    treeViewer.setFilters(new ViewerFilter[0]);
    treeViewer.setUseHashlookup(true);
    if (input instanceof EEFEditorSettings)
        treeViewer.setContentProvider(
                new HideResourcesContentProvider(new AdvancedEEFEditorContentProvider(adapterFactory)));
    else
        treeViewer.setContentProvider(
                new HideResourcesContentProvider(new AdapterFactoryContentProvider(adapterFactory)));

    ArrayList<ViewerFilter> filters = new ArrayList<ViewerFilter>();
    if (viewerFilters != null && !viewerFilters.isEmpty()) {
        for (ViewerFilter filter : viewerFilters) {
            filters.add(filter);
        }
    }
    // for now, add the businessRuleFilters to the 'normal' filters
    if (brFilters != null && !brFilters.isEmpty()) {
        for (ViewerFilter filter : brFilters) {
            filters.add(filter);
        }
    }
    filters.add(patternFilter);
    ViewerFilter[] v = filters.toArray(new ViewerFilter[filters.size()]);
    treeViewer.setFilters(v);
    treeViewer.setLabelProvider(new EEFLabelProvider() {

        @Override
        public Color getForeground(Object element) {
            if (input instanceof ReferencesTableSettings && element instanceof EObject
                    && ((ReferencesTableSettings) input).contains((EObject) element)) {
                return getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
            }

            return super.getForeground(element);
        }

    });

    filteredTree.setLayoutData(new GridData(550, 300));
    // handle selection change
    if (input instanceof EEFEditorSettings) {
        treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                if (event.getSelection() instanceof IStructuredSelection) {
                    // Check selection
                    IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
                    if (structuredSelection != null && !structuredSelection.isEmpty()) {
                        Object o = structuredSelection.getFirstElement();
                        // Check type matching
                        Button okButton = getButton(IDialogConstants.OK_ID);
                        if (((List<?>) ((EEFEditorSettings) input).choiceOfValues(adapterFactory))
                                .contains(o)) {
                            if (input instanceof ReferencesTableSettings) {
                                if (o instanceof EObject
                                        && !((ReferencesTableSettings) input).contains((EObject) o)) {
                                    selection = structuredSelection;
                                    if (okButton != null) {
                                        okButton.setEnabled(true);
                                    }
                                } else {
                                    // Reject selection
                                    if (okButton != null) {
                                        okButton.setEnabled(false);
                                    }
                                }
                            } else {
                                selection = structuredSelection;
                                if (okButton != null) {
                                    okButton.setEnabled(true);
                                }
                            }
                        } else {
                            // Reject selection
                            if (okButton != null) {
                                okButton.setEnabled(false);
                            }
                        }
                    }

                }
            }
        });

        // handle double click to validate
        treeViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                if (selection != null && !selection.isEmpty()) {
                    Object o = selection.getFirstElement();
                    if (((List<?>) ((EEFEditorSettings) input).choiceOfValues(adapterFactory)).contains(o)
                            && input instanceof ReferencesTableSettings && o instanceof EObject
                            && !((ReferencesTableSettings) input).contains((EObject) o)) {
                        okPressed();
                    }
                }
            }
        });
    }
    treeViewer.setInput(input);

    // Init selected element
    if (selection != null) {
        treeViewer.setSelection(selection);
    }

    return composite;

}

From source file:org.eclipse.emf.eef.runtime.ui.widgets.TabElementTreeSelectionDialog.java

License:Open Source License

/**
 * Used to display a page in a tab/*w  w  w.  j ava2  s.  c  o  m*/
 * 
 * @param tabFolder
 *            that contains all tabs
 * @param specificTabFilter
 *            a specific filter to this page
 * @return the composite of this page
 */
public Control fillModelpage(CTabFolder tabFolder, final boolean showResourceItem,
        final ViewerFilter specificTabFilter) {
    Composite composite = new Composite(tabFolder, 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);

    // use pattern filter
    PatternFilter patternFilter = new TreeSelectionPatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);

    FilteredTree filteredTree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.RESIZE,
            patternFilter);
    // use of EMF facilities
    final TreeViewer treeViewer = filteredTree.getViewer();
    treeViewer.setFilters(new ViewerFilter[0]);
    treeViewer.setUseHashlookup(true);
    if (input instanceof EEFEditorSettings)
        treeViewer.setContentProvider(new AdvancedEEFEditorContentProvider(adapterFactory));
    else
        treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));

    ArrayList<ViewerFilter> filters = new ArrayList<ViewerFilter>();
    if (specificTabFilter != null) {
        filters.add(specificTabFilter);
    }
    if (viewerFilters != null && !viewerFilters.isEmpty()) {
        for (ViewerFilter filter : viewerFilters) {
            filters.add(filter);
        }
    }
    // for now, add the businessRuleFilters to the 'normal' filters
    if (brFilters != null && !brFilters.isEmpty()) {
        for (ViewerFilter filter : brFilters) {
            filters.add(filter);
        }
    }
    filters.add(patternFilter);
    ViewerFilter[] v = filters.toArray(new ViewerFilter[filters.size()]);
    treeViewer.setFilters(v);
    treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));

    filteredTree.setLayoutData(new GridData(550, 300));
    // handle selection change
    if (input instanceof EEFEditorSettings) {
        treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event) {
                if (event.getSelection() instanceof IStructuredSelection) {
                    // Check selection
                    IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
                    if (structuredSelection != null && !structuredSelection.isEmpty()) {
                        Object o = structuredSelection.getFirstElement();
                        // Check type matching
                        Button okButton = getButton(IDialogConstants.OK_ID);
                        if (((List<?>) ((EEFEditorSettings) input).choiceOfValues(adapterFactory))
                                .contains(o)) {
                            selection = structuredSelection;
                            if (okButton != null) {
                                okButton.setEnabled(true);
                            }
                        } else {
                            // Reject selection
                            if (okButton != null) {
                                okButton.setEnabled(false);
                            }
                        }
                    }

                }
            }
        });

        // handle double click to validate
        treeViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                if (selection != null && !selection.isEmpty()) {
                    Object o = selection.getFirstElement();
                    if (((List<?>) ((EEFEditorSettings) input).choiceOfValues(adapterFactory)).contains(o)) {
                        okPressed();
                    }
                }
            }
        });
    }
    treeViewer.setInput(input);

    // Init selected element
    if (selection != null) {
        treeViewer.setSelection(selection);
    }

    return composite;

}

From source file:org.eclipse.emf.emfstore.client.ui.views.emfstorebrowser.views.CertificateSelectionDialog.java

License:Open Source License

/**
 * Overridden method to allow adding further elements onto the dialog
 * composite./*from  w w w . ja v a  2 s . c om*/
 * 
 * @see org.eclipse.ui.dialogs.ElementListSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 * @return Control
 * @param parent
 *            Parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    // standard layout used by dialogue area
    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);

    // two column layout composite
    Composite grid = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(grid);

    // left column composite
    Composite left = new Composite(grid, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(left);

    // right column composite
    Composite right = new Composite(grid, SWT.NONE);
    GridLayoutFactory.createFrom(layout).margins(layout.marginWidth, 35).applyTo(right);
    GridDataFactory.fillDefaults().grab(true, true).hint(300, 200).applyTo(right);
    applyDialogFont(right);

    // right column: certificate details
    new Label(right, SWT.NONE).setText("Certificate Alias: ");
    final Text certAlias = new Text(right, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(certAlias);
    certAlias.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    certAlias.setEditable(false);
    new Label(right, SWT.NONE).setText("Certificate Details: ");
    final Text certDetails = new Text(right, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().grab(true, false).hint(300, 230).applyTo(certDetails);
    certDetails.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    certDetails.setEditable(false);

    // left column: dialogue area composite (displays certificates and
    // filter)
    Composite dialogArea = new Composite(left, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(dialogArea);
    Control control = super.createDialogArea(dialogArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(control);

    // left column: import button, composite used to ensure correct
    // alignment
    Composite certButtonsComposite = new Composite(grid, SWT.NONE);
    GridLayoutFactory.createFrom(layout).numColumns(3).equalWidth(true).margins(layout.marginWidth, 0)
            .applyTo(certButtonsComposite);
    applyDialogFont(certButtonsComposite);
    Button browse = new Button(certButtonsComposite, SWT.NONE);
    browse.setText("Import...");
    browse.addSelectionListener(new CertificateSelectionListener());

    // Delete certificate
    Button delete = new Button(certButtonsComposite, SWT.NONE);
    delete.setText("Delete");
    delete.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            // nothing to do
        }

        public void widgetSelected(SelectionEvent e) {
            if (selectedTableItem != null && !selectedTableItem.getText().equals("")) {
                String alias = selectedTableItem.getText();
                try {
                    KeyStoreManager.getInstance().deleteCertificate(alias);
                    setListElements(KeyStoreManager.getInstance().getCertificates().toArray());
                } catch (CertificateStoreException e1) {
                    setErrorMessage(e1.getMessage());
                }
            }
        }
    });
    fFilteredList.addSelectionListener(new SelectionListenerImplementation(certDetails, certAlias));
    return control;
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.views.emfstorebrowser.views.CertificateSelectionDialog.java

License:Open Source License

/**
 * Overridden method to allow adding further elements onto the dialog
 * composite./*from w ww  .j  a va  2s  . co  m*/
 * 
 * @see org.eclipse.ui.dialogs.ElementListSelectionDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
 * @return Control
 * @param parent
 *            Parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    // standard layout used by dialogue area
    final 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);

    // two column layout composite
    final Composite grid = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(grid);

    // left column composite
    final Composite left = new Composite(grid, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(left);

    // right column composite
    final Composite right = new Composite(grid, SWT.NONE);
    GridLayoutFactory.createFrom(layout).margins(layout.marginWidth, 35).applyTo(right);
    GridDataFactory.fillDefaults().grab(true, true).hint(300, 200).applyTo(right);
    applyDialogFont(right);

    // right column: certificate details
    new Label(right, SWT.NONE).setText(Messages.CertificateSelectionDialog_Alias);
    final Text certAlias = new Text(right, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(certAlias);
    certAlias.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    certAlias.setEditable(false);
    new Label(right, SWT.NONE).setText(Messages.CertificateSelectionDialog_Details);
    final Text certDetails = new Text(right, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().grab(true, false).hint(300, 230).applyTo(certDetails);
    certDetails.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    certDetails.setEditable(false);

    // left column: dialogue area composite (displays certificates and
    // filter)
    final Composite dialogArea = new Composite(left, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(dialogArea);
    final Control control = super.createDialogArea(dialogArea);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(control);

    // left column: import button, composite used to ensure correct
    // alignment
    final Composite certButtonsComposite = new Composite(grid, SWT.NONE);
    GridLayoutFactory.createFrom(layout).numColumns(3).equalWidth(true).margins(layout.marginWidth, 0)
            .applyTo(certButtonsComposite);
    applyDialogFont(certButtonsComposite);
    final Button browse = new Button(certButtonsComposite, SWT.NONE);
    browse.setText(Messages.CertificateSelectionDialog_Import);
    browse.addSelectionListener(new CertificateSelectionListener());

    // Delete certificate
    final Button delete = new Button(certButtonsComposite, SWT.NONE);
    delete.setText(Messages.CertificateSelectionDialog_Delete);
    delete.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            // nothing to do
        }

        public void widgetSelected(SelectionEvent e) {
            if (selectedTableItem != null && StringUtils.isNotBlank(selectedTableItem.getText())) {
                final String alias = selectedTableItem.getText();
                try {
                    KeyStoreManager.getInstance().deleteCertificate(alias);
                    setListElements(KeyStoreManager.getInstance().getCertificates().toArray());
                } catch (final ESCertificateException e1) {
                    setErrorMessage(e1.getMessage());
                }
            }
        }
    });
    fFilteredList.addSelectionListener(new SelectionListenerImplementation(certDetails, certAlias));
    return control;
}

From source file:org.eclipse.emf.eson.ui.editor.tree.XtextMultiEObjectSearchDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite container) {
    Composite parent = new Composite(container, SWT.NONE);
    parent.setLayout(new GridLayout(3, false));
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

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

    createPickerButtons(parent);/*from   w  ww .ja  va  2 s  . c o m*/

    Composite rightComp = new Composite(parent, SWT.NONE);
    selectedElementsLabel = new Label(rightComp, SWT.NONE);
    selectedElementsLabel.setText(SELECTED_ELEMENTS_LABEL);
    selectedElementsLabel.setFont(rightComp.getFont());

    GridLayout rightCompLayout = new GridLayout();
    rightCompLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    rightCompLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    rightCompLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    rightCompLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    rightComp.setLayout(rightCompLayout);
    rightComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(rightComp);

    GridLayout leftCompLayout = (GridLayout) leftComp.getLayout();
    leftCompLayout.marginLeft = rightCompLayout.marginRight = convertHorizontalDLUsToPixels(
            IDialogConstants.HORIZONTAL_MARGIN) / 2;
    leftCompLayout.marginWidth = rightCompLayout.marginWidth = 0;

    selectedTableViewer = new TableViewer(rightComp, getTableStyle());
    selectedTableViewer.setContentProvider(getTableViewer().getContentProvider());
    selectedTableViewer.setLabelProvider(getTableViewer().getLabelProvider());

    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = convertHeightInCharsToPixels(getHeightInChars());
    gd.widthHint = convertWidthInCharsToPixels(getWidthInChars());
    Table table = selectedTableViewer.getTable();
    table.setLayoutData(gd);
    table.setFont(container.getFont());

    Label selectionMessageLabel = new Label(rightComp, SWT.NONE);
    setDefaultGridData(selectionMessageLabel);

    getTableViewer().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            moveToSection();
        }
    });

    getSelectedTableViewer().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            removeFromSelection();
        }
    });

    return leftComp;
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.AvailableIUsPage.java

License:Open Source License

private void createSelectButtons(Composite parent) {
    Composite buttonParent = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;//from   w  w w  .j a va  2  s.com
    gridLayout.marginWidth = 0;
    gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    buttonParent.setLayout(gridLayout);

    GridData data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
    buttonParent.setLayoutData(data);

    Button selectAll = new Button(buttonParent, SWT.PUSH);
    selectAll.setText(ProvUIMessages.SelectableIUsPage_Select_All);
    setButtonLayoutData(selectAll);
    selectAll.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            setAllChecked(true);
        }
    });

    Button deselectAll = new Button(buttonParent, SWT.PUSH);
    deselectAll.setText(ProvUIMessages.SelectableIUsPage_Deselect_All);
    setButtonLayoutData(deselectAll);
    deselectAll.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            setAllChecked(false);
        }
    });

    // dummy to take extra space
    selectionCount = new Label(buttonParent, SWT.NONE);
    data = new GridData(SWT.FILL, SWT.CENTER, true, true);
    data.horizontalIndent = 20; // breathing room
    selectionCount.setLayoutData(data);

    // separator underneath
    Label sep = new Label(buttonParent, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
    data.horizontalSpan = 3;
    sep.setLayoutData(data);
}