jrubyfx icon indicating copy to clipboard operation
jrubyfx copied to clipboard

Node inspector

Open whitehat101 opened this issue 12 years ago • 4 comments

I was sad that calling #inspect on Java FX objects didn't return much useful information.

This pull only deals with #inspect on objects descended from Node. It is able to discover all the properties of just the top class. (It can be used for more custom inspections, see inspector_spec)

Java::JavafxSceneShape::Rectangle.new.inspect => 
  #<Java::JavafxSceneShape::Rectangle:0x64027866 x:0.0 y:0.0 width:0.0 height:0.0 arcWidth:0.0 arcHeight:0.0>

Lots of examples in the specs.

I'd like to get a useful inspect for Events as well, someday.

Enjoy!

dirty: https://github.com/whitehat101/jrubyfx/tree/inspector

whitehat101 avatar Apr 20 '13 04:04 whitehat101

Hey a fix for #40. In my quick scan over it looks fairly good except this:

+Java::JavafxScene::Node.send :include, JRubyFX::Utils::Inspector

just put it in node.rb.

byteit101 avatar Apr 20 '13 16:04 byteit101

I doubt anyone will ever call 'discover_properties' outside of inspect, but the logic below seems like it belongs (in some form) in discover_properties just in case something else ever wants that info. Otherwise each consumer needs to know to perform this ||'ing:

(self.class.instance_variable_get('@inspect_properties')||discover_properties). 

enebo avatar Apr 20 '13 16:04 enebo

Hey wait a minute! Is there a reason you can't use toString?

 System.out.println(aGridObjectInJavaLand);
 Grid hgap=0.0, vgap=0.0, alignment=TOP_LEFT

is what I just got from debugging a hybrid jrubyfx/java app

byteit101 avatar Apr 20 '13 21:04 byteit101

@whitehat101 toString is quite variable in its coverage. If you update this pr to inject itself into the new precompilation phase (second half of dsl.rb) with all the reflected properties pre-computed, I'll pull it

byteit101 avatar May 17 '13 15:05 byteit101