Source Code Cross Referenced for SshToolsConnectionProtocolTab.java in  » Net » j2ssh » com » sshtools » common » ui » 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 » Net » j2ssh » com.sshtools.common.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  SSHTools - Java SSH2 API
003:         *
004:         *  Copyright (C) 2002-2003 Lee David Painter and Contributors.
005:         *
006:         *  Contributions made by:
007:         *
008:         *  Brett Smith
009:         *  Richard Pernavas
010:         *  Erwin Bolwidt
011:         *
012:         *  This program is free software; you can redistribute it and/or
013:         *  modify it under the terms of the GNU General Public License
014:         *  as published by the Free Software Foundation; either version 2
015:         *  of the License, or (at your option) any later version.
016:         *
017:         *  This program is distributed in the hope that it will be useful,
018:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020:         *  GNU General Public License for more details.
021:         *
022:         *  You should have received a copy of the GNU General Public License
023:         *  along with this program; if not, write to the Free Software
024:         *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
025:         */
026:        package com.sshtools.common.ui;
027:
028:        import com.sshtools.common.configuration.SshToolsConnectionProfile;
029:
030:        import com.sshtools.j2ssh.transport.cipher.SshCipherFactory;
031:        import com.sshtools.j2ssh.transport.compression.SshCompressionFactory;
032:        import com.sshtools.j2ssh.transport.hmac.SshHmacFactory;
033:        import com.sshtools.j2ssh.transport.kex.SshKeyExchangeFactory;
034:        import com.sshtools.j2ssh.transport.publickey.SshKeyPairFactory;
035:
036:        import java.awt.Component;
037:        import java.awt.GridBagConstraints;
038:        import java.awt.GridBagLayout;
039:        import java.awt.Insets;
040:
041:        import java.util.Iterator;
042:
043:        import javax.swing.BorderFactory;
044:        import javax.swing.Icon;
045:        import javax.swing.JComboBox;
046:        import javax.swing.JLabel;
047:        import javax.swing.JPanel;
048:        import javax.swing.JSeparator;
049:
050:        /**
051:         *
052:         *
053:         * @author $author$
054:         * @version $Revision: 1.15 $
055:         */
056:        public class SshToolsConnectionProtocolTab extends JPanel implements 
057:                SshToolsConnectionTab {
058:            final static String KEYS_ICON = "/com/sshtools/common/ui/largekeys.png";
059:            final static String PROTOCOL_ICON = "/com/sshtools/common/ui/largeprotocol.png";
060:            final static String DEFAULT = "<Default>";
061:
062:            //
063:
064:            /**  */
065:            protected JComboBox jComboCipherCS = new JComboBox();
066:
067:            /**  */
068:            protected JComboBox jComboCipherSC = new JComboBox();
069:
070:            /**  */
071:            protected JComboBox jComboMacCS = new JComboBox();
072:
073:            /**  */
074:            protected JComboBox jComboMacSC = new JComboBox();
075:
076:            /**  */
077:            protected JComboBox jComboCompCS = new JComboBox();
078:
079:            /**  */
080:            protected JComboBox jComboCompSC = new JComboBox();
081:
082:            /**  */
083:            protected JComboBox jComboKex = new JComboBox();
084:
085:            /**  */
086:            protected JComboBox jComboPK = new JComboBox();
087:
088:            /**  */
089:            protected SshToolsConnectionProfile profile;
090:
091:            /**
092:             * Creates a new SshToolsConnectionProtocolTab object.
093:             */
094:            public SshToolsConnectionProtocolTab() {
095:                super ();
096:
097:                //  Keys
098:                JPanel keysPanel = new JPanel(new GridBagLayout());
099:                GridBagConstraints gbc = new GridBagConstraints();
100:                gbc.fill = GridBagConstraints.NONE;
101:                gbc.anchor = GridBagConstraints.WEST;
102:                gbc.insets = new Insets(2, 2, 2, 2);
103:                gbc.weightx = 1.0;
104:
105:                //  Public key
106:                UIUtil.jGridBagAdd(keysPanel, new JLabel("Public key"), gbc,
107:                        GridBagConstraints.REMAINDER);
108:                gbc.fill = GridBagConstraints.HORIZONTAL;
109:                UIUtil.jGridBagAdd(keysPanel, jComboPK, gbc,
110:                        GridBagConstraints.REMAINDER);
111:                gbc.fill = GridBagConstraints.NONE;
112:
113:                //  Public key
114:                UIUtil.jGridBagAdd(keysPanel, new JLabel("Key exchange"), gbc,
115:                        GridBagConstraints.REMAINDER);
116:                gbc.fill = GridBagConstraints.HORIZONTAL;
117:                UIUtil.jGridBagAdd(keysPanel, jComboKex, gbc,
118:                        GridBagConstraints.REMAINDER);
119:                gbc.fill = GridBagConstraints.NONE;
120:
121:                //
122:                IconWrapperPanel iconKeysPanel = new IconWrapperPanel(
123:                        new ResourceIcon(KEYS_ICON), keysPanel);
124:
125:                //  Preferences
126:                JPanel prefPanel = new JPanel(new GridBagLayout());
127:                prefPanel
128:                        .setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
129:                gbc = new GridBagConstraints();
130:                gbc.fill = GridBagConstraints.NONE;
131:                gbc.anchor = GridBagConstraints.WEST;
132:                gbc.insets = new Insets(2, 2, 2, 2);
133:                gbc.weightx = 1.0;
134:
135:                //  Public key
136:                gbc.fill = GridBagConstraints.HORIZONTAL;
137:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Client - > Server"),
138:                        gbc, GridBagConstraints.RELATIVE);
139:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Server - > Client"),
140:                        gbc, GridBagConstraints.REMAINDER);
141:
142:                //  Separator
143:                gbc.weightx = 2.0;
144:                UIUtil.jGridBagAdd(prefPanel, new JSeparator(
145:                        JSeparator.HORIZONTAL), gbc,
146:                        GridBagConstraints.REMAINDER);
147:
148:                //  Cipher
149:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Cipher"), gbc,
150:                        GridBagConstraints.RELATIVE);
151:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Cipher"), gbc,
152:                        GridBagConstraints.REMAINDER);
153:                UIUtil.jGridBagAdd(prefPanel, jComboCipherCS, gbc,
154:                        GridBagConstraints.RELATIVE);
155:                UIUtil.jGridBagAdd(prefPanel, jComboCipherSC, gbc,
156:                        GridBagConstraints.REMAINDER);
157:
158:                //  Mac
159:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Mac"), gbc,
160:                        GridBagConstraints.RELATIVE);
161:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Mac"), gbc,
162:                        GridBagConstraints.REMAINDER);
163:                UIUtil.jGridBagAdd(prefPanel, jComboMacCS, gbc,
164:                        GridBagConstraints.RELATIVE);
165:                UIUtil.jGridBagAdd(prefPanel, jComboMacSC, gbc,
166:                        GridBagConstraints.REMAINDER);
167:
168:                //  Compression
169:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Compression"), gbc,
170:                        GridBagConstraints.RELATIVE);
171:                UIUtil.jGridBagAdd(prefPanel, new JLabel("Compression"), gbc,
172:                        GridBagConstraints.REMAINDER);
173:                UIUtil.jGridBagAdd(prefPanel, jComboCompCS, gbc,
174:                        GridBagConstraints.RELATIVE);
175:                UIUtil.jGridBagAdd(prefPanel, jComboCompSC, gbc,
176:                        GridBagConstraints.REMAINDER);
177:
178:                //
179:                IconWrapperPanel iconPrefPanel = new IconWrapperPanel(
180:                        new ResourceIcon(PROTOCOL_ICON), prefPanel);
181:
182:                //  This tab
183:                setLayout(new GridBagLayout());
184:                setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
185:                gbc = new GridBagConstraints();
186:                gbc.fill = GridBagConstraints.NONE;
187:                gbc.anchor = GridBagConstraints.WEST;
188:                gbc.insets = new Insets(2, 2, 2, 2);
189:                gbc.weightx = 1.0;
190:                UIUtil.jGridBagAdd(this , iconKeysPanel, gbc,
191:                        GridBagConstraints.REMAINDER);
192:                gbc.weighty = 1.0;
193:                UIUtil.jGridBagAdd(this , iconPrefPanel, gbc,
194:                        GridBagConstraints.REMAINDER);
195:
196:                //
197:                loadList(SshCipherFactory.getSupportedCiphers(),
198:                        jComboCipherCS, true);
199:                loadList(SshCipherFactory.getSupportedCiphers(),
200:                        jComboCipherSC, true);
201:                loadList(SshHmacFactory.getSupportedMacs(), jComboMacCS, true);
202:                loadList(SshHmacFactory.getSupportedMacs(), jComboMacSC, true);
203:                loadList(SshCompressionFactory.getSupportedCompression(),
204:                        jComboCompCS, true);
205:                loadList(SshCompressionFactory.getSupportedCompression(),
206:                        jComboCompSC, true);
207:                loadList(SshKeyExchangeFactory.getSupportedKeyExchanges(),
208:                        jComboKex, true);
209:                loadList(SshKeyPairFactory.getSupportedKeys(), jComboPK, true);
210:            }
211:
212:            /**
213:             *
214:             *
215:             * @param profile
216:             */
217:            public void setConnectionProfile(SshToolsConnectionProfile profile) {
218:                this .profile = profile;
219:                jComboCipherCS.setSelectedItem(profile.getPrefCSEncryption());
220:                jComboCipherSC.setSelectedItem(profile.getPrefSCEncryption());
221:                jComboMacCS.setSelectedItem(profile.getPrefCSMac());
222:                jComboMacSC.setSelectedItem(profile.getPrefSCMac());
223:                jComboCompCS.setSelectedItem(profile.getPrefCSComp());
224:                jComboCompSC.setSelectedItem(profile.getPrefSCComp());
225:                jComboKex.setSelectedItem(profile.getPrefKex());
226:                jComboPK.setSelectedItem(profile.getPrefPublicKey());
227:            }
228:
229:            /**
230:             *
231:             *
232:             * @return
233:             */
234:            public SshToolsConnectionProfile getConnectionProfile() {
235:                return profile;
236:            }
237:
238:            private void loadList(java.util.List list, JComboBox combo,
239:                    boolean addDefault) {
240:                Iterator it = list.iterator();
241:
242:                if (addDefault) {
243:                    combo.addItem(DEFAULT);
244:                }
245:
246:                while (it.hasNext()) {
247:                    combo.addItem(it.next());
248:                }
249:            }
250:
251:            /**
252:             *
253:             *
254:             * @return
255:             */
256:            public String getTabContext() {
257:                return "Connection";
258:            }
259:
260:            /**
261:             *
262:             *
263:             * @return
264:             */
265:            public Icon getTabIcon() {
266:                return null;
267:            }
268:
269:            /**
270:             *
271:             *
272:             * @return
273:             */
274:            public String getTabTitle() {
275:                return "Protocol";
276:            }
277:
278:            /**
279:             *
280:             *
281:             * @return
282:             */
283:            public String getTabToolTipText() {
284:                return "Protocol related properties.";
285:            }
286:
287:            /**
288:             *
289:             *
290:             * @return
291:             */
292:            public int getTabMnemonic() {
293:                return 'p';
294:            }
295:
296:            /**
297:             *
298:             *
299:             * @return
300:             */
301:            public Component getTabComponent() {
302:                return this ;
303:            }
304:
305:            /**
306:             *
307:             *
308:             * @return
309:             */
310:            public boolean validateTab() {
311:                return true;
312:            }
313:
314:            /**
315:             *
316:             */
317:            public void applyTab() {
318:                // Get the algorithm preferences
319:                if (!jComboCipherCS.getSelectedItem().equals(DEFAULT)) {
320:                    profile.setPrefCSEncryption((String) jComboCipherCS
321:                            .getSelectedItem());
322:                }
323:
324:                if (!jComboCipherSC.getSelectedItem().equals(DEFAULT)) {
325:                    profile.setPrefSCEncryption((String) jComboCipherSC
326:                            .getSelectedItem());
327:                }
328:
329:                if (!jComboMacCS.getSelectedItem().equals(DEFAULT)) {
330:                    profile
331:                            .setPrefCSMac((String) jComboMacCS
332:                                    .getSelectedItem());
333:                }
334:
335:                if (!jComboMacSC.getSelectedItem().equals(DEFAULT)) {
336:                    profile
337:                            .setPrefSCMac((String) jComboMacSC
338:                                    .getSelectedItem());
339:                }
340:
341:                if (!jComboCompCS.getSelectedItem().equals(DEFAULT)) {
342:                    profile.setPrefCSComp((String) jComboCompCS
343:                            .getSelectedItem());
344:                }
345:
346:                if (!jComboCompSC.getSelectedItem().equals(DEFAULT)) {
347:                    profile.setPrefSCComp((String) jComboCompSC
348:                            .getSelectedItem());
349:                }
350:
351:                if (!jComboKex.getSelectedItem().equals(DEFAULT)) {
352:                    profile.setPrefKex((String) jComboKex.getSelectedItem());
353:                }
354:
355:                if (!jComboPK.getSelectedItem().equals(DEFAULT)) {
356:                    profile.setPrefPublicKey((String) jComboPK
357:                            .getSelectedItem());
358:                }
359:            }
360:
361:            /**
362:             *
363:             */
364:            public void tabSelected() {
365:            }
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.