Thursday, July 7, 2016

Eclipse WindowBuilder: JavaDoc tags reference

Documentation about the WindowBuilder JavaDoc tags is sparse. I have found only two resources so far. First the source code and second the DesignerCustomizationAPI.pdf. Though the DesignerCustomizationAPI.pdf is part of the official WindowBuilder documentation it's a little bit hard to find. As a quick reference I have listed all WindowBuilder JavaDoc tags which I know so far in this blog post. Most of the information is taken directly from DesignerCustomizationAPI.pdf.


@wbp.factory


Description


Specifies if method is a factory method. If this tag is used on a class, then all methods of this class are considered as factories. Designer will automatically exclude methods that return «null» (such as setters) and getters, i.e. methods that starts with «set» and have no parameters.

@wbp.factory.parameter.source parameterName expressionSource


Description


Sets the default source for parameter. This source will also be used when adding component using this factory method. If no such source is specified, the default value for this type will be used – zero for numerics and «null» for objects.

@wbp.factory.parameter.property parameterName propertyTitle


Description


Specifies that the parameter with given name is bound to some component property. This is useful for example if you want to set the text of a button directly in a factory method, without additional setText() invocation.


@wbp.factory.parameters.noBinding



Description


Specifies that Designer should not bind parameters to properties by names.

Usually parameters are bound to corresponding properties, but if there are many methods and parameters, it is tedious to describe each binding. Instead, you can just name the parameters with the same name as the title of the components property. For example, if you name the parameter «text», it will be bound to a property with title «text». Note that title is used, not id of the property (because id is a complex string).

One special name of parameter is reserved for SWT support, parameter with
name «parent» is considered as parent parameter (i.e. in same way if it would be
marked as parent in *.wbp-factory.xml).

@wbp.parser.entryPoint


Description


If you want to edit a GUI in a standalone class, which is not a subclass of a known component, such as Swing JPanel or SWT Composite, then you should tell WindowBuilder which method to use as the entry point for execution flow. In this case WindowBuilder will not look in the constructor and superclass, it will design only this specific method.


Example

/**
 * @wbp.parser.entryPoint
 */
public void someMethod(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
}


@wbp.parser.preferredRoot


Description


Specifies that marked component should be used as root component, even when there are other possible roots, may be with bigger hierarchy (by default WindowBuilder chooses root component with biggest hierarchy).


Example

mainPanel = new JPanel(); // @wbp.parser.preferredRoot

@wbp.parser.constructor


Description

If «this» component has only one constructor, then Designer will select it as entry point for execution flow. If «this» container has several constructors and one of them marked with this tag, then it will be used. If no tag and container has a default constructor (without parameters), then it will be used implicitly. If all constructors are non-default, error will be generated.


@wbp.eval.method.parameter parameterName expressionSource


Description


If the constructor, (or other entry method), has a parameter whose value is used for creating some component or as part of some property (method invocation or field assignment), then Designer requires hint about value that will be passed with this parameter. This tag can be used to specify any statically evaluable expression.


Example

/**
 * @wbp.eval.method.parameter _int 1 + 2
 * @wbp.eval.method.parameter _true true
 * @wbp.eval.method.parameter _false false
 * @wbp.eval.method.parameter _string "ab" + "c"
 * @wbp.eval.method.parameter _null null
 */
public Test(int _int, boolean _true, boolean _false, String _string,
        Object _null) {
    super(_int, _true, _false, _string, _null);
}


@wbp.eval.method.return parameterName


Description


Sometimes code may use some instance methods declared in the same class. Designer can not evaluate these methods (at least in current implementation), so it requires some hint. In our experience, the value of one of the parameters (usually even single parameter) is enough.

Example

public int root() {
    return instancePublicMethod(5);
}
 /**
  * @wbp.eval.method.return value
  */
public int instancePublicMethod(int value) {
    return 2 * value;
}
/**


@wbp.gwt.Request


Description


GWT specific tag for RemoteService interface method that specifies that com.google.gwt.http.client.Request should be returned from «async» of this method.

Example


@wbp.gwt.Request
public interface MyService extends RemoteService {
    /** @wbp.gwt.Request */
    int getValue() throws Exception;
}


@wbp.nls.resourceBundle test.messages


Description


JavaDoc tag that tells the parser where to find the resource files.


Example

/**
 * @wbp.nls.resourceBundle test.messages
 */
private static final ResourceBundle m_bundle = MyResourceBundleFactory.getMainBundle();

No comments:

Post a Comment