swingx - Why does a RolloverRenderer uses the wrong cell context -


It's difficult to reproduce my issue, but I hope someone can give me a hint here How is it solved?

I received a ComponentProvider & lt; JLabel & gt; is a string that assumes a string creates a clickable cell decorated with an icon if the string contains a URL if no URL is found in the string value, then no icon is set for the label And the cell should not be clickable

Here is the code:

  Public class ExternalLinkProvider ExponentProvider Expands & lt; JLabel & gt; Rollover renderer {private string url = null; Applies; @ Override Protected Zero Format (Selconent Reference) {} @ Override Protected Zero Configuration (Cell Content Reference) {If (context.getValue (Example String)} {String stringValue = (string) context.getValue (); WwwLink Link = NewWwwLink (stringValue); // Set a link icon if it has a valid URL. If (link.isValid ()) {rendererComponent.setIcon (ExternalLink.WWW_LINK_ICON); Url = link.getUrl (); } Else {rendererComponent.setIcon (null); Url = null; } RendererComponent.setText (link.getString ()); }} @ Override Protected JLab MakeRenderer Companent () {Return New Generator Label (); } @ Override Public Boolean enabled () {Return URL! = Null; } @ Override Public Wide Doychic () {if (url! = Null) {// Follow URL}}}   

It looks like:

Enter image details here

Clicking the first cell to follow the given link in the string Must be qualified and removed from the display text. The second cell had no link in the text and therefore it should not be clickable

However, in this case, both cells are not clickable and if I store the string value and it < Code> isEnabled () method, I think that

is the only condition that has seen me this behavior. I know that a provider example for each type of cell is reused, but for some reason the rollover renderer does not properly reconfigure this provider in this case.

Am I doing something wrong here?

After playing some games: you might hit on this issue - all our instances always click Actually, it is brittle to keep the cell related state in the provider, because it can be said often and for other cells

The rollovers renderer's API is not really rich enough: the system Depends on the renderer which is configured before a click (So ​​that "old" situation still does), is not sufficient for your use case: -) You may want to consider filing a bug report in swing x issue tracker, so we do not forget to look into it. Thank you.

To play with the snippet, it basically shows which methods can be overridden in a custom provider (but not solving the problem - rollover always excluding a user-irrelevant call Enabled):

  Expands the Public Class ExternalLinkProvider Applying LabelProvider RolloverRenderer {Private URL url = null; / ** * Override * / @ Override Protected to Check for Valid URLs * Zero Config Contents (Selcontext Reference) {url = ConvertVolueUule (Reference.Gate Value); Super.configureContent (reference); } Private URL ConvertVaultUul (Object Result) {If (! (Result of string!) Blank return; Url = null; Try {url = new URL (result.To string ()); } Catch (exception e) {// TODO: handle exception} return url; } Get @ Override Protected Icon ValueAsIcon (SelconTest Reference) {return url! = Null? XTestUtils.loadDefaultIcon (): Zero; } / ** * Conditional enable is not strongly supported. Really returning * Probably is not an option because the cursor has changed ... * / @ Override public boolean is enabled () {back true; // url! = Null; } @ Override Public Wide Doecic () {follow (url! = Null) {// url System.out.println ("Clicking"); }}}    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -