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:com.liferay.ide.ui.dialog.ChooseWorkspaceWithPreferenceDialog.java

License:Open Source License

@SuppressWarnings("unchecked")
private boolean createButtons(Composite parent) {

    IConfigurationElement[] settings = SettingsTransfer.getSettingsTransfers();

    String[] enabledSettings = getEnabledSettings(
            IDEWorkbenchPlugin.getDefault().getDialogSettings().getSection(WORKBENCH_SETTINGS));

    Composite panel = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(1, false);

    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    panel.setLayout(layout);/*from   ww  w .j  ava 2 s. c  o m*/
    panel.setFont(parent.getFont());

    Group group = new Group(panel, SWT.NONE);

    group.setText("Copy Settings");
    group.setLayout(layout);
    group.setFont(parent.getFont());

    for (int i = 0; i < settings.length; i++) {
        final IConfigurationElement settingsTransfer = settings[i];

        final Button button = new Button(group, SWT.CHECK);

        button.setText(settings[i].getAttribute(ATT_NAME));

        String helpId = settings[i].getAttribute(ATT_HELP_CONTEXT);

        if (helpId != null)
            PlatformUI.getWorkbench().getHelpSystem().setHelp(button, helpId);

        if (enabledSettings != null && enabledSettings.length > 0) {

            String id = settings[i].getAttribute(ATT_ID);
            for (int j = 0; j < enabledSettings.length; j++) {
                if (enabledSettings[j] != null && enabledSettings[j].equals(id)) {
                    button.setSelection(true);
                    selectedSettings.add(settingsTransfer);
                    break;
                }
            }
        }

        button.setBackground(parent.getBackground());
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (button.getSelection())
                    selectedSettings.add(settingsTransfer);
                else
                    selectedSettings.remove(settingsTransfer);
            }
        });

    }

    return enabledSettings != null && enabledSettings.length > 0;
}

From source file:com.maccasoft.composer.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);//from  w  w  w  .  java  2 s . c  o  m
    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));

    InputStream is = getClass().getResourceAsStream("about.png");
    try {
        ImageLoader loader = new ImageLoader();
        ImageData[] data = loader.load(is);

        final Image image = new Image(Display.getDefault(), data[0]);
        label.setImage(image);
        label.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent arg0) {
                image.dispose();
            }
        });
        is.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    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 fugue = "http://p.yusukekamiyamane.com";
    final String message = title + "\r\n\r\n"
            + "Copyright (c) 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\nand " + fugue;

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

    style = new StyleRange();
    style.start = message.indexOf(fugue);
    style.length = fugue.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);
                        System.out.println("[" + link + "]");
                        Program.launch(link);
                        break;
                    }
                }
            } catch (IllegalArgumentException e) {
                // no character under event.x, event.y
            }
        }
    });

    return content;
}

From source file:com.maccasoft.composer.InstrumentEditor.java

License:Open Source License

protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout();
    layout.numColumns = 0;//from w  ww  .  j a  v a 2 s. c  o m
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    layout.marginTop = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
            IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Button button = createButton(composite, -1, "Get Spin Data");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuilder sb = new StringBuilder();
            sb.append("DAT\n\n");

            sb.append(name.getText().replace(' ', '_'));
            sb.append("\n");

            for (Command cmd : list) {
                if (!cmd.isDisabled()) {
                    sb.append("    " + cmd.toSpinString() + "\n");
                }
            }

            TextDialog dlg = new TextDialog(getShell());
            dlg.setString(sb.toString());
            dlg.open();
        }
    });

    button = createButton(composite, -1, "Get C Data");
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            StringBuilder sb = new StringBuilder();
            sb.append(String.format("uint32_t %s[] = {\n", name.getText().replace(' ', '_')));

            for (Command cmd : list) {
                if (!cmd.isDisabled()) {
                    sb.append("    " + cmd.toCString() + ",\n");
                }
            }

            sb.append("};\n");

            TextDialog dlg = new TextDialog(getShell());
            dlg.setString(sb.toString());
            dlg.open();
        }
    });

    Label label = new Label(composite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    layout.numColumns++;

    button = createButton(composite, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            okPressed();
            setReturnCode(OK);
            close();
        }
    });
    getShell().setDefaultButton(button);

    button = createButton(composite, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL);
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            close();
        }
    });

    return composite;
}

From source file:com.maccasoft.composer.ListSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(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);/*from w w w.j a v  a 2  s  . c o  m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    Label label = new Label(composite, SWT.NONE);
    label.setText(message);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    viewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.widthHint = convertWidthInCharsToPixels(50);
    layoutData.heightHint = viewer.getTable().getItemHeight() * 20;
    viewer.getControl().setLayoutData(layoutData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(elements);

    return composite;
}

From source file:com.maccasoft.composer.TextDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, 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   www  . j  a va 2s  .co m
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    if ("win32".equals(SWT.getPlatform())) { //$NON-NLS-1$
        font = new Font(Display.getDefault(), "Courier New", 10, SWT.NONE); //$NON-NLS-1$
    } else {
        font = new Font(Display.getDefault(), "mono", 10, SWT.NONE); //$NON-NLS-1$
    }

    text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setFont(font);
    text.setLayoutData(new GridData(convertWidthInCharsToPixels(80), convertHeightInCharsToPixels(25)));
    if (data != null) {
        text.setText(data);
    }

    text.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            font.dispose();
        }
    });

    return composite;
}

From source file:com.maccasoft.composer.TextExportDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, 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  a 2s  . c  o  m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    if ("win32".equals(SWT.getPlatform())) { //$NON-NLS-1$
        font = new Font(Display.getDefault(), "Courier New", 10, SWT.NONE); //$NON-NLS-1$
    } else {
        font = new Font(Display.getDefault(), "mono", 10, SWT.NONE); //$NON-NLS-1$
    }

    Composite container = new Composite(composite, SWT.NONE);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = gridLayout.marginHeight = 0;
    container.setLayout(gridLayout);
    spin = new Button(container, SWT.RADIO);
    spin.setText("Spin");
    spin.setSelection(true);
    spin.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTextDump();
            text.setFocus();
        }
    });
    clang = new Button(container, SWT.RADIO);
    clang.setText("C Array");
    clang.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateTextDump();
            text.setFocus();
        }
    });

    text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    text.setFont(font);
    text.setLayoutData(new GridData(convertWidthInCharsToPixels(80), convertHeightInCharsToPixels(25)));

    text.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            font.dispose();
        }
    });
    text.setFocus();

    size = new Label(composite, SWT.NONE);
    size.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));

    updateTextDump();

    return composite;
}

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);/*w w  w. ja  v a  2s . co  m*/
    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 ww.j  a  va 2  s .  co 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();//from  w  w w. j  a  v  a 2 s.  co  m

    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.generic.StringInputDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);

    final FormLayout formLayout = new FormLayout();
    formLayout.spacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    formLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    formLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    container.setLayout(formLayout);/*from   ww w  .j av a2 s.  c  o  m*/

    final Label inputLabel = new Label(container, SWT.NONE);

    inputText = new Text(container, SWT.BORDER);
    AutomationIDHelper.setWidgetID(inputText, INPUT_TEXT_ID);

    inputLabel.setText(label);
    final FormData fd1 = new FormData();
    fd1.left = new FormAttachment(0, 0);
    fd1.top = new FormAttachment(0, FormHelper.VerticalOffset(inputLabel, inputText));
    inputLabel.setLayoutData(fd1);

    if (text != null) {
        inputText.setText(text);
    }

    if (text != null && selectionStart >= 0 && selectionEnd >= 0) {
        inputText.setSelection(selectionStart, selectionEnd);
    } else if (text != null) {
        inputText.setSelection(text.length());
    }

    final FormData fd2 = new FormData();
    fd2.left = new FormAttachment(inputLabel, 0, SWT.RIGHT);
    fd2.top = new FormAttachment(0, 0);
    fd2.right = new FormAttachment(100, 0);
    inputText.setLayoutData(fd2);

    inputText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            processInput();
        }
    });

    ControlSize.setCharWidthHint(inputText, 60);

    return container;
}