做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 &Menu"
id="testMenu">
<separator
name="testGroup">
</separator>
</menu>
<action
label="&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>
<extension
point="org.eclipse.ui.views">
<view
class="com.test.view.MainView"
id="com.test.view.MainView"
name="mainView">
</view>
</extension>
</plugin>
[最优解释]
@Override
public void init(IWorkbenchWindow arg0) {
// TODO Auto-generated method stub
this.window = window;
}
[其他解释]
另外好像必须有个无参构造函数的,系统创建对象的时候是用无参构造函数的。
[其他解释]
谢谢楼上的
[其他解释]
up
[其他解释]
seesee
[其他解释]
原来是这么回事儿啊!
[其他解释]
xixie
[其他解释]
貌似还是不行,人在吗,指教指教