Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用另一个编辑器RCP、SWT、JAVA上的按钮打开编辑器_Java_Swt_Rcp_Jface - Fatal编程技术网

使用另一个编辑器RCP、SWT、JAVA上的按钮打开编辑器

使用另一个编辑器RCP、SWT、JAVA上的按钮打开编辑器,java,swt,rcp,jface,Java,Swt,Rcp,Jface,我有一个RCP程序,有3个部分-2个视图(左侧,2个部分)和各种编辑器(右侧和其他部分)。 在我的视图中,我有树,我可以打开编辑器(其他部分)。 在编辑器上,我可以打开另一个编辑器,但我需要在调用编辑器时跳过一个对象,我将其设置为:addMouseListener(newmouseadapter()){ @凌驾 public void mouseDown(MouseEvent e){…. 我的按钮: btnNewButton.addMouseListener(new MouseAdapter()

我有一个RCP程序,有3个部分-2个视图(左侧,2个部分)和各种编辑器(右侧和其他部分)。 在我的视图中,我有树,我可以打开编辑器(其他部分)。 在编辑器上,我可以打开另一个编辑器,但我需要在调用编辑器时跳过一个对象,我将其设置为:
addMouseListener(newmouseadapter()){
@凌驾
public void mouseDown(MouseEvent e){….

我的按钮:

btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {

                  IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);

                  try {
                        handlerService.executeCommand("XPTO.command", null);
                    } catch (Exception ex) {
                        throw new RuntimeException(
                                "XPTO");
                    }
                }
            }); 
我的命令:

public class CallEditors extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    System.out.println("calledEditor");

    // Get the view
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);

    IWorkbenchPage page = window.getActivePage();

    Editor navEditor = (Editor) page.findEditor(Editor.IDI);
} }

谢谢


我有答案:

btnNewButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {

                // Get the view
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

                IWorkbenchPage page = window.getActivePage();


                    Object obj = btnNewButton.getData();

                    if (obj != null) {


                      xPTO input = new xPTO();
                          try {

                                 page.openEditor(input, xptoEditor.ID, false);  
                                } catch (PartInitException e1) {
                                    throw new RuntimeException(e1);
                                }
                      }

}

使用
IWorkbenchPage#openEditor(..)
这里的问题是什么?如何使用另一个编辑器上的按钮打开编辑器?