Source Code Cross Referenced for ItsNatTableUIImpl.java in  » Ajax » ItsNat » org » itsnat » impl » comp » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » ItsNat » org.itsnat.impl.comp.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          ItsNat Java Web Application Framework
003:          Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004:          Author: Jose Maria Arranz Santamaria
005:
006:          This program is free software: you can redistribute it and/or modify
007:          it under the terms of the GNU Affero General Public License as published by
008:          the Free Software Foundation, either version 3 of the License, or
009:          (at your option) any later version. See the GNU Affero General Public 
010:          License for more details. See the copy of the GNU Affero General Public License
011:          included in this program. If not, see <http://www.gnu.org/licenses/>.
012:         */
013:
014:        package org.itsnat.impl.comp.ui;
015:
016:        import org.itsnat.comp.ItsNatTable;
017:        import org.itsnat.comp.ui.ItsNatTableHeaderUI;
018:        import org.itsnat.impl.comp.ItsNatTableImpl;
019:        import org.itsnat.impl.core.domutil.ElementTableImpl;
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import org.itsnat.comp.ItsNatTableCellRenderer;
023:        import org.itsnat.comp.ItsNatTableHeader;
024:        import org.itsnat.comp.ItsNatTableStructure;
025:        import org.itsnat.comp.ui.ItsNatTableCellUI;
026:        import org.itsnat.comp.ui.ItsNatTableUI;
027:        import org.itsnat.impl.core.ItsNatDocumentImpl;
028:        import org.itsnat.impl.core.domutil.ElementListBaseImpl;
029:        import org.itsnat.impl.core.domutil.ElementListImpl;
030:        import org.itsnat.impl.core.domutil.TableCellElementInfoMasterImpl;
031:        import org.w3c.dom.Element;
032:        import org.w3c.dom.Node;
033:
034:        /**
035:         *
036:         * @author jmarranz
037:         */
038:        public abstract class ItsNatTableUIImpl extends
039:                ItsNatElementComponentUIImpl implements  ItsNatTableUI {
040:            protected boolean enabled = true;
041:            protected ElementTableImpl tableMgr;
042:            protected ArrayList columnIdentifiers = new ArrayList();
043:
044:            /**
045:             * Creates a new instance of ItsNatTableUIImpl
046:             */
047:            public ItsNatTableUIImpl(ItsNatTableImpl parentComp) {
048:                super (parentComp);
049:
050:                ItsNatTableStructure structure = parentComp
051:                        .getItsNatTableStructure();
052:                Element tableElem = parentComp.getElement();
053:                Element bodyElem = structure.getBodyElement(parentComp,
054:                        tableElem);
055:
056:                ItsNatTableStructureCoreAdapterImpl structAdapter;
057:                structAdapter = new ItsNatTableStructureCoreAdapterImpl(
058:                        structure, parentComp, null);
059:
060:                ItsNatDocumentImpl itsNatDoc = getItsNatDocumentImpl();
061:                this .tableMgr = itsNatDoc.createElementTableInternal(bodyElem,
062:                        true, structAdapter, null);
063:            }
064:
065:            public Element getBodyElement() {
066:                return tableMgr.getParentElement(); // El <tbody> en el caso de <table>
067:            }
068:
069:            public ItsNatTableHeaderUI getItsNatTableHeaderUI() {
070:                ItsNatTableHeader header = getItsNatTable()
071:                        .getItsNatTableHeader();
072:                if (header == null)
073:                    return null;
074:                return header.getItsNatTableHeaderUI();
075:            }
076:
077:            public ItsNatTable getItsNatTable() {
078:                return (ItsNatTable) parentComp;
079:            }
080:
081:            public ItsNatTableCellRenderer getItsNatTableCellRenderer() {
082:                return getItsNatTable().getItsNatTableCellRenderer();
083:            }
084:
085:            public ItsNatTableCellUI getItsNatTableCellUIFromNode(Node node) {
086:                TableCellElementInfoMasterImpl cellInfo = (TableCellElementInfoMasterImpl) tableMgr
087:                        .getTableCellElementInfoFromNode(node);
088:                return ItsNatTableCellUIImpl.getItsNatTableCellUI(cellInfo,
089:                        this );
090:            }
091:
092:            public ItsNatTableCellUI getItsNatTableCellUIAt(int row, int column) {
093:                TableCellElementInfoMasterImpl cellInfo = (TableCellElementInfoMasterImpl) tableMgr
094:                        .getTableCellElementInfoAt(row, column);
095:                return ItsNatTableCellUIImpl.getItsNatTableCellUI(cellInfo,
096:                        this );
097:            }
098:
099:            public int getRowCount() {
100:                return tableMgr.getRowCount();
101:            }
102:
103:            public int getColumnCount() {
104:                return tableMgr.getColumnCount();
105:            }
106:
107:            public void setRowCount(int rows) {
108:                tableMgr.setRowCount(rows);
109:            }
110:
111:            public void setColumnCount(int columns) {
112:                tableMgr.setColumnCount(columns);
113:            }
114:
115:            public void setCellValueAt(int rowIndex, int columnIndex,
116:                    Object aValue, boolean isSelected, boolean hasFocus) {
117:                Element cellElem = getCellElementAt(rowIndex, columnIndex);
118:                setElementValueAt(rowIndex, columnIndex, aValue, isSelected,
119:                        hasFocus, cellElem, false);
120:            }
121:
122:            public void setElementValueAt(int rowIndex, int columnIndex,
123:                    Object aValue, boolean isSelected, boolean hasFocus,
124:                    Element cellElem, boolean isNew) {
125:                Element cellContentElem = tableMgr.getCellContentElementAt(
126:                        rowIndex, columnIndex, cellElem);
127:
128:                tableMgr.prepareRendering(cellContentElem, isNew);
129:
130:                ItsNatTableCellRenderer renderer = getItsNatTableCellRenderer();
131:                if (renderer != null)
132:                    renderer.renderTableCell(getItsNatTable(), rowIndex,
133:                            columnIndex, aValue, isSelected, hasFocus,
134:                            cellContentElem, isNew);
135:            }
136:
137:            public void insertRowAt(int row, Object[] values) {
138:                Element rowElem = tableMgr.insertRowAt(row);
139:
140:                boolean[] selected = null;
141:                boolean[] hasFocus = null;
142:                if (values != null) {
143:                    selected = new boolean[values.length];
144:                    hasFocus = new boolean[values.length];
145:                }
146:                setRowValuesAt(row, values, selected, hasFocus, rowElem, true);
147:            }
148:
149:            public void setRowValuesAt(int row, Object[] values,
150:                    boolean[] selected, boolean[] hasFocus) {
151:                Element rowElem = tableMgr.getRowElementAt(row);
152:                setRowValuesAt(row, values, selected, hasFocus, rowElem, false);
153:            }
154:
155:            protected void setRowValuesAt(int row, Object[] values,
156:                    boolean[] selected, boolean[] hasFocus, Element rowElem,
157:                    boolean isNew) {
158:                if (values != null) {
159:                    ElementListImpl columns = (ElementListImpl) tableMgr
160:                            .getColumnsOfRowElementList(row, rowElem);
161:                    // Si la longitud de values es menor que el número de columnas dará error
162:                    int i = 0;
163:                    for (Iterator it = columns
164:                            .getInternalElementListFreeMaster().iterator(); it
165:                            .hasNext();) {
166:                        Element columElem = (Element) it.next();
167:                        setElementValueAt(row, i, values[i], selected[i],
168:                                hasFocus[i], columElem, isNew);
169:
170:                        i++;
171:                    }
172:                }
173:            }
174:
175:            public void insertColumnAt(int column, Object[] columnData) {
176:                tableMgr.insertColumnAt(column);
177:
178:                boolean[] selected = null;
179:                boolean[] hasFocus = null;
180:                if (columnData != null) {
181:                    selected = new boolean[columnData.length];
182:                    hasFocus = new boolean[columnData.length];
183:                }
184:
185:                setColumnValuesAt(column, columnData, selected, hasFocus, true);
186:            }
187:
188:            public void setColumnValuesAt(int column, Object[] columnData,
189:                    boolean[] selected, boolean[] hasFocus) {
190:                setColumnValuesAt(column, columnData, selected, hasFocus, false);
191:            }
192:
193:            public void setColumnValuesAt(int column, Object[] columnData,
194:                    boolean[] selected, boolean[] hasFocus, boolean isNew) {
195:                if (columnData != null) {
196:                    ElementListImpl rows = tableMgr.getRowElementList();
197:
198:                    if (!rows.isEmpty()) {
199:                        // Si la longitud de columnData es menor que el número de columnas dará error            
200:                        int row = 0;
201:                        for (Iterator it = rows
202:                                .getInternalElementListFreeMaster().iterator(); it
203:                                .hasNext();) {
204:                            Element rowElem = (Element) it.next();
205:
206:                            ElementListBaseImpl columns = tableMgr
207:                                    .getColumnsOfRowElementList(row, rowElem);
208:                            Element cellElem = (Element) columns
209:                                    .getElementAt(column);
210:                            setElementValueAt(row, column, columnData[row],
211:                                    selected[row], hasFocus[row], cellElem,
212:                                    isNew);
213:
214:                            row++;
215:                        }
216:                    }
217:                }
218:            }
219:
220:            public void unrenderCell(int rowIndex, int columnIndex) {
221:                ItsNatTableCellRenderer renderer = getItsNatTableCellRenderer();
222:                if (renderer == null)
223:                    return;
224:
225:                Element cellElem = getCellElementAt(rowIndex, columnIndex);
226:                Element cellContentElem = tableMgr.getCellContentElementAt(
227:                        rowIndex, columnIndex, cellElem);
228:                renderer.unrenderTableCell(getItsNatTable(), rowIndex,
229:                        columnIndex, cellContentElem);
230:            }
231:
232:            public void unrenderAllCells() {
233:                ItsNatTableCellRenderer renderer = getItsNatTableCellRenderer();
234:                if (renderer == null)
235:                    return;
236:
237:                int rowCount = getRowCount();
238:                int colCount = getColumnCount();
239:                for (int row = 0; row < rowCount; row++)
240:                    for (int col = 0; col < colCount; col++)
241:                        unrenderCell(row, col);
242:            }
243:
244:            public void removeRowAt(int row) {
245:                ItsNatTableCellRenderer renderer = getItsNatTableCellRenderer();
246:                if (renderer != null) {
247:                    int colCount = getColumnCount();
248:                    for (int col = 0; col < colCount; col++)
249:                        unrenderCell(row, col);
250:                }
251:
252:                tableMgr.removeRowAt(row);
253:            }
254:
255:            public void removeColumnAt(int column) {
256:                ItsNatTableCellRenderer renderer = getItsNatTableCellRenderer();
257:                if (renderer != null) {
258:                    int rowCount = getRowCount();
259:                    for (int row = 0; row < rowCount; row++)
260:                        unrenderCell(row, column);
261:                }
262:
263:                tableMgr.removeColumnAt(column);
264:            }
265:
266:            public void removeAllRows() {
267:                unrenderAllCells();
268:
269:                tableMgr.removeAllRows();
270:            }
271:
272:            public void removeAllColumns() {
273:                unrenderAllCells();
274:
275:                tableMgr.removeAllColumns();
276:            }
277:
278:            public Element getRowElementAt(int row) {
279:                return tableMgr.getRowElementAt(row);
280:            }
281:
282:            public Element getRowContentElementAt(int row) {
283:                return tableMgr.getRowContentElementAt(row);
284:            }
285:
286:            public Element getCellElementAt(int row, int column) {
287:                return tableMgr.getCellElementAt(row, column);
288:            }
289:
290:            public Element getCellContentElementAt(int row, int column) {
291:                return tableMgr.getCellContentElementAt(row, column);
292:            }
293:
294:            public Element[] getCellElementsOfRow(int row) {
295:                return tableMgr.getCellElementsOfRow(row);
296:            }
297:
298:            public Element[] getCellElementsOfColumn(int column) {
299:                return tableMgr.getCellElementsOfColumn(column);
300:            }
301:
302:            public boolean isUsePatternMarkupToRender() {
303:                return tableMgr.isUsePatternMarkupToRender();
304:            }
305:
306:            public void setUsePatternMarkupToRender(boolean value) {
307:                tableMgr.setUsePatternMarkupToRender(value);
308:            }
309:
310:            public void setEnabled(boolean b) {
311:                this .enabled = b;
312:            }
313:
314:            public boolean isEnabled() {
315:                return enabled;
316:            }
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.