@Override
    protected void init(CmsObject cms, CmsMessages widgetDialog, I_CmsWidgetParameter param, String configuration) {

        if (configuration == null) {
            // no configuration String found, return
            return;
        }
        configuration = CmsMacroResolver.resolveMacros(configuration, cms, widgetDialog);
        JSONObject jsonObj = new JSONObject();
        try {
            jsonObj = new JSONObject(configuration);
        } catch (JSONException e) {
            // initialization failed
            return;
        }
        // determine the class name that fills in values dynamically
        setClassName(jsonObj.optString(CONFIG_KEY_CLASS, null));
        I_CmsImageWidgetDynamicConfiguration dynConf = null;
        if (getClassName() != null) {
            try {
                dynConf = (I_CmsImageWidgetDynamicConfiguration)Class.forName(getClassName()).newInstance();
            } catch (Exception e) {
                // class not found
            }
        }
        // determine if the description field should be shown
        setShowDescription(jsonObj.optBoolean(CONFIG_KEY_USEDESCRIPTION));
        // determine if the format select box should be shown
        setShowFormat(jsonObj.optBoolean(CONFIG_KEY_USEFORMAT));
        if (isShowFormat()) {
            // only parse options if the format select box should be shown
            String optionsStr = (String)jsonObj.opt(CONFIG_KEY_FORMATNAMES);
            setSelectFormatString(optionsStr);
            setSelectFormat(CmsSelectWidgetOption.parseOptions(optionsStr));
            // get the corresponding format values as well
            JSONArray formatValues = jsonObj.optJSONArray(CONFIG_KEY_FORMATVALUES);
            if (formatValues != null) {
                List<String> formatValueList = new ArrayList<String>(formatValues.length());
                for (int i = 0; i < formatValues.length(); i++) {
                    formatValueList.add(formatValues.optString(i));
                }
                setFormatValues(formatValueList);
            }
            if (dynConf != null) {
                setFormatValues(
                    dynConf.getFormatValues(cms, widgetDialog, param, getSelectFormat(), getFormatValues()));
            }
        }
        // determine the initial image list settings
        setType(jsonObj.optString(CONFIG_KEY_TYPE));
        if ((CONFIG_VALUE_DYNAMIC.equals(getType()) || CmsStringUtil.isEmpty(getType())) && (dynConf != null)) {
            setType(dynConf.getType(cms, widgetDialog, param));
        }
        setStartup(jsonObj.optString(CONFIG_KEY_STARTUP));
        if ((CONFIG_VALUE_DYNAMIC.equals(getStartup()) || CmsStringUtil.isEmpty(getStartup())) && (dynConf != null)) {
            setStartup(dynConf.getStartup(cms, widgetDialog, param));
        }
        // determine the scale parameters
        setScaleParams(jsonObj.optString(CONFIG_KEY_SCALEPARAMS));
    }
@ Override protected void init ( CmsObject cms , CmsMessages widgetDialog , I_CmsWidgetParameter param , String configuration ) { if ( configuration == null ) { return ; } configuration = CmsMacroResolver . resolveMacros ( configuration , cms , widgetDialog ) ; JSONObject jsonObj = new JSONObject ( ) ; try { jsonObj = new JSONObject ( configuration ) ; } catch ( JSONException e ) { return ; } setClassName ( jsonObj . optString ( CONFIG_KEY_CLASS , null ) ) ; I_CmsImageWidgetDynamicConfiguration dynConf = null ; if ( getClassName ( ) != null ) { try { dynConf = ( I_CmsImageWidgetDynamicConfiguration ) Class . forName ( getClassName ( ) ) . newInstance ( ) ; } catch ( Exception e ) { } } setShowDescription ( jsonObj . optBoolean ( CONFIG_KEY_USEDESCRIPTION ) ) ; setShowFormat ( jsonObj . optBoolean ( CONFIG_KEY_USEFORMAT ) ) ; if ( isShowFormat ( ) ) { String optionsStr = ( String ) jsonObj . opt ( CONFIG_KEY_FORMATNAMES ) ; setSelectFormatString ( optionsStr ) ; setSelectFormat ( CmsSelectWidgetOption . parseOptions ( optionsStr ) ) ; JSONArray formatValues = jsonObj . optJSONArray ( CONFIG_KEY_FORMATVALUES ) ; if ( formatValues != null ) { List < String > formatValueList = new ArrayList < String > ( formatValues . length ( ) ) ; for ( int i = 0 ; i < formatValues . length ( ) ; i ++ ) { formatValueList . add ( formatValues . optString ( i ) ) ; } setFormatValues ( formatValueList ) ; } if ( dynConf != null ) { setFormatValues ( dynConf . getFormatValues ( cms , widgetDialog , param , getSelectFormat ( ) , getFormatValues ( ) ) ) ; } } setType ( jsonObj . optString ( CONFIG_KEY_TYPE ) ) ; if ( ( CONFIG_VALUE_DYNAMIC . equals ( getType ( ) ) || CmsStringUtil . isEmpty ( getType ( ) ) ) && ( dynConf != null ) ) { setType ( dynConf . getType ( cms , widgetDialog , param ) ) ; } setStartup ( jsonObj . optString ( CONFIG_KEY_STARTUP ) ) ; if ( ( CONFIG_VALUE_DYNAMIC . equals ( getStartup ( ) ) || CmsStringUtil . isEmpty ( getStartup ( ) ) ) && ( dynConf != null ) ) { setStartup ( dynConf . getStartup ( cms , widgetDialog , param ) ) ; } setScaleParams ( jsonObj . optString ( CONFIG_KEY_SCALEPARAMS ) ) ; }
Initializes the widget configuration using the given configuration string.<p>

@param cms an initialized instance of a CmsObject
@param widgetDialog the dialog where the widget is used on
@param param the widget parameter to generate the widget for
@param configuration the widget configuration string