r3374 - in trunk: pollen-persistence/src/main/java/org/chorem/pollen/entities/migration pollen-ui-struts2/src/main/java/org/chorem/pollen/ui pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll pollen-ui-struts2/src/main/resources/i18n pollen-ui-struts2/src/main/webapp/WEB-INF/decorators pollen-ui-struts2/src/main/webapp/css pollen-ui-struts2/src/main/webapp/img
Author: tchemit Date: 2012-05-18 14:48:26 +0200 (Fri, 18 May 2012) New Revision: 3374 Url: http://chorem.org/repositories/revision/pollen/3374 Log: fixes #517: Add a WARNING message level Added: trunk/pollen-ui-struts2/src/main/webapp/img/warning.png Removed: trunk/pollen-ui-struts2/src/main/webapp/css/screen.css Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp trunk/pollen-ui-struts2/src/main/webapp/css/common.css Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -1,3 +1,26 @@ +/* + * #%L + * Pollen :: Persistence + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2009 - 2012 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ package org.chorem.pollen.entities.migration; import org.nuiton.topia.TopiaException; Property changes on: trunk/pollen-persistence/src/main/java/org/chorem/pollen/entities/migration/PollenMigrationCallbackV1_4.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/PollenSession.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -23,6 +23,7 @@ */ package org.chorem.pollen.ui; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.opensymphony.xwork2.ActionContext; import org.apache.commons.logging.Log; @@ -32,6 +33,7 @@ import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import java.util.List; import java.util.Map; /** @@ -52,6 +54,8 @@ public static final String SESSION_TOKEN_ERRORS = "errors"; + public static final String SESSION_TOKEN_WARNINGS = "warnings"; + public static PollenSession get(ServletRequest servletRequest) { HttpSession httpSession = ((HttpServletRequest) servletRequest).getSession(true); PollenSession pollenSession = (PollenSession) httpSession.getAttribute(SESSION_PARAMETER); @@ -101,6 +105,14 @@ return (T) result; } + public <T> T consumeDynamicData(String token) { + Object result = getDynamicData().get(token); + if (result != null) { + removeDynamicData(token); + } + return (T) result; + } + public void putDynamicData(String token, Object data) { getDynamicData().put(token, data); if (log.isDebugEnabled()) { @@ -130,4 +142,14 @@ } return dynamicData; } + + public void addMessage(String messageScope, String message) { + List<String> messages = getDynamicData(messageScope); + if (messages == null) { + messages = Lists.newArrayList(message); + putDynamicData(messageScope, messages); + } else { + messages.add(message); + } + } } Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/PollenActionSupport.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -202,29 +202,29 @@ return new Date(); } - public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) { - String result; - switch (voteCountingType) { - - default: - case NORMAL: - result = - _("pollen.common.voteCountingTypeHelp.normal"); - break; - case PERCENTAGE: - result = - _("pollen.common.voteCountingTypeHelp.percentage"); - break; - case CONDORCET: - result = - _("pollen.common.voteCountingTypeHelp.condorcet"); - break; - case NUMBER: - result = - _("pollen.common.voteCountingTypeHelp.number"); - } - return result; - } +// public String getVoteCountingTypeHelp(VoteCountingType voteCountingType) { +// String result; +// switch (voteCountingType) { +// +// default: +// case NORMAL: +// result = +// _("pollen.common.voteCountingTypeHelp.normal"); +// break; +// case PERCENTAGE: +// result = +// _("pollen.common.voteCountingTypeHelp.percentage"); +// break; +// case CONDORCET: +// result = +// _("pollen.common.voteCountingTypeHelp.condorcet"); +// break; +// case NUMBER: +// result = +// _("pollen.common.voteCountingTypeHelp.number"); +// } +// return result; +// } public String getCurrentUrl() { HttpServletRequest request = ServletActionContext.getRequest(); @@ -233,45 +233,47 @@ } public void addFlashMessage(String message) { - List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); - if (messages == null) { - messages = Lists.newArrayList(message); - getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_MESSAGES, messages); - } else { - messages.add(message); - } + getPollenSession().addMessage(PollenSession.SESSION_TOKEN_MESSAGES, message); } public void addFlashError(String message) { - List<String> messages = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS); - if (messages == null) { - messages = Lists.newArrayList(message); - getPollenSession().putDynamicData(PollenSession.SESSION_TOKEN_ERRORS, messages); - } else { - messages.add(message); - } + getPollenSession().addMessage(PollenSession.SESSION_TOKEN_ERRORS, message); } + public void addFlashWarning(String message) { + getPollenSession().addMessage(PollenSession.SESSION_TOKEN_WARNINGS, message); + } + public Collection<String> getFlashMessages() { - List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); - if (result == null) { - result = Collections.emptyList(); - } else { - getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); - } + + List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); +// if (result == null) { +// result = Collections.emptyList(); +// } else { +// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); +// } return result; } public Collection<String> getFlashErrors() { - List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_ERRORS); - if (result == null) { - result = Collections.emptyList(); - } else { - getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS); - } + List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_ERRORS); +// if (result == null) { +// result = Collections.emptyList(); +// } else { +// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS); +// } return result; } + public Collection<String> getFlashWarnings() { + List<String> result = getPollenSession().consumeDynamicData(PollenSession.SESSION_TOKEN_WARNINGS); +// if (result == null) { +// result = Collections.emptyList(); +// } else { +// getPollenSession().removeDynamicData(PollenSession.SESSION_TOKEN_ERRORS); +// } + return result; + } public boolean hasFlashMessages() { List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); return CollectionUtils.isNotEmpty(result); @@ -282,6 +284,11 @@ return CollectionUtils.isNotEmpty(result); } + public boolean hasFlashWarnings() { + List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_WARNINGS); + return CollectionUtils.isNotEmpty(result); + } + public void clearFlashMessages() { List<String> result = getPollenSession().getDynamicData(PollenSession.SESSION_TOKEN_MESSAGES); if (result != null) { Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -321,7 +321,7 @@ } else if (isPollFinished()) { addFlashMessage(_("pollen.information.pollFinished")); } else if (pollCreator.equals(pollAccount)) { - addFlashMessage(_("pollen.information.vote.creatorUser")); + addFlashWarning(_("pollen.information.vote.creatorUser")); } if (isPollChoiceRunning()) { addFlashMessage(_("pollen.information.pollChoiceRunning")); Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -185,7 +185,7 @@ addFlashError(_("pollen.error.userNotAllowed")); } else if (poll.isRunning(serviceContext.getCurrentTime())) { - addFlashMessage(_("pollen.information.pollRunning")); + addFlashWarning(_("pollen.information.pollRunning")); loadResults(); } else { Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/VoteForPoll.java 2012-05-18 12:48:26 UTC (rev 3374) @@ -118,6 +118,7 @@ getPollService().addVoteToPoll(getPoll(), voteCreated); } + //TODO tchemit-2012-05-18 Why clean messages and just messages here ? clearFlashMessages(); // For free Poll, display the update Url (useless if user is logged) Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_en_GB.properties 2012-05-18 12:48:26 UTC (rev 3374) @@ -208,6 +208,7 @@ pollen.fieldset.userInformation.toCreate=User informations to create pollen.fieldset.userInformation.toDelete=User informations to delete pollen.fieldset.userInformation.toUpdate=User informations to update +pollen.image.not.loaded=Image not loaded pollen.information.confirmClonePoll=Confirm clone of poll\: pollen.information.confirmClosePoll=Confirm close of poll\: pollen.information.confirmDeleteChoice=Confirm delete of choice %s @@ -292,4 +293,3 @@ pollen.title.usersList=Users administration title=Create a poll vote.anonymous=Anonymous vote -pollen.image.not.loaded=Image not loaded Modified: trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties =================================================================== --- trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/resources/i18n/pollen-ui-struts2_fr_FR.properties 2012-05-18 12:48:26 UTC (rev 3374) @@ -206,6 +206,7 @@ pollen.fieldset.userInformation.toCreate=Informations de l'utilisateur à créer pollen.fieldset.userInformation.toDelete=Informations de l'utilisateur à supprimer pollen.fieldset.userInformation.toUpdate=Informations de l'utilisateur à mettre à jour +pollen.image.not.loaded=Image non chargée pollen.information.confirmClonePoll=Confirmer le clonage du sondage \: pollen.information.confirmClosePoll=Confirmer la fermeture du sondage \: pollen.information.confirmDeleteFavoriteList=Confirmer la suppression de la liste de votants \: @@ -288,4 +289,3 @@ pollen.title.usersList=Gestion des utilisateurs title=Création d'un sondage vote.anonymous=Vote anonyme -pollen.image.not.loaded=Image non chargée Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-05-18 12:48:26 UTC (rev 3374) @@ -33,8 +33,6 @@ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Pollen - <d:title default="Pollen"/></title> <d:head/> - <%--<link rel="stylesheet" type="text/css" href="<s:url value='/css/pollen.css' />"/>--%> - <%--<link rel="stylesheet" type="text/css" href="<s:url value='/css/screen.css' />"/>--%> <link rel="stylesheet" type="text/css" href="<s:url value='/css/main.css' />"/> <link rel="stylesheet" type="text/css" href="<s:url value='/css/common.css' />"/> <link rel="icon" type="image/png" href="<s:url value='/favicon.png' />"/> @@ -280,6 +278,15 @@ </div> </s:if> + <s:if test="hasFlashWarnings()"> + <div class="info_warning clearfix"> + <ul class="actionWarnings fleft"> + <s:iterator value="flashWarnings" var="message"> + <li><span><s:property value="#message" escapeHtml="false"/></span></li> + </s:iterator> + </ul> + </div> + </s:if> <s:if test="hasFlashErrors()"> <div class="info_error clearfix"> <ul class="actionErrors fleft"> Modified: trunk/pollen-ui-struts2/src/main/webapp/css/common.css =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/css/common.css 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/webapp/css/common.css 2012-05-18 12:48:26 UTC (rev 3374) @@ -149,6 +149,28 @@ color: #880000; margin-left:0px; } + +.info_warning { + background: no-repeat scroll 8px 5px #fff71f; + border: 2px solid #FFCC00; + width: 970px; + margin-bottom: 5px; + margin-top: 10px; +} +.info_warning ul{ + margin: 5px; + padding-left: 5px; + width: 950px; +} +.info_warning li{ + background: url("../img/warning.png") no-repeat ; + list-style: none; + font-style: italic; + padding-left: 25px; + color: #e09210; + margin-left:0px; +} + #tooltip { position:absolute; z-index:9999; Deleted: trunk/pollen-ui-struts2/src/main/webapp/css/screen.css =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/css/screen.css 2012-05-18 07:40:41 UTC (rev 3373) +++ trunk/pollen-ui-struts2/src/main/webapp/css/screen.css 2012-05-18 12:48:26 UTC (rev 3374) @@ -1,162 +0,0 @@ -/* - * #%L - * Pollen :: UI (strust2) - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ -/** {*/ - /*font-family: sans-serif;*/ -/*}*/ - -.inline { - display:inline; -} - -.fontsize11 { - font-size: 11px; -} - -.ui-tabs-panel { - font-family: monospace; - font-size: 9pt; -} - -.ui-tabs .ui-tabs-nav li a { - float: left; - padding: .5em .1em; - text-decoration: none; - font-size: 11px; -} - -.clearBoth { - clear: both; -} - -.hidden { - display:none; -} - -.displayBlock { - display:block; -} - -.floatLeft { - float:left; -} - -.floatRight { - float:right; -} - -.info_success { - background: no-repeat scroll 8px 5px #DFFFDF; - border: 2px solid #9FCF9F; - width: 800px; - margin-bottom: 5px; -} -.info_success ul{ - margin: 5px; - padding-left: 5px; -} -.info_success li{ - background: url("../img/true.png") no-repeat ; - list-style: none; - font-style: italic; - padding-left: 25px; - color: #005F00; - margin-left:0px; -} - -.info_error { - background: no-repeat scroll 8px 5px #FFE3E3; - border: 2px solid #DD0000; - width: 800px; - margin-bottom: 5px; -} -.info_error ul{ - margin: 5px; - padding-left: 5px; -} -.info_error li{ - background: url("../img/exclamation.png") no-repeat ; - list-style: none; - font-style: italic; - padding-left: 25px; - color: #880000; - margin-left:0px; -} - -.errorMessage li{ - background: url("../img/exclamation.png") no-repeat ; - list-style: none; - font-style: italic; - padding-left: 25px; - color: #880000; - margin-left:0px; -} - -.verticalAlignTop { - vertical-align: top; -} - -fieldset, hr , .cleanBoth{ - clear: both -} -.wwlbl { - float: left; - clear: both; - width: 300px; -/*# text-align: right;*/ -} -.wwctrl { - float: left; -} - -.wwerr { - clear: both; - float: left; -} - -div.errorMessage{ - clear: both; - float: left; -} -.errorMessage { - background: url("../img/exclamation.png") no-repeat ; - list-style: none; - font-style: italic; - padding-left: 25px; - color: #880000; - margin-left:0px; -} - -.required { - color: #880000; - font-style: italic; -} - -.clearfix { - display: inline-block; -} - -/* Hide from IE Mac \*/ -.clearfix { - display: block; -} Added: trunk/pollen-ui-struts2/src/main/webapp/img/warning.png =================================================================== (Binary files differ) Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/warning.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
tchemit@users.chorem.org