cmseditprojectdialog.java
来自「找了很久才找到到源代码」· Java 代码 · 共 573 行 · 第 1/2 页
JAVA
573 行
*
* @param ou ignored
*/
public void setAssignedOu(String ou) {
ou.length(); // prevent warning
}
/**
* Sets the manager Group name.<p>
*
* @param managerGroup the manager Group name to set
*/
public void setManagerGroup(String managerGroup) {
CmsGroup group = checkGroup(managerGroup);
if (group != null) {
m_project.setManagerGroupId(group.getId());
}
}
/**
* Sets the name of the project.<p>
*
* @param name the name to set
*/
public void setName(String name) {
m_project.setName(getOufqn() + "/" + name);
}
/**
* Sets the fully qualified name of the organizational unit.<p>
*
* @param oufqn the fully qualified name of the organizational unit to set
*/
public void setOufqn(String oufqn) {
if (oufqn != null) {
if (oufqn.endsWith("/")) {
oufqn += '/';
}
} else {
oufqn = "";
}
String name = m_project.getSimpleName();
if (name == null) {
name = "";
}
name = oufqn + name;
if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
name = "/";
}
m_project.setName(oufqn + name);
}
/**
* Sets the project id parameter value.<p>
*
* @param projectId the project id parameter value
*/
public void setParamProjectid(String projectId) {
m_paramProjectid = projectId;
}
/**
* Sets the resources of this project.<p>
*
* @param value the project resources to set
*/
public void setResources(List value) {
if (value == null) {
m_resources = new ArrayList();
return;
}
m_resources = CmsFileUtil.removeRedundancies(value);
}
/**
* Sets the user Group name.<p>
*
* @param userGroup the user Group name to set
*/
public void setUserGroup(String userGroup) {
CmsGroup group = checkGroup(userGroup);
if (group != null) {
m_project.setGroupId(group.getId());
}
}
/**
* @see org.opencms.workplace.CmsWidgetDialog#createDialogHtml(java.lang.String)
*/
protected String createDialogHtml(String dialog) {
StringBuffer result = new StringBuffer(1024);
result.append(createWidgetTableStart());
// show error header once if there were validation errors
result.append(createWidgetErrorHeader());
if (dialog.equals(PAGES[0])) {
// create the widgets for the first dialog page
result.append(dialogBlockStart(key(Messages.GUI_PROJECT_EDITOR_LABEL_IDENTIFICATION_BLOCK_0)));
result.append(createWidgetTableStart());
result.append(createDialogRowsHtml(0, 5));
result.append(createWidgetTableEnd());
result.append(dialogBlockEnd());
result.append(dialogBlockStart(key(Messages.GUI_PROJECT_EDITOR_LABEL_CONTENT_BLOCK_0)));
result.append(createWidgetTableStart());
result.append(createDialogRowsHtml(6, 6));
result.append(createWidgetTableEnd());
result.append(dialogBlockEnd());
}
result.append(createWidgetTableEnd());
return result.toString();
}
/**
* Creates the list of widgets for this dialog.<p>
*/
protected void defineWidgets() {
// initialize the project object to use for the dialog
initProjectObject();
setKeyPrefix(KEY_PREFIX);
// widgets to display
if (isNewProject()) {
addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsInputWidget()));
} else {
addWidget(new CmsWidgetDialogParameter(this, "name", PAGES[0], new CmsDisplayWidget()));
}
addWidget(new CmsWidgetDialogParameter(m_project, "description", "", PAGES[0], new CmsTextareaWidget(), 0, 1));
addWidget(new CmsWidgetDialogParameter(this, "managerGroup", PAGES[0], new CmsGroupWidget(new Integer(
I_CmsPrincipal.FLAG_GROUP_PROJECT_MANAGER), null)));
addWidget(new CmsWidgetDialogParameter(this, "userGroup", PAGES[0], new CmsGroupWidget(null, null)));
if (isNewProject()) {
int ous = 1;
try {
ous = OpenCms.getRoleManager().getOrgUnitsForRole(getCms(), CmsRole.PROJECT_MANAGER, true).size();
} catch (CmsException e) {
// should never happen
}
if (ous < 2) {
addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
} else {
addWidget(new CmsWidgetDialogParameter(this, "oufqn", PAGES[0], new CmsOrgUnitWidget(
CmsRole.PROJECT_MANAGER)));
}
} else {
addWidget(new CmsWidgetDialogParameter(this, "assignedOu", PAGES[0], new CmsDisplayWidget()));
}
addWidget(new CmsWidgetDialogParameter(m_project, "deleteAfterPublishing", PAGES[0], new CmsCheckboxWidget()));
addWidget(new CmsWidgetDialogParameter(this, "resources", PAGES[0], new CmsVfsFileWidget(
false,
"",
false,
false)));
}
/**
* @see org.opencms.workplace.CmsWidgetDialog#getPageArray()
*/
protected String[] getPageArray() {
return PAGES;
}
/**
* @see org.opencms.workplace.CmsWorkplace#initMessages()
*/
protected void initMessages() {
// add specific dialog resource bundle
addMessages(Messages.get().getBundleName());
// add default resource bundles
super.initMessages();
}
/**
* Initializes the project object to work with depending on the dialog state and request parameters.<p>
*
* Two initializations of the project object on first dialog call are possible:
* <ul>
* <li>edit an existing project</li>
* <li>create a new project</li>
* </ul>
*/
protected void initProjectObject() {
Object o = null;
try {
if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
// edit an existing project, get the project object from database
m_project = getCms().readProject(new CmsUUID(getParamProjectid()));
m_resources = getCms().readProjectResources(m_project);
} else {
// this is not the initial call, get the project object from session
o = getDialogObject();
Map map = (Map)o;
m_project = (CmsProject)map.get("prj");
// test
m_project.getUuid();
m_resources = (List)map.get("res");
m_resources.isEmpty();
}
} catch (Exception e) {
// create a new project object
m_project = new CmsProject();
m_resources = new ArrayList();
setOufqn(getCms().getRequestContext().getOuFqn());
setUserGroup(getCms().getRequestContext().getOuFqn() + OpenCms.getDefaultUsers().getGroupUsers());
}
}
/**
* Overridden to set a custom online help mapping.<p>
*
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceMembers(org.opencms.jsp.CmsJspActionElement)
*/
protected void initWorkplaceMembers(CmsJspActionElement jsp) {
super.initWorkplaceMembers(jsp);
setOnlineHelpUriCustom("/projects/project_edit.jsp");
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// initialize parameters and dialog actions in super implementation
super.initWorkplaceRequestValues(settings, request);
Map map = new HashMap();
map.put("prj", m_project);
map.put("res", m_resources);
// save the current state of the project (may be changed because of the widget values)
setDialogObject(map);
}
/**
* Checks if the Project overview has to be displayed.<p>
*
* @return <code>true</code> if the project overview has to be displayed
*/
protected boolean isNewProject() {
return getCurrentToolPath().equals("/projects/new");
}
/**
* @see org.opencms.workplace.CmsWidgetDialog#validateParamaters()
*/
protected void validateParamaters() throws Exception {
if (!isNewProject()) {
// test the needed parameters
getCms().readProject(new CmsUUID(getParamProjectid())).getName();
}
}
/**
* Checks if the given group name is a valid opencms user group.<p>
*
* @param groupName the group name to check
*
* @return the read group
*/
private CmsGroup checkGroup(String groupName) {
try {
return getCms().readGroup(groupName);
} catch (CmsException e) {
throw new CmsIllegalArgumentException(e.getMessageContainer());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?