Search in sources :

Example 1 with LoggedInUser

use of org.activiti.explorer.identity.LoggedInUser in project Activiti by Activiti.

the class SubTaskComponent method initAddSubTaskPanelKeyboardActions.

protected void initAddSubTaskPanelKeyboardActions() {
    addSubTaskPanel.addActionHandler(new Handler() {

        public void handleAction(Action action, Object sender, Object target) {
            if ("escape".equals(action.getCaption())) {
                resetAddButton();
            } else if ("enter".equals(action.getCaption())) {
                if (newTaskTextField != null && newTaskTextField.getValue() != null && !"".equals(newTaskTextField.getValue().toString())) {
                    LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();
                    // save task
                    Task newTask = taskService.newTask();
                    newTask.setParentTaskId(parentTask.getId());
                    if (parentTask.getAssignee() != null) {
                        newTask.setAssignee(parentTask.getAssignee());
                    } else {
                        newTask.setAssignee(loggedInUser.getId());
                    }
                    if (parentTask.getOwner() != null) {
                        newTask.setOwner(parentTask.getOwner());
                    } else {
                        newTask.setOwner(loggedInUser.getId());
                    }
                    newTask.setName(newTaskTextField.getValue().toString());
                    taskService.saveTask(newTask);
                    // Reset the add button to its original state
                    resetAddButton();
                    // refresh sub tasks section
                    refreshSubTasks();
                }
            }
        }

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null), new ShortcutAction("escape", ShortcutAction.KeyCode.ESCAPE, null) };
        }
    });
}
Also used : ShortcutAction(com.vaadin.event.ShortcutAction) Action(com.vaadin.event.Action) Task(org.activiti.engine.task.Task) Handler(com.vaadin.event.Action.Handler) LoggedInUser(org.activiti.explorer.identity.LoggedInUser) ShortcutAction(com.vaadin.event.ShortcutAction)

Example 2 with LoggedInUser

use of org.activiti.explorer.identity.LoggedInUser in project Activiti by Activiti.

the class MainMenuBar method initProfileButton.

protected void initProfileButton() {
    final LoggedInUser user = ExplorerApp.get().getLoggedInUser();
    // User name + link to profile 
    MenuBar profileMenu = new MenuBar();
    profileMenu.addStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_BOX);
    MenuItem rootItem = profileMenu.addItem(user.getFirstName() + " " + user.getLastName(), null);
    rootItem.setStyleName(ExplorerLayout.STYLE_HEADER_PROFILE_MENU);
    if (useProfile()) {
        // Show profile
        rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_SHOW), new Command() {

            public void menuSelected(MenuItem selectedItem) {
                ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
            }
        });
        // Edit profile
        rootItem.addItem(i18nManager.getMessage(Messages.PROFILE_EDIT), new Command() {

            public void menuSelected(MenuItem selectedItem) {
                // TODO: Show in edit-mode
                ExplorerApp.get().getViewManager().showProfilePopup(user.getId());
            }
        });
        // Change password
        rootItem.addItem(i18nManager.getMessage(Messages.PASSWORD_CHANGE), new Command() {

            public void menuSelected(MenuItem selectedItem) {
                ExplorerApp.get().getViewManager().showPopupWindow(new ChangePasswordPopupWindow());
            }
        });
        rootItem.addSeparator();
    }
    // Logout
    rootItem.addItem(i18nManager.getMessage(Messages.HEADER_LOGOUT), new Command() {

        public void menuSelected(MenuItem selectedItem) {
            ExplorerApp.get().close();
        }
    });
    addComponent(profileMenu);
    setComponentAlignment(profileMenu, Alignment.TOP_RIGHT);
    setExpandRatio(profileMenu, 1.0f);
}
Also used : ChangePasswordPopupWindow(org.activiti.explorer.ui.profile.ChangePasswordPopupWindow) Command(com.vaadin.ui.MenuBar.Command) MenuBar(com.vaadin.ui.MenuBar) MenuItem(com.vaadin.ui.MenuBar.MenuItem) LoggedInUser(org.activiti.explorer.identity.LoggedInUser)

Example 3 with LoggedInUser

use of org.activiti.explorer.identity.LoggedInUser in project Activiti by Activiti.

the class DefaultLoginHandler method authenticate.

public LoggedInUserImpl authenticate(String userName, String password) {
    LoggedInUserImpl loggedInUser = null;
    try {
        if (identityService.checkPassword(userName, password)) {
            User user = identityService.createUserQuery().userId(userName).singleResult();
            // Fetch and cache user data
            loggedInUser = new LoggedInUserImpl(user, password);
            List<Group> groups = identityService.createGroupQuery().groupMember(user.getId()).list();
            for (Group group : groups) {
                if (Constants.SECURITY_ROLE.equals(group.getType())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    if (Constants.SECURITY_ROLE_USER.equals(group.getId())) {
                        loggedInUser.setUser(true);
                    }
                    if (Constants.SECURITY_ROLE_ADMIN.equals(group.getId())) {
                        loggedInUser.setAdmin(true);
                    }
                } else if (ExplorerApp.get().getAdminGroups() != null && ExplorerApp.get().getAdminGroups().contains(group.getId())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    loggedInUser.setAdmin(true);
                } else if (ExplorerApp.get().getUserGroups() != null && ExplorerApp.get().getUserGroups().contains(group.getId())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    loggedInUser.setUser(true);
                } else {
                    loggedInUser.addGroup(group);
                }
            }
        }
    } catch (Exception e) {
    // Do nothing, returning null should be enough
    }
    return loggedInUser;
}
Also used : Group(org.activiti.engine.identity.Group) LoggedInUser(org.activiti.explorer.identity.LoggedInUser) User(org.activiti.engine.identity.User) LoggedInUserImpl(org.activiti.explorer.identity.LoggedInUserImpl)

Example 4 with LoggedInUser

use of org.activiti.explorer.identity.LoggedInUser in project Activiti by Activiti.

the class TaskMenuBar method initItems.

protected void initItems() {
    setWidth("100%");
    // TODO: the counts should be done later by eg a Refresher component
    // Inbox
    long inboxCount = new InboxListQuery().size();
    ToolbarEntry inboxEntry = addToolbarEntry(ENTRY_INBOX, i18nManager.getMessage(Messages.TASK_MENU_INBOX), new ToolbarCommand() {

        public void toolBarItemSelected() {
            viewManager.showInboxPage();
        }
    });
    inboxEntry.setCount(inboxCount);
    // Tasks
    LoggedInUser user = ExplorerApp.get().getLoggedInUser();
    long tasksCount = new TasksListQuery().size();
    ToolbarEntry tasksEntry = addToolbarEntry(ENTRY_TASKS, i18nManager.getMessage(Messages.TASK_MENU_TASKS), new ToolbarCommand() {

        public void toolBarItemSelected() {
            viewManager.showTasksPage();
        }
    });
    tasksEntry.setCount(tasksCount);
    // Queued
    List<Group> groups = user.getGroups();
    ToolbarPopupEntry queuedItem = addPopupEntry(ENTRY_QUEUED, (i18nManager.getMessage(Messages.TASK_MENU_QUEUED)));
    long queuedCount = 0;
    for (final Group group : groups) {
        long groupCount = new QueuedListQuery(group.getId()).size();
        queuedItem.addMenuItem(group.getName() + " (" + groupCount + ")", new ToolbarCommand() {

            public void toolBarItemSelected() {
                viewManager.showQueuedPage(group.getId());
            }
        });
        queuedCount += groupCount;
    }
    queuedItem.setCount(queuedCount);
    // Involved
    long involvedCount = new InvolvedListQuery().size();
    ToolbarEntry involvedEntry = addToolbarEntry(ENTRY_INVOLVED, i18nManager.getMessage(Messages.TASK_MENU_INVOLVED), new ToolbarCommand() {

        public void toolBarItemSelected() {
            viewManager.showInvolvedPage();
        }
    });
    involvedEntry.setCount(involvedCount);
    // Archived
    long archivedCount = new ArchivedListQuery().size();
    ToolbarEntry archivedEntry = addToolbarEntry(ENTRY_ARCHIVED, i18nManager.getMessage(Messages.TASK_MENU_ARCHIVED), new ToolbarCommand() {

        public void toolBarItemSelected() {
            viewManager.showArchivedPage();
        }
    });
    archivedEntry.setCount(archivedCount);
}
Also used : Group(org.activiti.engine.identity.Group) ArchivedListQuery(org.activiti.explorer.ui.task.data.ArchivedListQuery) ToolbarEntry(org.activiti.explorer.ui.custom.ToolbarEntry) InvolvedListQuery(org.activiti.explorer.ui.task.data.InvolvedListQuery) ToolbarCommand(org.activiti.explorer.ui.custom.ToolbarEntry.ToolbarCommand) TasksListQuery(org.activiti.explorer.ui.task.data.TasksListQuery) QueuedListQuery(org.activiti.explorer.ui.task.data.QueuedListQuery) LoggedInUser(org.activiti.explorer.identity.LoggedInUser) ToolbarPopupEntry(org.activiti.explorer.ui.custom.ToolbarPopupEntry) InboxListQuery(org.activiti.explorer.ui.task.data.InboxListQuery)

Example 5 with LoggedInUser

use of org.activiti.explorer.identity.LoggedInUser in project Activiti by Activiti.

the class ExplorerApp method onRequestStart.

// HttpServletRequestListener -------------------------------------------------------------------
public void onRequestStart(HttpServletRequest request, HttpServletResponse response) {
    // Set current application object as thread-local to make it easy accessible
    current.set(this);
    // Authentication: check if user is found, otherwise send to login page
    LoggedInUser user = (LoggedInUser) getUser();
    if (user == null) {
        // First, try automatic login
        user = loginHandler.authenticate(request, response);
        if (user == null) {
            if (mainWindow != null && !mainWindow.isShowingLoginPage()) {
                viewManager.showLoginPage();
            }
        } else {
            setUser(user);
        }
    }
    if (user != null) {
        Authentication.setAuthenticatedUserId(user.getId());
        if (mainWindow != null && mainWindow.isShowingLoginPage()) {
            viewManager.showDefaultPage();
        }
    }
    // Callback to the login handler
    loginHandler.onRequestStart(request, response);
}
Also used : LoggedInUser(org.activiti.explorer.identity.LoggedInUser)

Aggregations

LoggedInUser (org.activiti.explorer.identity.LoggedInUser)7 Group (org.activiti.engine.identity.Group)2 Action (com.vaadin.event.Action)1 Handler (com.vaadin.event.Action.Handler)1 ShortcutAction (com.vaadin.event.ShortcutAction)1 Button (com.vaadin.ui.Button)1 ClickEvent (com.vaadin.ui.Button.ClickEvent)1 ClickListener (com.vaadin.ui.Button.ClickListener)1 MenuBar (com.vaadin.ui.MenuBar)1 Command (com.vaadin.ui.MenuBar.Command)1 MenuItem (com.vaadin.ui.MenuBar.MenuItem)1 User (org.activiti.engine.identity.User)1 Task (org.activiti.engine.task.Task)1 LoggedInUserImpl (org.activiti.explorer.identity.LoggedInUserImpl)1 ToolbarEntry (org.activiti.explorer.ui.custom.ToolbarEntry)1 ToolbarCommand (org.activiti.explorer.ui.custom.ToolbarEntry.ToolbarCommand)1 ToolbarPopupEntry (org.activiti.explorer.ui.custom.ToolbarPopupEntry)1 SubmitEvent (org.activiti.explorer.ui.event.SubmitEvent)1 ChangePasswordPopupWindow (org.activiti.explorer.ui.profile.ChangePasswordPopupWindow)1 ArchivedListQuery (org.activiti.explorer.ui.task.data.ArchivedListQuery)1