List of usage examples for com.vaadin.server FontAwesome QUESTION_CIRCLE
FontAwesome QUESTION_CIRCLE
To view the source code for com.vaadin.server FontAwesome QUESTION_CIRCLE.
Click Source Link
From source file:org.opencms.ui.dialogs.permissions.CmsPermissionView.java
License:Open Source License
/** * Constructor.<p>/*from w w w .j a va 2s .co m*/ * * @param entry the access control entry * @param editable the editable flag * @param isFolder the is folder flag * @param inheritedFrom the inherited from path * @param changeHandler the change handler */ public CmsPermissionView(CmsAccessControlEntry entry, boolean editable, boolean isFolder, String inheritedFrom, PermissionChangeHandler changeHandler) { m_changeHandler = changeHandler; m_editable = editable; m_entry = entry; CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null); CmsObject cms = A_CmsUI.getCmsObject(); // get name and type of the current entry I_CmsPrincipal principal; try { principal = CmsPrincipal.readPrincipalIncludingHistory(cms, entry.getPrincipal()); } catch (CmsException e) { principal = null; LOG.debug(e.getLocalizedMessage(), e); } m_principalName = (principal != null) ? principal.getName() : entry.getPrincipal().toString(); String ou = null; String displayName; int flags = 0; if ((principal != null) && (principal instanceof CmsHistoryPrincipal)) { // there is a history principal entry, handle it if (principal.isGroup()) { String niceName = OpenCms.getWorkplaceManager().translateGroupName(principal.getName(), false); displayName = CmsVaadinUtils.getMessageText( org.opencms.security.Messages.GUI_ORGUNIT_DISPLAY_NAME_2, ((CmsHistoryPrincipal) principal).getDescription(), niceName); ou = CmsOrganizationalUnit.getParentFqn(m_principalName); flags = CmsAccessControlEntry.ACCESS_FLAGS_GROUP; } else { displayName = ((CmsHistoryPrincipal) principal).getName(); ou = CmsOrganizationalUnit.getParentFqn(m_principalName); flags = CmsAccessControlEntry.ACCESS_FLAGS_USER; } } else if ((principal != null) && principal.isGroup()) { String niceName = OpenCms.getWorkplaceManager().translateGroupName(principal.getName(), false); displayName = CmsVaadinUtils.getMessageText(org.opencms.security.Messages.GUI_ORGUNIT_DISPLAY_NAME_2, ((CmsGroup) principal).getDescription(A_CmsUI.get().getLocale()), niceName); ou = CmsOrganizationalUnit.getParentFqn(m_principalName); flags = CmsAccessControlEntry.ACCESS_FLAGS_GROUP; } else if ((principal != null) && principal.isUser()) { displayName = ((CmsUser) principal).getFullName(); ou = CmsOrganizationalUnit.getParentFqn(m_principalName); flags = CmsAccessControlEntry.ACCESS_FLAGS_USER; } else if ((m_principalName != null) && m_principalName.equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.toString())) { m_principalName = CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME; displayName = CmsVaadinUtils.getMessageText(Messages.GUI_LABEL_ALLOTHERS_0); m_responsibleCheckbox.setVisible(false); flags = CmsAccessControlEntry.ACCESS_FLAGS_ALLOTHERS; } else if ((m_principalName != null) && m_principalName.equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.toString())) { m_principalName = CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME; displayName = CmsVaadinUtils.getMessageText(Messages.GUI_LABEL_OVERWRITEALL_0); flags = CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE_ALL; } else { // check if it is the case of a role CmsRole role = CmsRole.valueOfId(entry.getPrincipal()); if (role != null) { displayName = role.getName(A_CmsUI.get().getLocale()); m_principalName = role.getRoleName(); flags = CmsAccessControlEntry.ACCESS_FLAGS_ROLE; } else { displayName = entry.getPrincipal().toString(); } } if ((flags > 0) && ((entry.getFlags() & flags) == 0)) { // the flag is set to the wrong principal type if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.ERR_INVALID_ACE_1, entry.toString())); } entry = new CmsAccessControlEntry(entry.getResource(), entry.getPrincipal(), entry.getAllowedPermissions(), entry.getDeniedPermissions(), (entry.getFlags() | flags)); } else if (entry.getFlags() < CmsAccessControlEntry.ACCESS_FLAGS_USER) { // the flag is set to NO principal type if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.ERR_INVALID_ACE_1, entry.toString())); } entry = new CmsAccessControlEntry(entry.getResource(), entry.getPrincipal(), entry.getAllowedPermissions(), entry.getDeniedPermissions(), (entry.getFlags() | CmsAccessControlEntry.ACCESS_FLAGS_GROUP)); } m_principalType = getEntryType(entry.getFlags(), false); if (m_principalName == null) { m_principalName = ""; } FontIcon icon = null; boolean isOverwriteAll = false; switch (flags) { case CmsAccessControlEntry.ACCESS_FLAGS_USER: icon = FontAwesome.USER; break; case CmsAccessControlEntry.ACCESS_FLAGS_GROUP: icon = FontAwesome.GROUP; break; case CmsAccessControlEntry.ACCESS_FLAGS_ALLOTHERS: icon = FontAwesome.GLOBE; break; case CmsAccessControlEntry.ACCESS_FLAGS_ROLE: icon = FontAwesome.GRADUATION_CAP; break; case CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE_ALL: icon = FontAwesome.EXCLAMATION_CIRCLE; isOverwriteAll = true; break; default: icon = FontAwesome.QUESTION_CIRCLE; } m_label.setContentMode(ContentMode.HTML); String ouName = null; if (ou != null) { try { ouName = OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, ou) .getDisplayName(UI.getCurrent().getLocale()); } catch (CmsException e) { LOG.debug("Error reading OU name.", e); } } m_label.setValue(icon.getHtml() + " <b>" + displayName + "</b> " + entry.getPermissions().getPermissionString() + (ouName != null ? ("<br />" + ouName) : "")); m_label.setWidthUndefined(); m_details.setIcon(FontAwesome.PLUS_SQUARE_O); m_details.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { toggleDetails(); } }); m_setButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { setPermissions(); } }); m_deleteButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { deletePermissionSet(); } }); if (inheritedFrom != null) { m_inheritedFrom.setValue(inheritedFrom); } else { m_inheritedFrom.setVisible(false); } if (isOverwriteAll) { setDetailButtonVisible(false); if (m_editable) { addComponent(m_deleteButton, 2); m_deleteButton.addStyleName("o-permissions_delete"); } } else { // get all permissions of the current entry CmsPermissionSet permissions = entry.getPermissions(); IndexedContainer container = getPermissionContainer(permissions); m_permissions.setContainerDataSource(container); m_permissions.setColumnReorderingAllowed(false); m_permissions.setColumnHeader(PROPERTY_LABEL, CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_0)); m_permissions.setColumnHeader(PROPERTY_ALLOWED, CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_ALLOWED_0)); m_permissions.setColumnHeader(PROPERTY_DISPLAY_ALLOWED, CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_ALLOWED_0)); m_permissions.setColumnHeader(PROPERTY_DENIED, CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_DENIED_0)); m_permissions.setColumnHeader(PROPERTY_DISPLAY_DENIED, CmsVaadinUtils.getMessageText(Messages.GUI_PERMISSION_DENIED_0)); m_permissions.setPageLength(5); m_permissions.setSortEnabled(false); if (m_editable) { toggleDetails(); setDetailButtonVisible(false); m_permissions.setVisibleColumns(PROPERTY_LABEL, PROPERTY_ALLOWED, PROPERTY_DENIED); m_permissions.setTableFieldFactory(FIELD_FACTORY); m_permissions.setEditable(m_editable); m_responsibleCheckbox.setValue(isResponsible(entry.getFlags())); m_overwriteCheckbox.setValue(isOverWritingInherited(entry.getFlags())); m_inheritCheckbox.setVisible(isFolder); m_inheritCheckbox.setValue(Boolean.valueOf(m_entry.isInheriting())); m_buttonBar.setVisible(true); } else { m_permissions.setVisibleColumns(PROPERTY_LABEL, PROPERTY_DISPLAY_ALLOWED, PROPERTY_DISPLAY_DENIED); } } }