Revision 39462
tags/v2_0_0_Build_2061/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_2061/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 |
public void doRegistration() { |
|
10 |
registerAsAPI(IverUtilesLibrary.class); |
|
11 |
} |
|
12 |
|
|
13 |
@Override |
|
14 |
protected void doInitialize() throws LibraryException { |
|
15 |
// Nothing to do |
|
16 |
} |
|
17 |
|
|
18 |
@Override |
|
19 |
protected void doPostInitialize() throws LibraryException { |
|
20 |
// nothing to do |
|
21 |
} |
|
22 |
} |
|
0 | 23 |
tags/v2_0_0_Build_2061/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_2061/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_2061/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_2061/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_2061/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_2061/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_2061/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_2061/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 |
* |
|
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 |
* IProgressMonitorIF must be all classes which |
|
59 |
* monitors the process of a long costly task. |
|
60 |
* <br> |
|
61 |
* It is designed to monitor defined tasks (those |
|
62 |
* which we know what number of steps have) and |
|
63 |
* undefined tasks. |
|
64 |
* <br> |
|
65 |
* It must has associated a GUI component to show |
|
66 |
* progress of the task (usually a Progress Bar and |
|
67 |
* a cancel button). |
|
68 |
* |
|
69 |
* @author azabala |
|
70 |
* |
|
71 |
*/ |
|
72 |
public interface IProgressMonitorIF { |
|
73 |
/** |
|
74 |
* sets initial step number of the task |
|
75 |
* monitored |
|
76 |
* @param step |
|
77 |
*/ |
|
78 |
public void setInitialStep(int step); |
|
79 |
/** |
|
80 |
* sets final step number of the task |
|
81 |
* monitored |
|
82 |
* @param step |
|
83 |
*/ |
|
84 |
public void setLastStep(int step); |
|
85 |
/** |
|
86 |
* sets current step number of the task |
|
87 |
* monitored |
|
88 |
* @param step |
|
89 |
*/ |
|
90 |
public void setCurrentStep(int step); |
|
91 |
public int getInitialStep(); |
|
92 |
public int getLastStep(); |
|
93 |
public int getCurrentStep(); |
|
94 |
/** |
|
95 |
* Sets if the monitored task is defined (known |
|
96 |
* number of steps) or undefined (unknown) |
|
97 |
* @param indeterminated |
|
98 |
*/ |
|
99 |
public void setIndeterminated(boolean indeterminated); |
|
100 |
public boolean isIndeterminated(); |
|
101 |
/** |
|
102 |
* Sets if the progress bar associated to monitor |
|
103 |
* must draw a complementary text to progress bar |
|
104 |
* @param stringDrawed |
|
105 |
*/ |
|
106 |
public void setBarStringDrawed(boolean stringDrawed); |
|
107 |
/** |
|
108 |
* Sets complementary text to progress bar. |
|
109 |
* @param barString |
|
110 |
*/ |
|
111 |
public void setBarString(String barString); |
|
112 |
/** |
|
113 |
* Set main text of GUI component |
|
114 |
* @param text |
|
115 |
*/ |
|
116 |
public void setMainTitleLabel(String text); |
|
117 |
public void setNote(String note); |
|
118 |
/** |
|
119 |
* Sends cancel message to monitored task. |
|
120 |
* |
|
121 |
*/ |
|
122 |
public void cancel(); |
|
123 |
/** |
|
124 |
* Returns if has received cancel message |
|
125 |
* @return |
|
126 |
*/ |
|
127 |
public boolean isCanceled(); |
|
128 |
/** |
|
129 |
* Says if associated task is running in background |
|
130 |
* |
|
131 |
*/ |
|
132 |
// public void taskInBackground(); |
|
133 |
/** |
|
134 |
* Closes associated GUI component |
|
135 |
* |
|
136 |
*/ |
|
137 |
public void close(); |
|
138 |
/** |
|
139 |
* Sets associated gui component visible |
|
140 |
* |
|
141 |
*/ |
|
142 |
public void open(); |
|
143 |
|
|
144 |
} |
|
145 |
|
|
0 | 146 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/ICancelableTask.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 |
* Revision 1.1 2006-03-14 19:23:42 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* Revision 1.1 2006/03/07 21:00:29 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package org.gvsig.utils.swing.threads; |
|
57 |
/** |
|
58 |
* Runnable task that could be canceled. |
|
59 |
* |
|
60 |
* @author azabala |
|
61 |
* |
|
62 |
*/ |
|
63 |
public interface ICancelableTask extends ITask { |
|
64 |
public void cancel(); |
|
65 |
} |
|
66 |
|
|
0 | 67 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/ICancelMonitor.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 |
* Revision 1.1 2006-03-14 19:23:42 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* Revision 1.1 2006/03/07 21:00:29 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package org.gvsig.utils.swing.threads; |
|
57 |
/** |
|
58 |
* It monitors cancelation of task, informing |
|
59 |
* to interested in cancelation |
|
60 |
* @author azabala |
|
61 |
* |
|
62 |
*/ |
|
63 |
public interface ICancelMonitor { |
|
64 |
public boolean isCanceled(); |
|
65 |
public boolean isFinished(); |
|
66 |
} |
|
67 |
|
|
0 | 68 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/IMonitorableTask.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 |
* Revision 1.3 2007-06-06 14:02:39 cesar |
|
49 |
* Include the finished method in the abstract class. Add comments in the interface. |
|
50 |
* |
|
51 |
* Revision 1.2 2007/05/15 07:21:20 cesar |
|
52 |
* Add the finished method for execution from Event Dispatch Thread |
|
53 |
* |
|
54 |
* Revision 1.1 2006/03/14 19:23:42 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.2 2006/03/09 18:57:39 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* Revision 1.1 2006/03/07 21:00:29 azabala |
|
61 |
* *** empty log message *** |
|
62 |
* |
|
63 |
* |
|
64 |
*/ |
|
65 |
package org.gvsig.utils.swing.threads; |
|
66 |
|
|
67 |
/** |
|
68 |
* Long time task that could be monitored. The monitorization |
|
69 |
* information that this task could offer is:<br> |
|
70 |
* <ul> |
|
71 |
* <li>Defined (number of steps known) or Undefined task</li> |
|
72 |
* <li>Number of steps (for defined tasks)</li> |
|
73 |
* <li>Initial and final step</li> |
|
74 |
* <li>Description of the task (status)</li> |
|
75 |
* <li>Description of subtasks (note)</li> |
|
76 |
* </ul> |
|
77 |
* @author azabala |
|
78 |
* |
|
79 |
*/ |
|
80 |
public interface IMonitorableTask extends ICancelableTask, |
|
81 |
ICancelMonitor { |
|
82 |
public int getInitialStep(); |
|
83 |
public int getFinishStep(); |
|
84 |
public int getCurrentStep(); |
|
85 |
public String getStatusMessage(); |
|
86 |
public String getNote(); |
|
87 |
public boolean isDefined(); |
|
88 |
/** |
|
89 |
* This method is executed <b>from the Event Dispatch Thread</b> |
|
90 |
* when the background task finishes. Any interaction with SWing |
|
91 |
* objects should be placed here. |
|
92 |
*/ |
|
93 |
public void finished(); |
|
94 |
|
|
95 |
} |
|
96 |
|
|
0 | 97 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/ITask.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 14-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.1 2006-03-14 19:23:42 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* |
|
52 |
*/ |
|
53 |
package org.gvsig.utils.swing.threads; |
|
54 |
/** |
|
55 |
* Base interface for generic tasks. |
|
56 |
* At origin we are going to use Runnable, |
|
57 |
* but we are interested in the possibility |
|
58 |
* of launch explicit exceptions |
|
59 |
* @author azabala |
|
60 |
* |
|
61 |
*/ |
|
62 |
public interface ITask { |
|
63 |
public void run() throws Exception; |
|
64 |
} |
|
65 |
|
|
0 | 66 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/Monitorable.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 09-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.1 2006-05-22 10:31:55 fjp |
|
49 |
* Monitorable tasks easy |
|
50 |
* |
|
51 |
* Revision 1.3 2006/05/15 14:56:23 azabala |
|
52 |
* A?adida la posibilidad de modificar el paso actual (para que en tareas que constan de varios pasos, para cada paso se pueda mostrar una barra llenandose) |
|
53 |
* |
|
54 |
* Revision 1.2 2006/03/09 18:43:29 azabala |
|
55 |
* *** empty log message *** |
|
56 |
* |
|
57 |
* Revision 1.1 2006/03/09 18:26:19 azabala |
|
58 |
* *** empty log message *** |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
package org.gvsig.utils.swing.threads; |
|
63 |
/** |
|
64 |
* Interface to monitorize a long process, which operates |
|
65 |
* in many individual steps |
|
66 |
* @author azabala |
|
67 |
* |
|
68 |
*/ |
|
69 |
public interface Monitorable { |
|
70 |
/** |
|
71 |
* Report to monitor that an individual step |
|
72 |
* was processed. |
|
73 |
* |
|
74 |
*/ |
|
75 |
public void reportStep(); |
|
76 |
/** |
|
77 |
* Return the number of steps processed |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
public int getCurrentStep(); |
|
81 |
/** |
|
82 |
* Allows to modify current step. |
|
83 |
* |
|
84 |
*/ |
|
85 |
public void setCurrentStep(int currentStep); |
|
86 |
|
|
87 |
/** |
|
88 |
* report monitor what number has the initial |
|
89 |
* step of the process is monitoring |
|
90 |
* @param step |
|
91 |
*/ |
|
92 |
public void setInitialStep(int step); |
|
93 |
|
|
94 |
public int getInitialStep(); |
|
95 |
|
|
96 |
public int getFinalStep(); |
|
97 |
/** |
|
98 |
* report monitor what number has the final |
|
99 |
* step of the process is monitoring |
|
100 |
* (no apply to undefined process) |
|
101 |
* @param step |
|
102 |
*/ |
|
103 |
public void setFinalStep(int step); |
|
104 |
/** |
|
105 |
* Reports to the monitor that the process is |
|
106 |
* monitoring is (or not) a defined process. A defined |
|
107 |
* process is a process whose number of step is predefined |
|
108 |
* (in front of not defined process, which may run in |
|
109 |
* an unknown number of steps) |
|
110 |
* @param defined |
|
111 |
*/ |
|
112 |
public void setDeterminatedProcess(boolean defined); |
|
113 |
/** |
|
114 |
* Tells if the process is monitoring is defined |
|
115 |
* @return |
|
116 |
*/ |
|
117 |
public boolean isDeterminatedProcess(); |
|
118 |
/** |
|
119 |
* Sets initial default monitorization values |
|
120 |
*/ |
|
121 |
public void reset(); |
|
122 |
|
|
123 |
} |
|
124 |
|
|
0 | 125 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/IBackgroundExecution.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 |
* Revision 1.1 2006-03-14 19:23:42 azabala |
|
49 |
* *** empty log message *** |
|
50 |
* |
|
51 |
* Revision 1.1 2006/03/07 21:00:29 azabala |
|
52 |
* *** empty log message *** |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
package org.gvsig.utils.swing.threads; |
|
57 |
/** |
|
58 |
* This interface must be implemented by all classes |
|
59 |
* that could create a background, cancelable, GUI based |
|
60 |
* thread. |
|
61 |
* |
|
62 |
* @author azabala |
|
63 |
* |
|
64 |
*/ |
|
65 |
public interface IBackgroundExecution { |
|
66 |
public IMonitorableTask createTask(); |
|
67 |
} |
|
68 |
|
|
0 | 69 |
tags/v2_0_0_Build_2061/libraries/libIverUtiles/src/org/gvsig/utils/swing/threads/ProgressMonitorAdapter.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 |
Also available in: Unified diff