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.eclipse.datatools.sqltools.internal.sqlscrapbook.connection.FilesConnectionInfoDialog.java

License:Open Source License

protected void createFilesArea(Composite composite) {
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.ConnectionInfoDialog_file_conn_info);
    TableLayoutComposite tableComposite = new TableLayoutComposite(composite, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 500;/*from w w w. j  a  v a2s.c  o  m*/
    data.heightHint = convertHeightInCharsToPixels(15);
    tableComposite.setLayoutData(data);

    Table table = new Table(tableComposite,
            SWT.CHECK | 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 column1 = new TableColumn(table, SWT.NONE);
    column1.setText(Messages.FilesConnectionInfoDialog_column_name);
    int minWidth = computeMinimumColumnWidth(gc, Messages.FilesConnectionInfoDialog_column_name);
    tableComposite.addColumnData(new ColumnWeightData(2, minWidth, true));
    column1.addSelectionListener(new SelectionAdapter() {
        boolean sortType = true;

        public void widgetSelected(SelectionEvent e) {
            sortType = !sortType;
            fTableViewer.setSorter(sortType ? nameSorter : nameSorterReverse);
            setSortColumn(e, sortType);
        }

    });

    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.FilesConnectionInfoDialog_column_type);
    minWidth = computeMinimumColumnWidth(gc, Messages.FilesConnectionInfoDialog_column_type);
    tableComposite.addColumnData(new ColumnWeightData(2, minWidth, true));
    column2.addSelectionListener(new SelectionAdapter() {
        boolean sortType = true;

        public void widgetSelected(SelectionEvent e) {
            sortType = !sortType;
            fTableViewer.setSorter(sortType ? vendorSorter : vendorSorterReverse);
            setSortColumn(e, sortType);
        }

    });
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(Messages.FilesConnectionInfoDialog_column_profile);
    minWidth = computeMinimumColumnWidth(gc, Messages.FilesConnectionInfoDialog_column_profile);
    tableComposite.addColumnData(new ColumnWeightData(1, minWidth, true));
    column3.addSelectionListener(new SelectionAdapter() {
        boolean sortType = true;

        public void widgetSelected(SelectionEvent e) {
            sortType = !sortType;
            fTableViewer.setSorter(sortType ? profileSorter : profileSorterReverse);
            setSortColumn(e, sortType);
        }

    });

    TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setAlignment(SWT.CENTER);
    column4.setText(Messages.FilesConnectionInfoDialog_column_database);
    minWidth = computeMinimumColumnWidth(gc, Messages.FilesConnectionInfoDialog_column_database);
    tableComposite.addColumnData(new ColumnWeightData(1, minWidth, true));
    column4.addSelectionListener(new SelectionAdapter() {
        boolean sortType = true;

        public void widgetSelected(SelectionEvent e) {
            sortType = !sortType;
            fTableViewer.setSorter(sortType ? dbSorter : dbSorterReverse);
            setSortColumn(e, sortType);
        }
    });

    gc.dispose();

    fTableViewer = new CheckboxTableViewer(table);
    fTableViewer.setLabelProvider(new FileConnectionInfoLabelProvider());
    fTableViewer.setContentProvider(new FileConnectionInfoContentProvider());

    fTableViewer.setComparator(null);

    fTableViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            checkOK();
        }
    });
    fTableViewer.setInput(_files);
    fTableViewer.setAllChecked(true);
    fTableViewer.getControl().addMouseTrackListener(new TooltipPresenter());

    addSelectionButtons(composite);
}

From source file:org.eclipse.datatools.sqltools.result.internal.ui.utils.UIUtil.java

License:Open Source License

/**
 * Returns the width in pixels given the characters number.
 * /* w w  w  .j  ava2s.  co  m*/
 * @param chars number of characters
 * @param control the widget which contains font information, should not be null
 * @return the width in pixels
 */
public static int convertWidthInCharsToPixels(int chars, Control control) {
    if (control == null) {
        return 0;
    }
    GC gc = new GC(control);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    if (fontMetrics == null) {
        return 0;
    }
    return fontMetrics.getAverageCharWidth() * chars;
}

From source file:org.eclipse.datatools.sqltools.result.internal.ui.utils.UIUtil.java

License:Open Source License

/**
 * Returns the height in pixels given the characters number.
 * /*  w  w w.  j a  v  a  2 s.  co m*/
 * @param chars number of characters
 * @param control the widget which contains font information, should not be null
 * @return the width in pixels
 */
public static int convertHeightInCharsToPixels(int chars, Control control) {
    if (control == null) {
        return 0;
    }
    GC gc = new GC(control);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();
    if (fontMetrics == null) {
        return 0;
    }
    return fontMetrics.getHeight() * chars;
}

From source file:org.eclipse.datatools.sqltools.routineeditor.ui.launching.RoutineMainTab.java

License:Open Source License

protected void initializeDialogUnits(Control control) {
    // Compute and store a font metric
    GC gc = new GC(control);
    gc.setFont(JFaceResources.getDialogFont());
    _fontMetrics = gc.getFontMetrics();/*from   w w  w.j  av a 2 s  .  c om*/
    gc.dispose();
}

From source file:org.eclipse.debug.internal.ui.sourcelookup.browsers.DirectorySourceContainerDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Image image = (fNewContainer) ? DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_ADD_SRC_DIR_WIZ)
            : DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_EDIT_SRC_DIR_WIZ);
    setTitle(SourceLookupUIMessages.DirectorySourceContainerDialog_2);
    setMessage(SourceLookupUIMessages.DirectorySourceContainerDialog_3);
    setTitleImage(image);/*  www. j  a v a  2s.co  m*/
    Composite parentComposite = (Composite) super.createDialogArea(parent);
    Font font = parentComposite.getFont();
    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);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(font);

    Composite dirComposite = new Composite(composite, SWT.NONE);
    layout = new GridLayout(2, false);
    dirComposite.setLayout(layout);
    dirComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    dirComposite.setFont(font);

    Label label = new Label(dirComposite, SWT.NONE);
    label.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_4);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    label.setFont(font);

    fDirText = new Text(dirComposite, SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 1;
    fDirText.setLayoutData(data);
    fDirText.setFont(font);
    fDirText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validate();
        }
    });

    Button button = new Button(dirComposite, SWT.PUSH);
    button.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_5);
    data = new GridData();
    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);
    button.setFont(JFaceResources.getDialogFont());
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browse();
        }
    });

    fSubfoldersButton = new Button(composite, SWT.CHECK);
    fSubfoldersButton.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_6);

    return parentComposite;
}

From source file:org.eclipse.dirigible.ide.template.ui.html.wizard.HtmlForEntityTemplateTablePage.java

License:Open Source License

private void createTableField(Composite parent) {
    Composite upperPart = new Composite(parent, SWT.NONE);
    upperPart.setLayout(new GridLayout(3, false));
    upperPart.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    final Label label = new Label(upperPart, SWT.NONE);
    label.setText(AVAILABLE_FIELDS);//from  w w  w.java  2 s  . co  m
    label.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false));

    Button selectButton = new Button(upperPart, SWT.PUSH);
    selectButton.setText("&Select All");
    selectButton.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true));
    selectButton.setFont(JFaceResources.getDialogFont());
    selectButton.addSelectionListener(new SelectionAdapter() {
        /**
         * 
         */
        private static final long serialVersionUID = -7095187791495950403L;

        public void widgetSelected(SelectionEvent event) {
            selectAll(true);
        }
    });

    Button deselectButton = new Button(upperPart, SWT.PUSH);
    deselectButton.setText("&Deselect All");
    deselectButton.setLayoutData(new GridData(SWT.END, SWT.FILL, false, false));
    deselectButton.setFont(JFaceResources.getDialogFont());
    deselectButton.addSelectionListener(new SelectionAdapter() {
        /**
         * 
         */
        private static final long serialVersionUID = 7117397741755265980L;

        public void widgetSelected(SelectionEvent event) {
            selectAll(false);
        }
    });

    typeViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.CHECK);
    typeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    typeViewer.setContentProvider(new ArrayContentProvider());
    typeViewer.setLabelProvider(new HtmlForEntityTemplateTablePageLabelProvider());
    //typeViewer.setSorter(new ViewerSorter());
    createTableColumns();
    typeViewer.setInput(model.getOriginalTableColumns());
    typeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateTableColumns();
            checkPageStatus();
        }
    });
    updateTableColumns();

}

From source file:org.eclipse.dltk.mod.ui.wizards.WorkingSetConfigurationBlock.java

License:Open Source License

private static int getButtonWidthHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());

    GC gc = new GC(button);
    gc.setFont(button.getFont());/*  ww w . j  a  va  2  s.com*/
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:org.eclipse.ease.discovery.ui.viewer.DiscoveryViewer.java

License:Open Source License

private void initializeFonts() {
    // create a level-2 heading font
    if (h2Font == null) {
        Font baseFont = JFaceResources.getDialogFont();
        FontData[] fontData = baseFont.getFontData();
        for (FontData data : fontData) {
            data.setStyle(data.getStyle() | SWT.BOLD);
            data.height = data.height * 1.25f;
        }//w  ww. java 2  s  .c  o  m
        h2Font = new Font(Display.getCurrent(), fontData);
        disposables.add(h2Font);
    }
    // create a level-1 heading font
    if (h1Font == null) {
        Font baseFont = JFaceResources.getDialogFont();
        FontData[] fontData = baseFont.getFontData();
        for (FontData data : fontData) {
            data.setStyle(data.getStyle() | SWT.BOLD);
            data.height = data.height * 1.35f;
        }
        h1Font = new Font(Display.getCurrent(), fontData);
        disposables.add(h1Font);
    }
}

From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java

License:Open Source License

/**
 * Creates button for renaming a branch.
 *
 * @param parent/*from w  ww. j av  a2 s .  c  o m*/
 * @return button
 */
protected Button createRenameButton(Composite parent) {
    ((GridLayout) parent.getLayout()).numColumns++;
    renameButton = new Button(parent, SWT.PUSH);
    renameButton.setFont(JFaceResources.getDialogFont());
    renameButton.setText(UIText.BranchSelectionAndEditDialog_Rename);
    setButtonLayoutData(renameButton);
    renameButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Ref selectedRef = refFromDialog();

            String namePrefix = selectedRef.getName().startsWith(Constants.R_REMOTES) ? Constants.R_REMOTES
                    : Constants.R_HEADS;

            BranchRenameDialog dialog = new BranchRenameDialog(getShell(), repo, selectedRef);
            if (dialog.open() == Window.OK) {
                branchTree.refresh();
                markRef(namePrefix + dialog.getNewName());
            }
        }
    });
    renameButton.setEnabled(false);
    return renameButton;
}

From source file:org.eclipse.egit.ui.internal.dialogs.BranchSelectionAndEditDialog.java

License:Open Source License

/**
 * Creates button for deleting a branch.
 *
 * @param parent/*from w ww.  j  a v a  2 s.c  o  m*/
 * @return button
 */
protected Button createDeleteButton(Composite parent) {
    ((GridLayout) parent.getLayout()).numColumns++;
    deleteButton = new Button(parent, SWT.PUSH);
    deleteButton.setFont(JFaceResources.getDialogFont());
    deleteButton.setText(UIText.BranchSelectionAndEditDialog_Delete);
    setButtonLayoutData(deleteButton);

    deleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            try {
                CommonUtils.runCommand(IWorkbenchCommandConstants.EDIT_DELETE,
                        (IStructuredSelection) branchTree.getSelection());
                branchTree.refresh();
            } catch (Throwable e) {
                reportError(e, UIText.BranchSelectionAndEditDialog_ErrorCouldNotDeleteRef, refNameFromDialog());
            }
        }
    });
    deleteButton.setEnabled(false);
    return deleteButton;
}