当前位置: 代码迷 >> Eclipse >> 做eclipse 插件的时候,遇到"The chosen operation is not currently available"的异常
  详细解决方案

做eclipse 插件的时候,遇到"The chosen operation is not currently available"的异常

热度:760   发布时间:2016-04-23 02:00:11.0
做eclipse 插件的时候,遇到"The chosen operation is not currently available"的错误
进入run()的时候,我发现window是空值
我就是想调用一个窗口而已
这是我的TestViewAction
package com.test.action;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

import com.test.view.MainView;

public class TestViewAction implements IWorkbenchWindowActionDelegate{


private IWorkbenchWindow window;
private IShellProvider is = null;


public TestViewAction(IWorkbenchWindow window){
this.window = window;
}

@Override
public void dispose() {
// TODO Auto-generated method stub

}

@Override
public void init(IWorkbenchWindow arg0) {
// TODO Auto-generated method stub

}

@Override
public void run(IAction arg0) {
// TODO Auto-generated method stub
window.getActivePage().findView("com.test.view.MainView");
}

@Override
public void selectionChanged(IAction arg0, ISelection arg1) {
// TODO Auto-generated method stub

}

}



plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>

   <extension 
    point="org.eclipse.ui.actionSets">
    <actionSet 
    label="Sample Action Set"
            visible="true"
            id="com.test.actionSet">
            <menu
               label="Test &amp;Menu"
               id="testMenu">
            <separator
                  name="testGroup">
            </separator>
         </menu>
          <action
               label="&amp;Test Action"
               icon="icons/sample.gif"
               class="com.test.action.TestViewAction"
               tooltip="Hello, Eclipse world"
               menubarPath="testMenu/testGroup"
               toolbarPath="testGroup"
               id="com.test.action.TestViewAction">
         </action>
    </actionSet>
   </extension>
  相关解决方案