Search in sources :

Example 1 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter 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 2 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project egit by eclipse.

the class CreateTagDialog method createAdvancedSection.

private void createAdvancedSection(final Composite composite) {
    if (commitId != null)
        return;
    ExpandableComposite advanced = new ExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
    advanced.setText(UIText.CreateTagDialog_advanced);
    advanced.setToolTipText(UIText.CreateTagDialog_advancedToolTip);
    advanced.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    Composite advancedComposite = new Composite(advanced, SWT.WRAP);
    advancedComposite.setLayout(GridLayoutFactory.swtDefaults().create());
    advancedComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    Label advancedLabel = new Label(advancedComposite, SWT.WRAP);
    advancedLabel.setText(UIText.CreateTagDialog_advancedMessage);
    advancedLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    commitCombo = new CommitCombo(advancedComposite, SWT.NORMAL);
    commitCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(300, SWT.DEFAULT).create());
    advanced.setClient(advancedComposite);
    advanced.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            // fill the Combo lazily to improve UI responsiveness
            if (((Boolean) e.data).booleanValue() && commitCombo.getItemCount() == 0) {
                final Collection<RevCommit> commits = new ArrayList<>();
                try {
                    PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {

                        @Override
                        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                            getRevCommits(commits);
                        }
                    });
                } catch (InvocationTargetException e1) {
                    Activator.logError(e1.getMessage(), e1);
                } catch (InterruptedException e1) {
                // ignore here
                }
                for (RevCommit revCommit : commits) commitCombo.add(revCommit);
                // Set combo selection if a tag is selected
                if (existingTag != null)
                    commitCombo.setSelectedElement(existingTag.getObject());
            }
            composite.layout(true);
            composite.getShell().pack();
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) Label(org.eclipse.swt.widgets.Label) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Collection(java.util.Collection) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 3 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project egit by eclipse.

the class SimpleConfigurePushDialog method createAdditionalUriArea.

@Override
protected Control createAdditionalUriArea(Composite parent) {
    ExpandableComposite pushUriArea = new ExpandableComposite(parent, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(pushUriArea);
    pushUriArea.setExpanded(!getConfig().getPushURIs().isEmpty());
    pushUriArea.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            parent.layout(true, true);
            parent.getShell().pack();
        }
    });
    pushUriArea.setText(UIText.SimpleConfigurePushDialog_PushUrisLabel);
    final Composite pushUriDetails = new Composite(pushUriArea, SWT.NONE);
    pushUriArea.setClient(pushUriDetails);
    pushUriDetails.setLayout(new GridLayout(2, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(pushUriDetails);
    uriViewer = new TableViewer(pushUriDetails, SWT.BORDER | SWT.MULTI);
    GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 30).applyTo(uriViewer.getTable());
    uriViewer.setContentProvider(ArrayContentProvider.getInstance());
    final Composite uriButtonArea = new Composite(pushUriDetails, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(uriButtonArea);
    GridDataFactory.fillDefaults().grab(false, true).applyTo(uriButtonArea);
    Button addUri = new Button(uriButtonArea, SWT.PUSH);
    addUri.setText(UIText.SimpleConfigurePushDialog_AddPushUriButton);
    GridDataFactory.fillDefaults().applyTo(addUri);
    addUri.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            SelectUriWizard wiz = new SelectUriWizard(false);
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
                getConfig().addPushURI(wiz.getUri());
                updateControls();
            }
        }
    });
    final Button changeUri = new Button(uriButtonArea, SWT.PUSH);
    changeUri.setText(UIText.SimpleConfigurePushDialog_ChangePushUriButton);
    GridDataFactory.fillDefaults().applyTo(changeUri);
    changeUri.setEnabled(false);
    changeUri.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            URIish uri = (URIish) ((IStructuredSelection) uriViewer.getSelection()).getFirstElement();
            SelectUriWizard wiz = new SelectUriWizard(false, uri.toPrivateString());
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
                getConfig().removePushURI(uri);
                getConfig().addPushURI(wiz.getUri());
                updateControls();
            }
        }
    });
    final Button deleteUri = new Button(uriButtonArea, SWT.PUSH);
    deleteUri.setText(UIText.SimpleConfigurePushDialog_DeletePushUriButton);
    GridDataFactory.fillDefaults().applyTo(deleteUri);
    deleteUri.setEnabled(false);
    deleteUri.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            URIish uri = (URIish) ((IStructuredSelection) uriViewer.getSelection()).getFirstElement();
            getConfig().removePushURI(uri);
            updateControls();
        }
    });
    uriViewer.addSelectionChangedListener(event -> {
        deleteUri.setEnabled(!uriViewer.getSelection().isEmpty());
        changeUri.setEnabled(((IStructuredSelection) uriViewer.getSelection()).size() == 1);
    });
    return pushUriArea;
}
Also used : URIish(org.eclipse.jgit.transport.URIish) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectUriWizard(org.eclipse.egit.ui.internal.repository.SelectUriWizard) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.

the class CorrelationAnalysisResultPage method createBubbleOrGanttChart.

private void createBubbleOrGanttChart(final ScrolledForm sForm, final Composite composite, final ColumnSetMultiValueIndicator columnSetMultiValueIndicator) {
    List<Composite> previewChartList = new ArrayList<Composite>();
    List<ModelElement> bubOrGanttColumnList = new ArrayList<ModelElement>();
    if (columnSetMultiValueIndicator instanceof CountAvgNullIndicator) {
        bubOrGanttColumnList = columnSetMultiValueIndicator.getNumericColumns();
    } else {
        bubOrGanttColumnList = columnSetMultiValueIndicator.getDateColumns();
    }
    for (ModelElement column : bubOrGanttColumnList) {
        final MetadataColumn tdColumn = (MetadataColumn) column;
        final ExpandableComposite exComp = toolkit.createExpandableComposite(composite, ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
        // $NON-NLS-1$
        exComp.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.column", tdColumn.getName()));
        exComp.setLayout(new GridLayout());
        exComp.setData(columnSetMultiValueIndicator);
        previewChartList.add(exComp);
        final Composite comp = toolkit.createComposite(exComp);
        comp.setLayout(new GridLayout(2, false));
        comp.setLayoutData(new GridData(GridData.FILL_BOTH));
        if (tdColumn != null) {
            IRunnableWithProgress rwp = new IRunnableWithProgress() {

                public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(DefaultMessagesImpl.getString("ColumnCorrelationNominalIntervalResultPage.CreatePreview", tdColumn.getName()), // $NON-NLS-1$
                    IProgressMonitor.UNKNOWN);
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            HideSeriesChartComposite hcc = new HideSeriesChartComposite(comp, getAnalysisHandler().getAnalysis(), columnSetMultiValueIndicator, tdColumn, true);
                            GridData gd = new GridData();
                            gd.widthHint = 800;
                            gd.heightHint = 450;
                            hcc.setLayoutData(gd);
                        }
                    });
                    monitor.done();
                }
            };
            try {
                new ProgressMonitorDialog(getSite().getShell()).run(true, false, rwp);
            } catch (Exception ex) {
                log.error(ex, ex);
            }
        }
        exComp.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                getChartComposite().layout();
                sForm.reflow(true);
            }
        });
        exComp.setExpanded(true);
        exComp.setClient(comp);
    }
    if (!previewChartList.isEmpty()) {
        this.previewChartCompsites = previewChartList.toArray(new Composite[previewChartList.size()]);
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) HideSeriesChartComposite(org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite) HideSeriesChartComposite(org.talend.dataprofiler.core.ui.editor.preview.HideSeriesChartComposite) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GridData(org.eclipse.swt.layout.GridData) CountAvgNullIndicator(org.talend.dataquality.indicators.columnset.CountAvgNullIndicator) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 5 with ExpansionAdapter

use of org.eclipse.ui.forms.events.ExpansionAdapter in project tdq-studio-se by Talend.

the class MasterPaginationInfo method render.

@Override
protected void render() {
    // refresh analysis tree
    if (treeViewer != null) {
        treeViewer.setElements(modelElementIndicators.toArray(new ModelElementIndicator[modelElementIndicators.size()]), false);
    }
    // chart composite don't display So need't consider it.
    if (previewChartList == null || uiPagination.getChartComposite() == null) {
        return;
    }
    previewChartList.clear();
    clearDynamicList();
    if (EditorPreferencePage.isHideGraphicsSectionForSettingsPage() || !TOPChartUtils.getInstance().isTOPChartInstalled()) {
        return;
    }
    for (ModelElementIndicator modelElementIndicator : modelElementIndicators) {
        final ExpandableComposite exComp = uiPagination.getToolkit().createExpandableComposite(uiPagination.getChartComposite(), ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
        needDispostWidgets.add(exComp);
        exComp.setText(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.column", // $NON-NLS-1$
        modelElementIndicator.getElementName()));
        exComp.setLayout(new GridLayout());
        exComp.setData(modelElementIndicator);
        previewChartList.add(exComp);
        Composite comp = uiPagination.getToolkit().createComposite(exComp);
        comp.setLayout(new GridLayout());
        comp.setLayoutData(new GridData(GridData.FILL_BOTH));
        Map<EIndicatorChartType, List<IndicatorUnit>> indicatorComposite = CompositeIndicator.getInstance().getIndicatorComposite(modelElementIndicator);
        for (EIndicatorChartType chartType : indicatorComposite.keySet()) {
            List<IndicatorUnit> units = indicatorComposite.get(chartType);
            if (!units.isEmpty()) {
                if (chartType == EIndicatorChartType.UDI_FREQUENCY) {
                    for (IndicatorUnit unit : units) {
                        List<IndicatorUnit> specialUnit = new ArrayList<IndicatorUnit>();
                        specialUnit.add(unit);
                        createChart(comp, chartType, specialUnit);
                    }
                } else {
                    createChart(comp, chartType, units);
                }
            }
        }
        exComp.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                uiPagination.getChartComposite().layout();
                form.reflow(true);
                if (e.getState()) {
                    exComp.setExpanded(e.getState());
                    exComp.getParent().pack();
                }
            }
        });
        exComp.setExpanded(true);
        exComp.setClient(comp);
        uiPagination.getChartComposite().layout();
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ArrayList(java.util.ArrayList) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) EIndicatorChartType(org.talend.dq.indicators.preview.EIndicatorChartType) ArrayList(java.util.ArrayList) List(java.util.List) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Aggregations

ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)51 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)51 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)41 GridData (org.eclipse.swt.layout.GridData)40 Composite (org.eclipse.swt.widgets.Composite)40 GridLayout (org.eclipse.swt.layout.GridLayout)33 Section (org.eclipse.ui.forms.widgets.Section)28 TableViewer (org.eclipse.jface.viewers.TableViewer)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 ICellModifier (org.eclipse.jface.viewers.ICellModifier)7 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 TableItem (org.eclipse.swt.widgets.TableItem)7 ArrayList (java.util.ArrayList)6 ParseTree (org.antlr.v4.runtime.tree.ParseTree)6 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)6 Point (org.eclipse.swt.graphics.Point)6 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5