Document.addDocumentListener throws "Already registered" Follow
Is there any way to check if a listener already registered with the document? I'm getting `java.lang.Throwable: Already registered` error, but obviously I could've avoided it if I had a way to check if the listener is already registered.
Also, apparently there's no way to suppress this error by surrounding the code with try/catch.
Please sign in to leave a comment.
Please show the code/use-case where listener is attached.
Something like this:
So again, I see two issues here. First, I have no way to check if the listener is already added to the document, and second, even though I have try/catch, the throwable is not caught.
Please show the full source code of this snippet. You cannot "catch" the error message from LOG.error("Already registered: " + listener);
Hmm, ok, I see.
OK, here's the full code. What I'm trying to do here is I have a folder that contains a number of "input" files, and there's a listener that reacts to the changes in these files.
I would like to understand the use-case better. From where is this code collecting files and registering listeners called from? Why multiple times (as it seems)? Why do you create Editor instance?
What kind of changes of the files in this special directory do you want to monitor?
I have a plugin for custom language/framework that processes multiple input files. The result of the processing changes depending on the content of these files, so I want to automatically detect the change in any of the input files and refresh the output. In addition to that, input files are grouped in sets and user has an option to switch between the sets - so every time the new set is selected, I'm resetting everything and process the input files again.
Folks, I posted this a while ago, but I'm still having the same issue. What I'm looking for is a way to reset the document listener or at least the way to check if document listener has already been added to the document. Is it possible? Are there any workarounds?