GWT Designer with MVP

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

GWT Designer with MVP

Postby bobpardoe » Thu Mar 04, 2010 5:42 am

I am trying to evaluate the latest GWT Designer 7.3

I have a prototype project that has been hand coded. It follows an MVP pattern so that the 'view' element has the ui widgets and the 'presenter' has all the methods \ event handlers etc etc.

The issue that I have is that when I choose to edit the 'view' with the GWT Designer, it stops as it cannot find the entry point.

The issue is that (of course) as this is the view, it wont have one. The entry point is in the 'presenter' file.

Is there any way around this issue ?
bobpardoe
 
Posts: 1
Joined: Thu Mar 04, 2010 5:34 am

Re: GWT Designer with MVP

Postby Eric Clayberg » Thu Mar 04, 2010 10:30 am

GWT Designer is designed to edit any of the known GWT UI types like EntryPoints, Composites, PopupPanels and DialogBoxes.

If you provide a complete example of what you are trying to do, we might be able to make some suggestions.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: GWT Designer with MVP

Postby lowecg » Wed Mar 10, 2010 3:21 pm

Hi Eric,

The MVP pattern typically breaks a panel down into a view and a presenter where an interface defines the boundary between the two classes. For example, the following presenter has a simple view containing a text widget and a button:

Code: Select all
public class GreetingPresenter extends WidgetPresenter {

public interface Display extends WidgetDisplay {
  public HasValue getName();

  public HasClickHandlers getSend();
}

@Inject
public GreetingPresenter(final Display display,
                final EventBus eventBus) {
  super(display, eventBus);
 
  bind();
}


@Override
protected void onBind() {
  // 'display' is a final global field containing the Display passed into the constructor.
  display.getSend().addClickHandler(new ClickHandler() {
   public void onClick(final ClickEvent event) {
    doSend();
   }
  });
}


protected void onSend() {
    // do something here
}

public void refreshDisplay() {
  display.getName().setValue("some value");
}

}


Code: Select all
public class GreetingView implements GreetingPresenter.Display {

private final TextBox name;
private final Button sendButton;

public GreetingView() {
  final FlowPanel panel = new FlowPanel();

  name = new TextBox();
  panel.add(name);

  sendButton = new Button("Go");
  panel.add(sendButton);
 
  // Add the nameField and sendButton to the RootPanel
  // Use RootPanel.get() to get the entire body element
  RootPanel.get("nameFieldContainer").add(name);
  RootPanel.get("sendButtonContainer").add(sendButton);
}

public HasValue getName() {
  return name;
}

public HasClickHandlers getSend() {
  return sendButton;
}

public Widget asWidget() {
  return panel;
}

}


An Eclipse project for a very basic MVP application is available from here.

Particular points of interest are in the presenter's refreshDisplay (value pushed to the view) and the onBind method where a button event handler is registered. Additionally, the view and presenter instances are constructed and associated using Google Injector (GIN). Is GWT Designer able to handle code where a panel has been broken out into view construction and associated event handling + other business logic in this way?

Best regards,

Chris.
lowecg
 
Posts: 1
Joined: Wed Mar 10, 2010 12:50 pm

Re: GWT Designer with MVP

Postby DaveL » Thu Mar 11, 2010 7:08 am

A small compromise is to extend Composite in your display classes. GWT Designer would be limited in scope to a layout tool for displays. I don't think a tool can cope with the "interfaces of interfaces" used in the presenters.
DaveL
 
Posts: 1
Joined: Thu Mar 11, 2010 6:58 am

Re: GWT Designer with MVP

Postby Eric Clayberg » Thu Mar 11, 2010 12:51 pm

lowecg wrote: Is GWT Designer able to handle code where a panel has been broken out into view construction and associated event handling + other business logic in this way?

The basic answer to your question is, no. GWT Designer is designed to edit all of the normal GWT UI classes and their associated common patterns. It knows nothing about this specific framework you are using or its patterns for handling events and other constructs. That said, GWT Designer can edit the GreetingView class as shown below (although I don't understand why it is adding widgets first to the FlowPanel and then again to the RootPanels).

GreetingView.jpg
GreetingView.jpg (49.44 KiB) Viewed 848 times
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest