/** * Returns a list for the indexed select box.<p> * * @return a list for the indexed select box */ private List<CmsSelectWidgetOption> getTokenizedWidgetConfiguration() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); result.add(new CmsSelectWidgetOption("true", true)); result.add(new CmsSelectWidgetOption("false", false)); result.add(new CmsSelectWidgetOption("untokenized", false)); return result; } }
/** * @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_CmsADEWidget#getConfiguration(org.opencms.file.CmsObject, org.opencms.xml.types.A_CmsXmlContentValue, org.opencms.i18n.CmsMessages, org.opencms.file.CmsResource, java.util.Locale) */ @Override public String getConfiguration( CmsObject cms, A_CmsXmlContentValue schemaType, CmsMessages messages, CmsResource resource, Locale contentLocale) { return CmsSelectWidgetOption.createConfigurationString( CmsSelectWidgetOption.parseOptions(createConfiguration())); }
/** * 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; } }
options.add(new CmsSelectWidgetOption("", true, getMessage(cms, Messages.GUI_FORMATTER_EMPTY_SELECTION_0))); List<CmsSelectWidgetOption> formatterOptions = getFormatterOptions(cms, adeConfig, path, allRemoved); options.addAll(formatterOptions); options.addAll(typeOptions); for (CmsSelectWidgetOption option : options) { added.add(option.getValue()); I_CmsFormatterBean formatter = cacheState.getFormatters().get(mapKey); if (formatter != null) { title = A_CmsFormatterWidget.getWidgetOptionForFormatter(cms, formatter).getOption(); CmsSelectWidgetOption option = new CmsSelectWidgetOption(formatterKey, false, title); if (!added.contains(option.getValue())) { options.add(option);
String[] parts = splitOptions(input); List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(parts.length); result.add(new CmsSelectWidgetOption(value, isDefault, option, help));
/** * @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 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; }
/** * Converts a list of select widget options to the configuration string as expected on the client side of the widget. * @param options the options to convert * @return the configuration String as expected on the client side of the widget. * * @deprecated use {@link CmsSelectWidgetOption#createConfigurationString(List)}. */ @Deprecated String optionsToConfigurationString(final List<CmsSelectWidgetOption> options) { return CmsSelectWidgetOption.createConfigurationString(options); }
/** * @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; }
/** * 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; } }
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object arg0, Object arg1) { CmsSelectWidgetOption o1 = (CmsSelectWidgetOption)arg0; CmsSelectWidgetOption o2 = (CmsSelectWidgetOption)arg1; return m_collator.compare(o1.getOption(), o2.getOption()); } });
/** * 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; }
/** * @see org.opencms.widgets.A_CmsWidget#getConfiguration() */ @Override public String getConfiguration() { if (super.getConfiguration() != null) { return super.getConfiguration(); } return CmsSelectWidgetOption.createConfigurationString(m_selectOptions); }
/** * Returns the list of default destinations for export points.<p> * * The result list elements are of type <code>{@link org.opencms.widgets.CmsSelectWidgetOption}</code>.<p> * * @return the list of default destinations for export points */ private List getDestinations() { List result = new ArrayList(); result.add(new CmsSelectWidgetOption("WEB-INF/classes/")); result.add(new CmsSelectWidgetOption("WEB-INF/lib/")); return result; }
/** * @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(); }
/** * @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; }
/** * 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; }