Results 1 to 3 of 3
  1. #1
    circum is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default GUI Builder: how an editor can add custom code for a property?

    Hi all,

    I have to modify an existing project in a way that from now on, for a given property of a given class on a form I need the following code generated:

    Java Code:
    component1.setPropertyName(Wrapper.method("property value"));

    So the question is how can I write a property editor which puts the Wrapper.method() into the generated code?

    There is a PropertyDescriptor and a PropertyEditor already for the property, but as I understand now it simply does not allow customizing the code generation itself.

    I have found in netbeans source that there is a class RADConnectionPropertyEditor.RADConnectionDesignVal ue, which is used by Netbeans' "Custom code" property editor, and I guess that maybe I could create a property value of this type in my editor to achieve my goal. The problem is, that this class belongs to netbeans -- it means I have to include all the netbeans jars into my project...?

    Is it feasible what I need? Is it the right way to do?

    I am using NetBeans 6.5, just in case it does matter.

    Thanks,
    Circum

  2. #2
    shall is offline Senior Member
    Join Date
    Apr 2012
    Posts
    199
    Rep Power
    0

    Default Re: GUI Builder: how an editor can add custom code for a property?

    I haven't done it before.

    Search for "Customize Code Dialog Box (Swing GUI Builder)" in the Help->Help Contents. I think that might be thing your looking for.

  3. #3
    circum is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: GUI Builder: how an editor can add custom code for a property?

    Reply to myself:

    You do not need the RADConnectionPropertyEditor.RADConnectionDesignVal ue class to customize code generation.

    If you have a custom PropertyEditor for your property, the editor's getJavaInitializationString() method returns the user code which is put as parameter of the setter/getter method call. So, if you make a propertydescriptor with setter method setPropertyName(), with a custom property editor class, and implement getJavaInitializationString() something like this:

    public String getJavaInitializationString() {
    return "Wrapper.method(\"" + getAsText() + "\")";
    }
    Then you get the expected result. (Please note that I have more complicated case, I did not tried out whether getAsText() is the right call to get the property's value.)

Similar Threads

  1. Custom code validation
    By shivam0101 in forum Advanced Java
    Replies: 1
    Last Post: 01-13-2012, 02:40 PM
  2. No Property Editor Found Exception -JSF 1.2
    By venkatcanwin in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 11-18-2010, 07:02 AM
  3. Help Creating Custom File and Adding an Editor
    By Fondor in forum Advanced Java
    Replies: 6
    Last Post: 04-23-2010, 05:06 AM
  4. AutoCompile in Eclipse Custom Editor
    By SSG_JJV in forum Eclipse
    Replies: 2
    Last Post: 01-29-2009, 05:09 AM
  5. Replies: 1
    Last Post: 04-26-2007, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •