cmsprincipalselectionlist.java
来自「找了很久才找到到源代码」· Java 代码 · 共 729 行 · 第 1/2 页
JAVA
729 行
/**
* Sets the flags parameter value.<p>
*
* @param flags the flags parameter value to set
*/
public void setParamFlags(String flags) {
m_paramFlags = flags;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String)
*/
protected void fillDetails(String detailId) {
// noop
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#getListItems()
*/
protected List getListItems() throws CmsException {
List ret = new ArrayList();
boolean withOtherOus = hasPrincipalsInOtherOus()
&& getList().getMetadata().getItemDetailDefinition(LIST_DETAIL_OTHEROU).isVisible();
// get content
List principals = getPrincipals(withOtherOus);
Iterator itPrincipals = principals.iterator();
while (itPrincipals.hasNext()) {
I_CmsPrincipal principal = (I_CmsPrincipal)itPrincipals.next();
CmsListItem item = getList().newItem(principal.getId().toString());
item.set(LIST_COLUMN_NAME, principal.getName());
item.set(LIST_COLUMN_DISPLAY, principal.getSimpleName());
if (principal.isUser()) {
if (principal.getId().equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID)
|| principal.getId().equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID)) {
item.set(LIST_COLUMN_DESCRIPTION, ((CmsUser)principal).getDescription(getLocale()));
} else {
item.set(LIST_COLUMN_DESCRIPTION, ((CmsUser)principal).getFullName());
}
} else {
item.set(LIST_COLUMN_DESCRIPTION, ((CmsGroup)principal).getDescription(getLocale()));
}
item.set(LIST_COLUMN_ORGUNIT, CmsOrganizationalUnit.SEPARATOR + principal.getOuFqn());
ret.add(item);
}
return ret;
}
/**
* Returns the list of principals for selection.<p>
*
* @param includeOtherOus if to include other ou's in the selection
*
* @return a list of principals
*
* @throws CmsException if womething goes wrong
*/
protected List getPrincipals(boolean includeOtherOus) throws CmsException {
String ou = getCms().getRequestContext().currentUser().getOuFqn();
Set principals = new HashSet();
if (isShowingUsers()) {
// include special principals
if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) {
CmsUser user = new CmsUser(
CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID,
key(Messages.GUI_LABEL_OVERWRITEALL_0),
"",
"",
"",
"",
0,
0,
0,
null);
user.setDescription(key(Messages.GUI_DESCRIPTION_OVERWRITEALL_0));
principals.add(user);
}
CmsUser user = new CmsUser(
CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID,
key(Messages.GUI_LABEL_ALLOTHERS_0),
"",
"",
"",
"",
0,
0,
0,
null);
user.setDescription(key(Messages.GUI_DESCRIPTION_ALLOTHERS_0));
principals.add(user);
if (includeOtherOus) {
// add all manageable users
principals.addAll(OpenCms.getRoleManager().getManageableUsers(getCms(), "", true));
// add own ou users
principals.addAll(OpenCms.getOrgUnitManager().getUsers(getCms(), ou, true));
} else {
// add own ou users
principals.addAll(OpenCms.getOrgUnitManager().getUsers(getCms(), ou, false));
}
} else {
// include special principals
if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER)) {
principals.add(new CmsGroup(
CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID,
null,
key(Messages.GUI_LABEL_OVERWRITEALL_0),
key(Messages.GUI_DESCRIPTION_OVERWRITEALL_0),
0));
}
principals.add(new CmsGroup(
CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID,
null,
key(Messages.GUI_LABEL_ALLOTHERS_0),
key(Messages.GUI_DESCRIPTION_ALLOTHERS_0),
0));
if (includeOtherOus) {
// add all manageable users
principals.addAll(OpenCms.getRoleManager().getManageableGroups(getCms(), "", true));
// add own ou users
principals.addAll(OpenCms.getOrgUnitManager().getGroups(getCms(), ou, true));
} else {
// add own ou users
principals.addAll(OpenCms.getOrgUnitManager().getGroups(getCms(), ou, false));
}
}
List ret = new ArrayList(principals);
if (getParamFlags() != null) {
int flags = Integer.parseInt(getParamFlags());
return CmsPrincipal.filterFlag(ret, flags);
}
return ret;
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#initializeDetail(java.lang.String)
*/
protected void initializeDetail(String detailId) {
super.initializeDetail(detailId);
if (detailId.equals(LIST_DETAIL_OTHEROU)) {
boolean visible = hasPrincipalsInOtherOus()
&& getList().getMetadata().getItemDetailDefinition(LIST_DETAIL_OTHEROU).isVisible();
getList().getMetadata().getColumnDefinition(LIST_COLUMN_ORGUNIT).setVisible(visible);
getList().getMetadata().getColumnDefinition(LIST_COLUMN_ORGUNIT).setPrintable(visible);
}
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setColumns(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setColumns(CmsListMetadata metadata) {
// create column for icon display
CmsListColumnDefinition iconCol = new CmsListColumnDefinition(LIST_COLUMN_ICON);
iconCol.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_COLS_ICON_0));
iconCol.setHelpText(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_COLS_ICON_HELP_0));
iconCol.setWidth("20");
iconCol.setAlign(CmsListColumnAlignEnum.ALIGN_CENTER);
iconCol.setSorteable(false);
// set icon action
CmsListDirectAction iconAction = new CmsListDirectAction(LIST_ACTION_ICON) {
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
*/
public String getIconPath() {
return ((CmsPrincipalSelectionList)getWp()).getIconPath(getItem());
}
};
iconAction.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_ICON_NAME_0));
iconAction.setHelpText(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_ICON_HELP_0));
iconAction.setEnabled(false);
iconCol.addDirectAction(iconAction);
// add it to the list definition
metadata.addColumn(iconCol);
CmsListColumnDefinition loginCol = new CmsListColumnDefinition(LIST_COLUMN_NAME);
loginCol.setVisible(false);
metadata.addColumn(loginCol);
loginCol.setPrintable(false);
// create column for display name
CmsListColumnDefinition displayNameCol = new CmsListColumnDefinition(LIST_COLUMN_DISPLAY);
displayNameCol.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_COLS_NAME_0));
displayNameCol.setWidth("40%");
displayNameCol.setListItemComparator(LIST_ITEM_COMPARATOR);
CmsListDefaultAction selectAction = new A_CmsListDefaultJsAction(LIST_ACTION_SELECT) {
/**
* @see org.opencms.workplace.list.A_CmsListDirectJsAction#jsCode()
*/
public String jsCode() {
return "window.opener.setPrincipalFormValue("
+ (((CmsPrincipalSelectionList)getWp()).isShowingUsers() ? 1 : 0)
+ ",'"
+ getItem().get(LIST_COLUMN_NAME)
+ "'); window.opener.focus(); window.close();";
}
};
selectAction.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_ACTION_SELECT_NAME_0));
selectAction.setHelpText(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_ACTION_SELECT_HELP_0));
displayNameCol.addDefaultAction(selectAction);
// add it to the list definition
metadata.addColumn(displayNameCol);
// create column for description
CmsListColumnDefinition descriptionCol = new CmsListColumnDefinition(LIST_COLUMN_DESCRIPTION);
descriptionCol.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_COLS_DESCRIPTION_0));
descriptionCol.setWidth("60%");
descriptionCol.setTextWrapping(true);
descriptionCol.setListItemComparator(LIST_ITEM_COMPARATOR);
// add it to the list definition
metadata.addColumn(descriptionCol);
// create column for org unit
CmsListColumnDefinition ouCol = new CmsListColumnDefinition(LIST_COLUMN_ORGUNIT);
ouCol.setName(Messages.get().container(Messages.GUI_PRINCIPALSELECTION_LIST_COLS_ORGUNIT_0));
ouCol.setWidth("40%");
ouCol.setTextWrapping(true);
ouCol.setListItemComparator(LIST_ITEM_COMPARATOR);
// add it to the list definition
metadata.addColumn(ouCol);
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setIndependentActions(CmsListMetadata metadata) {
// add other ou button
CmsListItemDetails otherOuDetails = new CmsListItemDetails(LIST_DETAIL_OTHEROU);
otherOuDetails.setVisible(false);
otherOuDetails.setHideAction(new CmsListIndependentAction(LIST_DETAIL_OTHEROU) {
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getHelpText()
*/
public CmsMessageContainer getHelpText() {
if (getWp().getList().getMetadata().getIndependentAction(LIST_IACTION_USERS).isVisible()) {
return Messages.get().container(Messages.GUI_GROUPS_DETAIL_HIDE_OTHEROU_HELP_0);
} else {
return Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_OTHEROU_HELP_0);
}
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
*/
public String getIconPath() {
return A_CmsListDialog.ICON_DETAILS_HIDE;
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getName()
*/
public CmsMessageContainer getName() {
if (getWp().getList().getMetadata().getIndependentAction(LIST_IACTION_USERS).isVisible()) {
return Messages.get().container(Messages.GUI_GROUPS_DETAIL_HIDE_OTHEROU_NAME_0);
} else {
return Messages.get().container(Messages.GUI_USERS_DETAIL_HIDE_OTHEROU_NAME_0);
}
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
*/
public boolean isVisible() {
return ((CmsPrincipalSelectionList)getWp()).hasPrincipalsInOtherOus();
}
});
otherOuDetails.setShowAction(new CmsListIndependentAction(LIST_DETAIL_OTHEROU) {
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getHelpText()
*/
public CmsMessageContainer getHelpText() {
if (getWp().getList().getMetadata().getIndependentAction(LIST_IACTION_USERS).isVisible()) {
return Messages.get().container(Messages.GUI_GROUPS_DETAIL_SHOW_OTHEROU_HELP_0);
} else {
return Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_OTHEROU_HELP_0);
}
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getIconPath()
*/
public String getIconPath() {
return A_CmsListDialog.ICON_DETAILS_SHOW;
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#getName()
*/
public CmsMessageContainer getName() {
if (getWp().getList().getMetadata().getIndependentAction(LIST_IACTION_USERS).isVisible()) {
return Messages.get().container(Messages.GUI_GROUPS_DETAIL_SHOW_OTHEROU_NAME_0);
} else {
return Messages.get().container(Messages.GUI_USERS_DETAIL_SHOW_OTHEROU_NAME_0);
}
}
/**
* @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible()
*/
public boolean isVisible() {
return ((CmsPrincipalSelectionList)getWp()).hasPrincipalsInOtherOus();
}
});
otherOuDetails.setName(Messages.get().container(Messages.GUI_PRINCIPALS_DETAIL_OTHEROU_NAME_0));
otherOuDetails.setFormatter(new CmsListItemDetailsFormatter(Messages.get().container(
Messages.GUI_PRINCIPALS_DETAIL_OTHEROU_NAME_0)));
metadata.addItemDetails(otherOuDetails);
CmsListIndependentAction usersAction = new CmsListIndependentAction(LIST_IACTION_USERS);
usersAction.setName(Messages.get().container(Messages.GUI_PRINCIPALS_IA_USERS_NAME_0));
usersAction.setHelpText(Messages.get().container(Messages.GUI_PRINCIPALS_IA_USERS_HELP_0));
usersAction.setIconPath(PATH_BUTTONS + "user.png");
usersAction.setVisible(true);
metadata.addIndependentAction(usersAction);
CmsListIndependentAction groupsAction = new CmsListIndependentAction(LIST_IACTION_GROUPS);
groupsAction.setName(Messages.get().container(Messages.GUI_PRINCIPALS_IA_GROUPS_NAME_0));
groupsAction.setHelpText(Messages.get().container(Messages.GUI_PRINCIPALS_IA_GROUPS_HELP_0));
groupsAction.setIconPath(PATH_BUTTONS + "group.png");
groupsAction.setVisible(false);
metadata.addIndependentAction(groupsAction);
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
*/
protected void setMultiActions(CmsListMetadata metadata) {
// no-op
}
/**
* @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters()
*/
protected void validateParamaters() throws Exception {
try {
Integer.valueOf(getParamFlags());
} catch (Throwable e) {
setParamFlags(null);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?