Source Code Cross Referenced for SessionProviderFrame.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.SftpClient;
031:        import com.sshtools.j2ssh.SshClient;
032:        import com.sshtools.j2ssh.SshEventAdapter;
033:        import com.sshtools.j2ssh.connection.Channel;
034:        import com.sshtools.j2ssh.connection.ChannelFactory;
035:        import com.sshtools.j2ssh.forwarding.ForwardingClient;
036:        import com.sshtools.j2ssh.session.SessionChannelClient;
037:
038:        import java.awt.BorderLayout;
039:
040:        import java.io.IOException;
041:
042:        /**
043:         * <p>This frame class embeds a SessionProvider and manages the connection
044:         * on behalf of the caller. To invoke a session provider from an external
045:         * application is a straight forward procedure. Assuming that the connection
046:         * has already been established [see SshClient] you can invoke a frame using
047:         * the following code:</p>
048:         *
049:         * <blockquote><pre>
050:         * // Create an SshClient connection
051:         * SshClient ssh = new SshClient();
052:         *
053:         * // Connection code goes here - see SshClient for more details
054:         *
055:         * SessionProviderFrame frame = new SessionProviderFrame(null,
056:         *                            new SshToolsConnectionProfile(),
057:         *                                                        ssh,
058:         *          SessionProviderFactory.getInstance().getProvider("sshterm"));
059:         * frame.pack();
060:         * frame.show();
061:         * </pre></blockquote>
062:         *
063:         * @author Lee David Painter
064:         * @version $Id: SessionProviderFrame.java,v 1.9 2003/11/16 19:30:08 rpernavas Exp $
065:         */
066:        public class SessionProviderFrame extends SshToolsApplicationFrame
067:                implements  SessionManager {
068:            //  Private instance variables
069:            private SshToolsApplicationSessionPanel panel;
070:            private SessionProvider provider;
071:            private SshToolsConnectionProfile profile;
072:            private SshClient ssh;
073:            private boolean disconnectOnClose = false;
074:
075:            /**
076:             * Construct a new Session Provider frame.
077:             *
078:             * @param app The SshToolsApplication instance, can be null
079:             * @param profile The profile of the connection
080:             * @param ssh the client connection
081:             * @param provider the provider instance
082:             * @throws IOException
083:             * @throws SshToolsApplicationException
084:             */
085:            public SessionProviderFrame(SshToolsConnectionProfile profile,
086:                    SshClient ssh, SessionProvider provider)
087:                    throws IOException, SshToolsApplicationException {
088:                try {
089:                    this .provider = provider;
090:                    this .ssh = ssh;
091:                    this .profile = profile;
092:                    setIconImage(provider.getSmallIcon().getImage());
093:                    setTitle(provider.getName() + " - "
094:                            + ssh.getConnectionProperties().getHost());
095:                    getContentPane().setLayout(new BorderLayout());
096:                    getContentPane().add(
097:                            panel = (SshToolsApplicationSessionPanel) provider
098:                                    .getProviderClass().newInstance(),
099:                            BorderLayout.CENTER);
100:
101:                    return;
102:                } catch (IllegalAccessException ex) {
103:                } catch (InstantiationException ex) {
104:                }
105:
106:                throw new SshToolsApplicationException(
107:                        "Failed to create instance of "
108:                                + provider.getProviderClass().getName());
109:            }
110:
111:            /**
112:             * Initialize the frame and open the remote session
113:             * @param app the application object, can be null
114:             * @return
115:             * @throws IOException
116:             * @throws SshToolsApplicationException
117:             */
118:            public boolean initFrame(SshToolsApplication app)
119:                    throws IOException, SshToolsApplicationException {
120:                panel.setCurrentConnectionProfile(profile);
121:                panel.init(app);
122:                init(app, panel);
123:                pack();
124:
125:                return panel.openSession(this , profile);
126:            }
127:
128:            /**
129:             * Get the attached session provider panel.
130:             * @return
131:             */
132:            public SshToolsApplicationSessionPanel getSessionPanel() {
133:                return panel;
134:            }
135:
136:            /**
137:             * Returns the guessed EOL setting of the remote computer
138:             * @return
139:             */
140:            public int getRemoteEOL() {
141:                return ssh.getRemoteEOL();
142:            }
143:
144:            /**
145:             * Called by the application framework when testing exit state
146:             * @return
147:             */
148:            public boolean canExit() {
149:                return panel.canClose();
150:            }
151:
152:            /**
153:             * Called by the framework when exiting. Can also be called to close the session.
154:             */
155:            public void exit() {
156:                panel.close();
157:                dispose();
158:            }
159:
160:            /**
161:             * Implementation of the SessionManager method, simply calls the SshClient
162:             * openSession method.
163:             * @return
164:             * @throws IOException
165:             */
166:            public SessionChannelClient openSession() throws IOException {
167:                return ssh.openSessionChannel();
168:            }
169:
170:            /**
171:             * Implementation of the SessionManager method, this does nothing. Overide this
172:             * method to provide additional functionality to save changes made by the session
173:             * to the profile.
174:             *
175:             * @param profile
176:             */
177:            public void applyProfileChanges(SshToolsConnectionProfile profile) {
178:            }
179:
180:            /**
181:             * When the session closes, should the connection be disconnected?
182:             * @param disconnectOnClose
183:             */
184:            public void setDisconnectOnClose(boolean disconnectOnClose) {
185:                this .disconnectOnClose = disconnectOnClose;
186:            }
187:
188:            /**
189:             * Implementation of the SessionManager method, this simply calls the SshClient
190:             * method openSftpClient.
191:             * @return
192:             * @throws IOException
193:             */
194:            public SftpClient openSftpClient() throws IOException {
195:                return ssh.openSftpClient();
196:            }
197:
198:            /**
199:             * Implementation of the SessionManager method, this simply calls the SshClient
200:             * method openChannel.
201:             * @param channel
202:             * @return
203:             * @throws IOException
204:             */
205:            public boolean openChannel(Channel channel) throws IOException {
206:                return ssh.openChannel(channel);
207:            }
208:
209:            /**
210:             * Implementation of the SessionManager method, this simply calls the SshClient
211:             * method isConnected.
212:             * @return
213:             */
214:            public boolean isConnected() {
215:                return ssh.isConnected();
216:            }
217:
218:            /**
219:             * Implementation of the SessionManager method, this simply returns false.
220:             * Overide to change this behaviour
221:             *
222:             * @return
223:             */
224:            public boolean requestDisconnect() {
225:                return disconnectOnClose;
226:            }
227:
228:            /**
229:             * Implementation of the SessionManager method, simply calls the SshClient
230:             * method getForwardingClient.
231:             * @return
232:             */
233:            public ForwardingClient getForwardingClient() {
234:                return ssh.getForwardingClient();
235:            }
236:
237:            /**
238:             * Implementation of the SessionManager method, simply calls the SshClient
239:             * method sendGlobalRequest.
240:             * @param requestname
241:             * @param wantreply
242:             * @param requestdata
243:             * @return
244:             * @throws IOException
245:             */
246:            public byte[] sendGlobalRequest(String requestname,
247:                    boolean wantreply, byte[] requestdata) throws IOException {
248:                return ssh.sendGlobalRequest(requestname, wantreply,
249:                        requestdata);
250:            }
251:
252:            /**
253:             * Implementation of the SessionManager method, simply calls the SshClient
254:             * method addEventHandler.
255:             * @param eventHandler
256:             */
257:            public void addEventHandler(SshEventAdapter eventHandler) {
258:                ssh.addEventHandler(eventHandler);
259:            }
260:
261:            /**
262:             * Implemenation of the SessionManager method, simply calls the SshClient
263:             * method getServerId.
264:             * @return
265:             */
266:            public String getServerId() {
267:                return ssh.getServerId();
268:            }
269:
270:            /**
271:             * Implemenation of the SessionManager method, simply calls the SshClient
272:             * method allowChannelOpen.
273:             * @param channelType
274:             * @param cf
275:             * @throws IOException
276:             */
277:            public void allowChannelOpen(String channelType, ChannelFactory cf)
278:                    throws IOException {
279:                ssh.allowChannelOpen(channelType, cf);
280:            }
281:
282:            /**
283:             * Gets the profile currently attached to the frame.
284:             * @return
285:             */
286:            public SshToolsConnectionProfile getProfile() {
287:                return profile;
288:            }
289:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.