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:com.maccasoft.template.AboutDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite content = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    content.setLayout(layout);/*ww  w . j  a v  a2 s  .c  om*/
    content.setLayoutData(new GridData(GridData.FILL_BOTH));
    content.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    content.setBackgroundMode(SWT.INHERIT_FORCE);

    applyDialogFont(content);

    Label label = new Label(content, SWT.NONE);
    label.setLayoutData(new GridData(SWT.TOP, SWT.RIGHT, false, false));

    final Image image = Main.getImageFromResources(getClass(), "about.png");
    label.setImage(image);
    label.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent arg0) {
            image.dispose();
        }
    });

    String title = Main.APP_TITLE + " " + Main.APP_VERSION;
    final String epl = "http://www.eclipse.org/legal/epl-v10.html";
    final String famfamfam = "http://www.famfamfam.com/lab/icons/silk";
    final String message = title + "\r\n\r\n"
            + "Copyright \u00a9 2016 Marco Maccaferri and others. All rights reserved.\r\n\r\n" + //
            "This program and the accompanying materials are made available under the\r\n" + //
            "terms of the Eclipse Public License v1.0 which accompanies this distribution\r\n" + //
            "and is available at " + epl + "\r\n" + //
            "\r\nIcons from " + famfamfam + "\r\n";

    final StyledText text = new StyledText(content, SWT.READ_ONLY);
    text.setLayoutData(new GridData(SWT.TOP, SWT.RIGHT, true, false));
    text.setCaret(null);
    text.setMargins(0, layout.verticalSpacing,
            convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING), layout.verticalSpacing);
    text.setText(message);

    final List<StyleRange> linkRanges = new ArrayList<StyleRange>();

    StyleRange style = new StyleRange();
    style.start = 0;
    style.length = title.length();
    style.fontStyle = SWT.BOLD;
    text.setStyleRange(style);

    style = new StyleRange();
    style.start = message.indexOf(epl);
    style.length = epl.length();
    style.underline = true;
    style.underlineStyle = SWT.UNDERLINE_LINK;
    text.setStyleRange(style);
    linkRanges.add(style);

    style = new StyleRange();
    style.start = message.indexOf(famfamfam);
    style.length = famfamfam.length();
    style.underline = true;
    style.underlineStyle = SWT.UNDERLINE_LINK;
    text.setStyleRange(style);
    linkRanges.add(style);

    text.addListener(SWT.MouseDown, new Listener() {

        @Override
        public void handleEvent(Event event) {
            try {
                int offset = text.getOffsetAtLocation(new Point(event.x, event.y));
                for (StyleRange style : linkRanges) {
                    if (offset >= style.start && offset < (style.start + style.length)) {
                        String link = text.getText(style.start, style.start + style.length - 1);
                        Program.launch(link);
                        break;
                    }
                }
            } catch (IllegalArgumentException e) {
                // no character under event.x, event.y
            }
        }
    });

    return content;
}

From source file:com.mercatis.lighthouse3.security.DefaultLoginModule.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    this.setTitle(header);

    Composite composite = (Composite) super.createDialogArea(parent);
    Composite c = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, 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);
    c.setLayout(layout);//from  w w w.ja va 2 s  .  c  o m
    c.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(c);

    Label label = new Label(c, SWT.NONE);
    label.setText("Username: ");
    label.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false));
    nameText = new Text(c, SWT.BORDER);
    nameText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));

    label = new Label(c, SWT.NONE);
    label.setText("Password: ");
    label.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false));
    passwordText = new Text(c, SWT.BORDER | SWT.PASSWORD);
    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));

    return c;
}

From source file:com.microsoft.tfs.client.common.ui.controls.generic.BaseControl.java

License:Open Source License

public BaseControl(final Composite parent, final int style) {
    super(parent, style);

    /* Compute metrics in pixels */
    final GC gc = new GC(this);
    final FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();/*  www . j av  a 2s  .c  om*/

    horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING);
    verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);

    spacing = Math.max(horizontalSpacing, verticalSpacing);

    horizontalMargin = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    verticalMargin = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);

    minimumMessageAreaWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ChangesetDetailsDialog.java

License:Open Source License

@Override
protected Control createButtonBar(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(composite);

    final GridLayout layout = new GridLayout(4, false);
    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);/*from w  w w .  ja  v  a2s. c  o  m*/

    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.getString("ChangesetDetailsDialog.ChangesetLabelText")); //$NON-NLS-1$

    Text text = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
    text.setText(String.valueOf(changeset.getChangesetID()));
    GridDataBuilder.newInstance().hFill().applyTo(text);

    label = new Label(composite, SWT.NONE);
    label.setText(Messages.getString("ChangesetDetailsDialog.ByUserLabelText")); //$NON-NLS-1$

    text = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
    text.setText(changeset.getOwnerDisplayName());
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(text);

    label = new Label(composite, SWT.NONE);
    label.setText(Messages.getString("ChangesetDetailsDialog.CreatedOnLabelText")); //$NON-NLS-1$

    text = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
    text.setText(dateFormat.format(changeset.getDate().getTime()));
    GridDataBuilder.newInstance().hFill().applyTo(text);
    ControlSize.setCharWidthHint(text, 30);

    final Control control = super.createButtonBar(composite);
    GridDataBuilder.newInstance().hSpan(2).hAlign(SWT.END).applyTo(control, true);

    final GridLayout subLayout = (GridLayout) ((Composite) control).getLayout();
    subLayout.marginHeight = 0;
    subLayout.marginWidth = 0;

    return composite;
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.DetectLocalChangesDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    final GridLayout layout = new GridLayout(1, true);

    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);

    dialogArea.setLayout(layout);/* ww  w  .j a v a2s  .  co  m*/

    final Label explanationLabel = new Label(dialogArea, SWT.WRAP);
    explanationLabel.setText(Messages.getString("ReturnOnlineDialog.ExplainLabelText")); //$NON-NLS-1$
    explanationLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));

    changesTable = new ReturnOnlineChangesTable(dialogArea, SWT.NONE);
    changesTable.setChanges(changes);
    changesTable.setCheckedChanges(changes);
    changesTable.addCheckboxListener(new CheckboxListener() {
        @Override
        public void checkedElementsChanged(final CheckboxEvent event) {
            getButton(IDialogConstants.OK_ID).setEnabled(changesTable.getCheckedElements().length > 0);
        }
    });
    AutomationIDHelper.setWidgetID(changesTable, RETURNONLINECHANGES_TABLE_ID);
    ControlSize.setCharHeightHint(changesTable, 10);
    ControlSize.setCharWidthHint(changesTable, 80);

    final GridData changesData = new GridData(SWT.FILL, SWT.FILL, true, true);
    changesData.grabExcessHorizontalSpace = true;
    changesData.grabExcessVerticalSpace = true;
    changesTable.setLayoutData(changesData);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.MultipleConflictResolutionDialog.java

License:Open Source License

@Override
protected void hookAddToDialogArea(final Composite dialogArea) {
    final GridLayout dialogLayout = new GridLayout(1, true);
    dialogLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    dialogLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    dialogLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    dialogArea.setLayout(dialogLayout);//from  w w  w .j  a v  a  2 s  . com

    controlsByCategory.clear();

    final Label explanationLabel = new Label(dialogArea, SWT.WRAP);
    explanationLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    explanationLabel.setText(Messages.getString("MultipleConflictResolutionDialog.ExplainLabelText")); //$NON-NLS-1$

    /* Add some additional spacing */
    final Composite spacer = new Composite(dialogArea, SWT.NONE);
    spacer.setLayoutData(new GridData(1, 1));

    // get the conflict types...
    final Iterator i = descriptionsByCategory.keySet().iterator();
    while (i.hasNext()) {
        final ConflictCategory conflictCategory = (ConflictCategory) i.next();
        final List descriptions = (List) descriptionsByCategory.get(conflictCategory);

        final ConflictCategory category = ((ConflictDescription) descriptions.get(0)).getConflictCategory();

        final MultipleConflictResolutionControl resolveControl = new MultipleConflictResolutionControl(
                dialogArea, SWT.NONE);

        resolveControl.setConflictCategory(category);
        resolveControl.setConflictCount(descriptions.size());

        resolveControl.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                updateSelection();
            }
        });

        resolveControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        controlsByCategory.put(conflictCategory, resolveControl);
    }
}

From source file:com.microsoft.tfs.client.common.ui.editors.ConflictResolutionEditor.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);

    /* Compute metrics in pixels */
    final GC gc = new GC(composite);
    final FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();//from w w  w .  j a  va  2 s .  com

    Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING);
    Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    final int marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_MARGIN);
    final int marginHeight = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.VERTICAL_MARGIN);

    final GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    final Composite summaryComposite = new Composite(composite, SWT.NONE);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(summaryComposite);

    final GridLayout summaryLayout = new GridLayout(1, false);
    summaryLayout.horizontalSpacing = 0;
    summaryLayout.verticalSpacing = 0;
    summaryLayout.marginWidth = marginWidth;
    summaryLayout.marginHeight = marginHeight;
    summaryComposite.setLayout(summaryLayout);
    summaryComposite.setBackground(getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));

    summaryLabel = new Label(summaryComposite, SWT.NONE);
    summaryLabel.setBackground(getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    summaryLabel.setForeground(getSite().getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(summaryLabel);

    final Label separatorLabel = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(separatorLabel);

    final Composite toolbarComposite = new Composite(composite, SWT.NONE);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(toolbarComposite);

    final GridLayout toolbarCompositeLayout = new GridLayout(1, false);
    toolbarCompositeLayout.horizontalSpacing = 0;
    toolbarCompositeLayout.verticalSpacing = 0;
    toolbarCompositeLayout.marginWidth = marginWidth;
    toolbarCompositeLayout.marginHeight = 0;
    toolbarComposite.setLayout(toolbarCompositeLayout);

    toolbar = new ToolBar(toolbarComposite, SWT.HORIZONTAL | SWT.FLAT | SWT.RIGHT);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(toolbar);

    setupToolbar(toolbar);

    conflictTable = new ConflictTable(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    conflictTable.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateSelection();
        }
    });

    final MenuManager menuManager = new MenuManager("#popup"); //$NON-NLS-1$
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {
        @Override
        public void menuAboutToShow(final IMenuManager manager) {
            fillContextMenu(manager);
        }
    });
    conflictTable.setMenu(menuManager.createContextMenu(conflictTable));

    GridDataBuilder.newInstance().grab().fill().applyTo(conflictTable);

    getSite().setSelectionProvider(conflictTable);

    /*
     * Set up the resolution options control
     */

    conflictResolutionControl = new ConflictResolutionControl(composite, SWT.NONE);
    conflictResolutionControl.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent e) {
            conflictTable.setSelection(e.getSelection());
        }
    });
    conflictResolutionControl.addConflictResolutionSelectionListener(new ConflictResolutionSelectionListener() {
        @Override
        public void conflictResolutionSelected(final ConflictDescription[] conflictDescriptions,
                final ConflictResolution resolution) {
            if (conflictDescriptions.length == 1) {
                resolveConflict(conflictDescriptions[0], resolution);
            } else {
                resolveConflicts(conflictDescriptions, resolution);
            }
        }
    });
    conflictResolutionControl.addConflictResolutionCancelledListener(new ConflictResolutionCancelledListener() {
        @Override
        public void conflictResolutionCancelled(final ConflictDescription conflictDescription,
                final ConflictResolution resolution) {
            resolution.removeStatusListener(ConflictResolutionEditor.this);
            resolution.cancel();
        }
    });
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(conflictResolutionControl);

    setPartName(Messages.getString("ConflictResolutionEditor.PartName")); //$NON-NLS-1$

    if (needsPaint == true) {
        if (initialConflicts == null) {
            queryConflicts(null);
        } else {
            setConflictDescriptions(initialConflicts);
        }
    } else {
        updateSummary();
        updateSelection();
    }

    hasPainted = true;
}

From source file:com.microsoft.tfs.client.common.ui.editors.HistoryEditor.java

License:Open Source License

@Override
public void createPartControl(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);

    /* Compute metrics in pixels */
    final GC gc = new GC(composite);
    final FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();//w  ww .  j  a  va 2 s . co m

    final int horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_SPACING);
    final int verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics,
            IDialogConstants.VERTICAL_SPACING);
    final int marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_MARGIN);
    final int marginHeight = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.VERTICAL_MARGIN);

    final GridLayout layout = new GridLayout(1, false);
    layout.horizontalSpacing = horizontalSpacing;
    layout.verticalSpacing = verticalSpacing;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    final Composite locationComposite = new Composite(composite, SWT.NONE);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(locationComposite);

    final GridLayout locationLayout = new GridLayout(3, false);
    locationLayout.horizontalSpacing = horizontalSpacing;
    locationLayout.verticalSpacing = verticalSpacing;
    locationLayout.marginWidth = marginWidth;
    locationLayout.marginHeight = marginHeight;
    locationComposite.setLayout(locationLayout);

    final Label locationLabel = new Label(locationComposite, SWT.NONE);
    locationLabel.setText(Messages.getString("HistoryEditor.SourceLocationLabel")); //$NON-NLS-1$

    locationText = new Text(locationComposite, SWT.BORDER | SWT.READ_ONLY);
    GridDataBuilder.newInstance().hGrab().hFill().applyTo(locationText);

    final Button refreshButton = new Button(locationComposite, SWT.PUSH);

    /* Icons in buttons look good on Windows, strange elsewhere. */
    if (Platform.isCurrentPlatform(Platform.WINDOWS)) {
        refreshButton.setImage(
                imageHelper.getImage(TFSCommonUIImages.getImageDescriptor(TFSCommonUIImages.IMG_REFRESH)));
    }

    refreshButton.setText(Messages.getString("HistoryEditor.RefreshActionText")); //$NON-NLS-1$
    GridDataBuilder.newInstance().applyTo(refreshButton);

    historyControl = new HistoryCombinedControl(composite, SWT.FULL_SELECTION | SWT.MULTI);
    GridDataBuilder.newInstance().grab().fill().hSpan(3).applyTo(historyControl);

    historyControl.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });

    getSite().setSelectionProvider(historyControl);

    createActions();

    // getEditorSite().getActionBars().setGlobalActionHandler(
    // ActionFactory.COPY.getId(),
    // historyControl.getCopyAction());
    // getEditorSite().getActionBars().updateActionBars();
    refreshButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            refresh();

        }

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
            refresh();
        }
    });

    setPartName(Messages.getString("HistoryEditor.PartName")); //$NON-NLS-1$
    contributeActions();

    TFSCommonUIClientPlugin.getDefault().getProductPlugin().getRepositoryManager()
            .addListener(repositoryManagerListener);
}

From source file:com.microsoft.tfs.client.common.ui.framework.dialog.BaseDialog.java

License:Open Source License

/**
 * This method will provide the vertical spacing (in pixels) for controls on
 * this platform./*from ww w .j a  v a 2  s  .  com*/
 *
 * @return Vertical spacing of controls (in pixels)
 */
public int getVerticalSpacing() {
    return convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
}

From source file:com.microsoft.tfs.client.common.ui.framework.dialog.ExtendedButtonDialog.java

License:Open Source License

protected Control createExtendedButtonBar(final Composite parent) {
    final 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  a2s . c o m*/
    final 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);
    composite.setFont(parent.getFont());

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