Package at.riemers.zero.widgets

Examples of at.riemers.zero.widgets.HtmlTableWidget


            log.debug(userList.size());

            view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "user_current_users"));


            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("CURRENTUSERLIST");
            if (userListComponent == null) {
                DefaultTableModelColumn usernameColumn = new DefaultTableModelColumn("base.user.table.username", "user.username");
                usernameColumn.setStyleClass("emphasize");
                /* usernameColumn.addClickListener(new TableClickListener() {
                public void fireClicked(TableClickEvent event) {
                log.debug("fireClicked: " + event.getWidget().getModel().getData(event.getColumn(), event.getRow()));
                }
                });*/
                DefaultTableModel<UserSession> model = new DefaultTableModel<UserSession>(userList, getMessages(), request.getLocale());

                model.setSelectable(true);
                model.addColumn(usernameColumn);
                model.addColumn(new DefaultTableModelColumn("base.user.table.firstname", "user.person.firstname"));
                model.addColumn(new DefaultTableModelColumn("base.user.table.lastname", "user.person.lastname"));
                model.addColumn(new DefaultTableModelColumn("base.user.table.email", "user.person.email"));
                model.addColumn(new DefaultTableModelColumn("base.user.table.phone", "user.person.phone"));
                model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "user.userGroup.groupKey"));
                model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "session.lastRequest"));
                model.setSort(1);
                userListComponent = new HtmlTableWidget("CURRENTUSERLIST", model, request.getLocale());

                getWidgetManager(session).register(userListComponent);
            } else {
                ((DefaultTableModel<UserSession>) userListComponent.getModel()).setCollection(userList);
            }

            view.addWidget(userListComponent);           

        }
View Full Code Here


        logFunction("user-kick");

        if (user.checkAuthorisation(UserModule.AUTH_CURRENT_USERS)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("CURRENTUSERLIST");

            for ( String selectedRow : selected.getSelected().keySet()) {
                log.debug(selectedRow);
                UserSession selectedSession = ((DefaultTableModel<UserSession>) userListComponent.getModel()).get(Integer.parseInt(selectedRow));
                if (selectedSession != null) {
                    selectedSession.getSession().expireNow();
                }
            }
        }
View Full Code Here

        User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

        if (user.checkAuthorisation(UserModule.AUTH_CURRENT_USERS)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("CURRENTUSERLIST");

            List<UserSession> sendMessageSessions = new ArrayList();
            for ( String selectedRow : selected.getSelected().keySet()) {
                log.debug(selectedRow);
                UserSession selectedSession = ((DefaultTableModel<UserSession>) userListComponent.getModel()).get(Integer.parseInt(selectedRow));
                if (selectedSession != null) {
                    //log.debug(selectedSession.getSession().getSessionId());
                    //texts.put(selectedSession.getSession().getSessionId(),selectedSession.getSession().getSessionId());
                    sendMessageSessions.add(selectedSession);
                }
View Full Code Here

        ZeroView view = new ZeroView(getMessages(), request.getLocale());


        if (checkAuthorisation(SystemModule.AUTH_RESOURCE_EDIT)) {

            HtmlTableWidget widget = (HtmlTableWidget) getWidgetManager(session).getWidget("RESOURCELIST");
            if (widget == null) {
                DefaultTableModelColumn dc1 = new DefaultTableModelColumn("base.resourcemessages.language1", "");

                dc1.setEditable(true);
                dc1.setRenderer(new LanguageRenderer("EN"));

                DefaultTableModelColumn dc2 = new DefaultTableModelColumn("base.resourcemessages.language2", "");

                dc2.setEditable(true);
                dc2.setRenderer(new LanguageRenderer("DE"));



                DefaultTableModel<ResourceMessage> model = new DefaultTableModel(resourceMessageDao.findAll(), getMessages(), request.getLocale(),
                        new DefaultTableModelColumn("base.resourcemessages.code", "code"),
                        dc1,
                        dc2);

                model.setInlineEditable(true);

                model.setEditListener(new TableEditListener() {

                    public void fireEdited(TableEditEvent event) {
                        DefaultTableModel<ResourceMessage> model = (DefaultTableModel<ResourceMessage>) event.getWidget().getModel();
                        ResourceMessage resourceMessage = model.get(event.getRow());
                        ResourceMessage resourceMessage2 = resourceMessageDao.findById(resourceMessage.getCode());
                        String language = ((LanguageRenderer) ((DefaultTableModel<ResourceMessage>) event.getWidget().getModel()).getColumns().get(event.getColumn()).getRenderer()).getLanguage();
                        resourceMessage.getMessage().getTexts().put(language, event.getNewValue());
                        resourceMessage2.getMessage().getTexts().put(language, event.getNewValue());
                        resourceMessageDao.makePersistent(resourceMessage2);
                    }
                });

                widget = new HtmlTableWidget("RESOURCELIST", model, request.getLocale());
                getWidgetManager(session).register(widget);
            }

            view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "system_resourcelist"));
            view.addWidget(widget);

            JSONArray jLanguages = new JSONArray();
            view.getJson().element("languages", jLanguages);
            for (String language : getModuleManager().getLanguages()) {
                jLanguages.element(language);
            }

            String language1 = ((LanguageRenderer) ((DefaultTableModel<ResourceMessage>) widget.getModel()).getColumns().get(1).getRenderer()).getLanguage();
            String language2 = ((LanguageRenderer) ((DefaultTableModel<ResourceMessage>) widget.getModel()).getColumns().get(2).getRenderer()).getLanguage();
            view.getJson().element("language1", language1);           
            view.getJson().element("language2", language2);
            view.getJson().element("importFile", checkAuthorisation(SystemModule.AUTH_RESOURCE_IMPORT));

        }
View Full Code Here

    @RequestMapping(value = "/sys/selectResourceLanguage.do", method = RequestMethod.POST)
    public ModelAndView selectResourceLanguage(@ModelAttribute("ResourceForm") ResourceForm form, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), getLocale(request));

        HtmlTableWidget widget = (HtmlTableWidget) getWidgetManager(session).getWidget("RESOURCELIST");

        ((LanguageRenderer) ((DefaultTableModel<ResourceMessage>) widget.getModel()).getColumns().get(1).getRenderer()).setLanguage(form.getLanguage1());
        ((LanguageRenderer) ((DefaultTableModel<ResourceMessage>) widget.getModel()).getColumns().get(2).getRenderer()).setLanguage(form.getLanguage2());

        return resource(session, request);
    }
View Full Code Here

            for (String userGroup : userGroups) {
                userList.addAll(userDao.findByGroup(userGroup));
            }
        }

        HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");
        if (userListComponent == null) {
            DefaultTableModelColumn usernameColumn = new DefaultTableModelColumn("base.user.table.username", "username");
            usernameColumn.setStyleClass("emphasize");
            usernameColumn.setRenderer(new TableColumnRenderer() {

                public String getTemplate() {
                    return "v2js_widgets_username";
                }

                public Object getData(Object obj) {
                    JSONObject jLink = new JSONObject();
                    jLink.element("username", ((ZeroUser) obj).getUsername());
                    jLink.element("deleted", ((ZeroUser) obj).isDeleted());
                    return jLink;

                }
            });

            /* usernameColumn.addClickListener(new TableClickListener() {
           
            public void fireClicked(TableClickEvent event) {
            log.debug("fireClicked: " + event.getWidget().getModel().getData(event.getColumn(), event.getRow()));
            }
            });*/
            UserTableModel model = new UserTableModel(userList, getMessages(), request.getLocale());

            if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
                model.setSelectable(true);
                DefaultTableModelColumn editColumn = new DefaultTableModelColumn("", "");
                editColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return "v2js_widgets_tablelink";
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            JSONObject jLink = new JSONObject();
                            jLink.element("url", "user/userEdit.do?selected=" + ((ZeroUser) obj).getId());
                            jLink.element("text", "Edit");
                            return jLink;
                        }
                        return "";
                    }
                });
                model.addColumn(editColumn);

            }

            if (user.checkAuthorisation(UserModule.AUTH_LOGIN_AS)) {
                model.setSelectable(true);
                DefaultTableModelColumn loginColumn = new DefaultTableModelColumn("", "");
                loginColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return null;
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            return new HtmlSnippet("<a href=\"user/loginAsUser.do?selected=" + ((ZeroUser) obj).getId() + "\">Login</a>");
                        }
                        return "";
                    }
                });
                model.addColumn(loginColumn);

            }

            model.addColumn(usernameColumn);
            model.addColumn(new DefaultTableModelColumn("base.user.table.firstname", "person.firstname"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.lastname", "person.lastname"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.email", "person.email"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.phone", "person.phone"));
            model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "userGroup.groupKey"));
            model.addColumn(new DefaultTableModelColumn("base.user.label.locked", "locked"));

            if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
                DefaultTableModelColumn sendPwdColumn = new DefaultTableModelColumn("", "");
                sendPwdColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return "v2js_widgets_tablelink";
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            JSONObject jLink = new JSONObject();
                            jLink.element("url", "user/userSendPwd.do?selected=" + ((ZeroUser) obj).getId());
                            jLink.element("text", "Send Password");
                            return jLink;
                        }
                        return "";
                    }
                });
                model.addColumn(sendPwdColumn);

            }

            model.setSort(1);
            userListComponent = new HtmlTableWidget("USERLIST", model, request.getLocale());
            userListComponent.setRowsPerPage(20);

            getWidgetManager(session).register(userListComponent);
        } else {
            ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).setCollection(userList);
        }

        view.addWidget(userListComponent);

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
View Full Code Here

        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                log.debug(row);
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.delete_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
            }

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                log.debug(row);
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    selectedUser = userDao.findById(selectedUser.getId(), true);
                    selectedUser.setDeleted(true);

                    selectedUser.setModificationDate(new Date());
View Full Code Here

        logFunction("user-undelete");
        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.delete_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
            }

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    selectedUser = userDao.findById(selectedUser.getId(), true);
                    selectedUser.setDeleted(false);
                    selectedUser.setModificationDate(new Date());
                    selectedUser.setLastModifiedBy((ZeroUser) getUser());
View Full Code Here

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            FormWidget filter = (FormWidget) getWidgetManager(session).getWidget("USERLIST_FILTER");
            filter.setValuesFromForm(form);
            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");
            UserTableModel model = (UserTableModel) userListComponent.getModel();
            model.setUsername(form.getValues().get("username"));
            model.setUserGroupId(form.getValues().get("userGroup"));
            model.setDeleted(form.getValues().get("deleted"));
        }
        return list(session, request);
View Full Code Here

        logFunction("user-lock");
        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.edit_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
            }

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    selectedUser = userDao.findById(selectedUser.getId(), true);
                    selectedUser.setLocked(true);
                    selectedUser.setModificationDate(new Date());
                    selectedUser.setLastModifiedBy((ZeroUser) getUser());
View Full Code Here

TOP

Related Classes of at.riemers.zero.widgets.HtmlTableWidget

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.