Search in sources :

Example 6 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project translationstudio8 by heartsome.

the class ApplicationWorkbenchWindowAdvisor method setListenerToPespective.

/**
	 * 给默认透视图添加监听,当透视图发生改变时,触发相关事件	robert	2012-10-18
	 * @param commandService
	 */
private void setListenerToPespective(final ICommandService commandService) {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IPerspectiveListener perspectiveListener = new IPerspectiveListener() {

        public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
        }

        public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
            // 改变透视图时,发出监听去检查品质检查结果视图的状态,从而让 视图 菜单的状态与之保持一致。
            commandService.refreshElements("net.heartsome.cat.ts.ui.qa.handlers.OpenQAResultViewCommand", null);
            // 显示状态栏与工具栏
            IHandlerService handlerService = (IHandlerService) window.getService(IHandlerService.class);
            IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
            boolean statusVisible = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status);
            if (!statusVisible) {
                preferenceStore.setValue(TsPreferencesConstant.TS_statusBar_status, false);
                try {
                    handlerService.executeCommand("net.heartsome.cat.ts.command.openStatusBar", null);
                } catch (Exception ex) {
                    throw new RuntimeException("CommandTest.exitcommand not found");
                }
            }
            WorkbenchWindow window_1 = (WorkbenchWindow) window;
            if (!window_1.getCoolBarVisible()) {
                try {
                    window_1.toggleToolbarVisibility();
                    commandService.refreshElements("net.heartsome.cat.ts.command.openToolBar", null);
                } catch (Exception ex) {
                    throw new RuntimeException("CommandTest.exitcommand not found");
                }
            }
        }
    };
    window.addPerspectiveListener(perspectiveListener);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WorkbenchWindow(org.eclipse.ui.internal.WorkbenchWindow) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPerspectiveListener(org.eclipse.ui.IPerspectiveListener) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 7 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project dbeaver by serge-rider.

the class CheckForUpdateAction method deactivateStandardHandler.

public static void deactivateStandardHandler(IWorkbenchWindow window) {
    if (p2UpdateHandlerActivation != null) {
        return;
    }
    IHandlerService srv = window.getService(IHandlerService.class);
    p2UpdateHandlerActivation = srv.activateHandler(CheckForUpdateAction.P2_UPDATE_COMMAND, new AbstractHandler() {

        @Override
        public Object execute(ExecutionEvent event) throws ExecutionException {
            new CheckForUpdateAction().run();
            return null;
        }
    });
}
Also used : IHandlerService(org.eclipse.ui.handlers.IHandlerService) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) AbstractHandler(org.eclipse.core.commands.AbstractHandler)

Example 8 with IHandlerService

use of org.eclipse.ui.handlers.IHandlerService in project tdi-studio-se by Talend.

the class BindingActions method registerActions.

/**
     * DOC smallet Comment method "registerActions".
     */
private void registerActions() {
    IContextService contextService = (IContextService) PlatformUI.getWorkbench().getAdapter(IContextService.class);
    //$NON-NLS-1$
    contextService.activateContext("talend.global");
    IWorkbench workbench = PlatformUI.getWorkbench();
    IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
    IHandler handler;
    for (IAction action : actions) {
        handler = new ActionHandler(action);
        handlerService.activateHandler(action.getActionDefinitionId(), handler);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IAction(org.eclipse.jface.action.IAction) IHandler(org.eclipse.core.commands.IHandler) IContextService(org.eclipse.ui.contexts.IContextService) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Aggregations

IHandlerService (org.eclipse.ui.handlers.IHandlerService)8 IHandler (org.eclipse.core.commands.IHandler)2 IAction (org.eclipse.jface.action.IAction)2 ActionHandler (org.eclipse.jface.commands.ActionHandler)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 AbstractHandler (org.eclipse.core.commands.AbstractHandler)1 Command (org.eclipse.core.commands.Command)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)1 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProduct (org.eclipse.core.runtime.IProduct)1