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();
}
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]);
}
Aggregations