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:melnorme.lang.ide.ui.utils.StatusMessageDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    createMessageArea(composite);/*w  w  w .ja  v a 2  s. c  om*/

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING) * 2;
    layout.numColumns = 2;
    composite.setLayout(layout);

    ignore = SWTFactory.createButton(parent, SWT.CHECK, ignoreButtonLabel,
            GridDataFactory.swtDefaults().span(2, 1).create());
    ignore.setSelection(true);

    return composite;
}

From source file:melnorme.util.swt.MetricsUtil.java

License:Open Source License

/** Initializes a layout with dialog unit settings. 
 * @param testControl the control used to obtain FontMetrics. */
public static void initGridLayoutWithDLUs(GridLayout layout, Control testControl) {

    FontMetrics fontMetrics = getFontMetrics(testControl);

    layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.VERTICAL_SPACING);
    layout.marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
}

From source file:msi.gama.lang.gaml.ui.templates.GamlEditTemplateDialog.java

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

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

    ModifyListener listener = new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            doTextWidgetChanged(e.widget);
        }
    };

    createLabel(parent, TemplateDialogMessages.EditTemplateDialog_name);

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

    fNameText = createText(composite);

    createLabel(composite, "Category:");
    Label category = new Label(composite, SWT.NONE);

    // category.addModifyListener(listener);

    createLabel(parent, TemplateDialogMessages.EditTemplateDialog_description);

    fDescriptionText = new Text(parent, SWT.BORDER);
    fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fDescriptionText.addModifyListener(listener);

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

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

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

    fInsertVariableButton = new Button(composite, SWT.NONE);
    fInsertVariableButton.setLayoutData(getButtonGridData());
    fInsertVariableButton.setText(TemplateDialogMessages.EditTemplateDialog_insert_variable);
    fInsertVariableButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            fPatternEditor.getTextWidget().setFocus();
            fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
        }

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

    fDescriptionText.setText(data.getTemplate().getDescription());
    fillMenuPath(category);
    fNameText.setText(data.getTemplate().getName());
    fNameText.addModifyListener(listener);
    applyDialogFont(parent);
    return composite;
}

From source file:name.schedenig.eclipse.grepconsole.util.GridLayoutBuilder.java

License:Open Source License

/**
 * Initialises the layout and its margins based on the current font.
 *///from www.j a va  2  s .  co  m
private void init() {
    layout = new GridLayout();

    if (fontMetrics != null) {
        layout.marginHeight = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
                IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics,
                IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
                IDialogConstants.HORIZONTAL_SPACING);
    }

    layout.marginLeft = layout.marginRight = layout.marginWidth;
    layout.marginTop = layout.marginBottom = layout.marginHeight;
    layout.marginWidth = layout.marginHeight = 0;
}

From source file:net.bioclipse.ui.dialogs.SaveAsDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    // top level composite
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parentComposite, 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);//w ww  .j  a  va  2  s.c om
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(parentComposite.getFont());

    Listener listener = new Listener() {
        public void handleEvent(Event event) {
            setDialogComplete(validatePage());
        }
    };

    resourceGroup = new ResourceAndContainerGroup(composite, listener,
            IDEWorkbenchMessages.SaveAsDialog_fileLabel, formats);
    resourceGroup.setAllowExistingResources(true);

    return parentComposite;
}

From source file:net.enilink.komma.common.ui.dialogs.DiagnosticDialog.java

License:Open Source License

/**
 * This implementation of the <code>Dialog</code> framework method creates
 * and lays out a composite. Subclasses that require a different dialog area
 * may either override this method, or call the <code>super</code>
 * implementation and add controls to the created composite.
 *///w w  w . j a  va2s . c  o m
@Override
protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);
    // create a composite with standard margins and spacing
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 2;
    composite.setLayout(layout);
    GridData childData = new GridData(GridData.FILL_HORIZONTAL);
    childData.horizontalSpan = 2;
    composite.setLayoutData(childData);
    composite.setFont(parent.getFont());
    return composite;
}

From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java

License:Open Source License

/**
 * Creates the dialog's title area./*w  ww.jav a 2  s.c om*/
 * 
 * @param parent
 *            the SWT parent for the title area widgets
 * @return Control with the highest x axis value.
 */
private Control createTitleArea(Composite parent) {

    // add a dispose listener
    parent.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (titleAreaColor != null) {
                titleAreaColor.dispose();
            }
        }
    });
    // Determine the background color of the title bar
    Display display = parent.getDisplay();
    Color background;
    Color foreground;
    if (titleAreaRGB != null) {
        titleAreaColor = new Color(display, titleAreaRGB);
        background = titleAreaColor;
        foreground = null;
    } else {
        background = JFaceColors.getBannerBackground(display);
        foreground = JFaceColors.getBannerForeground(display);
    }

    parent.setBackground(background);
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // Dialog image @ right
    titleImageLabel = new Label(parent, SWT.CENTER);
    titleImageLabel.setBackground(background);
    if (titleAreaImage == null)
        titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
    else
        titleImageLabel.setImage(titleAreaImage);

    FormData imageData = new FormData();
    imageData.top = new FormAttachment(0, 0);
    // Note: do not use horizontalSpacing on the right as that would be a
    // regression from
    // the R2.x style where there was no margin on the right and images are
    // flush to the right
    // hand side. see reopened comments in 41172
    imageData.right = new FormAttachment(100, 0); // horizontalSpacing
    titleImageLabel.setLayoutData(imageData);
    // Title label @ top, left
    titleLabel = new Label(parent, SWT.LEFT);
    JFaceColors.setColors(titleLabel, foreground, background);
    titleLabel.setFont(JFaceResources.getBannerFont());
    titleLabel.setText(" ");//$NON-NLS-1$
    FormData titleData = new FormData();
    titleData.top = new FormAttachment(0, verticalSpacing);
    titleData.right = new FormAttachment(titleImageLabel);
    titleData.left = new FormAttachment(0, horizontalSpacing);
    titleLabel.setLayoutData(titleData);
    // Message image @ bottom, left
    messageImageLabel = new Label(parent, SWT.CENTER);
    messageImageLabel.setBackground(background);
    // Message label @ bottom, center
    messageLabel = new Label(parent, SWT.WRAP | SWT.READ_ONLY);
    JFaceColors.setColors(messageLabel, foreground, background);
    messageLabel.setText(" \n "); // two lines//$NON-NLS-1$
    messageLabel.setFont(JFaceResources.getDialogFont());
    messageLabel.setBackground(JFaceColors.getBannerBackground(Display.getDefault()));

    messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
    // Filler labels
    leftFillerLabel = new Label(parent, SWT.CENTER);
    leftFillerLabel.setBackground(background);
    bottomFillerLabel = new Label(parent, SWT.CENTER);
    bottomFillerLabel.setBackground(background);
    setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    determineTitleImageLargest();
    if (titleImageLargest)
        return titleImageLabel;
    return messageLabel;
}

From source file:net.heartsome.cat.common.ui.wizard.TSTitleAreaDialog.java

License:Open Source License

/**
 * Re-layout the labels for the new message.
 * //w  w w.jav  a 2s.com
 * @param forceLayout
 *            <code>true</code> to force a layout of the shell
 */
private void layoutForNewMessage(boolean forceLayout) {
    int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    // If there are no images then layout as normal
    if (errorMessage == null && messageImage == null) {
        setImageLabelVisible(false);
        setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
    } else {
        messageImageLabel.setVisible(true);
        bottomFillerLabel.setVisible(true);
        leftFillerLabel.setVisible(true);
        /**
         * Note that we do not use horizontalSpacing here as when the
         * background of the messages changes there will be gaps between the
         * icon label and the message that are the background color of the
         * shell. We add a leading space elsewhere to compendate for this.
         */
        FormData data = new FormData();
        data.left = new FormAttachment(0, H_GAP_IMAGE);
        data.top = new FormAttachment(titleLabel, verticalSpacing);
        messageImageLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(messageImageLabel, 0);
        data.left = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(messageLabel, 0, SWT.BOTTOM);
        data.right = new FormAttachment(messageImageLabel, 0, SWT.RIGHT);
        bottomFillerLabel.setLayoutData(data);
        data = new FormData();
        data.top = new FormAttachment(messageImageLabel, 0, SWT.TOP);
        data.left = new FormAttachment(0, 0);
        data.bottom = new FormAttachment(messageImageLabel, 0, SWT.BOTTOM);
        data.right = new FormAttachment(messageImageLabel, 0);
        leftFillerLabel.setLayoutData(data);
        FormData messageLabelData = new FormData();
        messageLabelData.top = new FormAttachment(titleLabel, verticalSpacing);
        messageLabelData.right = new FormAttachment(titleImageLabel);
        messageLabelData.left = new FormAttachment(messageImageLabel, 0);
        messageLabelData.height = messageLabelHeight;
        if (titleImageLargest)
            messageLabelData.bottom = new FormAttachment(titleImageLabel, 0, SWT.BOTTOM);
        messageLabel.setLayoutData(messageLabelData);
    }

    if (forceLayout) {
        getShell().layout();
    } else {
        // Do not layout before the dialog area has been created
        // to avoid incomplete calculations.
        if (dialogArea != null)
            workArea.getParent().layout(true);
    }

    int messageLabelUnclippedHeight = messageLabel.computeSize(messageLabel.getSize().x - xTrim, SWT.DEFAULT,
            true).y;
    boolean messageLabelClipped = messageLabelUnclippedHeight > messageLabel.getSize().y - yTrim;
    if (messageLabel.getData() instanceof ToolTip) {
        ToolTip toolTip = (ToolTip) messageLabel.getData();
        toolTip.hide();
        toolTip.deactivate();
        messageLabel.setData(null);
    }
    if (messageLabelClipped) {
        ToolTip tooltip = new ToolTip(messageLabel, ToolTip.NO_RECREATE, false) {

            protected Composite createToolTipContentArea(Event event, Composite parent) {
                Composite result = new Composite(parent, SWT.NONE);
                result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
                result.setLayout(new GridLayout());
                Text text = new Text(result, SWT.WRAP);
                text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
                text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
                text.setText(messageLabel.getText());
                GridData gridData = new GridData();
                gridData.widthHint = messageLabel.getSize().x;
                text.setLayoutData(gridData);
                Dialog.applyDialogFont(result);
                return result;
            }

            public Point getLocation(Point tipSize, Event event) {
                return messageLabel.getShell().toDisplay(messageLabel.getLocation());
            }
        };
        messageLabel.setData(tooltip);
        tooltip.setPopupDelay(0);
        tooltip.activate();
    }
}

From source file:net.refractions.udig.internal.ui.SendLogDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    setTitle(Messages.SendLogDialog_description);
    ImageDescriptor image = UiPlugin.getDefault().getImageDescriptor(ImageConstants.LOG_WIZ);
    if (image != null)
        setTitleImage(image.createImage());

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parent, SWT.RESIZE);
    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);
    composite.setLayout(layout);/*from w  ww.  j  a v a  2  s.c  om*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    contactLabel = new Label(composite, SWT.NONE);
    contactLabel.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
    contactLabel.setText(Messages.SendLogDialog_contact);

    contact = new Text(composite, SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.horizontalSpan = 2;
    contact.setLayoutData(gridData);
    contact.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            refreshButtons();
        }

    });

    noteLabel = new Label(composite, SWT.NONE);
    noteLabel.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false));
    noteLabel.setText(Messages.SendLogDialog_notes);

    notes = new Text(composite, SWT.WRAP | SWT.BORDER | SWT.MULTI);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.heightHint = notes.getLineHeight() * 2;
    gridData.horizontalSpan = 2;
    notes.setLayoutData(gridData);
    notes.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            refreshButtons();
        }

    });

    logLabel = new Label(composite, SWT.NONE);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.verticalAlignment = SWT.END;
    logLabel.setLayoutData(gridData);
    logLabel.setText(Messages.SendLogDialog_log);

    log = new Text(composite, SWT.WRAP | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    log.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalSpan = 2;
    log.setLayoutData(gridData);
    log.setText(Messages.SendLogDialog_reading);
    log.setEnabled(false);

    //start a thread to acquire the log file
    PopulateLogRunnable populateLog = new PopulateLogRunnable();
    PlatformGIS.run(populateLog);
    contact.setFocus();

    return composite;
}

From source file:net.refractions.udig.internal.ui.SubmitIssueDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    setTitle(Messages.SendLogDialog_description);

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parent, SWT.RESIZE);
    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);
    composite.setLayout(layout);//from  ww w  .j  a  v  a2  s  .  c  o  m
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    // add issue tracker instructions with relevant links
    submitIssueLink = new Link(composite, SWT.WRAP | SWT.READ_ONLY | SWT.MULTI);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.horizontalSpan = 2;
    submitIssueLink.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    submitIssueLink.setLayoutData(gridData);
    submitIssueLink.setText(Messages.SubmitIssueDialog_instructions);
    submitIssueLink.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            UIUtilities.openLink(event.text);
        }
    });

    logLabel = new Label(composite, SWT.NONE);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    gridData.verticalAlignment = SWT.END;
    logLabel.setLayoutData(gridData);
    logLabel.setText(Messages.SendLogDialog_log);

    // add text widget for displaying log file contents
    log = new Text(composite, SWT.WRAP | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    log.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalSpan = 2;
    log.setLayoutData(gridData);
    log.setText(Messages.SendLogDialog_reading);
    log.setEnabled(false);

    // start a thread to acquire the log file
    PopulateLogRunnable populateLog = new PopulateLogRunnable();
    PlatformGIS.run(populateLog);

    return composite;
}