Search in sources :

Example 1 with ExpandListener

use of org.eclipse.swt.events.ExpandListener in project tdi-studio-se by Talend.

the class MultiSchemasUI method init.

public void init() {
    uiParent.setLayout(new GridLayout());
    Composite composite = new Composite(uiParent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setLayout(new FillLayout());
    ExpandBar bar = new ExpandBar(composite, SWT.V_SCROLL);
    final Composite fileGroup = new Composite(bar, SWT.NONE);
    createFileGroup(fileGroup);
    final ExpandItem settingItem = new ExpandItem(bar, SWT.NONE, 0);
    settingItem.setText(ExternalMultiSchemasUIProperties.SETTINGS_LABEL);
    settingItem.setHeight(fileGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    settingItem.setControl(fileGroup);
    settingItem.setExpanded(true);
    allContentForm = new SashForm(bar, SWT.NONE);
    createViewers(allContentForm);
    final ExpandItem previewItem = new ExpandItem(bar, SWT.NONE, 1);
    previewItem.setText(ExternalMultiSchemasUIProperties.PREVIEW_LABEL);
    previewItem.setHeight(allContentForm.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + 100);
    previewItem.setControl(allContentForm);
    previewItem.setExpanded(true);
    bar.addExpandListener(new ExpandListener() {

        public void itemExpanded(ExpandEvent e) {
            if (e.item != null && e.item instanceof ExpandItem) {
                if (((ExpandItem) e.item).getText().equals(ExternalMultiSchemasUIProperties.PREVIEW_LABEL)) {
                    if (settingItem.getExpanded()) {
                        previewItem.setHeight(allContentForm.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
                    } else {
                        previewItem.setHeight(allContentForm.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + fileGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
                    }
                } else if (((ExpandItem) e.item).getText().equals(ExternalMultiSchemasUIProperties.SETTINGS_LABEL)) {
                    settingItem.setHeight(fileGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
                }
            }
        }

        public void itemCollapsed(ExpandEvent e) {
            if (e.item != null && e.item instanceof ExpandItem) {
                if (((ExpandItem) e.item).getText().equals(ExternalMultiSchemasUIProperties.PREVIEW_LABEL)) {
                // settingItem.setHeight(allContentForm.computeSize(SWT.DEFAULT, SWT.DEFAULT).y
                // + fileGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
                } else if (((ExpandItem) e.item).getText().equals(ExternalMultiSchemasUIProperties.SETTINGS_LABEL)) {
                    previewItem.setHeight(allContentForm.computeSize(SWT.DEFAULT, SWT.DEFAULT).y + fileGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
                }
            }
        }
    });
    initFieldValues();
    // listener
    addFieldListeners();
    addButtonListeners();
    addFieldsListenersGroupFileSettings();
    addFieldsListenersGroupsEscapeChar();
    // preview
    refreshPreview();
    checkDialog();
    // reload
    reloadSchemaDataFromNode();
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ExpandBar(org.eclipse.swt.widgets.ExpandBar) Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) ExpandItem(org.eclipse.swt.widgets.ExpandItem) GridData(org.eclipse.swt.layout.GridData) ExpandEvent(org.eclipse.swt.events.ExpandEvent) FillLayout(org.eclipse.swt.layout.FillLayout) ExpandListener(org.eclipse.swt.events.ExpandListener)

Aggregations

SashForm (org.eclipse.swt.custom.SashForm)1 ExpandEvent (org.eclipse.swt.events.ExpandEvent)1 ExpandListener (org.eclipse.swt.events.ExpandListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 ExpandBar (org.eclipse.swt.widgets.ExpandBar)1 ExpandItem (org.eclipse.swt.widgets.ExpandItem)1 CommandStackForComposite (org.talend.commons.ui.command.CommandStackForComposite)1