Source Code Cross Referenced for InformationJDialog.java in  » 6.0-JDK-Modules » java-3d » com » db » server » 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 » 6.0 JDK Modules » java 3d » com.db.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 Silvere Martin-Michiellot All Rights Reserved.
003:         *
004:         * Silvere Martin-Michiellot grants you ("Licensee") a non-exclusive,
005:         * royalty free, license to use, modify and redistribute this
006:         * software in source and binary code form,
007:         * provided that i) this copyright notice and license appear on all copies of
008:         * the software; and ii) Licensee does not utilize the software in a manner
009:         * which is disparaging to Silvere Martin-Michiellot.
010:         *
011:         * This software is provided "AS IS," without a warranty of any kind. ALL
012:         * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
013:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
014:         * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. Silvere Martin-Michiellot
015:         * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
016:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
017:         * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
018:         * Silvere Martin-Michiellot OR ITS LICENSORS BE LIABLE
019:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
020:         * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
021:         * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
022:         * OR INABILITY TO USE SOFTWARE, EVEN IF Silvere Martin-Michiellot HAS BEEN
023:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
024:         *
025:         * This software is not designed or intended for use in on-line control of
026:         * aircraft, air traffic, aircraft navigation or aircraft communications; or in
027:         * the design, construction, operation or maintenance of any nuclear
028:         * facility. Licensee represents and warrants that it will not use or
029:         * redistribute the Software for such purposes.
030:         *
031:         * @Author: Silvere Martin-Michiellot
032:         *
033:         */
034:
035:        package com.db.server;
036:
037:        import java.awt.*;
038:        import java.awt.event.*;
039:        import java.util.*;
040:        import javax.swing.*;
041:        import javax.swing.table.*;
042:
043:        public class InformationJDialog extends JDialog implements 
044:                ActionListener {
045:
046:            private DigitalBiosphereServer parent;
047:
048:            private Hashtable information;
049:            private JPanel jPanel3;
050:            private JLabel jLabel7;
051:            private JPanel jPanel4;
052:            private JTable jTable1;
053:            private InformationTableModel informationTableModel;
054:            private JScrollPane jScrollPane;
055:            private JPanel jPanel5;
056:            private JButton jButton3;
057:            private JButton jButton4;
058:
059:            public InformationJDialog(DigitalBiosphereServer parent,
060:                    Hashtable information, ResourceBundle resourceBundle) {
061:
062:                super (parent);
063:
064:                this .information = information;
065:
066:                jPanel3 = new JPanel();
067:                jLabel7 = new JLabel();
068:                jPanel4 = new JPanel();
069:                jTable1 = new JTable();
070:                jPanel5 = new JPanel();
071:                jButton3 = new JButton();
072:                jButton4 = new JButton();
073:
074:                this .getContentPane().setLayout(new FlowLayout());
075:
076:                this .setName(resourceBundle
077:                        .getString("Add, change or remove some information"));
078:                this .setModal(true);
079:                this .setTitle(resourceBundle
080:                        .getString("Add, change or remove some information"));
081:                this .setResizable(false);
082:
083:                /* The following code is to close the windows. */
084:
085:                this .addWindowListener(new WindowAdapter() {
086:
087:                    public void windowClosing(WindowEvent e) {
088:
089:                        setVisible(false);
090:                        dispose();
091:
092:                    }
093:
094:                });
095:
096:                this .addWindowListener(new WindowAdapter() {
097:
098:                    public void windowIconified(WindowEvent e) {
099:
100:                        setVisible(false);
101:                        dispose();
102:
103:                    }
104:
105:                });
106:
107:                jPanel3.setPreferredSize(new Dimension(250, 30));
108:                jPanel3.setMinimumSize(new Dimension(250, 30));
109:                jPanel3.setMaximumSize(new Dimension(250, 30));
110:
111:                jLabel7
112:                        .setText(resourceBundle
113:                                .getString("Please add, change or remove some information:"));
114:                jPanel3.add(jLabel7);
115:
116:                this .getContentPane().add(jPanel3);
117:
118:                informationTableModel = new InformationTableModel(
119:                        this .information, resourceBundle);
120:
121:                jTable1 = new JTable(informationTableModel);
122:
123:                jScrollPane = new JScrollPane();
124:                jScrollPane.add(jTable1);
125:                jPanel4.add(jScrollPane);
126:
127:                this .getContentPane().add(jPanel4);
128:
129:                jPanel4.setPreferredSize(new Dimension(250, 150));
130:                jPanel4.setMinimumSize(new Dimension(250, 150));
131:                jPanel4.setMaximumSize(new Dimension(250, 150));
132:
133:                jTable1.setPreferredSize(new Dimension(250, 128));
134:
135:                jPanel5.setPreferredSize(new Dimension(250, 40));
136:                jPanel5.setMinimumSize(new Dimension(250, 40));
137:                jPanel5.setMaximumSize(new Dimension(250, 40));
138:
139:                jButton3.setText("OK");
140:                jButton3.setToolTipText(resourceBundle
141:                        .getString("OKToolTipText"));
142:                jButton3.getAccessibleContext().setAccessibleDescription(
143:                        resourceBundle.getString("OKAccessibleDescription"));
144:                jButton3.addActionListener(this );
145:                jPanel5.add(jButton3);
146:
147:                jButton4.setText("Cancel");
148:                jButton4.setToolTipText(resourceBundle
149:                        .getString("CancelToolTipText"));
150:                jButton4
151:                        .getAccessibleContext()
152:                        .setAccessibleDescription(
153:                                resourceBundle
154:                                        .getString("CancelAccessibleDescription"));
155:                jButton4.addActionListener(this );
156:                jPanel5.add(jButton4);
157:
158:                this .getContentPane().add(jPanel5);
159:
160:                this .pack();
161:
162:            }
163:
164:            public void actionPerformed(ActionEvent TheActionEvent) {
165:
166:                Object TheObject;
167:
168:                TheObject = TheActionEvent.getSource();
169:
170:                if (TheObject instanceof  JButton) {
171:                    if (TheObject == jButton3) {
172:                        this .TheOKCommand(informationTableModel
173:                                .getInformation());
174:                        this .TheCloseCommand();
175:                    } else if (TheObject == jButton4) {
176:                        this .TheCloseCommand();
177:                    }
178:
179:                }
180:
181:            }
182:
183:            private void TheOKCommand(Hashtable information) {
184:
185:                this .parent.setInformationJDialogResult(information);
186:
187:            }
188:
189:            private void TheCloseCommand() {
190:
191:                this .setVisible(false);
192:                this .dispose();
193:
194:            }
195:
196:            private class InformationTableModel extends AbstractTableModel {
197:
198:                private Vector keysVector;
199:                private Vector valuesVector;
200:                private ResourceBundle resourceBundle;
201:
202:                public InformationTableModel(Hashtable information,
203:                        ResourceBundle resourceBundle) {
204:
205:                    Vector keysVector;
206:                    Vector valuesVector;
207:
208:                    keysVector = new Vector();
209:                    valuesVector = new Vector();
210:
211:                    this .resourceBundle = resourceBundle;
212:
213:                    keysVector.add(UniverseServer.STRING_DATE);
214:                    keysVector.add(UniverseServer.STRING_CREATOR_NAME);
215:                    keysVector.add(UniverseServer.STRING_CREATOR_E_MAIL);
216:                    keysVector.add(UniverseServer.STRING_CREATOR_PUBLIC_KEY);
217:                    keysVector.add(UniverseServer.STRING_NAME);
218:                    keysVector.add(UniverseServer.STRING_VERSION);
219:
220:                    valuesVector.add(information
221:                            .get(UniverseServer.STRING_DATE));
222:                    valuesVector.add(information
223:                            .get(UniverseServer.STRING_CREATOR_NAME));
224:                    valuesVector.add(information
225:                            .get(UniverseServer.STRING_CREATOR_E_MAIL));
226:                    valuesVector.add(information
227:                            .get(UniverseServer.STRING_CREATOR_PUBLIC_KEY));
228:                    valuesVector.add(information
229:                            .get(UniverseServer.STRING_NAME));
230:                    valuesVector.add(information
231:                            .get(UniverseServer.STRING_VERSION));
232:
233:                }
234:
235:                public int getColumnCount() {
236:                    return 2;
237:                }
238:
239:                public int getRowCount() {
240:                    return keysVector.size() + 1;
241:                }
242:
243:                public String getColumnName(int col) {
244:                    if (col == 0) {
245:                        return new String(resourceBundle.getString("Field"));
246:                    } else {
247:                        if (col == 1) {
248:                            return new String(resourceBundle
249:                                    .getString("Field Value"));
250:                        } else
251:                            return null;
252:                    }
253:
254:                }
255:
256:                public Object getValueAt(int row, int col) {
257:
258:                    if (row < keysVector.size()) {
259:                        if (col == 0) {
260:                            return (String) keysVector.elementAt(row);
261:                        } else {
262:                            if (col == 1) {
263:                                return (String) valuesVector.elementAt(row);
264:                            } else {
265:                                return null;
266:                            }
267:                        }
268:                    } else {
269:                        if (row == keysVector.size()) {
270:                            if ((col == 0) || (col == 1)) {
271:                                return new String("");
272:                            } else {
273:                                return null;
274:                            }
275:                        } else {
276:                            return null;
277:                        }
278:                    }
279:                }
280:
281:                public Class getColumnClass(int c) {
282:                    return java.lang.String.class;
283:                }
284:
285:                public boolean isCellEditable(int row, int col) {
286:                    //there are 6 default fields
287:                    if ((col == 0) && (row < 5)) {
288:                        return false;
289:                    } else {
290:                        return true;
291:                    }
292:                }
293:
294:                //to be used once when the table is validated
295:                public Hashtable getInformation() {
296:
297:                    Hashtable hashtable;
298:                    int i;
299:
300:                    hashtable = new Hashtable();
301:                    //6 first lines should be ok
302:                    for (i = 0; i < 6; i++) {
303:                        hashtable.put(keysVector.get(i), valuesVector.get(i));
304:                    }
305:                    //next lines validated only if with a key
306:                    //keyvalue may be empty string
307:                    //i=6;
308:                    while (i < (keysVector.size() - 6)) {
309:                        if (((String) keysVector.get(i)).length() > 0) {
310:                            hashtable.put(keysVector.get(i), valuesVector
311:                                    .get(i));
312:                        }
313:                    }
314:
315:                    return hashtable;
316:
317:                }
318:
319:                public void setValueAt(Object value, int row, int col) {
320:
321:                    if ((row < 6) && (col == 1)) {
322:                        valuesVector.setElementAt((String) value, row);
323:                    }
324:
325:                    if ((row > 5) && (row < valuesVector.size())
326:                            && ((col == 0) || (col == 1))) {
327:                        if (col == 0) {
328:                            if (((String) valuesVector.get(row)).length() == 0) {
329:                                if (((String) valuesVector.get(row)).length() == 0) {
330:                                    keysVector.removeElementAt(row);
331:                                    valuesVector.removeElementAt(row);
332:                                    fireTableRowsDeleted(row, row);
333:                                } else {
334:                                    keysVector
335:                                            .setElementAt((String) value, row);
336:                                    fireTableCellUpdated(row, col);
337:                                }
338:                            } else {
339:                                keysVector.setElementAt((String) value, row);
340:                                fireTableCellUpdated(row, col);
341:                            }
342:                        } else {
343:                            //col=1
344:                            if (((String) keysVector.get(row)).length() == 0) {
345:                                if (((String) keysVector.get(row)).length() == 0) {
346:                                    keysVector.removeElementAt(row);
347:                                    valuesVector.removeElementAt(row);
348:                                    fireTableRowsDeleted(row, row);
349:                                } else {
350:                                    valuesVector.setElementAt((String) value,
351:                                            row);
352:                                    fireTableCellUpdated(row, col);
353:                                }
354:                            } else {
355:                                valuesVector.setElementAt((String) value, row);
356:                                fireTableCellUpdated(row, col);
357:                            }
358:                        }
359:                    }
360:
361:                    if ((row == keysVector.size())
362:                            && ((col == 0) || (col == 1))) {
363:                        if (col == 0) {
364:                            if (((String) keysVector.get(row)).length() == 0) {
365:                                //shouldn't happen
366:                                fireTableRowsDeleted(row, row);
367:                            } else {
368:                                keysVector.add((String) value);
369:                                valuesVector.add(new String(""));
370:                                //fireTableCellUpdated(row, col);
371:                                fireTableRowsInserted(row + 1, row + 1);
372:                            }
373:                        } else {
374:                            //col=1
375:                            if (((String) valuesVector.get(row)).length() == 0) {
376:                                //shouldn't happen
377:                                fireTableRowsDeleted(row, row);
378:                            } else {
379:                                keysVector.add(new String(""));
380:                                valuesVector.add((String) value);
381:                                //fireTableCellUpdated(row, col);
382:                                fireTableRowsInserted(row + 1, row + 1);
383:                            }
384:                        }
385:                    }
386:                }
387:
388:            }
389:
390:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.