EntryPoint module must be base class?

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

EntryPoint module must be base class?

Postby peterblazejewicz » Mon Oct 01, 2007 3:27 pm

Hello,

Is there requirement for Designer/Editor that entry point module defined in .gwt.xml entry point tag should be a base class which implements EntryPoint?

Code: Select all
public class MyClass impements EntryPoint{
    public void onModuleLoad(){
    }
}


I cannot use:
Code: Select all
public class MyClass implements EntryPoint{
    public void onModuleLoad(){
    }
}

and:
Code: Select all
public class MyEntryPoint extends MyClass{
}


regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Postby Konstantin.Scheglov » Mon Oct 01, 2007 11:03 pm

This combination of classes works.

Code: Select all
public class MyAbstractEntryPoint implements EntryPoint{
    public void onModuleLoad(){
    }
}


Code: Select all
public class MyEntryPoint extends MyAbstractEntryPoint {
   public void onModuleLoad() {
   }
}
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk

Postby peterblazejewicz » Mon Oct 01, 2007 11:49 pm

hi Konstantin,
thanks for doing tests, I'll test on my side later and let you know,
The purpose of such design is to put some common features of an appliation into base class (these will look kind of JSR-296 swing application framework now),
regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: EntryPoint module must be base class?

Postby Eric Clayberg » Tue Oct 02, 2007 3:18 am

peterblazejewicz wrote:Is there requirement for Designer/Editor that entry point module defined in .gwt.xml entry point tag should be a base class which implements EntryPoint?

Please give the latest build a try.

The "implements EntryPoint" requirement has been removed.
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

Postby peterblazejewicz » Tue Oct 02, 2007 11:15 am

hi all,

@Konstantin,
thanks, it really works with current build,
Konstantin.Scheglov wrote:This combination of classes works.

Code: Select all
public class MyAbstractEntryPoint implements EntryPoint{
    public void onModuleLoad(){
    }
}

Code: Select all
public class MyEntryPoint extends MyAbstractEntryPoint {
   public void onModuleLoad() {
   }
}


Code: Select all
package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class MyAbstractEntryPoint implements EntryPoint {
   // will be used internally
   private RootPanel rootPanel;

   public void onModuleLoad() {
      rootPanel = RootPanel.get();
   }

}

Code: Select all
package com.mycompany.project.client;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TestApplication extends MyAbstractEntryPoint {

   private Button button;
   private RootPanel rootPanel;

   /*@Override*/
   public void onModuleLoad() {
      super.onModuleLoad();
      // generated by Designer
      rootPanel = RootPanel.get();
      button = new Button();
      rootPanel.add(button, 5, 5);
      button.setText("Click me!");

   }
}


@Eric
thanks!,
will install update and report you back,

regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Re: EntryPoint module must be base class?

Postby peterblazejewicz » Tue Oct 02, 2007 4:11 pm

Eric Clayberg wrote:
peterblazejewicz wrote:Is there requirement for Designer/Editor that entry point module defined in .gwt.xml entry point tag should be a base class which implements EntryPoint?

Please give the latest build a try.

The "implements EntryPoint" requirement has been removed.

hi Eric,
Its working but in the way Konstantin hinted. That is there should be overriden (from inherited class) onModuleLoad where designer seeks for RootPanel instance.
If RootPanel reference is put into different method called from inherited class onModuleLoaded Design view engine get it rendered correct on first attempt but after that no content is drawn:
Code: Select all
   /* @Override */
   protected void startup() {
      System.out.println("startup() in " + GWT.getTypeName(this));
      RootPanel rootPanel = RootPanel.get();
      welcomeScreen = new WelcomeScreen();
      rootPanel.add(welcomeScreen);
   }


but guys that is really not an issue and I understand you had to decide where Design engine should look into code insertion point in order to render cotnent and thus "onModuleLoad" in module-referenced class should be either defined or overriden. I could live with that,

I've ended with something:
Code: Select all
package com.mycompany.project.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.HistoryListener;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.WindowCloseListener;
import com.google.gwt.user.client.ui.Widget;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MyApplication extends Application implements HistoryListener {
   private Widget welcomeScreen;

   /* @Override */
   protected void initialize() {
      System.out.println("initialize() in " + GWT.getTypeName(this));
      Window.addWindowCloseListener(new WindowCloseListener() {
         /* @Override */
         public void onWindowClosed() {
            exit(null);
         }

         /* @Override */
         public String onWindowClosing() {
            return "Do you really want to exit?";
         }
      });
      History.addHistoryListener(this);
   }

   /* @Override */
   protected void startup() {
      System.out.println("startup() in " + GWT.getTypeName(this));
      welcomeScreen = new WelcomeScreen();
   }

   /* @Override */
   protected void ready() {
      System.out.println("ready() in " + GWT.getTypeName(this));
      String token = History.getToken();
      if (token == null || token.length() == 0) {
         show(welcomeScreen);
      } else {
         onHistoryChanged(token);
      }

   }

   /*
    * last chance to persist data on client
    */
   /* @Override */
   protected void shutdown() {
      System.out.println("shutdown() in " + GWT.getTypeName(this));
   }

   /* @Override */
   public void onHistoryChanged(String historyToken) {

   }

}

similiar to Application solution from JSR-296 which beatifully fits currently into project I'm working (using GWT Designer of course ;) ),

thanks,
regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Postby Konstantin.Scheglov » Tue Oct 02, 2007 10:21 pm

Hm... Application Framework... ;-)

I've added support for @wbp.parser.EntryPoint to mark such special methods.

So, this can be parsed now:

Code: Select all
public class MyApplication {
   /**
    * @wbp.parser.entryPoint
    */
   protected void startup() {
      RootPanel rootPanel = RootPanel.get();
      rootPanel.add(new Button("aaaaaaaaaaaaa"));
   }
}
Konstantin.Scheglov
Moderator
 
Posts: 186
Joined: Tue Oct 18, 2005 8:11 pm
Location: Russian Federation, Lipetsk

Postby peterblazejewicz » Wed Oct 03, 2007 12:33 pm

Hello Konstantin,
I've got it working with today build,

e.g. Application base class implements entry point:
Code: Select all
public abstract class Application implements EntryPoint {
...
}


and on its onModuleLoad() it starts incremental startup (initialize>startup>ready),
concrete class could look like:
Code: Select all
package com.mycompany.project.client;

import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class MyApplication extends Application {

   private WelcomeScreen welcomeScreen;

   /* @Override */
   protected void initialize() {
   }

   /**
    * @wbp.parser.entryPoint
    */
   /* @Override */
   protected void startup() {
      RootPanel rootPanel = RootPanel.get();

      welcomeScreen = new WelcomeScreen();
      welcomeScreen.setVisible(false);
      rootPanel.add(welcomeScreen);
      welcomeScreen.setSize("303px", "109px");

   }

   /* @Override */
   protected void ready() {
      // this call is deffered
      welcomeScreen.setVisible(true);
   }

}


I'm quite fine with that :)
regards,
Peter
Peter Blazejewicz
GWT groups profile
peterblazejewicz
 
Posts: 153
Joined: Fri Jul 27, 2007 7:09 pm
Location: Europe/Poland/Warsaw

Postby Eric Clayberg » Wed Oct 03, 2007 7:02 pm

peterblazejewicz wrote:I've got it working with today build

Excellent! Good news.

peterblazejewicz wrote:I'm quite fine with that

Even better news. ;-)
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 3 guests