📄 cmspropertyadvanced.java
字号:
}
/**
* Performs the define property action, will be called by the JSP page.<p>
*
* @throws JspException if problems including sub-elements occur
*/
public void actionDefine() throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
performDefineOperation();
// set the request parameters before returning to the overview
setParamAction(DIALOG_SHOW_DEFAULT);
setParamNewproperty(null);
sendForward(CmsWorkplace.VFS_PATH_COMMONS + "property_advanced.jsp", paramsAsParameterMap());
} catch (Throwable e) {
// error defining property, show error dialog
includeErrorpage(this, e);
}
}
/**
* Deletes the current resource if the dialog is in wizard mode.<p>
*
* If the dialog is not in wizard mode, the resource is not deleted.<p>
*
* @throws JspException if including the error page fails
*/
public void actionDeleteResource() throws JspException {
if (getParamDialogmode() != null && getParamDialogmode().startsWith(MODE_WIZARD)) {
// only delete resource if dialog mode is a wizard mode
try {
getCms().deleteResource(getParamResource(), CmsResource.DELETE_PRESERVE_SIBLINGS);
} catch (Throwable e) {
// error deleting the resource, show error dialog
includeErrorpage(this, e);
}
}
}
/**
* Performs the edit properties action, will be called by the JSP page.<p>
*
* @param request the HttpServletRequest
* @throws JspException if problems including sub-elements occur
*/
public void actionEdit(HttpServletRequest request) throws JspException {
// save initialized instance of this class in request attribute for included sub-elements
getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this);
try {
if (isEditable()) {
performDialogOperation(request);
}
} catch (Throwable e) {
// error editing property, show error dialog
includeErrorpage(this, e);
}
}
/**
* Creates the HTML String for the active properties overview of the current resource.<p>
*
* @return the HTML output String for active properties of the resource
*/
public String buildActivePropertiesList() {
StringBuffer retValue = new StringBuffer(256);
List propertyDef = new ArrayList();
try {
// get all property definitions
propertyDef = getCms().readAllPropertyDefinitions();
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
Iterator j = propertyDef.iterator();
int i = 0;
while (j.hasNext()) {
CmsPropertyDefinition curProperty = (CmsPropertyDefinition)j.next();
retValue.append(CmsEncoder.escapeXml(curProperty.getName()));
if ((i + 1) < propertyDef.size()) {
retValue.append("<br>");
}
i++;
}
return retValue.toString();
}
/**
* Creates the HTML String for the edit properties form.<p>
*
* The values of the form are set delayed, have a look at the
* JavaDoc of buildSetFormValues() for a detailed description.<p>
*
* @return the HTML output String for the edit properties form
*/
public String buildEditForm() {
StringBuffer result = new StringBuffer(4096);
// get currently active tab
String activeTab = getActiveTabName();
// initialize "disabled" attribute for the input fields
String disabled = "";
if (!isEditable()) {
disabled = " disabled=\"disabled\"";
}
// get all properties for the resource
List properties = getPropertyValues();
// check for presence of property definitions, should always be true
if (properties.size() > 0) {
// there are properties defined for this resource, build the form list
result.append("<table border=\"0\">\n");
result.append("<tr>\n");
result.append("\t<td class=\"textbold\">");
result.append(key(Messages.GUI_PROPERTY_0));
result.append("</td>\n");
result.append("\t<td class=\"textbold\">");
result.append(key(Messages.GUI_PROPERTY_VALUE_0));
result.append("</td>\n");
result.append("\t<td class=\"textbold\" style=\"white-space: nowrap;\">");
result.append(key(Messages.GUI_PROPERTY_USED_0));
result.append("</td>\n");
result.append("</tr>\n");
result.append("<tr><td colspan=\"3\"><span style=\"height: 6px;\"></span></td></tr>\n");
// show all possible properties for the resource
Iterator i = properties.iterator();
while (i.hasNext()) {
String[] curProp = (String[])i.next();
// create a single property row
result.append(buildPropertyRow(curProp[0], curProp[1], curProp[2], curProp[3], disabled, activeTab));
}
result.append("</table>");
} else {
// there are no properties defined for this resource, show nothing (should never happen)
result.append(key(Messages.GUI_PROPERTY_ADVANCED_NO_PROPDEFS_0));
}
return result.toString();
}
/**
* Builds the JavaScript to set the property form values delayed.<p>
*
* The values of the properties are not inserted directly in the <input> tag,
* because there is a display issue when the property values are very long.
* This method creates JavaScript to set the property input field values delayed.
* On the JSP, the code which is created from this method has to be executed delayed after
* the creation of the html form, e.g. in the <body> tag with the attribute
* onload="window.setTimeout('doSet()',50);".<p>
*
* @return the JavaScript to set the property form values delayed
*/
public String buildSetFormValues() {
StringBuffer result = new StringBuffer(1024);
// get currently active tab
String activeTab = getActiveTabName();
// get structure panel name
String structurePanelName = key(Messages.GUI_PROPERTIES_INDIVIDUAL_0);
Iterator i = getPropertyValues().iterator();
while (i.hasNext()) {
String[] curProp = (String[])i.next();
// determine the shown value
String shownValue = curProp[1];
// in "shared properties" form, show resource value if no structure value is set
if (structurePanelName.equals(activeTab) && "".equals(curProp[2]) && !"".equals(curProp[3])) {
shownValue = curProp[3];
}
if (!"".equals(shownValue)) {
// create the JS output for a single property if not empty
result.append("\tdocument.getElementById(\"");
result.append(PREFIX_VALUE);
result.append(curProp[0]);
result.append("\").value = \"");
result.append(CmsStringUtil.escapeJavaScript(shownValue));
result.append("\";\n");
}
}
return result.toString();
}
/**
* Builds a button row with an "Ok", a "Cancel" and a "Define" button.<p>
*
* @return the button row
*/
public String dialogButtonsOkCancelDefine() {
if (isEditable()) {
int okButton = BUTTON_OK;
if (getParamDialogmode() != null && getParamDialogmode().startsWith(MODE_WIZARD)) {
// in wizard mode, display finish button instead of ok button
okButton = BUTTON_FINISH;
}
return dialogButtons(new int[] {okButton, BUTTON_CANCEL, BUTTON_DEFINE}, new String[] {
null,
null,
"onclick=\"definePropertyForm();\""});
} else {
return dialogButtons(new int[] {BUTTON_CLOSE}, new String[] {null});
}
}
/**
* @see org.opencms.workplace.I_CmsDialogHandler#getDialogHandler()
*/
public String getDialogHandler() {
return CmsDialogSelector.DIALOG_PROPERTY;
}
/**
* @see org.opencms.workplace.I_CmsDialogHandler#getDialogUri(java.lang.String, CmsJspActionElement)
*/
public String getDialogUri(String resource, CmsJspActionElement jsp) {
try {
CmsResource res = jsp.getCmsObject().readResource(resource, CmsResourceFilter.ALL);
if (res.getTypeId() == CmsResourceTypeXmlPage.getStaticTypeId()) {
// display special property dialog for xmlpage types
return PATH_WORKPLACE + "editors/dialogs/property.jsp";
}
String resTypeName = OpenCms.getResourceManager().getResourceType(res.getTypeId()).getTypeName();
// get settings for resource type
CmsExplorerTypeSettings settings = getSettingsForType(resTypeName);
if (settings.isPropertiesEnabled()) {
// special properties for this type enabled, display customized dialog
return URI_PROPERTY_CUSTOM_DIALOG;
}
} catch (CmsException e) {
// should usually never happen
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
return URI_PROPERTY_DIALOG;
}
/**
* Returns the value of the dialogmode parameter,
* or null if this parameter was not provided.<p>
*
* The dialogmode parameter stores the different modes of the property dialog,
* e.g. for displaying other buttons in the new resource wizard.<p>
*
* @return the value of the usetempfileproject parameter
*/
public String getParamDialogmode() {
return m_paramDialogMode;
}
/**
* Returns the value of the new property parameter,
* or null if this parameter was not provided.<p>
*
* The new property parameter stores the name of the
* new defined property.<p>
*
* @return the value of the new property parameter
*/
public String getParamNewproperty() {
return m_paramNewproperty;
}
/**
* Returns the value of the usetempfileproject parameter,
* or null if this parameter was not provided.<p>
*
* The usetempfileproject parameter stores if the file resides
* in the temp file project.<p>
*
* @return the value of the usetempfileproject parameter
*/
public String getParamUsetempfileproject() {
return m_paramUseTempfileProject;
}
/**
* @see org.opencms.workplace.CmsTabDialog#getTabParameterOrder()
*/
public List getTabParameterOrder() {
ArrayList orderList = new ArrayList(2);
orderList.add(TAB_STRUCTURE);
orderList.add(TAB_RESOURCE);
return orderList;
}
/**
* @see org.opencms.workplace.CmsTabDialog#getTabs()
*/
public List getTabs() {
ArrayList tabList = new ArrayList(2);
if (OpenCms.getWorkplaceManager().isEnableAdvancedPropertyTabs()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -