问题
I'm trying make a toolbar button to open one file with another editor on my RCP aplication!
I have de following code:
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();
}
but when i call de action, he did not do anything! but also does not return error..
The result of System.out.println()
looks like correct:
==>>org.eclipse.ui.part.FileEditorInput(/g/Network.int)>>>>DesignEditor
what i do wrong?
I following this advice to do my button
Sorry my english Regards
回答1:
The id value should be more like a java package name: org.myorg.tooling.designeditor
来源:https://stackoverflow.com/questions/12863111/workbenchpage-openeditor-does-nothing