Changeset 5423
- Timestamp:
- Sep 23, 2010, 11:09:55 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterFactory.java
r5136 r5423 262 262 return getDateFormatter(sc); 263 263 } 264 else if (type == Type.TIMESTAMP) 265 { 266 return getDateTimeFormatter(sc); 267 } 264 268 else if (type == Type.BOOLEAN) 265 269 { -
trunk/www/admin/annotationtypes/edit_annotationtype.jsp
r5156 r5423 2 2 ------------------------------------------------------------------ 3 3 Copyright (C) 2005 Nicklas Nordborg 4 Copyright (C) 2006 Jari H äkkinen, Nicklas Nordborg4 Copyright (C) 2006 Jari H�kkinen, Nicklas Nordborg 5 5 6 6 This file is part of BASE - BioArray Software Environment. … … 132 132 String jsDateFormat = HTML.javaScriptEncode(dateFormat); 133 133 String htmlDateFormat = HTML.encodeTags(dateFormat); 134 135 Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); 136 String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc); 137 String jsDateTimeFormat = HTML.javaScriptEncode(dateTimeFormat); 138 String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat); 134 139 %> 135 140 <base:page type="popup" title="<%=title%>"> … … 483 488 <% 484 489 } 490 else if (valueType == Type.TIMESTAMP) 491 { 492 %> 493 <table border="0" cellspacing="0" cellpadding="0"> 494 <tr> 495 <td> 496 <input <%=clazz%> type="text" name="defaultValue" 497 value="<%=HTML.encodeTags(defaultValue)%>" 498 size="30" maxlength="30 "title="Enter date in format: <%=htmlDateTimeFormat%>"> 499 </td> 500 <td> 501 <base:button 502 onclick="<%="Dates.selectDateTime('Default value', 'annotationType', 'defaultValue', null, '"+jsDateTimeFormat+"')"%>" 503 image="calendar.png" 504 title="Calendar…" 505 tooltip="Select a date and time from a calendar" 506 /> 507 </td> 508 </tr> 509 </table> 510 <% 511 } 485 512 else if (valueType == Type.STRING) 486 513 { … … 711 738 <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> 712 739 One date value (<%=htmlDateFormat%>) per line 740 </td> 741 </tr> 742 <% 743 } 744 else if (valueType == Type.TIMESTAMP) 745 { 746 %> 747 <tr> 748 <td class="prompt">Input box width</td> 749 <td> 750 <input <%=clazz%> type="text" name="width" 751 value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 752 size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> 713 753 </td> 714 754 </tr> -
trunk/www/admin/annotationtypes/list_annotationtypes.jsp
r5165 r5423 1 1 <%-- $Id$ 2 2 ------------------------------------------------------------------ 3 Copyright (C) 2006 Jari H äkkinen, Nicklas Nordborg, Martin Svensson3 Copyright (C) 2006 Jari H�kkinen, Nicklas Nordborg, Martin Svensson 4 4 Copyright (C) 2007 Johan Enell, Nicklas Nordborg, Martin Svensson 5 5 … … 612 612 /></tbl:cell> 613 613 <tbl:cell column="isEnumeration"><%=item.isEnumeration() ? 614 HTML.encodeTags(Values.getString( item.getValues(), ", ", true)) :614 HTML.encodeTags(Values.getString((List)item.getValues(), ", ", true, (Formatter)FormatterFactory.getTypeFormatter(sc, item.getValueType()) )) : 615 615 "<i>- no -</i>"%></tbl:cell> 616 616 <tbl:cell column="requiredForMiame"><%=item.isRequiredForMiame() ? "yes" : "no"%></tbl:cell> -
trunk/www/admin/annotationtypes/view_annotationtype.jsp
r5070 r5423 1 1 <%-- $Id$ 2 2 ------------------------------------------------------------------ 3 Copyright (C) 2006 Jari H äkkinen, Nicklas Nordborg, Martin Svensson3 Copyright (C) 2006 Jari H�kkinen, Nicklas Nordborg, Martin Svensson 4 4 Copyright (C) 2007 Martin Svensson 5 5 … … 63 63 import="java.util.Date" 64 64 import="java.util.Set" 65 import="java.util.List" 65 66 %> 66 67 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 283 284 <td class="prompt">Enumeration</td> 284 285 <td><%=annotationType.isEnumeration() ? 285 HTML.encodeTags(Values.getString( annotationType.getValues(), ", ", true,286 annotationType.getValueType() == Type.DATE ? dateFormatter : null)) : "no"%></td>286 HTML.encodeTags(Values.getString((List)annotationType.getValues(), ", ", true, 287 (Formatter)FormatterFactory.getTypeFormatter(sc, annotationType.getValueType()))) : "no"%></td> 287 288 </tr> 288 289 <tr> -
trunk/www/common/annotations/annotate.jsp
r5075 r5423 2 2 ------------------------------------------------------------------ 3 3 Copyright (C) 2005 Nicklas Nordborg 4 Copyright (C) 2006 Jari H äkkinen, Nicklas Nordborg4 Copyright (C) 2006 Jari H�kkinen, Nicklas Nordborg 5 5 Copyright (C) 2007 Nicklas Nordborg 6 6 … … 88 88 String htmlDateFormat = HTML.encodeTags(dateFormat); 89 89 90 Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); 91 String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc); 92 String jsDateTimeFormat = HTML.javaScriptEncode(dateTimeFormat); 93 String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat); 94 90 95 final Annotatable item = itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId); 91 96 final boolean writePermission = item == null ? true : item.hasPermission(Permission.WRITE); … … 190 195 List values = null; 191 196 Unit unit = at.getDefaultUnit(); 197 Type valueType = at.getValueType(); 192 198 if (existing != null && existing.containsKey(at)) 193 199 { … … 206 212 for (Object value : values) 207 213 { 208 if (value instanceof Date) value = dateFormatter.format((Date)value); 214 if (value instanceof Date) 215 { 216 if (valueType == Type.TIMESTAMP) 217 { 218 value = dateTimeFormatter.format((Date)value); 219 } 220 else 221 { 222 value = dateFormatter.format((Date)value); 223 } 224 } 209 225 %> 210 226 values[values.length] = '<%=HTML.javaScriptEncode(value.toString())%>'; … … 807 823 <% 808 824 } 825 else if (valueType == Type.TIMESTAMP) 826 { 827 %> 828 <table> 829 <tr> 830 <td> 831 <b><%=HTML.encodeTags(at.getName())%></b> (Timestamp)<br> 832 <input <%=clazz%> type="text" name="<%=inputName%>" value="" 833 size="30" maxlength="30" title="Enter date + time in format: <%=htmlDateTimeFormat%>" 834 onblur="valueOnBlur(this.value)"> 835 </td> 836 <td> 837 <br> 838 <base:button 839 onclick="<%="Dates.selectDateTime('Value', 'annotations', '"+inputName+"', 'setDateCallback', '"+jsDateTimeFormat+"')"%>" 840 image="calendar.png" 841 title="Calendar…" 842 tooltip="Select date and time from a calendar" 843 /> 844 </td> 845 </tr> 846 </table> 847 <% 848 } 809 849 if (at.supportUnits() && !at.isEnumeration()) 810 850 { -
trunk/www/common/calendar.jsp
r4889 r5423 2 2 ------------------------------------------------------------------ 3 3 Copyright (C) 2005 Nicklas Nordborg 4 Copyright (C) 2006 Jari H äkkinen, Nicklas Nordborg4 Copyright (C) 2006 Jari H�kkinen, Nicklas Nordborg 5 5 6 6 This file is part of BASE - BioArray Software Environment. … … 33 33 --%> 34 34 <%@ page session="false" 35 import="net.sf.basedb.core.SessionControl" 35 36 import="net.sf.basedb.util.Values" 37 import="net.sf.basedb.clients.web.Base" 36 38 import="net.sf.basedb.clients.web.util.HTML" 37 39 import="java.util.Date" … … 39 41 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> 40 42 <% 43 final SessionControl sc = Base.getExistingSessionControl(pageContext, true); 41 44 String title = request.getParameter("title"); 42 45 String form = request.getParameter("form"); 43 46 String input = request.getParameter("input"); 44 47 String callback = request.getParameter("callback"); 45 String format = Values.getString(request.getParameter("format"), "yyyy-MM-dd"); 48 boolean datetime = Values.getBoolean(request.getParameter("datetime")); 49 String format = Values.getString(request.getParameter("format"), datetime ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd"); 50 final float scale = Base.getScale(sc); 46 51 %> 47 52 <base:page type="popup" title="<%=title%>"> 48 <base:head styles="calendar.css ">53 <base:head styles="calendar.css?x"> 49 54 <script language="JavaScript"> 55 56 var datetime = <%=datetime ? "1" : "0"%>; 57 var dateFormat = '<%=HTML.javaScriptEncode(format)%>'; 58 var currentDate; 50 59 function init() 51 60 { 52 var date = getDate(); 53 var frm = document.forms['calendar']; 54 Forms.selectListOption(frm.month, date.getMonth()); 55 frm.year.value = Dates.getFourDigitYear(date.getFullYear()); 56 displayMonth(date.getFullYear(), date.getMonth(), date); 57 } 58 59 function getDate() 61 currentDate = getInitialDate(); 62 showFullDate(currentDate); 63 } 64 65 function getInitialDate() 60 66 { 61 67 var frm = window.opener.document.forms['<%=form%>']; … … 65 71 return date; 66 72 } 67 68 function setDate(theDate) 69 { 70 var formattedDate = Dates.formatDate(theDate, '<%=HTML.javaScriptEncode(format)%>'); 73 74 function saveCurrentDate() 75 { 76 var frm = document.forms['calendar']; 77 if (!validate()) 78 { 79 alert(document.getElementById('error').innerHTML); 80 return; 81 } 82 var formattedDate = Dates.formatDate(currentDate, dateFormat); 71 83 <% 72 84 if (callback == null) … … 87 99 } 88 100 101 function showFullDate(date) 102 { 103 var frm = document.forms['calendar']; 104 // Year is a regular input field 105 frm.year.value = Dates.getFourDigitYear(date.getFullYear()); 106 // Month is a selection list 107 Forms.selectListOption(frm.month, date.getMonth()); 108 // Days in the month are displayed as a table 109 displayMonth(date.getFullYear(), date.getMonth(), date); 110 // Time (if present) are regular input fields 111 if (datetime) 112 { 113 frm.hours.value = zeroPad(date.getHours()); 114 frm.minutes.value = zeroPad(date.getMinutes()); 115 frm.seconds.value = zeroPad(date.getSeconds()); 116 } 117 // Finally, a complete formatted date is created 118 document.getElementById('current').innerHTML = Dates.formatDate(date, dateFormat); 119 } 120 121 function zeroPad(value) 122 { 123 return value <= 9 ? '0' + value : value; 124 } 125 126 function setDate(date) 127 { 128 if (!validate()) return; 129 currentDate.setFullYear(date.getFullYear()); 130 currentDate.setMonth(date.getMonth()); 131 currentDate.setDate(date.getDate()); 132 if (datetime) 133 { 134 showFullDate(currentDate); 135 } 136 else 137 { 138 saveCurrentDate(); 139 } 140 } 141 142 function setTime() 143 { 144 if (!validate()) return; 145 var frm = document.forms['calendar']; 146 currentDate.setHours(frm.hours.value); 147 currentDate.setMinutes(frm.minutes.value); 148 currentDate.setSeconds(frm.seconds.value); 149 document.getElementById('current').innerHTML = Dates.formatDate(currentDate, dateFormat); 150 } 151 89 152 function setToday() 90 153 { 91 setDate(new Date()); 154 currentDate = new Date(); 155 saveCurrentDate(); 92 156 } 93 157 … … 107 171 if (dayOfMonth < 1 || dayOfMonth > daysInMonth) 108 172 { 109 cell.firstChild.nodeValue = ' 173 cell.firstChild.nodeValue = ''; 110 174 cell.theDate = ''; 175 if (day == 0 && week > 4) Main.hide('w' + week); 111 176 } 112 177 else … … 114 179 cell.firstChild.nodeValue = dayOfMonth; 115 180 cell.theDate = Dates.newDate(year, month, dayOfMonth); 181 if (day == 0) Main.show('w' + week); 116 182 } 117 183 if (year == today.getFullYear() && month == today.getMonth() && dayOfMonth == today.getDate()) … … 138 204 function changeMonth() 139 205 { 140 var frm = document.forms['calendar']; 141 if (frm.year.value.length != 4) 142 { 143 Main.showInline('invalidyear'); 144 return; 145 } 146 else 147 { 148 Main.hide('invalidyear'); 149 } 206 if (!validate()) return; 207 var frm = document.forms['calendar']; 150 208 var month = Number(frm.month[frm.month.selectedIndex].value); 151 209 var year = Number(frm.year.value); 152 displayMonth(year, month, getDate()); 153 } 154 210 displayMonth(year, month, currentDate); 211 } 212 213 function addToYear(delta) 214 { 215 var frm = document.forms['calendar']; 216 var nextYear = parseInt(frm.year.value, 10) + delta; 217 frm.year.value = nextYear; 218 changeMonth(); 219 } 220 221 function addToHour(delta) 222 { 223 var frm = document.forms['calendar']; 224 var nextHour = parseInt(frm.hours.value, 10) + delta; 225 if (nextHour < 0) nextHour = 0; 226 if (nextHour > 23) nextHour = 23; 227 frm.hours.value = zeroPad(nextHour); 228 setTime(); 229 } 230 231 function addToMinute(delta) 232 { 233 var frm = document.forms['calendar']; 234 var nextMinute = parseInt(frm.minutes.value, 10) + delta; 235 if (nextMinute < 0) nextMinute = 0; 236 if (nextMinute > 59) nextMinute = 59; 237 frm.minutes.value = zeroPad(nextMinute); 238 setTime(); 239 } 240 241 function addToSecond(delta) 242 { 243 var frm = document.forms['calendar']; 244 var nextSecond = parseInt(frm.seconds.value, 10) + delta; 245 if (nextSecond < 0) nextSecond = 0; 246 if (nextSecond > 59) nextSecond = 59; 247 frm.seconds.value = zeroPad(nextSecond); 248 setTime(); 249 } 250 251 function showError(message) 252 { 253 document.getElementById('error').innerHTML = message; 254 Main.show('error'); 255 Main.hide('current'); 256 } 257 258 function validate() 259 { 260 var frm = document.forms['calendar']; 261 if (frm.year.value.length != 4) 262 { 263 showError('Year must have four digits'); 264 return false; 265 } 266 if (datetime) 267 { 268 var hours = parseInt(frm.hours.value, 10); 269 if (hours < 0 || hours > 23) 270 { 271 showError('Hours must be a value between 0 and 23'); 272 return false; 273 } 274 var minutes = parseInt(frm.minutes.value, 10); 275 if (minutes < 0 || minutes > 59) 276 { 277 showError('Minutes must be a value between 0 and 59'); 278 return false; 279 } 280 var seconds = parseInt(frm.seconds.value, 10); 281 if (seconds < 0 || seconds > 59) 282 { 283 showError('Seconds must be a value between 0 and 59'); 284 return false; 285 } 286 } 287 Main.hide('error'); 288 Main.show('current'); 289 return true; 290 } 155 291 </script> 156 292 </base:head> 157 293 <base:body onload="init()"> 158 <form name="calendar" onsubmit=" changeMonth();return false;">294 <form name="calendar" onsubmit="return false;"> 159 295 <h3 class="docked"><%=title%><base:help helpid="calendar.selectday" /></h3> 160 296 <div class="boxed"> … … 179 315 </td> 180 316 <td style="text-align: right;"> 181 <span id="invalidyear" class="error" style="display: none;">Year must have 4 digits!</span>182 317 <input type="text" class="text" name="year" size="4" maxlength="4" 183 318 onkeypress="return Numbers.integerOnly(event);" 184 319 onkeyup="changeMonth()"> 185 320 </td> 321 <td width="12px"> 322 <table border="0" cellspacing="2" cellpadding="0"> 323 <tr><td><base:icon image="mini_scroll_up.png" onclick="addToYear(1)" tooltip="Next year"/></td></tr> 324 <tr><td><base:icon image="mini_scroll_down.png" onclick="addToYear(-1)" tooltip="Previous year"/></td></tr> 325 </table> 326 </td> 186 327 </tr> 187 328 </table> 188 329 <div style="min-height: <%=(int)(scale*130)%>px;"> 189 330 <table width="100%" border=0 cellspacing=0 cellpadding=0 class="calendar"> 190 331 <tr> … … 220 361 %> 221 362 </table> 363 </div> 364 <% 365 if (datetime) 366 { 367 %> 368 <table border="0" cellspacing=2 cellpadding=0 align="center" style="padding-top: 4px;"> 369 <tr> 370 <td class="time">Time</td> 371 <td><input class="text" type="text" name="hours" title="Hours" size="2" maxlength="2" 372 onkeypress="return Numbers.integerOnly(event)" onblur="setTime()"></td> 373 <td width="12px"> 374 <table border="0" cellspacing="1" cellpadding="0"> 375 <tr><td><base:icon image="mini_scroll_up.png" onclick="addToHour(1)" tooltip="Add one hour"/></td></tr> 376 <tr><td><base:icon image="mini_scroll_down.png" onclick="addToHour(-1)" tooltip="Subtract one hour"/></td></tr> 377 </table> 378 </td> 379 <td><input class="text" type="text" name="minutes" title="Minutes" size="2" maxlength="2" 380 onkeypress="return Numbers.integerOnly(event)" onblur="setTime()"></td> 381 <td width="12px"> 382 <table border="0" cellspacing="1" cellpadding="0"> 383 <tr><td><base:icon image="mini_scroll_up.png" onclick="addToMinute(1)" tooltip="Add one minute"/></td></tr> 384 <tr><td><base:icon image="mini_scroll_down.png" onclick="addToMinute(-1)" tooltip="Subtract one minute"/></td></tr> 385 </table> 386 </td> 387 <td><input class="text" type="text" name="seconds" title="Seconds" size="2" maxlength="2" 388 onkeypress="return Numbers.integerOnly(event)" onblur="setTime()"></td> 389 <td width="12px"> 390 <table border="0" cellspacing="1" cellpadding="0"> 391 <tr><td><base:icon image="mini_scroll_up.png" onclick="addToSecond(1)" tooltip="Add one second"/></td></tr> 392 <tr><td><base:icon image="mini_scroll_down.png" onclick="addToSecond(-1)" tooltip="Subtract one second"/></td></tr> 393 </table> 394 </td> 395 </tr> 396 </table> 397 <% 398 } 399 %> 222 400 </div> 223 401 </form> 224 <table align="center"> 225 <tr> 226 <td><base:button image="today.png" onclick="setToday()" title="Today" /></td> 227 <td><base:button onclick="window.close()" title="Cancel" /></td> 228 </tr> 229 </table> 402 <p></p> 403 <div id="error" class="error" style="display: none;"></div> 404 <div id="current" style="text-align: center; font-weight: bold;"></div> 405 <base:buttongroup align="center"> 406 <base:button image="today.png" onclick="setToday()" title="<%=datetime ? "Now" : "Today"%>" /> 407 <base:button onclick="saveCurrentDate()" title="Ok" visible="<%=datetime%>"/> 408 <base:button onclick="window.close()" title="Cancel" /> 409 </base:buttongroup> 230 410 </base:body> 231 411 </base:page> -
trunk/www/include/scripts/main.js
r5411 r5423 1366 1366 url += '&ID='+getSessionId(); 1367 1367 if (callback) url += '&callback='+callback; 1368 Main.openPopup(url, title.replace(/[^\w]/, ''), 350, 240); 1369 } 1368 Main.openPopup(url, title.replace(/[^\w]/, ''), 440, 340); 1369 } 1370 1371 /* 1372 Opens a popup window allowing a user to select a date and time graphically. The 1373 current value is taken from the specified input field of the specified form and 1374 is saved back to it when the window is closed. 1375 1376 @param title The title of the window 1377 @param form The name of the form where the input field is located 1378 @param input The name of the input field that holds the date value 1379 @param callback If specified, the date is returned by using this javascript call instead 1380 of by setting the form field 1381 */ 1382 this.selectDateTime = function(title, form, input, callback, format) 1383 { 1384 var url = getRoot()+'common/calendar.jsp?datetime=1&title='+escape(title)+'&form='+form+'&input='+input+'&format='+escape(format); 1385 url += '&ID='+getSessionId(); 1386 if (callback) url += '&callback='+callback; 1387 Main.openPopup(url, title.replace(/[^\w]/, ''), 440, 340); 1388 } 1389 1390 1370 1391 } 1371 1392 -
trunk/www/include/styles/calendar.css
r4889 r5423 2 2 ------------------------------------------------------------------ 3 3 Copyright (C) 2005 Nicklas Nordborg 4 Copyright (C) 2006 Jari H äkkinen4 Copyright (C) 2006 Jari H�kkinen 5 5 6 6 This file is part of BASE - BioArray Software Environment. … … 51 51 } 52 52 53 .time { 54 padding-left: 2px; 55 font-weight: bold; 56 } 57 53 58 .today, .current { 54 59 font-weight: bold;
Note: See TracChangeset
for help on using the changeset viewer.