|
DocDoku_GWT_Widget_Library_Howto
Here is explained the basis to use Docdoku-widgets-1.0
Library contentsDocDoku Widget library is a set of re-usable GWT components.It contents mainly :
Here is explained how you can use them. Setting up your projectDependencies to other librariesDocDoku widget library depends on two GWT libraries (three in fact, with the google API), GWT dnd and Cobogwt. You can find GWT dnd here and Cobogwt here. Module inheritanceTo use the library in your modules, add the following to your Module.gwt.xml file : <inherits name='com.docdoku.gwt.client.ui.Docdoku-widgets' /> Widgets providedHere is a short introduction to widgets included in the library. SpinBoxA spin box provides an easy way to input numbers. SpinBoxListener listener = new ... ; // whatever that implements SpinBoxListener SpinBox spin = new SpinBox(0,50,42) ; spin.addListener(listener); TableWidgetThe TableWidget is very similar to Swing Table, in the way that it holds data in a model and uses delegates/renderers to display the content of a cell. It features Drag'n drop support (thanks to GWT dnd) and a basic selection mode, as you can find in GMail. One particularity of TableWidget is that it uses a TableProfile to manage style, delegates, drag n drop enabled and selection enabled. This is designed to easily change the behavior of the TableWidget. The following UML diagramm illustrates how it is designed : Another powerful feature of the TableWidget is tooltips. In your models, you can choose to display various pieces of information, with multi-line support (which is not possible with the setText function). By default, whenever a click happend on the TableWidget (except in the header row) leads to an event (TableClickEvent) propagation. You can catch these events implementing TableClickHandler. You can also decide that a specific column must not emit events. This is achieved by calling addColumnNotToEmitClick in TableProfile. ButtonMenu
InputLast but not least, the library provides a simple and fast way to check inputs (in a form for instance) with the DocdokuLineEdit class. Basicly, DocdokuLineEdit just extends TextBox and uses an instance of DocdokuChecker to determine if the input is valid or not. When the input status changes, observers are notified via the onInputStateChange method. You can provide your own checker by implementing DocdokuChecker, and listen for changes by calling addListener with an instance of DocdokuLineEditListener. You can find many uses of these widgets in DocDoku, just browse the sources ! |
You can listen to a spin box value change in setting a SpinBoxListener. Example :
This widget is a simple button which displays a popup menu when it is clicked. The popup menu contains MenuItem. You can create your own widgets implementing this interface and sublcassing Widget, but a more convenient way is to use AbstractMenuItem. AbstractMenuItem uses GWT Command to perform actions when the item is activated. The way an item is activated must be specified in your subclasses. This is done by calling activate. You can specify the behavior of your item when the Command is about to be executed by overriding beforeCommandCall. If you returns false in this method the command call will be canceled. You can also change the behavior after a command call, by overriding afterCommandCall. The API includes a default LabelMenuItem. Here is a simplified UML class diagram of the ButtonMenu widget :