164 |
164 |
addConsoleListener("ViewEditing", new ResponseListener() {
|
165 |
165 |
|
166 |
166 |
public void acceptResponse(String response) {
|
167 |
|
try{
|
|
167 |
try {
|
168 |
168 |
textEntered(response);
|
169 |
|
} catch( VectorEditingException e){
|
|
169 |
}
|
|
170 |
catch (VectorEditingException e) {
|
170 |
171 |
showConsoleMessage(e.getMessage());
|
171 |
|
} finally{
|
172 |
|
getNextParameter();
|
173 |
172 |
}
|
|
173 |
finally {
|
|
174 |
if (activeService != null) {
|
|
175 |
getNextParameter();
|
|
176 |
}
|
174 |
177 |
}
|
|
178 |
}
|
175 |
179 |
});
|
176 |
180 |
|
177 |
181 |
}
|
... | ... | |
190 |
194 |
if (service != null) {
|
191 |
195 |
this.activeService = service;
|
192 |
196 |
try {
|
193 |
|
service.start();
|
194 |
|
} catch (StartServiceException e) {
|
195 |
|
logger.error(String.format("Can't start the service %(s)", service.getName()), e);
|
196 |
|
}
|
|
197 |
service.start();
|
|
198 |
}
|
|
199 |
catch (StartServiceException e) {
|
|
200 |
logger.error(
|
|
201 |
String.format("Can't start the service %(s)", service.getName()),
|
|
202 |
e);
|
|
203 |
}
|
197 |
204 |
getNextParameter();
|
198 |
205 |
}
|
199 |
206 |
}
|
... | ... | |
203 |
210 |
if (getConsolePanel() != null) {
|
204 |
211 |
showConsoleMessage("\n#" + param.getDescription() + " > ");
|
205 |
212 |
}
|
206 |
|
}
|
|
213 |
}
|
207 |
214 |
|
208 |
215 |
private void showConsoleMessage(String text) {
|
209 |
216 |
getConsolePanel().addText(text, JConsole.MESSAGE);
|
... | ... | |
233 |
240 |
currentParam = activeService.next();
|
234 |
241 |
if (currentParam == null) {
|
235 |
242 |
finishAndStartService();
|
236 |
|
getNextParameter();
|
237 |
243 |
}
|
238 |
244 |
else {
|
239 |
245 |
askQuestion(currentParam);
|
... | ... | |
244 |
250 |
|
245 |
251 |
private void finishAndStartService() {
|
246 |
252 |
try {
|
247 |
|
activeService.finish();
|
248 |
|
}
|
|
253 |
activeService.finish();
|
|
254 |
}
|
249 |
255 |
catch (VectorEditingException e) {
|
250 |
256 |
logger.error("An error ocurred when try to finish service", e);
|
251 |
257 |
}
|
252 |
258 |
mapControl.rePaintDirtyLayers();
|
253 |
259 |
try {
|
254 |
|
activeService.start();
|
255 |
|
} catch (StartServiceException e) {
|
256 |
|
logger.error(String.format("Can't start the service %(s)", activeService.getName()), e);
|
257 |
|
}
|
|
260 |
activeService.start();
|
|
261 |
}
|
|
262 |
catch (StartServiceException e) {
|
|
263 |
logger.error(String.format("Can't start the service %(s)",
|
|
264 |
activeService.getName()), e);
|
|
265 |
}
|
|
266 |
getNextParameter();
|
258 |
267 |
}
|
259 |
268 |
|
260 |
269 |
private void initMapControlListeners(MapControl mapControl) {
|
... | ... | |
313 |
322 |
Point point;
|
314 |
323 |
point = vp.convertToMapPoint(e.getX(), e.getY());
|
315 |
324 |
try {
|
316 |
|
this.activeService.value(point);
|
317 |
|
}
|
|
325 |
this.activeService.value(point);
|
|
326 |
}
|
318 |
327 |
catch (VectorEditingException ex) {
|
319 |
328 |
logger.error("Invalid value %s", new Object[] { point });
|
320 |
329 |
}
|
... | ... | |
323 |
332 |
Point point;
|
324 |
333 |
point = vp.convertToMapPoint(e.getX(), e.getY());
|
325 |
334 |
try {
|
326 |
|
this.activeService.value(point);
|
|
335 |
this.activeService.value(point);
|
327 |
336 |
}
|
328 |
337 |
catch (VectorEditingException ex) {
|
329 |
338 |
logger.error("Invalid value %s", new Object[] { point });
|
... | ... | |
429 |
438 |
|
430 |
439 |
}
|
431 |
440 |
|
432 |
|
private void textEntered(String response) throws InvalidEntryException{
|
|
441 |
private void textEntered(String response) throws InvalidEntryException {
|
433 |
442 |
if (response == null) {
|
434 |
|
this.activeService.stop();
|
435 |
|
cleanBehavior();
|
|
443 |
if(activeService != null){
|
|
444 |
this.activeService.stop();
|
|
445 |
cleanBehavior();
|
|
446 |
}
|
436 |
447 |
}
|
437 |
448 |
else {
|
438 |
449 |
List<TYPE> types = currentParam.getTypes();
|
... | ... | |
451 |
462 |
}
|
452 |
463 |
catch (VectorEditingException e) {
|
453 |
464 |
// Do nothing
|
454 |
|
}
|
455 |
465 |
}
|
|
466 |
}
|
456 |
467 |
if (!insertedValue && types.contains(TYPE.VALUE)) {
|
457 |
468 |
try {
|
458 |
469 |
value = parseValue(response);
|
... | ... | |
465 |
476 |
// Do nothing
|
466 |
477 |
}
|
467 |
478 |
|
468 |
|
}
|
|
479 |
}
|
469 |
480 |
if (!insertedValue && types.contains(TYPE.OPTION)) {
|
470 |
481 |
try {
|
471 |
482 |
response = response.replace("\n", "");
|
472 |
483 |
if (response != null) {
|
473 |
484 |
this.activeService.value(response);
|
474 |
485 |
insertedValue = true;
|
475 |
|
}
|
|
486 |
}
|
476 |
487 |
}
|
477 |
|
catch (VectorEditingException e) {
|
|
488 |
catch (VectorEditingException e) {
|
478 |
489 |
// Do nothing
|
479 |
490 |
}
|
480 |
491 |
}
|
... | ... | |
485 |
496 |
if (!insertedValue) {
|
486 |
497 |
throw new InvalidEntryException(null);
|
487 |
498 |
}
|
488 |
|
}
|
489 |
|
}
|
|
499 |
}
|
|
500 |
}
|
490 |
501 |
|
491 |
|
|
492 |
|
|
493 |
502 |
private Double parseValue(String response) throws ParseValueException {
|
494 |
|
try{
|
|
503 |
try {
|
495 |
504 |
return Double.valueOf(response);
|
496 |
505 |
}
|
497 |
506 |
catch (Exception e) {
|
498 |
507 |
throw new ParseValueException(e);
|
499 |
|
}
|
|
508 |
}
|
500 |
509 |
|
501 |
|
}
|
|
510 |
}
|
502 |
511 |
|
503 |
512 |
private Point parsePoint(String response) throws ParsePointException {
|
504 |
513 |
String[] numbers = new String[1];
|
... | ... | |
512 |
521 |
double[] values;
|
513 |
522 |
try {
|
514 |
523 |
values = new double[] { Double.parseDouble(numbers[0]),
|
515 |
|
Double.parseDouble(numbers[1]) };
|
|
524 |
Double.parseDouble(numbers[1]) };
|
516 |
525 |
}
|
517 |
526 |
catch (Exception e) {
|
518 |
527 |
throw new ParsePointException(e);
|
... | ... | |
520 |
529 |
|
521 |
530 |
Point point;
|
522 |
531 |
try {
|
523 |
|
point = geomManager.createPoint(values[0], values[1], currentLayer
|
524 |
|
.getFeatureStore().getDefaultFeatureType()
|
525 |
|
.getDefaultGeometryAttribute().getGeomType().getSubType());
|
|
532 |
point = geomManager.createPoint(values[0], values[1], currentLayer
|
|
533 |
.getFeatureStore().getDefaultFeatureType()
|
|
534 |
.getDefaultGeometryAttribute().getGeomType().getSubType());
|
526 |
535 |
// TODO: Maybe do util class to get type and subtype of a featureStore
|
527 |
536 |
// or a method in manager
|
528 |
537 |
}
|