📄 cmspropertyadvanced.java
字号:
// tabs are enabled, show both tabs except for folders
if (m_isFolder) {
// resource is a folder, show only the individual properties tab
tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
} else {
// resource is no folder, show both tabs
tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
tabList.add(key(Messages.GUI_PROPERTIES_SHARED_0));
}
} else {
// tabs are disabled, show only the configured tab except for folders
if (m_isFolder || OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
tabList.add(key(Messages.GUI_PROPERTIES_INDIVIDUAL_0));
} else {
tabList.add(key(Messages.GUI_PROPERTIES_SHARED_0));
}
}
return tabList;
}
/**
* Sets the value of the dialogmode parameter.<p>
*
* @param value the value to set
*/
public void setParamDialogmode(String value) {
m_paramDialogMode = value;
}
/**
* Sets the value of the new property parameter.<p>
*
* @param value the value to set
*/
public void setParamNewproperty(String value) {
m_paramNewproperty = value;
}
/**
* Sets the value of the usetempfileproject parameter.<p>
*
* @param value the value to set
*/
public void setParamUsetempfileproject(String value) {
m_paramUseTempfileProject = value;
}
/**
* @see org.opencms.workplace.CmsDialog#dialogButtonsHtml(java.lang.StringBuffer, int, java.lang.String)
*/
protected void dialogButtonsHtml(StringBuffer result, int button, String attribute) {
attribute = appendDelimiter(attribute);
switch (button) {
case BUTTON_DEFINE:
result.append("<input name=\"define\" type=\"button\" value=\"");
result.append(key(Messages.GUI_PROPERTY_DEFINE_0));
result.append("\" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
case BUTTON_FINISH:
result.append("<input name=\"finish\" type=\"submit\" value=\"");
result.append(key(Messages.GUI_PROPERTY_FINISH_0));
result.append("\" class=\"dialogbutton\"");
result.append(attribute);
result.append(">\n");
break;
default:
super.dialogButtonsHtml(result, button, attribute);
}
}
/**
* Returns the explorer type settings of the resource type, considering eventual references to another type.<p>
*
* @param resTypeName the resource type name
* @return the explorer type settings of the resource type
*/
protected CmsExplorerTypeSettings getSettingsForType(String resTypeName) {
// get settings for resource type
CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(resTypeName);
if (CmsStringUtil.isNotEmpty(settings.getReference())) {
// refers to another resource type, get settings of referred type
settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(settings.getReference());
}
return settings;
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// fill the parameter values in the get/set methods
fillParamValues(request);
// get the active tab from request parameter or display first tab
getActiveTab();
// check the resource type of the edited resource
m_isFolder = false;
try {
CmsResource resource = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
if (resource.isFolder()) {
m_isFolder = true;
if (!getParamResource().endsWith("/")) {
// append folder separator to resource name
setParamResource(getParamResource() + "/");
}
}
} catch (CmsException e) {
// error reading resource, log the error
LOG.error(e.getLocalizedMessage());
}
// set the dialog type
setParamDialogtype(DIALOG_TYPE);
boolean isPopup = Boolean.valueOf(getParamIsPopup()).booleanValue();
// set the action for the JSP switch
if (DIALOG_SHOW_DEFINE.equals(getParamAction())) {
setAction(ACTION_SHOW_DEFINE);
setParamTitle(key(Messages.GUI_PROPERTY_NEW_DEF_1, new Object[] {CmsResource.getName(getParamResource())}));
} else if (DIALOG_SAVE_EDIT.equals(getParamAction())) {
if (isPopup) {
setAction(ACTION_CLOSEPOPUP_SAVE);
} else {
setAction(ACTION_SAVE_EDIT);
}
} else if (DIALOG_SAVE_DEFINE.equals(getParamAction())) {
setAction(ACTION_SAVE_DEFINE);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
if (isPopup) {
setAction(ACTION_CLOSEPOPUP);
} else {
setAction(ACTION_CANCEL);
}
} else {
// set the default action: show edit form
setAction(ACTION_DEFAULT);
if (!isEditable()) {
setParamTitle(key(Messages.GUI_PROPERTIES_OF_1,
new Object[] {CmsResource.getName(getParamResource())}));
} else {
setParamTitle(key(Messages.GUI_PROPERTIES_EDIT_1,
new Object[] {CmsResource.getName(getParamResource())}));
}
// check if the user switched a tab
m_tabSwitched = false;
if (DIALOG_SWITCHTAB.equals(getParamAction())) {
m_tabSwitched = true;
}
}
}
/**
* Returns whether the properties are editable or not depending on the lock state of the resource and the current project.<p>
*
* @return true if properties are editable, otherwise false
*/
protected boolean isEditable() {
if (m_isEditable == null) {
if (getCms().getRequestContext().currentProject().getId() == CmsProject.ONLINE_PROJECT_ID
|| !getCms().isInsideCurrentProject(getParamResource())) {
// we are in the online project or resource does not belong to project, no editing allowed
m_isEditable = new Boolean(false);
} else {
// we are in an offline project
// check permissions
if (!checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) {
getSettings().setErrorMessage(null);
m_isEditable = new Boolean(false);
return m_isEditable.booleanValue();
}
// check lock state
String resourceName = getParamResource();
CmsResource file = null;
CmsLock lock = null;
try {
file = getCms().readResource(resourceName, CmsResourceFilter.ALL);
// check if resource is a folder
if (file.isFolder() && !resourceName.endsWith("/")) {
resourceName += "/";
}
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
try {
// get the lock for the resource
lock = getCms().getLock(resourceName);
} catch (CmsException e) {
lock = CmsLock.getNullLock();
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
if (!lock.isNullLock()) {
// determine if resource is editable...
if (lock.getType() != CmsLock.TYPE_SHARED_EXCLUSIVE
&& lock.getType() != CmsLock.TYPE_SHARED_INHERITED
&& lock.getUserId().equals(getCms().getRequestContext().currentUser().getId())) {
// lock is not shared and belongs to the current user
if (getCms().getRequestContext().currentProject().getId() == lock.getProjectId()
|| Boolean.valueOf(getParamUsetempfileproject()).booleanValue()) {
// resource is locked in the current project or the tempfileproject is used
m_isEditable = new Boolean(true);
return m_isEditable.booleanValue();
}
}
} else if (OpenCms.getWorkplaceManager().autoLockResources()) {
m_isEditable = new Boolean(true);
return m_isEditable.booleanValue();
}
// lock is null or belongs to other user and/or project, properties are not editable
m_isEditable = new Boolean(false);
}
}
return m_isEditable.booleanValue();
}
/**
* Builds the html for a single property entry row.<p>
*
* The output depends on the currently active tab (shared or individual properties)
* and on the present values of the current property.<p>
*
* The values of the property are not inserted directly in the <input> tag,
* because there is a display issue when the property values are very long.
* Have a look at buildSetFormValues() for a detailed description.<p>
*
* @param propName the name of the property
* @param propValue the displayed value of the property
* @param valueStructure the structure value of the property
* @param valueResource the resource value of the property
* @param disabled contains attribute String to disable the fields
* @param activeTab the name of the currently active dialog tab
* @return the html for a single property entry row
*/
private StringBuffer buildPropertyRow(
String propName,
String propValue,
String valueStructure,
String valueResource,
String disabled,
String activeTab) {
StringBuffer result = new StringBuffer(256);
String structurePanelName = key(Messages.GUI_PROPERTIES_INDIVIDUAL_0);
String inputAttrs = "class=\"maxwidth\"";
if (structurePanelName.equals(activeTab)) {
// in "shared properties" form, show resource value if no structure value is set
if ("".equals(valueStructure) && !"".equals(valueResource)) {
inputAttrs = "class=\"dialogmarkedfield\"";
}
}
result.append("<tr>\n");
result.append("\t<td style=\"white-space: nowrap;\">" + propName);
result.append("</td>\n");
result.append("\t<td class=\"maxwidth\">");
// build text input field
result.append("<input type=\"text\" ");
result.append(inputAttrs);
result.append(" name=\"");
result.append(PREFIX_VALUE);
result.append(propName);
result.append("\" id=\"");
result.append(PREFIX_VALUE);
result.append(propName);
result.append("\"");
result.append(" onFocus=\"deleteResEntry('");
result.append(propName);
result.append("', '");
result.append(activeTab);
result.append("');\"");
result.append(" onBlur=\"checkResEntry('");
result.append(propName);
result.append("', '");
result.append(activeTab);
result.append("');\" onKeyup=\"checkValue('");
result.append(propName);
result.append("', '");
result.append(activeTab);
result.append("');\"");
result.append(disabled);
result.append(">");
// build hidden input field for structure value
result.append("<input type=\"hidden\" name=\"");
result.append(PREFIX_STRUCTURE);
result.append(propName);
result.append("\" id=\"");
result.append(PREFIX_STRUCTURE);
result.append(propName);
result.append("\" value=\"");
result.append(CmsEncoder.escapeXml(valueStructure));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -