Package org.eurekastreams.web.client.events

Examples of org.eurekastreams.web.client.events.StartPageTabReadyEvent


                        }

                        // The start page tabs are ready. Let anyone who cares know.
                        for (StartPageTab tab : startTabs)
                        {
                            Session.getInstance().getEventBus().notifyObservers(new StartPageTabReadyEvent(tab));
                        }

                        // Fetch all the gadget def metadata in 1 request.
                        List<GadgetDefinition> gadgetDefList = new ArrayList<GadgetDefinition>();
                        List<Long> gadgetDefIds = new ArrayList<Long>();
                        for (GadgetDefinition gDef : gadgetDefs)
                        {
                            if (!gadgetDefIds.contains(gDef.getId()))
                            {
                                gadgetDefList.add(gDef);
                                gadgetDefIds.add(gDef.getId());
                            }
                        }

                        GadgetMetaDataFetcher fetcher = new GadgetMetaDataFetcher(gadgetDefList);
                        fetcher.fetchMetaData();

                        thisBuffered.addStyleName(StaticResourceBundle.INSTANCE.coreCss().portalBoundary());

                        Session.getInstance().getEventBus().addObserver(ThemeChangedEvent.getEvent(),
                                new Observer<ThemeChangedEvent>()
                                {
                                    public void update(final ThemeChangedEvent arg1)
                                    {
                                        Session.getInstance().getEventBus().notifyObservers(
                                                new UpdateHistoryEvent(new CreateUrlRequest(Page.START)));
                                        Location.reload();
                                    }
                                });

                        HashMap<String, String> params = new HashMap<String, String>();
                        params.put("tab", Long.toString(tabDomainObjects.get(0).getId()));
                        params.put("galleryTab", "Apps");
                        params.put("listId", "gadgets");
                        settings.setTargetHistoryToken(Session.getInstance().generateUrl(
                                new CreateUrlRequest(Page.GALLERY, params)));

                        // Respond to history changes.
                        Session.getInstance().getEventBus().addObserver(UpdatedHistoryParametersEvent.class,
                                new Observer<UpdatedHistoryParametersEvent>()
                                {
                                    public void update(final UpdatedHistoryParametersEvent event)
                                    {
                                        // Note: parameters do not need to be decoded here -that's already done
                                        // by
                                        // HistoryHandler before it published the event

                                        if (event.getParameters().get("tab")
                                        // line break
                                        != null)
                                        {
                                            HashMap<String, String> params = new HashMap<String, String>();
                                            params.put("tab", event.getParameters().get("tab"));

                                            params.put("galleryTab", "Apps");
                                            settings.setTargetHistoryToken(Session.getInstance().generateUrl(
                                                    new CreateUrlRequest(Page.GALLERY, params)));
                                        }

                                        if (event.getParameters().get("action").equals("addGadget"))
                                        {
                                            String prefs = event.getParameters().get("prefs");
                                            String url = event.getParameters().get("url");

                                            // Clear current action
                                            event.getParameters().put("action", "");
                                            event.getParameters().put("url", "");
                                            event.getParameters().put("prefs", "");
                                            EventBus.getInstance().notifyObservers(
                                                    new UpdatedHistoryParametersEvent(event.getParameters(), false));

                                            GadgetModel.getInstance().insert(
                                                    new AddGadgetToStartPageRequest(url, tabsResponse.get(0).getId(),
                                                            prefs));
                                        }
                                        else if (event.getParameters().get("action").equals("setTheme"))
                                        {
                                            // Clear current action
                                            EventBus.getInstance().notifyObservers(
                                                    new UpdatedHistoryParametersEvent(event.getParameters(), false));
                                            String url = event.getParameters().get("url");
                                            ThemeModel.getInstance().set(url);
                                        }
                                    }
                                }, true);

                        // Respond to new tabs.
                        Session.getInstance().getEventBus().addObserver(InsertedStartTabResponseEvent.class,
                                new Observer<InsertedStartTabResponseEvent>()
                                {
                                    public void update(final InsertedStartTabResponseEvent event)
                                    {
                                        Session.getInstance().getEventBus()
                                                .notifyObservers(new HideNotificationEvent());

                                        newTab.getTextBox().setVisible(false);
                                        newTab.getLabel().setVisible(true);

                                        StartPageTab tab = new StartPageTab(event.getResponse());
                                        tabs.insertTab(tab, event.getResponse().getTabIndex());

                                        // If more than 8 tabs (the new tab counts as 1) disable the new tab.
                                        if (tabs.getSize() >= Person.TAB_LIMIT + 1)
                                        {
                                            tabs.removeTab(newTab.getIdentifier());
                                        }

                                        // If 2 tabs are present (the new tab counts as 1) re-enable the remove.
                                        if (tabs.getSize() == 3)
                                        {
                                            ((StartPageTab) tabs.getTab(0)).enableRemove();
                                        }

                                        // The start page tab is ready.
                                        Session.getInstance().getEventBus().notifyObservers(
                                                new StartPageTabReadyEvent(tab));

                                        Session.getInstance().getEventBus().notifyObservers(
                                                new UpdateHistoryEvent(new CreateUrlRequest("tab", tab.getIdentifier(),
                                                        true)));
                                    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.web.client.events.StartPageTabReadyEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.