📄 cmspreferences.java
字号:
// now determine if the dialog has to be closed or not
try {
if (DIALOG_SET.equals(getParamAction())) {
// after "set" action, leave dialog open
Map params = new HashMap();
params.put(PARAM_TAB, String.valueOf(getActiveTab()));
params.put(PARAM_SETPRESSED, Boolean.TRUE.toString());
sendForward(getJsp().getRequestContext().getUri(), params);
} else {
// forward to dialog with action set to reload the workplace
Map params = new HashMap();
params.put(PARAM_ACTION, DIALOG_RELOAD);
sendForward(getJsp().getRequestContext().getUri(), params);
}
} catch (IOException e) {
// error during forward, do nothing
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
} catch (ServletException e) {
// error during forward, do nothing
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
}
/**
* Builds the html for the default copy file mode select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the default copy file mode select box
*/
public String buildSelectCopyFileMode(String htmlAttributes) {
List options = new ArrayList(2);
options.add(key(Messages.GUI_PREF_COPY_AS_SIBLING_0));
options.add(key(Messages.GUI_COPY_AS_NEW_0));
List values = new ArrayList(2);
values.add(String.valueOf(CmsResource.COPY_AS_SIBLING));
values.add(String.valueOf(CmsResource.COPY_AS_NEW));
int selectedIndex = values.indexOf(getParamTabDiCopyFileMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the default copy folder mode select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the default copy folder mode select box
*/
public String buildSelectCopyFolderMode(String htmlAttributes) {
List options = new ArrayList(3);
options.add(key(Messages.GUI_PREF_COPY_AS_SIBLINGS_0));
options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_RESOURCES_0));
options.add(key(Messages.GUI_PREF_COPY_AS_NEW_0));
List values = new ArrayList(3);
values.add(String.valueOf(CmsResource.COPY_AS_SIBLING));
values.add(String.valueOf(CmsResource.COPY_PRESERVE_SIBLING));
values.add(String.valueOf(CmsResource.COPY_AS_NEW));
int selectedIndex = values.indexOf(getParamTabDiCopyFolderMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the default delete file mode select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the default delete file mode select box
*/
public String buildSelectDeleteFileMode(String htmlAttributes) {
List options = new ArrayList(2);
options.add(key(Messages.GUI_PREF_PRESERVE_SIBLINGS_0));
options.add(key(Messages.GUI_PREF_DELETE_SIBLINGS_0));
List values = new ArrayList(2);
values.add(String.valueOf(CmsResource.DELETE_PRESERVE_SIBLINGS));
values.add(String.valueOf(CmsResource.DELETE_REMOVE_SIBLINGS));
int selectedIndex = values.indexOf(getParamTabDiDeleteFileMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the direct edit button style select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the direct edit button style select box
*/
public String buildSelectDirectEditButtonStyle(String htmlAttributes) {
int selectedIndex = Integer.parseInt(getParamTabEdDirectEditButtonStyle());
return buildSelectButtonStyle(htmlAttributes, selectedIndex);
}
/**
* Builds the html for the editor button style select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the editor button style select box
*/
public String buildSelectEditorButtonStyle(String htmlAttributes) {
int selectedIndex = Integer.parseInt(getParamTabEdButtonStyle());
return buildSelectButtonStyle(htmlAttributes, selectedIndex);
}
/**
* Builds the html for the explorer button style select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the explorer button style select box
*/
public String buildSelectExplorerButtonStyle(String htmlAttributes) {
int selectedIndex = Integer.parseInt(getParamTabExButtonStyle());
return buildSelectButtonStyle(htmlAttributes, selectedIndex);
}
/**
* Builds the html for the explorer number of entries per page select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the explorer number of entries per page select box
*/
public String buildSelectExplorerFileEntries(String htmlAttributes) {
String[] opts = new String[] {"10", "25", "50", "100", key(Messages.GUI_LABEL_UNLIMITED_0)};
List options = new ArrayList(java.util.Arrays.asList(opts));
String[] vals = new String[] {"10", "25", "50", "100", "" + Integer.MAX_VALUE};
int selectedIndex = 2;
for (int i = 0; i < vals.length; i++) {
if (vals[i].equals(getParamTabExFileEntries())) {
selectedIndex = i;
}
}
List values = new ArrayList(java.util.Arrays.asList(vals));
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the task startup filter select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the task startup filter select box
*/
public String buildSelectFilter(String htmlAttributes) {
List options = new ArrayList(16);
List values = new ArrayList(16);
int selectedIndex = -1;
int counter = 0;
for (int i = 1; i < 4; i++) {
for (char k = 'a'; k < 'd'; k++) {
options.add(key(
Messages.getTaskKey(CmsTaskService.TASK_FILTER + k + i)));
values.add("" + k + i);
if (("" + k + i).equals(getParamTabWfFilter())) {
selectedIndex = counter;
}
counter++;
}
options.add(SPACER);
values.add("");
counter++;
}
for (int i = 1; i < 4; i++) {
options.add(key(Messages.getTaskKey(CmsTaskService.TASK_FILTER + "d" + i)));
values.add("d" + i);
if (("d" + i).equals(getParamTabWfFilter())) {
selectedIndex = counter;
}
counter++;
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the language select box of the start settings.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the language select box
*/
public String buildSelectLanguage(String htmlAttributes) {
// get available locales from the workplace manager
List locales = OpenCms.getWorkplaceManager().getLocales();
List options = new ArrayList(locales.size());
List values = new ArrayList(locales.size());
int checkedIndex = 0;
int counter = 0;
Iterator i = locales.iterator();
Locale setLocale = getSettings().getUserSettings().getLocale();
while (i.hasNext()) {
Locale currentLocale = (Locale)i.next();
// add all locales to the select box
String language = currentLocale.getDisplayLanguage(setLocale);
if (CmsStringUtil.isNotEmpty(currentLocale.getCountry())) {
language = language + " (" + currentLocale.getDisplayCountry(setLocale) + ")";
}
if (CmsStringUtil.isNotEmpty(currentLocale.getVariant())) {
language = language + " (" + currentLocale.getDisplayVariant(setLocale) + ")";
}
options.add(language);
values.add(currentLocale.toString());
if (getParamTabWpLanguage().equals(currentLocale.toString())) {
// mark the currently active locale
checkedIndex = counter;
}
counter++;
}
return buildSelect(htmlAttributes, options, values, checkedIndex);
}
/**
* Builds the html for the preferred editors select boxes of the editor settings.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the preferred editors select boxes
*/
public String buildSelectPreferredEditors(String htmlAttributes) {
StringBuffer result = new StringBuffer(1024);
HttpServletRequest request = getJsp().getRequest();
if (htmlAttributes != null) {
htmlAttributes += " name=\"" + PARAM_PREFERREDEDITOR_PREFIX;
}
Map resourceEditors = OpenCms.getWorkplaceManager().getWorkplaceEditorManager().getConfigurableEditors();
if (resourceEditors != null) {
// first: iterate over the resource types and consider order from configuration
Iterator i = resourceEditors.keySet().iterator();
SortedMap rankResources = new TreeMap();
while (i.hasNext()) {
String currentResourceType = (String)i.next();
CmsExplorerTypeSettings settings = OpenCms.getWorkplaceManager().getExplorerTypeSetting(
currentResourceType);
rankResources.put(new Float(settings.getNewResourceOrder()), currentResourceType);
}
while (rankResources.size() > 0) {
// get editor configuration with lowest order
Float keyVal = (Float)rankResources.firstKey();
String currentResourceType = (String)rankResources.get(keyVal);
SortedMap availableEditors = (TreeMap)resourceEditors.get(currentResourceType);
if (availableEditors != null && availableEditors.size() > 0) {
String preSelection = computeEditorPreselection(request, currentResourceType);
List options = new ArrayList(availableEditors.size() + 1);
List values = new ArrayList(availableEditors.size() + 1);
options.add(key(Messages.GUI_PREF_EDITOR_BEST_0));
values.add(INPUT_DEFAULT);
// second: iteration over the available editors for the resource type
int selectedIndex = 0;
int counter = 1;
while (availableEditors.size() > 0) {
Float key = (Float)availableEditors.lastKey();
CmsWorkplaceEditorConfiguration conf = (CmsWorkplaceEditorConfiguration)availableEditors.get(key);
options.add(keyDefault(conf.getEditorLabel(), conf.getEditorLabel()));
values.add(conf.getEditorUri());
if (conf.getEditorUri().equals(preSelection)) {
selectedIndex = counter;
}
counter++;
availableEditors.remove(key);
}
// create the table row for the current resource type
result.append("<tr>\n\t<td style=\"white-space: nowrap;\">");
String localizedName = CmsWorkplaceMessages.getResourceName(this, currentResourceType);
result.append(localizedName);
result.append("</td>\n\t<td>");
result.append(buildSelect(
htmlAttributes + currentResourceType + "\"",
options,
values,
selectedIndex));
result.append("</td>\n</tr>\n");
}
rankResources.remove(keyVal);
}
}
return result.toString();
}
/**
* Builds the html for the project select box of the start settings.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the project select box
*/
public String buildSelectProject(String htmlAttributes) {
try {
List allProjects = getCms().getAllAccessibleProjects();
List options = new ArrayList(allProjects.size());
List values = new ArrayList(allProjects.size());
int checkedIndex = 0;
String startProject = "";
startProject = getParamTabWpProject();
for (int i = 0, n = allProjects.size(); i < n; i++) {
CmsProject project = (CmsProject)allProjects.get(i);
options.add(project.getName());
//values.add("" + project.getId());
values.add(project.getName());
if (startProject.equals(project.getName())) {
checkedIndex = i;
}
}
return buildSelect(htmlAttributes, options, values, checkedIndex);
} catch (CmsException e) {
// should usually never happen
LOG.error(e.getLocalizedMessage());
return getSettings().getProject() + "";
}
}
/**
* Builds the html for the default publish siblings mode select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the default publish siblings mode select box
*/
public String buildSelectPublishSiblings(String htmlAttributes) {
List options = new ArrayList(2);
options.add(key(Messages.GUI_PREF_PUBLISH_SIBLINGS_0));
options.add(key(Messages.GUI_PREF_PUBLISH_ONLY_SELECTED_0));
List values = new ArrayList(2);
values.add(CmsStringUtil.TRUE);
values.add(CmsStringUtil.FALSE);
int selectedIndex = values.indexOf(getParamTabDiPublishFileMode());
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the workplace report type select box.<p>
*
* @param htmlAttributes optional html attributes for the &lgt;select> tag
* @return the html for the workplace report type select box
*/
public String buildSelectReportType(String htmlAttributes) {
List options = new ArrayList(2);
options.add(key(Messages.GUI_LABEL_SIMPLE_0));
options.add(key(Messages.GUI_LABEL_EXTENDED_0));
String[] vals = new String[] {I_CmsReport.REPORT_TYPE_SIMPLE, I_CmsReport.REPORT_TYPE_EXTENDED};
List values = new ArrayList(java.util.Arrays.asList(vals));
int selectedIndex = 0;
if (I_CmsReport.REPORT_TYPE_EXTENDED.equals(getParamTabWpReportType())) {
selectedIndex = 1;
}
return buildSelect(htmlAttributes, options, values, selectedIndex);
}
/**
* Builds the html for the workplace start site select box.<p>
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -