Search in sources :

Example 1 with ExpandEvent

use of org.eclipse.swt.events.ExpandEvent 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)

Example 2 with ExpandEvent

use of org.eclipse.swt.events.ExpandEvent in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_ExpandBar method test_addExpandListenerLorg_eclipse_swt_events_ExpandListener.

@Test
public void test_addExpandListenerLorg_eclipse_swt_events_ExpandListener() {
    final boolean[] listenerCalled = new boolean[] { false };
    ExpandListener expandListener = new ExpandListener() {

        @Override
        public void itemCollapsed(ExpandEvent e) {
            listenerCalled[0] = true;
        }

        @Override
        public void itemExpanded(ExpandEvent e) {
            listenerCalled[0] = true;
        }
    };
    try {
        expandBar.addExpandListener(null);
        fail("No exception thrown for addExpandListener with null argument");
    } catch (IllegalArgumentException e) {
    }
    expandBar.addExpandListener(expandListener);
    expandBar.notifyListeners(SWT.Expand, new Event());
    assertTrue(":a:", listenerCalled[0]);
    listenerCalled[0] = false;
    expandBar.notifyListeners(SWT.Collapse, new Event());
    assertTrue(":b:", listenerCalled[0]);
    try {
        expandBar.removeExpandListener(null);
        fail("No exception thrown for removeExpandListener with null argument");
    } catch (IllegalArgumentException e) {
    }
    listenerCalled[0] = false;
    expandBar.removeExpandListener(expandListener);
    expandBar.notifyListeners(SWT.Expand, new Event());
    assertFalse(listenerCalled[0]);
}
Also used : ExpandEvent(org.eclipse.swt.events.ExpandEvent) ExpandEvent(org.eclipse.swt.events.ExpandEvent) Event(org.eclipse.swt.widgets.Event) ExpandListener(org.eclipse.swt.events.ExpandListener) Test(org.junit.Test)

Aggregations

ExpandEvent (org.eclipse.swt.events.ExpandEvent)2 ExpandListener (org.eclipse.swt.events.ExpandListener)2 SashForm (org.eclipse.swt.custom.SashForm)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 Event (org.eclipse.swt.widgets.Event)1 ExpandBar (org.eclipse.swt.widgets.ExpandBar)1 ExpandItem (org.eclipse.swt.widgets.ExpandItem)1 Test (org.junit.Test)1 CommandStackForComposite (org.talend.commons.ui.command.CommandStackForComposite)1