XML editor embedded in a MultiPageEditor [message #1730843] |
Fri, 29 April 2016 03:40  |
Eclipse User |
|
|
|
Hello,
I'm working on a plugin designed to assist the user when he's editing XML files. The current project works """fine""" but I'm using a "StructuredTextEditor" as main component. It implies two things :
- Opening a new file implies opening a new editor every time
- I can't get notified properly when the user activates another page (here, an other instance of the editor)
Moreover, I'm applying listeners on the editor. And as I can't get notified when the user activates another page, I cannot remove my listeners from all the open editors ===> Each action on an editor triggers an event on ALL editors. This makes the plugin really slow to work.
I saw an object called "MultiPageEditorPart", with a method "addPageChangedListener". I think this could be the key to solve my issue, but I cannot integrate it correctly.
If you already faced that kind of problem, if you know how a MPE works or if you see another solution to my problem, I would be glad to read your responses.
Thanks for reading.
[Updated on: Fri, 29 April 2016 08:51] by Moderator
|
|
|
Re: XML editor embedded in a MultiPageEditor [message #1730879 is a reply to message #1730843] |
Fri, 29 April 2016 08:50  |
Eclipse User |
|
|
|
I found an alternative solution. It's a bit "dirty", but it works fine. I post it here for those who could face the same problem one day :
I have an XML editor called TestCaseEditor (extends StructuredTextEditor)
I created a class (TestCaseEditorManager), with a static attribute and a static method. Here is its source code :
public class TestCaseEditorManager{
private static TestCaseEditor oldTestCaseEditor;
public static void create(TestCaseEditor tce) {
if (oldTestCaseEditor != null){
oldTestCaseEditor.removeListener();
System.out.println("listeners removed from : " + oldTestCaseEditor.getPartName());
}
oldTestCaseEditor = tce;
}
}
My TestCaseEditor has its listeners as attributes, and calls the following method in its constructor :
TestCaseEditorManager.create(this);
There is also a method called by TestCaseEditorManager inside TestCaseEditor, which is
public void removeListener(){
window.getPartService().removePartListener(listener);
window.getActivePage().removePostSelectionListener(selectionListener);
}
If you are facing the problem but find the solution unclear, feel free to contact me.
|
|
|
Powered by
FUDForum. Page generated in 0.25711 seconds