1

我正在尝试制作一个工具栏按钮,以便在我的RCP 应用程序上使用另一个编辑器打开一个文件!

我有以下代码:

        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart oldEditor = page.getActiveEditor();
    IFile file = ((IFileEditorInput) oldEditor.getEditorInput()).getFile();

    IConfigurationElement[] editorsElements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.editors");

    IEditorInput editorInput = new FileEditorInput(file);

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page2 = window.getActivePage();
    try {
        page2.openEditor(editorInput, editorsElements[3].getAttribute("id"));
        System.out.println("==>>"+editorInput+">>>>"+ editorsElements[3].getAttribute("id"));
    } catch (PartInitException e) {
        e.printStackTrace();
    }

但是当我要求采取行动时,他什么也没做!但也不返回错误..

结果System.out.println()看起来是正确的:

==>>org.eclipse.ui.part.FileEditorInput(/g/Network.int)>>>>DesignEditor

我做错了什么?

我按照 这个建议做我的按钮

对不起我的英语问候

4

1 回答 1

1

id 值应该更像一个 java 包名:org.myorg.tooling.designitor

于 2012-10-12T16:25:19.343 回答