Search in sources :

Example 1 with OpenPaletteFilterAction

use of org.talend.repository.ui.actions.OpenPaletteFilterAction in project tdi-studio-se by Talend.

the class TalendFlyoutPaletteComposite method createActionMenu.

private Menu createActionMenu(Control parent) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
    final MenuManager manager = new MenuManager();
    MenuManager mgr = new MenuManager(PaletteMessages.DOCK_LABEL);
    changeDockActionClass.getDeclaredConstructors();
    // reflect the constructor of ChangeDockAction
    Constructor changeDockActionConstructor = changeDockActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class, String.class, int.class);
    changeDockActionConstructor.setAccessible(true);
    // instance of ChangeDockAction for left
    Object changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.LEFT_LABEL, PositionConstants.WEST);
    if (changeDockActionInstance instanceof IAction) {
        mgr.add((IAction) changeDockActionInstance);
    }
    // instance of ChangeDockAction for right
    changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.RIGHT_LABEL, PositionConstants.EAST);
    if (changeDockActionInstance instanceof IAction) {
        mgr.add((IAction) changeDockActionInstance);
    }
    // instance of ResizeAction
    Constructor resizeActionConstructor = resizeActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class);
    resizeActionConstructor.setAccessible(true);
    Object resizeActionInstance = resizeActionConstructor.newInstance(this);
    if (resizeActionInstance instanceof IAction) {
        mgr.add((IAction) resizeActionInstance);
    }
    manager.add(mgr);
    mgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager menuMgr) {
            IContributionItem[] items = menuMgr.getItems();
            for (IContributionItem item : items) {
                ((ActionContributionItem) item).update();
            }
        }
    });
    //
    // ShowStandardAction showStandardAction = ShowStandardAction.getInstance();
    // ShowFavoriteAction showFavoriteAction = ShowFavoriteAction.getInstance();
    // manager.add(showStandardAction);
    // manager.add(showFavoriteAction);
    // if (ShowFavoriteAction.state) {
    // showStandardAction.doSetEnable();
    // }
    OpenPaletteFilterAction openPaletteFilterAction = OpenPaletteFilterAction.getInstance();
    manager.add(openPaletteFilterAction);
    manager.add(mgr);
    addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            manager.dispose();
        }
    });
    return manager.createContextMenu(this);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) IAction(org.eclipse.jface.action.IAction) OpenPaletteFilterAction(org.talend.repository.ui.actions.OpenPaletteFilterAction) Constructor(java.lang.reflect.Constructor) IContributionItem(org.eclipse.jface.action.IContributionItem) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 2 with OpenPaletteFilterAction

use of org.talend.repository.ui.actions.OpenPaletteFilterAction in project tdi-studio-se by Talend.

the class TalendPaletteHelper method checkAndInitToolBar2.

private static void checkAndInitToolBar2() {
    //
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null || activeWorkbenchWindow.getActivePage() == null) {
        return;
    }
    boolean isTalendEditor = false;
    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
    IEditorPart activePart = activePage.getActiveEditor();
    if (activePart != null && activePart instanceof AbstractMultiPageTalendEditor) {
        isTalendEditor = true;
    }
    IViewPart paletteViewPart = activePage.findView(PaletteView.ID);
    if (paletteViewPart != null) {
        // find existing or not, and add it.
        IActionBars actionBars = paletteViewPart.getViewSite().getActionBars();
        // ShowStandardAction showStandardAction = ShowStandardAction.getInstance();
        // updatePaletteActions(actionBars, showStandardAction, isTalendEditor);
        //
        // ShowFavoriteAction showFavoriteAction = ShowFavoriteAction.getInstance();
        // updatePaletteActions(actionBars, showFavoriteAction, isTalendEditor);
        //
        // if (ShowFavoriteAction.state) {
        // showStandardAction.doSetEnable();
        // }
        OpenPaletteFilterAction openPaletteFilterAction = OpenPaletteFilterAction.getInstance();
        updatePaletteActions(actionBars, openPaletteFilterAction, isTalendEditor);
        actionBars.updateActionBars();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) OpenPaletteFilterAction(org.talend.repository.ui.actions.OpenPaletteFilterAction) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IActionBars(org.eclipse.ui.IActionBars)

Aggregations

OpenPaletteFilterAction (org.talend.repository.ui.actions.OpenPaletteFilterAction)2 Constructor (java.lang.reflect.Constructor)1 IAction (org.eclipse.jface.action.IAction)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 IActionBars (org.eclipse.ui.IActionBars)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)1