From: <die...@us...> - 2011-04-01 10:45:23
|
Revision: 3397 http://openutils.svn.sourceforge.net/openutils/?rev=3397&view=rev Author: diego_schivo Date: 2011-04-01 10:45:17 +0000 (Fri, 01 Apr 2011) Log Message: ----------- TAGCLOUD-13 extract method Modified Paths: -------------- trunk/openutils-mgnltagcloud/src/main/java/net/sourceforge/openutils/mgnltagcloud/dialog/TagCloudDialog.java Modified: trunk/openutils-mgnltagcloud/src/main/java/net/sourceforge/openutils/mgnltagcloud/dialog/TagCloudDialog.java =================================================================== --- trunk/openutils-mgnltagcloud/src/main/java/net/sourceforge/openutils/mgnltagcloud/dialog/TagCloudDialog.java 2011-03-23 13:57:26 UTC (rev 3396) +++ trunk/openutils-mgnltagcloud/src/main/java/net/sourceforge/openutils/mgnltagcloud/dialog/TagCloudDialog.java 2011-04-01 10:45:17 UTC (rev 3397) @@ -117,6 +117,43 @@ log.error("RepositoryException: {}", e); } + TagCloud tagCloud = buildTagCloud(); + if (tagCloud == null) + { + parameters.put("configuredTagList", new String[]{}); + return; + } + + Map<String, Map<String, Object>> tags = new HashMap<String, Map<String, Object>>(tagCloud.getTags().size()); + for (String key : tagCloud.getTags().keySet()) + { + Map<String, Object> values = new HashMap<String, Object>(2); + values.put("selected", tagList.contains(key)); + values.put("count", tagCloud.getTags().get(key)); + tags.put(key, values); + } + + parameters.put("configuredTagList", tags); + + // load the script once: if there are multiple instances + String jQueryAttributeName = "info.magnolia.cms.gui.dialog.jquery.loaded"; + boolean includejquery = getRequest().getAttribute(jQueryAttributeName) == null; + parameters.put("includejquery", includejquery); + if (includejquery) + { + getRequest().setAttribute(jQueryAttributeName, "true"); + } + + parameters.put("debugEnabled", Boolean.valueOf(this.getConfigValue("debugEnabled"))); + + parameters.put("width", StringUtils.isNotEmpty(this.getConfigValue("width")) + ? this.getConfigValue("width") + : ""); + + } + + protected TagCloud buildTagCloud() + { // Get configured node TagCloud tagCloud = null; if (StringUtils.isNotBlank(this.getConfigValue("tagCloudName"))) @@ -125,8 +162,7 @@ if (tagCloudOriginal == null) { log.error("No tag cloud configured with name : {}", this.getConfigValue("tagCloudName")); - parameters.put("configuredTagList", new String[]{}); - return; + return null; } try { @@ -173,32 +209,6 @@ } tagCloud.setCount(10000); TagCloudManager.getInstance().calculateTagCloud(tagCloud); - - Map<String, Map<String, Object>> tags = new HashMap<String, Map<String, Object>>(tagCloud.getTags().size()); - for (String key : tagCloud.getTags().keySet()) - { - Map<String, Object> values = new HashMap<String, Object>(2); - values.put("selected", tagList.contains(key)); - values.put("count", tagCloud.getTags().get(key)); - tags.put(key, values); - } - - parameters.put("configuredTagList", tags); - - // load the script once: if there are multiple instances - String jQueryAttributeName = "info.magnolia.cms.gui.dialog.jquery.loaded"; - boolean includejquery = getRequest().getAttribute(jQueryAttributeName) == null; - parameters.put("includejquery", includejquery); - if (includejquery) - { - getRequest().setAttribute(jQueryAttributeName, "true"); - } - - parameters.put("debugEnabled", Boolean.valueOf(this.getConfigValue("debugEnabled"))); - - parameters.put("width", StringUtils.isNotEmpty(this.getConfigValue("width")) - ? this.getConfigValue("width") - : ""); - + return tagCloud; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |