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


001:        package net.sourceforge.squirrel_sql.plugins.codecompletion.prefs;
002:
003:        import net.sourceforge.squirrel_sql.client.IApplication;
004:        import net.sourceforge.squirrel_sql.client.preferences.INewSessionPropertiesPanel;
005:        import net.sourceforge.squirrel_sql.client.session.ISession;
006:        import net.sourceforge.squirrel_sql.client.session.properties.ISessionPropertiesPanel;
007:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
008:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
009:
010:        import javax.swing.table.TableColumn;
011:        import javax.swing.table.TableCellEditor;
012:        import javax.swing.*;
013:        import java.awt.*;
014:        import java.awt.event.ActionListener;
015:        import java.awt.event.ActionEvent;
016:
017:        public class CodeCompletionPreferencesController implements 
018:                INewSessionPropertiesPanel, ISessionPropertiesPanel {
019:            private static final StringManager s_stringMgr = StringManagerFactory
020:                    .getStringManager(CodeCompletionPreferencesController.class);
021:
022:            private CodeCompletionPreferences _prefs;
023:
024:            private CodeCompletionPreferencesPanel _panel;
025:
026:            public CodeCompletionPreferencesController(
027:                    CodeCompletionPreferences prefs) {
028:                _panel = new CodeCompletionPreferencesPanel();
029:                _prefs = prefs;
030:
031:                switch (_prefs.getGeneralCompletionConfig()) {
032:                case CodeCompletionPreferences.CONFIG_SP_WITH_PARARMS:
033:                    _panel.optSPWithParams.setSelected(true);
034:                    break;
035:                case CodeCompletionPreferences.CONFIG_SP_WITHOUT_PARARMS:
036:                    _panel.optSPWithoutParams.setSelected(true);
037:                    break;
038:                case CodeCompletionPreferences.CONFIG_UDF_WITH_PARARMS:
039:                    _panel.optUDFWithParams.setSelected(true);
040:                    break;
041:                case CodeCompletionPreferences.CONFIG_UDF_WITHOUT_PARARMS:
042:                    _panel.optUDFWithoutParams.setSelected(true);
043:                    break;
044:                }
045:
046:                PrefixesTableModel tm = new PrefixesTableModel(_prefs
047:                        .getPrefixedConfigs());
048:                _panel.tblPrefixes.setModel(tm);
049:
050:                TableColumn tcPrefix = new TableColumn();
051:                // i18n[codecompletion.prefs.table.col.prefix=Prefix]
052:                tcPrefix.setHeaderValue(s_stringMgr
053:                        .getString("codecompletion.prefs.table.col.prefix"));
054:                tcPrefix.setModelIndex(0);
055:                _panel.tblPrefixes.addColumn(tcPrefix);
056:
057:                TableColumn tcCompletionConfig = new TableColumn();
058:                // i18n[codecompletion.prefs.table.col.config=Configuration]
059:                tcCompletionConfig.setHeaderValue(s_stringMgr
060:                        .getString("codecompletion.prefs.table.col.config"));
061:
062:                JComboBox cboConfigs = new JComboBox(ConfigCboItem.items);
063:                cboConfigs.setSelectedIndex(0);
064:                tcCompletionConfig.setCellEditor(new DefaultCellEditor(
065:                        cboConfigs));
066:                tcCompletionConfig.setModelIndex(1);
067:                _panel.tblPrefixes.addColumn(tcCompletionConfig);
068:
069:                _panel.txtMaxLastSelectedCompletionNamesPanel.setText(""
070:                        + _prefs.getMaxLastSelectedCompletionNames());
071:
072:                _panel.btnNewRow.addActionListener(new ActionListener() {
073:                    public void actionPerformed(ActionEvent e) {
074:                        onAddRow();
075:                    }
076:                });
077:
078:                _panel.btnDeleteRows.addActionListener(new ActionListener() {
079:                    public void actionPerformed(ActionEvent e) {
080:                        onDeleteRows();
081:                    }
082:                });
083:            }
084:
085:            private void onDeleteRows() {
086:                stopEditing();
087:                PrefixesTableModel tm = (PrefixesTableModel) _panel.tblPrefixes
088:                        .getModel();
089:                int[] selRows = _panel.tblPrefixes.getSelectedRows();
090:                tm.removeRows(selRows);
091:            }
092:
093:            private void onAddRow() {
094:                PrefixesTableModel tm = (PrefixesTableModel) _panel.tblPrefixes
095:                        .getModel();
096:                tm.addNewConfig();
097:            }
098:
099:            public void initialize(IApplication app) {
100:            }
101:
102:            public void initialize(IApplication app, ISession session) {
103:            }
104:
105:            /**
106:             * Return the component to be displayed in the Preferences dialog.
107:             *
108:             * @return	the component to be displayed in the Preferences dialog.
109:             */
110:            public Component getPanelComponent() {
111:                return _panel;
112:            }
113:
114:            /**
115:             * User has pressed OK or Apply in the dialog so save data from
116:             * panel.
117:             */
118:            public void applyChanges() {
119:
120:                if (_panel.optSPWithParams.isSelected()) {
121:                    _prefs
122:                            .setGeneralCompletionConfig(CodeCompletionPreferences.CONFIG_SP_WITH_PARARMS);
123:                } else if (_panel.optSPWithoutParams.isSelected()) {
124:                    _prefs
125:                            .setGeneralCompletionConfig(CodeCompletionPreferences.CONFIG_SP_WITHOUT_PARARMS);
126:                } else if (_panel.optUDFWithParams.isSelected()) {
127:                    _prefs
128:                            .setGeneralCompletionConfig(CodeCompletionPreferences.CONFIG_UDF_WITH_PARARMS);
129:                } else if (_panel.optUDFWithoutParams.isSelected()) {
130:                    _prefs
131:                            .setGeneralCompletionConfig(CodeCompletionPreferences.CONFIG_UDF_WITHOUT_PARARMS);
132:                } else {
133:                    throw new IllegalStateException("No valid config selected");
134:                }
135:
136:                stopEditing();
137:
138:                PrefixesTableModel tm = (PrefixesTableModel) _panel.tblPrefixes
139:                        .getModel();
140:
141:                _prefs.setPrefixedConfigs(tm.getData());
142:
143:                try {
144:                    _prefs
145:                            .setMaxLastSelectedCompletionNames(Math
146:                                    .max(
147:                                            0,
148:                                            Integer
149:                                                    .parseInt(_panel.txtMaxLastSelectedCompletionNamesPanel
150:                                                            .getText())));
151:                } catch (NumberFormatException e) {
152:
153:                }
154:
155:            }
156:
157:            private void stopEditing() {
158:                TableCellEditor cellEditor = _panel.tblPrefixes.getCellEditor();
159:                if (null != cellEditor) {
160:                    cellEditor.stopCellEditing();
161:                }
162:            }
163:
164:            /**
165:             * Return the title for this panel.
166:             *
167:             * @return	the title for this panel.
168:             */
169:            public String getTitle() {
170:                // i18n[codeCompletion.PrefsTabTitle=Code Completion]
171:                return s_stringMgr.getString("codeCompletion.PrefsTabTitle");
172:            }
173:
174:            /**
175:             * Return the hint for this panel.
176:             *
177:             * @return	the hint for this panel.
178:             */
179:            public String getHint() {
180:                // i18n[codeCompletion.PrefsTabTitleHint=Configure Code Completion]
181:                return s_stringMgr
182:                        .getString("codeCompletion.PrefsTabTitleHint");
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.