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

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

Introduction

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

Prototype

int MINIMUM_MESSAGE_AREA_WIDTH

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

Click Source Link

Document

Minimum width of message area in dialog units (value 300).

Usage

From source file:com.genuitec.eclipse.gerrit.tools.utils.MessageLinkDialog.java

License:Open Source License

/**
 * Create the area the message will be shown in.
 * <p>/*from  w  w  w .ja va 2s  .  c  o  m*/
 * The parent composite is assumed to use GridLayout as its layout manager,
 * since the parent is typically the composite created in
 * {@link Dialog#createDialogArea}.
 * </p>
 * <p>
 * <strong>Note:</strong> Clients are expected to call this method,
 * otherwise neither the icon nor the message will appear.
 * </p>
 * 
 * @param composite
 *            The composite to parent from.
 * @return Control
 */
protected Control createMessageArea(Composite composite) {
    // create composite
    // create image
    Image image = getImage();
    if (image != null) {
        imageLabel = new Label(composite, SWT.NULL);
        image.setBackground(imageLabel.getBackground());
        imageLabel.setImage(image);
        // addAccessibleListeners(imageLabel, image);
        GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
    }
    // create message
    if (message != null) {
        linkLabel = new Link(composite, getMessageLabelStyle());
        linkLabel.setText(message);

        linkLabel.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                if (linkDialogListener != null) {
                    linkDialogListener.linkSelected(e);
                }
            }
        });

        GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false)
                .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH), SWT.DEFAULT)
                .applyTo(linkLabel);
    }
    return composite;
}

From source file:com.github.fengtan.sophie.dialogs.CComboDialog.java

License:Open Source License

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

    // Create label.
    Label label = new Label(composite, SWT.WRAP);
    GridData grid = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    grid.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setText(text);/*from ww  w .j  a va  2  s  . co m*/
    label.setLayoutData(grid);
    label.setFont(parent.getFont());

    // Create drop-down list.
    combo = new Combo(composite, SWT.SINGLE | SWT.BORDER);
    combo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    combo.setItems(items);

    applyDialogFont(composite);
    return composite;
}

From source file:com.github.fengtan.sophie.dialogs.ConnectDialog.java

License:Open Source License

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

    // Create radio buttons from the connection types enum.
    for (final SolrConnectionType type : SolrConnectionType.values()) {
        Button button = new Button(composite, SWT.RADIO);
        button.setText(type.getTypeName());
        button.addSelectionListener(new SelectionAdapter() {
            @Override//from   w  w w  .  j ava  2  s.  co  m
            public void widgetSelected(SelectionEvent e) {
                selectedType = type;
                label.setText(selectedType.getValueLabel());
                combo.setText(selectedType.getValueDefault());
                super.widgetSelected(e);
            }
        });
        if (type == selectedType) {
            button.setSelection(true);
        }
        buttons[type.ordinal()] = button;
    }

    // Create label.
    label = new Label(composite, SWT.WRAP);
    label.setText(selectedType.getValueLabel());
    GridData grid = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    grid.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(grid);
    label.setFont(parent.getFont());

    // Create combo. 
    combo = new Combo(composite, SWT.SINGLE | SWT.BORDER);
    combo.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    String[] favorites = Config.getFavorites();
    String[] items = ArrayUtils.isNotEmpty(favorites) ? favorites
            : new String[] { selectedType.getValueDefault() };
    combo.setItems(items);
    combo.setText(items[0]);

    applyDialogFont(composite);
    return composite;
}

From source file:com.github.fengtan.sophie.dialogs.ExceptionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    ((GridLayout) composite.getLayout()).numColumns = 2;

    // Create image.
    Image image = parent.getDisplay().getSystemImage(SWT.ICON_ERROR);
    Label labelImg = new Label(composite, SWT.WRAP);
    labelImg.setImage(image);/*from  w  w  w  .ja  v a 2 s . c om*/

    // Create label with the exception's message.
    Label labelTxt = new Label(composite, SWT.WRAP);
    labelTxt.setText(throwable.getMessage());
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    labelTxt.setLayoutData(data);

    return composite;
}

From source file:com.github.fengtan.sophie.dialogs.MultipleInputDialog.java

License:Open Source License

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

    // Create grid.
    GridData grid = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    grid.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);

    // Create widgets.
    inputs = new Text[texts.length];
    for (int i = 0; i < texts.length; i++) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(texts[i]);//from w  ww.  j a  va2s. co  m
        label.setLayoutData(grid);
        label.setFont(parent.getFont());
        inputs[i] = new Text(composite, SWT.SINGLE | SWT.BORDER);
        inputs[i].setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
        if (i < defaultValues.length) {
            inputs[i].setText(defaultValues[i]);
        }
    }

    applyDialogFont(composite);
    return composite;
}

From source file:com.google.dart.tools.ui.internal.dialogs.SortMembersMessageDialog.java

License:Open Source License

@Override
protected Control createMessageArea(Composite parent) {
    initializeDialogUnits(parent);/*from www .j a  v a  2 s  .c  o m*/

    Composite messageComposite = new Composite(parent, SWT.NONE);
    messageComposite.setFont(parent.getFont());
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    messageComposite.setLayout(layout);
    messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    createLinkControl(messageComposite);

    int indent = convertWidthInCharsToPixels(3);

    fNotSortAllRadio.doFillIntoGrid(messageComposite, 1);
    LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null), indent);

    fSortAllRadio.doFillIntoGrid(messageComposite, 1);
    LayoutUtil.setHorizontalIndent(fSortAllRadio.getSelectionButton(null), indent);

    final Composite warningComposite = new Composite(messageComposite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    warningComposite.setLayout(layout);
    warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    warningComposite.setFont(messageComposite.getFont());

    Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    final Label imageLabel1 = new Label(warningComposite, SWT.LEFT | SWT.WRAP);
    imageLabel1.setImage(image);
    imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));

    final Label label = new Label(warningComposite, SWT.WRAP);
    label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label);
    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
    gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(gridData);
    label.setFont(warningComposite.getFont());

    fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() {
        @Override
        public void dialogFieldChanged(DialogField field) {
            imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
            label.setEnabled(!fNotSortAllRadio.isSelected());
        }
    });
    imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
    label.setEnabled(!fNotSortAllRadio.isSelected());

    return messageComposite;
}

From source file:com.google.dart.tools.ui.internal.dialogs.SortMembersMessageDialog.java

License:Open Source License

private Control createLinkControl(Composite composite) {
    Link link = new Link(composite, SWT.WRAP | SWT.RIGHT);
    link.setText(DialogsMessages.SortMembersMessageDialog_description);
    link.addSelectionListener(new SelectionAdapter() {
        @Override/*from  www. jav a2 s .c om*/
        public void widgetSelected(SelectionEvent e) {
            openCodeTempatePage(CodeTemplateContextType.CONSTRUCTORCOMMENT_ID);
        }
    });
    link.setToolTipText(DialogsMessages.SortMembersMessageDialog_link_tooltip);
    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
    gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);// convertWidthInCharsToPixels(60);
    link.setLayoutData(gridData);
    link.setFont(composite.getFont());

    return link;
}

From source file:com.google.gapid.views.ErrorDialog.java

License:Apache License

public static void showErrorDialog(Shell shell, String text, String detailString) {
    new IconAndMessageDialog(shell) {
        private Group details;

        @Override/*  w  w  w.j av a2  s.  c om*/
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText("Error");
        }

        @Override
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite container = (Composite) super.createDialogArea(parent);
            ((GridLayout) container.getLayout()).numColumns = 2;
            createMessageArea(container);

            String msg = String.format(Messages.ERROR_MESSAGE, text);
            withLayoutData(createTextbox(container, SWT.WRAP | SWT.READ_ONLY, msg),
                    withSizeHints(new GridData(SWT.FILL, SWT.CENTER, true, false), getWidthHint(), SWT.DEFAULT))
                            .setBackground(container.getBackground());

            if (detailString != null) {
                ExpandBar bar = withLayoutData(new ExpandBar(container, SWT.NONE),
                        withSpans(new GridData(SWT.FILL, SWT.TOP, true, false), 2, 1));
                new ExpandItem(bar, SWT.NONE, 0).setText("Details...");

                bar.addListener(SWT.Expand, e -> {
                    createDetails(container);
                    Point curr = getShell().getSize();
                    Point want = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
                    if (want.y > curr.y) {
                        getShell().setSize(
                                new Point(curr.x, curr.y + Math.min(MAX_DETAILS_SIZE, want.y - curr.y)));
                    } else {
                        details.requestLayout();
                    }
                });

                bar.addListener(SWT.Collapse, e -> {
                    Point curr = getShell().getSize();
                    if (details != null) {
                        details.dispose();
                        details = null;
                    }
                    Point want = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
                    if (want.y < curr.y) {
                        getShell().setSize(new Point(curr.x, want.y));
                    }
                });
            }

            return container;
        }

        private int getWidthHint() {
            return convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        }

        private void createDetails(Composite container) {
            details = createGroup(container, "");
            GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(details);
            Composite inner = createComposite(details, new GridLayout(1, false));
            withLayoutData(createTextbox(inner, DETAILS_STYLE, detailString),
                    new GridData(SWT.FILL, SWT.FILL, true, true));
            withLayoutData(createLink(inner, "<a>File a bug</a> on GitHub", e -> {
                Program.launch(getFileBugUrl());
            }), new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));
            withLayoutData(createLink(inner, "<a>Show logs</a> directory", e -> {
                AboutDialog.showLogDir();
            }), new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));
        }

        private String getFileBugUrl() {
            Escaper esc = UrlEscapers.urlFormParameterEscaper();
            return String.format(FILE_BUG_URL, esc.escape(text), esc.escape(Messages.BUG_BODY));
        }

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true).setFocus();
        }

        @Override
        protected Image getImage() {
            return getErrorImage();
        }
    }.open();
}

From source file:com.ibm.research.tagging.core.ui.dialogs.QuickTagDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    // create message

    Label label = new Label(composite, SWT.WRAP);
    label.setText(fMessage);/*from ww  w  .  j a  va 2 s .  co m*/
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(data);
    label.setFont(parent.getFont());

    GridData tagData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
    fTagsText = new TagAssistField(composite, SWT.SINGLE | SWT.BORDER, tagData);

    fTagsText.getTextControl().addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    fTagsFeedbackLabel = new Label(composite, SWT.NONE);
    fTagsFeedbackLabel.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    fTagsFeedbackLabel
            .setBackground(fTagsText.getTextControl().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

    applyDialogFont(composite);
    return composite;
}

From source file:com.ibm.research.tagging.core.ui.dialogs.QuickTagDialog.java

License:Open Source License

protected Label createTagsLabel(Composite parent) {
    Label tagsLabel = new Label(parent, SWT.WRAP);
    tagsLabel.setText(fMessage);//from  w  w  w. ja va2s. c  om

    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);

    tagsLabel.setLayoutData(data);
    tagsLabel.setFont(parent.getFont());

    return tagsLabel;
}