Search in sources :

Example 46 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite 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 47 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project knime-core by knime.

the class PreferredRendererPreferencePage method createFieldEditors.

/**
 * {@inheritDoc}
 */
@Override
protected void createFieldEditors() {
    Map<String, List<ExtensibleUtilityFactory>> groupedUtilityFactories = new HashMap<String, List<ExtensibleUtilityFactory>>();
    // TODO retrieve the utility factories from the data type extension point once we have it
    for (ExtensibleUtilityFactory fac : ExtensibleUtilityFactory.getAllFactories()) {
        List<ExtensibleUtilityFactory> groupList = groupedUtilityFactories.get(fac.getGroupName());
        if (groupList == null) {
            groupList = new ArrayList<ExtensibleUtilityFactory>(16);
            groupedUtilityFactories.put(fac.getGroupName(), groupList);
        }
        groupList.add(fac);
    }
    List<String> groupNames = new ArrayList<String>(groupedUtilityFactories.keySet());
    Collections.sort(groupNames);
    for (String group : groupNames) {
        final Section sectionExpander = new Section(getFieldEditorParent(), ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
        sectionExpander.setText(group);
        final Composite section = new Composite(sectionExpander, SWT.NONE);
        sectionExpander.setClient(section);
        sectionExpander.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(final ExpansionEvent e) {
                Composite comp = section;
                while (!(comp instanceof ScrolledComposite)) {
                    comp = comp.getParent();
                }
                // this is to fix a bug in Eclipse, no scrollbar is shown when this is true
                ((ScrolledComposite) comp).setExpandVertical(false);
                comp = section;
                while (!(comp instanceof ScrolledComposite)) {
                    comp.setSize(comp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                    comp.layout();
                    comp = comp.getParent();
                }
            }
        });
        List<ExtensibleUtilityFactory> utilityFactories = groupedUtilityFactories.get(group);
        Collections.sort(utilityFactories, utilityFactoryComparator);
        for (ExtensibleUtilityFactory utilFac : utilityFactories) {
            List<DataValueRendererFactory> rendererFactories = new ArrayList<DataValueRendererFactory>(utilFac.getAvailableRenderers());
            Collections.sort(rendererFactories, rendererFactoryComparator);
            String[][] comboEntries = new String[utilFac.getAvailableRenderers().size()][2];
            int i = 0;
            for (DataValueRendererFactory rendFac : rendererFactories) {
                comboEntries[i++] = new String[] { rendFac.getDescription(), rendFac.getId() };
            }
            ComboFieldEditor c = new ComboFieldEditor(utilFac.getPreferenceKey(), utilFac.getName(), comboEntries, section);
            c.setEnabled(comboEntries.length > 1, section);
            addField(c);
            m_fieldEditors.put(utilFac.getPreferenceKey(), c);
        }
        // add a dummy control which occupies the second column so that the next expander is in a new row
        new Label(getFieldEditorParent(), SWT.NONE);
    }
    DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(DataValueRendererFactory.class).getSymbolicName()).addPreferenceChangeListener(this);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) ComboFieldEditor(org.eclipse.jface.preference.ComboFieldEditor) Section(org.eclipse.ui.forms.widgets.Section) ExtensibleUtilityFactory(org.knime.core.data.ExtensibleUtilityFactory) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ArrayList(java.util.ArrayList) List(java.util.List) DataValueRendererFactory(org.knime.core.data.renderer.DataValueRendererFactory) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 48 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.

the class Bug515915_ScrolledCompositeCTabFolder method main.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setSize(100, 150);
    CTabFolder tabFolder = new CTabFolder(shell, SWT.NONE);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
    tabItem.setText("Tab");
    ScrolledComposite scroller = new ScrolledComposite(tabFolder, SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setExpandHorizontal(true);
    scroller.setExpandVertical(true);
    tabItem.setControl(scroller);
    Label label = new Label(scroller, SWT.NONE);
    label.setText("Label\n with\n a\n tall\n text\n string\n inside\n of\n it.");
    label.pack();
    scroller.setContent(label);
    scroller.setMinSize(label.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem) Display(org.eclipse.swt.widgets.Display)

Example 49 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_ScrolledComposite method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    scrolledComposite = new ScrolledComposite(shell, 0);
    setWidget(scrolledComposite);
}
Also used : ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Before(org.junit.Before)

Example 50 with ScrolledComposite

use of org.eclipse.swt.custom.ScrolledComposite in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_ScrolledComposite method test_ConstructorLorg_eclipse_swt_widgets_CompositeI.

@Override
@Test
public void test_ConstructorLorg_eclipse_swt_widgets_CompositeI() {
    try {
        scrolledComposite = new ScrolledComposite(null, 0);
        fail("No exception thrown");
    } catch (IllegalArgumentException e) {
    }
    int[] cases = { SWT.H_SCROLL, SWT.V_SCROLL, SWT.BORDER, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT };
    for (int i = 0; i < cases.length; i++) {
        scrolledComposite = new ScrolledComposite(shell, cases[i]);
    }
}
Also used : ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Aggregations

ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)89 Composite (org.eclipse.swt.widgets.Composite)67 GridData (org.eclipse.swt.layout.GridData)55 GridLayout (org.eclipse.swt.layout.GridLayout)51 Label (org.eclipse.swt.widgets.Label)39 Point (org.eclipse.swt.graphics.Point)27 Button (org.eclipse.swt.widgets.Button)21 Text (org.eclipse.swt.widgets.Text)20 FillLayout (org.eclipse.swt.layout.FillLayout)19 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)14 Control (org.eclipse.swt.widgets.Control)13 Group (org.eclipse.swt.widgets.Group)13 ControlEvent (org.eclipse.swt.events.ControlEvent)10 Rectangle (org.eclipse.swt.graphics.Rectangle)9 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)8 ArrayList (java.util.ArrayList)7 Combo (org.eclipse.swt.widgets.Combo)7 Image (org.eclipse.swt.graphics.Image)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6