use of org.eclipse.swt.events.DisposeListener in project cogtool by cogtool.
the class MenuFactory method addWindowMenu.
// addToCascade
protected static void addWindowMenu(Menu newWindowMenu, IWindowMenuData<?> menuData) {
if (windowMenus.size() > 0) {
copyExistingWindows(windowMenus.get(0), newWindowMenu);
}
// Add to global registry
windowMenus.add(newWindowMenu);
newWindowMenu.setData(menuData);
// i.e. the RootView will not be added!
if (menuData.getNexusData() != null) {
Iterator<Menu> menus = windowMenus.iterator();
while (menus.hasNext()) {
Menu windowMenu = menus.next();
Menu nexusCascade = null;
// Remove the last item if it is the NO_WINDOWS_SENTINEL
MenuItem[] nexusItems = windowMenu.getItems();
if (nexusItems.length > 0) {
MenuItem lastItem = nexusItems[nexusItems.length - 1];
if (lastItem.getData() == NO_WINDOWS_SENTINEL) {
lastItem.dispose();
nexusCascade = createNexusCascade(windowMenu, -1, menuData);
}
}
if (nexusCascade == null) {
nexusCascade = ensureNexusCascade(windowMenu, nexusItems, menuData);
}
addToCascade(nexusCascade, menuData);
}
newWindowMenu.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
removeWindowMenu((Menu) e.getSource());
}
});
} else {
newWindowMenu.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
windowMenus.remove(e.getSource());
}
});
}
}
use of org.eclipse.swt.events.DisposeListener in project cogtool by cogtool.
the class MenuUtil method createMenuStep.
/**
* Recursive support method for navigating the tree of
* menu item definitions to construct actual menus and menu items.
* <p>
* Each menu item created is associated with its
* <code>ListenerIdentifier</code>.
*/
protected static void createMenuStep(Shell shell, Menu parent, MenuItemDefinition defn, Boolean availability, Listener selectionListener, final ListenerIdentifierMap lIDMap) {
if (defn.isSingle()) {
SimpleMenuItemDefinition itemDef = (SimpleMenuItemDefinition) defn;
renderShortcut(itemDef);
final MenuItem item = addMenuItem(parent, itemDef.name, itemDef.image, itemDef.style, itemDef.accelerator, itemDef.enabledInitially, itemDef.selectedInitially);
// pull the lid out to a local so the whole SimpleMenuItemDefinition
// doesn't get stored in the dispose listener
final ListenerIdentifier lid = itemDef.listenerID;
if (lid != null) {
// avoid separator
// Associate LID with menu item so that it can be used to find
// the associated semantic action by the selectionListener.
item.setData(lid);
item.addListener(SWT.Selection, selectionListener);
lIDMap.addWidget(lid, item, availability);
// If this menu item gets disposed, as for example from a
// dynamic menu, we don't want the LID still pointing at it
item.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
lIDMap.removeWidget(lid, item);
}
});
}
} else {
CascadingMenuItemDefinition itemDef = (CascadingMenuItemDefinition) defn;
MenuItem item = addMenuItem(parent, itemDef.name, itemDef.image, SWT.CASCADE);
Menu cascadeParent = new Menu(shell, SWT.DROP_DOWN);
item.setMenu(cascadeParent);
item.setData(itemDef.data);
if (itemDef.menuItems != null) {
for (MenuItemDefinition menuItem : itemDef.menuItems) {
createMenuStep(shell, cascadeParent, menuItem, availability, selectionListener, lIDMap);
}
}
}
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class SchemaXMLLinker method initColors.
/**
* amaumont Comment method "initColors".
*
* @param display
*/
private void initColors(Display display) {
// selectedLoopLinkColor = new Color(display, 255, 131, 255);
// light blue
selectedLoopLinkColor = new Color(display, 110, 168, 255);
selectedRelativeLinkColor = new Color(display, 110, 168, 0);
getSource().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
selectedLoopLinkColor.dispose();
selectedRelativeLinkColor.dispose();
getSource().removeDisposeListener(this);
}
});
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToOutputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToOutputButtons() {
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
outputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
}
}
if (removeButton != null) {
final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
for (TableItem item : tableViewerCreator.getTable().getSelection()) {
if (item.getData() instanceof MetadataColumn) {
MetadataColumn column = (MetadataColumn) item.getData();
removeButton.getButton().setEnabled(!column.isCustom());
break;
}
}
}
});
}
this.addDisposeListener(new DisposeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
}
}
});
}
use of org.eclipse.swt.events.DisposeListener in project tdi-studio-se by Talend.
the class SQLResultComposite method createTabItem.
/**
*
* DOC dev Comment method "createTabItem".
*
* @throws Exception throw all exception
*/
private void createTabItem() throws Exception {
lastTabNumber = lastTabNumber + 1;
final CTabItem tabItem = new CTabItem(tabFolder, SWT.NULL);
String labelText = Messages.getString("SQLResultComposite.Result") + ": " + lastTabNumber;
tabItem.setText(labelText);
//$NON-NLS-1$
tabItem.setData("tabLabel", labelText);
tabItem.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
Composite composite = new Composite(tabFolder, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginLeft = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
composite.setLayout(layout);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
tabItem.setControl(composite);
tabItem.setData(sqlExecution);
tabItem.addDisposeListener(new DisposeListener() {
public void widgetDisposed(final DisposeEvent e) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
CTabItem tabItem = (CTabItem) e.getSource();
AbstractSQLExecution sqlExe = (AbstractSQLExecution) tabItem.getData();
sqlExe.stop();
tabItem.setData(null);
if (tabFolder != null && !tabFolder.isDisposed()) {
if (tabFolder.getItemCount() == 0) {
// this is last tab..
clearParent();
setDefaultMessage();
}
} else if (tabFolder.isDisposed()) {
clearParent();
setDefaultMessage();
}
}
});
}
});
createHeaderComposite(composite, tabItem);
createDetailComposite(composite, tabItem);
// refresh view
composite.layout();
tabFolder.layout();
tabFolder.redraw();
}
Aggregations