Revision 33904
tags/v2_0_0_Build_2020/libraries/libIverUtiles/resources-test/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
5 |
|
|
6 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
7 |
<layout class="org.apache.log4j.PatternLayout"> |
|
8 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
9 |
</layout> |
|
10 |
</appender> |
|
11 |
|
|
12 |
<category name="org.gvsig.tools"> |
|
13 |
<priority value="DEBUG" /> |
|
14 |
</category> |
|
15 |
|
|
16 |
<category name="org.gvsig.utils"> |
|
17 |
<priority value="DEBUG" /> |
|
18 |
</category> |
|
19 |
|
|
20 |
<root> |
|
21 |
<priority value="INFO" /> |
|
22 |
<appender-ref ref="CONSOLE" /> |
|
23 |
</root> |
|
24 |
</log4j:configuration> |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/backup/DefaultBackupGeneratorFactory.java | ||
---|---|---|
1 |
package org.gvsig.tools.backup; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
/** |
|
26 |
* <p>Factory that gets a {@link DefaultBackupGenerator DefaultBackupGenerator} as a particular version of |
|
27 |
* backup generator.</p> |
|
28 |
* |
|
29 |
* @author Jose Ignacio Yarza (jiyarza@opensistemas.com) |
|
30 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
31 |
*/ |
|
32 |
public class DefaultBackupGeneratorFactory extends BackupGeneratorFactory { |
|
33 |
/* |
|
34 |
* (non-Javadoc) |
|
35 |
* @see com.iver.utiles.backup.BackupGeneratorFactory#getBackupGenerator() |
|
36 |
*/ |
|
37 |
public BackupGenerator getBackupGenerator() { |
|
38 |
return new DefaultBackupGenerator(); |
|
39 |
} |
|
40 |
} |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/backup/BackupGenerator.java | ||
---|---|---|
1 |
package org.gvsig.tools.backup; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
import org.gvsig.tools.backup.exceptions.BackupException; |
|
28 |
|
|
29 |
|
|
30 |
/** |
|
31 |
* <p>A tagging interface that all file backups must implement.</p> |
|
32 |
* |
|
33 |
* @author Jose Ignacio Yarza (jiyarza@opensistemas.com) |
|
34 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
35 |
*/ |
|
36 |
public interface BackupGenerator { |
|
37 |
/** |
|
38 |
* <p>Performs a backup of <code>source</code>.</p> |
|
39 |
* |
|
40 |
* @param source the source file |
|
41 |
*/ |
|
42 |
public void backup(File source) throws BackupException; |
|
43 |
} |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/backup/DefaultBackupGenerator.java | ||
---|---|---|
1 |
package org.gvsig.tools.backup; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
import java.io.FileInputStream; |
|
27 |
import java.io.FileOutputStream; |
|
28 |
import java.nio.channels.FileChannel; |
|
29 |
|
|
30 |
import org.gvsig.tools.backup.exceptions.BackupException; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* <p>Performs a backup of a file, into another file at the same path (directory), with the file extension |
|
35 |
* changed to <i>.bak</i>.</p> |
|
36 |
* |
|
37 |
* @author Jose Ignacio Yarza (jiyarza@opensistemas.com) |
|
38 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
39 |
*/ |
|
40 |
public class DefaultBackupGenerator implements BackupGenerator { |
|
41 |
/* |
|
42 |
* (non-Javadoc) |
|
43 |
* @see com.iver.utiles.backup.BackupGenerator#backup(java.io.File) |
|
44 |
*/ |
|
45 |
public void backup(File source) throws BackupException { |
|
46 |
try { |
|
47 |
int index = source.getAbsolutePath().lastIndexOf("."); |
|
48 |
|
|
49 |
if (index == -1) |
|
50 |
return; |
|
51 |
|
|
52 |
File dest = new File(source.getAbsolutePath().substring(0, index) + ".bak"); |
|
53 |
|
|
54 |
// Create channel on the source |
|
55 |
FileChannel srcChannel = new FileInputStream(source).getChannel(); |
|
56 |
|
|
57 |
// Create channel on the destination |
|
58 |
FileChannel dstChannel = new FileOutputStream(dest).getChannel(); |
|
59 |
|
|
60 |
// Copy file contents from source to destination |
|
61 |
dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); |
|
62 |
|
|
63 |
// Close the channels |
|
64 |
srcChannel.close(); |
|
65 |
dstChannel.close(); |
|
66 |
} catch (Exception ex) { |
|
67 |
throw new BackupException(ex.getMessage(), ex, source); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/backup/exceptions/BackupException.java | ||
---|---|---|
1 |
package org.gvsig.tools.backup.exceptions; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
import java.io.File; |
|
26 |
|
|
27 |
/** |
|
28 |
* <p>Exception to report that a backup process has failed.</p> |
|
29 |
* |
|
30 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
31 |
*/ |
|
32 |
public class BackupException extends Exception { |
|
33 |
private static final long serialVersionUID = -2846421984617208883L; |
|
34 |
|
|
35 |
/** |
|
36 |
* <p>The source file to be backup.</p> |
|
37 |
*/ |
|
38 |
protected File source; |
|
39 |
|
|
40 |
/** |
|
41 |
* <p>Constructs a new backup exception with the specified detail message and cause.</p> |
|
42 |
* |
|
43 |
* @param message the detail message (which is saved for later retrieval by the <code>getMessage()</code> method). |
|
44 |
* @param cause the cause (which is saved for later retrieval by the <code>getCause()</code> method). (A <code>null</code> |
|
45 |
* value is permitted, and indicates that the cause is nonexistent or unknown.) |
|
46 |
* @param source the file from that was going to be done a backup |
|
47 |
* |
|
48 |
* @see Exception#Exception(String, Throwable) |
|
49 |
*/ |
|
50 |
public BackupException(String message, Throwable cause, File source) { |
|
51 |
super(message, cause); |
|
52 |
this.source = source; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* <p>Gets the source file to be backup.</p> |
|
57 |
* |
|
58 |
* @return the source file |
|
59 |
*/ |
|
60 |
public File getSource() { |
|
61 |
return source; |
|
62 |
} |
|
63 |
} |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/backup/BackupGeneratorFactory.java | ||
---|---|---|
1 |
package org.gvsig.tools.backup; |
|
2 |
|
|
3 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
4 |
* |
|
5 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
6 |
* of the Valencian Government (CIT) |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
21 |
* MA 02110-1301, USA. |
|
22 |
* |
|
23 |
*/ |
|
24 |
|
|
25 |
/** |
|
26 |
* <p>Generic factory that creates a {@link BackupGenerator BackupGenerator} that performs a particular |
|
27 |
* kind of backup.</p> |
|
28 |
* |
|
29 |
* @author Jose Ignacio Yarza (jiyarza@opensistemas.com) |
|
30 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
31 |
*/ |
|
32 |
public abstract class BackupGeneratorFactory { |
|
33 |
/** |
|
34 |
* <p>Gets an instance of a backup generator that performs a particular kind of backup.</p> |
|
35 |
* |
|
36 |
* @return an instance of a backup generator that performs a particular kind of backup |
|
37 |
*/ |
|
38 |
public abstract BackupGenerator getBackupGenerator(); |
|
39 |
} |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/tools/IverUtilesLibrary.java | ||
---|---|---|
1 |
package org.gvsig.tools; |
|
2 |
|
|
3 |
import org.gvsig.tools.library.AbstractLibrary; |
|
4 |
import org.gvsig.tools.library.LibraryException; |
|
5 |
|
|
6 |
public class IverUtilesLibrary extends AbstractLibrary { |
|
7 |
|
|
8 |
@Override |
|
9 |
protected void doInitialize() throws LibraryException { |
|
10 |
} |
|
11 |
|
|
12 |
@Override |
|
13 |
protected void doPostInitialize() throws LibraryException { |
|
14 |
} |
|
15 |
} |
|
0 | 16 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/ExceptionDescription.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 01-sep-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2006-09-22 08:08:04 ldiaz |
|
49 |
* layerName y driverName gestionados/almacenados desde esta clase |
|
50 |
* |
|
51 |
* Revision 1.1 2006/09/21 17:04:52 azabala |
|
52 |
* First version in cvs |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package org.gvsig.utils; |
|
57 |
|
|
58 |
/** |
|
59 |
* <p>Most exceptions produced in a layer, has common information (layer name, driver name, error description, error code).</p> |
|
60 |
* |
|
61 |
* <p>An <code>ExceptionDescription</code> can provide this extra information describing the cause of the |
|
62 |
* error, and more useful information to give to the user that works with a layer.<p> |
|
63 |
* |
|
64 |
* @author azabala |
|
65 |
*/ |
|
66 |
public abstract class ExceptionDescription { |
|
67 |
/** |
|
68 |
* <p>Code which identifies the kind of error which is the cause of this exception.</p> |
|
69 |
*/ |
|
70 |
private int errorCode; |
|
71 |
|
|
72 |
/** |
|
73 |
* <p>A description about the error which produced this exception.</p> |
|
74 |
*/ |
|
75 |
private String errorDescription; |
|
76 |
|
|
77 |
/** |
|
78 |
* <p>If this exception was produced using a driver, this attribute describes that driver.</p> |
|
79 |
*/ |
|
80 |
private String driverName; |
|
81 |
|
|
82 |
/** |
|
83 |
* <p>If this exception was produced using a layer, this attribute describes that layer.</p> |
|
84 |
*/ |
|
85 |
private String layerName; |
|
86 |
|
|
87 |
/** |
|
88 |
* <p>Gets the name of the driver (if a driver was using) which this exception was produced.</p> |
|
89 |
* |
|
90 |
* @return the name of the driver (if a driver was using) which this exception was produced |
|
91 |
*/ |
|
92 |
public String getDriverName() { |
|
93 |
return driverName; |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* <p>Sets the name of the driver (if a driver was using) which this exception was produced.</p> |
|
98 |
* |
|
99 |
* @param driverName the name of the driver (if a driver was using) which this exception was produced |
|
100 |
*/ |
|
101 |
public void setDriverName(String driverName){ |
|
102 |
this.driverName = driverName; |
|
103 |
} |
|
104 |
|
|
105 |
/** |
|
106 |
* <p>Gets the name of the layer (if a layer was using) with that this exception was produced.</p> |
|
107 |
* |
|
108 |
* @return the name of the layer (if a layer was using) with that this exception was produced |
|
109 |
*/ |
|
110 |
public String getLayerName() { |
|
111 |
return driverName; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* <p>Sets the name of the layer (if a layer was using) with that this exception was produced.</p> |
|
116 |
* |
|
117 |
* @param layerName the name of the layer (if a layer was using) with that this exception was produced |
|
118 |
*/ |
|
119 |
public void setLayerName(String layerName){ |
|
120 |
this.layerName = layerName; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* <p>Sets the name of the layer (if a layer was using) with that this exception was produced.</p> |
|
125 |
* |
|
126 |
* @param layerName the name of the layer (if a layer was using) with that this exception was produced |
|
127 |
*/ |
|
128 |
public ExceptionDescription() { |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* <p>Creates a new <code>ExceptionDescription</code> with the useful values initialized.</p> |
|
133 |
* |
|
134 |
* @param errorCode code which identifies the kind of error which is the cause of this exception |
|
135 |
* @param errorDescription description about the error which produced this exception |
|
136 |
*/ |
|
137 |
public ExceptionDescription(int errorCode, String errorDescription) { |
|
138 |
this.errorCode = errorCode; |
|
139 |
this.errorDescription = errorDescription; |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* <p>Sets the code which identifies the kind of error which is the cause of this exception.</p> |
|
144 |
* |
|
145 |
* @param errorCode code which identifies the kind of error which is the cause of this exception |
|
146 |
*/ |
|
147 |
public void setCode(int errorCode) { |
|
148 |
this.errorCode = errorCode; |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* <p>Sets the description about the error which produced this exception.</p> |
|
153 |
* |
|
154 |
* @param description description about the error which produced this exception |
|
155 |
*/ |
|
156 |
public void setDescription(String description) { |
|
157 |
this.errorDescription = description; |
|
158 |
} |
|
159 |
|
|
160 |
/** |
|
161 |
* <p>Gets the code which identifies the kind of error which is the cause of this exception.</p> |
|
162 |
* |
|
163 |
* @return code which identifies the kind of error which is the cause of this exception |
|
164 |
*/ |
|
165 |
public int getErrorCode() { |
|
166 |
return errorCode; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* <p>Gets the description about the error which produced this exception.</p> |
|
171 |
* |
|
172 |
* @return description about the error which produced this exception |
|
173 |
*/ |
|
174 |
public String getErrorDescription() { |
|
175 |
return errorDescription; |
|
176 |
} |
|
177 |
|
|
178 |
/** |
|
179 |
* <p>Returns a message that describes the error which produced this exception, formatted in HTML code.</p> |
|
180 |
* |
|
181 |
* @return message that describes the error which produced this exception, formatted in HTML code |
|
182 |
*/ |
|
183 |
public abstract String getHtmlErrorMessage(); |
|
184 |
} |
|
0 | 185 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/CompareLists.java | ||
---|---|---|
1 |
package org.gvsig.utils; |
|
2 |
|
|
3 |
import java.util.Comparator; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 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 |
|
|
47 |
/** |
|
48 |
* This class has methods to compare lists of objects |
|
49 |
* |
|
50 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
51 |
*/ |
|
52 |
public class CompareLists { |
|
53 |
/** |
|
54 |
* Compares two lists of elements, using the value returned of the <i><b>toString()</b></i> method |
|
55 |
* of each element. <br> |
|
56 |
* Each element must also implement the {@link Comparable} interface. <br> |
|
57 |
* This method considers case sensitive . |
|
58 |
* |
|
59 |
* @param l1 First list of items. @see java.util.List |
|
60 |
* @param l2 Second list of items. @see java.util.List |
|
61 |
* @return True if the two lists have the same number of elements, and elements are in the same |
|
62 |
* position of the two lists and have the same <i>String</i> value . |
|
63 |
*/ |
|
64 |
public synchronized static boolean compare(List l1, List l2) { |
|
65 |
// If both are null -> true; if one yes but the other no -> return false |
|
66 |
if ((l1 == null) || (l2 == null)) { |
|
67 |
if (l1 == l2) |
|
68 |
return true; |
|
69 |
else |
|
70 |
return false; |
|
71 |
} |
|
72 |
|
|
73 |
// If the length isn't equal |
|
74 |
if (l1.size() != l2.size()) |
|
75 |
return false; |
|
76 |
|
|
77 |
// Compares each item: must have the same value in the same position in the list |
|
78 |
for (int i = 0; i < l1.size(); i++) { |
|
79 |
if ( l1.get(i).toString().compareTo(l2.get(i).toString()) != 0 ) |
|
80 |
return false; |
|
81 |
} |
|
82 |
|
|
83 |
return true; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Compares two lists of elements, using the value returned of the <i><b>toString()</b></i> method |
|
88 |
* of each element. <br> |
|
89 |
* Each element must also implement the {@link Comparable} interface. <br> |
|
90 |
* This method ignores case sensitive during the comparation. |
|
91 |
* |
|
92 |
* @param l1 First list of items. @see java.util.List |
|
93 |
* @param l2 Second list of items. @see java.util.List |
|
94 |
* @return True if the two lists have the same number of elements, and elements are in the same |
|
95 |
* position of the two lists and have the same <i>String</i> value . |
|
96 |
*/ |
|
97 |
public synchronized static boolean compareIgnoringCaseSensitive(List l1, List l2) { |
|
98 |
// If both are null -> true; if one yes but the other no -> return false |
|
99 |
if ((l1 == null) || (l2 == null)) { |
|
100 |
if (l1 == l2) |
|
101 |
return true; |
|
102 |
else |
|
103 |
return false; |
|
104 |
} |
|
105 |
|
|
106 |
// If the length isn't equal |
|
107 |
if (l1.size() != l2.size()) |
|
108 |
return false; |
|
109 |
|
|
110 |
// Compares each item: must have the same value in the same position in the list |
|
111 |
for (int i = 0; i < l1.size(); i++) { |
|
112 |
if ( l1.get(i).toString().compareToIgnoreCase(l2.get(i).toString()) != 0 ) |
|
113 |
return false; |
|
114 |
} |
|
115 |
|
|
116 |
return true; |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Compares two lists of elements, using the value returned of the <i><b>toString()</b></i> method |
|
121 |
* of each element. <br> |
|
122 |
* Each element must also implement the {@link Comparable} interface. <br> |
|
123 |
* |
|
124 |
* @param l1 First list of items. @see java.util.List |
|
125 |
* @param l2 Second list of items. @see java.util.List |
|
126 |
* @param comp A class which implements the <i><b>compare</b></i> method of the <i>Comparator</i> interface . |
|
127 |
* @return True if the two lists have the same number of elements, and elements are in the same |
|
128 |
* position of the two lists and have the same <i>String</i> value . |
|
129 |
*/ |
|
130 |
public synchronized static boolean compare(List l1, List l2, Comparator comp) { |
|
131 |
// If both are null -> true; if one yes but the other no -> return false |
|
132 |
if ((l1 == null) || (l2 == null)) { |
|
133 |
if (l1 == l2) |
|
134 |
return true; |
|
135 |
else |
|
136 |
return false; |
|
137 |
} |
|
138 |
|
|
139 |
// If the length isn't equal |
|
140 |
if (l1.size() != l2.size()) |
|
141 |
return false; |
|
142 |
|
|
143 |
// Compares each item: must have the same value in the same position in the list |
|
144 |
for (int i = 0; i < l1.size(); i++) { |
|
145 |
if ( comp.compare(l1.get(i).toString(), (l2.get(i).toString())) != 0 ) |
|
146 |
return false; |
|
147 |
} |
|
148 |
|
|
149 |
return true; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* Compares two lists of elements, using the value returned of the <i><b>toString()</b></i> method |
|
154 |
* of each element. <br> |
|
155 |
* Each element must also implement the {@link Comparable} interface. <br> |
|
156 |
* This method ignores case sensitive during the comparation. |
|
157 |
* |
|
158 |
* @param l1 First list of items. @see java.util.List |
|
159 |
* @param l2 Second list of items. @see java.util.List |
|
160 |
* @param comp A class which implements the <i><b>compare</b></i> method of the <i>Comparator</i> interface . |
|
161 |
* @return True if the two lists have the same number of elements, and elements are in the same |
|
162 |
* position of the two lists and have the same <i>String</i> value . |
|
163 |
*/ |
|
164 |
public synchronized static boolean compareIgnoringCaseSensitive(List l1, List l2, Comparator comp) { |
|
165 |
// If both are null -> true; if one yes but the other no -> return false |
|
166 |
if ((l1 == null) || (l2 == null)) { |
|
167 |
if (l1 == l2) |
|
168 |
return true; |
|
169 |
else |
|
170 |
return false; |
|
171 |
} |
|
172 |
|
|
173 |
// If the length isn't equal |
|
174 |
if (l1.size() != l2.size()) |
|
175 |
return false; |
|
176 |
|
|
177 |
// Compares each item: must have the same value in the same position in the list |
|
178 |
for (int i = 0; i < l1.size(); i++) { |
|
179 |
if ( comp.compare(l1.get(i).toString().toLowerCase(), (l2.get(i).toString().toLowerCase())) != 0 ) |
|
180 |
return false; |
|
181 |
} |
|
182 |
|
|
183 |
return true; |
|
184 |
} |
|
185 |
} |
|
0 | 186 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/DoubleUtilities.java | ||
---|---|---|
1 |
package org.gvsig.utils; |
|
2 |
|
|
3 |
import java.text.DecimalFormat; |
|
4 |
import java.text.DecimalFormatSymbols; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 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.3 2006-10-30 11:59:47 nacho |
|
51 |
* formateado de double |
|
52 |
* |
|
53 |
* Revision 1.2 2006/09/13 08:10:07 jorpiell |
|
54 |
* Se limita el n?mero de decimales por arriba y por abajo |
|
55 |
* |
|
56 |
* Revision 1.1 2006/05/16 13:02:41 jorpiell |
|
57 |
* Se ha a?adido la clase DoubleUtiles, donde ha un metodo para limitar el tama?o de los decimales de un double y para quitar los "puntos" de la parte entera |
|
58 |
* |
|
59 |
* |
|
60 |
*/ |
|
61 |
/** |
|
62 |
* This class has some methods to manage "Doubles" |
|
63 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
64 |
*/ |
|
65 |
public class DoubleUtilities { |
|
66 |
/** |
|
67 |
* Formats a double with an specified number of decimals. It |
|
68 |
* removes the separator character of the integer part. |
|
69 |
* @param value |
|
70 |
* Separator char of the integer part |
|
71 |
* @param decimalSeparator |
|
72 |
* Separator char of the decimal part |
|
73 |
* @param decimalsNumber |
|
74 |
* Number of decimals |
|
75 |
* @return |
|
76 |
* The formatted double |
|
77 |
*/ |
|
78 |
public static double format(double value, |
|
79 |
char decimalSeparator, |
|
80 |
int decimalsNumber){ |
|
81 |
|
|
82 |
DecimalFormat dFormat = new DecimalFormat("#"); |
|
83 |
DecimalFormatSymbols dFormatSymbols = new DecimalFormatSymbols(); |
|
84 |
|
|
85 |
dFormatSymbols.setDecimalSeparator(decimalSeparator); |
|
86 |
dFormat.setMaximumFractionDigits(decimalsNumber); |
|
87 |
dFormat.setMaximumFractionDigits(decimalsNumber); |
|
88 |
dFormat.setDecimalFormatSymbols(dFormatSymbols); |
|
89 |
double d = Double.parseDouble(dFormat.format(value)); |
|
90 |
return Double.parseDouble(dFormat.format(value)); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Formats a double with an specified number of decimals. |
|
95 |
* @param num |
|
96 |
* Value to tail |
|
97 |
* @param n |
|
98 |
* Number of decimals |
|
99 |
* @return |
|
100 |
* The formatted double |
|
101 |
*/ |
|
102 |
public static double format(double num, int n){ |
|
103 |
long m = (long)Math.pow(10, n); |
|
104 |
num *= m; |
|
105 |
long aux = ((long)num); |
|
106 |
num = (double)((double)aux / (double)m); |
|
107 |
return num; |
|
108 |
} |
|
109 |
|
|
110 |
} |
|
0 | 111 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/IPipedTask.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 06-mar-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id: |
|
47 |
* $Log: |
|
48 |
*/ |
|
49 |
package org.gvsig.utils.swing.threads; |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* This task is useful for pipes. |
|
54 |
* Its methods getResult and setEntry are useful for pipes |
|
55 |
* process. |
|
56 |
* @author alzabord |
|
57 |
* |
|
58 |
*/ |
|
59 |
public interface IPipedTask extends IMonitorableTask { |
|
60 |
public Object getResult(); |
|
61 |
public void setEntry(Object object); |
|
62 |
} |
|
0 | 63 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/UndefinedProgressMonitor.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 10-mar-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.4 2006-11-06 07:29:59 jaume |
|
49 |
* organize imports |
|
50 |
* |
|
51 |
* Revision 1.3 2006/04/18 15:16:14 azabala |
|
52 |
* a?adida la posibilidad de personalizar el titulo del dialogo de proceso |
|
53 |
* |
|
54 |
* Revision 1.2 2006/03/20 16:04:21 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.1 2006/03/14 19:23:58 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
package org.gvsig.utils.swing.threads; |
|
63 |
|
|
64 |
import java.awt.Frame; |
|
65 |
import java.awt.GridBagConstraints; |
|
66 |
import java.awt.GridBagLayout; |
|
67 |
|
|
68 |
import javax.swing.JButton; |
|
69 |
import javax.swing.JDialog; |
|
70 |
import javax.swing.JLabel; |
|
71 |
import javax.swing.JPanel; |
|
72 |
import javax.swing.JProgressBar; |
|
73 |
|
|
74 |
/** |
|
75 |
* Dialog that shows the evolution of the execution of a |
|
76 |
* ITask. |
|
77 |
* If this ITask is a defined task (we know the number of steps |
|
78 |
* it must do) it shows a progress bar. |
|
79 |
* |
|
80 |
* If it doesnt, progress bar is filling and emptying |
|
81 |
* @author azabala |
|
82 |
* |
|
83 |
*/ |
|
84 |
public class UndefinedProgressMonitor extends JDialog |
|
85 |
implements IProgressMonitorIF{ |
|
86 |
|
|
87 |
|
|
88 |
private static final long serialVersionUID = 8776505862813807891L; |
|
89 |
private JPanel jContentPane = null; |
|
90 |
private JLabel mainTitleLabel = null; |
|
91 |
private JLabel noteLabel = null; |
|
92 |
private JProgressBar jProgressBar = null; |
|
93 |
private JButton cancelButton = null; |
|
94 |
boolean canceled = false; |
|
95 |
private String title = "Processing..."; |
|
96 |
|
|
97 |
/** |
|
98 |
* This is the default constructor |
|
99 |
*/ |
|
100 |
public UndefinedProgressMonitor() { |
|
101 |
super(); |
|
102 |
initialize(); |
|
103 |
} |
|
104 |
/** |
|
105 |
* Constructor which specify the dialog title |
|
106 |
* (for example:processing, etc) |
|
107 |
* @param parent |
|
108 |
* @param title |
|
109 |
*/ |
|
110 |
public UndefinedProgressMonitor(Frame parent, String title){ |
|
111 |
super(parent, false); |
|
112 |
this.title = title; |
|
113 |
initialize(); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* This method initializes this |
|
118 |
* |
|
119 |
* @return void |
|
120 |
* |
|
121 |
* FIXME Internationalize this |
|
122 |
*/ |
|
123 |
private void initialize() { |
|
124 |
this.setSize(318, 181); |
|
125 |
this.setTitle(title); |
|
126 |
this.setContentPane(getJContentPane()); |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* This method initializes jContentPane |
|
131 |
* |
|
132 |
* @return javax.swing.JPanel |
|
133 |
*/ |
|
134 |
private JPanel getJContentPane() { |
|
135 |
if (jContentPane == null) { |
|
136 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
|
137 |
gridBagConstraints3.insets = new java.awt.Insets(6,97,18,125); |
|
138 |
gridBagConstraints3.gridy = 3; |
|
139 |
gridBagConstraints3.ipadx = 4; |
|
140 |
gridBagConstraints3.ipady = -4; |
|
141 |
gridBagConstraints3.gridx = 0; |
|
142 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
143 |
gridBagConstraints2.insets = new java.awt.Insets(11,43,5,32); |
|
144 |
gridBagConstraints2.gridy = 2; |
|
145 |
gridBagConstraints2.ipadx = 109; |
|
146 |
gridBagConstraints2.ipady = 4; |
|
147 |
gridBagConstraints2.fill = java.awt.GridBagConstraints.NONE; |
|
148 |
gridBagConstraints2.gridwidth = 2; |
|
149 |
gridBagConstraints2.anchor = java.awt.GridBagConstraints.CENTER; |
|
150 |
gridBagConstraints2.gridx = 0; |
|
151 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
152 |
gridBagConstraints1.insets = new java.awt.Insets(9,43,8,32); |
|
153 |
gridBagConstraints1.gridy = 1; |
|
154 |
gridBagConstraints1.ipadx = 180; |
|
155 |
gridBagConstraints1.ipady = 0; |
|
156 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
157 |
gridBagConstraints1.gridx = 0; |
|
158 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
159 |
gridBagConstraints.insets = new java.awt.Insets(10,43,8,32); |
|
160 |
gridBagConstraints.gridy = 0; |
|
161 |
gridBagConstraints.ipadx = 148; |
|
162 |
gridBagConstraints.ipady = 11; |
|
163 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
164 |
gridBagConstraints.gridx = 0; |
|
165 |
noteLabel = new JLabel(); |
|
166 |
noteLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); |
|
167 |
noteLabel.setText("noteLabel"); |
|
168 |
mainTitleLabel = new JLabel(); |
|
169 |
mainTitleLabel.setText("mainTittleLabel"); |
|
170 |
mainTitleLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12)); |
|
171 |
jContentPane = new JPanel(); |
|
172 |
jContentPane.setLayout(new GridBagLayout()); |
|
173 |
jContentPane.add(mainTitleLabel, gridBagConstraints); |
|
174 |
jContentPane.add(noteLabel, gridBagConstraints1); |
|
175 |
jContentPane.add(getJProgressBar(), gridBagConstraints2); |
|
176 |
jContentPane.add(getCancelButton(), gridBagConstraints3); |
|
177 |
} |
|
178 |
return jContentPane; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* This method initializes jProgressBar |
|
183 |
* |
|
184 |
* @return javax.swing.JProgressBar |
|
185 |
*/ |
|
186 |
private JProgressBar getJProgressBar() { |
|
187 |
if (jProgressBar == null) { |
|
188 |
jProgressBar = new JProgressBar(); |
|
189 |
} |
|
190 |
return jProgressBar; |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* This method initializes cancelButton |
|
195 |
* |
|
196 |
* @return javax.swing.JButton |
|
197 |
*/ |
|
198 |
private JButton getCancelButton() { |
|
199 |
if (cancelButton == null) { |
|
200 |
cancelButton = new JButton(); |
|
201 |
cancelButton.setText("cancelar"); |
|
202 |
cancelButton.addActionListener(new java.awt.event.ActionListener() { |
|
203 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
204 |
cancel(); |
|
205 |
} |
|
206 |
}); |
|
207 |
cancelButton.addActionListener(new java.awt.event.ActionListener() { |
|
208 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
209 |
cancel(); |
|
210 |
} |
|
211 |
}); |
|
212 |
} |
|
213 |
return cancelButton; |
|
214 |
} |
|
215 |
|
|
216 |
public void setInitialStep(int step) { |
|
217 |
jProgressBar.setMinimum(step); |
|
218 |
} |
|
219 |
|
|
220 |
public void setLastStep(int step) { |
|
221 |
jProgressBar.setMaximum(step); |
|
222 |
} |
|
223 |
|
|
224 |
public void setCurrentStep(int step) { |
|
225 |
jProgressBar.setValue(step); |
|
226 |
} |
|
227 |
|
|
228 |
public int getInitialStep() { |
|
229 |
return jProgressBar.getMinimum(); |
|
230 |
} |
|
231 |
|
|
232 |
public int getLastStep() { |
|
233 |
return jProgressBar.getMaximum(); |
|
234 |
} |
|
235 |
|
|
236 |
public int getCurrentStep() { |
|
237 |
return jProgressBar.getValue(); |
|
238 |
} |
|
239 |
|
|
240 |
public void setIndeterminated(boolean indeterminated) { |
|
241 |
jProgressBar.setIndeterminate(indeterminated); |
|
242 |
} |
|
243 |
|
|
244 |
public boolean isIndeterminated() { |
|
245 |
return jProgressBar.isIndeterminate(); |
|
246 |
} |
|
247 |
|
|
248 |
public void setBarStringDrawed(boolean stringDrawed) { |
|
249 |
jProgressBar.setStringPainted(stringDrawed); |
|
250 |
} |
|
251 |
|
|
252 |
public void setBarString(String barString) { |
|
253 |
jProgressBar.setString(barString); |
|
254 |
} |
|
255 |
|
|
256 |
public void setMainTitleLabel(String text) { |
|
257 |
mainTitleLabel.setText(text); |
|
258 |
} |
|
259 |
|
|
260 |
public void setNote(String note) { |
|
261 |
noteLabel.setText(note); |
|
262 |
} |
|
263 |
|
|
264 |
public void cancel() { |
|
265 |
canceled = true; |
|
266 |
} |
|
267 |
|
|
268 |
// public void taskInBackground() { |
|
269 |
// //setModal(false); |
|
270 |
// } |
|
271 |
|
|
272 |
public boolean isCanceled() { |
|
273 |
return canceled == true; |
|
274 |
} |
|
275 |
|
|
276 |
public void close() { |
|
277 |
this.dispose(); |
|
278 |
} |
|
279 |
|
|
280 |
public void open() { |
|
281 |
this.setVisible(true); |
|
282 |
} |
|
283 |
|
|
284 |
} // @jve:decl-index=0:visual-constraint="30,10" |
|
0 | 285 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/MonitorableTaskQueue.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 10-mar-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-05-15 07:21:20 cesar |
|
49 |
* Add the finished method for execution from Event Dispatch Thread |
|
50 |
* |
|
51 |
* Revision 1.1 2006/03/14 19:23:42 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package org.gvsig.utils.swing.threads; |
|
57 |
|
|
58 |
import java.util.ArrayList; |
|
59 |
import java.util.Iterator; |
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* A task that could enqueue tasks. |
|
64 |
* @author azabala |
|
65 |
* |
|
66 |
*/ |
|
67 |
public class MonitorableTaskQueue implements IMonitorableTask { |
|
68 |
|
|
69 |
private ArrayList taskQueue; |
|
70 |
private boolean canceled = false; |
|
71 |
private IMonitorableTask currentTask = null; |
|
72 |
|
|
73 |
public MonitorableTaskQueue(){ |
|
74 |
taskQueue = new ArrayList(); |
|
75 |
} |
|
76 |
|
|
77 |
public void addTask(IMonitorableTask task){ |
|
78 |
taskQueue.add(task); |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
public int getInitialStep() { |
|
83 |
return 0; |
|
84 |
} |
|
85 |
|
|
86 |
public int getFinishStep() { |
|
87 |
int lastStep = 0; |
|
88 |
if(isDefined()){ |
|
89 |
for(int i = 0; i < taskQueue.size(); i++){ |
|
90 |
IMonitorableTask task = |
|
91 |
(IMonitorableTask) taskQueue.get(i); |
|
92 |
lastStep += task.getFinishStep(); |
|
93 |
} |
|
94 |
}else{ |
|
95 |
lastStep += taskQueue.size(); |
|
96 |
} |
|
97 |
return lastStep; |
|
98 |
} |
|
99 |
|
|
100 |
public int getCurrentStep() { |
|
101 |
int currentStep = 0; |
|
102 |
|
|
103 |
for(int i = 0; i < taskQueue.size(); i++){ |
|
104 |
IMonitorableTask task = |
|
105 |
(IMonitorableTask) taskQueue.get(i); |
|
106 |
|
|
107 |
if(task == currentTask) |
|
108 |
{ |
|
109 |
if(isDefined()){ |
|
110 |
currentStep += currentTask.getCurrentStep(); |
|
111 |
|
|
112 |
}else{ |
|
113 |
currentStep = i; |
|
114 |
} |
|
115 |
break; |
|
116 |
}else{ |
|
117 |
if(isDefined()) |
|
118 |
currentStep += currentTask.getFinishStep(); |
|
119 |
} |
|
120 |
} |
|
121 |
return currentStep++; |
|
122 |
} |
|
123 |
|
|
124 |
public String getStatusMessage() { |
|
125 |
if(currentTask != null){ |
|
126 |
return currentTask.getStatusMessage(); |
|
127 |
}else{ |
|
128 |
return "Waiting for new tasks..."; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
public String getNote() { |
|
133 |
if(currentTask != null){ |
|
134 |
return currentTask.getNote(); |
|
135 |
}else{ |
|
136 |
return ""; |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
public boolean isDefined() { |
|
141 |
for(int i = 0; i < taskQueue.size(); i++){ |
|
142 |
IMonitorableTask task = |
|
143 |
(IMonitorableTask) taskQueue.get(i); |
|
144 |
if(!task.isDefined()) |
|
145 |
return false; |
|
146 |
} |
|
147 |
return true; |
|
148 |
} |
|
149 |
|
|
150 |
public void cancel() { |
|
151 |
if(currentTask != null){ |
|
152 |
currentTask.cancel(); |
|
153 |
} |
|
154 |
canceled = true; |
|
155 |
|
|
156 |
} |
|
157 |
|
|
158 |
public void run() throws Exception { |
|
159 |
System.out.println("lanzando procesos encolados..."); |
|
160 |
Iterator taskIterator = taskQueue.iterator(); |
|
161 |
while (taskIterator.hasNext() && (! canceled)){ |
|
162 |
currentTask = (IMonitorableTask) taskIterator.next(); |
|
163 |
System.out.println("proceso " + currentTask.toString()); |
|
164 |
currentTask.run(); |
|
165 |
} |
|
166 |
System.out.println("Se finalizo la cola de procesos"); |
|
167 |
|
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
public boolean isCanceled() { |
|
172 |
if(currentTask != null){ |
|
173 |
return currentTask.isCanceled(); |
|
174 |
} |
|
175 |
return false; |
|
176 |
} |
|
177 |
|
|
178 |
public boolean isFinished() { |
|
179 |
if(currentTask != null){ |
|
180 |
return currentTask.isFinished(); |
|
181 |
} |
|
182 |
return false; |
|
183 |
} |
|
184 |
|
|
185 |
public void finished() { |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
0 | 189 |
tags/v2_0_0_Build_2020/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/IProgressMonitorIF.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 10-mar-2006 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id$ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2006-03-20 16:04:11 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
Also available in: Unified diff