svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / legend / CreateSpatialIndexMonitorableTask.java @ 42250
History | View | Annotate | Download (4.45 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40558 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | 40558 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40558 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | /* CVS MESSAGES:
|
||
25 | *
|
||
26 | * $Id: CreateSpatialIndexMonitorableTask.java 29596 2009-06-29 16:02:00Z jpiera $
|
||
27 | * $Log$
|
||
28 | * Revision 1.4 2007-07-30 12:56:04 jaume
|
||
29 | * organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
|
||
30 | *
|
||
31 | * Revision 1.3 2007/05/15 07:22:56 cesar
|
||
32 | * Add the finished method for execution from Event Dispatch Thread
|
||
33 | *
|
||
34 | * Revision 1.2 2007/03/06 16:37:08 caballero
|
||
35 | * Exceptions
|
||
36 | *
|
||
37 | * Revision 1.1 2006/09/15 10:41:30 caballero
|
||
38 | * extensibilidad de documentos
|
||
39 | *
|
||
40 | * Revision 1.2 2006/05/22 10:35:41 fjp
|
||
41 | * Monitorable tasks easy
|
||
42 | *
|
||
43 | * Revision 1.1 2006/05/08 15:41:06 azabala
|
||
44 | * added rtree spatial indexing capabilities
|
||
45 | *
|
||
46 | *
|
||
47 | */
|
||
48 | package org.gvsig.app.project.documents.view.legend; |
||
49 | |||
50 | import org.gvsig.andami.PluginServices; |
||
51 | import org.gvsig.fmap.dal.exception.DataException; |
||
52 | import org.gvsig.fmap.dal.feature.FeatureStore; |
||
53 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
54 | import org.gvsig.utils.swing.threads.CancellableMonitorable; |
||
55 | import org.gvsig.utils.swing.threads.DefaultCancellableMonitorable; |
||
56 | import org.gvsig.utils.swing.threads.IMonitorableTask; |
||
57 | |||
58 | |||
59 | public class CreateSpatialIndexMonitorableTask implements IMonitorableTask{ |
||
60 | |||
61 | String MAIN_MESSAGE;
|
||
62 | String HULL_MESSAGE = PluginServices.getText(this, "Indexando"); |
||
63 | String OF = "de"; |
||
64 | |||
65 | FLyrVect layer; |
||
66 | /**
|
||
67 | * It monitors advance of indexing process
|
||
68 | */
|
||
69 | private CancellableMonitorable cancelMonitor = null; |
||
70 | /**
|
||
71 | * flag to tell if the process is finished
|
||
72 | */
|
||
73 | private boolean finished = false; |
||
74 | |||
75 | /**
|
||
76 | * Default constructor
|
||
77 | * @throws DriverIOException
|
||
78 | * @throws DriverException
|
||
79 | */
|
||
80 | public CreateSpatialIndexMonitorableTask(FLyrVect layer)
|
||
81 | throws DataException {
|
||
82 | this.layer = layer;
|
||
83 | MAIN_MESSAGE = PluginServices.getText(this, "Indexando_espacialmente") + |
||
84 | layer.getName(); |
||
85 | // cancelMonitor = createCancelMonitor();
|
||
86 | } |
||
87 | |||
88 | /**
|
||
89 | * Creates a CancellableMonitorable instance to monitor
|
||
90 | * progress and to cancel the process.
|
||
91 | * @return
|
||
92 | * @throws DriverIOException
|
||
93 | * @throws DriverException
|
||
94 | */
|
||
95 | // private CancellableMonitorable createCancelMonitor()
|
||
96 | // throws ReadException {
|
||
97 | // DefaultCancellableMonitorable monitor =
|
||
98 | // new DefaultCancellableMonitorable();
|
||
99 | // monitor.setInitialStep(0);
|
||
100 | // monitor.setDeterminatedProcess(true);
|
||
101 | // int numSteps = ((FLyrVect)layer).getFeatureStore().getDataCollection().size();
|
||
102 | // monitor.setFinalStep(numSteps);
|
||
103 | // return monitor;
|
||
104 | // }
|
||
105 | |||
106 | public void run() throws Exception { |
||
107 | FeatureStore fs=(layer).getFeatureStore(); |
||
108 | //TODO comentado para que compile
|
||
109 | // fs.createIndex(fs.getDefaultFeatureType());
|
||
110 | finished = true;
|
||
111 | } |
||
112 | |||
113 | public int getInitialStep() { |
||
114 | return cancelMonitor.getInitialStep();
|
||
115 | } |
||
116 | |||
117 | public int getFinishStep() { |
||
118 | return cancelMonitor.getFinalStep();
|
||
119 | } |
||
120 | |||
121 | public int getCurrentStep() { |
||
122 | return cancelMonitor.getCurrentStep();
|
||
123 | } |
||
124 | |||
125 | public String getStatusMessage() { |
||
126 | return MAIN_MESSAGE;
|
||
127 | } |
||
128 | |||
129 | public String getNote() { |
||
130 | return HULL_MESSAGE + " " + |
||
131 | getCurrentStep()+ " " +
|
||
132 | OF + " "+
|
||
133 | getFinishStep(); |
||
134 | } |
||
135 | //FIXME Borrar los ficheros de indice en caso de cancelacion
|
||
136 | public void cancel() { |
||
137 | ((DefaultCancellableMonitorable) cancelMonitor).setCanceled(true);
|
||
138 | } |
||
139 | /**
|
||
140 | * Tells if it is a defined process (we know its number of steps)
|
||
141 | */
|
||
142 | public boolean isDefined() { |
||
143 | return true; |
||
144 | } |
||
145 | public boolean isCanceled() { |
||
146 | return cancelMonitor.isCanceled();
|
||
147 | } |
||
148 | |||
149 | public boolean isFinished() { |
||
150 | return finished;
|
||
151 | } |
||
152 | |||
153 | /* (non-Javadoc)
|
||
154 | * @see com.iver.utiles.swing.threads.IMonitorableTask#finished()
|
||
155 | */
|
||
156 | public void finished() { |
||
157 | // TODO Auto-generated method stub
|
||
158 | |||
159 | } |
||
160 | }//CreateSpatialIndexMonitorableTask
|
||
161 |