Hi everyone,
I have created a perspective with two CDockables, the rightPanel and the leftPanel, each of them taking half the grid.
In the leftPanel, I can select text files in a tree view. When double-clicking a text file, I want it to appear in a text editor on the rightPanel (by default, there is already a “tab” in the right panel, I want to add one more for each opened text file).
How can I do that?
I tried directly adding a CDockable wrapping the text editor in the existing perspective like this:
private final void editSelectedFile() {
final TextEditor textEditor = new TextEditor(selectedFile);
CPerspective perspective = perspectivesMap.get(perspectiveName);
final String uniqueId = String.valueOf(counter.incrementAndGet());
final DefaultSingleCDockable dockable = new DefaultSingleCDockable(uniqueId, selectedFile.getName(), textEditor);
control.addDockable(dockable);
final CGridPerspective center = perspective.getContentArea().getCenter();
center.gridAdd(50, 0, 50, 100, new SingleCDockablePerspective(uniqueId));
perspectives.setPerspective(perspectiveName, perspective);
control.load(perspectiveName);
}
My problem is that if I close the text editor for file1.txt and open a new editor for file2.txt, the editor of file1.txt appears again. This is normal, it is registered in the perspective… But this is not the behaviour the user expects…
What I want is to insert the new CDockables in the current view, at the correct place, and not to add them in the perspective itself.
The documentation on perspectives is rather limited and I could’nt find how to do it. Can anyone help?
Kind regards