-1

私は1つのRCPプログラムを持っており、3つの部分があります-2つのビュー(左側に2つの部分)とさまざまなエディター(右側と他の部分)。私の見解では、私は木を持っており、エディターを開くことができます(他の部分)。エディターでは別のエディターを開くことができますが、エディターを呼び出すときにオブジェクトを通過する必要があります。addMouseListener(new MouseAdapter() { @Override 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);
                                }
                      }

}

4

1 に答える 1

2

使用するIWorkbenchPage#openEditor(..)

于 2013-01-03T16:27:20.970 に答える