Revision 35869
tags/v2_0_0_Build_2030/frameworks/_fwAndami/castor.properties | ||
---|---|---|
1 |
org.exolab.castor.indent=true |
|
0 | 2 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/compile-classpath.xml | ||
---|---|---|
1 |
<project name="_fwAndami.compile-classpath" basedir="."> |
|
2 |
<!-- defines the classpath to be used for batch-compilation --> |
|
3 |
<property name="andami" location="../_fwAndami"/> |
|
4 |
<property name="andamiLibs" location="${andami}/lib"/> |
|
5 |
<path id="_fwAndami.compile-classpath"> |
|
6 |
<pathelement location="${andamiLibs}/beans.jar"/> |
|
7 |
<pathelement location="${andamiLibs}/castor-0.9.5.3-xml.jar"/> |
|
8 |
<pathelement location="${andamiLibs}/gvsig-i18n.jar"/> |
|
9 |
<pathelement location="${andamiLibs}/iver-utiles.jar"/> |
|
10 |
<pathelement location="${andamiLibs}/javaws.jar"/> |
|
11 |
<pathelement location="${andamiLibs}/JWizardComponent.jar"/> |
|
12 |
<pathelement location="${andamiLibs}/log4j-1.2.8.jar"/> |
|
13 |
<pathelement location="${andamiLibs}/tempFileManager.jar"/> |
|
14 |
<pathelement location="${andamiLibs}/xercesImpl.jar"/> |
|
15 |
<pathelement location="${andamiLibs}/xml-apis.jar"/> |
|
16 |
<pathelement location="${andamiLibs}/kxml2.jar"/> |
|
17 |
<pathelement location="${andamiLibs}/jcalendar.jar"/> |
|
18 |
</path> |
|
19 |
</project> |
|
0 | 20 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/authentication/LoginUI.java | ||
---|---|---|
1 |
package org.gvsig.andami.authentication; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Container; |
|
6 |
|
|
7 |
import javax.swing.BorderFactory; |
|
8 |
import javax.swing.ImageIcon; |
|
9 |
import javax.swing.JDialog; |
|
10 |
import javax.swing.JLabel; |
|
11 |
import javax.swing.JPanel; |
|
12 |
import javax.swing.JPasswordField; |
|
13 |
import javax.swing.JTextField; |
|
14 |
|
|
15 |
import org.gvsig.andami.PluginServices; |
|
16 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
17 |
import org.gvsig.gui.beans.swing.JButton; |
|
18 |
|
|
19 |
|
|
20 |
/** |
|
21 |
* Form to let the user log in the system. |
|
22 |
* @author laura |
|
23 |
* |
|
24 |
*/ |
|
25 |
public class LoginUI extends JDialog |
|
26 |
{ |
|
27 |
private JTextField usernameField; |
|
28 |
private JPasswordField passwordField; |
|
29 |
private JTextField serverURLField; |
|
30 |
private JLabel invalidLoginLabel; |
|
31 |
private JButton okButton; |
|
32 |
private JButton exitButton; |
|
33 |
private GridBagLayoutPanel mainPanel; |
|
34 |
private JPanel buttonPanel; |
|
35 |
private boolean isFirstLogin = true; |
|
36 |
|
|
37 |
//TODO: |
|
38 |
//Cambiar esto para que coja un icono de una ruta que se lee de un xml |
|
39 |
|
|
40 |
static private ImageIcon gvsigIcon = PluginServices |
|
41 |
.getIconTheme().get("login-gvsig"); |
|
42 |
|
|
43 |
IAuthentication authentication; |
|
44 |
|
|
45 |
public LoginUI(IAuthentication authentication ) |
|
46 |
{ |
|
47 |
Container container = getContentPane(); |
|
48 |
mainPanel = new GridBagLayoutPanel(); |
|
49 |
usernameField = new JTextField(25); |
|
50 |
passwordField = new JPasswordField(25); |
|
51 |
serverURLField = new JTextField(25); |
|
52 |
|
|
53 |
String server_text = (String)authentication.get("server_url"); |
|
54 |
if(server_text != null){ |
|
55 |
serverURLField.setText( server_text ); |
|
56 |
} |
|
57 |
|
|
58 |
buttonPanel = new JPanel(); |
|
59 |
okButton = new JButton( PluginServices.getText(this, "login_ok") ); |
|
60 |
okButton.addActionListener(new java.awt.event.ActionListener() { |
|
61 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
62 |
OK(); |
|
63 |
} |
|
64 |
}); |
|
65 |
exitButton = new JButton( PluginServices.getText(this, "login_exit") ); |
|
66 |
exitButton.addActionListener(new java.awt.event.ActionListener() { |
|
67 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
68 |
Cancel(); |
|
69 |
} |
|
70 |
}); |
|
71 |
|
|
72 |
buttonPanel.add( okButton ); |
|
73 |
buttonPanel.add( exitButton ); |
|
74 |
|
|
75 |
JPanel logoPanel = new JPanel(); |
|
76 |
logoPanel.add(new JLabel(gvsigIcon)); |
|
77 |
logoPanel.setBorder(BorderFactory.createEmptyBorder(1,1,1,10)); |
|
78 |
container.add(logoPanel, BorderLayout.WEST); |
|
79 |
container.add( mainPanel, BorderLayout.CENTER ); |
|
80 |
mainPanel.addComponent(PluginServices.getText(this, "login_name"), usernameField); |
|
81 |
mainPanel.addComponent(PluginServices.getText(this, "login_password"), passwordField); |
|
82 |
mainPanel.addComponent(PluginServices.getText(this, "login_name"), serverURLField); |
|
83 |
invalidLoginLabel = new JLabel(PluginServices.getText(this, "login_invalid_user")); |
|
84 |
invalidLoginLabel.setForeground(Color.RED); |
|
85 |
invalidLoginLabel.setVisible( false ); |
|
86 |
mainPanel.addComponent(invalidLoginLabel, buttonPanel); |
|
87 |
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); |
|
88 |
|
|
89 |
this.authentication = authentication; |
|
90 |
this.setBounds(400,400,this.getWidth(),this.getHeight()); |
|
91 |
this.setTitle( "Login" ); |
|
92 |
this.setModal(true); |
|
93 |
this.setSize( 400, 200); |
|
94 |
this.setResizable( false ); |
|
95 |
pack(); |
|
96 |
setVisible( true ); |
|
97 |
} |
|
98 |
|
|
99 |
public void OK() |
|
100 |
{ |
|
101 |
if (((String)serverURLField.getText() == null) || (((String)serverURLField.getText()).length() == 0)){ |
|
102 |
return; |
|
103 |
} |
|
104 |
|
|
105 |
authentication.put("user", (String)usernameField.getText()); |
|
106 |
authentication.put("pwd", new String(passwordField.getPassword())); |
|
107 |
authentication.put("server", (String)serverURLField.getText()); |
|
108 |
|
|
109 |
if (authentication.isValidUser()){ |
|
110 |
authentication.setLogged(true); |
|
111 |
dispose(); |
|
112 |
} |
|
113 |
else{ |
|
114 |
usernameField.setText(""); |
|
115 |
passwordField.setText(""); |
|
116 |
if (isFirstLogin) |
|
117 |
{ |
|
118 |
invalidLoginLabel.setVisible(true); |
|
119 |
isFirstLogin = false; |
|
120 |
} |
|
121 |
//JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"Invalid user/password"); |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
public void Cancel() |
|
126 |
{ |
|
127 |
authentication.put("user", ""); |
|
128 |
authentication.put("pwd", ""); |
|
129 |
authentication.setLogged(false); |
|
130 |
dispose(); |
|
131 |
} |
|
132 |
|
|
133 |
} |
|
0 | 134 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/authentication/IAuthentication.java | ||
---|---|---|
1 |
package org.gvsig.andami.authentication; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
/** |
|
6 |
* Interface to implement by clases which perform the authentication |
|
7 |
* @author laura |
|
8 |
*/ |
|
9 |
public interface IAuthentication extends Map{ |
|
10 |
|
|
11 |
public boolean Login(); |
|
12 |
public boolean isLogged(); |
|
13 |
public void setLogged(boolean logged); |
|
14 |
public boolean isValidUser(); |
|
15 |
public boolean validationRequired(); |
|
16 |
public void setPluginDirectory(String dir); |
|
17 |
|
|
18 |
} |
|
0 | 19 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/HiddableExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins; |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Extending andami's classical extension this interface will support hidding or |
|
46 |
* showing an extension on the fly. |
|
47 |
* |
|
48 |
* @autor Jaume Dominguez Faus - jaume.dominguez@iver.es |
|
49 |
*/ |
|
50 |
public interface HiddableExtension extends IExtension{ |
|
51 |
|
|
52 |
/** |
|
53 |
* Determines whether the extension will be visible or not, overriding |
|
54 |
* the value defined by the extension itself. |
|
55 |
* |
|
56 |
* @return |
|
57 |
*/ |
|
58 |
public int getVisibility(); |
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* Sets the absolute visibility of this extension (overriding the value |
|
64 |
* set at the MDIManager) |
|
65 |
* @param b |
|
66 |
*/ |
|
67 |
public void setVisibility(int state); |
|
68 |
} |
|
0 | 69 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/PluginClassLoader.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins; |
|
42 |
|
|
43 |
import java.io.DataInputStream; |
|
44 |
import java.io.File; |
|
45 |
import java.io.FileInputStream; |
|
46 |
import java.io.IOException; |
|
47 |
import java.io.InputStream; |
|
48 |
import java.net.MalformedURLException; |
|
49 |
import java.net.URL; |
|
50 |
import java.net.URLClassLoader; |
|
51 |
import java.security.AllPermission; |
|
52 |
import java.security.CodeSource; |
|
53 |
import java.security.PermissionCollection; |
|
54 |
import java.util.ArrayList; |
|
55 |
import java.util.Enumeration; |
|
56 |
import java.util.Hashtable; |
|
57 |
import java.util.List; |
|
58 |
import java.util.StringTokenizer; |
|
59 |
import java.util.zip.ZipEntry; |
|
60 |
import java.util.zip.ZipException; |
|
61 |
import java.util.zip.ZipFile; |
|
62 |
|
|
63 |
import org.slf4j.Logger; |
|
64 |
import org.slf4j.LoggerFactory; |
|
65 |
|
|
66 |
import org.gvsig.andami.messages.Messages; |
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
/** |
|
71 |
* <p>Class loader which loads the classes requested by the |
|
72 |
* plugins. It first tries to search in the classpath, then it requests |
|
73 |
* the class to the parent classloader, then it searches in the owns |
|
74 |
* plugins' library dir, and if all these methods fail, it tries to load |
|
75 |
* the class from any of the depended plugins. Finally, if this also |
|
76 |
* fails, the other classloaders provided in the <code>addLoaders</code> method |
|
77 |
* are requested to load the class.</p> |
|
78 |
* |
|
79 |
* <p>The class loader can also be used to load resources from the |
|
80 |
* plugin's directory by using the <code>getResource()</code> method.</p> |
|
81 |
* |
|
82 |
* @author Fernando Gonz?lez Cort?s |
|
83 |
*/ |
|
84 |
public class PluginClassLoader extends URLClassLoader { |
|
85 |
/** DOCUMENT ME! */ |
|
86 |
private static Logger logger = LoggerFactory.getLogger(PluginClassLoader.class.getName()); |
|
87 |
|
|
88 |
/** DOCUMENT ME! */ |
|
89 |
private Hashtable clasesJar = new Hashtable(); |
|
90 |
|
|
91 |
/** DOCUMENT ME! */ |
|
92 |
private File baseDir; |
|
93 |
private PluginClassLoader[] pluginLoaders; |
|
94 |
private static ArrayList otherLoaders=new ArrayList(); |
|
95 |
private boolean isOtherLoader=false; |
|
96 |
|
|
97 |
/** |
|
98 |
* Creates a new PluginClassLoader object. |
|
99 |
* |
|
100 |
* @param jars Array with the search paths where classes will be searched |
|
101 |
* @param baseDir Base directory for this plugin. This is the directory |
|
102 |
* which will be used as basedir in the <code>getResources</code> method. |
|
103 |
* @param cl The parent classloader of this classloader. It will be used to |
|
104 |
* search classes before trying to search in the plugin's directory |
|
105 |
* @param pluginLoaders The classloaders of the depended plugins. |
|
106 |
* |
|
107 |
* @throws IOException |
|
108 |
*/ |
|
109 |
public PluginClassLoader(URL[] jars, String baseDir, ClassLoader cl, |
|
110 |
PluginClassLoader[] pluginLoaders) throws IOException { |
|
111 |
super(jars, cl); |
|
112 |
this.baseDir = new File(new File(baseDir).getAbsolutePath()); |
|
113 |
this.pluginLoaders = pluginLoaders; |
|
114 |
|
|
115 |
ZipFile[] jarFiles = new ZipFile[jars.length]; |
|
116 |
|
|
117 |
for (int i = 0; i < jars.length; i++) { |
|
118 |
try { |
|
119 |
jarFiles[i] = new ZipFile(jars[i].getPath()); |
|
120 |
|
|
121 |
Enumeration entradas = jarFiles[i].entries(); |
|
122 |
|
|
123 |
while (entradas.hasMoreElements()) { |
|
124 |
ZipEntry file = (ZipEntry) entradas.nextElement(); |
|
125 |
String fileName = file.getName(); |
|
126 |
|
|
127 |
if (!fileName.toLowerCase().endsWith(".class")) { //$NON-NLS-1$ |
|
128 |
|
|
129 |
continue; |
|
130 |
} |
|
131 |
|
|
132 |
fileName = fileName.substring(0, fileName.length() - 6) |
|
133 |
.replace('/', '.'); |
|
134 |
|
|
135 |
if (clasesJar.get(fileName) != null) { |
|
136 |
logger.warn(Messages |
|
137 |
.getString( |
|
138 |
"PluginClassLoader.Dos_clases_con_el_mismo_nombre_en_el_plugin") + |
|
139 |
": " + fileName + " "+ Messages.getString("en") + " " + |
|
140 |
jarFiles[i].getName() + " " + Messages.getString("y_en") + " " + |
|
141 |
((ZipFile) clasesJar.get(fileName)).getName()); |
|
142 |
} |
|
143 |
else { |
|
144 |
clasesJar.put(fileName, jarFiles[i]); |
|
145 |
} |
|
146 |
} |
|
147 |
} catch (ZipException e) { |
|
148 |
throw new IOException(e.getMessage() + " Jar: " + |
|
149 |
jars[i].getPath() + ": " + jarFiles[i]); |
|
150 |
} catch (IOException e) { |
|
151 |
throw e; |
|
152 |
} |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* DOCUMENT ME! |
|
158 |
* |
|
159 |
* @param name DOCUMENT ME! |
|
160 |
* |
|
161 |
* @return DOCUMENT ME! |
|
162 |
* |
|
163 |
* @throws ClassNotFoundException DOCUMENT ME! |
|
164 |
*/ |
|
165 |
protected Class singleLoadClass(String name) throws ClassNotFoundException { |
|
166 |
// Buscamos en las clases de las librer?as del plugin |
|
167 |
Class c = findLoadedClass(name); |
|
168 |
|
|
169 |
if (c != null) { |
|
170 |
return c; |
|
171 |
} |
|
172 |
|
|
173 |
try { |
|
174 |
ZipFile jar = (ZipFile) clasesJar.get(name); |
|
175 |
|
|
176 |
//No est? en ning?n jar |
|
177 |
if (jar == null) { |
|
178 |
//Buscamos en el directorio de clases |
|
179 |
String classFileName = baseDir + "/classes/" + |
|
180 |
name.replace('.', '/') + ".class"; |
|
181 |
File f = new File(classFileName); |
|
182 |
if (f.exists()){ |
|
183 |
byte[] data = loadClassData(f); |
|
184 |
c = defineClass(name, data, 0, data.length); |
|
185 |
|
|
186 |
if (logger.isDebugEnabled()) { |
|
187 |
logger.debug("Class {} found in the classes folder by the " |
|
188 |
+ "classloader for the plugin {}", |
|
189 |
name, baseDir); |
|
190 |
} |
|
191 |
|
|
192 |
}else{ |
|
193 |
//Buscamos en los otros plugins |
|
194 |
for (int i = 0; i < pluginLoaders.length; i++) { |
|
195 |
try |
|
196 |
{ |
|
197 |
if (pluginLoaders[i] != null){ |
|
198 |
c = pluginLoaders[i].singleLoadClass(name); |
|
199 |
}else{ |
|
200 |
//TODO El pluginLoaders[i] puede ser nulo? |
|
201 |
logger.warn("PluginLoaders[i] es nulo"); |
|
202 |
} |
|
203 |
} |
|
204 |
catch (ClassNotFoundException e) |
|
205 |
{ |
|
206 |
// Si no la encontramos en el primer plugin, capturamos la exceptci?n |
|
207 |
// porque es probable que la encontremos en el resto de plugins. |
|
208 |
} |
|
209 |
|
|
210 |
if (c != null) { |
|
211 |
break; |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} else { |
|
216 |
String fileName = name.replace('.', '/') + ".class"; |
|
217 |
ZipEntry classFile = jar.getEntry(fileName); |
|
218 |
byte[] data = loadClassData(classFile, |
|
219 |
jar.getInputStream(classFile)); |
|
220 |
|
|
221 |
c = defineClass(name, data, 0, data.length); |
|
222 |
|
|
223 |
if (logger.isDebugEnabled()) { |
|
224 |
logger.debug("Class {} found in the jar file {} by the " |
|
225 |
+ "classloader for the plugin {}", |
|
226 |
new Object[] { name, jar.getName(), baseDir }); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
if (c == null) { |
|
231 |
throw new ClassNotFoundException(name); |
|
232 |
} |
|
233 |
|
|
234 |
return c; |
|
235 |
} catch (IOException e) { |
|
236 |
throw new ClassNotFoundException(Messages.getString( |
|
237 |
"PluginClassLoader.Error_reading_file") + name); |
|
238 |
} |
|
239 |
} |
|
240 |
|
|
241 |
/** |
|
242 |
* Carga la clase |
|
243 |
* |
|
244 |
* @param name Nombre de la clase |
|
245 |
* @param resolve Si se ha de resolver la clase o no |
|
246 |
* |
|
247 |
* @return Clase cargada |
|
248 |
* |
|
249 |
* @throws ClassNotFoundException Si no se pudo encontrar la clase |
|
250 |
*/ |
|
251 |
protected Class loadClass(String name, boolean resolve) |
|
252 |
throws ClassNotFoundException { |
|
253 |
Class c = null; |
|
254 |
|
|
255 |
// Intentamos cargar con el system classloader |
|
256 |
try { |
|
257 |
if (!isOtherLoader) |
|
258 |
c = super.loadClass(name, resolve); |
|
259 |
logger.debug("Class {} found by the system classloader", name); |
|
260 |
} catch (ClassNotFoundException e1) { |
|
261 |
try { |
|
262 |
c = singleLoadClass(name); |
|
263 |
} catch (ClassNotFoundException e2) { |
|
264 |
try { |
|
265 |
isOtherLoader=true; |
|
266 |
c = loadOtherClass(name); |
|
267 |
}catch (ClassNotFoundException e3) { |
|
268 |
// throw new ClassNotFoundException(Messages.getString( |
|
269 |
// "PluginClassLoader.Error_reading_file") |
|
270 |
// + name, e3); |
|
271 |
throw new ClassNotFoundException("Class " + name |
|
272 |
+ " not found through the plugin " + baseDir, e3); |
|
273 |
}finally { |
|
274 |
isOtherLoader=false; |
|
275 |
} |
|
276 |
} |
|
277 |
} |
|
278 |
if (c==null) |
|
279 |
throw new ClassNotFoundException(Messages.getString( |
|
280 |
"PluginClassLoader.Error_reading_file") + name); |
|
281 |
if (resolve) { |
|
282 |
resolveClass(c); |
|
283 |
} |
|
284 |
return c; |
|
285 |
} |
|
286 |
private Class loadOtherClass(String name) |
|
287 |
throws ClassNotFoundException |
|
288 |
{ |
|
289 |
ClassLoader[] ocl=(ClassLoader[])otherLoaders.toArray(new ClassLoader[0]); |
|
290 |
Class c=null; |
|
291 |
for (int i=0;i<ocl.length;i++) { |
|
292 |
c=ocl[i].loadClass(name); |
|
293 |
if (c != null) { |
|
294 |
logger |
|
295 |
.debug( |
|
296 |
"Class {} found by the alternative classloaders of the plugin {}", |
|
297 |
name, baseDir); |
|
298 |
|
|
299 |
return c; |
|
300 |
} |
|
301 |
} |
|
302 |
throw new ClassNotFoundException(name); |
|
303 |
} |
|
304 |
|
|
305 |
/** |
|
306 |
* obtiene el array de bytes de la clase |
|
307 |
* |
|
308 |
* @param classFile Entrada dentro del jar contiene los bytecodes de la |
|
309 |
* clase (el .class) |
|
310 |
* @param is InputStream para leer la entrada del jar |
|
311 |
* |
|
312 |
* @return Bytes de la clase |
|
313 |
* |
|
314 |
* @throws IOException Si no se puede obtener el .class del jar |
|
315 |
*/ |
|
316 |
private byte[] loadClassData(ZipEntry classFile, InputStream is) |
|
317 |
throws IOException { |
|
318 |
// Get size of class file |
|
319 |
int size = (int) classFile.getSize(); |
|
320 |
|
|
321 |
// Reserve space to read |
|
322 |
byte[] buff = new byte[size]; |
|
323 |
|
|
324 |
// Get stream to read from |
|
325 |
DataInputStream dis = new DataInputStream(is); |
|
326 |
|
|
327 |
// Read in data |
|
328 |
dis.readFully(buff); |
|
329 |
|
|
330 |
// close stream |
|
331 |
dis.close(); |
|
332 |
|
|
333 |
// return data |
|
334 |
return buff; |
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* Gets the bytes of a File |
|
339 |
* |
|
340 |
* @param file File |
|
341 |
* |
|
342 |
* @return bytes of file |
|
343 |
* |
|
344 |
* @throws IOException If the operation fails |
|
345 |
*/ |
|
346 |
private byte[] loadClassData(File file) throws IOException { |
|
347 |
InputStream is = new FileInputStream(file); |
|
348 |
|
|
349 |
// Get the size of the file |
|
350 |
long length = file.length(); |
|
351 |
|
|
352 |
// You cannot create an array using a long type. |
|
353 |
// It needs to be an int type. |
|
354 |
// Before converting to an int type, check |
|
355 |
// to ensure that file is not larger than Integer.MAX_VALUE. |
|
356 |
if (length > Integer.MAX_VALUE) { |
|
357 |
// File is too large |
|
358 |
} |
|
359 |
|
|
360 |
// Create the byte array to hold the data |
|
361 |
byte[] bytes = new byte[(int) length]; |
|
362 |
|
|
363 |
// Read in the bytes |
|
364 |
int offset = 0; |
|
365 |
int numRead = 0; |
|
366 |
|
|
367 |
while ((offset < bytes.length) && |
|
368 |
((numRead = is.read(bytes, offset, bytes.length - offset)) >= 0)) { |
|
369 |
offset += numRead; |
|
370 |
} |
|
371 |
|
|
372 |
// Ensure all the bytes have been read in |
|
373 |
if (offset < bytes.length) { |
|
374 |
throw new IOException("Could not completely read file " + |
|
375 |
file.getName()); |
|
376 |
} |
|
377 |
|
|
378 |
// Close the input stream and return bytes |
|
379 |
is.close(); |
|
380 |
|
|
381 |
return bytes; |
|
382 |
} |
|
383 |
|
|
384 |
/** |
|
385 |
* Gets the requested resource. If the path is relative, its base directory |
|
386 |
* will be the one provided in the PluginClassLoader's constructor. |
|
387 |
* If the resource is not found, the parent classloader will be invoked |
|
388 |
* to try to get it. If it is not found, it will return null. |
|
389 |
* |
|
390 |
* @param res An absolute or relative path to the requested resource. |
|
391 |
* |
|
392 |
* @return Resource's URL if it was found, nul otherwise. |
|
393 |
*/ |
|
394 |
public URL getResource(String res) { |
|
395 |
try { |
|
396 |
ArrayList resource = new ArrayList(); |
|
397 |
StringTokenizer st = new StringTokenizer(res, "\\/"); |
|
398 |
|
|
399 |
while (st.hasMoreTokens()) { |
|
400 |
String token = st.nextToken(); |
|
401 |
resource.add(token); |
|
402 |
} |
|
403 |
|
|
404 |
URL ret = getResource(baseDir, resource); |
|
405 |
|
|
406 |
if (ret != null) { |
|
407 |
return ret; |
|
408 |
} |
|
409 |
} catch (Exception e) { |
|
410 |
e.printStackTrace(); |
|
411 |
} |
|
412 |
|
|
413 |
return super.getResource(res); |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* Gets the requested resource. If the path is relative, its base directory |
|
418 |
* will be the one provided in the PluginClassLoader's constructor. |
|
419 |
* If the resource is not found, the parent classloader will be invoked |
|
420 |
* to try to get it. If it is not found, it will return null. |
|
421 |
* |
|
422 |
* @param res An absolute or relative path to the requested resource. |
|
423 |
* |
|
424 |
* @return Resource's URL if it was found, nul otherwise. |
|
425 |
*/ |
|
426 |
private URL getResource(File base, List res) { |
|
427 |
File[] files = base.listFiles(); |
|
428 |
|
|
429 |
String parte = (String) res.get(0); |
|
430 |
|
|
431 |
for (int i = 0; i < files.length; i++) { |
|
432 |
if (files[i].getName().compareTo(parte) == 0) { |
|
433 |
if (res.size() == 1) { |
|
434 |
try { |
|
435 |
return new URL("file:" + files[i].toString()); |
|
436 |
} catch (MalformedURLException e) { |
|
437 |
return null; |
|
438 |
} |
|
439 |
} else { |
|
440 |
return getResource(files[i], res.subList(1, res.size())); |
|
441 |
} |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
return null; |
|
446 |
} |
|
447 |
|
|
448 |
/** |
|
449 |
* Returns the name of the plugin (the name of the directory containing |
|
450 |
* the plugin). |
|
451 |
* |
|
452 |
* @return An String containing the plugin's name. |
|
453 |
*/ |
|
454 |
public String getPluginName() { |
|
455 |
String ret = baseDir.getAbsolutePath().substring(baseDir.getAbsolutePath() |
|
456 |
.lastIndexOf(File.separatorChar) + |
|
457 |
1); |
|
458 |
|
|
459 |
return ret; |
|
460 |
} |
|
461 |
|
|
462 |
/* |
|
463 |
* @see java.security.SecureClassLoader#getPermissions(java.security.CodeSource) |
|
464 |
*/ |
|
465 |
protected PermissionCollection getPermissions(CodeSource codesource) { |
|
466 |
PermissionCollection perms = super.getPermissions(codesource); |
|
467 |
perms.add(new AllPermission()); |
|
468 |
|
|
469 |
return perms; |
|
470 |
} |
|
471 |
|
|
472 |
/** |
|
473 |
* Gets the plugin's base dir, the directory which will be used to |
|
474 |
* search resources. |
|
475 |
* |
|
476 |
* @return Returns the baseDir. |
|
477 |
*/ |
|
478 |
public String getBaseDir() { |
|
479 |
return baseDir.getAbsolutePath(); |
|
480 |
} |
|
481 |
|
|
482 |
/** |
|
483 |
* Adds other classloader to use when all the normal methods fail. |
|
484 |
* |
|
485 |
* @param classLoaders An ArrayList of ClassLoaders which will |
|
486 |
* be used to load classes when all the normal methods fail. |
|
487 |
*/ |
|
488 |
public static void addLoaders(ArrayList classLoaders) { |
|
489 |
otherLoaders.addAll(classLoaders); |
|
490 |
} |
|
491 |
} |
|
0 | 492 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/Extension.java | ||
---|---|---|
1 |
package org.gvsig.andami.plugins; |
|
2 |
|
|
3 |
import org.gvsig.andami.PluginsLocator; |
|
4 |
import org.gvsig.andami.plugins.status.IExtensionStatus; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004-2007 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.12 2007-09-17 06:33:34 caballero |
|
51 |
* unsaveddata |
|
52 |
* |
|
53 |
* Revision 1.11 2007/07/19 12:01:06 cesar |
|
54 |
* Add support for the new Andami termination process (and the unsaved data dialog) |
|
55 |
* |
|
56 |
* Revision 1.10 2007/05/31 07:42:17 cesar |
|
57 |
* Add ExclusiveUIExtension interface and clean the IExtension interface; update Extension, ExtensionDecorator and Launcher to reflect this change; add missing comments, translate existing ones to english |
|
58 |
* |
|
59 |
* Revision 1.9 2007/05/31 07:00:47 cesar |
|
60 |
* Add missing comments, translate existing ones to english |
|
61 |
* |
|
62 |
* Revision 1.8 2006/11/27 11:33:05 jmvivo |
|
63 |
* Soporte para que una clase tenga el control de la visibilidad y estado de las acciones del resto de extensiones. |
|
64 |
* |
|
65 |
* Revision 1.7 2006/09/15 10:39:18 caballero |
|
66 |
* multisplah y postInitialize |
|
67 |
* |
|
68 |
* Revision 1.6 2006/07/31 18:22:13 cesar |
|
69 |
* Rename finalize method to terminate method |
|
70 |
* |
|
71 |
* Revision 1.5 2006/05/02 15:53:06 jorpiell |
|
72 |
* Se ha cambiado la interfaz Extension por dos clases: una interfaz (IExtension) y una clase abstract(Extension). A partir de ahora todas las extensiones deben heredar de Extension |
|
73 |
* |
|
74 |
* |
|
75 |
*/ |
|
76 |
/** |
|
77 |
* Extensions are the way in which plugins extend Andami. Extensions |
|
78 |
* can add controls to user interface (GUI) and execute some code |
|
79 |
* when controls are activated. Every class implementing |
|
80 |
* {@link IExtension} is an extension, but directly implementing |
|
81 |
* that interface is discouraged. The preferred way to create |
|
82 |
* an extension is extending this absctract class. |
|
83 |
* |
|
84 |
* @see IExtension |
|
85 |
* |
|
86 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
87 |
*/ |
|
88 |
public abstract class Extension implements IExtension { |
|
89 |
|
|
90 |
/* |
|
91 |
* (non-Javadoc) |
|
92 |
* @see com.iver.andami.plugins.IExtension#terminate() |
|
93 |
*/ |
|
94 |
public void terminate(){ |
|
95 |
|
|
96 |
} |
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* @see com.iver.andami.plugins.IExtension#postInitialize() |
|
100 |
*/ |
|
101 |
public void postInitialize(){ |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* @see com.iver.andami.plugins.IExtension#getStatus() |
|
108 |
*/ |
|
109 |
public IExtensionStatus getStatus() { |
|
110 |
return null; |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* (non-Javadoc) |
|
115 |
* @see com.iver.andami.plugins.IExtension#getStatus(IExtension extension) |
|
116 |
*/ |
|
117 |
public IExtensionStatus getStatus(IExtension extension) { |
|
118 |
return extension.getStatus(); |
|
119 |
} |
|
120 |
|
|
121 |
public String getText(String msg) { |
|
122 |
return PluginsLocator.getManager().getText(this, msg); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
0 | 126 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/ExtensionDecorator.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins; |
|
42 |
|
|
43 |
import org.gvsig.andami.plugins.status.IExtensionStatus; |
|
44 |
|
|
45 |
|
|
46 |
/** |
|
47 |
* This class extends the functionality of Extension class to let the programmer |
|
48 |
* set an extension visible or not on-the-fly. |
|
49 |
* |
|
50 |
* @autor Jaume Dominguez Faus - jaume.dominguez@iver.es |
|
51 |
*/ |
|
52 |
public class ExtensionDecorator implements HiddableExtension{ |
|
53 |
public static final int INACTIVE = 0; |
|
54 |
public static final int ALWAYS_VISIBLE = 1; |
|
55 |
public static final int ALWAYS_INVISIBLE = 2; |
|
56 |
int alwaysVisible; |
|
57 |
IExtension extension; |
|
58 |
|
|
59 |
public ExtensionDecorator(IExtension e, int visibilityControl){ |
|
60 |
setExtension(e); |
|
61 |
setVisibility(visibilityControl); |
|
62 |
} |
|
63 |
|
|
64 |
public void setExtension(IExtension e) { |
|
65 |
this.extension = e; |
|
66 |
} |
|
67 |
|
|
68 |
public void setVisibility(int state){ |
|
69 |
this.alwaysVisible = state; |
|
70 |
} |
|
71 |
|
|
72 |
public int getVisibility(){ |
|
73 |
return alwaysVisible; |
|
74 |
} |
|
75 |
|
|
76 |
public IExtension getExtension(){ |
|
77 |
return extension; |
|
78 |
} |
|
79 |
|
|
80 |
public void initialize() { |
|
81 |
extension.initialize(); |
|
82 |
} |
|
83 |
|
|
84 |
public void terminate(){ |
|
85 |
//TODO |
|
86 |
} |
|
87 |
|
|
88 |
public void execute(String actionCommand) { |
|
89 |
extension.execute(actionCommand); |
|
90 |
} |
|
91 |
|
|
92 |
public boolean isEnabled() { |
|
93 |
return extension.isEnabled(); |
|
94 |
} |
|
95 |
|
|
96 |
public boolean isVisible() { |
|
97 |
if (alwaysVisible == INACTIVE) |
|
98 |
return extension.isVisible(); |
|
99 |
else if (alwaysVisible == ALWAYS_VISIBLE) return true; |
|
100 |
else return false; |
|
101 |
} |
|
102 |
|
|
103 |
public void postInitialize() { |
|
104 |
// TODO |
|
105 |
} |
|
106 |
|
|
107 |
/* (non-Javadoc) |
|
108 |
* @see com.iver.andami.plugins.IExtension#getStatus() |
|
109 |
*/ |
|
110 |
public IExtensionStatus getStatus() { |
|
111 |
return extension.getStatus(); |
|
112 |
} |
|
113 |
public IExtensionStatus getStatus(IExtension extension) { |
|
114 |
return this.extension.getStatus(extension); |
|
115 |
} |
|
116 |
} |
|
0 | 117 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/ExclusiveUIExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
package org.gvsig.andami.plugins; |
|
43 |
|
|
44 |
/** |
|
45 |
* Extensions implementing this interface are able to take control |
|
46 |
* over the user interface, by deciding which of the other extensions |
|
47 |
* will be enabled/disabled or visible/hidden. |
|
48 |
* |
|
49 |
* Besides implementing this interface, the extension needs to |
|
50 |
* be set as ExclusiveUIExtension during Andami startup process. |
|
51 |
* This is performed by providing a command line argument to |
|
52 |
* Andami: |
|
53 |
* <br> |
|
54 |
* <code>ExclusiveUIExtension=ExtensionName</code> |
|
55 |
* |
|
56 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> |
|
57 |
*/ |
|
58 |
public interface ExclusiveUIExtension extends IExtension { |
|
59 |
|
|
60 |
/** |
|
61 |
* This method is used when this extension is installed as |
|
62 |
* ExclusiveUIExtension. This extension will be asked for |
|
63 |
* each installed extension to determine which of them |
|
64 |
* should be enabled. |
|
65 |
* |
|
66 |
* @return true if the provided extension should be enabled, |
|
67 |
* false if it should be disabled. |
|
68 |
*/ |
|
69 |
public boolean isEnabled(IExtension extension); |
|
70 |
|
|
71 |
/** |
|
72 |
* This method is used when this extension is installed as |
|
73 |
* ExclusiveUIExtension. This extension will be asked for |
|
74 |
* each installed extension to determine which of them |
|
75 |
* should be visible. |
|
76 |
* |
|
77 |
* @return true if the provided extension should be visible, |
|
78 |
* false if it should be hidden. |
|
79 |
*/ |
|
80 |
public boolean isVisible(IExtension extension); |
|
81 |
} |
|
0 | 82 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/status/IExtensionStatus.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins.status; |
|
42 |
|
|
43 |
import org.gvsig.andami.plugins.IExtension; |
|
44 |
import org.gvsig.utils.swing.threads.IMonitorableTask; |
|
45 |
|
|
46 |
|
|
47 |
/** |
|
48 |
* <p>This interface provides a framework to query the status of |
|
49 |
* extensions. By default, the interface provides methods to check |
|
50 |
* if the extension has some unsaved data (and save them), and methods |
|
51 |
* to check if the extension has some associated background tasks. |
|
52 |
* However, additional aspects can be included in the status by extending |
|
53 |
* this interface.</p> |
|
54 |
* |
|
55 |
* <p>Each extension will have an associated IExtensionStatus object, which |
|
56 |
* can be used at any time to check the status. This is specially useful |
|
57 |
* during the Andami termination process, to check if there are unfinished |
|
58 |
* tasks which should be attended before exiting.</p> |
|
59 |
* |
|
60 |
* @see IUnsavedData |
|
61 |
* @see UnsavedData |
|
62 |
* @see IExtension |
|
63 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> |
|
64 |
* |
|
65 |
*/ |
|
66 |
public interface IExtensionStatus { |
|
67 |
/** |
|
68 |
* This method is used to check if the extension has some unsaved data. |
|
69 |
* For example, if the project has been modified, or there is a layer in |
|
70 |
* edition mode. |
|
71 |
* |
|
72 |
* @return true if the extension has some unsaved data, false otherwise. |
|
73 |
*/ |
|
74 |
public boolean hasUnsavedData(); |
|
75 |
|
|
76 |
/** |
|
77 |
* <p>Gets an array of the UnsavedData objects, which contain information about |
|
78 |
* the unsaved data and allows to save it.</p> |
|
79 |
* |
|
80 |
* @return An array of the associated unsaved data, or null in case the extension |
|
81 |
* has not unsaved data. |
|
82 |
*/ |
|
83 |
public IUnsavedData[] getUnsavedData(); |
|
84 |
|
|
85 |
/** |
|
86 |
* This method is used to check if the extension has some associated |
|
87 |
* background process which is currently running. |
|
88 |
* |
|
89 |
* @return true if the extension has some associated background process, |
|
90 |
* false otherwise. |
|
91 |
*/ |
|
92 |
public boolean hasRunningProcesses(); |
|
93 |
|
|
94 |
|
|
95 |
/** |
|
96 |
* <p>Gets an array of the traceable background tasks associated with this |
|
97 |
* extension. These tasks may be tracked, canceled, etc.</p> |
|
98 |
* |
|
99 |
* @return An array of the associated background tasks, or null in case there is |
|
100 |
* no associated background tasks. |
|
101 |
*/ |
|
102 |
public IMonitorableTask[] getRunningProcesses(); |
|
103 |
|
|
104 |
//public IStatusGUI getGUI(); |
|
105 |
} |
|
0 | 106 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/status/UnsavedData.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins.status; |
|
42 |
|
|
43 |
import javax.swing.ImageIcon; |
|
44 |
|
|
45 |
import org.gvsig.andami.plugins.IExtension; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Abstract class implementing IUnsavedData. is a convenience |
|
50 |
* class used to allow easier modifications of IUnsaveData |
|
51 |
* interface. |
|
52 |
* |
|
53 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> |
|
54 |
* |
|
55 |
*/ |
|
56 |
public abstract class UnsavedData implements IUnsavedData { |
|
57 |
|
|
58 |
/** |
|
59 |
* This UnsavedData object is associated to this extension. |
|
60 |
*/ |
|
61 |
private IExtension ext; |
|
62 |
|
|
63 |
/** |
|
64 |
* Creates a new UnsavedData object which will be associated to |
|
65 |
* the provided extension. |
|
66 |
* |
|
67 |
* @param extension |
|
68 |
*/ |
|
69 |
public UnsavedData(IExtension extension) { |
|
70 |
ext = extension; |
|
71 |
} |
|
72 |
|
|
73 |
/* (non-Javadoc) |
|
74 |
* @see com.iver.andami.plugins.status.IUnsavedData#getDescription() |
|
75 |
*/ |
|
76 |
public abstract String getDescription() ; |
|
77 |
|
|
78 |
/* (non-Javadoc) |
|
79 |
* @see com.iver.andami.plugins.status.IUnsavedData#getExtension() |
|
80 |
*/ |
|
81 |
public IExtension getExtension() { |
|
82 |
return ext; |
|
83 |
} |
|
84 |
|
|
85 |
/* (non-Javadoc) |
|
86 |
* @see com.iver.andami.plugins.status.IUnsavedData#getIcon() |
|
87 |
*/ |
|
88 |
public String getIcon() { |
|
89 |
return null; |
|
90 |
} |
|
91 |
|
|
92 |
/* (non-Javadoc) |
|
93 |
* @see com.iver.andami.plugins.status.IUnsavedData#getResourceName() |
|
94 |
*/ |
|
95 |
public abstract String getResourceName(); |
|
96 |
|
|
97 |
/* (non-Javadoc) |
|
98 |
* @see com.iver.andami.plugins.status.IUnsavedData#saveData() |
|
99 |
*/ |
|
100 |
public abstract boolean saveData(); |
|
101 |
|
|
102 |
} |
|
0 | 103 |
tags/v2_0_0_Build_2030/frameworks/_fwAndami/src/org/gvsig/andami/plugins/status/IUnsavedData.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.andami.plugins.status; |
|
42 |
|
|
43 |
import javax.swing.ImageIcon; |
|
44 |
|
|
45 |
import org.gvsig.andami.plugins.IExtension; |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* <p>This interface represents some unsaved data, associated to one extension. |
|
51 |
* There are methods to get the associated extension, to get info about these |
|
52 |
* data, to get the type of the data and a suitable icon for this type, |
|
53 |
* and a method to save the data.</p> |
|
54 |
* |
|
55 |
* <p>It is used during the Andami termination process, to construct the |
|
56 |
* dialog of unsaved data, although it can be used at any time.</p> |
|
57 |
* |
|
58 |
* <p>Normally, it should not be directly implemented, use the convenience |
|
59 |
* UnsavedData class.</p> |
|
60 |
* |
|
61 |
* @see IExtensionStatus |
|
62 |
* @see UnsavedData |
|
63 |
* @see IExtension |
|
64 |
* @author Cesar Martinez Izquierdo <cesar.martinez@iver.es> |
|
65 |
*/ |
|
66 |
public interface IUnsavedData { |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets the resource name of this unsaved data. Normally, this will be |
|
70 |
* a file path, but it may be different for certain type of unsaved data |
|
71 |
* (for example, database connections). |
|
72 |
* |
|
73 |
* @return The resource name of this unsaved data |
|
74 |
*/ |
|
75 |
public String getResourceName(); |
|
76 |
|
|
77 |
/** |
|
78 |
* <p>Gets a description of this unsaved data. This would be combined with the |
|
79 |
* resource name to show a coherent information to the user.</p> |
|
80 |
* |
|
81 |
* <p>Examples of descriptions: |
|
82 |
* <ul><li>Modified SHP Layer</li> |
|
83 |
* <li>Modified gvSIG project</li> |
|
84 |
* </ul> |
|
85 |
* |
|
86 |
* @return A description for this unsaved data, probably containing the type |
|
87 |
* of data and the kind of modification. |
|
88 |
*/ |
|
89 |
public String getDescription(); |
|
90 |
|
|
91 |
/** |
|
92 |
* <p>Save the existing changes for this resource (for example, save the layer |
|
93 |
* to disk or to the database, etc). The resource should not be closed at this |
|
94 |
* point (files, database connections, etc should no be closed), as they may |
|
95 |
* be still needed by other extensions. Resources should be closed at |
|
96 |
* {@link IExtension#terminate()}.</p> |
|
97 |
* |
|
98 |
* @return true if the data was correctly saved, false if it was not saved |
|
99 |
* (there are many reasons for this: there was an error, the user cancelled |
|
100 |
* the process, etc). |
Also available in: Unified diff