Revision 83
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.editor/src/main/java/org/gvsig/educa/thematicmap/app/editor/impl/CompilationListenerAdapter.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.educa.thematicmap.app.editor.impl; |
23 | 23 |
|
24 |
import org.gvsig.andami.messages.NotificationManager; |
|
24 | 25 |
import org.gvsig.educa.thematicmap.app.editor.CompilationListener; |
25 | 26 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilation; |
26 | 27 |
import org.gvsig.educa.thematicmap.compilation.ThematicMapCompilerStatus; |
... | ... | |
55 | 56 |
public void canceledEditing(ThematicMapCompilation compilation) { |
56 | 57 |
// Nothing to do |
57 | 58 |
} |
59 |
|
|
60 |
public void exception(String message, Throwable exception) { |
|
61 |
// use notification manager by default |
|
62 |
NotificationManager.addError(message, exception); |
|
63 |
} |
|
58 | 64 |
} |
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.editor/src/main/java/org/gvsig/educa/thematicmap/app/editor/impl/DefaultThematicMapEditorManager.java | ||
---|---|---|
184 | 184 |
public void fail(ThematicMapCompilerStatus status) { |
185 | 185 |
if (delegate != null) { |
186 | 186 |
delegate.fail(status); |
187 |
} else { |
|
188 |
String msg = |
|
189 |
swingManager |
|
190 |
.getTranslation( |
|
191 |
"problems_creating_thematic_map_from_a_view") |
|
192 |
.concat(": ").concat(status.getFailMessage()); |
|
193 |
if (status.getException() != null) { |
|
194 |
NotificationManager.addWarning(msg, status.getException()); |
|
195 |
} else { |
|
196 |
NotificationManager.addWarning(msg); |
|
197 |
} |
|
187 | 198 |
} |
199 |
} |
|
188 | 200 |
|
201 |
public void exception(String message, Throwable exception) { |
|
202 |
if (delegate != null) { |
|
203 |
delegate.exception(message, exception); |
|
204 |
} else { |
|
205 |
String msg = |
|
206 |
swingManager |
|
207 |
.getTranslation( |
|
208 |
"problems_creating_thematic_map_from_a_view") |
|
209 |
.concat(": ").concat(message); |
|
210 |
NotificationManager.addError(msg, exception); |
|
211 |
} |
|
189 | 212 |
} |
190 | 213 |
|
191 | 214 |
} |
... | ... | |
233 | 256 |
} catch (Exception ex) { |
234 | 257 |
NotificationManager.addError(swingManager |
235 | 258 |
.getTranslation("problems_reloading_thematic_map"), ex); |
259 |
return; |
|
236 | 260 |
} |
237 | 261 |
|
238 | 262 |
if (openWindow) { |
... | ... | |
269 | 293 |
public void fail(ThematicMapCompilerStatus status) { |
270 | 294 |
if (delegate != null) { |
271 | 295 |
delegate.fail(status); |
296 |
} else { |
|
297 |
String msg = |
|
298 |
swingManager |
|
299 |
.getTranslation("problems_regeneration_thematic_map") |
|
300 |
.concat(": ").concat(status.getFailMessage()); |
|
301 |
if (status.getException() != null) { |
|
302 |
NotificationManager.addWarning(msg, status.getException()); |
|
303 |
} else { |
|
304 |
NotificationManager.addWarning(msg); |
|
305 |
} |
|
272 | 306 |
} |
273 | 307 |
} |
308 |
|
|
309 |
public void exception(String message, Throwable exception) { |
|
310 |
if (delegate != null) { |
|
311 |
delegate.exception(message, exception); |
|
312 |
} else { |
|
313 |
String msg = |
|
314 |
swingManager |
|
315 |
.getTranslation("problems_regeneration_thematic_map") |
|
316 |
.concat(": ").concat(message); |
|
317 |
NotificationManager.addError(msg, exception); |
|
318 |
} |
|
319 |
} |
|
320 |
|
|
274 | 321 |
} |
275 | 322 |
|
276 | 323 |
/** {@inheridDoc} */ |
... | ... | |
304 | 351 |
SwingUtilities.invokeLater(new Runnable() { |
305 | 352 |
|
306 | 353 |
public void run() { |
307 |
compileInInstallFolder(editor.getCompilation(), |
|
308 |
myListener); |
|
354 |
try { |
|
355 |
compileInInstallFolder(editor.getCompilation(), |
|
356 |
myListener); |
|
357 |
} catch (Exception ex) { |
|
358 |
myListener.exception("Exception compiling", ex); |
|
359 |
} |
|
309 | 360 |
} |
310 | 361 |
}); |
311 | 362 |
} |
... | ... | |
469 | 520 |
if (target == null) { |
470 | 521 |
return null; |
471 | 522 |
} |
523 |
if (!target.exists()) { |
|
524 |
continue; |
|
525 |
} |
|
472 | 526 |
if (target.list().length == 0) { |
473 | 527 |
break; |
474 | 528 |
} else { |
... | ... | |
600 | 654 |
SwingUtilities.invokeLater(new Runnable() { |
601 | 655 |
|
602 | 656 |
public void run() { |
603 |
compileInInstallFolder(editor.getCompilation(), |
|
604 |
myListener); |
|
657 |
try { |
|
658 |
compileInInstallFolder(editor.getCompilation(), |
|
659 |
myListener); |
|
660 |
} catch (Exception ex) { |
|
661 |
myListener.exception("Exception compiling", ex); |
|
662 |
} |
|
663 |
|
|
605 | 664 |
} |
606 | 665 |
}); |
607 | 666 |
} |
org.gvsig.educa.thematicmap.app/trunk/org.gvsig.educa.thematicmap.app/org.gvsig.educa.thematicmap.app.editor/src/main/java/org/gvsig/educa/thematicmap/app/editor/CompilationListener.java | ||
---|---|---|
60 | 60 |
* @param status |
61 | 61 |
*/ |
62 | 62 |
void fail(ThematicMapCompilerStatus status); |
63 |
|
|
64 |
/** |
|
65 |
* Call when an exception is throw |
|
66 |
* |
|
67 |
* @param message |
|
68 |
* @param exception |
|
69 |
*/ |
|
70 |
void exception(String message, Throwable exception); |
|
63 | 71 |
} |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/DefaultThematicMapCompiler.java | ||
---|---|---|
185 | 185 |
throw new IllegalAccessError("Missing folder params"); |
186 | 186 |
} |
187 | 187 |
|
188 |
if (LOG.isDebugEnabled()) { |
|
189 |
LOG.debug("Begin compile"); |
|
190 |
} |
|
191 |
|
|
188 | 192 |
// prepare process data and status |
189 | 193 |
ProcessData data = new ProcessData(); |
190 | 194 |
DefaultThematicMapCompilerStatus status = |
... | ... | |
259 | 263 |
|
260 | 264 |
// Notify to listener |
261 | 265 |
data.notifyStatus(); |
266 |
if (LOG.isTraceEnabled()) { |
|
267 |
LOG.trace( |
|
268 |
"Process: {} done [{}/{}] [{}/100]", |
|
269 |
new Object[] { status.getCurrentStepKey(), |
|
270 |
status.getCurrentStep(), status.getTotalSteps(), |
|
271 |
status.getCompleted() }); |
|
272 |
} |
|
262 | 273 |
|
263 | 274 |
} |
264 | 275 |
|
... | ... | |
268 | 279 |
} |
269 | 280 |
data.notifyStatus(); |
270 | 281 |
|
282 |
if (status.getStatus() == Status.finished_error) { |
|
283 |
LOG.warn(status.getFailMessage(), status.getException()); |
|
284 |
} |
|
285 |
if (status.getStatus() == Status.finished_fail) { |
|
286 |
LOG.warn(status.getFailMessage()); |
|
287 |
} |
|
288 |
if (LOG.isDebugEnabled()) { |
|
289 |
LOG.debug("End compile with status {}", status.getStatus()); |
|
290 |
} |
|
291 |
|
|
271 | 292 |
return status; |
272 | 293 |
} |
273 | 294 |
|
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/WriteMapInfo.java | ||
---|---|---|
91 | 91 |
// Get Persistence State from info data |
92 | 92 |
PersistentState mapInfoPState; |
93 | 93 |
try { |
94 |
// XXX use the non-validated method avoid raster persistence |
|
95 |
// problems |
|
96 |
int autoValidation = pManager.getAutoValidation(); |
|
97 |
pManager.setAutoValidation(PersistenceManager.DISABLED); |
|
94 | 98 |
mapInfoPState = pManager.getState(data.info); |
99 |
pManager.setAutoValidation(autoValidation); |
|
95 | 100 |
} catch (PersistenceException e) { |
96 | 101 |
data.status.setError("Error serailizing MapInfo", e); |
97 | 102 |
return; |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/CopyAllLayersFiles.java | ||
---|---|---|
217 | 217 |
List<File> sourceFiles; |
218 | 218 |
try { |
219 | 219 |
// Gets status |
220 |
|
|
221 |
// XXX use the non-validated method avoid raster persistence |
|
222 |
// problems |
|
223 |
int autoValidation = persitenceMan.getAutoValidation(); |
|
224 |
persitenceMan.setAutoValidation(PersistenceManager.DISABLED); |
|
220 | 225 |
layerPerStatus = persitenceMan.getState(layer); |
226 |
persitenceMan.setAutoValidation(autoValidation); |
|
221 | 227 |
|
222 | 228 |
// Gets related files |
223 | 229 |
sourceFiles = PersistenceUtils.getRelatedFiles(layerPerStatus); |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/process/WriteMapContextDefinition.java | ||
---|---|---|
76 | 76 |
// Gets persistence state of the mapContext |
77 | 77 |
PersistentState mapContextState; |
78 | 78 |
try { |
79 |
// XXX use the non-validated method avoid raster persistence |
|
80 |
// problems |
|
81 |
int autoValidation = persitenceMan.getAutoValidation(); |
|
82 |
persitenceMan.setAutoValidation(PersistenceManager.DISABLED); |
|
79 | 83 |
mapContextState = persitenceMan.getState(data.mapContext); |
84 |
persitenceMan.setAutoValidation(autoValidation); |
|
85 |
|
|
80 | 86 |
} catch (PersistenceException e) { |
81 | 87 |
data.status.setError("Problem getting MapContext state", e); |
82 | 88 |
return; |
... | ... | |
101 | 107 |
try { |
102 | 108 |
try { |
103 | 109 |
os = FileUtils.openOutputStream(data.mapContextFile); |
110 |
int autoValidation = persitenceMan.getAutoValidation(); |
|
111 |
persitenceMan.setAutoValidation(PersistenceManager.DISABLED); |
|
104 | 112 |
persitenceMan.saveState(mapContextState, os); |
113 |
persitenceMan.setAutoValidation(autoValidation); |
|
105 | 114 |
} catch (Exception e) { |
106 | 115 |
data.status.setError("Problem storing MapContext file", e); |
107 | 116 |
return; |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.lib/org.gvsig.educa.thematicmap.lib.impl/src/main/java/org/gvsig/educa/thematicmap/impl/compilation/ValidationLayerIterator.java | ||
---|---|---|
45 | 45 |
public class ValidationLayerIterator extends LayersIterator implements |
46 | 46 |
Iterable<FLayer> { |
47 | 47 |
|
48 |
private List<CompilationValidationMessage> messages; |
|
48 |
private final List<CompilationValidationMessage> messages;
|
|
49 | 49 |
private final String source; |
50 | 50 |
|
51 | 51 |
public ValidationLayerIterator(String source, FLayer layerOrLayers) { |
... | ... | |
61 | 61 |
if (!(layer instanceof SingleLayer)) { |
62 | 62 |
return true; |
63 | 63 |
} |
64 |
if (!(layer instanceof VectorLayer)) { |
|
65 |
addMsgError(layer, "Unsupported layer type: ".concat(layer |
|
66 |
.getClass().getCanonicalName())); |
|
67 |
return false; |
|
64 |
boolean isOK = checkDataSource(layer); |
|
65 |
if (layer instanceof VectorLayer) { |
|
66 |
VectorLayer vLayer = (VectorLayer) layer; |
|
67 |
isOK = isOK && checkLegend(vLayer); |
|
68 |
isOK = isOK && checkLabeling(vLayer); |
|
68 | 69 |
} |
69 |
VectorLayer vLayer = (VectorLayer) layer; |
|
70 |
boolean isOK = checkDataSource(vLayer); |
|
71 |
isOK = isOK && checkLegend(vLayer); |
|
72 |
isOK = isOK && checkLabeling(vLayer); |
|
73 | 70 |
return isOK; |
74 | 71 |
} |
75 | 72 |
|
... | ... | |
79 | 76 |
* @param vLayer |
80 | 77 |
* @return |
81 | 78 |
*/ |
82 |
private boolean checkDataSource(VectorLayer vLayer) {
|
|
79 |
private boolean checkDataSource(FLayer vLayer) {
|
|
83 | 80 |
/* |
84 | 81 |
* by now, don't make any source check |
85 | 82 |
* |
... | ... | |
130 | 127 |
* @param layer |
131 | 128 |
* @param description |
132 | 129 |
*/ |
130 |
@SuppressWarnings("unused") |
|
133 | 131 |
private void addMsgError(FLayer layer, String description) { |
134 | 132 |
messages.add(new DefaultCompilationValidationMessage(Type.ERROR, |
135 | 133 |
"Layer '".concat(getLayerPath(layer)).concat("': ") |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.swing/org.gvsig.educa.thematicmap.swing.impl/src/main/java/org/gvsig/educa/thematicmap/swing/impl/viewer/DefaultThematicMapViewer.java | ||
---|---|---|
117 | 117 |
|
118 | 118 |
public void visibilityChanged(LayerEvent e) { |
119 | 119 |
// Nothing to do |
120 |
mapControl.rePaintDirtyLayers(); |
|
120 | 121 |
} |
121 | 122 |
|
122 | 123 |
public void nameChanged(LayerEvent e) { |
... | ... | |
128 | 129 |
} |
129 | 130 |
|
130 | 131 |
public void drawValueChanged(LayerEvent e) { |
131 |
mapControl.rePaintDirtyLayers(); |
|
132 |
// XXX removed this redraw to avoid problem in raster layers |
|
133 |
// which always changed "drawValue" in every draw process |
|
134 |
// (so drawing never ends ) |
|
135 |
|
|
136 |
// mapControl.rePaintDirtyLayers(); |
|
132 | 137 |
} |
133 | 138 |
|
134 | 139 |
public void activationChanged(LayerEvent e) { |
org.gvsig.educa.thematicmap/trunk/org.gvsig.educa.thematicmap/org.gvsig.educa.thematicmap.swing/org.gvsig.educa.thematicmap.swing.impl/src/main/java/org/gvsig/educa/thematicmap/swing/impl/viewer/DefaultThematicMapToc.java | ||
---|---|---|
172 | 172 |
TocTreeNode node; |
173 | 173 |
if (layer instanceof Classifiable) { |
174 | 174 |
Classifiable classifLayer = (Classifiable) layer; |
175 |
loadLayerWithLegendNode(layer, classifLayer.getLegend(), parent); |
|
176 |
} else |
|
177 |
if (layer instanceof IHasImageLegend) { |
|
178 |
Image imgLegend = ((IHasImageLegend) layer).getImageLegend(); |
|
179 |
loadLayerWithImageLegendNode(layer, imgLegend, parent); |
|
180 |
|
|
181 |
} else { |
|
182 |
node = new TocTreeNode(layer); |
|
183 |
parent.add(node); |
|
175 |
if (classifLayer.getLegend() != null) { |
|
176 |
loadLayerWithLegendNode(layer, classifLayer.getLegend(), parent); |
|
177 |
return; |
|
184 | 178 |
} |
179 |
} |
|
180 |
if (layer instanceof IHasImageLegend) { |
|
181 |
Image imgLegend = ((IHasImageLegend) layer).getImageLegend(); |
|
182 |
loadLayerWithImageLegendNode(layer, imgLegend, parent); |
|
183 |
return; |
|
184 |
} |
|
185 |
node = new TocTreeNode(layer); |
|
186 |
parent.add(node); |
|
185 | 187 |
} |
186 | 188 |
|
187 | 189 |
/** |
Also available in: Unified diff