The code for the error is
protected void buttonpressed (int buttonid) {
Display.getdefault (). Syncexec (New Runnable () {
public void Run () {
Localpmtsstreamviewsaction.refreshperspective (Localviewid,
LOCALW);
}
});
Super.buttonpressed (ButtonID);
}
Throw exception:
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 : Up to 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)
The solution to this problem: just change the order of the Code
protected void buttonpressed (int buttonid) {
Super.buttonpressed (ButtonID);//This line of code is put here
Display.getdefault (). Syncexec (New Runnable () {
public void Run () {
Localpmtsstreamviewsaction.refreshperspective (Localviewid,
LOCALW);
}
});
}