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

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

Introduction

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

Prototype

int VERTICAL_SPACING

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

Click Source Link

Document

Vertical spacing in dialog units (value 4).

Usage

From source file:ac.soton.multisim.ui.dialogs.SimulationSettingsDialog.java

License:Open Source License

/**
 * Creates form data attached to provided control.
 * //from  ww w  .  j av a 2s.  c o  m
 * @param control attached control
 * @param stretch stretch horizontally
 * @return
 */
private FormData getAttachedData(Control control, boolean stretch) {
    FormData layoutData = new FormData();
    layoutData.top = new FormAttachment(control, IDialogConstants.VERTICAL_SPACING);
    layoutData.left = new FormAttachment(0);
    if (stretch)
        layoutData.right = new FormAttachment(100);
    return layoutData;
}

From source file:au.com.cybersearch2.controls.DialogPixels.java

License:Open Source License

public DialogPixels(FontMetrics fontMetrics) {
    marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    marginHeight = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
    horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING);
    verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    buttonWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
}

From source file:au.gov.ansto.bragg.quokka.ui.workflow.AddConfigDialog.java

License:Open Source License

protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1; // this is incremented by createButton
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0; //convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = 0; //convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);/* w ww . ja  v  a2  s.c o m*/

    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | 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:au.gov.ga.earthsci.discovery.csw.CSWURLSelectionDialog.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    initializeDialogUnits(comp);//w w  w.  ja va 2 s.  c  om
    GridLayout layout = new GridLayout();
    layout.marginTop = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);

    urlList = new org.eclipse.swt.widgets.List(comp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    urlList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    int maxCountOfWms = 0;
    int selectedIndex = -1;
    for (int i = 0; i < urls.size(); i++) {
        URL url = urls.get(i);
        String urlString = url.toString();
        urlList.add(urlString);
        int countOfWms = countStringOccurences(urlString.toLowerCase(), "wms"); //$NON-NLS-1$
        if (countOfWms > maxCountOfWms) {
            maxCountOfWms = countOfWms;
            selectedIndex = i;
        }
    }
    if (selectedIndex < 0 && !urls.isEmpty()) {
        selectedIndex = 0;
    }
    if (selectedUrl != null) {
        int indexOfSelectedUrl = urls.indexOf(selectedUrl);
        selectedIndex = indexOfSelectedUrl >= 0 ? indexOfSelectedUrl : selectedIndex;
    }
    if (selectedIndex >= 0) {
        urlList.select(selectedIndex);
    }
    urlList.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            validate();
        }
    });

    getCapabilitiesButton = new Button(comp, SWT.CHECK);
    getCapabilitiesButton.setText(Messages.CSWURLSelectionDialog_GetCapabilitiesButtonText);
    getCapabilitiesButton.setSelection(true);
    getCapabilitiesButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            validate();
        }
    });

    finalUrlLabel = new Label(comp, SWT.NONE);
    finalUrlLabel.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    comp.setLayout(layout);

    Dialog.applyDialogFont(comp);
    return comp;
}

From source file:au.gov.ga.earthsci.discovery.darwin.DarwinURLSelectionDialog.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    GridLayout layout = new GridLayout();
    layout.marginTop = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    comp.setLayout(layout);/*w w  w.j  a  v  a  2  s  .co  m*/
    initializeDialogUnits(comp);

    viewer = new TableViewer(comp, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    //set max size (actual size is calculated below):
    gd.widthHint = 600;
    gd.heightHint = 400;
    viewer.getTable().setLayoutData(gd);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(urls);

    DarwinDiscoveryResultURL longestUrl = urlWithLongestName(urls);
    if (longestUrl != null) {
        GC gc = new GC(viewer.getTable());
        Point point = gc.textExtent(longestUrl.getName());
        gc.dispose();
        gd.widthHint = Math.min(gd.widthHint, point.x);
    }
    int height = viewer.getTable().getItemHeight() * urls.size() + viewer.getTable().getHeaderHeight();
    if (height < gd.heightHint) {
        //if height of all rows is less than the max height, then use the default height:
        gd.heightHint = SWT.DEFAULT;
    }

    //keep the column width in sync with the table width
    final TableColumn resultsColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
    Listener resizeListener = new Listener() {
        @Override
        public void handleEvent(Event event) {
            resultsColumn.setWidth(viewer.getTable().getClientArea().width);
        }
    };
    viewer.getControl().addListener(SWT.Resize, resizeListener);
    viewer.getControl().addListener(SWT.Paint, resizeListener);

    if (selected != null) {
        viewer.setSelection(new StructuredSelection(selected));
    } else if (urls.size() == 1) {
        viewer.getTable().select(0);
    } else {
        //if there is a WMS url, select it by default
        for (DarwinDiscoveryResultURL url : urls) {
            if (url.getProtocol().toLowerCase().contains("wms")) //$NON-NLS-1$
            {
                viewer.setSelection(new StructuredSelection(url));
                break;
            }
        }
    }

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            validate();
        }
    });

    ColumnViewerToolTipSupport.enableFor(viewer);

    urlLabel = new CLabel(comp, SWT.NONE);
    urlLabel.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    Dialog.applyDialogFont(comp);
    return comp;
}

From source file:au.gov.ga.earthsci.discovery.ui.preferences.DiscoveryServicesPreferencePage.java

License:Apache License

@Override
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    composite.setLayoutData(gd);/*  w  w  w.  ja  v  a2  s .  c om*/

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    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);

    table = new Table(composite,
            SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_WIDTH);
    data.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT);
    table.setLayoutData(data);

    viewer = new CheckboxTableViewer(table);

    // Key listener for delete
    table.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                removeSelected();
            }
        }
    });
    setTableColumns();

    viewer.setComparator(comparator);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new DiscoveryServiceLabelProvider());

    stagingSet.clear();
    stagingSet.addAll(DiscoveryServiceManager.getServices());
    viewer.setInput(stagingSet);

    viewer.setCellModifier(new ICellModifier() {
        @Override
        public boolean canModify(Object element, String property) {
            return element instanceof IDiscoveryService;
        }

        @Override
        public Object getValue(Object element, String property) {
            String name = ((IDiscoveryService) element).getName();
            return name != null ? name : ""; //$NON-NLS-1$
        }

        @Override
        public void modify(Object element, String prop, Object value) {
            if (value != null && value.toString().length() >= 0) {
                IDiscoveryService service;
                if (element instanceof Item) {
                    service = (IDiscoveryService) ((Item) element).getData();
                } else if (element instanceof IDiscoveryService) {
                    service = (IDiscoveryService) element;
                } else {
                    return;
                }
                if (!value.toString().equals(service.getName())) {
                    Map<IDiscoveryServiceProperty<?>, Object> propertyValues = new HashMap<IDiscoveryServiceProperty<?>, Object>();
                    IDiscoveryServiceProperty<?>[] properties = service.getProvider().getProperties();
                    if (properties != null) {
                        for (IDiscoveryServiceProperty<?> property : properties) {
                            propertyValues.put(property, property.getValue(service));
                        }
                    }

                    IDiscoveryService replacement = service.getProvider().createService(value.toString(),
                            service.getServiceURL(), propertyValues);
                    replacement.setEnabled(service.isEnabled());
                    stagingSet.remove(service);
                    stagingSet.add(replacement);
                    viewer.refresh();
                }
            }
        }
    });
    viewer.setColumnProperties(new String[] { "name" }); //$NON-NLS-1$
    viewer.setCellEditors(new CellEditor[] { new TextCellEditor(table) });

    viewer.setCheckStateProvider(new ICheckStateProvider() {
        @Override
        public boolean isChecked(Object element) {
            return ((IDiscoveryService) element).isEnabled();
        }

        @Override
        public boolean isGrayed(Object element) {
            return false;
        }
    });

    viewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            IDiscoveryService service = (IDiscoveryService) event.getElement();
            if (!originalEnablement.containsKey(service)) {
                originalEnablement.put(service, service.isEnabled());
            }
            service.setEnabled(event.getChecked());
            viewer.refresh();
            validateButtons();
        }
    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            validateButtons();
        }
    });

    Composite verticalButtonBar = createVerticalButtonBar(composite);
    data = new GridData(SWT.FILL, SWT.FILL, false, false);
    data.verticalAlignment = SWT.TOP;
    data.verticalIndent = 0;
    verticalButtonBar.setLayoutData(data);
    validateButtons();

    return composite;
}

From source file:au.gov.ga.earthsci.discovery.ui.preferences.DiscoveryServicesPreferencePage.java

License:Apache License

private Composite createVerticalButtonBar(Composite parent) {
    // Create composite.
    Composite composite = new Composite(parent, SWT.NONE);
    initializeDialogUnits(composite);// w w w  .  j  a  va 2 s  .  c o m

    // create a layout with spacing and margins appropriate for the font
    // size.
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 5;
    layout.marginHeight = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);

    createVerticalButtons(composite);
    return composite;
}

From source file:au.gov.ga.earthsci.discovery.ui.preferences.EditDiscoveryServiceDialog.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    initializeDialogUnits(comp);//from   w  w w.j  a v  a2s  .  c o  m
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginTop = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);

    createTypeCombo(comp);
    createNameField(comp);
    createLocationField(comp);
    createProviderPropertyControls(comp, false);

    comp.setLayout(layout);
    GridData data = new GridData();
    comp.setLayoutData(data);

    Dialog.applyDialogFont(comp);
    return comp;
}

From source file:au.gov.ga.earthsci.eclipse.extras.ide.ChooseWorkspaceDialog.java

License:Open Source License

/**
 * The main area of the dialog is just a row with the current selection
 * information and a drop-down of the most recently used workspaces.
 *//*from  w  w w  .jav  a2  s .  c  om*/
private void createWorkspaceBrowseRow(Composite parent) {
    Composite panel = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    panel.setLayout(layout);
    panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    panel.setFont(parent.getFont());

    Label label = new Label(panel, SWT.NONE);
    label.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_workspaceEntryLabel);

    text = new Combo(panel, SWT.BORDER | SWT.LEAD | SWT.DROP_DOWN);
    text.setFocus();
    text.setLayoutData(new GridData(400, SWT.DEFAULT));
    text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            Button okButton = getButton(Window.OK);
            if (okButton != null && !okButton.isDisposed()) {
                boolean nonWhitespaceFound = false;
                String characters = getWorkspaceLocation();
                for (int i = 0; !nonWhitespaceFound && i < characters.length(); i++) {
                    if (!Character.isWhitespace(characters.charAt(i))) {
                        nonWhitespaceFound = true;
                    }
                }
                okButton.setEnabled(nonWhitespaceFound);
            }
        }
    });
    setInitialTextValues(text);

    Button browseButton = new Button(panel, SWT.PUSH);
    browseButton.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_browseLabel);
    setButtonLayoutData(browseButton);
    GridData data = (GridData) browseButton.getLayoutData();
    data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
    browseButton.setLayoutData(data);
    browseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
            dialog.setText(IDEWorkbenchMessages.ChooseWorkspaceDialog_directoryBrowserTitle);
            dialog.setMessage(IDEWorkbenchMessages.ChooseWorkspaceDialog_directoryBrowserMessage);
            dialog.setFilterPath(getInitialBrowsePath());
            String dir = dialog.open();
            if (dir != null) {
                text.setText(TextProcessor.process(dir));
            }
        }
    });
}

From source file:au.gov.ga.earthsci.eclipse.extras.ide.ChooseWorkspaceWithSettingsDialog.java

License:Open Source License

/**
 * Create the controls for selecting the controls we are going to export.
 * //from   ww w.j ava  2  s.  c o  m
 * @param workArea
 */
private void createSettingsControls(Composite workArea) {
    final FormToolkit toolkit = new FormToolkit(workArea.getDisplay());
    workArea.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            toolkit.dispose();

        }
    });
    final ScrolledForm form = toolkit.createScrolledForm(workArea);
    form.setBackground(workArea.getBackground());
    form.getBody().setLayout(new GridLayout());

    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    form.setLayoutData(layoutData);
    final ExpandableComposite expandable = toolkit.createExpandableComposite(form.getBody(),
            ExpandableComposite.TWISTIE);
    expandable.setText(IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SettingsGroupName);
    expandable.setBackground(workArea.getBackground());
    expandable.setLayout(new GridLayout());
    expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    expandable.addExpansionListener(new IExpansionListener() {

        boolean notExpanded = true;

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanged(org.eclipse.ui.forms.events.ExpansionEvent)
         */
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
            if (e.getState() && notExpanded) {
                getShell().setRedraw(false);
                Rectangle shellBounds = getShell().getBounds();
                int entriesToShow = Math.min(4, SettingsTransfer.getSettingsTransfers().length);

                shellBounds.height += convertHeightInCharsToPixels(entriesToShow)
                        + IDialogConstants.VERTICAL_SPACING;
                getShell().setBounds(shellBounds);
                getShell().setRedraw(true);
                notExpanded = false;
            }

        }

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.ui.forms.events.IExpansionListener#expansionStateChanging(org.eclipse.ui.forms.events.ExpansionEvent)
         */
        public void expansionStateChanging(ExpansionEvent e) {
            // Nothing to do here

        }
    });

    Composite sectionClient = toolkit.createComposite(expandable);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setBackground(workArea.getBackground());

    if (createButtons(toolkit, sectionClient))
        expandable.setExpanded(true);

    expandable.setClient(sectionClient);

}