Dragging and dropping code snippets from the Palette (23 posts)

  • Profile picture of zathras zathras31p said 3 months, 2 weeks ago:

    As you may have noticed, the SDK has a Java code palette. Open a Java file, then choose Windows>Palette if you don’t see it. It contains common code snippets that you can drag and drop into a method (or into the class, it depends) and adjust to your application’s needs.

    For example, there are code snippets for light sources, some particle and post-processor effects, Node and Material code, some common input handlers, quaternions, HUD text, load and save a Node as j3o…

    Does anyone use it yet? I just added some new snippets, but maybe you can think of other useful things that you would like to see there. You know, THAT one line of code that you keep in a text file and copy all the time, because it’s so powerful but you always forget it? 8)

    I don’t want to fill it just for the heck of it, it has to be something useful. A palette only makes sense for self-contained kinds of code samples. (It can’t be code that needs to be added in two, three different places, for example.)

    Well, try it, and tell us whether it works for you.

  • Profile picture of wezrule wezrule201p said 3 months, 2 weeks ago:

    i always use it for quaternions and lights, and sometimes the particles. Im sure theres much more it will be useful for, but i cant think off the top of my head

  • Profile picture of glaucomardano glaucomardano252p said 3 months, 2 weeks ago:

    yeah, this is very useful.

  • Profile picture of glaucomardano glaucomardano252p said 3 months, 1 week ago:

    Btw the code snippets are out of date.

  • Profile picture of Sploreg Sploreg202p said 3 months, 1 week ago:

    I use the quaternions frequently. I will try and think of some useful code snippets I know I have used a lot that would be beneficial to others.

  • Profile picture of sbook sbook261p said 3 months, 1 week ago:

    I think having a few of the popular materials setup with each of their fields set would be helpful.. Lighting and Unshaded I guess would be the two big ones.

  • Profile picture of darkeye darkeye said 3 months, 1 week ago:

    I’d like to ask if it is possible change the palette. I’d like to set there my own code snippets.

  • Profile picture of normen normen1290p said 3 months, 1 week ago:

    @darkeye said:
    I’d like to ask if it is possible change the palette. I’d like to set there my own code snippets.

    not really but you can set macros in the settings that expand to full code snippets.

  • Profile picture of sbook sbook261p said 3 months, 1 week ago:

    @normen said:
    not really but you can set macros in the settings that expand to full code snippets.

    Are the snippets there hardcoded into the app?

  • Profile picture of normen normen1290p said 3 months, 1 week ago:

    @sbook said:
    Are the snippets there hardcoded into the app?

    They are basically intelligent scripts that could do much more than just insert text in the editor but also change names according to the existing code etc.

  • Profile picture of sbook sbook261p said 3 months, 1 week ago:

    Cool.. so it wouldn’t be totally far-fetched to see an SDK plugin that let the user “drag” highlighted text in the editor to the palette (or something along those lines?)

    Could be a fun project for me to become more intimate with the NetBeans API :)

  • Profile picture of normen normen1290p said 3 months, 1 week ago:

    I think I even saw some plugin like that..

  • Profile picture of zathras zathras31p said 3 months ago:

    Gaaah. I didn’t set this thread up to send me email alerts, duh. Thanks for your answers!

    @glaucomardano: Which ones are out of date? I updated a few of them, but editing this code in the sources is like open heart surgery with a playstation controller :o ;)

    @sbook When you open an HTML file in the SDK together with the Palette, you can drag an drop HTML code snippets into it… @Normen, can you reuse this existing Platform code? (Maybe related? http://platform.netbeans.org/tutorials/nbm-palette-api1.html) Adding stuff by drag&drop would be super awesome.

    Macros (Options> Editor>Macros) are another option to insert custom code, true!

  • Profile picture of glaucomardano glaucomardano252p said 3 months ago:

    @zathras said:
    @glaucomardano: Which ones are out of date? I updated a few of them, but editing this code in the sources is like open heart surgery with a playstation controller :o ;)

    If I remember well, there’s a particle emitter snippet with reference problems, it calls methods that doesn’t exist anymore.

  • Profile picture of zathras zathras31p said 2 months, 4 weeks ago:

    @glaucomardano Good catch, the effects API changed months ago… The fix should be in the next nightly build.
    I also noticed that the InputListener snippet never reacted to being dropped, hopefully also fixed now.

    @sbook Did you try the snippets under “Material”? You are saying the examples should be more extensive?