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 | 7304 | caballero | /*
|
---|---|---|---|
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$
|
||
47 | * $Log$
|
||
48 | 12826 | jaume | * 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 | 11634 | cesar | * Add the finished method for execution from Event Dispatch Thread
|
53 | *
|
||
54 | * Revision 1.2 2007/03/06 16:37:08 caballero
|
||
55 | 10626 | caballero | * Exceptions
|
56 | *
|
||
57 | * Revision 1.1 2006/09/15 10:41:30 caballero
|
||
58 | 7304 | caballero | * 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 | 29596 | jpiera | package org.gvsig.app.project.documents.view.legend; |
69 | 7304 | caballero | |
70 | 29596 | jpiera | import org.gvsig.andami.PluginServices; |
71 | 24759 | jmvivo | import org.gvsig.fmap.dal.exception.DataException; |
72 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
73 | 20994 | jmvivo | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
74 | 29596 | jpiera | import org.gvsig.utils.swing.threads.CancellableMonitorable; |
75 | import org.gvsig.utils.swing.threads.DefaultCancellableMonitorable; |
||
76 | import org.gvsig.utils.swing.threads.IMonitorableTask; |
||
77 | 20994 | jmvivo | |
78 | 7304 | caballero | |
79 | public class CreateSpatialIndexMonitorableTask implements IMonitorableTask{ |
||
80 | 10626 | caballero | |
81 | 7304 | caballero | String MAIN_MESSAGE;
|
82 | String HULL_MESSAGE = PluginServices.getText(this, "Indexando"); |
||
83 | String OF = "de"; |
||
84 | 10626 | caballero | |
85 | 7304 | caballero | 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 | 10626 | caballero | |
95 | 7304 | caballero | /**
|
96 | * Default constructor
|
||
97 | * @throws DriverIOException
|
||
98 | * @throws DriverException
|
||
99 | */
|
||
100 | 24759 | jmvivo | public CreateSpatialIndexMonitorableTask(FLyrVect layer)
|
101 | throws DataException {
|
||
102 | 7304 | caballero | this.layer = layer;
|
103 | 10626 | caballero | MAIN_MESSAGE = PluginServices.getText(this, "Indexando_espacialmente") + |
104 | 7304 | caballero | layer.getName(); |
105 | 22653 | vcaballero | // cancelMonitor = createCancelMonitor();
|
106 | 7304 | caballero | } |
107 | 10626 | caballero | |
108 | 7304 | caballero | /**
|
109 | * Creates a CancellableMonitorable instance to monitor
|
||
110 | * progress and to cancel the process.
|
||
111 | * @return
|
||
112 | * @throws DriverIOException
|
||
113 | * @throws DriverException
|
||
114 | */
|
||
115 | 22653 | vcaballero | // 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 | 10626 | caballero | |
126 | 7304 | caballero | public void run() throws Exception { |
127 | 24759 | jmvivo | FeatureStore fs=(layer).getFeatureStore(); |
128 | 23383 | vcaballero | //TODO comentado para que compile
|
129 | // fs.createIndex(fs.getDefaultFeatureType());
|
||
130 | 7304 | caballero | finished = true;
|
131 | } |
||
132 | 10626 | caballero | |
133 | 7304 | caballero | 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 | 10626 | caballero | getCurrentStep()+ " " +
|
152 | 7304 | caballero | 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 | 11634 | cesar | |
173 | /* (non-Javadoc)
|
||
174 | * @see com.iver.utiles.swing.threads.IMonitorableTask#finished()
|
||
175 | */
|
||
176 | public void finished() { |
||
177 | // TODO Auto-generated method stub
|
||
178 | 21299 | vcaballero | |
179 | 11634 | cesar | } |
180 | 7304 | caballero | }//CreateSpatialIndexMonitorableTask
|
181 |