Index: modules/org.opencms.editors/resources/manifest.xml =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.editors/resources/manifest.xml,v retrieving revision 1.44 diff -u -r1.44 manifest.xml --- modules/org.opencms.editors/resources/manifest.xml 3 Jul 2009 10:36:01 -0000 1.44 +++ modules/org.opencms.editors/resources/manifest.xml 24 Jun 2010 19:19:41 -0000 @@ -16,7 +16,7 @@ This module contains the OpenCms Common Editing tools.

This module is needed to be able to edit files in the OpenCms Workplace.

(c) 2007 by Alkacon Software GmbH (http://www.alkacon.com).

]]>
- 7.5.1 + 7.5.2.5 Mon, 27 Jun 2005 08:00:00 GMT Index: modules/org.opencms.workplace.explorer/resources/system/workplace/resources/commons/tree.js =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace.explorer/resources/system/workplace/resources/commons/tree.js,v retrieving revision 1.14 diff -u -r1.14 tree.js --- modules/org.opencms.workplace.explorer/resources/system/workplace/resources/commons/tree.js 18 Jan 2010 10:03:57 -0000 1.14 +++ modules/org.opencms.workplace.explorer/resources/system/workplace/resources/commons/tree.js 24 Jun 2010 19:19:43 -0000 @@ -88,6 +88,7 @@ var m_rootFolder = null; var m_sitePrefix = null; var m_treeType = null; +var m_resourcetypeIds = null; function treeObject(){ this.dfsToggleFound = false; @@ -547,6 +548,14 @@ } } +function getResourcetypeIds() { + return m_resourcetypeIds; +} + +function setResourcetypeIds(resourcetypeIds) { + m_resourcetypeIds = resourcetypeIds; +} + function setRootFolder(value) { m_rootFolder = value; } @@ -574,6 +583,9 @@ if (getTreeType()) { params += "&type=" + getTreeType(); } + if (getResourcetypeIds()) { + params += "&resourcetypeIds=" + getResourcetypeIds(); + } if (m_rootFolder) { nodeName = m_rootFolder + nodeName.substring(1); } @@ -638,9 +650,13 @@ if (!isProjectAware()) { params += "&projectaware=false"; } - if (getTreeType()) { - params += "&type=" + getTreeType(); - } + if (getTreeType()) { + params += "&type=" + getTreeType(); + } + if (getResourcetypeIds()) { + params += "&resourcetypeIds=" + getResourcetypeIds(); + } + var nodeNames = ""; for (var i=0; i < nodeListToLoad.length; i++) { var node = nodeListToLoad[i]; Index: build.xml =================================================================== RCS file: /usr/local/cvs/opencms/build.xml,v retrieving revision 1.225 diff -u -r1.225 build.xml --- build.xml 19 Jan 2010 10:39:16 -0000 1.225 +++ build.xml 24 Jun 2010 19:19:40 -0000 @@ -1,8 +1,8 @@ - + - + @@ -54,6 +54,8 @@ + + @@ -64,6 +66,13 @@ + + + + + + + @@ -212,6 +221,13 @@ includes="org/opencms/**" > + + + + + + + @@ -342,7 +358,17 @@ - + + + + + + @@ -436,7 +462,7 @@ - + @@ -523,7 +549,6 @@ - @@ -561,7 +586,14 @@ jarfile="${opencms.output.jars}/opencms-setup.jar" basedir="${opencms.output}/build/setup" includes="org/opencms/**" /> - + + + + + + + + @@ -658,6 +690,184 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: src/org/opencms/workplace/list/CmsListResourceTypeIconAction.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/workplace/list/CmsListResourceTypeIconAction.java,v retrieving revision 1.8 diff -u -r1.8 CmsListResourceTypeIconAction.java --- src/org/opencms/workplace/list/CmsListResourceTypeIconAction.java 18 Jan 2010 10:02:15 -0000 1.8 +++ src/org/opencms/workplace/list/CmsListResourceTypeIconAction.java 24 Jun 2010 19:19:48 -0000 @@ -31,7 +31,9 @@ package org.opencms.workplace.list; +import org.apache.commons.logging.Log; import org.opencms.i18n.CmsMessageContainer; +import org.opencms.main.CmsLog; import org.opencms.main.OpenCms; import org.opencms.util.CmsStringUtil; import org.opencms.workplace.CmsWorkplace; @@ -49,6 +51,9 @@ */ public class CmsListResourceTypeIconAction extends CmsListExplorerDirectAction { + /** The log object for this class. */ + private static final Log LOG = CmsLog.getLog(CmsListResourceTypeIconAction.class); + /** * Default Constructor.

* @@ -148,7 +153,7 @@ html.append(name); html.append("'"); html.append(" style='display: block; width: 20px; height: 20px;'>"); - if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(iconPath)) { + if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(iconPath) && hasFileExtension(iconPath)) { html.append(" /dev/null -# get path to tomcat home +# get path to tomcat home if [ -z "$TOMCAT_HOME" ]; then [ -n "$CATALINA_HOME" ] && TOMCAT_HOME="$CATALINA_HOME" [ -z "$TOMCAT_HOME" ] && TOMCAT_HOME="$OPENCMS_BASE"/../../.. Index: webapp/WEB-INF/cmsshell.bat =================================================================== RCS file: /usr/local/cvs/opencms/webapp/WEB-INF/cmsshell.bat,v retrieving revision 1.15 diff -u -r1.15 cmsshell.bat --- webapp/WEB-INF/cmsshell.bat 29 Oct 2008 12:46:48 -0000 1.15 +++ webapp/WEB-INF/cmsshell.bat 24 Jun 2010 19:19:49 -0000 @@ -66,23 +66,15 @@ :okTomcatHome rem Guess OPENCMS_LIB if not defined -if not "%OPENCMS_LIB%" == "" goto gotLib +if not "%OPENCMS_LIB%" == "" goto gotHome set OPENCMS_LIB=%OPENCMS_HOME%\lib :gotHome if exist "%OPENCMS_LIB%\opencms.jar" goto okLib +if exist "%OPENCMS_LIB%\opencms-core.jar" goto okLib echo The OPENCMS_LIB environment variable is not defined correctly echo This environment variable is needed to run this program goto end :okLib -rem Add all jars in lib dir to OPENCMS_CP variable (will include a initial semicolon ";") -for %%i in ("%OPENCMS_LIB%\*.jar") do call "%OPENCMS_HOME%\cpappend.bat" %%i - -rem Check for Tomcat libs -rem Add all jars in TOMCAT_HOME\common\lib dir to TOMCAT_LIB variable (will include a initial semicolon ";") -for %%i in ("%TOMCAT_HOME%\common\lib\*.jar") do call "%OPENCMS_HOME%\tlappend.bat" %%i -rem also support different tomcat folder structure -for %%i in ("%TOMCAT_HOME%\lib\*.jar") do call "%OPENCMS_HOME%\tlappend.bat" %%i -:okLib rem ----- Execute The Requested Command --------------------------------------- echo Using JAVA_HOME: %JAVA_HOME% @@ -95,18 +87,13 @@ rem Get command line arguments and save them in rem the CMD_LINE_ARGS environment variable -set CMD_LINE_ARGS= -:setArgs -if ""%1""=="""" goto doneSetArgs -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setArgs -:doneSetArgs +set CMD_LINE_ARGS=%* @rem set opencms arguments set CMD_LINE_ARGS=%CMD_LINE_ARGS% -base="%CD%" +echo %CMD_LINE_ARGS% rem execute OPENCMS -%_RUNJAVA% %JAVA_OPTS% -classpath "%OPENCMS_HOME%\classes%CLASSPATH%%OPENCMS_CP%%TOMCAT_LIB%" %MAINCLASS% %CMD_LINE_ARGS% +%_RUNJAVA% %JAVA_OPTS% -Djava.ext.dirs=%OPENCMS_LIB%;%TOMCAT_HOME%\common\lib;%TOMCAT_HOME%\lib -classpath "%OPENCMS_HOME%\classes%CLASSPATH%" %MAINCLASS% %CMD_LINE_ARGS% :end \ No newline at end of file Index: modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_fs.jsp =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_fs.jsp,v retrieving revision 1.5 diff -u -r1.5 tree_fs.jsp --- modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_fs.jsp 6 Jul 2007 09:52:13 -0000 1.5 +++ modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_fs.jsp 24 Jun 2010 19:19:43 -0000 @@ -30,6 +30,13 @@ params.append("=true"); } + if (wp.getResourcetypeIds() != null) { + params.append("&"); + params.append(CmsTree.PARAM_RESOURCETYPE_IDS); + params.append("="); + params.append(wp.getResourcetypeIds()); + } + String frameRows = "*,0"; String frameSiteSelector = ""; if (wp.showSiteSelector()) { Index: modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_siteselector.jsp =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_siteselector.jsp,v retrieving revision 1.5 diff -u -r1.5 tree_siteselector.jsp --- modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_siteselector.jsp 9 Jun 2008 13:41:54 -0000 1.5 +++ modules/org.opencms.workplace.explorer/resources/system/workplace/views/explorer/tree_siteselector.jsp 24 Jun 2010 19:19:43 -0000 @@ -32,8 +32,9 @@

- - + + + <%= wp.getSiteSelector("name=\"treesite\" onchange=\"changeSite();\" style=\"width:250px;\"") %>
Index: modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/editor_form.jsp =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/editor_form.jsp,v retrieving revision 1.15 diff -u -r1.15 editor_form.jsp --- modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/editor_form.jsp 9 Jun 2009 12:21:36 -0000 1.15 +++ modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/editor_form.jsp 24 Jun 2010 19:19:41 -0000 @@ -298,9 +298,80 @@ //--> + + +
+
+
+
Modal Window
+
close
+
+ +
+
"> @@ -314,6 +385,7 @@ + <%= wp.getXmlEditorForm() %> Index: modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/edit.js =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/edit.js,v retrieving revision 1.16 diff -u -r1.16 edit.js --- modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/edit.js 18 Jan 2010 10:04:29 -0000 1.16 +++ modules/org.opencms.editors/resources/system/workplace/editors/xmlcontent/edit.js 24 Jun 2010 19:19:41 -0000 @@ -190,14 +190,88 @@ } // add an optional element to the currently edited content -function addElement(elemName, insertAfter) { +function addElement(elemName, insertAfter, choiceList) { setLastPosition(); var _form = document.EDITOR; _form.elementname.value = elemName; _form.elementindex.value = insertAfter; + if (choiceList.length == 0){ + buttonAction(5); + } else if (choiceList.length == 1){ + addChoiceElement(choiceList[0].Name); + } else { + // more than one element + showChoiceSelection(choiceList); + } +} + +function addChoiceElement(elemName) { + var _form = document.EDITOR; + _form.choiceelementname.value = elemName; buttonAction(5); } +// shows the possible SubElements for a Choice-NestedContentType +function showChoiceSelection(choiceList) { + + // get Choice element + var choiceOverlay = document.getElementById("CHOICE_OVERLAY"); + var choiceSelectElem = document.getElementById("CHOICE_SELECT"); + var choiceSelectLinksElem = document.getElementById("CHOICE_SELECT_LINKS"); + + // create the button row HTML + var i = 0; + var linkList =""; + for (i=0; i < choiceList.length; i++){ + if (i > 0){ + linkList += "
"; + } + linkList += ""; + linkList += choiceList[i].Label; + linkList += ""; + if (choiceList[i].Help){ + linkList += " ("; + linkList += choiceList[i].Help; + linkList += ")"; + } + } + + + // set the created HTML into the ModalBox + choiceSelectLinksElem.innerHTML = linkList; + + // arrange the Modal-Box + var height = document.body.clientHeight/2; + var width = document.body.clientWidth/2; + choiceSelectElem.style.height = height + 'px'; + choiceSelectElem.style.width = width + 'px'; + choiceSelectLinksElem.style.height = height + 'px'; + choiceSelectLinksElem.style.width = width + 'px'; + choiceSelectElem.style.top = document.body.scrollTop+(document.body.clientHeight - height)/2; + choiceSelectElem.style.left = document.body.scrollLeft+(document.body.clientWidth - width)/2; + + // show the Modal-Box + choiceSelectElem.style.display = "block"; + + // show the Gay Background + choiceOverlay.style.height = document.body.scrollHeight + 'px'; + choiceOverlay.style.width = document.body.scrollWidth + 'px'; + choiceOverlay.style.display = "block"; + +} + + +function closeChoiceSelection() { + var _form = document.EDITOR; + // reset the Data + _form.elementname.value = ""; + _form.elementindex.value = ""; + _form.choiceelementname.value = ""; + // close the Modal-Box + document.getElementById('CHOICE_SELECT').style.display ='none'; + document.getElementById('CHOICE_OVERLAY').style.display = 'none'; +} + // move an element in currently edited content function moveElement(elemName, index, direction) { setLastPosition(); @@ -307,7 +381,7 @@ } // shows the element operation buttons -function showElementButtons(elementName, elementIndex, showRemove, showUp, showDown, showAdd) { +function showElementButtons(elementName, elementIndex, showRemove, showUp, showDown, showAdd, choiceList) { var elemId = elementName + "." + elementIndex; if (oldEditorButtons != null && oldEditorButtons != elemId) { // close eventually open element buttons @@ -342,7 +416,7 @@ // add element button if (showAdd) { - buttons += button("javascript:addElement('" + elementName + "', " + elementIndex + ")", null, "new", LANG_BT_ADD, buttonStyle); + buttons += button("javascript:addElement('" + elementName + "', " + elementIndex + ", " + choiceList + ")", null, "new", LANG_BT_ADD, buttonStyle); } else { buttons += button(null, null, "new_in", LANG_BT_ADD, buttonStyle); } Index: modules/org.opencms.workplace/resources/manifest.xml =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace/resources/manifest.xml,v retrieving revision 1.70 diff -u -r1.70 manifest.xml --- modules/org.opencms.workplace/resources/manifest.xml 14 Jan 2010 14:52:05 -0000 1.70 +++ modules/org.opencms.workplace/resources/manifest.xml 24 Jun 2010 19:19:45 -0000 @@ -16,7 +16,7 @@ This module contains the OpenCms Workplace base files.

It includes common used dialogs and style sheets, that are needed by any workplace module.

(c) 2010 by Alkacon Software GmbH (http://www.alkacon.com).

]]>
- 7.5.2 + 7.5.2.4 Mon, 27 Jun 2005 08:00:00 GMT Index: src/org/opencms/widgets/CmsVfsFileWidget.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/widgets/CmsVfsFileWidget.java,v retrieving revision 1.24 diff -u -r1.24 CmsVfsFileWidget.java --- src/org/opencms/widgets/CmsVfsFileWidget.java 18 Jan 2010 10:01:01 -0000 1.24 +++ src/org/opencms/widgets/CmsVfsFileWidget.java 24 Jun 2010 19:19:46 -0000 @@ -32,10 +32,16 @@ package org.opencms.widgets; import org.opencms.file.CmsObject; +import org.opencms.loader.CmsLoaderException; +import org.opencms.main.CmsLog; import org.opencms.main.OpenCms; import org.opencms.util.CmsStringUtil; import org.opencms.workplace.CmsWorkplace; +import java.util.Arrays; + +import org.apache.commons.logging.Log; + /** * Provides a OpenCms VFS file selection widget, for use on a widget dialog.

* @@ -47,6 +53,9 @@ */ public class CmsVfsFileWidget extends A_CmsWidget { + /** The static log object for this class. */ + private static final Log LOG = CmsLog.getLog(CmsVfsFileWidget.class); + /** Configuration parameter to set the flag to include files in popup resource tree. */ public static final String CONFIGURATION_EXCLUDEFILES = "excludefiles"; @@ -68,6 +77,9 @@ /** Configuration parameter to set start site of the popup resource tree. */ public static final String CONFIGURATION_STARTSITE = "startsite"; + /** Configuration parameter to set the name of the resource types to accept. */ + public static final String CONFIGURATION_RESOURCETYPENAMES = "resourcetypeNames"; + /** Flag to determine if files should be shown in popup window. */ private boolean m_includeFiles; @@ -80,6 +92,9 @@ /** The start site used in the popup window. */ private String m_startSite; + /** The value for the resource types to accept. */ + private String[] m_resourcetypeNames; + /** * Creates a new vfs file widget.

*/ @@ -121,11 +136,25 @@ * @param projectAware true if resources outside of the current project should be displayed as normal */ public CmsVfsFileWidget(boolean showSiteSelector, String startSite, boolean includeFiles, boolean projectAware) { + this(showSiteSelector, startSite, includeFiles, projectAware, null); + } + + /** + * Creates a new vfs file widget with the parameters to configure the popup tree window behavior.

+ * + * @param showSiteSelector true if the site selector should be shown in the popup window + * @param startSite the start site root for the popup window + * @param includeFiles true if files should be shown in the popup window + * @param projectAware true if resources outside of the current project should be displayed as normal + * @param resourcetypeNames the resource types to accept. + */ + public CmsVfsFileWidget(boolean showSiteSelector, String startSite, boolean includeFiles, boolean projectAware, String[] resourcetypeNames) { m_showSiteSelector = showSiteSelector; m_startSite = startSite; m_includeFiles = includeFiles; m_projectAware = projectAware; + m_resourcetypeNames = resourcetypeNames; } /** @@ -176,7 +205,19 @@ } else { result.append(CONFIGURATION_NOTPROJECTAWARE); } - + // S.Softic append flag for file restrictions + if (m_resourcetypeNames != null && m_resourcetypeNames.length > 0) { + result.append("|"); + result.append(CONFIGURATION_RESOURCETYPENAMES); + result.append("="); + result.append(CmsStringUtil.arrayAsString( + m_resourcetypeNames, + ",")); + } + if (LOG.isDebugEnabled()) { + LOG.debug("m_resourcetypeNames: " + Arrays.toString(m_resourcetypeNames)); + LOG.debug(result.toString()); + } return result.toString(); } @@ -230,7 +271,8 @@ public String getDialogWidget(CmsObject cms, I_CmsWidgetDialog widgetDialog, I_CmsWidgetParameter param) { String id = param.getId(); - StringBuffer result = new StringBuffer(128); + // S.Softic adding some space to the buffer + StringBuffer result = new StringBuffer(200); result.append(""); result.append("
"); @@ -248,7 +290,8 @@ result.append(widgetDialog.dialogHorizontalSpacer(10)); result.append(""); - StringBuffer buttonJs = new StringBuffer(8); + // S.Softic adding some space to the buffer + StringBuffer buttonJs = new StringBuffer(35); buttonJs.append("javascript:openTreeWin('EDITOR', '"); buttonJs.append(id); buttonJs.append("', document, "); @@ -265,7 +308,10 @@ // project awareness buttonJs.append(", "); buttonJs.append(m_projectAware); - buttonJs.append(");return false;"); + // resourcetypeIds + buttonJs.append(", '"); + buttonJs.append(getRestrictResTypeIdsAsString(",")); + buttonJs.append("');return false;"); result.append(widgetDialog.button( buttonJs.toString(), @@ -347,7 +393,55 @@ // resources outside of the current project should not be disabled m_projectAware = false; } + + //setting the configuration + if (configuration.indexOf(CONFIGURATION_RESOURCETYPENAMES) !=-1) { + String restriction = configuration.substring(configuration.indexOf(CONFIGURATION_RESOURCETYPENAMES)+CONFIGURATION_RESOURCETYPENAMES.length() + 1); + if (restriction.indexOf('|') != -1) { + // cut eventual following configuration values + restriction = restriction.substring(0, restriction.indexOf('|')); + } + else { + restriction = restriction.substring(0, restriction.length()); + } + + m_resourcetypeNames = CmsStringUtil.splitAsArray( + restriction, + ","); + if (LOG.isDebugEnabled()) { + LOG.debug("m_restrictResTypes.length: " + m_resourcetypeNames.length); + LOG.debug("m_restrictResTypes: " + Arrays.toString(m_resourcetypeNames)); + } + } } super.setConfiguration(configuration); } + + /** + * Get The restricted ResourceType Ids as String with the given delimiter. + * + * @param delimiter + * @return String of Ids + */ + protected String getRestrictResTypeIdsAsString(String delimiter) { + if (m_resourcetypeNames == null) { + //TODO Harald.Brabenetz 28.01.2010 : Check if this should return null or empty String. + return ""; + } + StringBuffer result = new StringBuffer(); + for (int i = 0; i < m_resourcetypeNames.length; i++) { + String resourceTypeName = m_resourcetypeNames[i]; + try { + int id = OpenCms.getResourceManager().getResourceType(resourceTypeName).getTypeId(); + if (result.length() > 0) { + result.append(delimiter); + } + LOG.info("append id: " + id); + result.append(id); + } catch (CmsLoaderException e) { + LOG.warn("No id found for ResourceTyp '" + resourceTypeName + "'", e); + } + } + return result.toString(); + } } Index: test/test.properties =================================================================== RCS file: /usr/local/cvs/opencms/test/test.properties,v retrieving revision 1.35 diff -u -r1.35 test.properties --- test/test.properties 26 Feb 2009 11:59:18 -0000 1.35 +++ test/test.properties 24 Jun 2010 19:19:49 -0000 @@ -27,5 +27,5 @@ db.product=hsqldb # Set the path to the test resources files -test.data.path=C:\dev\workspace\OpenCmsHead\test\data -test.webapp.path=C:\dev\workspace\OpenCmsHead\webapp +test.data.path=test\data +test.webapp.path=webapp Index: src/org/opencms/xml/CmsXmlComplexTypeSequence.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/xml/CmsXmlComplexTypeSequence.java,v retrieving revision 1.8 diff -u -r1.8 CmsXmlComplexTypeSequence.java --- src/org/opencms/xml/CmsXmlComplexTypeSequence.java 18 Jan 2010 10:04:10 -0000 1.8 +++ src/org/opencms/xml/CmsXmlComplexTypeSequence.java 24 Jun 2010 19:19:48 -0000 @@ -55,18 +55,23 @@ /** The type sequence elements. */ private List m_sequence; + /** Returns true if this sequence is created from a {@link CmsXmlContentDefinition#XSD_NODE_CHOICE}-Element. */ + protected boolean m_isChoiceSequence; + /** * Creates a new complex type sequence data structure.

* * @param name the name of the sequence * @param sequence the type sequence element list * @param hasLanguageAttribute indicates if a "language" attribute is present + * @param isChoiceSequence the type choice element list */ - protected CmsXmlComplexTypeSequence(String name, List sequence, boolean hasLanguageAttribute) { + protected CmsXmlComplexTypeSequence(String name, List sequence, boolean hasLanguageAttribute, boolean isChoiceSequence) { m_name = name; m_sequence = sequence; m_hasLanguageAttribute = hasLanguageAttribute; + m_isChoiceSequence = isChoiceSequence; } /** Index: src/org/opencms/xml/CmsXmlContentDefinition.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/xml/CmsXmlContentDefinition.java,v retrieving revision 1.47 diff -u -r1.47 CmsXmlContentDefinition.java --- src/org/opencms/xml/CmsXmlContentDefinition.java 18 Jan 2010 10:04:12 -0000 1.47 +++ src/org/opencms/xml/CmsXmlContentDefinition.java 24 Jun 2010 19:19:49 -0000 @@ -146,6 +146,9 @@ /** Constant for the "sequence" node in the XML schema namespace. */ public static final QName XSD_NODE_SEQUENCE = QName.get("sequence", XSD_NAMESPACE); + /** Constant for the "choice" node in the XML schema namespace. */ + public static final QName XSD_NODE_CHOICE = QName.get("choice", XSD_NAMESPACE); + /** The XML content handler. */ private I_CmsXmlContentHandler m_contentHandler; @@ -158,6 +161,9 @@ /** The outer element name of the content definition (language sequence). */ private String m_outerName; + /** Returns true if this sequence is created from a {@link #XSD_NODE_CHOICE}-Element. */ + private boolean m_isChoiceSequence; + /** The location from which the XML schema was read (XML system id). */ private String m_schemaLocation; @@ -523,15 +529,21 @@ // no error: then the language attribute is valid hasLanguageAttribute = true; } - + + boolean isChoice = false; + // check the main element type sequence Element typeSequence = mainElements.get(0); if (!XSD_NODE_SEQUENCE.equals(typeSequence.getQName())) { + if (!XSD_NODE_CHOICE.equals(typeSequence.getQName())) { throw new CmsXmlException(Messages.get().container( Messages.ERR_CD_ELEMENT_NAME_3, typeSequence.getUniquePath(), XSD_NODE_SEQUENCE.getQualifiedName(), typeSequence.getQName().getQualifiedName())); + } else { + isChoice = true; + } } // check the type definition sequence @@ -553,7 +565,7 @@ CmsXmlContentTypeManager typeManager = OpenCms.getXmlContentTypeManager(); Iterator i = typeSequenceElements.iterator(); while (i.hasNext()) { - sequence.add(typeManager.getContentType(i.next(), includes)); + sequence.add(typeManager.getContentType((Element)i.next(), includes, isChoice)); } } else { // generate a nested content definition for the main type sequence @@ -569,7 +581,7 @@ } // return a data structure with the collected values - return new CmsXmlComplexTypeSequence(name, sequence, hasLanguageAttribute); + return new CmsXmlComplexTypeSequence(name, sequence, hasLanguageAttribute, isChoice); } /** @@ -704,8 +716,8 @@ result.setInnerName(outer.getName()); // get the inner element sequence, this must be the second element - CmsXmlComplexTypeSequence innerSequence = complexTypeData.get(1); - + CmsXmlComplexTypeSequence innerSequence = (CmsXmlComplexTypeSequence)complexTypeData.get(1); + result.m_isChoiceSequence =innerSequence.m_isChoiceSequence; // add the types from the main sequence node Iterator it = innerSequence.getSequence().iterator(); while (it.hasNext()) { @@ -852,6 +864,7 @@ result.m_contentHandler = m_contentHandler; result.m_typeName = m_typeName; result.m_includes = m_includes; + result.m_isChoiceSequence = m_isChoiceSequence; return result; } @@ -1174,4 +1187,16 @@ m_outerName = outerName; } + + + /** + * Returns true if this sequence is created from a {@link #XSD_NODE_CHOICE}-Element. + * + * @return true if this sequence is created from a {@link #XSD_NODE_CHOICE}-Element. + * + * @see CmsXmlNestedContentDefinition + */ + public boolean isChoiceType() { + return m_isChoiceSequence; + } } \ No newline at end of file Index: src/org/opencms/xml/CmsXmlContentTypeManager.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/xml/CmsXmlContentTypeManager.java,v retrieving revision 1.39 diff -u -r1.39 CmsXmlContentTypeManager.java --- src/org/opencms/xml/CmsXmlContentTypeManager.java 18 Jan 2010 10:04:11 -0000 1.39 +++ src/org/opencms/xml/CmsXmlContentTypeManager.java 24 Jun 2010 19:19:49 -0000 @@ -324,15 +324,19 @@ * Generates an initialized instance of a XML content type definition * from the given XML schema element.

* - * @param typeElement the element to generate the XML content type definition from - * @param nestedDefinitions the nested (included) XML content sub-definitions + * @param typeElement + * The element to generate the XML content type definition from + * @param nestedDefinitions + * The nested (included) XML content sub-definitions + * @param isChoice + * true if this node is an element of a Choice XSD element. + * In this case the maxOccurs is always handled as "1" and minOccurs is always handled as "0". * * @return an initialized instance of a XML content type definition * @throws CmsXmlException in case the element does not describe a valid XML content type definition */ - public I_CmsXmlSchemaType getContentType(Element typeElement, Set nestedDefinitions) + public I_CmsXmlSchemaType getContentType(Element typeElement, Set nestedDefinitions, boolean isChoice) throws CmsXmlException { - if (!CmsXmlContentDefinition.XSD_NODE_ELEMENT.equals(typeElement.getQName())) { throw new CmsXmlException(Messages.get().container(Messages.ERR_INVALID_CD_SCHEMA_STRUCTURE_0)); } @@ -345,7 +349,12 @@ String defaultValue = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_DEFAULT); String maxOccrs = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_MAX_OCCURS); String minOccrs = typeElement.attributeValue(CmsXmlContentDefinition.XSD_ATTRIBUTE_MIN_OCCURS); - + // a schemyType inside a Choice-ContentDefinition can only occurred one time. + if (isChoice) { + minOccrs = CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_ZERO; + maxOccrs = "1"; + } + if (CmsStringUtil.isEmpty(elementName) || CmsStringUtil.isEmpty(typeName)) { throw new CmsXmlException(Messages.get().container(Messages.ERR_INVALID_CD_SCHEMA_STRUCTURE_0)); } @@ -362,7 +371,14 @@ if (typeName.equals(cd.getTypeName())) { simpleType = false; - return new CmsXmlNestedContentDefinition(cd, elementName, minOccrs, maxOccrs); + if (cd.isChoiceType()) { + // A Choice Element itself is always optional. + // the initial XML content (create new resource) can not be automatically generated if minOccurs > 0 + // the editor must choose the sub element! + return new CmsXmlNestedContentDefinition(cd, elementName, CmsXmlContentDefinition.XSD_ATTRIBUTE_VALUE_ZERO, maxOccrs); + } else { + return new CmsXmlNestedContentDefinition(cd, elementName, minOccrs, maxOccrs); + } } } Index: src/org/opencms/workplace/CmsWorkplace.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWorkplace.java,v retrieving revision 1.180 diff -u -r1.180 CmsWorkplace.java --- src/org/opencms/workplace/CmsWorkplace.java 18 Jan 2010 10:03:36 -0000 1.180 +++ src/org/opencms/workplace/CmsWorkplace.java 24 Jun 2010 19:19:47 -0000 @@ -748,7 +748,7 @@ String anchorStart = " don't jump to the Top of the page. } result.append("

"); if (!collapseLabel) { @@ -1795,13 +1905,13 @@ result.append("Disabled"); } result.append("\">"); - result.append(keyDefault(A_CmsWidget.getLabelKey((I_CmsWidgetParameter)value), value.getName())); + result.append(label); if (elementCount > 1) { - result.append(" [").append(value.getIndex() + 1).append("]"); + result.append(" [").append(valueIndex + 1).append("]"); } result.append(": "); if (showHelpBubble && (widget != null) && (value.getIndex() == 0)) { - // show help bubble only on first element of each content definition + // show help bubble only on first element of each content definition (if it is a Choice-Value than value.getIndex() is always 0) result.append(widget.getHelpBubble(getCms(), this, (I_CmsWidgetParameter)value)); } else { // create empty cell for all following elements @@ -1812,17 +1922,31 @@ // append individual widget html cell if element is enabled if (!disabledElement) { if (widget == null) { - // recurse into nested type sequence - String newPath = CmsXmlUtils.createXpathElement(value.getName(), value.getIndex() + 1); - result.append(""); + + if (nestedContentDefinition.isChoiceType()) { + //include subelement + String newPath = CmsXmlUtils.createXpathElement(value.getName(), value.getIndex() + 1); // if it is a Choice-Value than value.getIndex() is always 0 + result.append(""); + } else { + String newPath = CmsXmlUtils.createXpathElement(value.getName(), value.getIndex() + 1); + result.append(""); + } + } else { // this is a simple type, display widget result.append(widget.getDialogWidget(getCms(), this, (I_CmsWidgetParameter)value)); @@ -1835,7 +1959,7 @@ } // append element operation (add, remove, move) buttons if required - result.append(buildElementButtons(name, value.getIndex(), addValue, removeValue)); + result.append(buildElementButtons(name, valueIndex, addValue, removeValue, new JSONArray(choiceList).toString())); // close row result.append("\n"); @@ -1874,6 +1998,211 @@ } /** + * Get some infos of The SubElement of this ChoiceElements:
+ * (a Choice-Element can only have one Subelement.)
+ * - pathPrefix: only necessary if the Choice-SubElement is a NestedContent (for recursive-Call of this function)
+ * - I_CmsXmlContentValue value:
+ * - Widget or NestedContentDefinition)
+ *
+ * return the ValueHolder With the nestedContentDefinition, pathprefix and value of the single SubElement
+ * Or recursively the SubSubElement who is not a Choice NestedContentDefinition.
+ * + * @param valueHolder Contains the nestedContentDefinition, pathprefix and value of the parentElement. + * @return the ValueHolder With the (nestedContentDefinition or widget), pathprefix and value of the single SubElement (or recursively the SubSubElement who is not a Choice NestedContentDefinition.). + * @throws CmsXmlException + */ + private ChoiceSubElementValueHolder getChoiceSubElement(ChoiceSubElementValueHolder valueHolder) throws CmsXmlException { + + String newPath = CmsXmlUtils.createXpathElement(valueHolder.getValue().getName(), valueHolder.getValue().getIndex() + 1); + + // GET new PathPrefix + valueHolder.setPathPrefix(valueHolder.getPathPrefix() + newPath + "/"); + + // iterate the type sequence and search a value with this type + Iterator choiceSubElementTypeIterator = valueHolder.getNestedContentDefinition().getTypeSequence().iterator(); + while (choiceSubElementTypeIterator.hasNext()) { + + // get the type of possible SubElements + I_CmsXmlSchemaType choiceSubElementType = (I_CmsXmlSchemaType)choiceSubElementTypeIterator.next(); + + + // create xpath to the Sub element of this Choice-Element + String choiceSubElementName = valueHolder.getPathPrefix() + choiceSubElementType.getName(); + + if (LOG.isDebugEnabled()) { + LOG.debug("choiceSubElementName: " + choiceSubElementName); + } + + // get the element sequence of the current type + CmsXmlContentValueSequence choiceSubElementSequence = m_content.getValueSequence(choiceSubElementName, getElementLocale()); + if (choiceSubElementSequence == null) { + // No choiceSubElementType found, goto next choiceSubElementType + LOG.error("should not occured"); + continue; + } + + int choiceSubElementCount = choiceSubElementSequence.getElementCount(); + if (choiceSubElementCount < 1) { + // No element found for this choiceSubElementType, goto next choiceSubElementType + continue; + } + + if (choiceSubElementCount > 1) { // Choice-Sub-Elements can only occurede one time. + LOG.warn("choiceSubElementCount > 1: '" + m_content.getFile().getRootPath() + "'; '" + valueHolder.getPathPrefix() + "'"); + } + + // get the first choiceSubElementValue + valueHolder.setValue(choiceSubElementSequence.getValue(0)); + + // get Lable + String label = keyDefault(A_CmsWidget.getLabelKey((I_CmsWidgetParameter)valueHolder.getValue()), valueHolder.getValue().getName()); + if (!CmsStringUtil.isEmpty(valueHolder.getLabel())) { + if (!CmsStringUtil.isEmpty(label)) { + label = valueHolder.getLabel().concat("/").concat(label); + } + } + valueHolder.setLabel(label); + + // get Widget or NestedContentDefinition or recursivly the result of the Choice-NestedContentDefinition + if (choiceSubElementType.isSimpleType()) { + valueHolder.setWidget(valueHolder.getNestedContentDefinition().getContentHandler().getWidget(valueHolder.getValue())); + } else { + // get nested content definition for nested types + CmsXmlNestedContentDefinition choiceSubElementNestedSchema = (CmsXmlNestedContentDefinition)choiceSubElementType; + valueHolder.setNestedContentDefinition(choiceSubElementNestedSchema.getNestedContentDefinition()); + if (valueHolder.getNestedContentDefinition().isChoiceType()) { + LOG.info("Nested ChoiceContentDefinition found: " + valueHolder.getPathPrefix()); + valueHolder = getChoiceSubElement(valueHolder); + } + } + + // found one Sub-Element found in Choice-Element + return valueHolder; // exit loop + } + + LOG.warn("NO nestedContent- Choice-Value found: " + valueHolder.getPathPrefix()); + return valueHolder; + } + + /** + * add Choice-Element to Choice-List (needed for Javascript-ADD-Button). + * + * @param choiceList The ChoiceList where The Choice-Element should be added + * @param contentDefinition The contentDefinition who contents this choiceSubElementType + * @param choiceSubElementType The element type of the Choice-Element who should be added + * @throws JSONException + */ + private void addChoiceElementToChoiceList(List choiceList, CmsXmlContentDefinition contentDefinition, I_CmsXmlSchemaType choiceSubElementType) throws JSONException { + addChoiceElementToChoiceList(choiceList, contentDefinition, choiceSubElementType, "", ""); + } + + /** + * add Choice-Element to Choice-List recursively (needed for Javascript-ADD-Button). + * + * @param choiceList The ChoiceList where The Choice-Element should be added + * @param contentDefinition The contentDefinition who contents this choiceSubElementType + * @param choiceSubElementType The element type of the Choice-Element who should be added + * @param labelPrefix the Labelprefix of the previously called {@link #addChoiceElementToChoiceList(List, CmsXmlContentDefinition, I_CmsXmlSchemaType, String, String)} + * @param namePrefix the Nameprefix of the previously called {@link #addChoiceElementToChoiceList(List, CmsXmlContentDefinition, I_CmsXmlSchemaType, String, String)} + * @throws JSONException + */ + private void addChoiceElementToChoiceList(List choiceList, CmsXmlContentDefinition contentDefinition, I_CmsXmlSchemaType choiceElementType, String labelPrefix, String namePrefix) throws JSONException { + StringBuffer labelKey = new StringBuffer(128); + String helpKey; + // The following code is not used in XmlContentEditor (Only used in Administration-View etc....) +// if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(pathPrefix)) { +// labelKey.append(pathPrefix); +// labelKey.append('.'); +// } + labelKey.append(A_CmsWidget.LABEL_PREFIX); + labelKey.append(contentDefinition.getInnerName()); + labelKey.append('.'); + labelKey.append(choiceElementType.getName()); + + helpKey = labelKey.toString().concat(A_CmsWidget.HELP_POSTFIX); + + + if (LOG.isDebugEnabled()) { + LOG.debug("labelKey: " + labelKey.toString()); + LOG.debug("helpKey: " + helpKey); + } + + String label = keyDefault(labelKey.toString(), choiceElementType.getName()); + String help = keyDefault(helpKey, ""); + String name = choiceElementType.getName(); + + // append Prefixes to Name & Label + if (!CmsStringUtil.isEmpty(namePrefix)) { + name = namePrefix.concat("/").concat(name); + } + if (!CmsStringUtil.isEmpty(labelPrefix)) { + if (!CmsStringUtil.isEmpty(label)) { + label = labelPrefix.concat("/").concat(label); + } + } + + + // add Choice-Element to Choice-List + if (isChoiceType(choiceElementType)) { + CmsXmlContentDefinition nestedContentDefinition = getNestedContentDefinition(choiceElementType); + + // recursive call if this is a Choice-NestedContentDefinition + Iterator choiceSubElementTypeIterator = nestedContentDefinition.getTypeSequence().iterator(); + while (choiceSubElementTypeIterator.hasNext()) { + // get the type of possible SubElements + I_CmsXmlSchemaType choiceSubElementType = (I_CmsXmlSchemaType)choiceSubElementTypeIterator.next(); + + // add Choice-Element to Choice-List + addChoiceElementToChoiceList(choiceList, nestedContentDefinition, choiceSubElementType, label, name); + } + } else { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("Label", label); + jsonObj.put("Name", name); + if (!CmsStringUtil.isEmpty(help)) { + jsonObj.put("Help", help); + } + choiceList.add(jsonObj); + } + } + + /** + * check if this choiceElementType is a Choice-NestedContentDefinition. + * + * @param choiceElementType true if this element is a choice-element + * + * @return + */ + private boolean isChoiceType(I_CmsXmlSchemaType choiceElementType) { + + boolean isChoiceType; + CmsXmlContentDefinition nestedContentDefinition = null; + if (choiceElementType.isSimpleType()) { + isChoiceType = false; + } else { + nestedContentDefinition = getNestedContentDefinition(choiceElementType); + + // get Choice-Elements to Choice-List (needed for Javascript-ADD-Button) + if (nestedContentDefinition.isChoiceType()) { + isChoiceType = true; + } else { + isChoiceType = false; + } + } + return isChoiceType; + } + + private CmsXmlContentDefinition getNestedContentDefinition(I_CmsXmlSchemaType nestedSchema) { + + if (nestedSchema instanceof CmsXmlNestedContentDefinition) { + CmsXmlContentDefinition nestedContentDefinition = ((CmsXmlNestedContentDefinition)nestedSchema).getNestedContentDefinition(); + return nestedContentDefinition; + } else { + throw new IllegalArgumentException("The nestedSchema must be an Inxtance of CmsXmlNestedContentDefinition."); + } + } + + /** * Resets the error handler member variable to reinitialize the error messages.

*/ private void resetErrorHandler() { @@ -1908,4 +2237,57 @@ m_file = getCloneCms().writeFile(m_file); m_content = CmsXmlContentFactory.unmarshal(getCloneCms(), m_file); } + + /** + * The recursive function {@link CmsXmlContentEditor#getChoiceSubElement(ChoiceSubElementValueHolder)}
+ * Returns more then one Value: A ValueHolder is needed.
+ * + * @author harald brabenetz + */ + private class ChoiceSubElementValueHolder { + private String m_pathPrefix; // only necessary if the Choice-SubElement is a NestedContent (recursive-Calls) + private CmsXmlContentDefinition m_nestedContentDefinition; //only used if widget==null + private I_CmsXmlContentValue m_value; + private I_CmsWidget m_widget; + private String m_label; + + public ChoiceSubElementValueHolder(CmsXmlContentDefinition nestedContentDefinition, String pathPrefix, I_CmsXmlContentValue value, I_CmsWidget widget) { + super(); + this.m_nestedContentDefinition = nestedContentDefinition; + this.m_pathPrefix = pathPrefix; + this.m_value = value; + this.m_widget = widget; + } + + public CmsXmlContentDefinition getNestedContentDefinition() { + return m_nestedContentDefinition; + } + public void setNestedContentDefinition(CmsXmlContentDefinition nestedContentDefinition) { + this.m_nestedContentDefinition = nestedContentDefinition; + } + public String getPathPrefix() { + return m_pathPrefix; + } + public void setPathPrefix(String pathPrefix) { + this.m_pathPrefix = pathPrefix; + } + public I_CmsXmlContentValue getValue() { + return m_value; + } + public void setValue(I_CmsXmlContentValue value) { + this.m_value = value; + } + public I_CmsWidget getWidget() { + return m_widget; + } + public void setWidget(I_CmsWidget widget) { + this.m_widget = widget; + } + public String getLabel() { + return m_label; + } + public void setLabel(String label) { + this.m_label = label; + } + } } \ No newline at end of file Index: modules/org.opencms.editors/resources/system/workplace/resources/editors/directedit/jq_edit.js =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.editors/resources/system/workplace/resources/editors/directedit/jq_edit.js,v retrieving revision 1.2 diff -u -r1.2 jq_edit.js --- modules/org.opencms.editors/resources/system/workplace/resources/editors/directedit/jq_edit.js 25 Mar 2008 09:12:44 -0000 1.2 +++ modules/org.opencms.editors/resources/system/workplace/resources/editors/directedit/jq_edit.js 24 Jun 2010 19:19:42 -0000 @@ -161,6 +161,7 @@ /** Function to set the position of the buttons to the correct position. **/ var func_ocms_de_reposition = function() { + if(this.offsetParent) { var offset = $(this).calcOcmsDeOffset(); offset.left = offset.left + $(this).width() - $('#buttons_'+this.id).width(); $('#buttons_'+this.id).css(offset); @@ -169,6 +170,7 @@ } else { $('#buttons_'+this.id).css('visibility', "hidden"); } + } }; /** Function submit the form after clicking the direct edit button. **/ Index: src-setup/org/opencms/setup/CmsSetupBean.java =================================================================== RCS file: /usr/local/cvs/opencms/src-setup/org/opencms/setup/CmsSetupBean.java,v retrieving revision 1.13 diff -u -r1.13 CmsSetupBean.java --- src-setup/org/opencms/setup/CmsSetupBean.java 18 Jan 2010 10:02:59 -0000 1.13 +++ src-setup/org/opencms/setup/CmsSetupBean.java 24 Jun 2010 19:19:46 -0000 @@ -1909,6 +1909,11 @@ // initialize the database name with the app name if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(request.getContextPath())) { dbName = request.getContextPath().substring(1); + // transform Maven default finalName "${artifactId}-${version}.war" + // e.g.: "opencms-demo-7.5.2" -> "opencms_demo_7_5_2" + // reason: e.g.: MySql cannot have '-', '.' in Database-Name. + dbName = dbName.replace('-', '_'); + dbName = dbName.replace('.', '_'); } if (provider.equals(ORACLE_PROVIDER) || provider.equals(POSTGRESQL_PROVIDER) Index: modules/build.xml =================================================================== RCS file: /usr/local/cvs/opencms/modules/build.xml,v retrieving revision 1.20 diff -u -r1.20 build.xml --- modules/build.xml 8 Jun 2009 10:01:17 -0000 1.20 +++ modules/build.xml 24 Jun 2010 19:19:41 -0000 @@ -274,5 +274,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: modules/build-single.xml =================================================================== RCS file: /usr/local/cvs/opencms/modules/build-single.xml,v retrieving revision 1.37 diff -u -r1.37 build-single.xml --- modules/build-single.xml 28 Sep 2009 15:34:29 -0000 1.37 +++ modules/build-single.xml 24 Jun 2010 19:19:40 -0000 @@ -1,6 +1,6 @@ - + @@ -30,6 +30,13 @@ + + + + + + + @@ -306,14 +313,29 @@ + + + + + + + + + + + + + + + @@ -350,6 +372,15 @@ + + + + + + + + + @@ -383,6 +414,13 @@ + + + + + + + @@ -400,7 +438,7 @@ - + @@ -469,4 +507,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: src/org/opencms/workplace/explorer/CmsTree.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/workplace/explorer/CmsTree.java,v retrieving revision 1.34 diff -u -r1.34 CmsTree.java --- src/org/opencms/workplace/explorer/CmsTree.java 18 Jan 2010 10:03:13 -0000 1.34 +++ src/org/opencms/workplace/explorer/CmsTree.java 24 Jun 2010 19:19:48 -0000 @@ -122,6 +122,12 @@ /** Type name for showing the tree in a widget dialog. */ private static final String TYPE_VFSWIDGET = "vfswidget"; + /** Request parameter name for the resourcetype-ids parameter. */ + public static final String PARAM_RESOURCETYPE_IDS = "resourcetypeIds"; + + /** delimiter for ResourcetypeIds. */ + public static final String PARAM_RESOURCETYPE_IDS_DELIMITER = ","; + /** Indicates if only folders or files and folders should be included in the tree. */ private boolean m_includeFiles; @@ -146,6 +152,9 @@ /** The type of the tree (e.g. "copy", "project" etc.). */ private String m_treeType; + /** The delimited list of resource type ids. */ + private String m_resourcetypeIds; + /** * Public constructor.

* @@ -432,7 +441,11 @@ } } } - + + if (getResourcetypeIds() != null) { + resources = filterResourceTypes(resources); + } + // now output all the tree nodes Iterator i = resources.iterator(); while (i.hasNext()) { @@ -449,7 +462,7 @@ grey = true; } } - + result.append(getNode( resource.getRootPath(), resource.getName(), @@ -501,6 +514,10 @@ } } + if (getResourcetypeIds() != null) { + result.append("parent.setResourcetypeIds('").append(getResourcetypeIds()).append("');\n"); + } + result.append("}\n"); } finally { if (storedSiteRoot != null) { @@ -582,6 +599,7 @@ boolean rootloaded = Boolean.valueOf(request.getParameter(PARAM_ROOTLOADED)).booleanValue(); String resource = request.getParameter(PARAM_RESOURCE); + setResourcetypeIds(request.getParameter(PARAM_RESOURCETYPE_IDS)); setTreeType(request.getParameter(PARAM_TYPE)); String treeSite = request.getParameter(PARAM_TREESITE); if ((getTreeType() != null) && (treeSite != null)) { @@ -824,7 +842,7 @@ * @return error information output */ private String printError(Throwable t) { - + LOG.error(t.getMessage(), t); StringBuffer result = new StringBuffer(1024); result.append("/*\n"); result.append(CmsStringUtil.escapeHtml(t.getMessage())); @@ -893,4 +911,64 @@ m_treeType = type; } + + /** + * Sets the resource types to accept.

+ * + * @param resourcetypeIds the resource types to accept (delimited list) + */ + public void setResourcetypeIds(String resourcetypeIds) { + + m_resourcetypeIds = resourcetypeIds; + } + + /** + * Returns the resource types to accept.

+ * + * @return resource types to accept + */ + public String getResourcetypeIds() { + + return m_resourcetypeIds; + } + + + /** + * Filters the restricted resources types. + * @param resources All Resources + * @return filtered resources. + */ + private List filterResourceTypes(List resources) { + List result = new ArrayList(); + + for (CmsResource cmsResource : resources) { + if (getResourcetypeIdsAsList().contains(Integer.valueOf(cmsResource.getTypeId()))) { + result.add(cmsResource); + } + } + + return result; + } + + /** + * @return + */ + private List getResourcetypeIdsAsList() { + + List result = new ArrayList(); + //always show folder + result.add(Integer.valueOf(0)); + + String[] splitedIdsAsString = CmsStringUtil.splitAsArray(m_resourcetypeIds, PARAM_RESOURCETYPE_IDS_DELIMITER); + for (int i = 0; i < splitedIdsAsString.length; i++) { + String idString = splitedIdsAsString[i]; + try { + result.add(Integer.valueOf(idString.trim())); + } catch (NumberFormatException e) { + LOG.error("The resourcTypeIds '" + m_resourcetypeIds + "' contains invalid characters: " + e.getMessage()); + } + } + + return result; + } } \ No newline at end of file Index: .settings/org.eclipse.jdt.ui.prefs =================================================================== RCS file: .settings/org.eclipse.jdt.ui.prefs diff -N .settings/org.eclipse.jdt.ui.prefs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .settings/org.eclipse.jdt.ui.prefs 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,9 @@ +#Thu Jan 07 19:56:06 CET 2010 +cleanup_settings_version=2 +eclipse.preferences.version=1 +formatter_settings_version=11 +internal.default.compliance=default +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com.alkacon;de.alkacon;org.opencms;com.opencms;java;javax;org.apache;org;com; +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 Index: pom-opencms-core.xml =================================================================== RCS file: pom-opencms-core.xml diff -N pom-opencms-core.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pom-opencms-core.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,401 @@ + + 4.0.0 + org.opencms + opencms-core + jar + 7.5.2.5 + opencms-core + http://opencms.org + + + Opencms-core is the JAR-Library for OpenCms. + + OpenCms is a Content Management System that is based on Open + Source Software. Complex Intranet and Internet websites can be + quickly and cost-effectively created, maintained and managed. + + + 2008 + + + + + + + + + + + + + + + + + GNU LESSER GENERAL PUBLIC LICENSE 2.1 + http://www.gnu.org/licenses/lgpl-2.1.txt + repo + + + + + install + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + + test-jar + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + + + + + + + + + + + + + javax.servlet + jsp-api + 2.0 + provided + + + javax.servlet + servlet-api + 2.4 + provided + + + + + + + javax.activation + activation + 1.1.1 + + + com.alkacon + alkacon-diff + 0.9.2 + + + com.alkacon + alkacon-simapi + 0.9.8 + + + commons-beanutils + commons-beanutils + 1.8.0 + + + commons-codec + commons-codec + 1.3 + + + commons-collections + commons-collections + 3.2.1 + + + commons-dbcp + commons-dbcp + 1.2.2 + + + commons-digester + commons-digester + 1.8 + + + org.apache.commons + commons-email + 1.1 + + + commons-fileupload + commons-fileupload + 1.2.1 + + + commons-httpclient + commons-httpclient + 3.1 + + + commons-io + commons-io + 1.4 + + + commons-logging + commons-logging + 1.1.1 + + + + commons-pool + commons-pool + 1.5.4 + + + dom4j + dom4j + 1.6.1 + + + xml-apis + xml-apis + + + + + org.htmlparser + htmlparser + 1.6 + + + oro + oro + 2.0.8 + + + jaxen + jaxen + 1.1.1 + + + xom + xom + + + jdom + jdom + + + xml-apis + xml-apis + + + + + javax.servlet + jstl + 1.1.2 + + + + + org.hibernate + jtidy + r8-20060801 + + + org.safehaus.jug + jug + 2.0.0 + lgpl + + + log4j + log4j + 1.2.15 + + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + + + org.apache.lucene + lucene-analyzers + 2.4.1 + + + org.apache.lucene + lucene-core + 2.4.1 + + + org.apache.lucene + lucene-highlighter + 2.4.1 + + + org.apache.lucene + lucene-queries + 2.4.1 + + + org.apache.lucene + lucene-snowball + 2.4.1 + + + javax.mail + mail + 1.4.1 + + + + + pdfbox + pdfbox + 0.7.3 + + + org.fontbox + fontbox + + + org.jempbox + jempbox + + + bouncycastle + bcmail-jdk14 + + + bouncycastle + bcprov-jdk14 + + + + + poi + poi + 2.5.1-final-20040804 + + + quartz + quartz + 1.5.2 + + + taglibs + standard + 1.1.2 + + + org.textmining + tm-extractors + 0.4 + + + xml-apis + xml-apis + 1.3.04 + + + xerces + xercesImpl + 2.9.1 + + + xml-apis + xml-apis + + + + + + + + + junit + junit + 3.8.1 + test + + + + + + + + + + scp://grzmvn01.infonova.at/srv/maven/repos/content/sourceforge + + + + + infonova-opencms-repo + http://bp-cms-commons.sourceforge.net/m2repo + + + + + + + + + scp-grzmvn01-content-repository + ${distribution.htdocs}/m2repo + + + scp-grzmvn01-content-snapshot-repository + ${distribution.htdocs}/m2snapshot + + + scp-grzmvn01-content-site + ${distribution.htdocs}/m2site/opencms/${project.artifactId}/${project.version}/ + + + + Index: test/org/opencms/workplace/explorer/TestCmsTree.java =================================================================== RCS file: test/org/opencms/workplace/explorer/TestCmsTree.java diff -N test/org/opencms/workplace/explorer/TestCmsTree.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/org/opencms/workplace/explorer/TestCmsTree.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,349 @@ +/* + * File : $Source$ + * Date : $Date$ + * Version: $Revision$ + * + * This library is part of OpenCms - + * the Open Source Content Management System + * + * Copyright (C) 2002 - 2008 Alkacon Software (http://www.alkacon.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * For further information about Alkacon Software, please see the + * company website: http://www.alkacon.com + * + * For further information about OpenCms, please see the + * project website: http://www.opencms.org + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package org.opencms.workplace.explorer; + +import org.opencms.file.CmsObject; +import org.opencms.flex.CmsFlexController; +import org.opencms.flex.CmsFlexDummyLoader; +import org.opencms.flex.CmsFlexRequest; +import org.opencms.flex.CmsFlexResponse; +import org.opencms.flex.TestCmsFlexResponse.RecordingMock; +import org.opencms.flex.TestCmsFlexResponse.RequestStub; +import org.opencms.jsp.CmsJspActionElement; +import org.opencms.main.CmsException; +import org.opencms.main.CmsLog; +import org.opencms.test.OpenCmsTestCase; +import org.opencms.test.OpenCmsTestProperties; +import org.opencms.util.CmsStringUtil; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.logging.Log; + +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * UnitTest for {@link CmsTree}. + */ +public class TestCmsTree extends OpenCmsTestCase { + + /** The log object for this class. */ + private static final Log LOG = CmsLog.getLog(TestCmsTree.class); + + /** + * Default JUnit constructor.

+ * + * @param arg0 JUnit parameters + */ + public TestCmsTree(String arg0) { + + super(arg0); + } + + /** + * Test suite for this test class.

+ * + * @return the test suite + */ + public static Test suite() { + + OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH); + + TestSuite suite = new TestSuite(); + suite.setName(TestCmsTree.class.getName()); + + suite.addTest(new TestCmsTree("testGetTreeHappyPath")); + suite.addTest(new TestCmsTree("testGetTreeHappyPath2")); + suite.addTest(new TestCmsTree("testGetTreeHappyPath3")); + suite.addTest(new TestCmsTree("testGetTreeHappyPath4")); + + TestSetup wrapper = new TestSetup(suite) { + + @Override + protected void setUp() { + + setupOpenCms("simpletest", "/sites/default/"); + } + + @Override + protected void tearDown() { + + removeOpenCms(); + } + }; + + return wrapper; + } + + /** + * Test HappyPath. + * + * @throws CmsException if an error occurs + */ + public void testGetTreeHappyPath() throws CmsException { + // prepare params + Map parameter = new HashMap(); + parameter.put("resource", "/"); + // The Ids should be: jsp=4, image=3, xmlpage=6 + parameter.put("resourcetypeIds", "3,4,6"); + parameter.put("includefiles", "true"); + + // get Treelines + String[] treeLines = getTreeLines(parameter); + + // validate Result + assertEquals(14, treeLines.length); + assertTrue(treeLines[7].startsWith("parent.aC(\"index.html\"")); + assertEquals("parent.setResourcetypeIds('3,4,6');", treeLines[12]); + + } + + /** + * Test HappyPath2. getTree of subFolder. + * + * @throws CmsException if an error occurs + */ + public void testGetTreeHappyPath2() throws CmsException { + // prepare params + Map parameter = new HashMap(); + parameter.put("resource", "/folder1/"); + // The Ids should be: jsp=4, image=3, xmlpage=6 + parameter.put("resourcetypeIds", "3,4,6"); + parameter.put("includefiles", "true"); + + // get Treelines + String[] treeLines = getTreeLines(parameter); + + // validate Result + assertEquals(16, treeLines.length); + assertTrue(treeLines[4].startsWith("parent.aC(\"image2.gif\"")); + assertEquals("parent.setResourcetypeIds('3,4,6');", treeLines[14]); + + } + + /** + * Test HappyPath3. getTree of subFolder without xmlpages. + * + * @throws CmsException if an error occurs + */ + public void testGetTreeHappyPath3() throws CmsException { + // prepare params + Map parameter = new HashMap(); + parameter.put("resource", "/folder1/"); + // The Ids should be: jsp=4, image=3, xmlpage=6 + parameter.put("resourcetypeIds", "3,4"); + parameter.put("includefiles", "true"); + + // get Treelines + String[] treeLines = getTreeLines(parameter); + + // validate Result + assertEquals(11, treeLines.length); + assertTrue(treeLines[4].startsWith("parent.aC(\"image2.gif\"")); + assertEquals("parent.setResourcetypeIds('3,4');", treeLines[9]); + + } + + /** + * Test HappyPath4 getTree without resourcetypeIds. + * + * @throws CmsException if an error occurs + */ + public void testGetTreeHappyPath4() throws CmsException { + // prepare params + Map parameter = new HashMap(); + parameter.put("resource", "/"); + parameter.put("includefiles", "true"); + + // get Treelines + String[] treeLines = getTreeLines(parameter); + + // validate Result + assertEquals(13, treeLines.length); + assertTrue(treeLines[7].startsWith("parent.aC(\"index.html\"")); + } + + private String[] getTreeLines(Map parameter) throws CmsException { + + CmsJspActionElement cms = createCmsJspActionElement("index.html", parameter); + CmsTree cmsTree = new CmsTree(cms); + LOG.info("allParamsAsRequest: " + cmsTree.allParamsAsRequest()); + LOG.info("getResourcetypeIds: " + cmsTree.getResourcetypeIds()); + LOG.info("initTree: " + cmsTree.initTree()); + LOG.info("getTreeType: " + cmsTree.getTreeType()); + LOG.info("getTree: " + cmsTree.getTree()); + String[] treeLines = CmsStringUtil.splitAsArray(cmsTree.getTree(), "\n"); + return treeLines; + } + + private CmsJspActionElement createCmsJspActionElement(String xmlFilePath, Map parameter) + throws CmsException { + + HttpServletRequest request = createMockRequest(parameter); + + RecordingMock resMock = new RecordingMock(); + HttpServletResponse response = createMockResponse(resMock); + + initCmsFlexController(getCmsObject(), xmlFilePath, request, response); + + CmsJspActionElement cms = new CmsJspActionElement(null, request, response); + return cms; + } + + private void initCmsFlexController(CmsObject cms, String xmlFilePath, HttpServletRequest request, + HttpServletResponse response) throws CmsException { + CmsFlexController controller = new CmsFlexController( + cms, + cms.readFile(xmlFilePath), + CmsFlexDummyLoader.getFlexCache(), + request, + response, + false, + false); + CmsFlexRequest cmsFlexRequest = new CmsFlexRequest(request, controller); + CmsFlexResponse cmsFlexResponse = new CmsFlexResponse(response, controller, false, false); + + controller.push(cmsFlexRequest, cmsFlexResponse); + CmsFlexController.setController(request, controller); + } + + /** + * Convenience method to create a mock {@link HttpServletRequest} backed by the given invocation handler.

+ * + * @param recorder the mock recorder + * + * @return the new created request + */ + private static HttpServletRequest createMockRequest(Map parameter) { + + RecordingMock sessionMock = new RecordingMock(new RequestStub()); + final HttpSession session = (HttpSession)createProxy(HttpSession.class, sessionMock); + + RecordingMock reqMock = new RecordingMock(new RequestExtendedStub(session, parameter)); + + HttpServletRequest request = (HttpServletRequest)createProxy(HttpServletRequest.class, reqMock); + + + return request; + } + + /** + * Convenience method to create a mock {@link HttpServletResponse} backed by the given invocation handler.

+ * + * @param recorder the mock recorder + * + * @return the new created response + */ + private static HttpServletResponse createMockResponse(RecordingMock recorder) { + + return (HttpServletResponse)createProxy(HttpServletResponse.class, recorder); + } + + private static Object createProxy(Class interfaceClass, InvocationHandler handler) { + + return Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class[] {interfaceClass}, + handler); + } + + /** + * A partial implementation of {@link HttpServletRequest} which allows for the setting and getting of request attributes.

+ */ + public static class RequestExtendedStub extends RequestStub { + + private HttpSession m_session; + private Map m_parameter; + + /** + * Constructor to generate a RequestStub with Session-Stub and Parameters handling. + * + * @param session + * @param parameter + */ + public RequestExtendedStub(HttpSession session, Map parameter) { + + super(); + this.m_session = session; + this.m_parameter = parameter; + } + + public HttpSession getSession() { + return m_session; + } + + + /** + * @see javax.servlet.ServletRequest#getParameter(java.lang.String) + */ + public String getParameter(String key) { + return m_parameter.get(key); + } + + /** + * @see javax.servlet.ServletRequest#getParameterMap() + */ + public Map getParameterMap() { + return m_parameter; + } + + /** + * @see javax.servlet.ServletRequest#getParameterNames() + */ + public Enumeration getParameterNames() { + + return Collections.enumeration(m_parameter.keySet()); + } + + /** + * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String) + */ + public String[] getParameterValues(String key) { + if (getParameter(key) == null) { + return new String[0]; + } else { + return new String[]{getParameter(key)}; + } + } + } +} \ No newline at end of file Index: modules/maven-install.bat =================================================================== RCS file: modules/maven-install.bat diff -N modules/maven-install.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/maven-install.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +echo off +call set ANT_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo ANT_OPTS: %ANT_OPTS% +call ant maven-install +pause Index: maven-install-with-new-modules.bat =================================================================== RCS file: maven-install-with-new-modules.bat diff -N maven-install-with-new-modules.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ maven-install-with-new-modules.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +echo off +call set ANT_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo ANT_OPTS: %ANT_OPTS% +call set MAVEN_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo MAVEN_OPTS: %MAVEN_OPTS% +call ant maven-install-with-new-modules +pause Index: .checkstyle =================================================================== RCS file: .checkstyle diff -N .checkstyle --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .checkstyle 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ + + + + + + + Index: pom-opencms-setup.xml =================================================================== RCS file: pom-opencms-setup.xml diff -N pom-opencms-setup.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pom-opencms-setup.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,122 @@ + + 4.0.0 + org.opencms + opencms-setup + jar + 7.5.2.5 + opencms-setup + http://opencms.org + + + opencms-setup is the JAR-Library for OpenCms to make a initial setup or an update. + + OpenCms is a Content Management System that is based on Open + Source Software. Complex Intranet and Internet websites can be + quickly and cost-effectively created, maintained and managed. + + + 2008 + + + + + + + + + + + + + + + GNU LESSER GENERAL PUBLIC LICENSE 2.1 + http://www.gnu.org/licenses/lgpl-2.1.txt + repo + + + + + install + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + + + + + scp://grzmvn01.infonova.at/srv/maven/repos/content/sourceforge + + + + + infonova-opencms-repo + http://bp-cms-commons.sourceforge.net/m2repo + + + + + + + + + scp-grzmvn01-content-repository + ${distribution.htdocs}/m2repo + + + scp-grzmvn01-content-snapshot-repository + ${distribution.htdocs}/m2snapshot + + + scp-grzmvn01-content-site + ${distribution.htdocs}/m2site/opencms/${project.artifactId}/${project.version}/ + + + Index: .classpath =================================================================== RCS file: .classpath diff -N .classpath --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .classpath 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: .project =================================================================== RCS file: .project diff -N .project --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .project 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ + + + opencms-7.5.2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder + + + + + net.sf.eclipsecs.core.CheckstyleBuilder + + + + + + org.eclipse.jdt.core.javanature + com.atlassw.tools.eclipse.checkstyle.CheckstyleNature + net.sf.eclipsecs.core.CheckstyleNature + + Index: maven-install-init-all.bat =================================================================== RCS file: maven-install-init-all.bat diff -N maven-install-init-all.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ maven-install-init-all.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +echo off +call set ANT_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo ANT_OPTS: %ANT_OPTS% +call set MAVEN_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo MAVEN_OPTS: %MAVEN_OPTS% +call ant maven-install-init-all +pause Index: maven-deploy-with-new-modules.bat =================================================================== RCS file: maven-deploy-with-new-modules.bat diff -N maven-deploy-with-new-modules.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ maven-deploy-with-new-modules.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +echo off +call set ANT_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo ANT_OPTS: %ANT_OPTS% +call set MAVEN_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo MAVEN_OPTS: %MAVEN_OPTS% +call ant clean maven-deploy-with-new-modules +pause Index: pom-opencms-webapp.xml =================================================================== RCS file: pom-opencms-webapp.xml diff -N pom-opencms-webapp.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pom-opencms-webapp.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,158 @@ + + 4.0.0 + org.opencms + opencms-webapp + war + 7.5.2.5 + opencms-webapp + http://opencms.org + + + Opencms-webapp is the Skeleton WAR-File for OpenCms without Modules. + It only contains the JSPs, Configs, opencms-core and so on. + + OpenCms is a Content Management System that is based on Open + Source Software. Complex Intranet and Internet websites can be + quickly and cost-effectively created, maintained and managed. + + + 2008 + + + + + + + + + + + + + + + GNU LESSER GENERAL PUBLIC LICENSE 2.1 + http://www.gnu.org/licenses/lgpl-2.1.txt + repo + + + + + install + + + org.apache.maven.plugins + maven-war-plugin + 2.0.2 + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + + + + + + + + + + + + javax.servlet + jsp-api + 2.0 + provided + + + javax.servlet + servlet-api + 2.4 + provided + + + + + + + org.opencms + opencms-core + 7.5.2.5 + + + org.opencms + opencms-setup + 7.5.2.5 + + + + + scp://grzmvn01.infonova.at/srv/maven/repos/content/sourceforge + + + + + infonova-opencms-repo + http://bp-cms-commons.sourceforge.net/m2repo + + + + + + + + + scp-grzmvn01-content-repository + ${distribution.htdocs}/m2repo + + + scp-grzmvn01-content-snapshot-repository + ${distribution.htdocs}/m2snapshot + + + scp-grzmvn01-content-site + ${distribution.htdocs}/m2site/opencms/${project.artifactId}/${project.version}/ + + + Index: .settings/org.eclipse.jdt.core.prefs =================================================================== RCS file: .settings/org.eclipse.jdt.core.prefs diff -N .settings/org.eclipse.jdt.core.prefs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .settings/org.eclipse.jdt.core.prefs 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,70 @@ +#Thu Jan 07 19:55:34 CET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.5 Index: maven-deploy-init-all.bat =================================================================== RCS file: maven-deploy-init-all.bat diff -N maven-deploy-init-all.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ maven-deploy-init-all.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +echo off +call set ANT_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo ANT_OPTS: %ANT_OPTS% +call set MAVEN_OPTS=-Xms128m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=256m +call echo MAVEN_OPTS: %MAVEN_OPTS% +call ant maven-deploy-init-all +pause Index: test/org/opencms/widgets/TestVfsFileWidgetConfiguration.java =================================================================== RCS file: test/org/opencms/widgets/TestVfsFileWidgetConfiguration.java diff -N test/org/opencms/widgets/TestVfsFileWidgetConfiguration.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/org/opencms/widgets/TestVfsFileWidgetConfiguration.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,134 @@ +/* + * File : $Source$ + * Date : $Date$ + * Version: $Revision$ + * + * This library is part of OpenCms - + * the Open Source Content Management System + * + * Copyright (C) 2002 - 2008 Alkacon Software (http://www.alkacon.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * For further information about Alkacon Software, please see the + * company website: http://www.alkacon.com + * + * For further information about OpenCms, please see the + * project website: http://www.opencms.org + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +package org.opencms.widgets; + +import org.opencms.test.OpenCmsTestCase; +import org.opencms.test.OpenCmsTestProperties; + +import junit.extensions.TestSetup; +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * TestCase for {@link CmsVfsFileWidget}. + */ +public class TestVfsFileWidgetConfiguration extends OpenCmsTestCase { + + /** + * Default JUnit constructor.

+ * + * @param arg0 JUnit parameters + */ + public TestVfsFileWidgetConfiguration(String arg0) { + + super(arg0); + } + + /** + * Test suite for this test class.

+ * + * @return the test suite + */ + public static Test suite() { + + OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH); + + TestSuite suite = new TestSuite(); + suite.setName(TestVfsFileWidgetConfiguration.class.getName()); + + suite.addTest(new TestVfsFileWidgetConfiguration("testConfigurationHappyPath")); + suite.addTest(new TestVfsFileWidgetConfiguration("testConfigurationWrongResourceTypeName")); + suite.addTest(new TestVfsFileWidgetConfiguration("testConfigurationWrongParameter")); + suite.addTest(new TestVfsFileWidgetConfiguration("testConfigurationNull")); + + TestSetup wrapper = new TestSetup(suite) { + + @Override + protected void setUp() { + + setupOpenCms("simpletest", "/sites/default/"); + } + + @Override + protected void tearDown() { + + removeOpenCms(); + } + }; + + return wrapper; + } + + /** + * Test HappyPath. + */ + public void testConfigurationHappyPath() { + CmsVfsFileWidget cmsVfsFileWidget = new CmsVfsFileWidget("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp,image,xmlpage"); + + assertEquals("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp,image,xmlpage", cmsVfsFileWidget.getConfiguration()); + // The Ids should be: jsp=4, image=3, xmlpage=6 + assertEquals("4,3,6", cmsVfsFileWidget.getRestrictResTypeIdsAsString(",")); + } + + /** + * Test wrong ResourceTypeName. + */ + public void testConfigurationWrongResourceTypeName() { + CmsVfsFileWidget cmsVfsFileWidget = new CmsVfsFileWidget("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp,image,unbekannt"); + + assertEquals("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp,image,unbekannt", cmsVfsFileWidget.getConfiguration()); + // The Ids should be: jsp=4, image=3 ("unbekannt" is not found and not listed.) + assertEquals("4,3", cmsVfsFileWidget.getRestrictResTypeIdsAsString(",")); + } + + /** + * Test wrong ResourceTypeName. + */ + public void testConfigurationWrongParameter() { + CmsVfsFileWidget cmsVfsFileWidget = new CmsVfsFileWidget("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp|unbekannt"); + + assertEquals("hidesiteselector|excludefiles|notprojectaware|resourcetypeNames=jsp", cmsVfsFileWidget.getConfiguration()); + // The Id should be: jsp=4 + assertEquals("4", cmsVfsFileWidget.getRestrictResTypeIdsAsString(",")); + } + + /** + * Test null configuration. + */ + public void testConfigurationNull() { + CmsVfsFileWidget cmsVfsFileWidget = new CmsVfsFileWidget(null); + + assertEquals("showsiteselector|includefiles|projectaware", cmsVfsFileWidget.getConfiguration()); + // The Ids should be: jsp=4, image=3 ("unbekannt" is not found and not listed.) + assertEquals("", cmsVfsFileWidget.getRestrictResTypeIdsAsString(",")); + } +} Index: modules/pom-template.xml =================================================================== RCS file: modules/pom-template.xml diff -N modules/pom-template.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/pom-template.xml 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,142 @@ + + 4.0.0 + org.opencms.modules + @OPENCMS_MODULE_NAME@ + jar + @OPENCMS_MODULE_VERSION@ + @OPENCMS_MODULE_NAME@ + http://opencms.org + + + + 2008 + + + + + + + + + + + + + + + GNU LESSER GENERAL PUBLIC LICENSE 2.1 + http://www.gnu.org/licenses/lgpl-2.1.txt + repo + + + + + install + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + + + + + + + + + + + + + + org.opencms + opencms-core + 7.5.2 + provided + + + + + @OPENCMS_MODULE_DEPENDENCIES@ + + + + + scp://grzmvn01.infonova.at/srv/maven/repos/content/sourceforge + + + + + infonova-opencms-repo + http://bp-cms-commons.sourceforge.net/m2repo + + + + + + + + + scp-grzmvn01-content-repository + ${distribution.htdocs}/m2repo + + + scp-grzmvn01-content-snapshot-repository + ${distribution.htdocs}/m2snapshot + + + scp-grzmvn01-content-site + ${distribution.htdocs}/m2site/opencms/${project.artifactId}/${project.version}/ + + + Index: install-nonpublic-libs.bat =================================================================== RCS file: install-nonpublic-libs.bat diff -N install-nonpublic-libs.bat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ install-nonpublic-libs.bat 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +echo off +echo Installing Non-Puplic Libraries to the local Maven-Repository.... +call mvn install:install-file -DgroupId=com.alkacon -DartifactId=alkacon-diff -Dversion=0.9.2 -Dpackaging=jar -Dfile=lib/runtime/alkacon-diff-0.9.2.jar +call mvn install:install-file -DgroupId=com.alkacon -DartifactId=alkacon-simapi -Dversion=0.9.8 -Dpackaging=jar -Dfile=lib/runtime/alkacon-simapi-0.9.8.jar + + +echo Installing ibm.as400-Driver to the local Maven-Repository.... +call mvn install:install-file -DgroupId=com.ibm.as400 -DartifactId=jt400 -Dversion=6.0 -Dpackaging=jar -Dfile=webapp/setup/database/as400/jt400.jar + +echo Installing ibm.db2-Driver to the local Maven-Repository.... +call mvn install:install-file -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc -Dversion=V9 -Dpackaging=jar -Dfile=webapp/setup/database/db2/db2jcc_v9.jar +call mvn install:install-file -DgroupId=com.ibm.db2.jcc -DartifactId=db2jcc_license_cu -Dversion=V9 -Dpackaging=jar -Dfile=webapp/setup/database/db2/db2jcc_license_cu.jar + +echo Installing oracle-Driver to the local Maven-Repository.... +call mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.3 -Dpackaging=jar -Dfile=webapp/setup/database/oracle/ojdbc14-10.2.0.3.jar + +pause

"); Index: src/org/opencms/workplace/CmsWidgetDialog.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/workplace/CmsWidgetDialog.java,v retrieving revision 1.73 diff -u -r1.73 CmsWidgetDialog.java --- src/org/opencms/workplace/CmsWidgetDialog.java 18 Jan 2010 10:03:37 -0000 1.73 +++ src/org/opencms/workplace/CmsWidgetDialog.java 24 Jun 2010 19:19:46 -0000 @@ -238,7 +238,7 @@ href.append(elementName); href.append("', "); href.append(insertAfter); - href.append(");"); + href.append(",[]);"); return button(href.toString(), null, "new.png", Messages.GUI_DIALOG_BUTTON_ADDNEW_0, 0); } else { return ""; Index: modules/org.opencms.workplace.explorer/resources/manifest.xml =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace.explorer/resources/manifest.xml,v retrieving revision 1.56 diff -u -r1.56 manifest.xml --- modules/org.opencms.workplace.explorer/resources/manifest.xml 20 Jan 2010 10:37:22 -0000 1.56 +++ modules/org.opencms.workplace.explorer/resources/manifest.xml 24 Jun 2010 19:19:43 -0000 @@ -16,7 +16,7 @@ This module contains the OpenCms Workplace Explorer.

Install this module if you want a GUI to work on the OpenCms VFS.

(c) 2008 by Alkacon Software GmbH (http://www.alkacon.com).

]]>
- 7.5.2 + 7.5.2.4 Mon, 27 Jun 2005 08:00:00 GMT Index: modules/org.opencms.workplace/resources/system/workplace/resources/components/widgets/fileselector.js =================================================================== RCS file: /usr/local/cvs/opencms/modules/org.opencms.workplace/resources/system/workplace/resources/components/widgets/fileselector.js,v retrieving revision 1.12 diff -u -r1.12 fileselector.js --- modules/org.opencms.workplace/resources/system/workplace/resources/components/widgets/fileselector.js 5 Jun 2009 13:31:35 -0000 1.12 +++ modules/org.opencms.workplace/resources/system/workplace/resources/components/widgets/fileselector.js 24 Jun 2010 19:19:45 -0000 @@ -43,7 +43,7 @@ var treeField = null; var treeDoc = null; -function openTreeWin(formName, fieldName, curDoc, showSiteSelector, startSite, includeFiles, projectAware) { +function openTreeWin(formName, fieldName, curDoc, showSiteSelector, startSite, includeFiles, projectAware, resourcetypeIds) { if (includeFiles == null) { includeFiles = true; @@ -65,6 +65,10 @@ paramString += "&treesite="; paramString += startSite; } + + if (resourcetypeIds != null) { + paramString += "&resourcetypeIds="+ resourcetypeIds; + } treewin = openWin(vr.contextPath + vr.workplacePath + "views/explorer/tree_fs.jsp" + paramString, "opencms", 300, 450); treeForm = formName; Index: src/org/opencms/workplace/editors/CmsXmlContentEditor.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/workplace/editors/CmsXmlContentEditor.java,v retrieving revision 1.89 diff -u -r1.89 CmsXmlContentEditor.java --- src/org/opencms/workplace/editors/CmsXmlContentEditor.java 18 Jan 2010 10:02:35 -0000 1.89 +++ src/org/opencms/workplace/editors/CmsXmlContentEditor.java 24 Jun 2010 19:19:48 -0000 @@ -39,6 +39,9 @@ import org.opencms.file.collectors.I_CmsResourceCollector; import org.opencms.i18n.CmsEncoder; import org.opencms.i18n.CmsLocaleManager; +import org.opencms.json.JSONArray; +import org.opencms.json.JSONException; +import org.opencms.json.JSONObject; import org.opencms.jsp.CmsJspActionElement; import org.opencms.lock.CmsLockType; import org.opencms.main.CmsException; @@ -75,6 +78,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.StringTokenizer; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -154,6 +158,9 @@ /** Parameter name for the request parameter "elementname". */ public static final String PARAM_ELEMENTNAME = "elementname"; + /** Parameter name for the request parameter "elementname". */ + public static final String PARAM_CHOICEELEMENTNAME = "choiceelementname"; + /** Parameter name for the request parameter "newlink". */ public static final String PARAM_NEWLINK = "newlink"; @@ -184,6 +191,9 @@ /** Parameter stores the name of the element to add or remove. */ private String m_paramElementName; + /** Parameter stores the name of the Choice-element to add. */ + private String m_paramChoiceElementName; + /** The selected model file for the new resource. */ private String m_paramModelFile; @@ -641,7 +651,20 @@ // when other values are present, increase index to use right position index += 1; } - m_content.addValue(getCms(), getParamElementName(), getElementLocale(), index); + + if (CmsStringUtil.isEmpty(getParamChoiceElementName())) { + m_content.addValue(getCms(), getParamElementName(), getElementLocale(), index); + } else { + I_CmsXmlContentValue value = m_content.addValue(getCms(), getParamElementName(), getElementLocale(), index); + + //The tokenizer is necessary if a ChoiceContentDefinition contents Elements who are also a ChoiceContentDefinition + StringTokenizer tok = new StringTokenizer(getParamChoiceElementName(), "/"); + while (tok.hasMoreElements()) { + String choiceElement = tok.nextToken(); + LOG.info("choiceElement: " + choiceElement); + value = m_content.addValue(getCms(), value.getPath() + "/" + choiceElement, getElementLocale(), 0); + } + } } if (getValidationHandler().hasWarnings(getElementLocale())) { @@ -740,6 +763,17 @@ } /** + * Returns the name of the Choice element to add.

+ * This Parameter can also be seperated by "/" if a ChoiceContentDefinition has Elements who are also ChoiceContentDefinitions. + * + * @return the name of the Choice element to add + */ + public String getParamChoiceElementName() { + + return m_paramChoiceElementName; + } + + /** * Returns the parameter that specifies the model file name.

* * @return the parameter that specifies the model file name @@ -1024,6 +1058,17 @@ } /** + * Sets the name of the Choice-Element to add.

+ * This Parameter can also be seperated by "/" if a ChoiceContentDefinition has Elements who are also ChoiceContentDefinitions. + * + * @param elementName the name of the Choice-Element to add + */ + public void setParamChoiceElementName(String elementName) { + + m_paramChoiceElementName = elementName; + } + + /** * Sets the parameter that specifies the model file name.

* * @param paramMasterFile the parameter that specifies the model file name @@ -1321,9 +1366,12 @@ * @param index the index of the element * @param addElement if true, the button to add an element is shown * @param removeElement if true, the button to remove an element is shown + * @param choiceListJson List of Choices if a ChoiceContentDefinition should be added.
+ * This must be a valid Javascript-JSON-String
+ * Example value for choiceListJson: [{Label:"first test", Name:"test1", Help:"The ElementType can be a Simple or Complex Type"},{Label:"second test", Name:"test2"}] * @return the html for the element operation buttons */ - private String buildElementButtons(String elementName, int index, boolean addElement, boolean removeElement) { + private String buildElementButtons(String elementName, int index, boolean addElement, boolean removeElement, String choiceListJson) { StringBuffer jsCall = new StringBuffer(512); @@ -1369,9 +1417,13 @@ // build the add element button if required if (addElement) { jsCall.append(Boolean.TRUE); + // This param must be Javascript & HTML escaped. + // It is the Parameter of the showElementButtons()-function who create a HTML-link with href="javascript:addElement(... choiceListJson ...)" + jsCall.append(", \"" + CmsStringUtil.escapeJavaScript(CmsStringUtil.escapeHtml(choiceListJson)) + "\""); buttonPresent = true; } else { jsCall.append(Boolean.FALSE); + jsCall.append(", \"[]\""); } jsCall.append(");"); @@ -1391,6 +1443,7 @@ action.append(elementName); action.append("', "); action.append(index); + action.append(", " + choiceListJson + ""); action.append(");"); btAction = action.toString(); } else if (removeElement) { @@ -1406,9 +1459,9 @@ } StringBuffer href = new StringBuffer(512); href.append("javascript:"); - href.append(btAction); + href.append(CmsStringUtil.escapeHtml(btAction)); //escape quotes in HTML-Attribute href.append("\" onmouseover=\""); - href.append(jsCall); + href.append(CmsStringUtil.escapeHtml(jsCall.toString())); //escape quotes in HTML-Attribute href.append("checkElementButtons(true);\" onmouseout=\"checkElementButtons(false);\" id=\"btimg."); href.append(elementName).append(".").append(index); result = button(href.toString(), null, btIcon, Messages.GUI_EDITOR_XMLCONTENT_ELEMENT_BUTTONS_0, 0); @@ -1635,7 +1688,7 @@ for (Iterator i = contentDefinition.getTypeSequence().iterator(); i.hasNext();) { // get the type I_CmsXmlSchemaType type = (I_CmsXmlSchemaType)i.next(); - + boolean tabCurrentlyOpened = false; if (useTabs) { @@ -1686,11 +1739,28 @@ firstElement = false; } + + // get nestedContent Infos (also Choice-Content) CmsXmlContentDefinition nestedContentDefinition = contentDefinition; + List choiceList = new ArrayList(); //needed for Javascript-ADD-Button + if (!type.isSimpleType()) { // get nested content definition for nested types CmsXmlNestedContentDefinition nestedSchema = (CmsXmlNestedContentDefinition)type; - nestedContentDefinition = nestedSchema.getNestedContentDefinition(); + nestedContentDefinition = getNestedContentDefinition(nestedSchema); + + // get Choice-Elements to Choice-List (needed for Javascript-ADD-Button) + if (nestedContentDefinition.isChoiceType()) { + + Iterator choiceSubElementTypeIterator = nestedContentDefinition.getTypeSequence().iterator(); + while (choiceSubElementTypeIterator.hasNext()) { + // get the type of possible SubElements + I_CmsXmlSchemaType choiceSubElementType = (I_CmsXmlSchemaType)choiceSubElementTypeIterator.next(); + + // add Choice-Element to Choice-List recursively + addChoiceElementToChoiceList(choiceList, nestedContentDefinition, choiceSubElementType); + } + } } // create xpath to the current element String name = pathPrefix + type.getName(); @@ -1724,10 +1794,49 @@ // get value and corresponding widget I_CmsXmlContentValue value = elementSequence.getValue(j); I_CmsWidget widget = null; - if (type.isSimpleType()) { - widget = contentDefinition.getContentHandler().getWidget(value); + + // the value will be replaced by the SubElement if it is a ChoiceElement. + // so get the Index now bevor it is to late. + int valueIndex = value.getIndex(); + + // Get ChoiceSubElementsVariables + String choiceSubElementPathPrefix = null; // only necessary if the Choice-SubElement is a NestedContent (recursive-Call of this function) + CmsXmlContentDefinition choiceSubElementNestedContentDefinition = null; //only used if widget==null + + String label; + + // if this elments has a Value and it is a Choice-Element, than get the chosen ChoiceSubElement + if (!disabledElement && !type.isSimpleType() && nestedContentDefinition.isChoiceType()) { + ChoiceSubElementValueHolder valueHolder = new ChoiceSubElementValueHolder(nestedContentDefinition, pathPrefix, value, widget); + + // get Lable + label = keyDefault(A_CmsWidget.getLabelKey((I_CmsWidgetParameter)value), value.getName()); + valueHolder.setLabel(label); + + valueHolder = getChoiceSubElement(valueHolder); + + // The new ChoiceSubElementPathPrefix + choiceSubElementPathPrefix = valueHolder.getPathPrefix(); + // The new ChoiceSubElement Value + value = valueHolder.getValue(); + // The Label for this ChoiceSubElement Value (Wihtout Counter. Maybe separate by "/" if it is a recusrsive Choice SubSubElement ) + label = valueHolder.getLabel(); + // The new ChoiceSubElement Widget Or NestedContentDefinition (who is certainly no choice nestedContentDefinition.) + widget = valueHolder.getWidget(); + choiceSubElementNestedContentDefinition = valueHolder.getNestedContentDefinition(); + + } else { + label = keyDefault(A_CmsWidget.getLabelKey((I_CmsWidgetParameter)value), value.getName()); + if (type.isSimpleType()) { + widget = contentDefinition.getContentHandler().getWidget(value); + } } + // Befor an empty Lable exists show the element-Name + if (CmsStringUtil.isEmpty(label)) { + label = value.getName(); + } + // show errors and/or warnings String key = value.getPath(); if (showErrors @@ -1786,6 +1895,7 @@ m_warningTabs.add(m_currentTab); } } + // create label and help bubble cells result.append("

"); - boolean showHelp = (j == 0); superTabOpened = !nested && tabOpened && collapseLabel; - result.append(getXmlEditorForm( - nestedContentDefinition, - pathPrefix + newPath + "/", - showHelp, - superTabOpened)); - result.append(""); + boolean showHelp = true; + result.append(getXmlEditorForm( + choiceSubElementNestedContentDefinition, + choiceSubElementPathPrefix + newPath + "/", + showHelp, + superTabOpened)); + result.append(""); + boolean showHelp = (j == 0); + result.append(getXmlEditorForm( + nestedContentDefinition, + pathPrefix + newPath + "/", + showHelp, + superTabOpened)); + result.append("