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


001:        package net.sourceforge.squirrel_sql.client.preferences;
002:
003:        /*
004:         * Copyright (C) 2002-2003 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.awt.Component;
022:        import java.awt.GridBagConstraints;
023:        import java.awt.GridBagLayout;
024:        import java.awt.Insets;
025:        import java.awt.event.ActionEvent;
026:        import java.awt.event.ActionListener;
027:
028:        import javax.swing.BorderFactory;
029:        import javax.swing.JCheckBox;
030:        import javax.swing.JLabel;
031:        import javax.swing.JPanel;
032:        import javax.swing.JPasswordField;
033:        import javax.swing.JTextField;
034:
035:        import net.sourceforge.squirrel_sql.client.IApplication;
036:        import net.sourceforge.squirrel_sql.fw.gui.MultipleLineLabel;
037:        import net.sourceforge.squirrel_sql.fw.util.ProxySettings;
038:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
039:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
040:
041:        class ProxyPreferencesPanel implements  IGlobalPreferencesPanel {
042:            /** Internationalized strings for this class. */
043:            private static final StringManager s_stringMgr = StringManagerFactory
044:                    .getStringManager(ProxyPreferencesPanel.class);
045:
046:            /** Panel to be displayed in preferences dialog. */
047:            private MyPanel _myPanel;
048:
049:            /** Application API. */
050:            private IApplication _app;
051:
052:            /**
053:             * Default ctor.
054:             */
055:            public ProxyPreferencesPanel() {
056:                super ();
057:            }
058:
059:            public void initialize(IApplication app) {
060:                if (app == null) {
061:                    throw new IllegalArgumentException(
062:                            "Null IApplication passed");
063:                }
064:
065:                _app = app;
066:
067:                ((MyPanel) getPanelComponent()).loadData(_app, _app
068:                        .getSquirrelPreferences());
069:            }
070:
071:            public void uninitialize(IApplication app) {
072:
073:            }
074:
075:            public synchronized Component getPanelComponent() {
076:                if (_myPanel == null) {
077:                    _myPanel = new MyPanel();
078:                }
079:                return _myPanel;
080:            }
081:
082:            public void applyChanges() {
083:                _myPanel.applyChanges(_app.getSquirrelPreferences());
084:            }
085:
086:            public String getTitle() {
087:                return s_stringMgr.getString("ProxyPreferencesPanel.title");
088:            }
089:
090:            public String getHint() {
091:                return s_stringMgr.getString("ProxyPreferencesPanel.hint");
092:            }
093:
094:            private static final class MyPanel extends JPanel {
095:                private JCheckBox _httpUseProxyChk = new JCheckBox(s_stringMgr
096:                        .getString("ProxyPreferencesPanel.useproxy"));
097:                private JTextField _httpProxyServer = new JTextField();
098:                private JTextField _httpProxyPort = new JTextField();
099:                private JTextField _httpNonProxyHosts = new JTextField();
100:                private JTextField _httpProxyUser = new JTextField();
101:                private JPasswordField _httpProxyPassword = new JPasswordField();
102:                private JCheckBox _socksUseProxyChk = new JCheckBox(s_stringMgr
103:                        .getString("ProxyPreferencesPanel.useproxy"));
104:                private JTextField _socksProxyServer = new JTextField();
105:                private JTextField _socksProxyPort = new JTextField();
106:
107:                MyPanel() {
108:                    super (new GridBagLayout());
109:                    createUserInterface();
110:                }
111:
112:                void loadData(IApplication app, SquirrelPreferences prefs) {
113:                    final ProxySettings proxySettings = prefs
114:                            .getProxySettings();
115:
116:                    _httpUseProxyChk.setSelected(proxySettings
117:                            .getHttpUseProxy());
118:                    _httpProxyServer
119:                            .setText(proxySettings.getHttpProxyServer());
120:                    _httpProxyPort.setText(proxySettings.getHttpProxyPort());
121:                    _httpNonProxyHosts.setText(proxySettings
122:                            .getHttpNonProxyHosts());
123:                    _httpProxyUser.setText(proxySettings.getHttpProxyUser());
124:                    _httpProxyPassword.setText(proxySettings
125:                            .getHttpProxyPassword());
126:
127:                    _socksUseProxyChk.setSelected(proxySettings
128:                            .getSocksUseProxy());
129:                    _socksProxyServer.setText(proxySettings
130:                            .getSocksProxyServer());
131:                    _socksProxyPort.setText(proxySettings.getSocksProxyPort());
132:
133:                    updateControlStatus();
134:                }
135:
136:                void applyChanges(SquirrelPreferences prefs) {
137:                    final ProxySettings proxySettings = new ProxySettings();
138:
139:                    proxySettings
140:                            .setHttpUseProxy(_httpUseProxyChk.isSelected());
141:                    proxySettings
142:                            .setHttpProxyServer(_httpProxyServer.getText());
143:                    proxySettings.setHttpProxyPort(_httpProxyPort.getText());
144:                    proxySettings.setHttpNonProxyHosts(_httpNonProxyHosts
145:                            .getText());
146:                    proxySettings.setHttpProxyUser(_httpProxyUser.getText());
147:
148:                    String password = new String(_httpProxyPassword
149:                            .getPassword());
150:                    proxySettings.setHttpProxyPassword(password);
151:
152:                    proxySettings.setSocksUseProxy(_socksUseProxyChk
153:                            .isSelected());
154:                    proxySettings.setSocksProxyServer(_socksProxyServer
155:                            .getText());
156:                    proxySettings.setSocksProxyPort(_socksProxyPort.getText());
157:
158:                    prefs.setProxySettings(proxySettings);
159:                }
160:
161:                private void updateControlStatus() {
162:                    final boolean http = _httpUseProxyChk.isSelected();
163:                    _httpProxyServer.setEnabled(http);
164:                    _httpProxyPort.setEnabled(http);
165:                    _httpNonProxyHosts.setEnabled(http);
166:                    _httpProxyUser.setEnabled(http);
167:                    _httpProxyPassword.setEnabled(http);
168:
169:                    final boolean socks = _socksUseProxyChk.isSelected();
170:                    _socksProxyServer.setEnabled(socks);
171:                    _socksProxyPort.setEnabled(socks);
172:                }
173:
174:                private void createUserInterface() {
175:                    final GridBagConstraints gbc = new GridBagConstraints();
176:                    gbc.fill = GridBagConstraints.HORIZONTAL;
177:                    gbc.insets = new Insets(4, 4, 4, 4);
178:                    gbc.gridx = 0;
179:                    gbc.gridy = 0;
180:                    gbc.weightx = 1;
181:                    add(createHTTPPanel(), gbc);
182:                    ++gbc.gridy;
183:                    add(createSOCKSPanel(), gbc);
184:
185:                    final ActionListener lis = new MyActionHandler();
186:                    _httpUseProxyChk.addActionListener(lis);
187:                    _socksUseProxyChk.addActionListener(lis);
188:                }
189:
190:                private JPanel createHTTPPanel() {
191:
192:                    JPanel pnl = new JPanel(new GridBagLayout());
193:                    pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
194:                            .getString("ProxyPreferencesPanel.httpproxy")));
195:
196:                    final GridBagConstraints gbc = new GridBagConstraints();
197:                    gbc.anchor = GridBagConstraints.WEST;
198:                    gbc.insets = new Insets(4, 4, 4, 4);
199:                    gbc.gridx = 0;
200:                    gbc.gridy = 0;
201:                    pnl.add(_httpUseProxyChk, gbc);
202:
203:                    gbc.fill = GridBagConstraints.HORIZONTAL;
204:                    ++gbc.gridx;
205:                    pnl.add(new JLabel(s_stringMgr
206:                            .getString("ProxyPreferencesPanel.server"),
207:                            JLabel.RIGHT), gbc);
208:
209:                    ++gbc.gridy;
210:                    pnl.add(new JLabel(s_stringMgr
211:                            .getString("ProxyPreferencesPanel.port"),
212:                            JLabel.RIGHT), gbc);
213:
214:                    ++gbc.gridy;
215:                    pnl.add(new JLabel(s_stringMgr
216:                            .getString("ProxyPreferencesPanel.user"),
217:                            JLabel.RIGHT), gbc);
218:
219:                    ++gbc.gridy;
220:                    pnl.add(new JLabel(s_stringMgr
221:                            .getString("ProxyPreferencesPanel.password"),
222:                            JLabel.RIGHT), gbc);
223:
224:                    ++gbc.gridy;
225:                    pnl.add(new JLabel(s_stringMgr
226:                            .getString("ProxyPreferencesPanel.noproxyfor"),
227:                            JLabel.RIGHT), gbc);
228:
229:                    ++gbc.gridy;
230:                    --gbc.gridx;
231:                    gbc.gridwidth = GridBagConstraints.REMAINDER;
232:                    pnl.add(new MultipleLineLabel(s_stringMgr
233:                            .getString("ProxyPreferencesPane.notes")), gbc);
234:                    gbc.gridwidth = 1;
235:                    ++gbc.gridx;
236:
237:                    ++gbc.gridx;
238:                    gbc.gridy = 0;
239:                    gbc.weightx = 1;
240:                    pnl.add(_httpProxyServer, gbc);
241:
242:                    ++gbc.gridy;
243:                    pnl.add(_httpProxyPort, gbc);
244:
245:                    ++gbc.gridy;
246:                    pnl.add(_httpProxyUser, gbc);
247:
248:                    ++gbc.gridy;
249:                    pnl.add(_httpProxyPassword, gbc);
250:
251:                    ++gbc.gridy;
252:                    pnl.add(_httpNonProxyHosts, gbc);
253:
254:                    return pnl;
255:                }
256:
257:                private JPanel createSOCKSPanel() {
258:                    JPanel pnl = new JPanel(new GridBagLayout());
259:                    pnl.setBorder(BorderFactory.createTitledBorder(s_stringMgr
260:                            .getString("ProxyPreferencesPanel.socksproxy")));
261:
262:                    final GridBagConstraints gbc = new GridBagConstraints();
263:                    gbc.anchor = GridBagConstraints.WEST;
264:                    gbc.insets = new Insets(4, 4, 4, 4);
265:                    gbc.gridx = 0;
266:                    gbc.gridy = 0;
267:                    pnl.add(_socksUseProxyChk, gbc);
268:
269:                    gbc.fill = GridBagConstraints.HORIZONTAL;
270:                    ++gbc.gridx;
271:                    pnl.add(new JLabel(s_stringMgr
272:                            .getString("ProxyPreferencesPanel.server"),
273:                            JLabel.RIGHT), gbc);
274:
275:                    ++gbc.gridy;
276:                    pnl.add(new JLabel(s_stringMgr
277:                            .getString("ProxyPreferencesPanel.port"),
278:                            JLabel.RIGHT), gbc);
279:
280:                    ++gbc.gridx;
281:                    gbc.gridy = 0;
282:                    gbc.weightx = 1;
283:                    pnl.add(_socksProxyServer, gbc);
284:
285:                    ++gbc.gridy;
286:                    pnl.add(_socksProxyPort, gbc);
287:
288:                    return pnl;
289:                }
290:
291:                private final class MyActionHandler implements  ActionListener {
292:                    public void actionPerformed(ActionEvent evt) {
293:                        updateControlStatus();
294:                    }
295:                }
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.