accessing stylesheet classes in code (for creating custom editors)

I was hoping to create an EditorCell_Constant in my code (say, in the implementation of a $custom_editor$) with a font family that is different.. So I typed this:

  EditorCell_Constant s = new EditorCell_Constant(context, myNode, "test");

then I insert it into a horizontal collection and it works. The thing is, I would like to change the font family for s, though I'm having trouble changing it... For example, if I say:

  EditorCell_Constant s = new EditorCell_Constant(context, myNode, "test");
s.getStyle().set(StyleAttributes.EDITABLE, true);
s.getStyle().set(StyleAttributes.FONT_FAMILY, fontFamily/Brush Script MT/);

the font stays the same as it was before I tried changing (via the third line above). Setting EDITABLE to true however seems to work as expected. 

I think this might have to do with the fact that my constant cells are all assigned a particular Key from some styleKeyPack and I don't know how to programmatically "apply" my EditorCell to use a different stylesheet class (I have defined one for my language -- though am unsure how to retrieve it's various classes. That is, given some stylesheet like this:

stylesheet FooLangStyle {

  style Moo {

      font-family: fontFamily/Brush Script MT/

      editable: false





How would one go about programmatically "applying" Moo style to my custom editor cell?

I don't even know how to access the (generated) stylesheet programmatically.. though I did manage to find something promising here:

(See line 123, for instance, where they set the javadoc styleclass):

Lastly: Yes, I know this would be super easy to do natively in the editor aspect, but I'm working on a more general use-case where I would like to display a more complex collection derived from a concept---and the only way I can think of doing it is through $custom_cell$.

Thanks for reading.

1 comment
Comment actions Permalink

Think I figured this out.. I found a styleRegistry object  has the style keys for my language stored in it: 


If I want to apply the separate font family + these style classes various other attributes I can do it like this and it seems to work:

EditorCell_Constant s = new EditorCell_Constant(context, myNode, "test");

StyleRegistry reg = StyleRegistry.getInstance();

Style desiredStyle = reg.getStyle("BRUSH_IDENT");


s.getStyle().set(StyleAttributes.Editable, true);

The trick was finding the StyleRegistry. Interestingly enough, the registry only seems to hold keys which are explicitly employed in styleclasses.


Please sign in to leave a comment.