Revision 15994

View differences:

tags/tmp_build/frameworks/_fwAndami/log4j.properties
1
log4j.rootLogger=DEBUG, stdout
2

  
3
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5

  
6
# Pattern to output the caller's file name and line number.
7
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
8

  
0 9

  
tags/tmp_build/frameworks/_fwAndami/.cvsignore
1
bin
2
gvsig.log
3
gvSIG
4
web
5
andami.jar
6
keystore
7
java.hprof.txt
8
build-doc
9
*.log
10
cachedir
11
bin-test
0 12

  
tags/tmp_build/frameworks/_fwAndami/schemas/andami-config.xml
1
<andami-config locale-language="es" locale-country="ES" locale-variant="es" pluginsDirectory="c:\tirar">
2
	<andami update="yes"/>
3
	<plugin name="com.iver.cit.gvsig" update="yes"/>
4
	<plugin name="com.iver.core" update="no"/>
5
	<andami-options>
6
	  <option name="CustomOption1" value="customValue1"/>
7
	  <icon-theme name="DefaultTheme" resource="iconThemes/default" basedir="iconThemes" />
8
	</andami-options>
9
</andami-config>
0 10

  
tags/tmp_build/frameworks/_fwAndami/schemas/sample-plugins-persistence.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugins-status>
3
	<plugin name="gvsig" lastUpdate="237628686">
4
		<xml-entity name="config">
5
			<property name="dataDirectory" value="c:\"/>
6
			<xml-entity>
7
				<property name="dataDirectory" value="c:\"/>
8
				<property name="dataDirectory" value="c:\"/>
9
				<property name="dataDirectory" value="c:\"/>
10
			</xml-entity>
11
		</xml-entity>
12
		<bookmarks>
13
			<bookmark text="Recientes/raster">
14
				<xml-entity>
15
					<property name="projection" value="EPSG:3403"/>
16
					<property name="boundinBox" value="12,12,115,115"/>
17
				</xml-entity>
18
			</bookmark>
19
		</bookmarks>
20
		<windows>
21
			<window id="0" rectangle="0,0,150,150"/>
22
			<window id="2" rectangle="50,50,150,150"/>
23
			<window id="8" rectangle="100,100,150,150"/>
24
			<window id="12" rectangle="150,150,150,150"/>
25
		</windows>
26
	</plugin>
27
	<tool-bars>
28
		<tool-bar name="gvsig.herramientas" x-position="0" y-position="1"/>
29
		<tool-bar name="gvsig.herramientas" x-position="0" y-position="0"/>
30
	</tool-bars>
31
</plugins-status>
0 32

  
tags/tmp_build/frameworks/_fwAndami/schemas/sample-config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<icon src="images/logoGVA.gif" text="gvSIG"/>
4
	<resourceBundle name="text"/>
5
	<import plugin-name="com.iver.cit.gvsig" />
6
	<labelSet class="com.iver.cit.gvsig.gui.View">
7
		<label id="1" size="100"/>
8
		<label id="2" size="230"/>
9
	</labelSet>
10
	<libraries>
11
		<library file="com.iver.cit.gvsig.jar"/>
12
		<library file="wmsclient.jar"/>	
13
	</libraries>
14
	<extensions>
15
		<extension>
16
			<class name="com.iver.cit.gvsig.ProjectExtension"/>
17
			<menu text="Archivo/nuevo_proyecto" 
18
				key="n" mnemonic="n" 
19
				tooltip="nuevo_tooltip"
20
				action-command="NUEVO" icon="images/new.png"/>
21
			<menu text="Archivo/abrir_proyecto" 
22
				key="a" mnemonic="a" 
23
				tooltip="abrir_tooltip"
24
				action-command="ABRIR" icon="images/open.png"/>
25
			<menu text="Archivo/guardar_proyecto" 
26
				key="g" mnemonic="g" 
27
				tooltip="guardar_tooltip"
28
				action-command="GUARDAR" icon="images/save.png"/>
29

  
30
			<toolBar>
31
				<tool icon="images/new.png" tooltip="nuevo_tooltip"
32
					action-command="NUEVO"/>
33
				<tool icon="images/open.png" tooltip="abrir_tooltip"
34
					action-command="ABRIR"/>
35
				<tool icon="images/save.png" tooltip="guardar_tooltip"
36
					action-command="GUARDAR"/>
37

  
38
				<!-- these will be added to the containing toolbar -->
39
				<combo-scale
40
					name="JPEG Quality"
41
					elements="15;30;60;70;80;90;100"
42
					value="80"
43
					action-command="JPEG_QUALITY" />
44

  
45
				<combo-button
46
					name="Copy/paste tools">
47
				  <combo-button-element icon="images/scissor.png" action-command="CUT" />
48
				  <combo-button-element icon="images/paste.png" action-command="PASTE" />
49
				  <combo-button-element icon="images/copy.png" action-command="COPY" />
50
				</combo-button>
51
			</toolBar>
52

  
53
		</extension>
54

  
55
		<extension>
56
			<class name="com.iver.cit.gvsig.ZoomPrev"/>
57
			<menu text="Vista/Zoom_Previo" icon="images/ZoomPrevio.png"/>
58
			<tool-bar name="Herramientas">
59
				<action-tool icon="images/ZoomPrevio.png" action-command="ZOOM_PREV" tooltip="Zoom_Previo" position="11"/>
60
			</tool-bar>
61
			
62
			<!-- these will be added to the status-bar (because they are not contained in any toolbar) -->					
63
			<combo-scale 
64
		  		name="Scale"
65
		  		label="Scale:"
66
		  		elements="1000;2000;5000;10000;25000;50000;100000;200000;500000;1000000;2000000;5000000"
67
	  			value="10000"
68
	  			action-command="CHANGE_SCALE" />
69

  
70
			<combo-button
71
				name="Tool Mode">
72
			  <combo-button-element icon="images/once.png" action-command="USE_ONCE" />
73
			  <combo-button-element icon="images/sticky-tool.png" action-command="UNTIL_CHANGED" />
74
			</combo-button>
75
		</extension>
76
		<extension processing-position="2">
77
			<class name="com.iver.cit.gvsig.ViewControls"/>
78
			<menus>
79
				<menu text="Vista/Zoom_Completo" action-command="FULL" icon="images/MapContents.png" tooltip="Zoom completo a la v?sta"/>
80
				<menu text="Vista/Zoom_Select" action-command="ZOOM_SELECT" icon="image/Select.png"/>
81
				<menu text="Vista/Encuadre" action-command="ENCUADRE" icon="images/encuadre.png"/>
82
				<menu text="Vista/Seleccion_por_tema" action-command="SELECTIONBYSHAPE"/>
83
				<menu text="Vista/configurar_localizador" action-command="CONFIG_LOCATOR"/>		
84
				<menu text="Vista/propiedades" action-command="PROPERTIES"/>
85
			</menus>
86
			<tool-bar name="Herramientas" y-position="1">
87
				<action-tool icon="images/MapContents.png" action-command="FULL" tooltip="Zoom_Completo" position="1"/>
88
				<action-tool icon="images/encuadre.png" action-command="ENCUADRE" tooltip="gestion_encuadre" last="true" position="2"/>			
89
				<selectable-tool group="grupo1" default="true" icon="images/ZoomIn.png" action-command="ZOOM_IN" tooltip="Zoom_M?s" position="3"/>
90
				<selectable-tool group="grupo1" icon="images/ZoomOut.png" action-command="ZOOM_OUT" position="4"/>
91
				<selectable-tool group="grupo1" icon="images/Pan.png" action-command="PAN"  tooltip="Encuadre" position="5"/>
92
				<selectable-tool group="grupo1" icon="images/Identify.png" action-command="INFO"  tooltip="informacion" position="6" />
93
				<selectable-tool group="grupo2" icon="images/Distancia.png" action-command="MEDICION"  tooltip="medir_distancias" position="7"/>
94
				<selectable-tool group="grupo2" icon="images/Poligono16.png" action-command="AREA"  tooltip="medir_area" position="8"/>
95
				<selectable-tool group="grupo2" default="true" icon="images/Select.png" action-command="SELPOINT"  tooltip="seleccionar_por_punto" position="9"/>
96
				<selectable-tool group="grupo2" icon="images/SelEspacial2b.png" action-command="SELRECT"  tooltip="seleccionar_por_rectangulo" position="10"/>
97
			</tool-bar>
98
		</extension>
99
		<extension>
100
			<class name="com.iver.cit.gvsig.ThemeControls"/>
101
			<menu text="Tema/propiedades"/>
102
		</extension>
103
	</extensions>
104

  
105
	<file-extensions>
106
		<file-extension description="DGNfiles" ends-with="dgn" dialog="openLayer">
107
			<class name="com.iver.cit.gvsig.DGNFileExtension"/>
108
		</file-extension>
109
		<file-extension description="Rasterfiles" ends-with="ecw,tif,tiff,jpg,png" dialog="openLayer">
110
			<class name="com.iver.cit.gvsig.RasterFileExtension"/>
111
		</file-extension>
112
	</file-extensions>
113
</plugin-config>
0 114

  
tags/tmp_build/frameworks/_fwAndami/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>_fwAndami</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
15
			<triggers>full,incremental,</triggers>
16
			<arguments>
17
				<dictionary>
18
					<key>LaunchConfigHandle</key>
19
					<value>&lt;project&gt;/.externalToolBuilders/Ant.launch</value>
20
				</dictionary>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>de.loskutov.FileSync.FSBuilder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
	</buildSpec>
29
	<natures>
30
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
31
		<nature>org.eclipse.jdt.core.javanature</nature>
32
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
33
	</natures>
34
</projectDescription>
0 35

  
tags/tmp_build/frameworks/_fwAndami/gvSIG.bat
1
d:
2
cd d:\eclipse\workspace\fwAndami
3
java -cp andami.jar;lib/beans.jar;./lib/castor-0.9.5.3-xml.jar;./lib/crimson.jar;./lib/gvsig-i18n.jar;./lib/iver-utiles.jar;./lib/javaws.jar;lib/JWizardComponent.jar;./lib/log4j-1.2.8.jar;lib/looks-2.0.2.jar;./lib/xerces_2_5_0.jar;./lib/xml-apis.jar -Xmx500M com.iver.andami.Launcher gvSIG gvSIG/extensiones %1
0 4

  
tags/tmp_build/frameworks/_fwAndami/castor.properties
1
org.exolab.castor.indent=true
0 2

  
tags/tmp_build/frameworks/_fwAndami/src/log4j.properties
1
log4j.rootLogger=debug, stdout
2

  
3
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5

  
6
# Pattern to output the caller's file name and line number.
7
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
8

  
0 9

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/Utilities.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-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 com.iver.andami;
42

  
43
import java.awt.Component;
44
import java.awt.Container;
45
import java.io.BufferedInputStream;
46
import java.io.BufferedOutputStream;
47
import java.io.DataOutputStream;
48
import java.io.File;
49
import java.io.FileOutputStream;
50
import java.io.IOException;
51
import java.io.InputStream;
52
import java.io.OutputStream;
53
import java.net.ConnectException;
54
import java.net.MalformedURLException;
55
import java.net.URL;
56
import java.net.UnknownHostException;
57
import java.util.Enumeration;
58
import java.util.Hashtable;
59
import java.util.zip.ZipEntry;
60
import java.util.zip.ZipException;
61
import java.util.zip.ZipFile;
62

  
63
import javax.swing.ImageIcon;
64
import javax.swing.RootPaneContainer;
65

  
66
import org.apache.log4j.Logger;
67

  
68
import com.iver.andami.ui.mdiManager.IWindow;
69
import com.iver.andami.ui.splash.MultiSplashWindow;
70

  
71

  
72

  
73
/**
74
 * This class offers several general purpose method, to perform common
75
 * tasks in an easy way.
76
 *
77
 * @version $Revision$
78
 */
79
public class Utilities {
80
	/**
81
     * <b>key</b>: URL, <b>value</b>: path to the downloaded file.
82
     */
83
    private static Hashtable downloadedFiles;
84
    /** DOCUMENT ME! */
85
    private static Logger logger = Logger.getLogger(Utilities.class.getName());
86
	public static final String TEMPDIRECTORYPATH = System.getProperty("java.io.tmpdir")+"/tmp-andami";
87

  
88

  
89
    /**
90
     * Creates an icon from an image path.
91
     *
92
     * @param path Path to the image to be loaded
93
     *
94
     * @return ImageIcon if the image is found, null otherwise
95
     */
96
    public static ImageIcon createImageIcon(String path) {
97
        URL imgURL = null;
98

  
99
        try {
100
            imgURL = new URL("file:" + path);
101
        } catch (MalformedURLException e) {
102
            e.printStackTrace();
103
        }
104

  
105
        if (imgURL != null) {
106
            return new ImageIcon(imgURL);
107
        } else {
108
            return null;
109
        }
110
    }
111

  
112
    /**
113
     * Method which frees the memory from JInternalFrames
114
     *
115
     * @param baseComponent JInternalFrame whose memory is to be
116
     * freed
117
     */
118
    public static void cleanComponent(Component baseComponent) {
119
        try {
120
            cleanComponent(baseComponent, 0);
121
        } catch (Exception ignore) { // give some exception handling...
122
        }
123
    }
124

  
125
    /*    * The "depth" parameter was being used for text output debugging.    * But isn't essential now.  I'll keep it anyways, as it avoids    * calling the garbage collector every recursion.    */
126
    protected static void cleanComponent(Component baseComponent, int depth) {
127
        if (baseComponent == null) // recursion terminating clause
128
         {
129
            return;
130
        }
131

  
132
        if (baseComponent instanceof IWindow){
133
        	return;
134
        }
135

  
136
        Container cont;
137
        Component[] childComponents;
138
        int numChildren; // clean up component containers
139

  
140
        if (baseComponent instanceof Container) { // now clean up container instance variables
141

  
142
            if (baseComponent instanceof RootPaneContainer) { // Swing specialised container
143
                cont = (Container) baseComponent;
144
                numChildren = cont.getComponentCount();
145
                childComponents = cont.getComponents();
146

  
147
                for (int i = 0; i < numChildren; i++) { // remove each component from the current container
148

  
149
                    // each child component may be a container itself
150
                    cleanComponent(childComponents[i], depth + 1);
151
                    ((RootPaneContainer) cont).getContentPane().remove(childComponents[i]);
152
                }
153

  
154
                ((RootPaneContainer) cont).getContentPane().setLayout(null);
155
            } else { // General Swing, and AWT, Containers
156
                cont = (Container) baseComponent;
157
                numChildren = cont.getComponentCount();
158
                childComponents = cont.getComponents();
159

  
160
                for (int i = 0; i < numChildren; i++) //for(int i = 0;i < numChildren;i++)
161
                 {
162
                    // remove each component from the current container                    // each child component may be a container itself
163
                    cleanComponent(childComponents[i], depth + 1);
164
                    cont.remove(childComponents[i]);
165
                }
166

  
167
                cont.setLayout(null);
168
            }
169
        }
170

  
171
        // if component is also a container
172
    }
173

  
174

  
175

  
176
    /**
177
     * Extracts a ZIP file in the provided directory
178
     *
179
     * @param file Compressed file
180
     * @param dir Directory to extract the files
181
     * @param splash The splash window to show the extraction progress
182
     *
183
     * @throws ZipException If there is some problem in the file format
184
     * @throws IOException If there is a problem reading the file
185
     */
186
    public static void extractTo(File file, File dir, MultiSplashWindow splash)
187
        throws ZipException, IOException {
188
        ZipFile zip = new ZipFile(file);
189
        Enumeration e = zip.entries();
190

  
191
		// Pasada para crear las carpetas
192
		while (e.hasMoreElements()) {
193
			ZipEntry entry = (ZipEntry) e.nextElement();
194

  
195
			if (entry.isDirectory()) {
196
				File directorio = new File(dir.getAbsolutePath()
197
						+ File.separator + entry.getName());
198

  
199
				directorio.mkdirs();
200
			}
201

  
202
    		}
203

  
204
		// Pasada para crear los ficheros
205
		e = zip.entries();
206
		while (e.hasMoreElements()) {
207
			ZipEntry entry = (ZipEntry) e.nextElement();
208
			splash.process(30, "Procesando " + entry.getName() + "...");
209
			if (!entry.isDirectory()) {
210
				InputStream in = zip.getInputStream(entry);
211
				OutputStream out = new FileOutputStream(dir + File.separator
212
						+ entry.getName());
213
				BufferedInputStream bin = new BufferedInputStream(in);
214
				BufferedOutputStream bout = new BufferedOutputStream(out);
215

  
216
				int i;
217

  
218
				while ((i = bin.read()) != -1) {
219
					bout.write(i);
220
				}
221

  
222
				bout.flush();
223
				bout.close();
224
				bin.close();
225

  
226
			}
227

  
228
		}
229

  
230
		zip.close();
231
		zip = null;
232
		System.gc();
233

  
234
	}
235
    /**
236
     * Returns the content of this URL as a file from the file system.<br>
237
     * <p>
238
     * If the URL has been already downloaded in this session and notified
239
     * to the system using the static <b>Utilities.addDownloadedURL(URL)</b>
240
     * method, it can be restored faster from the file system avoiding to
241
     * download it again.
242
     * </p>
243
     * @param url
244
     * @return File containing this URL's content or null if no file was found.
245
     */
246
    private static File getPreviousDownloadedURL(URL url){
247
        File f = null;
248
        if (downloadedFiles!=null && downloadedFiles.containsKey(url)){
249
            String filePath = (String) downloadedFiles.get(url);
250
            f = new File(filePath);
251
        }
252
        return f;
253
    }
254

  
255
    /**
256
     * Adds an URL to the table of downloaded files for further uses. If the URL
257
     * already exists in the table its filePath value is updated to the new one and
258
     * the old file itself is removed from the file system.
259
     *
260
     * @param url
261
     * @param filePath
262
     */
263
    private static void addDownloadedURL(URL url, String filePath){
264
        if (downloadedFiles==null)
265
            downloadedFiles = new Hashtable();
266
        String fileName = (String) downloadedFiles.put(url, filePath);
267
        //JMV: No se puede eliminar el anterior porque puede que alguien lo
268
        // este usando
269
        /*
270
        if (fileName!=null){
271
            File f = new File(fileName);
272
            if (f.exists())
273
                f.delete();
274
        }
275
        */
276
    }
277

  
278
    /**
279
     * Downloads an URL into a temporary file that is removed the next time the
280
     * tempFileManager class is called, which means the next time gvSIG is launched.
281
     *
282
     * @param url
283
     * @param name
284
     * @return
285
     * @throws IOException
286
     * @throws ServerErrorResponseException
287
     * @throws ConnectException
288
     * @throws UnknownHostException
289
     */
290
    public static File downloadFile(URL url, String name) throws IOException,ConnectException, UnknownHostException{
291
    	File f = null;
292

  
293
	    try{
294
	        if ((f=getPreviousDownloadedURL(url))==null){
295
	        	File tempDirectory = new File(TEMPDIRECTORYPATH);
296
	        	if (!tempDirectory.exists())
297
	        		tempDirectory.mkdir();
298

  
299
	        	f = new File(TEMPDIRECTORYPATH+"/"+name+System.currentTimeMillis());
300

  
301
	            System.out.println("downloading '"+url.toString()+"' to: "+f.getAbsolutePath());
302

  
303
	            f.deleteOnExit();
304
                DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)));
305
                byte[] buffer = new byte[1024*256];
306
                InputStream is = url.openStream();
307
                long readed = 0;
308
                for (int i = is.read(buffer); i>0; i = is.read(buffer)){
309
                    dos.write(buffer, 0, i);
310
                    readed += i;
311
                }
312
                dos.close();
313
                addDownloadedURL(url, f.getAbsolutePath());
314
	        }
315
	    } catch (IOException io) {
316
	    	io.printStackTrace();
317
	    }
318

  
319
	    return f;
320
	}
321

  
322
    /**
323
     * Cleans every temporal file previously downloaded.
324
     */
325
    public static void cleanUpTempFiles() {
326
    	try{
327
    		File tempDirectory = new File(TEMPDIRECTORYPATH);
328

  
329
    		File[] files = tempDirectory.listFiles();
330
    		if (files!=null) {
331
    			for (int i = 0; i < files.length; i++) {
332
    				 // s?lo por si en un futuro se necesitan crear directorios temporales
333
    				if (files[i].isDirectory())	deleteDirectory(files[i]);
334
    				files[i].delete();
335
    			}
336
    		}
337
    		tempDirectory.delete();
338
    	} catch (Exception e) {	}
339

  
340
    }
341
    /**
342
     * Recursive directory delete.
343
     * @param f
344
     */
345
	private static void deleteDirectory(File f) {
346
		File[] files = f.listFiles();
347
		for (int i = 0; i < files.length; i++) {
348
			if (files[i].isDirectory()) deleteDirectory(files[i]);
349
			files[i].delete();
350
		}
351

  
352
	}
353

  
354
    /**
355
     * Creates a temporary file with a the provided name and data. The file
356
     * will be automatically deleted when the application exits. 
357
     * 
358
     * @param fileName Name of the temporary file to create
359
     * @param data The data to store in the file
360
     */
361
    public static File createTemp(String fileName, String data)throws IOException{
362
    	File f = new File(fileName);
363
    	DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f)) );
364
		dos.writeBytes(data);
365
		dos.close();
366
    	f.deleteOnExit();
367
    	return f;
368
    }
369

  
370
    /**
371
     * Remove an URL from the system cache. The file will remain in the file
372
     * system for further eventual uses.
373
     * @param request
374
     */
375
	public static void removeURL(URL url) {
376
		if (downloadedFiles != null && downloadedFiles.containsKey(url))
377
			downloadedFiles.remove(url);
378
	}
379
	
380
	/**
381
	 * Creates the directory for temporary files, and returns the path of
382
	 * this directory. If the directory already exists, it just returns
383
	 * its path. Any file or directory created in this special directory
384
	 * will be delete when the application finishes.
385
	 * 
386
	 * @return An String containing the full path to the temporary directory
387
	 */
388
	public static String createTempDirectory(){
389
		File tempDirectory = new File(TEMPDIRECTORYPATH);
390
    	if (!tempDirectory.exists())
391
    		tempDirectory.mkdir();
392
    	return TEMPDIRECTORYPATH;
393
	}
394
}
0 395

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/fonts/FontUtils.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 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 com.iver.andami.ui.fonts;
42

  
43
import java.awt.Font;
44
import java.awt.GraphicsEnvironment;
45
import java.util.HashSet;
46
import java.util.Iterator;
47
import java.util.Locale;
48

  
49
import javax.swing.UIManager;
50

  
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.messages.Messages;
53

  
54
/**
55
 * Several methods to manage the user interface fonts.
56
 * 
57
 * @author Cesar Martinez Izquierdo <cesar.martinez@iver.es>
58
 *
59
 */
60
public class FontUtils {
61
	
62
	/**
63
	 * Changes the default UIManager font to the provided font.
64
	 * 
65
	 * @param fontName
66
	 */
67
	public static void setFont(String fontName) {
68
		String[] fieldList = {
69
				"Button.font",
70
				"CheckBox.font",
71
				"CheckBoxMenuItem.font",
72
				"ColorChooser.font",
73
				"ComboBox.font",
74
				"DesktopIcon.font",
75
				"EditorPane.font",
76
				"FormattedTextField.font",
77
				"Label.font",
78
				"List.font",
79
				"Menu.font",
80
				"MenuBar.font",
81
				"MenuItem.font",
82
				"OptionPane.font",
83
				"Panel.font",
84
				"PasswordField.font",
85
				"PopupMenu.font",
86
				"ProgressBar.font",
87
				"RadioButton.font",
88
				"RadioButtonMenuItem.font",
89
				"ScrollPane.font",
90
				"Slider.font",
91
				"Spinner.font",
92
				"TabbedPane.font",
93
				"Table.font",
94
				"TableHeader.font",
95
				"TextArea.font",
96
				"TextField.font",
97
				"TextPane.font",
98
				"TitledBorder.font",
99
				"ToggleButton.font",
100
				"ToolBar.font",
101
				"ToolTip.font",
102
				"Tree.font",
103
				"Viewport.font"
104
		} ;
105
		
106
		Font font;
107
		
108
		for (int i = fieldList.length-1; i>=0; i--) {
109
			font = UIManager.getFont(fieldList[i]);
110
			if (font!=null)
111
				UIManager.put(fieldList[i], new Font(fontName, Font.PLAIN, font.getSize()));
112
		}
113
	}
114
	
115
	/**
116
	 * Inits the UIManager fonts, so that it can display current's language
117
	 * symbols. The font is only changed when necessary.
118
	 */
119
	public static void initFonts() {
120
		// conservative behaviour: we just change the font, if the default one
121
		// can't correctly display the current language
122
		Font defaultFont = UIManager.getFont("Label.font");
123
		if (defaultFont==null) return;
124
		if (defaultFont.canDisplayUpTo(Messages.getString("MDIFrame.quiere_salir"))==-1) {
125
			PluginServices.getLogger().info("Fonts configuration was not necessary");
126
			//listSystemFonts();
127
			return;			
128
		}
129

  
130
		
131
		Font[] allfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
132
		HashSet workingFonts = new HashSet();
133
		
134
		for (int i=allfonts.length-1; i>=0; i--) {			
135
			if (allfonts[i].canDisplayUpTo(Messages.getString("MDIFrame.quiere_salir"))==-1) {
136
				workingFonts.add(allfonts[i].getName());
137
			}
138
		}
139
		
140
		// try to set the preferred font
141
		String[] preferredFonts = getPreferedFonts(Locale.getDefault().getLanguage());
142
		for (int i=0;i<preferredFonts.length; i++) {
143
			if (workingFonts.contains(preferredFonts[i])){
144
				setFont(preferredFonts[i]);
145
				PluginServices.getLogger().info("FontSet: "+preferredFonts[i]);
146
				return;
147
			}
148
		}
149
		
150
		// try to set any working font
151
		Iterator iterator = workingFonts.iterator();
152
		
153
		if (iterator.hasNext()) {
154
			String fontName = (String) iterator.next();
155
			setFont(fontName);
156
			PluginServices.getLogger().info("FontSet: "+fontName);	
157
		}
158
	}
159
	
160
	/**
161
	 * Returns an ordered list of preferred fonts for the provided language.
162
	 * As there is several fonts which can be used to display each language,
163
	 * this list provides a hint about which is the more suitable font for
164
	 * this language.
165
	 * 
166
	 * This method does not check whether the fonts are available in the
167
	 * running system.
168
	 * 
169
	 * @param lang
170
	 * @return
171
	 */
172
	private static String [] getPreferedFonts(String lang) {
173
		//TODO this should be read from a file, for each language
174
		if (lang.equals("zh")) {
175
			String []preferredChineseFonts = {
176
					"AR PL KaitiM GB",
177
					"AR PL SungtiL GB",
178
					"Kochi Gothic",
179
					"SimSun"
180
			} ;
181
			return preferredChineseFonts;
182
		}
183
		return new String[0];
184
	}
185
	
186
	private static void listSystemFonts() {
187
		Font[] allfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
188

  
189
		for (int i=allfonts.length-1; i>=0; i--) {
190
			System.out.println(allfonts[i].getName()+" --- "+allfonts[i].getFontName());
191
		}
192
	}
193
}
0 194

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/splash/MultiSplashWindow.java
1

  
2
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib��ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42

  
43
package com.iver.andami.ui.splash;
44

  
45
import java.awt.BorderLayout;
46
import java.awt.Color;
47
import java.awt.Dimension;
48
import java.awt.Font;
49
import java.awt.Frame;
50
import java.awt.Graphics;
51
import java.awt.Point;
52
import java.awt.Toolkit;
53
import java.awt.event.MouseEvent;
54
import java.awt.event.MouseListener;
55

  
56
import javax.swing.BorderFactory;
57
import javax.swing.ImageIcon;
58
import javax.swing.JLabel;
59
import javax.swing.JProgressBar;
60
import javax.swing.JWindow;
61

  
62
import com.iver.andami.PluginServices;
63
import com.iver.andami.messages.Messages;
64
import com.iver.andami.ui.theme.Theme;
65

  
66

  
67
public class MultiSplashWindow extends JWindow implements TimerCallBack,
68
    MouseListener {
69
    private static final long serialVersionUID = 572592158521767258L;
70
    private JProgressBar pb;
71
    private JLabel lblStatus;
72
    private Timer timer;
73
    private int numLogos = 0;
74
    private ImageIcon[] img = null;
75
    private Dimension splashDimension;
76
    private int index = 0;
77
    private int current;
78
    private int lastIndex = -1;
79
    private Theme theme;
80
    private long[] timers;
81

  
82
    private String version="";
83
    private String[] versions=null;
84
    private Point point=new Point(270,240);
85
    private Point[] points=null;
86
    private int fontsize=18;
87
    private int[] fontSizes=null;
88
    private Color fontcolor=new Color(80,170,240);
89
    private Color[] fontColors=null;
90

  
91
    public MultiSplashWindow(Frame f, Theme theme, int progressBarStepCount) {
92
        super(f);
93
        this.theme = theme;
94
        this.timers = theme.getTimers();
95
        lblStatus = new JLabel(Messages.getString("SplashWindow.Iniciando"));
96
        lblStatus.setBorder(BorderFactory.createEtchedBorder());
97
        lblStatus.setBackground(Color.WHITE);
98

  
99
        pack();
100
        pb = new JProgressBar(0, progressBarStepCount);
101
        getContentPane().setLayout(new BorderLayout());
102
        getContentPane().add(lblStatus, BorderLayout.NORTH);
103
        getContentPane().add(pb, BorderLayout.SOUTH);
104

  
105
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
106

  
107
        init();
108
        setLocation((screenSize.width / 2) - (splashDimension.width / 2),
109
            (screenSize.height / 2) - (splashDimension.height / 2));
110
        index = 0;
111
        setVisible(true);
112
        this.addMouseListener(this);
113
    }
114

  
115
    public void init() {
116
        img = theme.getSplashImages();
117
        numLogos = img.length;
118

  
119
        if (numLogos == 0) {
120
            numLogos = 1;
121
            img = new ImageIcon[1];
122
            img[0] = PluginServices.getIconTheme().get("splash"); 
123
            timers = new long[1];
124
            timers[0] = 1000L;
125
        }
126
        versions=theme.getVersions();
127
        points=theme.getPositions();
128
        fontSizes=theme.getFontSizes();
129
        fontColors=theme.getFontColors();
130
        int splashWidth = img[0].getIconWidth();
131
        int splashHeight = img[0].getIconHeight();
132

  
133
        for (int i = 1; i < numLogos; i++) {
134
            splashWidth = Math.max(splashWidth, img[i].getIconWidth());
135
            splashHeight = Math.max(splashHeight, img[i].getIconHeight());
136
        }
137

  
138
        splashDimension = new Dimension(splashWidth, splashHeight);
139
        setSize(splashDimension.width, splashDimension.height + 45);
140

  
141
        start();
142
    }
143

  
144
    public void paint(Graphics g) {
145
        if (lastIndex == current) {
146
            return;
147
        }
148

  
149
        super.paint(g);
150

  
151
        if ((img == null) || (img[current] == null)) {
152
            return;
153
        }
154

  
155
        ImageIcon image = img[current];
156
        g.drawImage(image.getImage(),
157
            (getWidth() / 2) - (image.getIconWidth() / 2),
158
            ((getHeight() / 2) - (image.getIconHeight() / 2)), this);
159

  
160
        Font font=new Font("SansSerif",Font.BOLD,fontsize);
161
        if (fontSizes.length>0 && fontSizes[current]!=0) {
162
        	font=new Font("SansSerif",Font.BOLD,fontSizes[current]);
163
        }
164
    	g.setFont(font);
165

  
166
    	Color color=fontcolor;
167
        if (fontColors.length>0 && fontColors[current]!=null) {
168
        	color=fontColors[current];
169
        }
170
        g.setColor(color);
171

  
172
        String ver=version;
173
        if (versions.length>0 && versions[current]!=null) {
174
        	ver=versions[current];
175
        }
176

  
177
        Point p=point;
178
        if (points.length>0 && points[current]!=null){
179
        	p=points[current];
180
        }
181
        g.drawString(PluginServices.getText(this,ver),(int)p.getX(),(int)p.getY());
182

  
183
        lastIndex = current;
184
    }
185

  
186
    public void tick() {
187
        current = index;
188
        timer.setInterval(timers[current]);
189
        repaint();
190
        index++;
191

  
192
        if (index >= numLogos) {
193
            index = 0;
194
        }
195
    }
196

  
197
    public void start() {
198
        timer = new Timer(this, 1000);
199
        timer.start();
200
    }
201

  
202
    /**
203
     * Cierra la ventana
204
     */
205
    public void close() {
206
        setVisible(false);
207
        stop();
208
        dispose();
209
    }
210

  
211
    public void stop() {
212
        timer.stop();
213
    }
214

  
215
    /**
216
     * DOCUMENT ME!
217
     *
218
     * @param args DOCUMENT ME!
219
     */
220
    public static void main(String[] args) {
221
        Frame frame = new Frame();
222
        Theme theme = new Theme();
223
        MultiSplashWindow ba = new MultiSplashWindow(frame, theme, 5);
224
        ba.setVisible(true);
225
        ba.setSize(500, 500);
226
        ba.init();
227
        ba.start();
228
    }
229

  
230
    /**
231
     * @see com.iver.mdiApp.ui.AppLoadingListener#process(int)
232
     */
233
    public void process(int p, String str) {
234
        lblStatus.setText(str);
235

  
236
        if (pb.getValue() != p) {
237
            pb.setValue(p);
238
        }
239
        doLayout();
240
        repaint();
241
    }
242

  
243
    public void mouseClicked(MouseEvent e) {
244
        this.setVisible(false);
245
    }
246

  
247
	public void mouseEntered(MouseEvent e) { }
248
	public void mouseExited(MouseEvent e) { }
249
	public void mousePressed(MouseEvent e) { }
250
	public void mouseReleased(MouseEvent e) { }
251
    }
252

  
0 253

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/splash/TimerCallBack.java
1
package com.iver.andami.ui.splash;
2
// This interface defines a callback for the Timer class
3

  
4
public interface TimerCallBack
5
{
6
     public void tick();
7
}
8

  
0 9

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/splash/Timer.java
1
package com.iver.andami.ui.splash;
2
/**
3
 * This class implements an interval timer. It calls
4
 * the tick method in the callback interface after
5
 * a fixed number of milliseconds (indicated by the
6
 * interval variable). It measures the amount of time spent
7
 * in the tick method and adjusts for it.
8
 * To start up a timer with this class, create it with
9
 * a callback and the number of milliseconds in the interval
10
 * and then call the start method:
11
 * <PRE>
12
 *
13
 *    Timer timer = new Timer(this, 2000);
14
	// 2 second interval
15
 *    timer.start();
16
 *
17
 * </PRE>
18
 *
19
 * @author Mark Wutka
20
 */
21

  
22
public class Timer extends Object implements Runnable
23
{
24

  
25
     protected Thread timerThread;
26

  
27
/** The number of milliseconds in the interval*/
28
     protected long interval;
29

  
30
/** The callback interface containing the tick method */
31
     protected TimerCallBack callback;
32

  
33
     public Timer()
34
     {
35
     }
36

  
37
     public Timer(TimerCallBack callback)
38
     {
39
          this.callback = callback;
40
     }
41

  
42
     public Timer(long interval)
43
     {
44
          this.interval = interval;
45
     }
46

  
47
     public Timer(TimerCallBack callback, long interval)
48
     {
49
          this.callback = callback;
50
          this.interval = interval;
51
     }
52

  
53
/** returns the number of milliseconds in the interval */
54
     public long getInterval()
55
     {
56
          return interval;
57
     }
58

  
59
/** sets the number of milliseconds in the interval
60
 * @param newInterval the new number of milliseconds
61
 */
62
     public void setInterval(long newInterval)
63
     {
64
          interval = newInterval;
65
     }
66

  
67
/** returns the callback interface */
68
     public TimerCallBack getCallback()
69
     {
70
          return callback;
71
     }
72

  
73
/** changes the callback interface
74
 * @param callback the new callback
75
 */
76
     public void setCallback(TimerCallBack callback)
77
     {
78
          this.callback = callback;
79
     }
80

  
81
/** starts the timer */
82
     public void start()
83
     {
84
          timerThread = new Thread(this);
85
          timerThread.start();
86
     }
87

  
88
/** stops the timer */
89
     public void stop()
90
     {
91
    	  timerThread.interrupt();
92
    	  timerThread = null;
93
     }
94

  
95
     public void run()
96
     {
97
          while (true)
98
          {
99
// Check the current time
100
               long startTime = System.currentTimeMillis();
101

  
102
// If there is a callback, call it
103
               if (callback != null)
104
               {
105
                    callback.tick();
106
               }
107

  
108
// Check the time again
109
               long endTime = System.currentTimeMillis();
110

  
111
// The amount of time to sleep is the interval minus the time spent
112
// in the tick routine
113
               long sleepTime = interval - (endTime - startTime);
114

  
115
// If you've passed the next interval, hurry up and call the next tick
116
               if (sleepTime <= 0) continue;
117

  
118
               try {
119
            	  Thread.sleep(sleepTime);
120
               } catch (Exception insomnia) {
121
               } catch (Throwable insomnia) {
122
               }
123
          }
124
     }
125
}
126

  
0 127

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/AndamiEventQueue.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 com.iver.andami.ui;
42

  
43
import java.awt.AWTEvent;
44
import java.awt.EventQueue;
45

  
46
import com.iver.andami.messages.Messages;
47
import com.iver.andami.messages.NotificationManager;
48

  
49

  
50
/**
51
 * DOCUMENT ME!
52
 *
53
 * @author Fernando Gonz?lez Cort?s
54
 */
55
public class AndamiEventQueue extends EventQueue {
56
	protected void dispatchEvent(AWTEvent event){
57
		try{
58
			super.dispatchEvent(event);
59
		} catch(RuntimeException e){
60
			NotificationManager.addError(e);//Messages.getString("PluginServices.Bug en el c?digo"), e);
61
		} catch (Error e){
62
			NotificationManager.addError(Messages.getString("PluginServices.Error grave de la aplicaci?n.  \n Es conveniente que salgas de la aplicaci?n"), e);
63
		}
64
	}
65
}
0 66

  
tags/tmp_build/frameworks/_fwAndami/src/com/iver/andami/ui/wizard/WizardPanelWithLogo.java
1
package com.iver.andami.ui.wizard;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Color;
5

  
6
import javax.swing.ImageIcon;
7
import javax.swing.JLabel;
8
import javax.swing.JPanel;
9
import javax.swing.JSeparator;
10

  
11
import jwizardcomponent.CancelAction;
12
import jwizardcomponent.DefaultJWizardComponents;
13
import jwizardcomponent.FinishAction;
14
import jwizardcomponent.frame.SimpleButtonPanel;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff