Search in sources :

Example 26 with DisposeListener

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ImportProjectWizard(net.heartsome.cat.ts.importproject.wizards.ImportProjectWizard) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 27 with DisposeListener

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;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Image(org.eclipse.swt.graphics.Image) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 28 with DisposeListener

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());
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 29 with DisposeListener

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);
            }
        }
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 30 with DisposeListener

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);
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Aggregations

DisposeListener (org.eclipse.swt.events.DisposeListener)118 DisposeEvent (org.eclipse.swt.events.DisposeEvent)117 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 GridData (org.eclipse.swt.layout.GridData)38 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)33 Image (org.eclipse.swt.graphics.Image)29 Cursor (org.eclipse.swt.graphics.Cursor)26 ToolBar (org.eclipse.swt.widgets.ToolBar)25 ToolItem (org.eclipse.swt.widgets.ToolItem)23 Composite (org.eclipse.swt.widgets.Composite)19 Color (org.eclipse.swt.graphics.Color)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 Point (org.eclipse.swt.graphics.Point)16 ControlEvent (org.eclipse.swt.events.ControlEvent)11 SelectionListener (org.eclipse.swt.events.SelectionListener)10 Control (org.eclipse.swt.widgets.Control)10 TextLayout (org.eclipse.swt.graphics.TextLayout)9 Listener (org.eclipse.swt.widgets.Listener)9 ControlListener (org.eclipse.swt.events.ControlListener)8 MouseEvent (org.eclipse.swt.events.MouseEvent)8