Search in sources :

Example 6 with Section

use of org.eclipse.ui.forms.widgets.Section 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 7 with Section

use of org.eclipse.ui.forms.widgets.Section in project cubrid-manager by CUBRID.

the class NoticeDashboardPage method createContentSections.

private void createContentSections(Composite left, Composite right) {
    Section section;
    section = createExpandableSection(left, Messages.titleAnnouncement, "Announcement");
    section.setExpanded(true);
    section = createExpandableSection(left, Messages.titleMajorFeatures, "MajorFeatures");
    section.setExpanded(true);
    section = createExpandableSection(left, Messages.titleTechTrends, "TechTrends");
    section.setExpanded(true);
    section = createExpandableSection(right, Messages.titleReleaseNews, "ReleaseNews");
    section.setExpanded(true);
    section = createExpandableSection(right, Messages.titleTutorials, "Tutorials");
    section.setExpanded(true);
    section = createExpandableSection(right, Messages.titleUsefulLinks, "UsefulLinks");
    section.setExpanded(true);
}
Also used : Section(org.eclipse.ui.forms.widgets.Section)

Example 8 with Section

use of org.eclipse.ui.forms.widgets.Section in project cubrid-manager by CUBRID.

the class NoticeDashboardPage method createSection.

private Section createSection(Composite parent, String title, String category, int sectionStyle) {
    Section section = toolkit.createSection(parent, sectionStyle);
    section.clientVerticalSpacing = 5;
    section.setLayout(new GridLayout());
    section.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
    section.setText(title);
    if (category != null) {
        TableWrapLayout layout = new TableWrapLayout();
        layout.numColumns = 1;
        Composite composite = toolkit.createComposite(section, SWT.None);
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        section.setClient(composite);
        FormText text = createFormText(composite);
        formTexts.put(category, text);
    }
    sections.add(section);
    return section;
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) FormText(org.eclipse.ui.forms.widgets.FormText) GridData(org.eclipse.swt.layout.GridData) Section(org.eclipse.ui.forms.widgets.Section)

Example 9 with Section

use of org.eclipse.ui.forms.widgets.Section in project cubrid-manager by CUBRID.

the class NoticeDashboardPage method createActionSection.

@SuppressWarnings("unused")
private void createActionSection(Composite parent) {
    Section section = createStaticSection(parent, Messages.titleCommonAction);
    Composite composite = toolkit.createComposite(section);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    composite.setLayout(gridLayout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    section.setClient(composite);
    GridData data = new GridData(GridData.BEGINNING);
    data.widthHint = 200;
    ImageHyperlink addHost = toolkit.createImageHyperlink(composite, SWT.NONE);
    addHost.setLayoutData(data);
    addHost.setImage(CommonUIPlugin.getImageDescriptor("icons/action/host_add.png").createImage());
    addHost.setText(Messages.titleAddHostBtn);
    addHost.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("com.cubrid.cubridmanager.ui.host.action.AddHostAction").run();
        }
    });
    ImageHyperlink connectHost = toolkit.createImageHyperlink(composite, SWT.NONE);
    connectHost.setLayoutData(data);
    connectHost.setImage(CommonUIPlugin.getImageDescriptor("icons/action/host_connect.png").createImage());
    connectHost.setText(Messages.titleConHostBtn);
    connectHost.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("com.cubrid.cubridmanager.ui.host.action.ConnectHostAction").run();
        }
    });
    ImageHyperlink preferences = toolkit.createImageHyperlink(composite, SWT.NONE);
    preferences.setLayoutData(data);
    preferences.setImage(CommonUIPlugin.getImageDescriptor("icons/action/property.png").createImage());
    preferences.setText(Messages.titlePreferencesBtn);
    preferences.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction("preferences").run();
        }
    });
    ImageHyperlink help = toolkit.createImageHyperlink(composite, SWT.NONE);
    help.setLayoutData(data);
    help.setImage(CommonUIPlugin.getImageDescriptor("icons/action/help.png").createImage());
    help.setText(Messages.titleHelpBtn);
    help.addHyperlinkListener(new IHyperlinkListener() {

        public void linkExited(HyperlinkEvent e) {
        }

        public void linkEntered(HyperlinkEvent e) {
        }

        public void linkActivated(HyperlinkEvent e) {
            ActionManager.getInstance().getAction(HelpDocumentAction.ID).run();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) Section(org.eclipse.ui.forms.widgets.Section)

Example 10 with Section

use of org.eclipse.ui.forms.widgets.Section in project tesb-studio-se by Talend.

the class CamelDependenciesEditor method createTableViewer.

private CamelDependenciesPanel createTableViewer(Composite parent, FormToolkit toolkit, String title, String type) {
    Section section = toolkit.createSection(parent, Section.TITLE_BAR);
    section.setText(title);
    final CamelDependenciesPanel c = (type == ManifestItem.BUNDLE_CLASSPATH) ? new CheckedCamelDependenciesPanel(section, type, isReadOnly(), this, this) : new CamelDependenciesPanel(section, type, isReadOnly(), this, this);
    section.setClient(c);
    toolkit.adapt(c);
    return c;
}
Also used : Section(org.eclipse.ui.forms.widgets.Section)

Aggregations

Section (org.eclipse.ui.forms.widgets.Section)17 Composite (org.eclipse.swt.widgets.Composite)14 GridData (org.eclipse.swt.layout.GridData)13 GridLayout (org.eclipse.swt.layout.GridLayout)13 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)10 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)7 Button (org.eclipse.swt.widgets.Button)4 Label (org.eclipse.swt.widgets.Label)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 RowLayout (org.eclipse.swt.layout.RowLayout)3 ScrolledForm (org.eclipse.ui.forms.widgets.ScrolledForm)3 ServerEditorSection (org.eclipse.wst.server.ui.editor.ServerEditorSection)3 ToolBarManager (org.eclipse.jface.action.ToolBarManager)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 Table (org.eclipse.swt.widgets.Table)2 Tree (org.eclipse.swt.widgets.Tree)2