Source Code Cross Referenced for SshToolsApplicationSessionPanel.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.configuration.ConfigurationLoader;
031:        import com.sshtools.j2ssh.connection.ChannelEventListener;
032:
033:        import org.apache.commons.logging.Log;
034:        import org.apache.commons.logging.LogFactory;
035:
036:        import java.awt.LayoutManager;
037:
038:        import java.io.File;
039:        import java.io.IOException;
040:
041:        import java.util.Comparator;
042:
043:        import javax.swing.SwingConstants;
044:
045:        /**
046:         *
047:         *
048:         * @author $author$
049:         * @version $Revision: 1.12 $
050:         */
051:        public abstract class SshToolsApplicationSessionPanel extends
052:                SshToolsApplicationPanel {
053:            /**  */
054:            public final static String PREF_CONNECTION_FILE_DIRECTORY = "sshapps.connectionFile.directory";
055:
056:            /**  */
057:            protected Log log = LogFactory
058:                    .getLog(SshToolsApplicationSessionPanel.class);
059:
060:            /**  */
061:            protected SshToolsConnectionProfile currentConnectionProfile;
062:
063:            /**  */
064:            protected SessionManager manager;
065:
066:            /**
067:             * Creates a new SshToolsApplicationClientPanel object.
068:             */
069:            public SshToolsApplicationSessionPanel() {
070:                super ();
071:            }
072:
073:            /**
074:             * Creates a new SshToolsApplicationClientPanel object.
075:             *
076:             * @param mgr
077:             */
078:            public SshToolsApplicationSessionPanel(LayoutManager mgr) {
079:                super (mgr);
080:            }
081:
082:            /**
083:             *
084:             *
085:             * @return
086:             */
087:            public abstract SshToolsConnectionTab[] getAdditionalConnectionTabs();
088:
089:            public abstract void addEventListener(
090:                    ChannelEventListener eventListener);
091:
092:            public abstract boolean requiresConfiguration();
093:
094:            public abstract String getId();
095:
096:            /**
097:             *
098:             *
099:             * @param manager
100:             * @param profile
101:             *
102:             * @throws IOException
103:             */
104:            public final boolean openSession(SessionManager manager,
105:                    SshToolsConnectionProfile profile) throws IOException {
106:                this .manager = manager;
107:
108:                // Set the current connection properties
109:                setCurrentConnectionProfile(profile);
110:
111:                if (requiresConfiguration()
112:                        && !profile.getApplicationPropertyBoolean(getId()
113:                                + ".configured", false)) {
114:                    if (!editSettings(profile)) {
115:                        return false;
116:                    }
117:                }
118:
119:                return onOpenSession();
120:            }
121:
122:            /**
123:             *
124:             *
125:             * @throws IOException
126:             */
127:            public abstract boolean onOpenSession() throws IOException;
128:
129:            /**
130:             *
131:             *
132:             * @return
133:             */
134:            public boolean isConnected() {
135:                return (manager != null) && manager.isConnected();
136:            }
137:
138:            /**
139:             *
140:             *
141:             * @param file
142:             */
143:            public void setContainerTitle(File file) {
144:                String verString = "";
145:
146:                if (application != null) {
147:                    verString = ConfigurationLoader.getVersionString(
148:                            application.getApplicationName(), application
149:                                    .getApplicationVersion());
150:                }
151:
152:                if (container != null) {
153:                    container.setContainerTitle((file == null) ? verString
154:                            : (verString + " [" + file.getName() + "]"));
155:                }
156:            }
157:
158:            /**
159:             *
160:             *
161:             * @param profile
162:             */
163:            public void setCurrentConnectionProfile(
164:                    SshToolsConnectionProfile profile) {
165:                currentConnectionProfile = profile;
166:            }
167:
168:            /**
169:             *
170:             *
171:             * @return
172:             */
173:            public SshToolsConnectionProfile getCurrentConnectionProfile() {
174:                return currentConnectionProfile;
175:            }
176:
177:            /**
178:             *
179:             *
180:             * @param profile
181:             *
182:             * @return
183:             */
184:            public boolean editSettings(SshToolsConnectionProfile profile) {
185:                final SshToolsConnectionPanel panel = new SshToolsConnectionPanel(
186:                        false);
187:                SshToolsConnectionTab[] tabs = getAdditionalConnectionTabs();
188:
189:                for (int i = 0; (tabs != null) && (i < tabs.length); i++) {
190:                    tabs[i].setConnectionProfile(profile);
191:                    panel.addTab(tabs[i]);
192:                }
193:
194:                panel.setConnectionProfile(profile);
195:
196:                final Option ok = new Option("Ok",
197:                        "Apply the settings and close this dialog", 'o');
198:                final Option cancel = new Option("Cancel",
199:                        "Close this dialog without applying the settings", 'c');
200:                OptionCallback callback = new OptionCallback() {
201:                    public boolean canClose(OptionsDialog dialog, Option option) {
202:                        if (option == ok) {
203:                            return panel.validateTabs();
204:                        }
205:
206:                        return true;
207:                    }
208:                };
209:
210:                OptionsDialog od = OptionsDialog.createOptionDialog(
211:                        SshToolsApplicationSessionPanel.this , new Option[] {
212:                                ok, cancel }, panel, "Connection Settings", ok,
213:                        callback, null);
214:                od.pack();
215:                UIUtil.positionComponent(SwingConstants.CENTER, od);
216:                od.setVisible(true);
217:
218:                if (od.getSelectedOption() == ok) {
219:                    // Apply the changes to the profile
220:                    panel.applyTabs();
221:
222:                    // Ask the session manager to apply them to persistence
223:                    manager.applyProfileChanges(profile);
224:
225:                    return true;
226:                }
227:
228:                return false;
229:            }
230:
231:            /*public static class ActionMenu
232:            implements Comparable {
233:            int weight;
234:            int mnemonic;
235:            String name;
236:            String displayName;
237:            public ActionMenu(String name, String displayName, int mnemonic,
238:                        int weight) {
239:            this.name = name;
240:            this.displayName = displayName;
241:            this.mnemonic = mnemonic;
242:            this.weight = weight;
243:            }
244:            public int compareTo(Object o) {
245:            int i = new Integer(weight).compareTo(new Integer(
246:            ( (ActionMenu) o).weight));
247:            return (i == 0)
248:            ? displayName.compareTo( ( (ActionMenu) o).displayName) : i;
249:            }
250:            }*/
251:            class ToolBarActionComparator implements  Comparator {
252:                public int compare(Object o1, Object o2) {
253:                    int i = ((Integer) ((StandardAction) o1)
254:                            .getValue(StandardAction.TOOLBAR_GROUP))
255:                            .compareTo((Integer) ((StandardAction) o2)
256:                                    .getValue(StandardAction.TOOLBAR_GROUP));
257:
258:                    return (i == 0) ? ((Integer) ((StandardAction) o1)
259:                            .getValue(StandardAction.TOOLBAR_WEIGHT))
260:                            .compareTo((Integer) ((StandardAction) o2)
261:                                    .getValue(StandardAction.TOOLBAR_WEIGHT))
262:                            : i;
263:                }
264:            }
265:
266:            class MenuItemActionComparator implements  Comparator {
267:                public int compare(Object o1, Object o2) {
268:                    int i = ((Integer) ((StandardAction) o1)
269:                            .getValue(StandardAction.MENU_ITEM_GROUP))
270:                            .compareTo((Integer) ((StandardAction) o2)
271:                                    .getValue(StandardAction.MENU_ITEM_GROUP));
272:
273:                    return (i == 0) ? ((Integer) ((StandardAction) o1)
274:                            .getValue(StandardAction.MENU_ITEM_WEIGHT))
275:                            .compareTo((Integer) ((StandardAction) o2)
276:                                    .getValue(StandardAction.MENU_ITEM_WEIGHT))
277:                            : i;
278:                }
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.