From: <die...@us...> - 2010-06-21 09:50:49
|
Revision: 2697 http://openutils.svn.sourceforge.net/openutils/?rev=2697&view=rev Author: diego_schivo Date: 2010-06-21 09:50:42 +0000 (Mon, 21 Jun 2010) Log Message: ----------- CONTROLS-31 refactoring Modified Paths: -------------- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ComboGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FileGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/LinkGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/UUIDLinkGridColumnType.java trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java Added Paths: ----------- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/AbstractGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ColorGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/DateGridColumnType.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/TextGridColumnType.java trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.color.xml trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.date.xml trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.text.xml Added: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/AbstractGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/AbstractGridColumnType.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/AbstractGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,103 @@ +/** + * + * Magnolia controls module (http://www.openmindlab.com/lab/products/controls.html) + * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.sourceforge.openutils.mgnlcontrols.configuration; + +import info.magnolia.cms.core.Content; +import info.magnolia.cms.i18n.Messages; +import info.magnolia.cms.security.AccessDeniedException; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.jcr.RepositoryException; + +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; + + +/** + * @author dschivo + * @version $Id$ + */ +public abstract class AbstractGridColumnType implements GridColumnType +{ + + /** + * {@inheritDoc} + */ + public String getHeadSnippet() + { + return StringUtils.EMPTY; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public String drawSupportHtml(String propertyName, Map colmap) + { + return StringUtils.EMPTY; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public String drawColumnJs(String propertyName, int colIndex, Map colMap, Messages msgs) + { + StringBuilder sb = new StringBuilder(); + Map<String, String> column = new HashMap<String, String>(); + String header = (String) colMap.get("header"); + column.put("header", "'" + StringEscapeUtils.escapeJavaScript(msgs.getWithDefault(header, header)) + "'"); + column.put("dataIndex", "'" + colIndex + "'"); + column.put("sortable", "false"); + addColumnData(column, propertyName, colIndex, colMap, msgs); + for (Entry<String, String> entry : column.entrySet()) + { + if (sb.length() > 0) + { + sb.append(",\n"); + } + sb.append(entry.getKey()).append(": ").append(entry.getValue()); + } + return "{\n" + sb + "\n}\n"; + } + + /** + * {@inheritDoc} + */ + public String processValueOnLoad(String value, Content colConfig) + { + return value; + } + + /** + * {@inheritDoc} + */ + public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) + throws RepositoryException, AccessDeniedException + { + } + + @SuppressWarnings("unchecked") + protected abstract void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs); +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/AbstractGridColumnType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ColorGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ColorGridColumnType.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ColorGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,61 @@ +/** + * + * Magnolia controls module (http://www.openmindlab.com/lab/products/controls.html) + * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.sourceforge.openutils.mgnlcontrols.configuration; + +import info.magnolia.cms.i18n.Messages; +import info.magnolia.context.MgnlContext; + +import java.util.Map; + + +/** + * @author dschivo + * @version $Id$ + */ +public class ColorGridColumnType extends AbstractGridColumnType +{ + + /** + * {@inheritDoc} + */ + @Override + public String getHeadSnippet() + { + return "<script type=\"text/javascript\" src=\"" + + MgnlContext.getContextPath() + + "/.resources/controls/js/ColorField.js\"></script>"; + } + + /** + * {@inheritDoc} + */ + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) + { + column.put("editor", "new Ed(new Ext.ux.ColorField({}))"); + column + .put( + "renderer", + "function(v, p, record){ return v ? '<em style=\"display: block; float: left; border: 1px solid #ACA899;\">" + + "<span style=\"display: block; width: 10px; height: 10px; line-height: 10px; background-color: ' + v + ';\">" + + "</span></em>' : ''; }"); + } +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ColorGridColumnType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ComboGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ComboGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ComboGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -1,15 +1,31 @@ +/** + * + * Magnolia controls module (http://www.openmindlab.com/lab/products/controls.html) + * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + package net.sourceforge.openutils.mgnlcontrols.configuration; -import info.magnolia.cms.core.Content; -import info.magnolia.cms.security.AccessDeniedException; +import info.magnolia.cms.i18n.Messages; import info.magnolia.context.MgnlContext; import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.jcr.RepositoryException; - import org.apache.commons.lang.StringUtils; @@ -17,12 +33,13 @@ * @author dschivo * @version $Id$ */ -public class ComboGridColumnType implements GridColumnType +public class ComboGridColumnType extends AbstractGridColumnType { /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -33,7 +50,7 @@ /** * {@inheritDoc} */ - @SuppressWarnings("unchecked") + @Override public String drawSupportHtml(String propertyName, Map colmap) { StringBuilder sb = new StringBuilder(); @@ -55,7 +72,9 @@ /** * {@inheritDoc} */ - public String drawColumnModelJs(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { List<String> options = new ArrayList<String>(); options.add("typeAhead: true"); @@ -64,27 +83,10 @@ options.add("lazyRender: true"); options.add("listClass: 'x-combo-list-small'"); - return "editor: new Ed(new " - + ("true".equals(String.valueOf(colmap.get("pipe"))) ? "PipeComboBox" : "fm.ComboBox") - + "({\n" - + StringUtils.join(options, ",\n") - + "}))"; + column.put("editor", "new Ed(new " + + ("true".equals(String.valueOf(colMap.get("pipe"))) ? "PipeComboBox" : "fm.ComboBox") + + "({" + + StringUtils.join(options, ",") + + "}))"); } - - /** - * {@inheritDoc} - */ - public String processValueOnLoad(String value, Content colConfig) - { - return value; - } - - /** - * {@inheritDoc} - */ - public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) - throws RepositoryException, AccessDeniedException - { - } - } Added: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/DateGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/DateGridColumnType.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/DateGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,44 @@ +/** + * + * Magnolia controls module (http://www.openmindlab.com/lab/products/controls.html) + * Copyright (C)2008 - 2010, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.sourceforge.openutils.mgnlcontrols.configuration; + +import info.magnolia.cms.i18n.Messages; + +import java.util.Map; + + +/** + * @author dschivo + * @version $Id$ + */ +public class DateGridColumnType extends AbstractGridColumnType +{ + + /** + * {@inheritDoc} + */ + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) + { + column.put("editor", "new Ed(new fm.DateField({format: 'Y-m-d'}))"); + column.put("renderer", "function(v){ return (v && Ext.isDate(v)) ? v.format('Y-m-d') : v; }"); + } +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/DateGridColumnType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -19,27 +19,23 @@ package net.sourceforge.openutils.mgnlcontrols.configuration; -import info.magnolia.cms.core.Content; -import info.magnolia.cms.security.AccessDeniedException; +import info.magnolia.cms.i18n.Messages; import info.magnolia.context.MgnlContext; import java.util.Map; -import javax.jcr.RepositoryException; -import org.apache.commons.lang.StringUtils; - - /** * @author dschivo * @version $Id$ */ -public class FckEditorGridColumnType implements GridColumnType +public class FckEditorGridColumnType extends AbstractGridColumnType { /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -50,36 +46,10 @@ /** * {@inheritDoc} */ - public String drawSupportHtml(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { - return StringUtils.EMPTY; + column.put("editor", "new Ed(new FckEditorField({contextPath: '" + MgnlContext.getContextPath() + "'}))"); } - - /** - * {@inheritDoc} - */ - public String drawColumnModelJs(String propertyName, Map colmap) - { - return "editor: new Ed(new FckEditorField({\n" - + "contextPath: '" - + MgnlContext.getContextPath() - + "'\n" - + "}))\n"; - } - - /** - * {@inheritDoc} - */ - public String processValueOnLoad(String value, Content colConfig) - { - return value; - } - - /** - * {@inheritDoc} - */ - public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) - throws RepositoryException, AccessDeniedException - { - } } Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FileGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FileGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FileGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -7,6 +7,7 @@ import info.magnolia.cms.core.NodeData; import info.magnolia.cms.core.Path; import info.magnolia.cms.gui.fckeditor.FCKEditorTmpFiles; +import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; import info.magnolia.cms.util.ContentUtil; import info.magnolia.context.MgnlContext; @@ -30,7 +31,7 @@ * @author dschivo * @version $Id$ */ -public class FileGridColumnType implements GridColumnType +public class FileGridColumnType extends AbstractGridColumnType { private Logger log = LoggerFactory.getLogger(getClass()); @@ -38,6 +39,7 @@ /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -48,34 +50,18 @@ /** * {@inheritDoc} */ - public String drawSupportHtml(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { - return StringUtils.EMPTY; + column.put("editor", "new Ed(new FileField({}))"); + column.put("renderer", "function(v, p, record){ return v ? v.replace(/^.*\\//, '') : v;}"); } /** * {@inheritDoc} */ - public String drawColumnModelJs(String propertyName, Map colmap) - { - return "editor: new Ed(new FileField({\n" - + "})),\n" - + "renderer : function(v, p, record){\n" - + "return v ? v.replace(/^.*\\//, '') : v;\n" - + "}"; - } - - /** - * {@inheritDoc} - */ - public String processValueOnLoad(String value, Content colConfig) - { - return value; - } - - /** - * {@inheritDoc} - */ + @Override public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) throws RepositoryException, AccessDeniedException { @@ -129,7 +115,6 @@ fileNodeData.delete(); } } - } } Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -20,6 +20,7 @@ package net.sourceforge.openutils.mgnlcontrols.configuration; import info.magnolia.cms.core.Content; +import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; import java.util.Map; @@ -42,7 +43,7 @@ public String drawSupportHtml(String propertyName, Map colmap); - public String drawColumnModelJs(String propertyName, Map colmap); + public String drawColumnJs(String propertyName, int colIndex, Map colmap, Messages msgs); public String processValueOnLoad(String value, Content colConfig); Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/LinkGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/LinkGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/LinkGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -1,15 +1,12 @@ package net.sourceforge.openutils.mgnlcontrols.configuration; -import info.magnolia.cms.core.Content; -import info.magnolia.cms.security.AccessDeniedException; +import info.magnolia.cms.i18n.Messages; import info.magnolia.context.MgnlContext; import java.util.ArrayList; import java.util.List; import java.util.Map; -import javax.jcr.RepositoryException; - import org.apache.commons.lang.StringUtils; @@ -17,12 +14,13 @@ * @author dschivo * @version $Id$ */ -public class LinkGridColumnType implements GridColumnType +public class LinkGridColumnType extends AbstractGridColumnType { /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -33,41 +31,19 @@ /** * {@inheritDoc} */ - public String drawSupportHtml(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { - return StringUtils.EMPTY; - } - - /** - * {@inheritDoc} - */ - public String drawColumnModelJs(String propertyName, Map colmap) - { List<String> options = new ArrayList<String>(); - if (!StringUtils.isEmpty((String) colmap.get("repository"))) + if (!StringUtils.isEmpty((String) colMap.get("repository"))) { - options.add("repository: '" + colmap.get("repository") + "'"); + options.add("repository: '" + colMap.get("repository") + "'"); } - if (!StringUtils.isEmpty((String) colmap.get("extension"))) + if (!StringUtils.isEmpty((String) colMap.get("extension"))) { - options.add("extension: '" + colmap.get("extension") + "'"); + options.add("extension: '" + colMap.get("extension") + "'"); } - return "editor: new Ed(new LinkField({\n" + StringUtils.join(options, ",\n") + "}))"; + column.put("editor", "new Ed(new LinkField({" + StringUtils.join(options, ",") + "}))"); } - - /** - * {@inheritDoc} - */ - public String processValueOnLoad(String value, Content colConfig) - { - return value; - } - - /** - * {@inheritDoc} - */ - public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) - throws RepositoryException, AccessDeniedException - { - } } Added: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/TextGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/TextGridColumnType.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/TextGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,24 @@ +package net.sourceforge.openutils.mgnlcontrols.configuration; + +import info.magnolia.cms.i18n.Messages; + +import java.util.Map; + + +/** + * @author dschivo + * @version $Id$ + */ +public class TextGridColumnType extends AbstractGridColumnType +{ + + /** + * {@inheritDoc} + */ + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) + { + column.put("editor", "new Ed(new fm.TextField({allowBlank: true}))"); + } +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/TextGridColumnType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/UUIDLinkGridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/UUIDLinkGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/UUIDLinkGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -2,6 +2,7 @@ import info.magnolia.cms.beans.config.ContentRepository; import info.magnolia.cms.core.Content; +import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; import info.magnolia.cms.util.ContentUtil; import info.magnolia.cms.util.NodeDataUtil; @@ -20,12 +21,13 @@ * @author dschivo * @version $Id$ */ -public class UUIDLinkGridColumnType implements GridColumnType +public class UUIDLinkGridColumnType extends AbstractGridColumnType { /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -36,31 +38,26 @@ /** * {@inheritDoc} */ - public String drawSupportHtml(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { - return StringUtils.EMPTY; - } - - /** - * {@inheritDoc} - */ - public String drawColumnModelJs(String propertyName, Map colmap) - { List<String> options = new ArrayList<String>(); - if (!StringUtils.isEmpty((String) colmap.get("repository"))) + if (!StringUtils.isEmpty((String) colMap.get("repository"))) { - options.add("repository: '" + colmap.get("repository") + "'"); + options.add("repository: '" + colMap.get("repository") + "'"); } - if (!StringUtils.isEmpty((String) colmap.get("extension"))) + if (!StringUtils.isEmpty((String) colMap.get("extension"))) { - options.add("extension: '" + colmap.get("extension") + "'"); + options.add("extension: '" + colMap.get("extension") + "'"); } - return "editor: new Ed(new UUIDLinkField({\n" + StringUtils.join(options, ",\n") + "}))"; + column.put("editor", "new Ed(new UUIDLinkField({" + StringUtils.join(options, ",") + "}))"); } /** * {@inheritDoc} */ + @Override public String processValueOnLoad(String value, Content colConfig) { String repository = StringUtils.defaultIfEmpty( @@ -77,6 +74,7 @@ /** * {@inheritDoc} */ + @Override public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) throws RepositoryException, AccessDeniedException { Modified: trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2010-06-21 09:50:42 UTC (rev 2697) @@ -126,18 +126,7 @@ [#if (colmap.type?? && colmap.type = 'checkbox')] checkColumns[checkIndex++] [#else] - { - header: '${msgs.getWithDefault(colmap.header?js_string, colmap.header?js_string)}', - dataIndex: '${colmap_index}', - sortable: false, - [#if (colmap.type?? && gridColumnTypes[colmap.type]??)] - ${gridColumnTypes[colmap.type].drawColumnModelJs(name, colmap)} - [#else] - editor: new Ed(new fm.TextField({ - allowBlank: true - })) - [/#if] - } + ${gridColumnTypes[colmap.type!'text'].drawColumnJs(name, colmap_index, colmap, msgs)} [/#if][#if colmap_has_next],[/#if] [/#list] ]); Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.color.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.color.xml (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.color.xml 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="color" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:contentNode</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>8ed77404-e4ee-4454-9ade-fb01dd211b79</sv:value> + </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlcontrols.configuration.ColorGridColumnType</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2010-06-18T11:41:55.562+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2010-06-21T10:38:03.946+02:00</sv:value> + </sv:property> + </sv:node> +</sv:node> Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.color.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.date.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.date.xml (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.date.xml 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="date" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:contentNode</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>2771e8a3-e7e1-4355-85ae-a4dda4406ef1</sv:value> + </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlcontrols.configuration.DateGridColumnType</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2010-06-18T11:41:55.562+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2010-06-21T10:28:51.069+02:00</sv:value> + </sv:property> + </sv:node> +</sv:node> Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.date.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.text.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.text.xml (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.text.xml 2010-06-21 09:50:42 UTC (rev 2697) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="text" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:contentNode</sv:value> + </sv:property> + <sv:property sv:name="jcr:mixinTypes" sv:type="Name"> + <sv:value>mix:lockable</sv:value> + </sv:property> + <sv:property sv:name="jcr:uuid" sv:type="String"> + <sv:value>5ef8f8d0-358d-4f56-b54e-77e92f2e370b</sv:value> + </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlcontrols.configuration.TextGridColumnType</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:node sv:name="MetaData"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>mgnl:metaData</sv:value> + </sv:property> + <sv:property sv:name="jcr:createdBy" sv:type="String"> + <sv:value>admin</sv:value> + </sv:property> + <sv:property sv:name="mgnl:activated" sv:type="Boolean"> + <sv:value>false</sv:value> + </sv:property> + <sv:property sv:name="mgnl:authorid" sv:type="String"> + <sv:value>superuser</sv:value> + </sv:property> + <sv:property sv:name="mgnl:creationdate" sv:type="Date"> + <sv:value>2010-06-18T11:41:55.562+02:00</sv:value> + </sv:property> + <sv:property sv:name="mgnl:lastmodified" sv:type="Date"> + <sv:value>2010-06-21T11:46:11.816+02:00</sv:value> + </sv:property> + </sv:node> +</sv:node> Property changes on: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.text.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java 2010-06-21 08:42:26 UTC (rev 2696) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/grid/MediaGridColumnType.java 2010-06-21 09:50:42 UTC (rev 2697) @@ -20,6 +20,7 @@ package net.sourceforge.openutils.mgnlmedia.grid; import info.magnolia.cms.core.Content; +import info.magnolia.cms.i18n.Messages; import info.magnolia.cms.security.AccessDeniedException; import info.magnolia.cms.util.ContentUtil; import info.magnolia.cms.util.NodeDataUtil; @@ -29,7 +30,7 @@ import javax.jcr.RepositoryException; -import net.sourceforge.openutils.mgnlcontrols.configuration.GridColumnType; +import net.sourceforge.openutils.mgnlcontrols.configuration.AbstractGridColumnType; import net.sourceforge.openutils.mgnlmedia.media.lifecycle.MediaModule; import org.apache.commons.lang.StringUtils; @@ -39,12 +40,13 @@ * @author dschivo * @version $Id$ */ -public class MediaGridColumnType implements GridColumnType +public class MediaGridColumnType extends AbstractGridColumnType { /** * {@inheritDoc} */ + @Override public String getHeadSnippet() { return "<script type=\"text/javascript\" src=\"" @@ -62,28 +64,20 @@ /** * {@inheritDoc} */ - public String drawSupportHtml(String propertyName, Map colmap) + @Override + protected void addColumnData(Map<String, String> column, String propertyName, int colIndex, Map colMap, + Messages msgs) { - return StringUtils.EMPTY; - } - - /** - * {@inheritDoc} - */ - public String drawColumnModelJs(String propertyName, Map colmap) - { - return "editor: new Ed(new MediaField({\n" - + "})),\n" - + "renderer : function(v, p, record){\n" - + "return v ? '<img border=\"0\" alt=\"\" src=\"" + column.put("editor", "new Ed(new MediaField({}))"); + column.put("renderer", "function(v, p, record){ return v ? '<img border=\"0\" alt=\"\" src=\"" + MgnlContext.getContextPath() - + "/mediathumbnail/' + v + '\" />' : v;\n" - + "}"; + + "/mediathumbnail/' + v + '\" />' : v; }"); } /** * {@inheritDoc} */ + @Override public String processValueOnLoad(String value, Content colConfig) { String valueType = StringUtils.defaultIfEmpty(NodeDataUtil.getString(colConfig, "valueType"), "uuid"); @@ -101,6 +95,7 @@ /** * {@inheritDoc} */ + @Override public void processColumnOnSave(String[] column, Content colConfig, String propertyName, Content parentNode) throws RepositoryException, AccessDeniedException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |