Source Code Cross Referenced for DataSetListModel.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » fw » datasetviewer » 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 » Database Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.fw.datasetviewer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.fw.datasetviewer;
002:
003:        /*
004:         * Copyright (C) 2001-2002 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.util.ArrayList;
022:        import java.util.List;
023:
024:        import javax.swing.event.EventListenerList;
025:
026:        /**
027:         * This is a <TT>IDataSetViewerDestination</TT> that doesn't
028:         * actually display the data, it simply stores it for future use.
029:         *
030:         * @author  <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
031:         */
032:        public class DataSetListModel extends BaseDataSetViewerDestination
033:                implements  IDataSetModel {
034:            /** Event types. */
035:            private interface IEventTypes {
036:                int ALL_ROWS_ADDED = 1;
037:                int MOVE_TO_TOP = 2;
038:            }
039:
040:            //??GETRIDOFTHIS
041:            public java.awt.Component getComponent() {
042:                return null;
043:            }
044:
045:            /**
046:             * Data. Each element is an array of objects. Each object is
047:             * the data for a column.
048:             */
049:            private List<Object[]> _data = new ArrayList<Object[]>();
050:
051:            /** Column headings. */
052:            //	private ColumnDisplayDefinition[] _hdgs = new ColumnDisplayDefinition[0];
053:            /** If <TT>true</TT> column headings should be shown. */
054:            //	private boolean _showHeadings;
055:            /** Listeners for this object. */
056:            private EventListenerList _listenerList = new EventListenerList();
057:
058:            /**
059:             * Clear the data.
060:             */
061:            public void clear() {
062:                _data.clear();
063:            }
064:
065:            /**
066:             * Add a row.
067:             *
068:             * @param	row		Array of objects specifying the row data.
069:             */
070:            protected void addRow(Object[] row) {
071:                _data.add(row);
072:            }
073:
074:            /**
075:             * Called once all rows have been added..
076:             */
077:            protected void allRowsAdded() {
078:                fireEvent(IEventTypes.ALL_ROWS_ADDED);
079:            }
080:
081:            /**
082:             * Indicates that the output display should scroll to the top.
083:             */
084:            public void moveToTop() {
085:                fireEvent(IEventTypes.MOVE_TO_TOP);
086:            }
087:
088:            /**
089:             * Return number of rows in model.
090:             *
091:             * @return	Number of rows.
092:             */
093:            public int getRowCount() {
094:                return _data.size();
095:            }
096:
097:            /**
098:             * Return the data value for the specified cell.
099:             *
100:             * @param	rowIndex	The row whose value is being retrieved.
101:             * @param	columnIndex	The column whose value is being retrieved.
102:             *
103:             * @return	the data value for the specified cell.
104:             */
105:            public Object getValueAt(int rowIndex, int columnIndex) {
106:                return (_data.get(rowIndex))[columnIndex];
107:            }
108:
109:            /**
110:             * Set the data value for the specified cell.
111:             *
112:             * @param	value		The new value for the cell.
113:             * @param	rowIndex	The row whose value is being set.
114:             * @param	columnIndex	The column whose value is being set.
115:             */
116:            public void setValueAt(Object value, int rowIndex, int columnIndex) {
117:                (_data.get(rowIndex))[columnIndex] = value;
118:            }
119:
120:            /**
121:             * Adds a listener for events in this model.
122:             *
123:             * @param	lis		<TT>DataSetModelListener</TT> that will be
124:             *					notified when events occur in this model.
125:             */
126:            public synchronized void addListener(IDataSetModelListener lis) {
127:                _listenerList.add(IDataSetModelListener.class, lis);
128:            }
129:
130:            /**
131:             * Removes an event listener fromthis model.
132:             *
133:             * @param	lis		<TT>DataSetModelListener</TT> to be removed.
134:             */
135:            public synchronized void removeListener(IDataSetModelListener lis) {
136:                _listenerList.remove(IDataSetModelListener.class, lis);
137:            }
138:
139:            /**
140:             * Fire a <TT>DataSetModel</TT> event.
141:             *
142:             * @param	eventType	Specifies the event type. @see IEventType.
143:             */
144:            protected void fireEvent(int eventType) {
145:                // Guaranteed to be non-null.
146:                Object[] listeners = _listenerList.getListenerList();
147:                // Process the listeners last to first, notifying
148:                // those that are interested in this event.
149:                DataSetModelEvent evt = null;
150:                for (int i = listeners.length - 2; i >= 0; i -= 2) {
151:                    if (listeners[i] == IDataSetModelListener.class) {
152:                        // Lazily create the event:
153:                        if (evt == null) {
154:                            evt = new DataSetModelEvent(this );
155:                        }
156:                        IDataSetModelListener lis = (IDataSetModelListener) listeners[i + 1];
157:                        switch (eventType) {
158:                        case IEventTypes.ALL_ROWS_ADDED: {
159:                            lis.allRowsAdded(evt);
160:                            break;
161:                        }
162:                        case IEventTypes.MOVE_TO_TOP: {
163:                            lis.moveToTop(evt);
164:                            break;
165:                        }
166:                        default: {
167:                            throw new IllegalArgumentException(
168:                                    "Invalid eventTypes passed: " + eventType);
169:                        }
170:                        }
171:                    }
172:                }
173:            }
174:
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.