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


001:        package net.sourceforge.squirrel_sql.plugins.mysql.gui;
002:
003:        /*
004:         * Copyright (C) 2003 Arun Kapilan.P
005:         *
006:         * Modifications Copyright (C) 2003 Colin Bell
007:         * colbell@users.sourceforge.net
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2.1 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:         */
023:        import java.awt.event.ActionEvent;
024:        import java.awt.event.ActionListener;
025:        import java.sql.SQLException;
026:        import java.util.HashMap;
027:        import java.util.Map;
028:
029:        import javax.swing.JCheckBox;
030:        import javax.swing.JPanel;
031:        import javax.swing.JTextField;
032:
033:        import com.jgoodies.forms.layout.FormLayout;
034:
035:        import net.sourceforge.squirrel_sql.fw.gui.IntegerField;
036:        import net.sourceforge.squirrel_sql.fw.sql.DataTypeInfo;
037:        import net.sourceforge.squirrel_sql.fw.sql.ISQLConnection;
038:        import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
039:
040:        import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
041:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
042:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory; //import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
043:        //import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
044:
045:        import net.sourceforge.squirrel_sql.client.gui.builders.DefaultFormBuilder;
046:        import net.sourceforge.squirrel_sql.client.gui.controls.ColumnsComboBox;
047:        import net.sourceforge.squirrel_sql.client.gui.controls.DataTypesComboBox;
048:        import net.sourceforge.squirrel_sql.client.session.ISession;
049:
050:        /**
051:         * This builder creates the component that allows the user to alter the
052:         * structure of a column, add and remove columns.
053:         *
054:         * @author Arun Kapilan.P
055:         */
056:        class AlterColumnsPanelBuilder {
057:            /** Logger for this class. */
058:            //	private final static ILogger s_log =
059:            //		LoggerController.createLogger(AlterColumnsPanelBuilder.class);
060:            /** Internationalized strings for this class. */
061:            private static final StringManager s_stringMgr = StringManagerFactory
062:                    .getStringManager(AlterTablePanelBuilder.class);
063:
064:            /**
065:             * Stores <TT>DataTypeInfo</TT> objects represeniting the different
066:             * data types that MySQL supports keyed by an uppercase version of the
067:             * type name. We uppercase the type name as MySQL and/or its JDBC
068:             * drivers are inconsistent in the case of the data type names.
069:             */
070:            private Map<String, DataTypeInfo> _dataTypesByTypeName;
071:
072:            /**
073:             * Update the status of the GUI controls as the user makes changes.
074:             */
075:            private ControlMediator _mediator;
076:
077:            /** Combobox of the <TT>TableColumnInfo</TT> objects in the database. */
078:            private ColumnsComboBox _columnsCmb;
079:
080:            /** Combobox of the <TT>DataTypeInfo</TT> objects in the database. */
081:            private DataTypesComboBox _dataTypesCmb;
082:
083:            /** Column length. */
084:            private IntegerField _columnLengthField;
085:
086:            /** Default value. */
087:            private JTextField _defaultvalue;
088:
089:            /** Are nulls allowed for this column? */
090:            private JCheckBox _allowNullChk;
091:
092:            /** Is column an auto-increment column? */
093:            private JCheckBox _autoIncChk;
094:
095:            /** Is column unsigned? */
096:            private JCheckBox _unsignedChk;
097:
098:            /** Is column binary? */
099:            private JCheckBox _binaryChk;
100:
101:            /** Is column zero fill? */
102:            private JCheckBox _zeroFillChk;
103:
104:            AlterColumnsPanelBuilder() {
105:                super ();
106:            }
107:
108:            public JPanel buildPanel(ISession session, ITableInfo ti)
109:                    throws SQLException {
110:                initComponents(session, ti);
111:
112:                final FormLayout layout = new FormLayout(
113:                        "12dlu, left:max(40dlu;pref), 3dlu, 75dlu:grow(0.50), 7dlu, 75dlu:grow(0.50), 3dlu",
114:                        "");
115:                final DefaultFormBuilder builder = new DefaultFormBuilder(
116:                        layout);
117:                builder.setDefaultDialogBorder();
118:                builder.setLeadingColumnOffset(1);
119:
120:                builder
121:                        .appendSeparator(getString("AlterColumnsPanelBuilder.selectcolumn"));
122:                builder.append(
123:                        getString("AlterColumnsPanelBuilder.columnname"),
124:                        _columnsCmb, 3);
125:
126:                builder
127:                        .appendSeparator(getString("AlterColumnsPanelBuilder.attributes"));
128:                builder.append(getString("AlterColumnsPanelBuilder.datatype"),
129:                        _dataTypesCmb, 3);
130:
131:                builder.nextLine();
132:                builder.append(getString("AlterColumnsPanelBuilder.length"),
133:                        _columnLengthField, 3);
134:
135:                builder.nextLine();
136:                builder.append(getString("AlterColumnsPanelBuilder.default"),
137:                        _defaultvalue, 3);
138:
139:                builder.nextLine();
140:                builder.setLeadingColumnOffset(3);
141:                builder.append(_unsignedChk);
142:                builder.append(_autoIncChk);
143:
144:                builder.nextLine();
145:                builder.append(_binaryChk);
146:                builder.append(_zeroFillChk);
147:
148:                builder.nextLine();
149:                builder.append(_allowNullChk);
150:                builder.setLeadingColumnOffset(1);
151:
152:                return builder.getPanel();
153:            }
154:
155:            private static String getString(String stringMgrKey) {
156:                return s_stringMgr.getString(stringMgrKey);
157:            }
158:
159:            private void updateControlStatus() {
160:                final TableColumnInfo tci = _columnsCmb.getSelectedColumn();
161:                _dataTypesCmb.setSelectedItem(_dataTypesByTypeName.get(tci
162:                        .getTypeName().toUpperCase()));
163:
164:                _columnLengthField.setInt(tci.getColumnSize());
165:                _defaultvalue.setText(tci.getDefaultValue());
166:
167:                //		selectedIndex = cbFieldName.getSelectedIndex();
168:                //		DefaultComboBoxModel comboModel =
169:                //			(DefaultComboBoxModel) cbFieldName.getModel();
170:                //		FieldDetails fd = (FieldDetails) comboModel.getElementAt(selectedIndex);
171:                //
172:                //		cbFieldName.setSelectedItem(fd.getFieldName());
173:                //		cbFieldType.setSelectedItem(fd.getFieldType());
174:                //		tfFieldDefault.setText(fd.getDefault());
175:                //		chAutoIncrement.setSelected(fd.IsAutoIncrement());
176:                //		chNotNull.setSelected(fd.IsNotNull());
177:
178:                //		boolean isSelected = _exportPrefsChk.isSelected();
179:                //		_exportPrefsText.setEditable(isSelected);
180:                //		_exportPrefsBtn.setEnabled(isSelected);
181:                //
182:                //		isSelected = _exportDriversChk.isSelected();
183:                //		_exportDriversText.setEditable(isSelected);
184:                //		_exportDriversBtn.setEnabled(isSelected);
185:                //
186:                //		isSelected = _exportAliasesChk.isSelected();
187:                //		_exportAliasesText.setEditable(isSelected);
188:                //		_exportAliasesBtn.setEnabled(isSelected);
189:                //		_includeUserNamesChk.setEnabled(isSelected);
190:                //		_includePasswordsChk.setEnabled(isSelected);
191:            }
192:
193:            private void initComponents(ISession session, ITableInfo ti)
194:                    throws SQLException {
195:                _dataTypesByTypeName = new HashMap<String, DataTypeInfo>();
196:                _mediator = new ControlMediator();
197:
198:                final ISQLConnection conn = session.getSQLConnection();
199:
200:                _columnsCmb = new ColumnsComboBox(conn, ti);
201:
202:                _dataTypesCmb = new DataTypesComboBox(conn);
203:                for (int i = 0, limit = _dataTypesCmb.getItemCount(); i < limit; ++i) {
204:                    DataTypeInfo dti = _dataTypesCmb.getDataTypeAt(i);
205:                    _dataTypesByTypeName.put(dti.getSimpleName().toUpperCase(),
206:                            dti);
207:                }
208:
209:                _columnLengthField = new IntegerField();
210:                _defaultvalue = new JTextField();
211:                _allowNullChk = new JCheckBox(
212:                        getString("AlterColumnsPanelBuilder.allownull"));
213:                _unsignedChk = new JCheckBox(
214:                        getString("AlterColumnsPanelBuilder.unsigned"));
215:                _autoIncChk = new JCheckBox(
216:                        getString("AlterColumnsPanelBuilder.autoinc"));
217:                _binaryChk = new JCheckBox(
218:                        getString("AlterColumnsPanelBuilder.binary"));
219:                _zeroFillChk = new JCheckBox(
220:                        getString("AlterColumnsPanelBuilder.zerofill"));
221:
222:                //		final File here = new File(".");
223:                //
224:                //		final String export = getString("ExportPanel.export");
225:                //		_exportPrefsChk = new JCheckBox(export);
226:                //		_exportDriversChk = new JCheckBox(export);
227:                //		_exportAliasesChk = new JCheckBox(export);
228:                //
229:                //		_exportPrefsText = new JTextField();
230:                //		_exportDriversText = new JTextField();
231:                //		_exportAliasesText = new JTextField();
232:                //
233:                //		final String btnTitle = getString("ExportPanel.browse");
234:                //		_exportPrefsBtn = new JButton(btnTitle);
235:                //		_exportDriversBtn = new JButton(btnTitle);
236:                //		_exportAliasesBtn = new JButton(btnTitle);
237:                //
238:                ////		final ApplicationFiles appFiles = new ApplicationFiles();
239:                ////		_exportPrefsText.setText(getFileName(here, appFiles.getUserPreferencesFile().getName()));
240:                ////		_exportDriversText.setText(getFileName(here, appFiles.getDatabaseDriversFile().getName()));
241:                ////		_exportAliasesText.setText(getFileName(here, appFiles.getDatabaseAliasesFile().getName()));
242:                //
243:                //		_includeUserNamesChk = new JCheckBox(getString("ExportPanel.includeusers"));
244:                //		_includePasswordsChk = new JCheckBox(getString("ExportPanel.includepasswords"));
245:
246:                _columnsCmb.addActionListener(_mediator);
247:                //		_exportDriversChk.addActionListener(_mediator);
248:                //		_exportAliasesChk.addActionListener(_mediator);
249:                //
250:                //		_exportPrefsBtn.addActionListener(new BrowseButtonListener(_exportPrefsText));
251:                //		_exportDriversBtn.addActionListener(new BrowseButtonListener( _exportDriversText));
252:                //		_exportAliasesBtn.addActionListener(new BrowseButtonListener(_exportAliasesText));
253:                //
254:                //		_exportPrefsChk.setSelected(prefs.getExportPreferences());
255:                //		_exportDriversChk.setSelected(prefs.getExportDrivers());
256:                //		_exportAliasesChk.setSelected(prefs.getExportAliases());
257:                //
258:                //		_includeUserNamesChk.setSelected(prefs.getIncludeUserNames());
259:                //		_includePasswordsChk.setSelected(prefs.getIncludePasswords());
260:                //
261:                //		_exportPrefsText.setText(prefs.getPreferencesFileName());
262:                //		_exportDriversText.setText(prefs.getDriversFileName());
263:                //		_exportAliasesText.setText(prefs.getAliasesFileName());
264:
265:                updateControlStatus();
266:            }
267:
268:            /**
269:             * This class will update the status of the GUI controls as the user
270:             * makes changes.
271:             */
272:            private final class ControlMediator implements  ActionListener {
273:                public void actionPerformed(ActionEvent evt) {
274:                    updateControlStatus();
275:                }
276:            }
277:
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.