zoukankan      html  css  js  c++  java
  • JFace dailog button事件中刷新透视图异常 Trying to execute the disabled command org.eclipse.ui.window.closePerspective

    报错的代码为

    protected void buttonPressed(int buttonId) {

    Display.getDefault().syncExec(new Runnable() {
    public void run() {
    localpmtsStreamViewsAction.refreshPerspective(localviewId,
    localw);
    }
    });

    super.buttonPressed(buttonId);

    }

    抛异常:

    org.eclipse.core.commands.NotEnabledException: Trying to execute the disabled command org.eclipse.ui.window.closePerspectiveat org.eclipse.core.commands.Command.executeWithChecks(Command.java:469)at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)at org.eclipse.ui.internal.actions.CommandAction.run(CommandAction.java:171)at cn.cncc.pams.actions.PMTSStreamViewsAction.refreshPerspective(PMTSStreamViewsAction.java:74)at cn.cncc.pams.test.MultiDialog$3.run(MultiDialog.java:274)at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:179)at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:150)at org.eclipse.swt.widgets.Display.syncExec(Display.java:4584)at cn.cncc.pams.test.MultiDialog.buttonPressed(MultiDialog.java:272)at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)at org.eclipse.jface.window.Window.open(Window.java:801)at cn.cncc.pams.actions.PMTSStreamViewsAction.run(PMTSStreamViewsAction.java:56)at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)at cn.cncc.pams.main.Application.start(Application.java:125)at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)at org.eclipse.equinox.launcher.Main.run(Main.java:1408)at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

    这个问题的解决办法:只需要改变代码的顺序即可

    protected void buttonPressed(int buttonId) {

    super.buttonPressed(buttonId);//这一行代码放到这里

    Display.getDefault().syncExec(new Runnable() {
    public void run() {
    localpmtsStreamViewsAction.refreshPerspective(localviewId,
    localw);
    }
    });

    }

  • 相关阅读:
    一条查询SQl是怎样执行的
    MySQL45讲笔记-事务隔离级别,为什么你改了数据我看不见
    了解一下IO控制器与控制方式
    进程的同步与互斥
    预防死锁,检测死锁,避免死锁,解除死锁....
    初识Git
    剑指offer-查找数组中重复的数字
    常见的几种进程调度算法
    操作系统-进程的状态以及转换
    中断、异常、系统调用
  • 原文地址:https://www.cnblogs.com/cupsuccess/p/3785377.html
Copyright © 2011-2022 走看看