Example usage for org.eclipse.jface.resource JFaceResources getDialogFont

List of usage examples for org.eclipse.jface.resource JFaceResources getDialogFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getDialogFont.

Prototype

public static Font getDialogFont() 

Source Link

Document

Returns the JFace's dialog font.

Usage

From source file:org.sonarlint.eclipse.ui.internal.properties.SonarLintExtraArgumentsPreferenceAndPropertyPage.java

License:Open Source License

@Override
protected Control createContents(final Composite ancestor) {
    loadProperties();/*from w ww .j a  v a2  s  . c  o m*/

    Composite parent = new Composite(ancestor, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);

    if (!isGlobal()) {
        createLinkToGlobal(ancestor, parent);
    }

    Composite innerParent = new Composite(parent, SWT.NONE);
    GridLayout innerLayout = new GridLayout();
    innerLayout.numColumns = 2;
    innerLayout.marginHeight = 0;
    innerLayout.marginWidth = 0;
    innerParent.setLayout(innerLayout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    innerParent.setLayoutData(gd);

    Composite tableComposite = new Composite(innerParent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 360;
    data.heightHint = convertHeightInCharsToPixels(10);
    tableComposite.setLayoutData(data);

    TableColumnLayout columnLayout = new TableColumnLayout();
    tableComposite.setLayout(columnLayout);
    Table table = new Table(tableComposite,
            SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    GC gc = new GC(getShell());
    gc.setFont(JFaceResources.getDialogFont());

    TableColumn propertyNameColumn = new TableColumn(table, SWT.NONE);
    propertyNameColumn.setText("Name");
    int minWidth = computeMinimumColumnWidth(gc, "Name");
    columnLayout.setColumnData(propertyNameColumn, new ColumnWeightData(1, minWidth, true));

    TableColumn propertyValueColumn = new TableColumn(table, SWT.NONE);
    propertyValueColumn.setText(VALUE);
    minWidth = computeMinimumColumnWidth(gc, VALUE);
    columnLayout.setColumnData(propertyValueColumn, new ColumnWeightData(1, minWidth, true));

    gc.dispose();

    fTableViewer = new TableViewer(table);
    fTableViewer.setLabelProvider(new SonarPropertiesLabelProvider());
    fTableViewer.setContentProvider(new SonarPropertiesContentProvider());

    fTableViewer.setComparator(null);

    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent e) {
            edit();
        }
    });

    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent e) {
            updateButtons();
        }
    });

    createButtons(innerParent);

    fTableViewer.setInput(sonarProperties);

    updateButtons();
    Dialog.applyDialogFont(parent);
    innerParent.layout();

    return parent;
}

From source file:org.spearce.egit.ui.internal.dialogs.BranchSelectionDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    if (!showResetType) {
        Button newButton = new Button(parent, SWT.PUSH);
        newButton.setFont(JFaceResources.getDialogFont());
        newButton.setText("New branch");
        ((GridLayout) parent.getLayout()).numColumns++;
        newButton.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                // check what ref name the user selected, if any.
                refNameFromDialog();/*from w  w  w.  j av  a  2 s .c om*/

                InputDialog labelDialog = new InputDialog(getShell(), "New branch",
                        "Enter name of new branch. It will branch from the selected branch. refs/heads/ will be prepended to the name you type",
                        null, new IInputValidator() {
                            public String isValid(String newText) {
                                String testFor = Constants.R_HEADS + newText;
                                try {
                                    if (repo.resolve(testFor) != null)
                                        return "Already exists";
                                } catch (IOException e1) {
                                    Activator.logError(
                                            String.format("Could not attempt to resolve %s", testFor), e1);
                                }
                                if (!Repository.isValidRefName(testFor))
                                    return "Invalid ref name";
                                return null;
                            }
                        });
                labelDialog.setBlockOnOpen(true);
                if (labelDialog.open() == Window.OK) {
                    String newRefName = Constants.R_HEADS + labelDialog.getValue();
                    RefUpdate updateRef;
                    try {
                        updateRef = repo.updateRef(newRefName);
                        ObjectId startAt;
                        if (refName == null)
                            startAt = repo.resolve(Constants.HEAD);
                        else
                            startAt = repo.resolve(refName);
                        updateRef.setNewObjectId(startAt);
                        updateRef.update();
                    } catch (IOException e1) {
                        Activator.logError(String.format("Could not create new ref %s", newRefName), e1);
                    }
                    try {
                        branchTree.removeAll();
                        fillTreeWithBranches(newRefName);
                    } catch (IOException e1) {
                        Activator.logError("Could not refresh list of branches", e1);
                    }
                }
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                widgetSelected(e);
            }
        });
    }
    createButton(parent, IDialogConstants.OK_ID, showResetType ? "Reset" : "Checkout", true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:org.springsource.ide.eclipse.commons.frameworks.ui.internal.actions.AbstractCommandActionDelegate.java

License:Open Source License

public void run(IAction action) {
    List<IProject> projects = getSelectedProjects();
    IProject project = null;/*www.  j  av a2s .  c o  m*/
    if (projects != null) {
        project = getSelectedProjects().get(0);
    }
    if (project != null) {
        LinkedHashSet<IProject> allProjects = new LinkedHashSet<IProject>();

        // Add the selected Project first
        allProjects.add(project);

        // Add any remaining projects that should appear as selectable
        // projects in the wizard
        Collection<IProject> selectionProjects = getSelectionProjects(project);
        if (selectionProjects != null) {
            allProjects.addAll(selectionProjects);
        }

        GenericCommandWizard wizard = getCommandWizard(allProjects, selectedCommand);

        if (wizard == null) {
            MessageDialog.openError(getShell(), "Unable to find command wizard",
                    "No command wizard found. This action requires a command wizard. Please contact STS support.");
            return;
        }

        WizardDialog dialog = new WizardDialog(getShell(), wizard);

        PixelConverter converter = new PixelConverter(JFaceResources.getDialogFont());
        dialog.setPageSize(converter.convertWidthInCharsToPixels(70),
                converter.convertHeightInCharsToPixels(20));
        dialog.create();

        if (Dialog.OK == dialog.open()) {
            //The call below is superfluous, performFinish was already called automatically when user clicks finish button! 
            //            wizard.performFinish();
        }
    }
}

From source file:org.springsource.ide.eclipse.commons.livexp.ui.UIConstants.java

License:Open Source License

/**
 * Computes a 'FIELD_LABEL_WIDTH_HINT' that scales based on the font metrics of
 * the 'DialogFont'. (See bug STS-3899)//from   w ww  . j a  v a 2s  .com
 */
public static final int fieldLabelWidthHint(Control control, int numChars) {
    Font dialogFont = JFaceResources.getDialogFont();
    GC gc = new GC(control);
    try {
        gc.setFont(dialogFont);
        return gc.getFontMetrics().getAverageCharWidth() * numChars;
    } finally {
        gc.dispose();
    }
}

From source file:org.summer.sdt.internal.ui.preferences.AppearancePreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);//  w ww .ja  va 2 s .c  om
    int nColumns = 1;

    Composite result = new Composite(parent, SWT.NONE);
    result.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = 0;
    layout.numColumns = nColumns;
    result.setLayout(layout);

    fShowMethodReturnType.doFillIntoGrid(result, nColumns);
    fShowMethodTypeParameters.doFillIntoGrid(result, nColumns);
    fShowCategory.doFillIntoGrid(result, nColumns);
    fShowMembersInPackageView.doFillIntoGrid(result, nColumns);
    fFoldPackagesInPackageExplorer.doFillIntoGrid(result, nColumns);

    new Separator().doFillIntoGrid(result, nColumns);

    fCompressPackageNames.doFillIntoGrid(result, nColumns);
    fPackageNamePattern.doFillIntoGrid(result, 2);
    LayoutUtil.setHorizontalIndent(fPackageNamePattern.getLabelControl(null));
    Text packageNamePatternControl = fPackageNamePattern.getTextControl(null);
    LayoutUtil.setHorizontalIndent(packageNamePatternControl);
    LayoutUtil.setHorizontalGrabbing(packageNamePatternControl);
    LayoutUtil.setWidthHint(fPackageNamePattern.getLabelControl(null), convertWidthInCharsToPixels(65));

    new Separator().doFillIntoGrid(result, nColumns);
    fAbbreviatePackageNames.doFillIntoGrid(result, nColumns);
    fAbbreviatePackageNamePattern.doFillIntoGrid(result, 2);
    LayoutUtil.setHorizontalIndent(fAbbreviatePackageNamePattern.getLabelControl(null));
    Text abbreviatePackageNamePatternControl = fAbbreviatePackageNamePattern.getTextControl(null);
    LayoutUtil.setHorizontalIndent(abbreviatePackageNamePatternControl);
    LayoutUtil.setHorizontalGrabbing(abbreviatePackageNamePatternControl);
    LayoutUtil.setWidthHint(fAbbreviatePackageNamePattern.getLabelControl(null),
            convertWidthInCharsToPixels(65));
    LayoutUtil.setVerticalGrabbing(abbreviatePackageNamePatternControl);
    LayoutUtil.setHeightHint(abbreviatePackageNamePatternControl, convertHeightInCharsToPixels(3));

    new Separator().doFillIntoGrid(result, nColumns);
    fStackBrowsingViewsVertically.doFillIntoGrid(result, nColumns);

    String noteTitle = PreferencesMessages.AppearancePreferencePage_note;
    String noteMessage = PreferencesMessages.AppearancePreferencePage_preferenceOnlyEffectiveForNewPerspectives;
    Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = LayoutUtil.getIndent();
    noteControl.setLayoutData(gd);

    initFields();

    Dialog.applyDialogFont(result);
    return result;
}

From source file:org.talend.core.ui.properties.tab.ToolbarTabbedPropertyTitle.java

License:Open Source License

protected Button createButton(int id, String label) {
    Button button = new Button(this, SWT.PUSH);
    button.setText(label);/*w w  w .  j ava2  s. c  o m*/
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            buttonPressed(((Integer) event.widget.getData()).intValue());
        }
    });
    buttons.put(new Integer(id), button);
    return button;
}

From source file:org.talend.repository.ui.wizards.metadata.connection.ldap.BaseWidgetUtils.java

License:Open Source License

/**
 * Creates a button under the given parent. The button width is set to the default width.
 * //from   w  w w. j  a  v  a  2  s.  c  om
 * @param parent the parent
 * @param text the label of the button
 * @param span the horizontal span
 * @return the created button
 */
public static Button createButton(Composite parent, String text, int span) {
    GC gc = new GC(parent);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    Button button = new Button(parent, SWT.PUSH);
    GridData gd = new GridData();
    gd.widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    button.setLayoutData(gd);
    button.setText(text);
    return button;
}

From source file:org.talend.sqlbuilder.ui.SQLBuilderDialog.java

License:Open Source License

@Override
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);/*  www.  ja  v  a 2s.  c o  m*/
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            buttonPressed(((Integer) event.widget.getData()).intValue());
        }
    });
    if (defaultButton) {
        Shell shell = parent.getShell();
        if (shell != null) {
            shell.setDefaultButton(button);
        }
    }
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);
    return button;
}

From source file:org.talend.updates.runtime.ui.feature.form.AbstractFeatureForm.java

License:Open Source License

protected Font getInstallButtonFont() {
    final String installBtnFontKey = AbstractFeatureListInfoItem.class.getName() + ".installButtonFont"; //$NON-NLS-1$
    FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    if (!fontRegistry.hasValueFor(installBtnFontKey)) {
        FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont())
                .setStyle(SWT.BOLD);//from  w w  w. j a va 2  s. c  om
        fontRegistry.put(installBtnFontKey, fontDescriptor.getFontData());
    }
    return fontRegistry.get(installBtnFontKey);
}

From source file:org.talend.updates.runtime.ui.feature.form.FeaturesUpdatesNotificationForm.java

License:Open Source License

private Font getTitleFont() {
    final String titleFontKey = this.getClass().getName() + ".titleFont"; //$NON-NLS-1$
    FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    if (!fontRegistry.hasValueFor(titleFontKey)) {
        FontDescriptor fontDescriptor = FontDescriptor.createFrom(JFaceResources.getDialogFont()).setHeight(12)
                .setStyle(SWT.BOLD);/*from w ww. ja  v  a2s. com*/
        fontRegistry.put(titleFontKey, fontDescriptor.getFontData());
    }
    return fontRegistry.get(titleFontKey);
}