Search in sources :

Example 31 with FontData

use of org.eclipse.swt.graphics.FontData in project knime-core by knime.

the class ElementRadioSelectionDialog method createRadioList.

/**
 * Creates the radio buttons and labels.
 * @param parent the parent composite.
 * @return returns the composite containing the radio buttons
 */
protected Composite createRadioList(final Composite parent) {
    Composite c = new Composite(parent, SWT.FILL);
    GridData data = new GridData();
    data.widthHint = convertWidthInCharsToPixels(m_width);
    data.heightHint = convertHeightInCharsToPixels(m_height);
    data.grabExcessVerticalSpace = true;
    data.grabExcessHorizontalSpace = true;
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    c.setLayoutData(data);
    GridLayout layout = new GridLayout(1, true);
    layout.marginTop = 10;
    c.setLayout(layout);
    c.setFont(parent.getFont());
    m_radioButtons = new Button[m_selectElements.length];
    for (int i = 0; i < m_selectElements.length; i++) {
        final RadioItem item = m_selectElements[i];
        Button radio = new Button(c, SWT.RADIO);
        radio.setText(item.getTitle());
        if (item.getTooltip() != null) {
            radio.setToolTipText(item.getTooltip());
        }
        radio.addSelectionListener(new SelectionAdapter() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void widgetSelected(final SelectionEvent e) {
                m_selectedElement = item;
            }
        });
        if (item.getDescription() != null) {
            Label description = new Label(c, SWT.WRAP);
            description.setLayoutData(new GridData(data.widthHint, SWT.DEFAULT));
            FontData[] fD = c.getFont().getFontData();
            fD[0].setHeight(Math.max(fD[0].getHeight() - 2, 6));
            description.setFont(new Font(parent.getDisplay(), fD[0]));
            description.setText(item.getDescription());
            if (item.getTooltip() != null) {
                description.setToolTipText(item.getTooltip());
            }
        }
        // spacer
        Label spacer = new Label(c, SWT.CENTER);
        spacer.setLayoutData(new GridData(data.widthHint, 5));
        m_radioButtons[i] = radio;
    }
    return c;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 32 with FontData

use of org.eclipse.swt.graphics.FontData in project knime-core by knime.

the class NodeContainerFigure method setFontSize.

/**
 * Set a new font size which is applied to the node name and label.
 *
 * @param fontSize the new font size to ba applied.
 */
public void setFontSize(final int fontSize) {
    setLabelText(m_label);
    // apply new font for node label
    Font font2 = super.getFont();
    FontData fontData2 = font2.getFontData()[0];
    Font newFont2 = FontStore.INSTANCE.getFont(fontData2.getName(), fontSize, fontData2.getStyle());
    // apply the standard node label font also to its parent figure to allow
    // editing the node label with the same font (size)
    super.setFont(newFont2);
    FontStore.INSTANCE.releaseFont(font2);
}
Also used : FontData(org.eclipse.swt.graphics.FontData) Font(org.eclipse.swt.graphics.Font)

Example 33 with FontData

use of org.eclipse.swt.graphics.FontData in project knime-core by knime.

the class NodeUsageComposite method createNodeGrid.

private void createNodeGrid(final SubNodeContainer subNodeContainer, @SuppressWarnings("rawtypes") final Map<NodeIDSuffix, WizardNode> viewNodes) {
    ScrolledComposite scrollPane = new ScrolledComposite(this, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    scrollPane.setExpandHorizontal(true);
    scrollPane.setExpandVertical(true);
    Composite composite = new Composite(scrollPane, SWT.NONE);
    scrollPane.setContent(composite);
    scrollPane.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
    composite.setLayout(new GridLayout(3, false));
    composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
    // titles
    new Composite(composite, SWT.NONE);
    /* Placeholder */
    Label wizardLabel = new Label(composite, SWT.CENTER);
    FontData fontData = wizardLabel.getFont().getFontData()[0];
    Font boldFont = new Font(Display.getCurrent(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    wizardLabel.setText("WebPortal /\nWrapped Metanode View");
    wizardLabel.setFont(boldFont);
    Label dialogLabel = new Label(composite, SWT.CENTER);
    dialogLabel.setText("\nWrapped Metanode Dialog");
    dialogLabel.setFont(boldFont);
    // select all checkboxes
    Label selectAllLabel = new Label(composite, SWT.LEFT);
    selectAllLabel.setText("Enable/Disable");
    Button selectAllWizard = createCheckbox(composite);
    Button selectAllDialog = createCheckbox(composite);
    // individual nodes
    for (@SuppressWarnings("rawtypes") Entry<NodeIDSuffix, WizardNode> entry : viewNodes.entrySet()) {
        NodeIDSuffix suffix = entry.getKey();
        NodeID id = suffix.prependParent(subNodeContainer.getWorkflowManager().getID());
        NodeContainer nodeContainer = viewNodes.containsKey(suffix) ? subNodeContainer.getWorkflowManager().getNodeContainer(id) : null;
        createNodeLabelComposite(composite, id, nodeContainer);
        @SuppressWarnings("rawtypes") WizardNode model = entry.getValue();
        Button wizardButton = createCheckbox(composite);
        wizardButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent e) {
                checkAllSelected(m_wizardUsageMap, selectAllWizard);
            }
        });
        wizardButton.setToolTipText("Enable/disable for usage in WebPortal and wizard execution.");
        wizardButton.setSelection(!((WizardNode<?, ?>) model).isHideInWizard());
        m_wizardUsageMap.put(id, wizardButton);
        if (model instanceof DialogNode) {
            Button dialogButton = createCheckbox(composite);
            dialogButton.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(final SelectionEvent e) {
                    checkAllSelected(m_dialogUsageMap, selectAllDialog);
                }
            });
            dialogButton.setToolTipText("Enable/disable for usage in wrapped metanode configure dialog.");
            dialogButton.setSelection(!((DialogNode<?, ?>) model).isHideInDialog());
            m_dialogUsageMap.put(id, dialogButton);
        } else {
            new Composite(composite, SWT.NONE);
        /* Placeholder */
        }
    }
    checkAllSelected(m_wizardUsageMap, selectAllWizard);
    checkAllSelected(m_dialogUsageMap, selectAllDialog);
    selectAllWizard.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectAllWizard.setGrayed(false);
            for (Button b : m_wizardUsageMap.values()) {
                b.setSelection(selectAllWizard.getSelection());
            }
        }
    });
    if (m_wizardUsageMap.size() < 1) {
        selectAllWizard.setEnabled(false);
    }
    selectAllDialog.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            selectAllDialog.setGrayed(false);
            for (Button b : m_dialogUsageMap.values()) {
                b.setSelection(selectAllDialog.getSelection());
            }
        }
    });
    if (m_dialogUsageMap.size() < 1) {
        selectAllDialog.setEnabled(false);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FontData(org.eclipse.swt.graphics.FontData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) DialogNode(org.knime.core.node.dialog.DialogNode) WizardNode(org.knime.core.node.wizard.WizardNode) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) NodeIDSuffix(org.knime.core.node.workflow.NodeID.NodeIDSuffix) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) NodeID(org.knime.core.node.workflow.NodeID) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 34 with FontData

use of org.eclipse.swt.graphics.FontData in project knime-core by knime.

the class EditorUISettingsDialog method createHeader.

private void createHeader(final Composite parent) {
    Composite header = new Composite(parent, SWT.FILL);
    Color white = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
    header.setBackground(white);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    header.setLayoutData(gridData);
    header.setLayout(new GridLayout(2, false));
    // 1st row
    Label exec = new Label(header, SWT.NONE);
    exec.setBackground(white);
    exec.setText("Workflow Editor Settings");
    FontData[] fd = parent.getFont().getFontData();
    for (FontData f : fd) {
        f.setStyle(SWT.BOLD);
        f.setHeight(f.getHeight() + 2);
    }
    exec.setFont(new Font(parent.getDisplay(), fd));
    exec.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    Label execIcon = new Label(header, SWT.NONE);
    execIcon.setBackground(white);
    execIcon.setImage(IMG_PERMS.createImage());
    execIcon.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, true, true));
    // 2nd row
    Label txt = new Label(header, SWT.NONE);
    txt.setBackground(white);
    txt.setText("Modify the settings for the active workflow editor. \n" + "All settings will be store with the workflow.\n" + "To change default settings for new workflow editors go to the preference page.\n" + "Snap to grid behavior can be toggled by pressing 'Ctrl-Shift-X'.");
    txt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    new Label(header, SWT.NONE);
    // 3rd row
    m_error = new Label(header, SWT.NONE);
    m_error.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false));
    m_error.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    m_error.setBackground(white);
    new Label(header, SWT.NONE);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font)

Example 35 with FontData

use of org.eclipse.swt.graphics.FontData in project knime-core by knime.

the class BorderStyleDialog method createHeader.

/**
 * Creates the header composite.
 *
 * @param parent the parent composite
 */
protected void createHeader(final Composite parent) {
    Composite header = new Composite(parent, SWT.FILL);
    Color white = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
    header.setBackground(white);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    header.setLayoutData(gridData);
    header.setLayout(new GridLayout(2, false));
    Label exec = new Label(header, SWT.NONE);
    exec.setBackground(white);
    exec.setText("Annotation Border Style");
    FontData[] fd = parent.getFont().getFontData();
    for (FontData f : fd) {
        f.setStyle(SWT.BOLD);
        f.setHeight(f.getHeight() + 2);
    }
    exec.setFont(new Font(parent.getDisplay(), fd));
    exec.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    Label mkdirIcon = new Label(header, SWT.NONE);
    mkdirIcon.setBackground(white);
    Label txt = new Label(header, SWT.NONE);
    txt.setBackground(white);
    txt.setText("Please set the style of the border");
    txt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Font(org.eclipse.swt.graphics.Font)

Aggregations

FontData (org.eclipse.swt.graphics.FontData)147 Font (org.eclipse.swt.graphics.Font)89 GridData (org.eclipse.swt.layout.GridData)30 Label (org.eclipse.swt.widgets.Label)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Composite (org.eclipse.swt.widgets.Composite)25 Point (org.eclipse.swt.graphics.Point)23 Test (org.junit.Test)21 Color (org.eclipse.swt.graphics.Color)15 FontStyle (org.eclipse.gmf.runtime.notation.FontStyle)14 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)11 Button (org.eclipse.swt.widgets.Button)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 Display (org.eclipse.swt.widgets.Display)9 Text (org.eclipse.swt.widgets.Text)9 GC (org.eclipse.swt.graphics.GC)8 StyleRange (org.eclipse.swt.custom.StyleRange)7 Image (org.eclipse.swt.graphics.Image)7 IOException (java.io.IOException)6