Example usage for com.vaadin.ui Embedded addListener

List of usage examples for com.vaadin.ui Embedded addListener

Introduction

In this page you can find the example usage for com.vaadin.ui Embedded addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:com.klwork.explorer.ui.task.SubTaskComponent.java

License:Apache License

protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
    if (subTasks.size() > 0) {
        for (final HistoricTaskInstance subTask : subTasks) {
            // icon
            Embedded icon = null;// ww w .  ja v  a  2  s. co  m

            if (subTask.getEndTime() != null) {//?
                icon = new Embedded(null, Images.TASK_FINISHED_22);
            } else {
                icon = new Embedded(null, Images.TASK_22);
            }
            icon.setWidth(22, UNITS_PIXELS);
            icon.setWidth(22, UNITS_PIXELS);
            subTaskLayout.addComponent(icon);

            // Link to subtask
            Button subTaskLink = new Button(subTask.getName());
            subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
            subTaskLink.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    //ExplorerApp.get().getViewManager().showTaskPage(subTask.getId());
                }
            });
            subTaskLayout.addComponent(subTaskLink);
            subTaskLayout.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);

            if (subTask.getEndTime() == null) {
                // Delete icon only appears when task is not finished yet
                Embedded deleteIcon = new Embedded(null, Images.DELETE);
                deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
                deleteIcon.addListener(new DeleteSubTaskClickListener(subTask, this));
                subTaskLayout.addComponent(deleteIcon);
                subTaskLayout.setComponentAlignment(deleteIcon, Alignment.MIDDLE_RIGHT);
            } else {
                // Next line of grid
                subTaskLayout.newLine();
            }
        }
    } else {
        Label noSubTasksLabel = new Label(i18nManager.getMessage(Messages.TASK_NO_SUBTASKS));
        noSubTasksLabel.setSizeUndefined();
        noSubTasksLabel.addStyleName(Reindeer.LABEL_SMALL);
        subTaskLayout.addComponent(noSubTasksLabel);
    }

}

From source file:com.klwork.explorer.ui.util.ThemeImageColumnGenerator.java

License:Apache License

public Component generateCell(Table source, Object itemId, Object columnId) {
    Embedded embedded = new Embedded(null, image);

    if (clickListener != null) {
        embedded.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
        embedded.setData(itemId);/*  ww  w.  j a v  a2s. c o m*/
        embedded.addListener(clickListener);
    }

    return embedded;
}

From source file:com.rdonasco.datamanager.listeditor.controller.ListEditorViewPanelController.java

License:Apache License

private void setupDeleteIconClickListener(Embedded icon, final VO itemVO) {
    icon.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from  w  w  w  .  jav  a 2s  .  c  o m*/
        public void click(MouseEvents.ClickEvent event) {
            try {
                dataContainer.removeItem(itemVO);
            } catch (RuntimeException ex) {
                LOG.log(Level.WARNING, ex.getMessage(), ex);
                getPopupProvider().popUpError(I18NResource.localize("Error deleting an item"));
            }
        }
    });
}

From source file:com.rdonasco.security.application.controllers.ApplicationDataManager.java

License:Apache License

private void addOptionalClickListener(Embedded icon, ApplicationItemVO applicationItemVO) {
    if (getClickListenerProvider() != null) {
        icon.addListener(getClickListenerProvider().provideClickListenerFor(applicationItemVO));
    }/*from w w w.  j  a v  a  2 s  .c o  m*/
}

From source file:com.rdonasco.security.group.controllers.GroupDataManagerDecorator.java

License:Apache License

private GroupItemVO convertToGroupItemVOWithListener(SecurityGroupVO groupVO) {
    Embedded icon = IconHelper.createDeleteIcon(I18NResource.localize("Delete"));
    GroupItemVO groupItemVO = new GroupItemVOBuilder().setIcon(icon).setRoleVO(groupVO).createGroupItemVO();
    if (clickListenerProvider != null) {
        icon.addListener(clickListenerProvider.provideClickListenerFor(groupItemVO));
    }/*from ww w .  j ava2  s  . c  om*/
    return groupItemVO;
}

From source file:com.rdonasco.security.group.controllers.GroupEditorViewController.java

License:Apache License

private GroupRoleItemVO createGroupRoleItemVO(RoleVO roleVO) {
    Embedded icon = IconHelper.createDeleteIcon("Remove Role");
    final GroupRoleItemVO groupRoleItemVO = new GroupRoleItemVOBuilder().setIcon(icon)
            .setSecurityGroupRoleVO(new SecurityGroupRoleVOBuilder().setRole(roleVO)
                    .setSecurityGroup(getCurrentItem().getBean().getSecurityGroupVO())
                    .createSecurityGroupRoleVO())
            .createGroupRoleItemVO();//from   w  ww  .j  av a 2s .  c  o  m
    icon.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void click(MouseEvents.ClickEvent event) {
            try {
                sessionSecurityChecker.checkCapabilityTo(ActionConstants.DELETE,
                        GroupConstants.RESOURCE_GROUP_ROLES);
                if (!getControlledView().isReadOnly() && !groupRolesContainer.removeItem(groupRoleItemVO)) {
                    popupProvider.popUpError(I18NResource.localizeWithParameter("Unable to remove role _",
                            groupRoleItemVO.getSecurityGroupRoleVO().getRoleVO().getName()));

                }
            } catch (Exception e) {
                exceptionPopupProvider.popUpErrorException(e);
            }
        }
    });
    return groupRoleItemVO;
}

From source file:com.rdonasco.security.role.controllers.RoleDataManagerDecorator.java

License:Apache License

private RoleItemVO convertToRoleItemVOWithListener(RoleVO roleVO) {
    Embedded icon = IconHelper.createDeleteIcon(I18NResource.localize("Delete"));
    RoleItemVO roleItemVO = new RoleItemVOBuilder().setIcon(icon).setRoleVO(roleVO).createRoleItemVO();
    if (getClickListenerProvider() != null) {
        icon.addListener(getClickListenerProvider().provideClickListenerFor(roleItemVO));
    }//from ww  w.j  a v a2  s  . c o m
    return roleItemVO;
}

From source file:com.rdonasco.security.role.controllers.RoleEditorViewController.java

License:Apache License

private RoleCapabilityItemVO createRoleCapabilityItemVO(final CapabilityVO capabilityVO) {
    Embedded icon = IconHelper.createDeleteIcon("Remove Capability");
    final RoleCapabilityItemVO newRoleCapability = new RoleCapabilityItemVOBuilder().setIcon(icon)
            .setRoleCapabilityVO(new RoleCapabilityVOBuilder().setCapabilityVO(capabilityVO)
                    .setRoleVO(getCurrentItem().getBean().getRoleVO()).createRoleCapabilityVO())
            .createRoleCapabilityItemVO();
    icon.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override// w  w  w  . j a v a  2  s  . com
        public void click(MouseEvents.ClickEvent event) {
            try {
                sessionSecurityChecker.checkCapabilityTo(ActionConstants.DELETE,
                        RoleConstants.RESOURCES_ROLE_CAPABILITY);
                if (!getControlledView().isReadOnly()
                        && !roleCapabilitiesContainer.removeItem(newRoleCapability)) {
                    popupProvider.popUpError(I18NResource.localizeWithParameter("Unable to remove capability _",
                            newRoleCapability.getCapability().getTitle()));

                }
            } catch (Exception e) {
                exceptionPopupProvider.popUpErrorException(e);
            }
        }
    });
    return newRoleCapability;
}

From source file:com.rdonasco.security.user.controllers.UserCapabilitiesViewController.java

License:Apache License

private UserCapabilityItemVO prepareUserCapabilityItemVO(UserCapabilityVO userCapability) {
    Embedded icon = IconHelper.createDeleteIcon("Remove capability");
    final UserCapabilityItemVO userCapabilityItemVO = new UserCapabilityItemVOBuilder().setIcon(icon)
            .setUserCapabilityVO(userCapability).createUserCapabilityItemVO();
    icon.addListener(new MouseEvents.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*  ww w.  j  a v a  2s .  c o m*/
        public void click(MouseEvents.ClickEvent event) {
            try {
                sessionSecurityChecker.checkCapabilityTo(ActionConstants.DELETE,
                        UserConstants.RESOURCE_USER_CAPABILITIES);
                if (!getControlledView().isReadOnly()
                        && !userCapabilityItemContainer.removeItem(userCapabilityItemVO)) {
                    popupProvider.popUpError(I18NResource.localizeWithParameter("Unable to remove capability _",
                            userCapabilityItemVO));

                }
            } catch (Exception e) {
                exceptionPopupProvider.popUpErrorException(e);
            }
        }
    });
    return userCapabilityItemVO;
}

From source file:com.rdonasco.security.user.controllers.UserDataManagerDecorator.java

License:Apache License

private void addOptionalClickListener(Embedded icon, UserSecurityProfileItemVO userSecurityProfileItemVO) {
    if (getClickListenerProvider() != null) {
        icon.addListener(getClickListenerProvider().provideClickListenerFor(userSecurityProfileItemVO));
    }//from  ww w.  jav a  2 s  .  c  o m
}