root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / legend / CreateSpatialIndexMonitorableTask.java @ 38608
History | View | Annotate | Download (4.67 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-may-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: CreateSpatialIndexMonitorableTask.java 29596 2009-06-29 16:02:00Z jpiera $
|
47 |
* $Log$
|
48 |
* Revision 1.4 2007-07-30 12:56:04 jaume
|
49 |
* organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
|
50 |
*
|
51 |
* Revision 1.3 2007/05/15 07:22:56 cesar
|
52 |
* Add the finished method for execution from Event Dispatch Thread
|
53 |
*
|
54 |
* Revision 1.2 2007/03/06 16:37:08 caballero
|
55 |
* Exceptions
|
56 |
*
|
57 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
58 |
* extensibilidad de documentos
|
59 |
*
|
60 |
* Revision 1.2 2006/05/22 10:35:41 fjp
|
61 |
* Monitorable tasks easy
|
62 |
*
|
63 |
* Revision 1.1 2006/05/08 15:41:06 azabala
|
64 |
* added rtree spatial indexing capabilities
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
package org.gvsig.app.project.documents.view.legend; |
69 |
|
70 |
import org.gvsig.andami.PluginServices; |
71 |
import org.gvsig.fmap.dal.exception.DataException; |
72 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
73 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
74 |
import org.gvsig.utils.swing.threads.CancellableMonitorable; |
75 |
import org.gvsig.utils.swing.threads.DefaultCancellableMonitorable; |
76 |
import org.gvsig.utils.swing.threads.IMonitorableTask; |
77 |
|
78 |
|
79 |
public class CreateSpatialIndexMonitorableTask implements IMonitorableTask{ |
80 |
|
81 |
String MAIN_MESSAGE;
|
82 |
String HULL_MESSAGE = PluginServices.getText(this, "Indexando"); |
83 |
String OF = "de"; |
84 |
|
85 |
FLyrVect layer; |
86 |
/**
|
87 |
* It monitors advance of indexing process
|
88 |
*/
|
89 |
private CancellableMonitorable cancelMonitor = null; |
90 |
/**
|
91 |
* flag to tell if the process is finished
|
92 |
*/
|
93 |
private boolean finished = false; |
94 |
|
95 |
/**
|
96 |
* Default constructor
|
97 |
* @throws DriverIOException
|
98 |
* @throws DriverException
|
99 |
*/
|
100 |
public CreateSpatialIndexMonitorableTask(FLyrVect layer)
|
101 |
throws DataException {
|
102 |
this.layer = layer;
|
103 |
MAIN_MESSAGE = PluginServices.getText(this, "Indexando_espacialmente") + |
104 |
layer.getName(); |
105 |
// cancelMonitor = createCancelMonitor();
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* Creates a CancellableMonitorable instance to monitor
|
110 |
* progress and to cancel the process.
|
111 |
* @return
|
112 |
* @throws DriverIOException
|
113 |
* @throws DriverException
|
114 |
*/
|
115 |
// private CancellableMonitorable createCancelMonitor()
|
116 |
// throws ReadException {
|
117 |
// DefaultCancellableMonitorable monitor =
|
118 |
// new DefaultCancellableMonitorable();
|
119 |
// monitor.setInitialStep(0);
|
120 |
// monitor.setDeterminatedProcess(true);
|
121 |
// int numSteps = ((FLyrVect)layer).getFeatureStore().getDataCollection().size();
|
122 |
// monitor.setFinalStep(numSteps);
|
123 |
// return monitor;
|
124 |
// }
|
125 |
|
126 |
public void run() throws Exception { |
127 |
FeatureStore fs=(layer).getFeatureStore(); |
128 |
//TODO comentado para que compile
|
129 |
// fs.createIndex(fs.getDefaultFeatureType());
|
130 |
finished = true;
|
131 |
} |
132 |
|
133 |
public int getInitialStep() { |
134 |
return cancelMonitor.getInitialStep();
|
135 |
} |
136 |
|
137 |
public int getFinishStep() { |
138 |
return cancelMonitor.getFinalStep();
|
139 |
} |
140 |
|
141 |
public int getCurrentStep() { |
142 |
return cancelMonitor.getCurrentStep();
|
143 |
} |
144 |
|
145 |
public String getStatusMessage() { |
146 |
return MAIN_MESSAGE;
|
147 |
} |
148 |
|
149 |
public String getNote() { |
150 |
return HULL_MESSAGE + " " + |
151 |
getCurrentStep()+ " " +
|
152 |
OF + " "+
|
153 |
getFinishStep(); |
154 |
} |
155 |
//FIXME Borrar los ficheros de indice en caso de cancelacion
|
156 |
public void cancel() { |
157 |
((DefaultCancellableMonitorable) cancelMonitor).setCanceled(true);
|
158 |
} |
159 |
/**
|
160 |
* Tells if it is a defined process (we know its number of steps)
|
161 |
*/
|
162 |
public boolean isDefined() { |
163 |
return true; |
164 |
} |
165 |
public boolean isCanceled() { |
166 |
return cancelMonitor.isCanceled();
|
167 |
} |
168 |
|
169 |
public boolean isFinished() { |
170 |
return finished;
|
171 |
} |
172 |
|
173 |
/* (non-Javadoc)
|
174 |
* @see com.iver.utiles.swing.threads.IMonitorableTask#finished()
|
175 |
*/
|
176 |
public void finished() { |
177 |
// TODO Auto-generated method stub
|
178 |
|
179 |
} |
180 |
}//CreateSpatialIndexMonitorableTask
|
181 |
|
182 |
|