mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[processing] enabled inut checks for field calculator algorithm
fixes #12586
This commit is contained in:
parent
295014647f
commit
55108ae709
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user