List of usage examples for com.vaadin.ui Embedded addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:com.rdonasco.security.user.controllers.UserGroupsViewController.java
License:Apache License
private UserGroupItemVO prepareUserGroupItemVO(UserGroupVO userGroup) { Embedded icon = IconHelper.createDeleteIcon("Remove group"); final UserGroupItemVO userRoleItemVO = new UserGroupItemVOBuilder().setIcon(icon).setUserGroupVO(userGroup) .createUserGroupItemVO();/*from w w w. j a v 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, UserConstants.RESOURCE_USER_GROUPS); if (!getControlledView().isReadOnly() && !userGroupItemContainer.removeItem(userRoleItemVO)) { popupProvider.popUpError( I18NResource.localizeWithParameter("Unable to remove group _", userRoleItemVO)); } } catch (Exception e) { exceptionPopupProvider.popUpErrorException(e); } } }); return userRoleItemVO; }
From source file:com.rdonasco.security.user.controllers.UserRolesViewController.java
License:Apache License
private void configureUserRolesTable() { getControlledView().getUserRolesTable().setContainerDataSource(userRoleItemContainer); userRoleItemContainer.addNestedContainerProperty(COLUMN_ROLE_NAME); getControlledView().getUserRolesTable().setVisibleColumns(editableColumns); getControlledView().getUserRolesTable() .setColumnHeaders(new String[] { "", I18NResource.localize("Name") }); getControlledView().getUserRolesTable().setCellStyleGenerator(new ListItemIconCellStyleGenerator()); userRolesDropHandler = new DropHandler() { private static final long serialVersionUID = 1L; @Override/*from w ww . jav a 2s. c o m*/ public void drop(DragAndDropEvent dropEvent) { try { // TODO: Enable adding multiple dragged items final DataBoundTransferable transferredData = (DataBoundTransferable) dropEvent .getTransferable(); if (null != transferredData && transferredData.getItemId() instanceof RoleItemVO) { sessionSecurityChecker.checkCapabilityTo(ActionConstants.ADD, UserConstants.RESOURCE_USER_ROLES); LOG.log(Level.FINE, "drop allowed at user capability panel"); final RoleItemVO droppedCapabilityItemVO = (RoleItemVO) transferredData.getItemId(); Embedded icon = IconHelper.createDeleteIcon(I18NResource.localize("Remove Role")); final UserRoleItemVO newUserRoleItemVO = new UserRoleItemVOBuilder().setIcon(icon) .setUserRoleVO(new UserRoleVOBuilder().setRole(droppedCapabilityItemVO.getRoleVO()) .setUserProfile(currentProfile.getBean().getUserSecurityProfileVO()) .createUserRoleVO()) .createUserRoleItemVO(); BeanItem<UserRoleItemVO> addedItem = userRoleItemContainer.addItem(newUserRoleItemVO); LOG.log(Level.FINE, "addedItem = {0}", addedItem); icon.addListener(prepareDeleteRoleClickListener(newUserRoleItemVO)); } else { LOG.log(Level.FINE, "invalid data dropped in user role panel"); } } catch (Exception e) { exceptionPopupProvider.popUpErrorException(e); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }; getControlledView().getUserRolesTable().setDropHandler(userRolesDropHandler); }
From source file:com.rdonasco.security.user.controllers.UserRolesViewController.java
License:Apache License
private void populateItemContainer() { userRoleItemContainer.removeAllItems(); getControlledView().getUserRolesTable().setSelectable(true); for (UserRoleVO userRole : currentProfile.getBean().getRoles()) { Embedded icon = IconHelper.createDeleteIcon("Remove role"); final UserRoleItemVO userRoleItemVO = new UserRoleItemVOBuilder().setIcon(icon).setUserRoleVO(userRole) .createUserRoleItemVO(); userRoleItemContainer.addItem(userRoleItemVO); icon.addListener(prepareDeleteRoleClickListener(userRoleItemVO)); }//from ww w . ja va2s. c o m }
From source file:org.activiti.explorer.ui.custom.UserProfileLink.java
License:Apache License
protected void initPicture(IdentityService identityService, boolean renderPicture, final String userName) { if (renderPicture) { Picture picture = identityService.getUserPicture(userName); if (picture != null) { Resource imageResource = new StreamResource(new InputStreamStreamSource(picture.getInputStream()), userName + picture.getMimeType(), ExplorerApp.get()); Embedded image = new Embedded(null, imageResource); image.addStyleName(ExplorerLayout.STYLE_CLICKABLE); image.setType(Embedded.TYPE_IMAGE); image.setHeight(30, Embedded.UNITS_PIXELS); image.setWidth(30, Embedded.UNITS_PIXELS); image.addListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = 7341560240277898495L; public void click(MouseEvents.ClickEvent event) { viewManager.showProfilePopup(userName); }//from w w w . jav a2 s . c o m }); addComponent(image); setComponentAlignment(image, Alignment.MIDDLE_LEFT); } else { // TODO: what when no image is available? } } }
From source file:org.activiti.explorer.ui.task.SubTaskComponent.java
License:Apache License
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) { if (!subTasks.isEmpty()) { for (final HistoricTaskInstance subTask : subTasks) { // icon Embedded icon = null;/*w ww . java 2 s. c om*/ 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:org.activiti.explorer.ui.task.TaskRelatedContentComponent.java
License:Apache License
protected void addAttachmentsToTable(List<Attachment> attachments) { for (Attachment attachment : attachments) { AttachmentRenderer renderer = attachmentRendererManager.getRenderer(attachment); Item attachmentItem = table.addItem(attachment.getId()); attachmentItem.getItemProperty("name").setValue(renderer.getOverviewComponent(attachment, this)); attachmentItem.getItemProperty("type").setValue(new Embedded(null, renderer.getImage(attachment))); Embedded deleteButton = new Embedded(null, Images.DELETE); deleteButton.addStyleName(ExplorerLayout.STYLE_CLICKABLE); deleteButton.addListener((ClickListener) new DeleteClickedListener(attachment)); attachmentItem.getItemProperty("delete").setValue(deleteButton); }//from w w w. ja v a 2 s. co m if (!table.getItemIds().isEmpty()) { table.setVisible(true); } table.setPageLength(table.size()); }
From source file:org.activiti.explorer.ui.task.UserDetailsComponent.java
License:Apache License
protected void addUserPicture() { Resource pictureResource = Images.USER_32; // default icon if (user != null) { final Picture userPicture = identityService.getUserPicture(user.getId()); if (userPicture != null) { pictureResource = new StreamResource(new StreamSource() { public InputStream getStream() { return userPicture.getInputStream(); }//from www .java 2 s . c o m }, user.getId(), ExplorerApp.get()); } } Embedded picture = new Embedded(null, pictureResource); picture.setType(Embedded.TYPE_IMAGE); picture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE); if (user != null) { // Only set fixed height and width when user has image, otherwise icon's dimensions will be used picture.setHeight("32px"); picture.setWidth("32px"); } addComponent(picture); // Add profile popup listener if (user != null) { picture.addStyleName(ExplorerLayout.STYLE_CLICKABLE); picture.addListener(new com.vaadin.event.MouseEvents.ClickListener() { public void click(ClickEvent event) { viewManager.showProfilePopup(user.getId()); } }); } }