private void persistRawOptions(DeliveryOptions options) { options.setStandardMode(standardModeEl.isSelected(0)); options.setjQueryEnabled(jsOptionEl.isSelected(1)); options.setPrototypeEnabled(jsOptionEl.isSelected(2)); options.setGlossaryEnabled(glossarEl.isAtLeastSelected(1)); options.setHeight(heightEl.getSelectedKey()); }
private void persistEncoding(DeliveryOptions options) { String contentEncoding = encodingContentEl.getSelectedKey(); if (NodeEditController.CONFIG_CONTENT_ENCODING_AUTO.equals(contentEncoding)) { options.setContentEncoding(null); } else { options.setContentEncoding(contentEncoding); } String javascriptEncoding = encodingJSEl.getSelectedKey(); if (NodeEditController.CONFIG_JS_ENCODING_AUTO.equals(javascriptEncoding)) { options.setJavascriptEncoding(null); } else { options.setJavascriptEncoding(javascriptEncoding); } }
public DeliveryOptionsConfigurationController( UserRequest ureq, WindowControl wControl, DeliveryOptions config, DeliveryOptions parentConfig) { super(ureq, wControl); this.config = (config == null ? new DeliveryOptions() : config.clone()); this.parentConfig = parentConfig; initForm(ureq); if (parentConfig != null && config != null && config.getInherit() != null && config.getInherit().booleanValue()) { setValues(parentConfig); } else { setValues(config); } updateEnabled(); }
@Override protected void formOK(UserRequest ureq) { if (parentConfig != null && inheritEl.isVisible() && inheritEl.isSelected(0)) { config = new DeliveryOptions(); config.setInherit(Boolean.TRUE); } else { if (config == null) { config = new DeliveryOptions(); } persistValues(config); } fireEvent(ureq, Event.DONE_EVENT); }
private void persistValues(DeliveryOptions options) { options.setInherit(Boolean.FALSE); if (standardModeEl.isSelected(0)) { // standard mode options.setStandardMode(Boolean.TRUE); options.setjQueryEnabled(Boolean.FALSE); options.setPrototypeEnabled(Boolean.FALSE); options.setGlossaryEnabled(Boolean.FALSE); options.setHeight(heightEl.getSelectedKey()); options.setOpenolatCss(Boolean.FALSE); } else { options.setStandardMode(Boolean.FALSE); // js if (jsOptionEl.isSelected(0)) { options.setjQueryEnabled(Boolean.FALSE); options.setPrototypeEnabled(Boolean.FALSE); options.setGlossaryEnabled(Boolean.FALSE); } else { options.setjQueryEnabled(jsOptionEl.isSelected(1)); options.setPrototypeEnabled(jsOptionEl.isSelected(2)); options.setGlossaryEnabled(glossarEl.isAtLeastSelected(1)); } // css options.setHeight(heightEl.getSelectedKey()); options.setOpenolatCss(cssOptionEl.isSelected(1)); } persistEncoding(config); }
private void setValues(DeliveryOptions cfg) { Boolean mode = (cfg == null ? null : cfg.getStandardMode()); if (mode == null || mode.booleanValue()) { standardModeEl.select("standard", true); } else { standardModeEl.select("configured", true); } if (cfg != null) { if (cfg.getjQueryEnabled() != null && cfg.getjQueryEnabled().booleanValue()) { jsOptionEl.select(jsKeys[1], true); // jQuery } else if (cfg.getPrototypeEnabled() != null && cfg.getPrototypeEnabled().booleanValue()) { jsOptionEl.select(jsKeys[2], true); // prototype } else { jsOptionEl.select(jsKeys[0], true); // default is none } } else { jsOptionEl.select(jsKeys[0], true); // default is none } Boolean glossarEnabled = (cfg == null ? null : cfg.getGlossaryEnabled()); if (glossarEnabled != null && glossarEnabled.booleanValue()) { glossarEl.select("on", true); } String height = cfg == null ? null : cfg.getHeight(); if (height != null && Arrays.asList(keys).contains(height)) { heightEl.select(height, true); } else { heightEl.select(DeliveryOptions.CONFIG_HEIGHT_AUTO, true); } if (cfg != null && cfg.getOpenolatCss() != null && cfg.getOpenolatCss().booleanValue()) { cssOptionEl.select(cssKeys[1], true); } else { cssOptionEl.select(cssKeys[0], false); // default none } String encodingContent = (cfg == null ? null : cfg.getContentEncoding()); if (encodingContent != null && Arrays.asList(encodingContentKeys).contains(encodingContent)) { encodingContentEl.select(encodingContent, true); } else { encodingContentEl.select(NodeEditController.CONFIG_CONTENT_ENCODING_AUTO, true); } String encodingJS = (cfg == null ? null : cfg.getJavascriptEncoding()); if (encodingJS != null && Arrays.asList(encodingJSKeys).contains(encodingJS)) { encodingJSEl.select(encodingJS, true); } else { encodingJSEl.select(NodeEditController.CONFIG_JS_ENCODING_AUTO, true); } }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { setFormTitle("option.desc"); setFormContextHelp( this.getClass().getPackage().getName(), "display-options.html", "chelp.display-options.title"); String[] inheritValues = new String[] {translate("inherit"), translate("custom")}; inheritEl = uifactory.addRadiosVertical("inherit.label", formLayout, inheritKeys, inheritValues); inheritEl.addActionListener(this, FormEvent.ONCHANGE); if (config != null && config.getInherit() != null && config.getInherit().booleanValue()) { inheritEl.select(inheritKeys[0], true); } else { inheritEl.select(inheritKeys[1], true); } if (parentConfig == null) { inheritEl.setVisible(false); } else { inheritEl.setVisible(true); uifactory.addSpacerElement("spacer.mode", formLayout, false); } String[] standardModeValues = new String[] {translate("mode.standard"), translate("mode.configured")}; standardModeEl = uifactory.addRadiosVertical("mode", formLayout, standardModeKeys, standardModeValues); standardModeEl.addActionListener(this, FormEvent.ONCHANGE); uifactory.addSpacerElement("spacer.js", formLayout, false); String[] jsValues = new String[] { translate("option.js.none"), translate("option.js.jQuery"), translate("option.js.prototypejs") }; jsOptionEl = uifactory.addRadiosVertical("option.js", formLayout, jsKeys, jsValues); jsOptionEl.addActionListener(this, FormEvent.ONCHANGE); glossarEl = uifactory.addCheckboxesHorizontal( "option.glossary", formLayout, new String[] {"on"}, new String[] {""}, null); String[] values = new String[] { translate("height.auto"), "460px", "480px", "500px", "520px", "540px", "560px", "580px", "600px", "620px", "640px", "660px", "680px", "700px", "720px", "730px", "760px", "780px", "800px", "820px", "840px", "860px", "880px", "900px", "920px", "940px", "960px", "980px", "1000px", "1020px", "1040px", "1060px", "1080px", "1100px", "1120px", "1140px", "1160px", "1180px", "1200px", "1220px", "1240px", "1260px", "1280px", "1300px", "1320px", "1340px", "1360px", "1380px" }; heightEl = uifactory.addDropdownSingleselect("height", "height.label", formLayout, keys, values, null); String[] cssValues = new String[] {translate("option.css.none"), translate("option.css.openolat")}; cssOptionEl = uifactory.addRadiosVertical("option.css", formLayout, cssKeys, cssValues); uifactory.addSpacerElement("spaceman", formLayout, false); Map<String, Charset> charsets = Charset.availableCharsets(); int numOfCharsets = charsets.size() + 1; encodingContentKeys = new String[numOfCharsets]; encodingContentKeys[0] = NodeEditController.CONFIG_CONTENT_ENCODING_AUTO; String[] encodingContentValues = new String[numOfCharsets]; encodingContentValues[0] = translate("encoding.auto"); encodingJSKeys = new String[numOfCharsets]; encodingJSKeys[0] = NodeEditController.CONFIG_JS_ENCODING_AUTO; String[] encodingJSValues = new String[numOfCharsets]; encodingJSValues[0] = translate("encoding.same"); int count = 1; Locale locale = getLocale(); for (Map.Entry<String, Charset> charset : charsets.entrySet()) { encodingContentKeys[count] = charset.getKey(); encodingContentValues[count] = charset.getValue().displayName(locale); encodingJSKeys[count] = charset.getKey(); encodingJSValues[count] = charset.getValue().displayName(locale); count++; } encodingContentEl = uifactory.addDropdownSingleselect( "encoContent", "encoding.content", formLayout, encodingContentKeys, encodingContentValues, null); encodingJSEl = uifactory.addDropdownSingleselect( "encoJS", "encoding.js", formLayout, encodingJSKeys, encodingJSValues, null); FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); buttonsLayout.setRootForm(mainForm); formLayout.add(buttonsLayout); uifactory.addFormSubmitButton("save", buttonsLayout); }
public boolean isInherit() { return parentConfig != null && config != null && config.getInherit() != null && config.getInherit().booleanValue(); }