Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / CreateSpatialIndexMonitorableTask.java @ 24759

History | View | Annotate | Download (4.72 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 24759 2008-11-04 16:08:30Z jmvivo $
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 com.iver.cit.gvsig.project.documents.view.legend;
69

    
70
import org.gvsig.fmap.dal.exception.DataException;
71
import org.gvsig.fmap.dal.feature.FeatureStore;
72
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
73
import org.gvsig.tools.exception.DriverException;
74

    
75
import com.iver.andami.PluginServices;
76
import com.iver.utiles.swing.threads.CancellableMonitorable;
77
import com.iver.utiles.swing.threads.DefaultCancellableMonitorable;
78
import com.iver.utiles.swing.threads.IMonitorableTask;
79

    
80
public class CreateSpatialIndexMonitorableTask implements IMonitorableTask{
81

    
82
        String MAIN_MESSAGE;
83
        String HULL_MESSAGE = PluginServices.getText(this, "Indexando");
84
        String OF = "de";
85

    
86
        FLyrVect layer;
87
        /**
88
         * It monitors advance of indexing process
89
         */
90
        private CancellableMonitorable cancelMonitor = null;
91
        /**
92
         * flag to tell if the process is finished
93
         */
94
        private boolean finished = false;
95

    
96
        /**
97
         * Default constructor
98
         * @throws DriverIOException
99
         * @throws DriverException
100
         */
101
        public CreateSpatialIndexMonitorableTask(FLyrVect layer)
102
                        throws DataException {
103
                this.layer = layer;
104
                MAIN_MESSAGE = PluginServices.getText(this, "Indexando_espacialmente") +
105
                                                                layer.getName();
106
//                cancelMonitor = createCancelMonitor();
107
        }
108

    
109
        /**
110
         * Creates a CancellableMonitorable instance to monitor
111
         * progress and to cancel the process.
112
         * @return
113
         * @throws DriverIOException
114
         * @throws DriverException
115
         */
116
//        private CancellableMonitorable createCancelMonitor()
117
//                                throws ReadException {
118
//                DefaultCancellableMonitorable monitor =
119
//                        new DefaultCancellableMonitorable();
120
//                monitor.setInitialStep(0);
121
//                monitor.setDeterminatedProcess(true);
122
//                int numSteps = ((FLyrVect)layer).getFeatureStore().getDataCollection().size();
123
//                monitor.setFinalStep(numSteps);
124
//                return monitor;
125
//        }
126

    
127
        public void run() throws Exception {
128
                FeatureStore fs=(layer).getFeatureStore();
129
                //TODO comentado para que compile
130
//                fs.createIndex(fs.getDefaultFeatureType());
131
                finished = true;
132
        }
133

    
134
        public int getInitialStep() {
135
                return cancelMonitor.getInitialStep();
136
        }
137

    
138
        public int getFinishStep() {
139
                return cancelMonitor.getFinalStep();
140
        }
141

    
142
        public int getCurrentStep() {
143
                return cancelMonitor.getCurrentStep();
144
        }
145

    
146
        public String getStatusMessage() {
147
                return MAIN_MESSAGE;
148
        }
149

    
150
        public String getNote() {
151
                return HULL_MESSAGE + " " +
152
                getCurrentStep()+ " " +
153
                OF  + " "+
154
                getFinishStep();
155
        }
156
        //FIXME Borrar los ficheros de indice en caso de cancelacion
157
        public void cancel() {
158
                ((DefaultCancellableMonitorable) cancelMonitor).setCanceled(true);
159
        }
160
        /**
161
         * Tells if it is a defined process (we know its number of steps)
162
         */
163
        public boolean isDefined() {
164
                return true;
165
        }
166
        public boolean isCanceled() {
167
                return cancelMonitor.isCanceled();
168
        }
169

    
170
        public boolean isFinished() {
171
                return finished;
172
        }
173

    
174
        /* (non-Javadoc)
175
         * @see com.iver.utiles.swing.threads.IMonitorableTask#finished()
176
         */
177
        public void finished() {
178
                // TODO Auto-generated method stub
179

    
180
        }
181
}//CreateSpatialIndexMonitorableTask
182

    
183