From: <die...@us...> - 2010-06-18 09:57:37
|
Revision: 2670 http://openutils.svn.sourceforge.net/openutils/?rev=2670&view=rev Author: diego_schivo Date: 2010-06-18 09:57:29 +0000 (Fri, 18 Jun 2010) Log Message: ----------- CONTROLS-31 fckedit column type Modified Paths: -------------- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/dialog/DialogGrid.java trunk/openutils-mgnlcontrols/src/main/resources/META-INF/magnolia/controls.xml trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl Added Paths: ----------- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.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/GridColumnTypeManager.java trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ControlsModule.java trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.fckedit.xml Added: 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 (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.java 2010-06-18 09:57:29 UTC (rev 2670) @@ -0,0 +1,54 @@ +/** + * + * 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.context.MgnlContext; + + +/** + * @author dschivo + * @version $Id$ + */ +public class FckEditorGridColumnType implements GridColumnType +{ + + /** + * {@inheritDoc} + */ + public String getHeadSnippet() + { + return "<script type=\"text/javascript\" src=\"" + + MgnlContext.getContextPath() + + "/.resources/controls/js/FckEditorField.js\"></script>"; + } + + /** + * {@inheritDoc} + */ + public String getColumnModelSnippet() + { + return "editor: new Ed(new FckEditorField({\n" + + "contextPath: '" + + MgnlContext.getContextPath() + + "'\n" + + "}))\n"; + } + +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/FckEditorGridColumnType.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/GridColumnType.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.java 2010-06-18 09:57:29 UTC (rev 2670) @@ -0,0 +1,41 @@ +/** + * + * 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; + +/** + * @author dschivo + * @version $Id$ + */ +public interface GridColumnType +{ + + /** + * Returns the headSnippet. + * @return the headSnippet + */ + public String getHeadSnippet(); + + /** + * Returns the columnModelSnippet. + * @return the columnModelSnippet + */ + public String getColumnModelSnippet(); + +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnType.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/GridColumnTypeManager.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnTypeManager.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnTypeManager.java 2010-06-18 09:57:29 UTC (rev 2670) @@ -0,0 +1,100 @@ +/** + * + * 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.beans.config.ObservedManager; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.util.ContentUtil; +import info.magnolia.cms.util.NodeDataUtil; +import info.magnolia.content2bean.Content2BeanUtil; +import info.magnolia.objectfactory.Components; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author dschivo + * @version $Id$ + */ +public class GridColumnTypeManager extends ObservedManager +{ + + public static GridColumnTypeManager getInstance() + { + return Components.getSingleton(GridColumnTypeManager.class); + } + + private Logger log = LoggerFactory.getLogger(getClass()); + + private final Map<String, GridColumnType> columnTypes = new HashMap<String, GridColumnType>(); + + /** + * Returns the types. + * @return the types + */ + public Map<String, GridColumnType> getColumnTypes() + { + return columnTypes; + } + + /** + * {@inheritDoc} + */ + @Override + protected void onClear() + { + columnTypes.clear(); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + protected void onRegister(Content node) + { + for (Iterator iter = ContentUtil.getAllChildren(node).iterator(); iter.hasNext();) + { + Content columnTypeNode = (Content) iter.next(); + + if (!NodeDataUtil.getBoolean(columnTypeNode, "enabled", true)) + { + continue; + } + + try + { + GridColumnType columnType = (GridColumnType) Content2BeanUtil.toBean(columnTypeNode); + + columnTypes.put(columnTypeNode.getName(), columnType); + } + catch (Throwable e) + { + log.error("Error getting column type {}", columnTypeNode.getHandle(), e); + } + } + } + +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/configuration/GridColumnTypeManager.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/dialog/DialogGrid.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/dialog/DialogGrid.java 2010-06-18 07:28:36 UTC (rev 2669) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/dialog/DialogGrid.java 2010-06-18 09:57:29 UTC (rev 2670) @@ -33,6 +33,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.sourceforge.openutils.mgnlcontrols.configuration.GridColumnTypeManager; + import org.apache.commons.lang.StringUtils; @@ -79,6 +81,9 @@ protected void addToParameters(Map<String, Object> parameters) { super.addToParameters(parameters); + + parameters.put("gridColumnTypes", GridColumnTypeManager.getInstance().getColumnTypes()); + String value = getValue(); if (value != null) { Added: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ControlsModule.java =================================================================== --- trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ControlsModule.java (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ControlsModule.java 2010-06-18 09:57:29 UTC (rev 2670) @@ -0,0 +1,56 @@ +/** + * + * 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.lifecycle; + +import info.magnolia.module.ModuleLifecycle; +import info.magnolia.module.ModuleLifecycleContext; +import net.sourceforge.openutils.mgnlcontrols.configuration.GridColumnTypeManager; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * @author dschivo + * @version $Id$ + */ +public class ControlsModule implements ModuleLifecycle +{ + + private Logger log = LoggerFactory.getLogger(getClass()); + + /** + * {@inheritDoc} + */ + public void start(ModuleLifecycleContext moduleLifecycleContext) + { + log.info("Starting module controls"); + moduleLifecycleContext.registerModuleObservingComponent("gridColumnTypes", GridColumnTypeManager.getInstance()); + } + + /** + * {@inheritDoc} + */ + public void stop(ModuleLifecycleContext moduleLifecycleContext) + { + log.info("Stopping module controls"); + } + +} Property changes on: trunk/openutils-mgnlcontrols/src/main/java/net/sourceforge/openutils/mgnlcontrols/lifecycle/ControlsModule.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/resources/META-INF/magnolia/controls.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/META-INF/magnolia/controls.xml 2010-06-18 07:28:36 UTC (rev 2669) +++ trunk/openutils-mgnlcontrols/src/main/resources/META-INF/magnolia/controls.xml 2010-06-18 09:57:29 UTC (rev 2670) @@ -4,6 +4,7 @@ <name>controls</name> <displayName>controls</displayName> <description>openutils magnolia controls module</description> + <class>net.sourceforge.openutils.mgnlcontrols.lifecycle.ControlsModule</class> <versionHandler>net.sourceforge.openutils.mgnlcontrols.setup.ControlsModuleVersionHandler</versionHandler> <version>${project.version}</version> <dependencies> Modified: trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2010-06-18 07:28:36 UTC (rev 2669) +++ trunk/openutils-mgnlcontrols/src/main/resources/dialogs/grid.ftl 2010-06-18 09:57:29 UTC (rev 2670) @@ -10,9 +10,12 @@ <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/CheckColumn.js"></script> <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/PipeComboBox.js"></script> <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/MediaField.js"></script> - <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/FckEditorField.js"></script> <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/FileField.js"></script> <script type="text/javascript" src="${request.contextPath}/.resources/controls/js/ColorField.js"></script> + [#list gridColumnTypes?values as gct] + ${gct.headSnippet} + [/#list] + <script type="text/javascript"> // <![CDATA[ function gridMoveRow(grid, delta) { @@ -163,10 +166,6 @@ renderer : function(v, p, record){ return v ? '<img border="0" alt="" src="${request.contextPath}/mediathumbnail/' + v + '" />' : v; } - [#elseif (colmap.type?? && colmap.type = 'fckedit')] - editor: new Ed(new FckEditorField({ - contextPath: '${request.contextPath}' - })) [#elseif (colmap.type?? && colmap.type = 'file')] editor: new Ed(new FileField({ })), @@ -179,6 +178,8 @@ 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>' : ''; } + [#elseif (colmap.type?? && gridColumnTypes[colmap.type]??)] + ${gridColumnTypes[colmap.type].columnModelSnippet} [#else] editor: new Ed(new fm.TextField({ allowBlank: true Added: trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.fckedit.xml =================================================================== --- trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.fckedit.xml (rev 0) +++ trunk/openutils-mgnlcontrols/src/main/resources/mgnl-bootstrap/controls/config.modules.controls.gridColumnTypes.fckedit.xml 2010-06-18 09:57:29 UTC (rev 2670) @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<sv:node sv:name="fckedit" 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>78844466-b609-4854-be67-5ce80321ee38</sv:value> + </sv:property> + <sv:property sv:name="class" sv:type="String"> + <sv:value>net.sourceforge.openutils.mgnlcontrols.configuration.FckEditorGridColumnType</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: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-18T11:42:33.906+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.fckedit.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |