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


001:        package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent;
002:
003:        import java.awt.GridBagConstraints;
004:        import java.awt.GridBagLayout;
005:        import java.awt.Insets;
006:        import java.text.NumberFormat;
007:
008:        import javax.swing.BorderFactory;
009:        import javax.swing.ButtonGroup;
010:        import javax.swing.JRadioButton;
011:
012:        import net.sourceforge.squirrel_sql.fw.gui.OkJPanel;
013:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
014:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
015:
016:        public class FloatingPointBase extends BaseDataTypeComponent {
017:            private static final StringManager s_stringMgr = StringManagerFactory
018:                    .getStringManager(FloatingPointBase.class);
019:
020:            // flag for whether we have already loaded the properties or not
021:            private static boolean propertiesAlreadyLoaded = false;
022:
023:            // flag for whether to use the default Java format (true)
024:            // or the Locale-dependent format (false)
025:            protected static boolean useJavaDefaultFormat = false;
026:
027:            /**
028:             * Generate a JPanel containing controls that allow the user
029:             * to adjust the properties for this DataType.
030:             * All properties are static accross all instances of this DataType.
031:             * However, the class may choose to apply the information differentially,
032:             * such as keeping a list (also entered by the user) of table/column names
033:             * for which certain properties should be used.
034:             * <P>
035:             * This is called ONLY if there is at least one property entered into the DTProperties
036:             * for this class.
037:             * <P>
038:             * Since this method is called by reflection on the Method object derived from this class,
039:             * it does not need to be included in the Interface.
040:             * It would be nice to include this in the Interface for consistancy, documentation, etc,
041:             * but the Interface does not seem to like static methods.
042:             */
043:            public static OkJPanel getControlPanel() {
044:
045:                /*
046:                 * If you add this method to one of the standard DataTypes in the
047:                 * fw/datasetviewer/cellcomponent directory, you must also add the name
048:                 * of that DataType class to the list in CellComponentFactory, method
049:                 * getControlPanels, variable named initialClassNameList.
050:                 * If the class is being registered with the factory using registerDataType,
051:                 * then you should not include the class name in the list (it will be found
052:                 * automatically), but if the DataType is part of the case statement in the
053:                 * factory method getDataTypeObject, then it does need to be explicitly listed
054:                 * in the getControlPanels method also.
055:                 */
056:
057:                // if this panel is called before any instances of the class have been
058:                // created, we need to load the properties from the DTProperties.
059:                loadProperties();
060:
061:                return new FloatingPointOkJPanel();
062:            }
063:
064:            public FloatingPointBase() {
065:                loadProperties();
066:            }
067:
068:            private static void loadProperties() {
069:
070:                //set the property values
071:                // Note: this may have already been done by another instance of
072:                // this DataType created to handle a different column.
073:                if (propertiesAlreadyLoaded == false) {
074:                    // get parameters previously set by user, or set default values
075:                    useJavaDefaultFormat = false; // set to use the Java default
076:                    String useJavaDefaultFormatString = DTProperties.get(
077:                            DataTypeBigDecimal.class.getName(),
078:                            "useJavaDefaultFormat");
079:
080:                    if (useJavaDefaultFormatString != null
081:                            && useJavaDefaultFormatString.equals("true")) {
082:                        useJavaDefaultFormat = true;
083:                    }
084:                }
085:            }
086:
087:            /**
088:             * Inner class that extends OkJPanel so that we can call the ok()
089:             * method to save the data when the user is happy with it.
090:             */
091:            private static class FloatingPointOkJPanel extends OkJPanel {
092:                private static final long serialVersionUID = 3745853322636427759L;
093:
094:                JRadioButton optUseDefaultFormat;
095:                JRadioButton optUseLocaleDependendFormat;
096:
097:                public FloatingPointOkJPanel() {
098:                    NumberFormat numberFormat = NumberFormat.getInstance();
099:                    numberFormat.setMaximumFractionDigits(5);
100:
101:                    optUseDefaultFormat = new JRadioButton(s_stringMgr
102:                            .getString("floatingPointBase.useDefaultFormat",
103:                                    new Double(3.14159).toString()));
104:                    optUseLocaleDependendFormat = new JRadioButton(
105:                            s_stringMgr
106:                                    .getString(
107:                                            "floatingPointBase.uselocaleDependendFormat",
108:                                            numberFormat.format(new Double(
109:                                                    3.14159))));
110:
111:                    setBorder(BorderFactory.createTitledBorder(s_stringMgr
112:                            .getString("floatingPointBase.typeBigDecimal")));
113:
114:                    setLayout(new GridBagLayout());
115:
116:                    GridBagConstraints gbc;
117:                    gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0,
118:                            GridBagConstraints.NORTHWEST,
119:                            GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4,
120:                                    4), 0, 0);
121:                    add(optUseLocaleDependendFormat, gbc);
122:                    gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0,
123:                            GridBagConstraints.NORTHWEST,
124:                            GridBagConstraints.HORIZONTAL, new Insets(0, 4, 4,
125:                                    4), 0, 0);
126:                    add(optUseDefaultFormat, gbc);
127:
128:                    ButtonGroup bg = new ButtonGroup();
129:                    bg.add(optUseDefaultFormat);
130:                    bg.add(optUseLocaleDependendFormat);
131:
132:                    optUseLocaleDependendFormat
133:                            .setSelected(!useJavaDefaultFormat);
134:                    optUseDefaultFormat.setSelected(useJavaDefaultFormat);
135:                }
136:
137:                /**
138:                 * User has clicked OK in the surrounding JPanel,
139:                 * so save the current state of all variables
140:                 */
141:                public void ok() {
142:                    // get the values from the controls and set them in the static properties
143:                    useJavaDefaultFormat = optUseDefaultFormat.isSelected();
144:                    DTProperties.put(DataTypeBigDecimal.class.getName(),
145:                            "useJavaDefaultFormat", Boolean.valueOf(
146:                                    useJavaDefaultFormat).toString());
147:                }
148:            } // end of inner class
149:
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.