/** * Returns the option text of this select option.<p> * * If this has not been set, the result of <code>{@link #getValue()}</code> is returned, * there will always be a result other than <code>null</code> returned.<p> * * @return the option text of this select option */ public String getOption() { if (m_option == null) { return getValue(); } return m_option; }
/** * Returns the option text of this select option.<p> * * If this has not been set, the result of <code>{@link #getValue()}</code> is returned, * there will always be a result other than <code>null</code> returned.<p> * * @return the option text of this select option */ public String getOption() { if (m_option == null) { return getValue(); } return m_option; }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\">"); // get select box options from default value String List<CmsSelectWidgetOption> options = parseSelectOptions(cms, widgetDialog, param); String selected = getSelectedValue(cms, param); Iterator<CmsSelectWidgetOption> i = options.iterator(); while (i.hasNext()) { CmsSelectWidgetOption option = i.next(); // create the option result.append("<input type='radio' name='"); result.append(id); result.append("' value='"); result.append(option.getValue()); result.append("'"); if (selected.indexOf(option.getValue()) >= 0) { result.append(" checked"); } result.append(">"); result.append(option.getOption()); result.append("<br>"); } result.append("</td>"); return result.toString(); }
/** * @see org.opencms.widgets.I_CmsWidget#getDialogWidget(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); StringBuffer result = new StringBuffer(16); result.append("<td class=\"xmlTd\">"); // get select box options from default value String List options = parseSelectOptions(cms, widgetDialog, param); String selected = getSelectedValue(cms, param); Iterator i = options.iterator(); while (i.hasNext()) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)i.next(); // create the option result.append("<input type='radio' name='"); result.append(id); result.append("' value='"); result.append(option.getValue()); result.append("'"); if (selected.indexOf(option.getValue()) >= 0) { result.append(" checked"); } result.append(">"); result.append(option.getOption()); result.append("<br>"); } result.append("</td>"); return result.toString(); }
/** * Returns the currently selected values of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is used.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return a list of the currently selected values of the select widget */ protected List<String> getSelectedValues(CmsObject cms, I_CmsWidgetParameter param) { List<String> values = new ArrayList<String>(); String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { Iterator<CmsSelectWidgetOption> itOptions = CmsSelectWidgetOption.getDefaultOptions( m_selectOptions).iterator(); while (itOptions.hasNext()) { CmsSelectWidgetOption option = itOptions.next(); values.add(option.getValue()); } } else { values.addAll(CmsStringUtil.splitAsList(paramValue, ',', true)); } return values; }
/** * Returns the currently selected values of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is used.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return a list of the currently selected values of the select widget */ protected List getSelectedValues(CmsObject cms, I_CmsWidgetParameter param) { List values = new ArrayList(); String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { Iterator itOptions = CmsSelectWidgetOption.getDefaultOptions(m_selectOptions).iterator(); while (itOptions.hasNext()) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)itOptions.next(); values.add(option.getValue()); } } else { values.addAll(CmsStringUtil.splitAsList(paramValue, ',', true)); } return values; }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param selectOptions the available select options * @param currentValue the current value that is selected * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, List<CmsSelectWidgetOption> selectOptions, String currentValue) { String paramValue = currentValue; if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; } }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param selectOptions the available select options * @param currentValue the current value that is selected * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, List selectOptions, String currentValue) { String paramValue = currentValue; if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; } }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, I_CmsWidgetParameter param) { String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(m_selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; }
/** * Returns the currently selected value of the select widget.<p> * * If a value is found in the given parameter, this is used. Otherwise * the default value of the select options are used. If there is neither a parameter value * nor a default value, <code>null</code> is returned.<p> * * @param cms the current users OpenCms context * @param param the widget parameter of this dialog * * @return the currently selected value of the select widget */ protected String getSelectedValue(CmsObject cms, I_CmsWidgetParameter param) { String paramValue = param.getStringValue(cms); if (CmsStringUtil.isEmpty(paramValue)) { CmsSelectWidgetOption option = CmsSelectWidgetOption.getDefaultOption(m_selectOptions); if (option != null) { paramValue = option.getValue(); } } return paramValue; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = super.getWidgetStringValue(cms, widgetDialog, param); String configuration = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog.getMessages()); if (configuration == null) { configuration = param.getDefault(cms); } List options = CmsSelectWidgetOption.parseOptions(configuration); for (int m = 0; m < options.size(); m++) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)options.get(m); if (result.equals(option.getValue())) { result = option.getOption(); break; } } return result; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = super.getWidgetStringValue(cms, widgetDialog, param); String configuration = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog.getMessages()); if (configuration == null) { configuration = param.getDefault(cms); } List<CmsSelectWidgetOption> options = CmsSelectWidgetOption.parseOptions(configuration); for (int m = 0; m < options.size(); m++) { CmsSelectWidgetOption option = options.get(m); if (result.equals(option.getValue())) { result = option.getOption(); break; } } return result; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = super.getWidgetStringValue(cms, widgetDialog, param); String configuration = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog.getMessages()); if (configuration == null) { configuration = param.getDefault(cms); } List<CmsSelectWidgetOption> options = CmsSelectWidgetOption.parseOptions(configuration); for (int m = 0; m < options.size(); m++) { CmsSelectWidgetOption option = options.get(m); if (result.equals(option.getValue())) { result = option.getOption(); break; } } return result; }
/** * @see org.opencms.widgets.A_CmsWidget#getWidgetStringValue(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter) */ @Override public String getWidgetStringValue(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String result = super.getWidgetStringValue(cms, widgetDialog, param); String configuration = CmsMacroResolver.resolveMacros(getConfiguration(), cms, widgetDialog.getMessages()); if (configuration == null) { configuration = param.getDefault(cms); } List options = CmsSelectWidgetOption.parseOptions(configuration); for (int m = 0; m < options.size(); m++) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)options.get(m); if (result.equals(option.getValue())) { result = option.getOption(); break; } } return result; }
/** * Returns all values that can be selected in the widget. * @param cms the current CMS object * @param rootPath the root path to the currently edited xml file (sitemap config) * @param allRemoved flag, indicating if all inheritedly available formatters should be disabled * @return all values that can be selected in the widget. */ public static List<String> getSelectOptionValues(CmsObject cms, String rootPath, boolean allRemoved) { try { cms = OpenCms.initCmsObject(cms); cms.getRequestContext().setSiteRoot(""); CmsADEConfigData adeConfig = OpenCms.getADEManager().lookupConfiguration(cms, rootPath); if (adeConfig.parent() != null) { adeConfig = adeConfig.parent(); } List<CmsSelectWidgetOption> options = getFormatterOptionsStatic(cms, adeConfig, rootPath, allRemoved); List<CmsSelectWidgetOption> typeOptions = getTypeOptionsStatic(cms, adeConfig, allRemoved); options.addAll(typeOptions); List<String> result = new ArrayList<String>(options.size()); for (CmsSelectWidgetOption o : options) { result.add(o.getValue()); } return result; } catch (CmsException e) { // should never happen LOG.error(e.getLocalizedMessage(), e); return null; } }