Source Code Cross Referenced for DetailPanel.java in  » J2EE » Sofia » com » salmonllc » examples » example15 » 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 » J2EE » Sofia » com.salmonllc.examples.example15 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.examples.example15;
002:
003:        //The Salmon Open Framework for Internet Applications (SOFIA)
004:        //Copyright (C) 1999 - 2002, Salmon LLC
005:        //
006:        //This program is free software; you can redistribute it and/or
007:        //modify it under the terms of the GNU General Public License version 2
008:        //as published by the Free Software Foundation;
009:        //
010:        //This program is distributed in the hope that it will be useful,
011:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
012:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:        //GNU General Public License for more details.
014:        //
015:        //You should have received a copy of the GNU General Public License
016:        //along with this program; if not, write to the Free Software
017:        //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:        //
019:        //For more information please visit http://www.salmonllc.com
020:
021:        import com.salmonllc.sql.*;
022:        import com.salmonllc.swing.*;
023:
024:        import javax.swing.*;
025:        import java.awt.*;
026:        import java.util.Hashtable;
027:        import java.util.Enumeration;
028:
029:        /**
030:         * The panel with the detail data for each row.
031:         */
032:
033:        public class DetailPanel extends JPanel {
034:
035:            private Dimension _capSize = new Dimension(100, 25);
036:            private Dimension _fieldSize = new Dimension(200, 25);
037:            private Icon _errorIcon;
038:            private JComponent _firstField;
039:            private Hashtable _components = new Hashtable();
040:            MainPanel _mainPan;
041:
042:            public class LocalTextField extends STextField {
043:                boolean _skinEnabled = true;
044:
045:                public boolean isSkinEnabled() {
046:                    return _skinEnabled;
047:                }
048:
049:                public void setSkinEnabled(boolean skinEnabled) {
050:                    _skinEnabled = skinEnabled;
051:                }
052:            }
053:
054:            public DetailPanel(DataStoreProxy ds, Icon errorIcon, MainPanel pan) {
055:                _mainPan = pan;
056:
057:                //create the GUI
058:                try {
059:                    _errorIcon = errorIcon;
060:
061:                    setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
062:                    JPanel p = new JPanel();
063:                    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
064:                    p.add(Box.createRigidArea(new Dimension(0, 10)));
065:                    addFieldToGrid(p, ds, "contact.first_name", "First Name");
066:                    addFieldToGrid(p, ds, "contact.last_name", "Last Name");
067:                    addFieldToGrid(p, ds, "contact.email_address",
068:                            "Email Address");
069:                    addFieldToGrid(p, ds, "contact.address", "Street Address");
070:                    addFieldToGrid(p, ds, "contact.city", "City");
071:                    addFieldToGrid(p, ds, "contact.state", "State");
072:                    addFieldToGrid(p, ds, "contact.zip", "Zip");
073:                    addFieldToGrid(p, ds, "contact.main_phone", "Main Phone");
074:                    addFieldToGrid(p, ds, "contact.alt_phone",
075:                            "Alternate Phone");
076:                    addFieldToGrid(p, ds, "contact.cell_phone", "Cell Phone");
077:
078:                    p.add(Box.createRigidArea(new Dimension(300, 10)));
079:
080:                    SErrorList l = new SErrorList();
081:                    l.setDataStoreAndPanel(ds, p);
082:                    Box b = Box.createHorizontalBox();
083:                    l.setPreferredSize(new Dimension(300, 50));
084:                    l.setMaximumSize(new Dimension(300, 50));
085:                    b.add(l);
086:                    p.add(b);
087:
088:                    p.add(Box.createRigidArea(new Dimension(0, 10)));
089:                    add(new JScrollPane(p));
090:
091:                } catch (Exception e) {
092:                    e.printStackTrace();
093:                }
094:            }
095:
096:            /**
097:             * It's a bit of work to add a new field for editing so we have a method that does it
098:             */
099:            private void addFieldToGrid(JPanel p, DataStoreProxy ds,
100:                    String column, String caption) {
101:                SLabel l = new SLabel(caption);
102:                l.addValidateColumn(ds, column, _errorIcon);
103:                l.setMaximumSize(_capSize);
104:                l.setMinimumSize(_capSize);
105:                l.setName("detailCap." + column);
106:
107:                STextField f = new LocalTextField();
108:                f.setColumn(ds, column);
109:                f.setMaximumSize(_fieldSize);
110:                f.setMinimumSize(_fieldSize);
111:                f.setName("detailField." + column);
112:
113:                Box b = Box.createHorizontalBox();
114:                b.add(l);
115:                b.add(f);
116:                p.add(b);
117:
118:                _components.put(column, f);
119:                if (_firstField == null)
120:                    _firstField = f;
121:                f.addKeyListener(_mainPan.getKeyHandler());
122:            }
123:
124:            /**
125:             * return the list of edit fields in the panel
126:             */
127:            public Hashtable getFields() {
128:                return _components;
129:            }
130:
131:            /**
132:             * Sets focus to the first field in the panel
133:             */
134:            public void grabFocus() {
135:                _firstField.grabFocus();
136:            }
137:
138:            /**
139:             * Sets all the text fields in the panel to enabled or not
140:             */
141:            public void setEnabled(boolean enabled) {
142:        if (enabled != isEnabled()) {
143:            super.setEnabled(enabled);
144:            Enumeration enum = _components.elements();
145:            while (enum.hasMoreElements()) {
146:                 Component comp = (JComponent)enum.nextElement();
147:                 if (comp instanceof LocalTextField && enabled)
148:                     comp.setEnabled(((LocalTextField)comp).isSkinEnabled());
149:                 else
150:                     comp.setEnabled(enabled);
151:            }
152:        }
153:
154:    }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.