use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class ImportProjectHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ImportProjectWizard wizard = new ImportProjectWizard();
TSWizardDialog dialog = new TSWizardDialog(window.getShell(), wizard) {
/**
* 添加帮助按钮
* robert 2012-09-06
*/
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 导入项目
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch07s03.html#import-project", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
};
dialog.setHelpAvailable(true);
dialog.open();
return null;
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class PreMachineTranslationDialog method createHelpControl.
// TODO :帮助按钮URL需要修改
/**
* 添加帮助按钮 robert 2012-09-06
*/
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 预翻译
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03.html?#prestore-mt", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
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);
}
});
}
Aggregations