Author: nmalin
Date: Fri Aug 25 09:36:04 2017 New Revision: 1806140 URL: http://svn.apache.org/viewvc?rev=1806140&view=rev Log: Implemented: Continue the common-theme upload (OFBIZ-9138 Create a common theme) Five step these step break all the UI #2 The MacroScreenRenderer class now resolve the macro ftl library location from the model theme The widget.properties lost all definition now managed by the theme definition Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/entity/FindGeneric.groovy ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/print/FoPrintServerEvents.java ofbiz/ofbiz-framework/trunk/framework/widget/config/widget.properties ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java Fri Aug 25 09:36:04 2017 @@ -49,6 +49,7 @@ import org.apache.ofbiz.webapp.control.R import org.apache.ofbiz.webapp.website.WebSiteWorker; import org.apache.ofbiz.widget.renderer.FormStringRenderer; import org.apache.ofbiz.widget.renderer.ScreenRenderer; +import org.apache.ofbiz.widget.renderer.VisualTheme; import org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer; import freemarker.template.TemplateException; @@ -66,6 +67,7 @@ public class CmsEvents { LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); ServletContext servletContext = request.getSession().getServletContext(); HttpSession session = request.getSession(); + VisualTheme visualTheme = UtilHttp.getVisualTheme(request); Writer writer = null; Locale locale = UtilHttp.getLocale(request); @@ -288,7 +290,7 @@ public class CmsEvents { try { writer = response.getWriter(); // TODO: replace "screen" to support dynamic rendering of different output - FormStringRenderer formStringRenderer = new MacroFormRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.formrenderer", delegator), request, response); + FormStringRenderer formStringRenderer = new MacroFormRenderer(visualTheme.getModelTheme().getFormRendererLocation("screen"), request, response); templateMap.put("formStringRenderer", formStringRenderer); // if use web analytics Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/data/DataResourceWorker.java Fri Aug 25 09:36:04 2017 @@ -80,10 +80,13 @@ import org.apache.ofbiz.service.LocalDis import org.apache.ofbiz.widget.model.FormFactory; import org.apache.ofbiz.widget.model.ModelForm; import org.apache.ofbiz.widget.model.ModelScreen; +import org.apache.ofbiz.widget.model.ModelTheme; import org.apache.ofbiz.widget.model.ScreenFactory; +import org.apache.ofbiz.widget.model.ThemeFactory; import org.apache.ofbiz.widget.renderer.FormRenderer; import org.apache.ofbiz.widget.renderer.ScreenRenderer; import org.apache.ofbiz.widget.renderer.ScreenStringRenderer; +import org.apache.ofbiz.widget.renderer.VisualTheme; import org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer; import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer; import org.apache.tika.Tika; @@ -99,7 +102,6 @@ public class DataResourceWorker impleme public static final String module = DataResourceWorker.class.getName(); public static final String err_resource = "ContentErrorUiLabels"; - private static final String formrenderer = UtilProperties.getPropertyValue("widget", "screen.formrenderer"); /** * Traverses the DataCategory parent/child structure and put it in categoryNode. Returns non-null error string if there is an error. @@ -623,6 +625,10 @@ public class DataResourceWorker impleme locale = Locale.getDefault(); } + //FIXME propage correctly the theme + VisualTheme visualTheme = ThemeFactory.getVisualThemeFromId("COMMON"); + ModelTheme modelTheme = visualTheme.getModelTheme(); + // if the target mimeTypeId is not a text type, throw an exception if (!targetMimeTypeId.startsWith("text/")) { throw new GeneralException("The desired mime-type is not a text type, cannot render as text: " + targetMimeTypeId); @@ -724,7 +730,7 @@ public class DataResourceWorker impleme ScreenRenderer screens = (ScreenRenderer) context.get("screens"); if (screens == null) { // TODO: replace "screen" to support dynamic rendering of different output - ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", delegator), EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", delegator)); + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(modelTheme.getType("screen"), modelTheme.getScreenRendererLocation("screen")); screens = new ScreenRenderer(out, context, screenStringRenderer); screens.getContext().put("screens", screens); } @@ -756,7 +762,7 @@ public class DataResourceWorker impleme try { Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("globalContext")); context.put("locale", locale); - context.put("simpleEncoder", UtilCodec.getEncoder(UtilProperties.getPropertyValue("widget", "screen.encoder"))); + context.put("simpleEncoder", UtilCodec.getEncoder(modelTheme.getEncoder("screen"))); HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); ModelForm modelForm = null; @@ -769,6 +775,7 @@ public class DataResourceWorker impleme Map.Entry<String, ModelForm> entry = modelFormMap.entrySet().iterator().next(); // get first entry, only one form allowed per file modelForm = entry.getValue(); } + String formrenderer = modelTheme.getFormRendererLocation("screen"); MacroFormRenderer renderer = new MacroFormRenderer(formrenderer, request, response); FormRenderer formRenderer = new FormRenderer(modelForm, renderer); formRenderer.render(out, context); Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/output/OutputServices.java Fri Aug 25 09:36:04 2017 @@ -64,6 +64,7 @@ import org.apache.ofbiz.service.ServiceU import org.apache.ofbiz.webapp.view.ApacheFopWorker; import org.apache.ofbiz.widget.renderer.ScreenRenderer; import org.apache.ofbiz.widget.renderer.ScreenStringRenderer; +import org.apache.ofbiz.widget.renderer.VisualTheme; import org.apache.ofbiz.widget.renderer.fo.FoFormRenderer; import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer; @@ -80,6 +81,7 @@ public class OutputServices { public static Map<String, Object> sendPrintFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) { Locale locale = (Locale) serviceContext.get("locale"); + VisualTheme visualTheme = (VisualTheme) serviceContext.get("visualTheme"); String screenLocation = (String) serviceContext.remove("screenLocation"); Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext")); String contentType = (String) serviceContext.remove("contentType"); @@ -103,8 +105,8 @@ public class OutputServices { Writer writer = new StringWriter(); // substitute the freemarker variables... - ScreenStringRenderer foScreenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screenfop.name", dctx.getDelegator()), - EntityUtilProperties.getPropertyValue("widget", "screenfop.screenrenderer", dctx.getDelegator())); + ScreenStringRenderer foScreenStringRenderer = new MacroScreenRenderer(visualTheme.getModelTheme().getType("screenfop"), + visualTheme.getModelTheme().getScreenRendererLocation("screenfop")); ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenStringRenderer); screensAtt.populateContextForService(dctx, screenContext); @@ -173,7 +175,6 @@ public class OutputServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentPrinterNotAvailable", locale)); } - PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet(); List<Object> printRequestAttributes = UtilGenerics.checkList(serviceContext.remove("printRequestAttributes")); if (UtilValidate.isNotEmpty(printRequestAttributes)) { @@ -195,6 +196,7 @@ public class OutputServices { public static Map<String, Object> createFileFromScreen(DispatchContext dctx, Map<String, ? extends Object> serviceContext) { Locale locale = (Locale) serviceContext.get("locale"); Delegator delegator = dctx.getDelegator(); + VisualTheme visualTheme = (VisualTheme) serviceContext.get("visualTheme"); String screenLocation = (String) serviceContext.remove("screenLocation"); Map<String, Object> screenContext = UtilGenerics.checkMap(serviceContext.remove("screenContext")); String contentType = (String) serviceContext.remove("contentType"); @@ -215,8 +217,8 @@ public class OutputServices { Writer writer = new StringWriter(); // substitute the freemarker variables... - ScreenStringRenderer foScreenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screenfop.name", dctx.getDelegator()), - EntityUtilProperties.getPropertyValue("widget", "screenfop.screenrenderer", dctx.getDelegator())); + ScreenStringRenderer foScreenStringRenderer = new MacroScreenRenderer(visualTheme.getModelTheme().getType("screenfop"), + visualTheme.getModelTheme().getScreenRendererLocation("screenfop")); ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContextTmp, foScreenStringRenderer); screensAtt.populateContextForService(dctx, screenContext); screenContextTmp.putAll(screenContext); Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/entity/FindGeneric.groovy URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/entity/FindGeneric.groovy?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/entity/FindGeneric.groovy (original) +++ ofbiz/ofbiz-framework/trunk/framework/webtools/groovyScripts/entity/FindGeneric.groovy Fri Aug 25 09:36:04 2017 @@ -28,6 +28,7 @@ import org.apache.ofbiz.entity.model.Mod import org.apache.ofbiz.widget.model.FormFactory import org.apache.ofbiz.widget.model.ModelForm import org.apache.ofbiz.widget.renderer.FormRenderer +import org.apache.ofbiz.widget.renderer.VisualTheme import org.apache.ofbiz.widget.renderer.macro.MacroFormRenderer import org.w3c.dom.Document @@ -70,7 +71,8 @@ if (modelEntity) { modelForm = entry.getValue() } - MacroFormRenderer renderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", "screen.formrenderer"), request, response) + String formRendererLocationTheme = context.theme.getModelTheme().getFormRendererLocation("screen") + MacroFormRenderer renderer = new MacroFormRenderer(formRendererLocationTheme, request, response) FormRenderer dynamicAutoEntitySearchFormRenderer = new FormRenderer(modelForm, renderer) Writer writer = new StringWriter() dynamicAutoEntitySearchFormRenderer.render(writer, context) @@ -99,7 +101,7 @@ if (modelEntity) { Map.Entry<String, ModelForm> entry = modelFormMap.entrySet().iterator().next() modelForm = entry.getValue() } - renderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", "screen.formrenderer"), request, response) + renderer = new MacroFormRenderer(formRendererLocationTheme, request, response) FormRenderer dynamicAutoEntityListFormRenderer = new FormRenderer(modelForm, renderer) Writer writerList = new StringWriter() dynamicAutoEntityListFormRenderer.render(writerList, context) Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/print/FoPrintServerEvents.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/print/FoPrintServerEvents.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/print/FoPrintServerEvents.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/print/FoPrintServerEvents.java Fri Aug 25 09:36:04 2017 @@ -39,6 +39,7 @@ import org.apache.ofbiz.service.Dispatch import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.widget.renderer.ScreenRenderer; import org.apache.ofbiz.widget.renderer.ScreenStringRenderer; +import org.apache.ofbiz.widget.renderer.VisualTheme; import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer; /** @@ -87,6 +88,7 @@ public class FoPrintServerEvents { public static byte[] getXslFo(DispatchContext dctx, String screen, Map<String, Object> parameters) throws GeneralException { // run as the system user + VisualTheme visualTheme = (VisualTheme) parameters.get("visualTheme"); GenericValue system = null; try { system = dctx.getDelegator().findOne("UserLogin", false, "userLoginId", "system"); @@ -101,8 +103,8 @@ public class FoPrintServerEvents { // render and obtain the XSL-FO Writer writer = new StringWriter(); try { - ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", dctx.getDelegator()), - EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", dctx.getDelegator())); + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(visualTheme.getModelTheme().getType("screen"), + visualTheme.getModelTheme().getScreenRendererLocation("screen")); ScreenRenderer screens = new ScreenRenderer(writer, null, screenStringRenderer); screens.populateContextForService(dctx, parameters); screens.render(screen); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/config/widget.properties URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/config/widget.properties?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/config/widget.properties (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/config/widget.properties Fri Aug 25 09:36:04 2017 @@ -30,33 +30,9 @@ widget.verbose=true # Default number of items to be displayed per page in a list form widget.form.defaultViewSize=20 -# Default number of items to be displayed in lookup ajax autocompleter -widget.autocompleter.defaultViewSize=10 - -# Default minimum number of characters an user has to type before the ajax autocompleter activates (jQuery default is 1) -widget.autocompleter.defaultMinLength=2 - -# Default delay in milliseconds the Autocomplete waits after a keystroke to activate itself. A zero-delay makes sense for local data (more responsive), but can produce a lot of load for remote data, while being less responsive. -widget.autocompleter.defaultDelay=300 - -# Show/hide the ID field that is returned from ajax autocompleter -widget.autocompleter.displayReturnField=Y - # Show/hide description for lookup field widget.lookup.showDescription=Y -# Default position and size for lookup layered windows -widget.lookup.position=topleft -widget.lookup.width=640 -widget.lookup.height=500 - -# Default position and size for Jgrowl error messages -# accept : top-left, top-right, bottom-left, bottom-right, center -widget.jgrowl.position=center -widget.jgrowl.width=600 -widget.jgrowl.height= -widget.jgrowl.speed=100 - # Default text find field's option widget.form.defaultTextFindOption=contains @@ -69,56 +45,3 @@ widget.form.displayhelpText=Y # first appears. widget.defaultNoConditionFind=N -#Default size for layered modal windows -widget.link.default.layered-modal.width=800 -widget.link.default.layered-modal.height=600 - -# Configurations for the Widget View Handlers implemented using the MacroScreenViewHandler -# -# html output -screen.name=html -screen.screenrenderer=component://common-theme/template/macro/HtmlScreenMacroLibrary.ftl -screen.formrenderer=component://common-theme/template/macro/HtmlFormMacroLibrary.ftl -screen.menurenderer=component://common-theme/template/macro/HtmlMenuMacroLibrary.ftl -screen.treerenderer=component://common-theme/template/macro/HtmlTreeMacroLibrary.ftl -screen.encoder=html -screen.compress=false -screen.default.contenttype=UTF-8 -screen.default.encoding=none -# text output -screentext.name=text -screentext.screenrenderer=component://common-theme/template/macro/TextScreenMacroLibrary.ftl -screentext.formrenderer=component://common-theme/template/macro/TextFormMacroLibrary.ftl -screentext.treerenderer=component://common-theme/template/macro/TextTreeMacroLibrary.ftl -screentext.default.contenttype=UTF-8 -screentext.default.encoding=none -# xml output -screenxml.name=xml -screenxml.screenrenderer=component://common-theme/template/macro/XmlScreenMacroLibrary.ftl -screenxml.formrenderer=component://common-theme/template/macro/XmlFormMacroLibrary.ftl -screenxml.treerenderer=component://common-theme/template/macro/XmlTreeMacroLibrary.ftl -screenxml.encoder=xml -screenxml.default.contenttype=UTF-8 -screenxml.default.encoding=none -# xls output -screenxls.name=xls -screenxls.screenrenderer=component://common-theme/template/macro/XlsScreenMacroLibrary.ftl -screenxls.formrenderer=component://common-theme/template/macro/XlsFormMacroLibrary.ftl -screenxls.treerenderer=component://common-theme/template/macro/XlsTreeMacroLibrary.ftl -screenxls.encoder=html -screenxls.default.contenttype=application/vnd.ms-excel -screenxls.default.encoding=none -# fo output -screenfop.name=xsl-fo -screenfop.screenrenderer=component://common-theme/template/macro/FoScreenMacroLibrary.ftl -screenfop.formrenderer=component://common-theme/template/macro/FoFormMacroLibrary.ftl -screenfop.treerenderer=component://common-theme/template/macro/FoTreeMacroLibrary.ftl -screenfop.default.contenttype=application/pdf -screenfop.default.encoding=none -# csv output -screencsv.name=csv -screencsv.screenrenderer=component://common-theme/template/macro/CsvScreenMacroLibrary.ftl -screencsv.formrenderer=component://common-theme/template/macro/CsvFormMacroLibrary.ftl -screencsv.treerenderer=component://common-theme/template/macro/CsvTreeMacroLibrary.ftl -screencsv.default.contenttype=UTF-8 -screencsv.default.encoding=none Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/fo/ScreenFopViewHandler.java Fri Aug 25 09:36:04 2017 @@ -84,17 +84,17 @@ public class ScreenFopViewHandler extend // render and obtain the XSL-FO Writer writer = new StringWriter(); try { - ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", getName() + ".name", delegator), EntityUtilProperties.getPropertyValue("widget", getName() + ".screenrenderer", delegator)); - FormStringRenderer formStringRenderer = new MacroFormRenderer(EntityUtilProperties.getPropertyValue("widget", getName() + ".formrenderer", delegator), request, response); + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(modelTheme.getType(getName()), modelTheme.getScreenRendererLocation(getName())); + FormStringRenderer formStringRenderer = new MacroFormRenderer(modelTheme.getFormRendererLocation(getName()), request, response); // TODO: uncomment these lines when the renderers are implemented - //TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(UtilProperties.getPropertyValue("widget", getName() + ".treerenderer"), writer); - //MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(UtilProperties.getPropertyValue("widget", getName() + ".menurenderer"), writer); + //TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(modelTheme.getTreeRendererLocation(getName()), writer); + //MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(modelTheme.getMenuRendererLocation(getName()), writer); ScreenRenderer screens = new ScreenRenderer(writer, null, screenStringRenderer); screens.populateContextForRequest(request, response, servletContext); // this is the object used to render forms from their definitions screens.getContext().put("formStringRenderer", formStringRenderer); - screens.getContext().put("simpleEncoder", UtilCodec.getEncoder(EntityUtilProperties.getPropertyValue("widget", getName() + ".encoder", delegator))); + screens.getContext().put("simpleEncoder", UtilCodec.getEncoder(modelTheme.getEncoder(getName()))); screens.render(page); } catch (Exception e) { renderError("Problems with the response writer/output stream", e, "[Not Yet Rendered]", request, response); @@ -109,7 +109,7 @@ public class ScreenFopViewHandler extend if (Debug.verboseOn()) Debug.logVerbose("XSL:FO Screen Output: " + screenOutString, module); if (UtilValidate.isEmpty(contentType)) { - contentType = UtilProperties.getPropertyValue("widget", getName() + ".default.contenttype"); + contentType = modelTheme.getContentType(getName()); } // get encryption related parameters @@ -186,8 +186,10 @@ public class ScreenFopViewHandler extend try { Delegator delegator = (Delegator) request.getAttribute("delegator"); Writer writer = new StringWriter(); - ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.name", delegator), - EntityUtilProperties.getPropertyValue("widget", "screen.screenrenderer", delegator)); + VisualTheme visualTheme = UtilHttp.getVisualTheme(request); + ModelTheme modelTheme = visualTheme.getModelTheme(); + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(modelTheme.getType("screen"), + modelTheme.getScreenRendererLocation("screen")); ScreenRenderer screens = new ScreenRenderer(writer, null, screenStringRenderer); screens.populateContextForRequest(request, response, servletContext); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlTreeRenderer.java Fri Aug 25 09:36:04 2017 @@ -33,10 +33,12 @@ import org.apache.ofbiz.base.util.UtilVa import org.apache.ofbiz.webapp.control.RequestHandler; import org.apache.ofbiz.webapp.taglib.ContentUrlTag; import org.apache.ofbiz.widget.WidgetWorker; +import org.apache.ofbiz.widget.model.ModelTheme; import org.apache.ofbiz.widget.model.ModelTree; import org.apache.ofbiz.widget.model.ModelWidget; import org.apache.ofbiz.widget.renderer.ScreenRenderer; import org.apache.ofbiz.widget.renderer.ScreenStringRenderer; +import org.apache.ofbiz.widget.renderer.VisualTheme; import org.apache.ofbiz.widget.renderer.TreeStringRenderer; import org.apache.ofbiz.widget.renderer.macro.MacroScreenRenderer; @@ -333,14 +335,15 @@ public class HtmlTreeRenderer extends Ht } public ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context) { + VisualTheme visualTheme = (VisualTheme) context.get("visualTheme"); + ModelTheme modelTheme = visualTheme.getModelTheme(); ScreenRenderer screenRenderer = (ScreenRenderer)context.get("screens"); if (screenRenderer != null) { screenStringRenderer = screenRenderer.getScreenStringRenderer(); } else { if (screenStringRenderer == null) { try { - screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", "screen.name"), - UtilProperties.getPropertyValue("widget", "screen.screenrenderer")); + screenStringRenderer = new MacroScreenRenderer(modelTheme.getType("screen"), modelTheme.getScreenRendererLocation("screen")); } catch (TemplateException | IOException e) { e.printStackTrace(); } Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java Fri Aug 25 09:36:04 2017 @@ -3107,12 +3107,12 @@ public final class MacroFormRenderer imp String uniqueItemName = "Modal_".concat(UUID.randomUUID().toString().replace("-", "_")); String width = (String) this.request.getAttribute("width"); if (UtilValidate.isEmpty(width)) { - width = String.valueOf(UtilProperties.getPropertyValue("widget", "widget.link.default.layered-modal.width", "800")); + width = String.valueOf(modelTheme.getLinkDefaultLayeredModalWidth()); this.request.setAttribute("width", width); } String height = (String) this.request.getAttribute("height"); if (UtilValidate.isEmpty(height)) { - height = String.valueOf(UtilProperties.getPropertyValue("widget", "widget.link.default.layered-modal.height", "600")); + height = String.valueOf(modelTheme.getLinkDefaultLayeredModalHeight()); this.request.setAttribute("height", height); } this.request.setAttribute("uniqueItemName", uniqueItemName); Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java Fri Aug 25 09:36:04 2017 @@ -79,7 +79,6 @@ public class MacroScreenRenderer impleme private String rendererName; private int elementId = 999; protected boolean widgetCommentsEnabled = false; - private static final String formrenderer = UtilProperties.getPropertyValue("widget", "screen.formrenderer"); private int screenLetsIdCounter = 1; public MacroScreenRenderer(String name, String macroLibraryPath) throws TemplateException, IOException { @@ -238,11 +237,11 @@ public class MacroScreenRenderer impleme StringBuilder parameters = new StringBuilder(); String width = link.getWidth(); if (UtilValidate.isEmpty(width)) { - width = String.valueOf(UtilProperties.getPropertyValue("widget", "widget.link.default.layered-modal.width", "800")); + width = String.valueOf(modelTheme.getLinkDefaultLayeredModalWidth()); } String height = link.getHeight(); if (UtilValidate.isEmpty(height)) { - height = String.valueOf(UtilProperties.getPropertyValue("widget", "widget.link.default.layered-modal.height", "600")); + height = String.valueOf(modelTheme.getLinkDefaultLayeredModalHeight()); } if ("hidden-form".equals(linkType) || "layered-modal".equals(linkType)) { StringBuilder sb = new StringBuilder(); @@ -626,8 +625,7 @@ public class MacroScreenRenderer impleme MenuStringRenderer savedRenderer = (MenuStringRenderer) context.get("menuStringRenderer"); MenuStringRenderer renderer; try { - renderer = new MacroMenuRenderer(EntityUtilProperties.getPropertyValue("widget", "screen.menurenderer", (Delegator) request.getAttribute("delegator")), - request, response); + renderer = new MacroMenuRenderer(modelTheme.getMenuRendererLocation("screen"), request, response); context.put("menuStringRenderer", renderer); navMenu.renderWidgetString(sb, context, this); context.put("menuStringRenderer", savedRenderer); @@ -675,7 +673,7 @@ public class MacroScreenRenderer impleme FormStringRenderer savedRenderer = (FormStringRenderer) context.get("formStringRenderer"); MacroFormRenderer renderer = null; try { - renderer = new MacroFormRenderer(formrenderer, request, response); + renderer = new MacroFormRenderer(modelTheme.getFormRendererLocation("screen"), request, response); } catch (TemplateException e) { Debug.logError("Not rendering content, error on MacroFormRenderer creation.", module); } Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java?rev=1806140&r1=1806139&r2=1806140&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenViewHandler.java Fri Aug 25 09:36:04 2017 @@ -67,63 +67,23 @@ public class MacroScreenViewHandler exte private ScreenStringRenderer loadRenderers(HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, Writer writer) throws GeneralException, TemplateException, IOException { - String screenMacroLibraryPath = UtilProperties.getPropertyValue("widget", getName() + ".screenrenderer"); - String formMacroLibraryPath = UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"); - String treeMacroLibraryPath = UtilProperties.getPropertyValue("widget", getName() + ".treerenderer"); - String menuMacroLibraryPath = UtilProperties.getPropertyValue("widget", getName() + ".menurenderer"); - Map<String, Object> userPreferences = UtilGenerics.cast(context.get("userPreferences")); - if (userPreferences != null) { - String visualThemeId = (String) userPreferences.get("VISUAL_THEME"); - if (visualThemeId != null) { - LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); - Map<String, Object> serviceCtx = dispatcher.getDispatchContext().makeValidContext("getVisualThemeResources", - ModelService.IN_PARAM, context); - serviceCtx.put("visualThemeId", visualThemeId); - Map<String, Object> serviceResult = dispatcher.runSync("getVisualThemeResources", serviceCtx); - if (ServiceUtil.isSuccess(serviceResult)) { - Map<String, List<String>> themeResources = UtilGenerics.cast(serviceResult.get("themeResources")); - List<String> resourceList = UtilGenerics.cast(themeResources.get("VT_SCRN_MACRO_LIB")); - if (resourceList != null && !resourceList.isEmpty()) { - String macroLibraryPath = resourceList.get(0); - if (macroLibraryPath != null) { - screenMacroLibraryPath = macroLibraryPath; - } - } - resourceList = UtilGenerics.cast(themeResources.get("VT_FORM_MACRO_LIB")); - if (resourceList != null && !resourceList.isEmpty()) { - String macroLibraryPath = resourceList.get(0); - if (macroLibraryPath != null) { - formMacroLibraryPath = macroLibraryPath; - } - } - resourceList = UtilGenerics.cast(themeResources.get("VT_TREE_MACRO_LIB")); - if (resourceList != null && !resourceList.isEmpty()) { - String macroLibraryPath = resourceList.get(0); - if (macroLibraryPath != null) { - treeMacroLibraryPath = macroLibraryPath; - } - } - resourceList = UtilGenerics.cast(themeResources.get("VT_MENU_MACRO_LIB")); - if (resourceList != null && !resourceList.isEmpty()) { - String macroLibraryPath = resourceList.get(0); - if (macroLibraryPath != null) { - menuMacroLibraryPath = macroLibraryPath; - } - } - } - } - } - ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", getName() - + ".name"), screenMacroLibraryPath); - if (!formMacroLibraryPath.isEmpty()) { + VisualTheme visualTheme = (VisualTheme) UtilHttp.getVisualTheme(request); + ModelTheme modelTheme = visualTheme.getModelTheme(); + + String screenMacroLibraryPath = modelTheme.getScreenRendererLocation(getName()); + String formMacroLibraryPath = modelTheme.getFormRendererLocation(getName()); + String treeMacroLibraryPath = modelTheme.getTreeRendererLocation(getName()); + String menuMacroLibraryPath = modelTheme.getMenuRendererLocation(getName()); + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(modelTheme.getType(getName()), screenMacroLibraryPath); + if (UtilValidate.isNotEmpty(formMacroLibraryPath)) { FormStringRenderer formStringRenderer = new MacroFormRenderer(formMacroLibraryPath, request, response); context.put("formStringRenderer", formStringRenderer); } - if (!treeMacroLibraryPath.isEmpty()) { + if (UtilValidate.isNotEmpty(treeMacroLibraryPath)) { TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(treeMacroLibraryPath, writer); context.put("treeStringRenderer", treeStringRenderer); } - if (!menuMacroLibraryPath.isEmpty()) { + if (UtilValidate.isNotEmpty(menuMacroLibraryPath)) { MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(menuMacroLibraryPath, request, response); context.put("menuStringRenderer", menuStringRenderer); } @@ -138,11 +98,11 @@ public class MacroScreenViewHandler exte Delegator delegator = (Delegator) request.getAttribute("delegator"); // compress output if configured to do so if (UtilValidate.isEmpty(encoding)) { - encoding = EntityUtilProperties.getPropertyValue("widget", getName() + ".default.encoding", "none", delegator); + encoding = modelTheme.getEncoding(getName()); } boolean compressOutput = "compressed".equals(encoding); if (!compressOutput) { - compressOutput = "true".equals(EntityUtilProperties.getPropertyValue("widget", getName() + ".compress", delegator)); + compressOutput = "true".equals(modelTheme.getCompress(getName())); } if (!compressOutput && this.servletContext != null) { compressOutput = "true".equals(this.servletContext.getAttribute("compressHTML")); @@ -157,8 +117,8 @@ public class MacroScreenViewHandler exte ScreenStringRenderer screenStringRenderer = loadRenderers(request, response, context, writer); ScreenRenderer screens = new ScreenRenderer(writer, context, screenStringRenderer); context.put("screens", screens); - context.put("simpleEncoder", UtilCodec.getEncoder(UtilProperties.getPropertyValue("widget", getName() + ".encoder"))); - screenStringRenderer.renderScreenBegin(writer, context); + context.put("simpleEncoder", UtilCodec.getEncoder(visualTheme.getModelTheme().getEncoder(getName()))); + screenStringRenderer.renderScreenBegin(writer, context); screens.render(page); screenStringRenderer.renderScreenEnd(writer, context); writer.flush(); |
Free forum by Nabble | Edit this page |