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);
}
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;
}
});
}
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);
}
}
Aggregations