Changeset 3908
- Timestamp:
- Oct 21, 2010, 11:47:37 AM (13 years ago)
- Location:
- trunk/client/servlet
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/src/org/proteios/gui/web/GUIConverter.java
r3905 r3908 1 1 /* 2 2 $Id$ 3 3 4 4 Copyright (C) 2006 Gregory Vincic 5 5 Copyright (C) 2007 Gregory Vincic, Olle Mansson 6 6 7 7 Files are copyright by their respective authors. The contributions to 8 8 files where copyright is not explicitly stated can be traced with the 9 9 source code revision system. 10 10 11 11 This file is part of Proteios. 12 12 Available at http://www.proteios.org/ 13 13 14 14 Proteios-2.x is free software; you can redistribute it and/or 15 15 modify it under the terms of the GNU General Public License 16 16 as published by the Free Software Foundation; either version 2 17 17 of the License, or (at your option) any later version. 18 18 19 19 Proteios is distributed in the hope that it will be useful, 20 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 22 GNU General Public License for more details. 23 23 24 24 You should have received a copy of the GNU General Public License 25 25 along with this program; if not, write to the Free Software … … 132 132 private String currentFormId = null; 133 133 private TypeUtil typeUtil = new TypeUtil(); 134 134 135 135 public HttpServletRequest getRequest() 136 136 { 137 137 return request; 138 138 } 139 139 140 140 public void setRequest(HttpServletRequest request) 141 141 { … … 143 143 hf.setRequest(request); 144 144 } 145 145 146 146 public GUIConverter(String contextPath) 147 147 { … … 151 151 this.hf = new HtmlFactory(contextPath); 152 152 } 153 153 154 154 private Random r = new Random(); 155 155 156 156 public Tag convert(Image img) 157 157 { … … 238 238 return div; 239 239 } 240 240 241 241 public Tag convert(IFrame obj) 242 242 { … … 250 250 return tag; 251 251 } 252 252 253 253 public Tag convert(Listing list) 254 254 { … … 285 285 return layout; 286 286 } 287 287 288 288 /** 289 289 * @param action … … 302 302 return sb.toString(); 303 303 } 304 304 305 305 public Tag convert(org.proteios.gui.TreeMenu menu) 306 306 { … … 314 314 return layout.getRoot(); 315 315 } 316 316 317 317 public Tag convert(org.proteios.gui.MainMenu menu) 318 318 { 319 319 Tag div, ul; 320 320 321 321 div = hf.newLayoutDiv(); 322 322 ul = convert((org.proteios.gui.TreeMenu) menu); 323 323 324 324 div.add(ul); 325 325 return div; 326 326 } 327 327 328 328 public String convert(ClosePopup button) 329 329 { 330 330 return "closeAllVisiblePopups()"; 331 331 } 332 332 333 333 public Tag<?> convert(ActionLink pageLink, String formId, boolean localize) 334 334 { … … 347 347 return tag; 348 348 } 349 349 350 350 /** 351 351 * Converts an ActionLink such that each parameter of the ActionLink is a … … 383 383 return js.toString(); 384 384 } 385 385 386 386 public Tag convert(Scroller scroller, String formId) 387 387 { … … 446 446 return scrollBar.getRoot(); 447 447 } 448 448 449 449 /** 450 450 * @param table to convert … … 486 486 } 487 487 } 488 488 489 489 } 490 490 scroller = table.getScroller(); … … 580 580 // Column display order select box 581 581 Integer colDisplayOrder = col.getDisplayOrder(); 582 582 583 583 if (ad.getKey().equals("Id")) 584 584 { … … 608 608 tr.newTd().add(displayOrderSelectBox); 609 609 } 610 610 611 611 // Order by 612 612 if (col.getDisplayFilter()) … … 893 893 return layout.getRoot(); 894 894 } 895 895 896 896 public Tag convert(org.proteios.gui.table.FolderTable table) 897 897 { … … 943 943 return layout.getRoot(); 944 944 } 945 945 946 946 public Tr convert(Row row) 947 947 { … … 962 962 return tr; 963 963 } 964 964 965 965 public Tr convert(TreeRow row) 966 966 { … … 989 989 return tr; 990 990 } 991 991 992 992 public Tag convert(Separator sep) 993 993 { 994 994 return new Hr(); 995 995 } 996 996 997 997 public <D extends Object> Tag convert(Cell<D> cell) 998 998 { … … 1069 1069 return td; 1070 1070 } 1071 1071 1072 1072 public Tag convert(Column col) 1073 1073 { … … 1078 1078 return th; 1079 1079 } 1080 1080 1081 1081 public Tag convert(Column col, org.proteios.gui.table.Table table) 1082 1082 { … … 1099 1099 return th; 1100 1100 } 1101 1101 1102 1102 public Tag convert(Text txt) 1103 1103 { … … 1107 1107 return layout; 1108 1108 } 1109 1109 1110 1110 public Tag convert(TitledWindow win) 1111 1111 { … … 1150 1150 return window.getRoot(); 1151 1151 } 1152 1152 1153 1153 @SuppressWarnings("unused") 1154 1154 public Tag convert(Space space) … … 1156 1156 return new Div().setClass("space"); 1157 1157 } 1158 1158 1159 1159 public Tag convert(Message msg) 1160 1160 { … … 1163 1163 return layout.getRoot(); 1164 1164 } 1165 1165 1166 1166 int idCounter = 0; 1167 1167 String lastId = ""; 1168 1168 1169 1169 public String nextId() 1170 1170 { … … 1173 1173 return lastId; 1174 1174 } 1175 1175 1176 1176 public String getLastId() 1177 1177 { 1178 1178 return lastId; 1179 1179 } 1180 1180 1181 1181 public Tag convert(org.proteios.gui.Error err) 1182 1182 { … … 1185 1185 return layout.getRoot(); 1186 1186 } 1187 1187 1188 1188 public Tag convert(org.proteios.gui.form.Form w) 1189 1189 { … … 1194 1194 Input field; 1195 1195 AbstractLink defaultAction; 1196 1196 1197 1197 layout = hf.newLayoutDiv(); 1198 1198 clearForm = false; … … 1239 1239 return layout.getRoot(); 1240 1240 } 1241 1241 1242 1242 public Tag convert(org.proteios.gui.form.Fieldset fs) 1243 1243 { 1244 1244 return convertFieldset(fs, null, false); 1245 1245 } 1246 1246 1247 1247 private int fieldsetId = 0; 1248 1248 private int nextFieldsetId() { fieldsetId++; return fieldsetId; } 1249 1249 1250 1250 private Tag convertFieldset(org.proteios.gui.form.Fieldset fs, Form form, Boolean useToggle) 1251 1251 { 1252 1252 Fieldset fieldset; 1253 1253 Tag legend, title, fields, table, row, helpC, input; 1254 1254 Img btn; 1255 1255 String subtitle; 1256 1256 org.proteios.gui.form.Field field; 1257 1257 String id = "fs" + nextFieldsetId(); 1258 1258 String btnId = "btn" + id; 1259 1259 fieldset = new Fieldset(); 1260 1260 // Fieldset legend 1261 1261 legend = fieldset.newDiv().setClass("legend"); 1262 1262 title = new Div().addClass("title"); 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1263 if(useToggle) 1264 { 1265 legend.setOnClick("toggleFieldset('" + id + "')"); 1266 btn = new Img(); 1267 btn.addClass("toggle"); 1268 btn.setId(btnId); 1269 legend.add(btn); 1270 btn.setSrc(fs.isOpen() ? "static/img/minus.gif" : "static/img/plus.gif"); 1271 } 1272 1273 1273 if (fs.getTitle()!= null) 1274 1274 { … … 1283 1283 } 1284 1284 legend.add(title.getRoot()); 1285 1285 1286 1286 fields = fieldset.newDiv().setClass("fields"); 1287 1288 1287 fields.setId(id); 1288 fields.setStyle("display: " + (fs.isOpen() ? "block" : "none")); 1289 1289 table = fields.newTable(); 1290 1290 for (org.proteios.gui.GUIElement f : fs.getFields()) 1291 1291 { 1292 row = table.newTr(); 1293 // Label cell 1294 if(f instanceof org.proteios.gui.form.Field) 1295 { 1296 field = (org.proteios.gui.form.Field) f; 1297 row.newTd().addClass("label").newCData(locale.get(field.getLabel())); 1298 input = null; 1299 // Field cell 1300 if (f instanceof TextField) 1301 { 1302 input = convert((TextField<?>) f); 1303 if(((TextField<?>)field).isHidden()) 1304 { 1305 row.addClass("hidden"); 1306 } 1307 } 1308 else if (f instanceof PasswordField) 1309 { 1310 input = convert((PasswordField) f); 1311 } 1312 else if (f instanceof FileField) 1313 { 1314 if (form != null) 1315 { 1316 form.setMultipart(); 1317 } 1318 input = convert((FileField) f); 1319 } 1320 else if (f instanceof TextArea) 1321 { 1322 input = convert((TextArea) f); 1323 } 1324 else if (f instanceof org.proteios.gui.form.Select) 1325 { 1326 input = convert((org.proteios.gui.form.Select) f); 1327 if (((org.proteios.gui.form.Select)f).isHidden() != null && ((org.proteios.gui.form.Select)f).isHidden()) 1328 { 1329 row.addClass("hidden"); 1330 } 1331 } 1332 else if (f instanceof org.proteios.gui.form.Checkbox) 1333 { 1334 input = convert((org.proteios.gui.form.Checkbox) f, false); 1335 } 1336 1337 if (field.getParam().isRequired() || 1338 (field.getParam() instanceof VString && ((VString) field.getParam()).getMinCharacterLength() > 0)) 1339 { 1340 input.addClass("required"); 1341 } 1342 if(input != null) 1343 { 1344 row.newTd().add(input); 1345 } 1346 1347 // Help and error field 1348 helpC = row.newTd(); 1349 helpC.newDiv().addClass("error").add(hf.getFieldError(field)); 1350 helpC.newDiv().addClass("help").newCData(field.getHelp()); 1351 } 1352 if (f instanceof org.proteios.gui.table.Table) 1353 { 1354 row.newTd().add(convert((org.proteios.gui.table.Table) f)); 1355 } 1356 1292 addFieldAsRow(table, f, form); 1357 1293 } 1358 1294 return fieldset; 1359 1295 } 1360 1296 1297 private Tag addFieldAsRow(Tag table, org.proteios.gui.GUIElement f, Form form) 1298 { 1299 Tag legend, title, fields, row, helpC, input; 1300 org.proteios.gui.form.Field field; 1301 row = table.newTr(); 1302 // Label cell 1303 if(f instanceof org.proteios.gui.form.Field) 1304 { 1305 field = (org.proteios.gui.form.Field) f; 1306 row.newTd().addClass("label").newCData(locale.get(field.getLabel())); 1307 input = null; 1308 // Field cell 1309 if (f instanceof TextField) 1310 { 1311 input = convert((TextField<?>) f); 1312 if(((TextField<?>)field).isHidden()) 1313 { 1314 row.addClass("hidden"); 1315 } 1316 } 1317 else if (f instanceof PasswordField) 1318 { 1319 input = convert((PasswordField) f); 1320 } 1321 else if (f instanceof FileField) 1322 { 1323 if (form != null) 1324 { 1325 form.setMultipart(); 1326 } 1327 input = convert((FileField) f); 1328 } 1329 else if (f instanceof TextArea) 1330 { 1331 input = convert((TextArea) f); 1332 } 1333 else if (f instanceof org.proteios.gui.form.Select) 1334 { 1335 input = convert((org.proteios.gui.form.Select) f); 1336 if (((org.proteios.gui.form.Select)f).isHidden() != null && ((org.proteios.gui.form.Select)f).isHidden()) 1337 { 1338 row.addClass("hidden"); 1339 } 1340 } 1341 else if (f instanceof org.proteios.gui.form.Checkbox) 1342 { 1343 input = convert((org.proteios.gui.form.Checkbox) f, false); 1344 } 1345 1346 if (field.getParam().isRequired() || 1347 (field.getParam() instanceof VString && ((VString) field.getParam()).getMinCharacterLength() > 0)) 1348 { 1349 input.addClass("required"); 1350 } 1351 if(input != null) 1352 { 1353 row.newTd().add(input); 1354 } 1355 1356 // Help and error field 1357 helpC = row.newTd(); 1358 helpC.newDiv().addClass("error").add(hf.getFieldError(field)); 1359 helpC.newDiv().addClass("help").newCData(field.getHelp()); 1360 } 1361 else if (f instanceof org.proteios.gui.table.Table) 1362 { 1363 row.newTd().add(convert((org.proteios.gui.table.Table) f)); 1364 } 1365 else if (f instanceof org.proteios.gui.form.Fieldset) 1366 { 1367 org.proteios.gui.form.Fieldset subfs = (org.proteios.gui.form.Fieldset) f; 1368 // Sub fieldsets are not allowed to have toggling feature 1369 row.newTd().setAttribute(new Attribute("colspan", "2")).setClass("sublegend").newCData(subfs.getTitle().getTitle()); 1370 for (org.proteios.gui.GUIElement subf : subfs.getFields()) 1371 { 1372 Tag subRow = addFieldAsRow(table, subf, form); 1373 Tag labeltd = (Tag) subRow.getElements().get(0); // the td tag 1374 labeltd.addClass("subfield"); 1375 } 1376 table.newTr().newTd().setAttribute(new Attribute("colspan", "2")).setClass("subend").newBr(); 1377 } 1378 return row; 1379 } 1380 1361 1381 private Tag convert(FileField f) 1362 1382 { … … 1369 1389 return in; 1370 1390 } 1371 1391 1372 1392 public Tag convert(org.proteios.gui.form.Select<?> select) 1373 1393 { … … 1404 1424 if (select.isHidden() != null && select.isHidden()) 1405 1425 { 1406 1426 selectTag.setAttribute(new Attribute("style", "display:none;")); 1407 1427 } 1408 1428 selectTag.setOnChange("setNameField(this)"); … … 1431 1451 return field; 1432 1452 } 1433 1453 1434 1454 public Tag convert(ColumnContainer container) 1435 1455 { … … 1456 1476 return layout; 1457 1477 } 1458 1478 1459 1479 public Tag convert(org.proteios.gui.Empty empty) 1460 1480 { 1461 1481 return new Span().newCData(" "); 1462 1482 } 1463 1483 1464 1484 public Tag convert(RowContainer container) 1465 1485 { … … 1484 1504 return span; 1485 1505 } 1486 1506 1487 1507 private int treeLevel = 0; 1488 1508 1489 1509 public Tag convert(Node node) 1490 1510 { … … 1557 1577 childHref.addClass("last"); 1558 1578 } 1559 1579 1560 1580 if (first) 1561 1581 first = false; … … 1566 1586 return li; 1567 1587 } 1568 1588 1569 1589 /** 1570 1590 * Convenience method for getting path to a bullet/spacer image file marking … … 1595 1615 return iconPath; 1596 1616 } 1597 1617 1598 1618 /** 1599 1619 * Converts a toolbar so that button clicks post the form referenced by … … 1664 1684 return new CData(""); 1665 1685 } 1666 1686 1667 1687 public Tag convert(org.proteios.gui.TabSet set) 1668 1688 { … … 1691 1711 return layout; 1692 1712 } 1693 1713 1694 1714 private Tag convert(org.proteios.gui.Tab tab, boolean convertTabContent) 1695 1715 { … … 1710 1730 return li; 1711 1731 } 1712 1732 1713 1733 private Tag convert(org.proteios.gui.form.TextArea f) 1714 1734 { … … 1727 1747 return in; 1728 1748 } 1729 1749 1730 1750 private String formatedValue(TextField<?> f) 1731 1751 { … … 1741 1761 return value; 1742 1762 } 1743 1763 1744 1764 private <D extends Object> Tag<?> convert( 1745 1765 org.proteios.gui.form.TextField<D> f) … … 1749 1769 Input in; 1750 1770 Tag<?> field; 1751 1771 1752 1772 // Format the value 1753 1773 value = formatedValue(f); 1754 1774 container = new CData(""); 1755 1775 1756 1776 in = null; 1757 1777 type = "text"; … … 1780 1800 return container; 1781 1801 } 1782 1802 1783 1803 private Tag<?> convert(org.proteios.gui.form.PasswordField f) 1784 1804 { … … 1791 1811 return in; 1792 1812 } 1793 1813 1794 1814 public Tag<?> convert(org.proteios.gui.form.Checkbox<?> checkbox) 1795 1815 { 1796 1816 return convert(checkbox, false); 1797 1817 } 1798 1818 1799 1819 private Tag<?> convert(org.proteios.gui.form.Checkbox<?> checkbox, 1800 1820 boolean inForm) … … 1817 1837 return cbF; 1818 1838 } 1819 1839 1820 1840 public Tag<?> convert(org.proteios.gui.Toolbar toolbar) 1821 1841 { … … 1883 1903 return layout.getRoot(); 1884 1904 } 1885 1905 1886 1906 public Tag<?> convert(org.proteios.gui.Button button) 1887 1907 { … … 1950 1970 return layout.getRoot(); 1951 1971 } 1952 1972 1953 1973 public Tag<?> convert(org.proteios.gui.ButtonSet toolbar) 1954 1974 { … … 1957 1977 return layout; 1958 1978 } 1959 1979 1960 1980 public Tag<?> convert(org.proteios.gui.Title title) 1961 1981 { … … 1977 1997 return hx.getRoot(); 1978 1998 } 1979 1999 1980 2000 @Override 1981 2001 public Tag missingConverter(ConvertableElement obj) … … 1987 2007 return div; 1988 2008 } 1989 2009 1990 2010 public void setLocale(Localizer locale) 1991 2011 { … … 1997 2017 } 1998 2018 } 1999 2019 2000 2020 public void setIconSet(Properties iconSet) 2001 2021 { -
trunk/client/servlet/www/static/css/layout2.jsp
r3905 r3908 222 222 223 223 224 .sublegend 225 { 226 text-align: right; 227 font-size: 0.8em; 228 text-transform: uppercase; 229 padding-top: 10px; 230 } 231 232 224 233 div.form form div.legend 225 234 {
Note: See TracChangeset
for help on using the changeset viewer.