[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Big problem with editor :(
|
Hi,
I would like to open multiple editor.
I have a view i created (browser with treeview), an editor, and i want
when i click on a node in my browser to have the opening of an editor
and when i click another time on another node i would like another
editor etc. But it doesn't work i have only the first editor.
I spend a long time trying to do this, I really need help ;)
Thx a lot
Jérôme
PS:
If you want more information i can send the sources.
Here what i have :
public class MyEditor extends FormEditor {
...
public class MyEditorInput implements IEditorInput {
...
public class MyEditorMatchingStrategy implements IEditorMatchingStrategy {
...
In my treeview i have on the doubleclick
doubleClickAction = new Action() {
public void run() {
ISelection sel = viewer.getSelection();
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (StructuredSelection)sel;
Object obj = selection.getFirstElement();
IWorkbenchPage page =
MyPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (obj instanceof File){
File temp = (File)obj;
MyEditorInput input = new MyEditorInput(temp.getName());
try {
page.openEditor(input,
getEditorId(temp,MyPlugin.getDefault().getWorkbench()));
} catch (PartInitException e) {
System.out.println(e);
}
}
}
}
};
private String getEditorId(File file,IWorkbench workbench) {
IEditorRegistry editorRegistry= workbench.getEditorRegistry();
IEditorDescriptor descriptor=
editorRegistry.getDefaultEditor(file.getName());
if (descriptor != null)
return descriptor.getId();
return "org.example.MyEditor"; //$NON-NLS-1$
}