[processing] enabled inut checks for field calculator algorithm

fixes #12586
This commit is contained in:
volaya 2015-04-28 09:19:58 +02:00
parent 295014647f
commit 55108ae709
2 changed files with 10 additions and 11 deletions

View File

@ -147,15 +147,13 @@ class FieldsCalculator(GeoAlgorithm):
def checkParameterValuesBeforeExecuting(self):
newField = self.getParameterValue(self.NEW_FIELD)
fieldName = self.getParameterValue(self.FIELD_NAME)
fieldName = self.getParameterValue(self.FIELD_NAME).strip()
if newField and len(fieldName) == 0:
raise GeoAlgorithmExecutionException(
self.tr('Field name is not set. Please enter a field name'))
return self.tr('Field name is not set. Please enter a field name')
outputName = self.getOutputValue(self.OUTPUT_LAYER)
outputName = self.getOutputValue(self.OUTPUT_LAYER).strip()
if outputName == '':
raise GeoAlgorithmExecutionException(
self.tr('Output is not set. Please specify valid filename'))
return self.tr('Output is not set. Please specify valid filename')
def getCustomParametersDialog(self):
return FieldsCalculatorDialog(self)

View File

@ -182,6 +182,12 @@ class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator):
self.alg.setParameterValue('FORMULA', self.builder.expressionText())
self.alg.setOutputValue('OUTPUT_LAYER',
self.leOutputFile.text())
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
QMessageBox.warning(
self, self.tr('Unable to execute algorithm'), msg)
return False
return True
def accept(self):
@ -199,11 +205,6 @@ class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator):
not keepOpen)
if not keepOpen:
QDialog.reject(self)
else:
QMessageBox.critical(self,
self.tr('Unable to execute algorithm'),
self.tr('Wrong or missing parameter '
'values'))
finally:
QApplication.restoreOverrideCursor()