Revision 19513

View differences:

tags/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/frameworks/_fwAndami/castor.properties
1
org.exolab.castor.indent=true
0 2

  
tags/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/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/J2ME_compat_v1_2_Build_1209/frameworks/_fwAndami/src/com/iver/andami/ui/theme/Theme.java
1
package com.iver.andami.ui.theme;
2

  
3
import java.awt.Color;
4
import java.awt.Point;
5
import java.io.BufferedReader;
6
import java.io.File;
7
import java.io.FileInputStream;
8
import java.io.FileNotFoundException;
9
import java.io.FileReader;
10
import java.io.IOException;
11
import java.util.ArrayList;
12

  
13
import javax.swing.ImageIcon;
14

  
15
import org.kxml2.io.KXmlParser;
16
import org.xmlpull.v1.XmlPullParser;
17

  
18
import com.iver.andami.PluginServices;
19
import com.iver.andami.messages.NotificationManager;
20

  
21

  
22
/**
23
 * Personalization of the program according to the file xml with the necessary information.
24
 *
25
 * @author Vicente Caballero Navarro
26
 */
27
public class Theme {
28
    public static final String CENTERED = "CENTERED";
29
    public static final String EXPAND = "EXPAND";
30
    public static final String MOSAIC = "MOSAIC";
31

  
32
	private static String encoding = "UTF-8";
33
	private static final String ANDAMI_PROPERTIES = "AndamiProperties";
34
    private static final String APPLICATION_IMAGES = "ApplicationImages";
35
    private static final String SPLASH_IMAGES = "SplashImages";
36
    private static final String SPLASH = "Splash";
37
    private static final String PATH = "path";
38
    private static final String TIMER = "timer";
39
    private static final String ICON = "Icon";
40
    private static final String APPLICATION_NAME = "ApplicationName";
41
    private static final String VALUE = "value";
42
	private static final String BACKGROUND_IMAGE = "BackgroundImage";
43
	private static final String WALLPAPER_TYPE = "WallpaperType";
44

  
45
	private static final String VERSION="version";
46
	private static final String FONTPOSITIONX="x";
47
	private static final String FONTPOSITIONY="y";
48

  
49
	private static final String FONTSIZE="fontsize";
50
	private static final String FONTCOLOR="color";
51

  
52
	private ArrayList<String> images = new ArrayList<String>();
53
    private String icon;
54
    private ArrayList<String> timers = new ArrayList<String>();
55
    private ArrayList<String> versions = new ArrayList<String>();
56
    private ArrayList<String> fontColors = new ArrayList<String>();
57
    private ArrayList<String> fontSizes = new ArrayList<String>();
58
    private ArrayList<String> fontpositionsX=new ArrayList<String>();
59
    private ArrayList<String> fontpositionsY=new ArrayList<String>();
60

  
61
    private String name = null;
62
	private String backgroundimage;
63
	private String wallpaperType=CENTERED;
64

  
65
    public static void main(String[] args) {
66
        Theme theme = new Theme();
67
        theme.readTheme(new File(
68
                "c:/workspace/_fwAndami/theme/andami-theme.xml"));
69
    }
70

  
71
    /**
72
     * Read the file xml with the personalization.
73
     *
74
     * @param file xml
75
     */
76
    public void readTheme(File file) {
77
        try {
78
            FileReader fr;
79

  
80
            try {
81
                fr = new FileReader(file);
82

  
83
                BufferedReader br = new BufferedReader(fr);
84
                char[] buffer = new char[100];
85
                br.read(buffer);
86

  
87
                StringBuffer st = new StringBuffer(new String(buffer));
88
                String searchText = "encoding=\"";
89
                int index = st.indexOf(searchText);
90

  
91
                if (index > -1) {
92
                    st.delete(0, index + searchText.length());
93
                    encoding = st.substring(0, st.indexOf("\""));
94
                }
95
            } catch (FileNotFoundException ex) {
96
                ex.printStackTrace();
97
            } catch (IOException e) {
98
                e.printStackTrace();
99
            }
100

  
101
            fr = new FileReader(file);
102

  
103
            KXmlParser parser = new KXmlParser();
104
            parser.setInput(new FileInputStream(file), encoding);
105

  
106
            int tag = parser.nextTag();
107

  
108
            if (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
109
                parser.require(XmlPullParser.START_TAG, null, ANDAMI_PROPERTIES);
110

  
111
                while (tag != XmlPullParser.END_DOCUMENT) {
112
                    //parser.next();
113
                    switch (tag) {
114
                    case XmlPullParser.START_TAG:
115

  
116
                        if (parser.getName().compareTo(ANDAMI_PROPERTIES) == 0) {
117
                            parser.nextTag();
118
                            if (parser.getName().compareTo(APPLICATION_IMAGES) == 0) {
119
                                int splashtag = parser.nextTag();
120
                            if (parser.getName().compareTo(SPLASH_IMAGES) == 0) {
121
									splashtag = parser.nextTag();
122
									boolean endSplash = false;
123

  
124
									// parser.require(KXmlParser.START_TAG,
125
									// null, SPLASH);
126
									while ((splashtag != XmlPullParser.END_DOCUMENT)
127
											&& !endSplash) {
128
										if (splashtag == XmlPullParser.END_TAG) {
129
											splashtag = parser.nextTag();
130

  
131
											continue;
132
										}
133

  
134
										if (parser.getName().compareTo(SPLASH) == 0) {
135
											images.add(parser
136
													.getAttributeValue("",
137
															PATH));
138
											timers.add(parser
139
													.getAttributeValue("",
140
															TIMER));
141
											versions.add(parser
142
													.getAttributeValue("",
143
															VERSION));
144
											fontpositionsX.add(parser
145
													.getAttributeValue("",
146
															FONTPOSITIONX));
147
											fontpositionsY.add(parser
148
													.getAttributeValue("",
149
															FONTPOSITIONY));
150
											fontSizes.add(parser
151
													.getAttributeValue("",
152
															FONTSIZE));
153
											fontColors.add(parser
154
													.getAttributeValue("",
155
															FONTCOLOR));
156

  
157
											splashtag = parser.nextTag();
158
										} else {
159
											endSplash = true;
160
										}
161
									}
162
								}
163
								int tagOptions = XmlPullParser.START_TAG;
164
								while ((tagOptions != XmlPullParser.END_TAG)) {
165
									if (parser.getName().compareTo(
166
											BACKGROUND_IMAGE) == 0) {
167
										backgroundimage = parser
168
												.getAttributeValue("", PATH);
169
										tag = parser.next();
170
									} else if (parser.getName().compareTo(ICON) == 0) {
171
										icon = parser.getAttributeValue("",
172
												PATH);
173
										tag = parser.next();
174
									} else if (parser.getName().compareTo(
175
											WALLPAPER_TYPE) == 0) {
176
										wallpaperType = parser.getAttributeValue(
177
												"", VALUE);
178
										tag = parser.next();
179
									}
180
									tagOptions = parser.nextTag();
181

  
182
								}
183
							}
184
                        }
185
                        if (parser.getName().compareTo(APPLICATION_NAME) == 0) {
186
							name = parser.getAttributeValue("",
187
									VALUE);
188
							tag = parser.next();
189
						}
190
                        break;
191

  
192
                    case XmlPullParser.END_TAG:
193
                        break;
194

  
195
                    case XmlPullParser.TEXT:
196

  
197
                        // System.out.println("[TEXT]["+kxmlParser.getText()+"]");
198
                        break;
199
                    }
200

  
201
                    tag = parser.next();
202
                }
203
            }
204

  
205
            parser.require(XmlPullParser.END_DOCUMENT, null, null);
206

  
207
            // }
208
        } catch (Exception e) {
209
        	 NotificationManager.addError("Error reading theme: "+file.getAbsolutePath(), e);
210
        }
211
    }
212

  
213
    /**
214
	 * Returns image to the splashwindow.
215
	 *
216
	 * @return ImageIcon[]
217
	 */
218
    public ImageIcon[] getSplashImages() {
219
        ImageIcon[] imgs = new ImageIcon[images.size()];
220

  
221
        for (int i = 0; i < images.size(); i++) {
222
            imgs[i] = new ImageIcon(images.get(i));
223
        }
224

  
225
        return imgs;
226
    }
227

  
228
    public String getTypeDesktop() {
229
    	return wallpaperType;
230
    }
231
    /**
232
     * Return the icon.
233
     *
234
     * @return ImageIcon
235
     */
236
    public ImageIcon getIcon() {
237
        if (icon == null) {
238
            return null;
239
        }
240

  
241
        try {
242
            return new ImageIcon(icon);
243
        } catch (Exception e) {
244
            return null;
245
        }
246
    }
247
    /**
248
     * Return the backgroundimage.
249
     *
250
     * @return ImageIcon
251
     */
252
    public ImageIcon getBackgroundImage() {
253
        if (backgroundimage == null) {
254
            return null;
255
        }
256

  
257
        try {
258
            return new ImageIcon(backgroundimage);
259
        } catch (Exception e) {
260
            return null;
261
        }
262
    }
263
    /**
264
     * Return the time of the splash images.
265
     *
266
     * @return long[]
267
     */
268
    public long[] getTimers() {
269
        long[] tms = new long[timers.size()];
270

  
271
        for (int i = 0; i < tms.length; i++) {
272
            tms[i] = Long.parseLong(timers.get(i));
273
        }
274

  
275
        return tms;
276
    }
277

  
278
    /**
279
     * Return the name of program.
280
     *
281
     * @return String
282
     */
283
    public String getName() {
284
        return name;
285
    }
286
    /**
287
     * Return the text to overwrite the images.
288
     *
289
     * @return String[]
290
     */
291
	public String[] getVersions() {
292
		return versions.toArray(new String[0]);
293
	}
294
	/**
295
     * Return the position of text to overwrite the images.
296
     *
297
     * @return Point[]
298
     */
299
	public Point[] getPositions() {
300
		Point[] points=new Point[fontpositionsX.size()];
301
		for (int i=0;i<points.length;i++) {
302
			try {
303
				points[i]=new Point(Integer.valueOf(fontpositionsX.get(i)),Integer.valueOf(fontpositionsY.get(i)));
304
			}catch (NumberFormatException e) {
305
				NotificationManager.addInfo(PluginServices.getText(this,"incorrect_position"),e);
306
			}
307
		}
308
		return points;
309
	}
310
	/**
311
     * Return the font size text to overwrite the images.
312
     *
313
     * @return int[]
314
     */
315
	public int[] getFontSizes() {
316
		int[] sizes=new int[fontSizes.size()];
317
		for (int i=0;i<sizes.length;i++) {
318
			try {
319
				sizes[i]=Integer.valueOf(fontSizes.get(i));
320
			}catch (NumberFormatException e) {
321
				NotificationManager.addInfo(PluginServices.getText(this,"incorrect_size"),e);
322
			}
323
		}
324
		return sizes;
325
	}
326
	/**
327
     * Return the font color of text to overwrite the images.
328
     *
329
     * @return Color[]
330
     */
331
	public Color[] getFontColors() {
332
		Color[] colors=new Color[fontColors.size()];
333
		for (int i=0;i<colors.length;i++) {
334
			try {
335
			String s=fontColors.get(i);
336
			String[] rgb=s.split(",");
337
			colors[i]=new Color(Integer.valueOf(rgb[0]),Integer.valueOf(rgb[1]),Integer.valueOf(rgb[2]));
338
			}catch (Exception e) {
339
				NotificationManager.addInfo(PluginServices.getText(this,"incorrect_color"),e);
340
			}
341
		}
342
		return colors;
343
	}
344
}
0 345

  
tags/J2ME_compat_v1_2_Build_1209/frameworks/_fwAndami/src/com/iver/andami/ui/MDIManagerLoadException.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
/**
44
 * 
45
 */
46
public class MDIManagerLoadException extends Exception{
47

  
48
	/**
49
	 * 
50
	 */
51
	public MDIManagerLoadException() {
52
		super();
53
		// TODO Auto-generated constructor stub
54
	}
55
	/**
56
	 * @param message
57
	 */
58
	public MDIManagerLoadException(String message) {
59
		super(message);
60
		// TODO Auto-generated constructor stub
61
	}
62
	/**
63
	 * @param message
64
	 * @param cause
65
	 */
66
	public MDIManagerLoadException(String message, Throwable cause) {
67
		super(message, cause);
68
		// TODO Auto-generated constructor stub
69
	}
70
	/**
71
	 * @param cause
72
	 */
73
	public MDIManagerLoadException(Throwable cause) {
74
		super(cause);
75
		// TODO Auto-generated constructor stub
76
	}
77
}
0 78

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

  
43
import javax.swing.Action;
44
import javax.swing.Icon;
45

  
46
public class JToolBarToggleButton extends javax.swing.JToggleButton implements EnableTextSupport{
47
	/**
48
	 * 
49
	 */
50
	public JToolBarToggleButton() {
51
		super();
52
		// TODO Auto-generated constructor stub
53
	}
54
	/**
55
	 * @param text
56
	 */
57
	public JToolBarToggleButton(String text) {
58
		super(text);
59
		// TODO Auto-generated constructor stub
60
	}
61
	/**
62
	 * @param text
63
	 * @param selected
64
	 */
65
	public JToolBarToggleButton(String text, boolean selected) {
66
		super(text, selected);
67
		// TODO Auto-generated constructor stub
68
	}
69
	/**
70
	 * @param text
71
	 * @param icon
72
	 */
73
	public JToolBarToggleButton(String text, Icon icon) {
74
		super(text, icon);
75
		// TODO Auto-generated constructor stub
76
	}
77
	/**
78
	 * @param text
79
	 * @param icon
80
	 * @param selected
81
	 */
82
	public JToolBarToggleButton(String text, Icon icon, boolean selected) {
83
		super(text, icon, selected);
84
		// TODO Auto-generated constructor stub
85
	}
86
	/**
87
	 * @param a
88
	 */
89
	public JToolBarToggleButton(Action a) {
90
		super(a);
91
		// TODO Auto-generated constructor stub
92
	}
93
	/**
94
	 * @param icon
95
	 */
96
	public JToolBarToggleButton(Icon icon) {
97
		super(icon);
98
		// TODO Auto-generated constructor stub
99
	}
100
	/**
101
	 * @param icon
102
	 * @param selected
103
	 */
104
	public JToolBarToggleButton(Icon icon, boolean selected) {
105
		super(icon, selected);
106
		// TODO Auto-generated constructor stub
107
	}
108
	private String enableText;
109
	private String toolTip;
110
	
111
	
112
	/**
113
	 * @return Returns the enableText.
114
	 */
115
	public String getEnableText() {
116
		return enableText;
117
	}
118
	/**
119
	 * @param enableText The enableText to set.
120
	 */
121
	public void setEnableText(String enableText) {
122
		this.enableText = enableText;
123
	}
124
	
125
	
126
	/**
127
	 * @see java.awt.Component#setVisible(boolean)
128
	 */
129
	public void setEnabled(boolean aFlag) {
130
		super.setEnabled(aFlag);
131
		if (aFlag){
132
			setToolTipText(toolTip);
133
		}else{
134
			setToolTipText(enableText);
135
		}
136
	}
137
	/**
138
	 * @see javax.swing.JComponent#setToolTipText(java.lang.String)
139
	 */
140
	public void setToolTip(String text) {
141
		toolTip = text;
142
	}
143
}
0 144

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

  
50
import javax.swing.JPanel;
51
import javax.swing.event.MouseInputAdapter;
52

  
53
public class GlassPane extends JPanel {
54

  
55
	public GlassPane(){
56
		this.setOpaque(false);
57
		this.addMouseListener(new MouseInputAdapter(){});
58
		this.addMouseMotionListener(new MouseInputAdapter(){});
59
		this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
60
	}
61

  
62
	/**
63
	 * @see java.awt.Component#setCursor(java.awt.Cursor)
64
	 */
65
	public void setCursor(Cursor cursor) {
66
		super.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
67
	}
68

  
69
}
70

  
0 71

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

  
43
import javax.swing.Action;
44
import javax.swing.Icon;
45

  
46
public class JMenuItem extends javax.swing.JMenuItem implements EnableTextSupport{
47
	/**
48
	 * 
49
	 */
50
	public JMenuItem() {
51
		super();
52
		// TODO Auto-generated constructor stub
53
	}
54
	/**
55
	 * @param text
56
	 */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff