com.klwork.explorer.ui.business.organization.GroupMenuBar.java Source code

Java tutorial

Introduction

Here is the source code for com.klwork.explorer.ui.business.organization.GroupMenuBar.java

Source

/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.klwork.explorer.ui.business.organization;

import java.util.List;

import org.activiti.engine.IdentityService;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.identity.Group;

import com.klwork.explorer.I18nManager;
import com.klwork.explorer.Messages;
import com.klwork.explorer.ViewToolManager;
import com.klwork.explorer.security.LoggedInUser;
import com.klwork.explorer.security.LoginHandler;
import com.klwork.explorer.ui.Images;
import com.klwork.explorer.ui.custom.ToolBar;
import com.klwork.explorer.ui.custom.ToolbarEntry;
import com.klwork.explorer.ui.custom.ToolbarEntry.ToolbarCommand;
import com.klwork.explorer.ui.custom.ToolbarPopupEntry;
import com.klwork.explorer.ui.mainlayout.ExplorerLayout;
import com.klwork.explorer.ui.task.data.ArchivedListQuery;
import com.klwork.explorer.ui.task.data.InboxListQuery;
import com.klwork.explorer.ui.task.data.InvolvedListQuery;
import com.klwork.explorer.ui.task.data.QueuedListQuery;
import com.klwork.explorer.ui.task.data.TasksListQuery;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

/**
 * The menu bar which is shown when 'Tasks' is selected in the main menu.
 * 
 * @author Joram Barrez
 * @author Frederik Heremans
 */
public class GroupMenuBar extends ToolBar {

    private static final long serialVersionUID = 1L;

    public static final String ENTRY_TASKS = "tasks";
    public static final String ENTRY_INBOX = "inbox";
    public static final String ENTRY_QUEUED = "queued";
    public static final String ENTRY_INVOLVED = "involved";
    public static final String ENTRY_ARCHIVED = "archived";

    protected transient IdentityService identityService;
    protected I18nManager i18nManager;

    public GroupMenuBar() {
        this.identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
        this.i18nManager = ViewToolManager.getI18nManager();
        //WW_TODO x?,
        initItems();
        //WW_TODO x
        initActions();
    }

    protected void initItems() {
        setWidth("100%");

        // TODO: the counts should be done later by eg a Refresher component
        ToolbarEntry teamManagerEntry = addToolbarEntry("team_manager",
                i18nManager.getMessage(Messages.ORGANIZATION_TEAM_MANAGER), new ToolbarCommand() {
                    public void toolBarItemSelected() {
                        ViewToolManager.getMainView().showOrganizationMain();
                    }
                });

        ToolbarEntry teamMemberEntry = addToolbarEntry("team_member",
                i18nManager.getMessage(Messages.ORGANIZATION_TEAM_MEMBER), new ToolbarCommand() {
                    public void toolBarItemSelected() {
                        ViewToolManager.getMainView().showOrganMemberMain();
                    }
                });

    }

    protected void initActions() {
        Button newCaseButton = new Button();
        newCaseButton.setCaption(i18nManager.getMessage(Messages.EXPAND_MENU_INVITE));
        //WW_TODO Fix
        newCaseButton.setIcon(Images.TASK_16);
        addButton(newCaseButton);

        newCaseButton.addClickListener(new ClickListener() {
            public void buttonClick(ClickEvent event) {

            }
        });
    }

    public void addButton(Button button) {
        button.addStyleName(ExplorerLayout.STYLE_TOOLBAR_BUTTON);

        actionButtons.add(button);
        // Button is added after the spacer
        addComponent(button);
        setComponentAlignment(button, Alignment.MIDDLE_LEFT);
    }

}