1 /*
2 * SSHTools - Java SSH2 API
3 *
4 * Copyright (C) 2002-2003 Lee David Painter and Contributors.
5 *
6 * Contributions made by:
7 *
8 * Brett Smith
9 * Richard Pernavas
10 * Erwin Bolwidt
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 */
26 package com.sshtools.common.ui;
27
28
29 /**
30 * <p>Instances of this class are created by the <code>SessionProviderFactory</code>
31 * for each installed session provider. Instances of this class can be supplied
32 * to the <code>SessionProviderFrame</code> to create windows contains the
33 * session providers service</p>
34 *
35 * @author Lee David Painter
36 * @version $Id: SessionProvider.java,v 1.12 2003/09/22 15:57:57 martianx Exp $
37 */
38 public class SessionProvider {
39 String id;
40 String name;
41 Class cls;
42 String description;
43 char mnemonic;
44 ResourceIcon smallicon;
45 ResourceIcon largeicon;
46 Class[] propertypages;
47 int weight;
48 Class optionsClass;
49
50 SessionProvider(String id, String name, Class cls, String description,
51 String mnemonic, String smallicon, String largeicon,
52 Class optionsClass, Class[] propertypages, int weight) {
53 this.id = id;
54 this.name = name;
55 this.cls = cls;
56 this.description = description;
57 this.mnemonic = mnemonic.charAt(0);
58 this.propertypages = propertypages;
59 this.optionsClass = optionsClass;
60 this.smallicon = new ResourceIcon(cls, smallicon);
61 this.largeicon = new ResourceIcon(cls, largeicon);
62 this.weight = weight;
63 }
64
65 /**
66 * Get the name of the provider e.g. 'Terminal Session'.
67 * @return
68 */
69 public String getName() {
70 return name;
71 }
72
73 /**
74 * Get the class instance for the session providers implementation.
75 * @return
76 */
77 public Class getProviderClass() {
78 return cls;
79 }
80
81 /**
82 * Get an array of class instances for the providers property pages.
83 * @return
84 */
85 public Class[] getPropertyPages() {
86 return propertypages;
87 }
88
89 /**
90 * Get the description of the provider e.g. 'Opens a terminal session'
91 * @return
92 */
93 public String getDescription() {
94 return description;
95 }
96
97 /**
98 * Get the mnemonic character for key access
99 * @return
100 */
101 public char getMnemonic() {
102 return mnemonic;
103 }
104
105 /**
106 * Get the weight of the provider.
107 * @return
108 */
109 public int getWeight() {
110 return weight;
111 }
112
113 /**
114 * Get the id of the provider e.g. 'sshterm'.
115 * @return
116 */
117 public String getId() {
118 return id;
119 }
120
121 /**
122 * Get the small icon of the provider.
123 * @return
124 */
125 public ResourceIcon getSmallIcon() {
126 return smallicon;
127 }
128
129 /**
130 * Get the large icon of the provider.
131 * @return
132 */
133 public ResourceIcon getLargeIcon() {
134 return largeicon;
135 }
136
137 /**
138 * Get the options class implementation
139 * @return
140 */
141 public Class getOptionsClass() {
142 return optionsClass;
143 }
144
145 /**
146 * Compares this session provider against another object. This method
147 * will only return true if the object provided is an instance of
148 * <code>SessionProvider</code> and that the provider id and implementation
149 * class are equal.
150 *
151 * @param obj
152 * @return
153 */
154 public boolean equals(Object obj) {
155 if ((obj != null) && obj instanceof SessionProvider) {
156 SessionProvider provider = (SessionProvider) obj;
157
158 return provider.id.equals(id) &&
159 provider.getProviderClass().equals(cls);
160 }
161
162 return false;
163 }
164
165 /**
166 * Returns the name of the provider.
167 * @return
168 */
169 public String toString() {
170 return name;
171 }
172 }