Hi,
thanks, i did something like you said.

On Wed, Jan 13, 2010 at 10:49 AM, Lukasz <[email protected]> wrote:

> HI,
>
> I'm doing something similar in my application - but instead of passing
> presenters through the event content, I'm only passing the widgets
> which should be shown in the main UI area. I've one central presenter
> (like e.g. AppPresenter) which listens to this event and if thrown
> reorganises the UI.
>
> Here's the code from the main presenter:
>
>                /*
>                 * Subscribing for the UIChangedEvent
>                 */
>                eventBus.addHandler(UIChangedEvent.TYPE, new
> UIChangedEventHandler()
> {
>
>                        @Override
>                        public void onUIChange(UIChangedEvent event) {
>                                reorganizeUI(event);
>                        }
>                });
>
>
>        /**
>         * Method which takes the given widget and places it as the main
> content
>         * (removing the old one)
>         *
>         * @param ui2Show
>         */
>        private void reorganizeUI(UIChangedEvent e) {
>                if (mainContent != null)
>                        dockLayout.remove(mainContent);
>                ScrollPanel sp = new ScrollPanel();
>                VerticalPanel wrapper = new VerticalPanel();
>                sp.add(wrapper);
>
>  wrapper.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
>                DecoratedTabPanel tab = new DecoratedTabPanel();
>                tab.setAnimationEnabled(true);
>                tab.add(e.getUi2Show(), e.getEventName());
>                wrapper.add(tab);
>                wrapper.add(e.getControls());
>                mainContent = sp;
>                tab.selectTab(0);
>                dockLayout.add(mainContent);
>                fadeEffect.setEffectElement(mainContent.getElement());
>                fadeEffect.play();
>        }
>
> HTH,
> Lukasz
>
> On 12 Jan., 15:42, mariyan nenchev <[email protected]> wrote:
> > Hi,
> >
> > i am having difficulties making my views to switch.
> > Here is my code:
> > Here is my hierarchy of presenters: AppPresenter, that contains
> > HeaderPresenter and BodyPresenter:
> >
> > public class AppPresenter extends
> > WidgetContainerPresenter<AppPresenter.Display> {
> >
> >     public interface Display extends WidgetContainerDisplay {
> >
> >     }
> >
> >     @Inject
> >     public AppPresenter(Display display, EventBus bus,HeaderPresenter
> > header,  BodyPresenter body) {
> >         super(display,bus, header, body);
> >     }
> >
> > }
> >
> > HeaderPresenter and BodyPresenter will never be changed.
> >
> > public class BodyPresenter extends
> > WidgetContainerPresenter<BodyPresenter.Display> {
> >
> >     public interface Display extends WidgetContainerDisplay {
> >
> >     }
> >
> >     @Inject
> >     public BodyPresenter(Display display, EventBus eventBus,
> > LeftMenuPresenter menu, ContentPresenter content) {
> >         super(display, eventBus, menu, content);
> >     }
> >
> > }
> >
> > BodyPresenter contains LeftMenuPresenter and ContentPresenter
> > And ContentPresenter must switch different presenters in it when
> something
> > is picked from the left menu(or some buttons in the header are clicked).
> >
> > public class ContentPresenter extends
> > WidgetContainerPresenter<ContentPresenter.Display> {
> >
> >     public interface Display extends WidgetContainerDisplay {
> >
> >     }
> >     private MyDefaultPresenter dPresenter;
> >
> >     @Inject
> >     public ContentPresenter(Display display, EventBus eventBus,
> > MyDefaultPresenter dPresenter) {
> >         super(display, eventBus, dPresenter);
> >         this.dPresenter =dPresenter;
> >
> >     }
> >
> >     @Override
> >     protected void onBind() {
> >         super.onBind();
> >
> registerHandler(eventBus.addHandler(PresenterChangedEvent.getType(),
> > new PresenterChangedHandler() {
> >             @Override
> >             public void onPresenterChanged(PresenterChangedEvent event) {
> >                 Debugger.log("receive PresenterChangedEvent");
> >
> > ContentPresenter.this.setCurrentPresenter((WidgetPresenter<?>)
> > event.getPresenter());
> >             }
> >         }));
> >     }
> >
> > }
> >
> > The PresenterChangedEvent is fired onClick event from the menu or header
> > links/buttons, but nothing happens.
> > And i had to pass my other presenters in the Header or LeftMenuPresenter,
> > which is not quite right, they should all be passed to the
> ContentPresenter
> > and somehow swich on event.
> >
> > Any ideas?
> >
> > Regards.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
>
>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to