Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg
1. Many of the MyGWT widgets do not have public constructors and use style bits in the same manner as SWT.
MyGWTWidget w = new MyGWTWidget();
w.setParams(params);
w.setModel(model);
w.addItem(myItem);
// etc
rootPanel.add(w);
MyGWTWidget w = MyGWTWidgetImpl.create(Object props, Object model);
rootPanel.add(w);
darrell wrote:1. Many of the MyGWT widgets do not have public constructors and use style bits in the same manner as SWT.
darrell wrote:2. Many of the MyGWT widgets use public members without getters and setters.
darrell wrote:I am not familiar with your product but thought I would initiate a conversation to see if there are things that could be done on either side to add support for MyGWT widgets.
darrell wrote:Thanks for the information. I think it would be a win for MyGWT if it's widgets could be used in your product. The changes needed would be easy to implement. I just need to figure out if this is what the MyGWT users want and if they are OK with the API changes as this would require them to refactor their code. This is where GWT shines as we are in Java and it is easy to find the code that needs to be updated.
darrell wrote:When I first started creating the MyGWT widgets I was not lazily rendering the widgets. So the SWT style bits worked well as it allowed the widget to receive configuration details before the UI was rendered. Now, the widgets are rendered lazily, which will allow the widget to be configured prior to the DOM elements are created. The public fields can be made private and getters and setters added. I think the changes would be good idea even without taking GWT Designer consideration as it is how GWT behaves and more in line with the Java bean model.
darrell wrote:I still believe there will need to be some custom support for some of the MyGWT to allow specialized design time behavior. We do not have to worry about that now as the API changes will need to come first and the API needs to become stable.
darrell wrote:In the short term, I will get familiar with GWT Designer and see how it works with the existing GWT widgets. I will also poll the current MyGWT developers to see if and when the API should be changed.
Eric Clayberg wrote:Keep in mind that GWT Designer only requires there to be a default constructor. It doesn't care about additional constructors, so you could leave those in place.
package com.mycompany.project.client;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;
public class MyButton extends Widget implements HasText {
public MyButton() {
setElement(DOM.createDiv());
DOM.setStyleAttribute(getElement(), "backgroundColor", "#000");
DOM.setStyleAttribute(getElement(), "color", "#FFF");
}
public MyButton(String text) {
this();
setText(text);
}
/* @Override */
public String getText() {
return DOM.getInnerText(getElement());
}
/* @Override */
public void setText(String text) {
DOM.setInnerText(getElement(), (text == null) ? "" : text);
}
}
n the short term, I will get familiar with GWT Designer and see how it works with the existing GWT widgets.
package code.google.com.gwt.iuilibrary.ui;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
public class Screen extends ComplexPanel {
public Screen() {
setElement(DOM.createDiv());
setStyleName("iui-Screeen");
}
/* @Override */
public void add(Widget w) {
super.add(w, getElement());
}
/* @Override */
public void insert(Widget w, int beforeIndex) {
super.insert(w, getElement(), beforeIndex, true);
}
}
package code.google.com.project.iui.client;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;
public class List extends ComplexPanel {
class UnselectTaskTimer extends Timer {
}
private boolean selected;
private ListItem selectedItem;
private Timer unselectTaskTimer;
public List() {
setElement(DOM.createElement("ul"));
}
/* @Override */
public void add(Widget w) {
}
/* @Override */
public void clear() {
}
public void clearItems() {
}
private ListItem findItem(Element eventSource) {
}
public String getID() {
}
public ListItem getSelectedItem() {
}
/* @Override */
public void insert(Widget w, int beforeIndex) {
}
public boolean isSelected() {
}
/* @Override */
public void onBrowserEvent(Event event) {
}
/* @Override */
protected void onDetach() {
}
public void setID(String id) {
}
public void setSelected(boolean selected) {
}
public void setSelectedItem(ListItem item) {
}
}
peterblazejewicz wrote:wow, that's new feature I was wating for, thanks!, I quickly tested and it works:
Eric Clayberg wrote:peterblazejewicz wrote:wow, that's new feature I was wating for, thanks!, I quickly tested and it works:
New feature?GWT Designer has always supported that (e.g., multiple constructors for a widget as long as there is a default constructor present).
eclipse.buildId=M20070921-1145
[...]
Error
Sat Jan 19 02:15:52 CET 2008
Designer internal error [6.5.1.20080117125226]: Only one constructor supported. Mark correct one with @wbp.parser.constructor JavaDoc tag.
java.lang.IllegalArgumentException: Only one constructor supported. Mark correct one with @wbp.parser.constructor JavaDoc tag.
at com.swtdesigner.gwt.model.widgets.panel.TopLevelUtils.getSingleConstructor(TopLevelUtils.java:173)
at com.swtdesigner.gwt.model.widgets.panel.ThisCompositeInfo.getMethodDeclaration(ThisCompositeInfo.java:169)
at com.swtdesigner.model.parser.JavaInfoParser.isParentAndChild(JavaInfoParser.java:1021)
at com.swtdesigner.model.parser.JavaInfoParser.findParentFor(JavaInfoParser.java:955)
at com.swtdesigner.model.parser.JavaInfoParser.getRootNodes(JavaInfoParser.java:526)
at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:1141)
[...]
/**
* @wbp.parser.constructor
*/
public LogReaderFilter() {
this(LogReaderFilter.INFO, "info");
}
public LogReaderFilter(int type) {
this(type, null);
}
public LogReaderFilter(int type, String text) {
checkBox = new CheckBox();
initWidget(checkBox);
setStyleName("yui-log-filtergrp");
setType(type);
setText((text == null) ? "Checkbox" : text);
}
Eric Clayberg wrote:Keep in mind that GWT Designer only requires there to be a default constructor. It doesn't care about additional constructors, so you could leave those in place.
The @wbp.parser.constructor is used to tell GWT Designer which constructor to edit in the deisgn view.
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
public class Test extends Composite {
public Test() {
//initWidget(new Label());
initWidget(this);
}
public Test(String s){
}
}
package com.mycompany.project.client;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
public class MyTooltip extends Composite {
/**
*
*/
public MyTooltip() {
this("Tooltip");
}
/**
* @param text
*/
public MyTooltip(String text) {
this(text, false);
}
/**
* @wbp.parser.constructor
* @param text
* @param wrap
*/
public MyTooltip(String text, boolean wrap) {
final Label label = new Label("test");
label.setWordWrap(wrap);
initWidget(label);
}
}
package com.mycompany.project.client;
import com.google.gwt.user.client.ui.Composite;
import com.mycompany.project.client.MyTooltip;
public class MyTootlipComposite extends Composite {
public MyTootlipComposite() {
final MyTooltip myTooltip = new MyTooltip("Tooltip", false);
initWidget(myTooltip);
}
}
@wbp.parser.constructor
Users browsing this forum: No registered users and 3 guests