unable to edit

Post a reply

:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review

Expand view Topic review: unable to edit

Re: unable to edit

Post by robert » Wed Aug 01, 2012 2:07 pm

Unfortunately I'm a little out of my comfort zone working on this. If you can find a solution other than removing the null checks, please let me know. Otherwise, is my previous suggestion sufficient (other than still being broken in Eclipse)? Or perhaps the best solution for you is just to built RSTA's source yourself and have your local copy remove those null checks.

Re: unable to edit

Post by je_bailey » Wed Aug 01, 2012 3:04 am

Yeah the code you suggested helps in the case of where I am deploying it as a bundle(jar). It still have the same issue when I am developing the UI in eclipse. But I can live with that. Your correct that I don't see this problem with other components but I think that has to do with how OSGi works. It's a series of nested classloaders. All of the swing pieces are in one classloader, and the rtextarea is in a child classloader. So when you are registering the KeyMap, it's getting stored in one classloader and when I restart the bundle it unloads the existing classloader and then creates a new one.

Re: unable to edit

Post by robert » Sun Jul 29, 2012 3:10 am

Hmm, while I think removing the null check wouldn't hurt anything per se, I don't want to "fix" something without fully understanding it. It appears to me that RTextAreaUI is simply mimicking what BasicTextUI does in its createKeymap() and getActionMap() calls. I'm assuming you can still use other JTextComponents in this scenario, correct? You are correct of course that references to the Keymap and actionMap are being cached statically, so if OSGi is unloading classes or something similar, I see where there could be problems like this. But we need to try to determine exactly what we're doing that's different than the standard text component code path.

It sounds like your knowledge of OSGi greatly surpasses mine (familiar by name only!) so I may need your help figuring this one out.

As a workaround, if you can listen to when the classes are (should be) unloaded, can you manually call

Code: Select all

? Pretty ghetto since you're hard-coding knowledge of the constant value the RSTA library uses to store the keymap, but could be a way to keep you going without modifying the RSTA library itself until we figure out what the proper fix should be.

You could do the same thing with ActionMaps if you prefer (though I can't tell if you're saying removing either null check results in everything working for you, or some combination of the two).

Code: Select all
UIManager.put("RTextAreaUI.actionMap", null);
UIManager.put("RSyntaxTextAreaUI.actionMap", null);


Re: unable to edit

Post by je_bailey » Thu Jul 26, 2012 2:12 pm


Is this something you can replicate? Will you be able to include a fix for this in the next release?

Re: unable to edit

Post by je_bailey » Tue Jul 24, 2012 1:18 am

I have an amendment to the prior post. The prior change allowed me to type. There is another function in the same class which does the same thing (including null check) to an actionmap. One I removed the null check there as well I was able to do everything as I was supposed too.

Re: unable to edit

Post by je_bailey » Mon Jul 23, 2012 2:17 pm

Okay :) So I finally got some time this morning to download your source and do some testing.

I found out how to "fix" it.

In RTextAreaUI

* Creates the keymap for this text area. This takes the super class's
* keymap, but sets the default keystroke to be RTextAreaEditorKit's
* DefaultKeyTypedAction. This must be done to override the default
* keymap's default key-typed action.
* @return The keymap.
protected Keymap createKeymap() {

// Load the keymap we'll be using (it's saved by
// JTextComponent.addKeymap).
Keymap map = JTextComponent.getKeymap(RTEXTAREA_KEYMAP_NAME);
//if (map==null) {
Keymap parent = JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP);
map = JTextComponent.addKeymap(RTEXTAREA_KEYMAP_NAME, parent);
map.setDefaultAction(new RTextAreaEditorKit.DefaultKeyTypedAction());

return map;


I commented out the null check. My hypothesis is that there is a static reference occurring on the map that prevents it from being properly garbage collected. When I'm recreating the UI the map ends up referencing classes that are no longer being used. However Swing isn't my really my area :D

Re: unable to edit

Post by je_bailey » Mon Jul 23, 2012 12:43 pm

robert wrote:Hello,

Are you saying you can take this example, compile and run it from the command line, and get the same behavior - being unable to type in the editor?

If so, we'll have to do some digging. What OS are you on?

It's a touch more insidious then that, I seem to be working on a very edge case :) Here's the simplest steps to reproduce. (either windows or linux)

1. Get the latest version of eclipse with the GUI development plugin (Window Builder)
2. Add the example code.
3. View the code in design mode.
4. preview the gui, with the preview button that's available on (it will work this time)
5. press the re-parse button, that's next to the preview button
6. it will re-parse and instantiate the ui.

at this point on the editor won't work.

That's the simple version. What I'm doing is developing in eclipse and pushing my code to an Apache Felix OSGi container. If I was to start the container from the command line everything works, I can stop and start the bundle that contains the UI just fine. But when I reload the bundle; which happens a lot when I'm developing. It immediately stops working. ( my code is here https://github.com/JEBailey/jcr-exploder)

Eclipse is built on top of OSGi as well, that's what the equinox platform is. So I believe that is part of the problem. However I haven't been able to reproduce this with any other ui component other then yours.

It's also very clearly a key event issue. I can copy, highlight, paste, trigger folds, all with the mouse. But no key event seems to be trickling down.

Re: unable to edit

Post by robert » Mon Jul 23, 2012 4:27 am


Are you saying you can take this example, compile and run it from the command line, and get the same behavior - being unable to type in the editor?

If so, we'll have to do some digging. What OS are you on?

Re: unable to edit

Post by je_bailey » Fri Jul 20, 2012 12:17 am

Okay, this is my post, I thought I was logged in last time. I have some additional information.

I may have two separate scenarios that I'm running into at the same time. The first scenario is that I am using the WindowBuilder Editor view in eclipse (the drag and drop gui builder) then do a quick display of the JFrame. The text area doesn't seem to respond to my input as described.

Additionally. I'm deploying this into an OSGi application framework. When it's running from the OSGi container it does the same thing, it doesn't respond to input.

This doesn't seem to have anything to do with my code as I can take a sample code and have the same experience.

unable to edit

Post by Guest » Thu Jul 19, 2012 5:59 pm

I have a maven project I'm running in eclipse that is using the rsyntaxtextarea2.02.jar

Here's is my snippet of code
editorTextArea = new RSyntaxTextArea(RSyntaxTextArea.INSERT_MODE);

RTextScrollPane editorScrollPane = new RTextScrollPane(editorTextArea);

editorTextArea.setText("public static void main(String[] args) {\n}");

it displays correctly, looks fantastic, and I'm unable to edit anything. I can copy and paste into the text area, I can use the right menu to undo and redo where appropriate. It just seems not to be receiving any of my key strokes.

Any suggestions would be appreciated.