GXT Feature Request: automatic assign variable to CardLayout

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

GXT Feature Request: automatic assign variable to CardLayout

Postby bunyawat » Sat Oct 10, 2009 6:18 pm

When I assign "com.extjs.gxt.ui.client.widget.layout.CardLayout" to "com.extjs.gxt.ui.client.widget.CardPanel"
It give me this snippet.

private void initComponents() {
initComponent(getCardPanel_1());
getCardPanel_1().setLayout(new CardLayout());
getCardPanel_1().add(getLogInComposite_1());
getCardPanel_1().add(getMainPageComposite_1());
}

It should auto generate variable for the CardLayout first in important properties window.
Since I need this variable to swap the card latter.

private void initComponents() {
initComponent(getCardPanel_1());
getCardPanel_1().setLayout(getCardLayOut());
getCardPanel_1().add(getLogInComposite_1());
getCardPanel_1().add(getMainPageComposite_1());
}

CardLayout getCardLayOut(){
if( cardLayout == null ){
cardLayout = new CardLayout();
}
return cardLayout;
}

private class LogInCompositeBtnNewButtonSelectionListener extends SelectionListener<ButtonEvent> {
public void componentSelected(final ButtonEvent ce) {
getCardLayOut().setActiveItem(getMainPageComposite_1());
}
}
Attachments
CARD_LAYOUT.JPG
CARD_LAYOUT.JPG (41.56 KiB) Viewed 388 times
bunyawat
 
Posts: 21
Joined: Thu Aug 06, 2009 6:52 pm

Re: GXT Feature Request: automatic assign variable to CardLayout

Postby Eric Clayberg » Mon Oct 12, 2009 7:51 am

You don't need to assign CardLayout to CardPanel because it already uses that layout.

You can also directly set the active item for the CardPanel itself...

Code: Select all
private class LogInCompositeBtnNewButtonSelectionListener extends SelectionListener<ButtonEvent> {
    public void componentSelected(final ButtonEvent ce) {
    getCardPanel_1().setActiveItem(getMainPageComposite_1());
}
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: GXT Feature Request: automatic assign variable to CardLayout

Postby bunyawat » Mon Oct 12, 2009 8:07 pm

Eric Clayberg wrote:You don't need to assign CardLayout to CardPanel because it already uses that layout.

You can also directly set the active item for the CardPanel itself...

Code: Select all
private class LogInCompositeBtnNewButtonSelectionListener extends SelectionListener<ButtonEvent> {
    public void componentSelected(final ButtonEvent ce) {
    getCardPanel_1().setActiveItem(getMainPageComposite_1());
}



I have try this before. It does not work.
In GXT 's example code, they use "CardLayout.setActiveItem()".
That why I asking for this feature.

Anyway I try this and it wrok for me.
((CardLayout)getCardPanel_1().getLayout()).setActiveItem(getMainPageComposite_1());
bunyawat
 
Posts: 21
Joined: Thu Aug 06, 2009 6:52 pm

Re: GXT Feature Request: automatic assign variable to CardLayout

Postby Eric Clayberg » Tue Oct 13, 2009 5:21 am

bunyawat wrote:I have try this before. It does not work.

I just tried it, and it works just fine.

There is no difference between:

Code: Select all
getCardPanel_1().setActiveItem()

and:

Code: Select all
(CardLayout)getCardPanel_1().getLayout()).setActiveItem()

Look at the code for CardPanel.setActiveItem(), and you will see why...

Code: Select all
  /**
   * Sets the active (visible) item in the layout.
   *
   * @param component the active widget
   */
  public void setActiveItem(Component component) {
    layout.setActiveItem(component);
  }
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