Search in sources :

Example 1 with WidgetFactory

use of org.wicketstuff.dashboard.WidgetFactory in project openmeetings by apache.

the class WebSession method initDashboard.

private void initDashboard() {
    DashboardContext dashboardContext = getDashboardContext();
    dashboard = (UserDashboard) dashboardContext.getDashboardPersister().load();
    boolean existMyRoomWidget = false, existRssWidget = false, existAdminWidget = false;
    boolean showMyRoomConfValue = cfgDao.getBool(CONFIG_MYROOMS_ENABLED, true) && cfgDao.getBool(CONFIG_DASHBOARD_SHOW_MYROOMS, false);
    boolean showRssConfValue = cfgDao.getBool(CONFIG_DASHBOARD_SHOW_RSS, false);
    boolean showAdminWidget = getRights().contains(User.Right.Admin);
    boolean save = false;
    WidgetFactory widgetFactory = dashboardContext.getWidgetFactory();
    if (dashboard == null) {
        dashboard = new UserDashboard("default", "Default");
        dashboard.addWidget(widgetFactory.createWidget(new WelcomeWidgetDescriptor()));
        dashboard.addWidget(widgetFactory.createWidget(new StartWidgetDescriptor()));
        if (showMyRoomConfValue) {
            dashboard.addWidget(widgetFactory.createWidget(new MyRoomsWidgetDescriptor()));
        }
        if (showRssConfValue) {
            dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
        }
        if (showAdminWidget) {
            dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
        }
        save = true;
    } else {
        for (Iterator<Widget> iter = dashboard.getWidgets().iterator(); iter.hasNext(); ) {
            Widget w = iter.next();
            // PrivateRoomWidget is stored in the profile of user. Now, Show_MyRooms_key is disable.
            if (w.getClass().equals(MyRoomsWidget.class)) {
                existMyRoomWidget = true;
                if (!showMyRoomConfValue) {
                    iter.remove();
                }
            } else if (w.getClass().equals(RssWidget.class)) {
                // RssWidget is stored in the profile of user. Now, Show_RSS_Key is disable.
                existRssWidget = true;
                if (!showRssConfValue) {
                    iter.remove();
                }
            } else if (w.getClass().equals(AdminWidget.class)) {
                // AdminWidget is stored in the profile of user. check if user is admin.
                existAdminWidget = true;
                if (!showAdminWidget) {
                    iter.remove();
                }
            } else {
                w.init();
            }
        }
        // PrivateRoomWidget was deleted from profile and now it's enabled. It's added again to dashboard.
        if (!existMyRoomWidget && showMyRoomConfValue && !dashboard.isWidgetMyRoomsDeleted()) {
            dashboard.addWidget(widgetFactory.createWidget(new MyRoomsWidgetDescriptor()));
            save = true;
        }
        // RssWidget was deleted from profile and now it's enabled. It's added again to dashboard.
        if (!existRssWidget && showRssConfValue && !dashboard.isWidgetRssDeleted()) {
            dashboard.addWidget(widgetFactory.createWidget(new RssWidgetDescriptor()));
            save = true;
        }
        // user had no admin rights, now he/she has.
        if (!existAdminWidget && showAdminWidget && !dashboard.isWidgetAdminDeleted()) {
            dashboard.addWidget(widgetFactory.createWidget(new AdminWidgetDescriptor()));
            save = true;
        }
    }
    if (save) {
        dashboardContext.getDashboardPersister().save(dashboard);
    }
}
Also used : Application.getDashboardContext(org.apache.openmeetings.web.app.Application.getDashboardContext) DashboardContext(org.wicketstuff.dashboard.web.DashboardContext) StartWidgetDescriptor(org.apache.openmeetings.web.user.dashboard.StartWidgetDescriptor) UserDashboard(org.apache.openmeetings.web.util.UserDashboard) WelcomeWidgetDescriptor(org.apache.openmeetings.web.user.dashboard.WelcomeWidgetDescriptor) WidgetFactory(org.wicketstuff.dashboard.WidgetFactory) AdminWidgetDescriptor(org.apache.openmeetings.web.user.dashboard.admin.AdminWidgetDescriptor) RssWidgetDescriptor(org.apache.openmeetings.web.user.dashboard.RssWidgetDescriptor) Widget(org.wicketstuff.dashboard.Widget) MyRoomsWidget(org.apache.openmeetings.web.user.dashboard.MyRoomsWidget) AdminWidget(org.apache.openmeetings.web.user.dashboard.admin.AdminWidget) RssWidget(org.apache.openmeetings.web.user.dashboard.RssWidget) RssWidget(org.apache.openmeetings.web.user.dashboard.RssWidget) MyRoomsWidgetDescriptor(org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor)

Aggregations

Application.getDashboardContext (org.apache.openmeetings.web.app.Application.getDashboardContext)1 MyRoomsWidget (org.apache.openmeetings.web.user.dashboard.MyRoomsWidget)1 MyRoomsWidgetDescriptor (org.apache.openmeetings.web.user.dashboard.MyRoomsWidgetDescriptor)1 RssWidget (org.apache.openmeetings.web.user.dashboard.RssWidget)1 RssWidgetDescriptor (org.apache.openmeetings.web.user.dashboard.RssWidgetDescriptor)1 StartWidgetDescriptor (org.apache.openmeetings.web.user.dashboard.StartWidgetDescriptor)1 WelcomeWidgetDescriptor (org.apache.openmeetings.web.user.dashboard.WelcomeWidgetDescriptor)1 AdminWidget (org.apache.openmeetings.web.user.dashboard.admin.AdminWidget)1 AdminWidgetDescriptor (org.apache.openmeetings.web.user.dashboard.admin.AdminWidgetDescriptor)1 UserDashboard (org.apache.openmeetings.web.util.UserDashboard)1 Widget (org.wicketstuff.dashboard.Widget)1 WidgetFactory (org.wicketstuff.dashboard.WidgetFactory)1 DashboardContext (org.wicketstuff.dashboard.web.DashboardContext)1