mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04: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):
|
def checkParameterValuesBeforeExecuting(self):
|
||||||
newField = self.getParameterValue(self.NEW_FIELD)
|
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:
|
if newField and len(fieldName) == 0:
|
||||||
raise GeoAlgorithmExecutionException(
|
return self.tr('Field name is not set. Please enter a field name')
|
||||||
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 == '':
|
if outputName == '':
|
||||||
raise GeoAlgorithmExecutionException(
|
return self.tr('Output is not set. Please specify valid filename')
|
||||||
self.tr('Output is not set. Please specify valid filename'))
|
|
||||||
|
|
||||||
def getCustomParametersDialog(self):
|
def getCustomParametersDialog(self):
|
||||||
return FieldsCalculatorDialog(self)
|
return FieldsCalculatorDialog(self)
|
||||||
|
@ -182,6 +182,12 @@ class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator):
|
|||||||
self.alg.setParameterValue('FORMULA', self.builder.expressionText())
|
self.alg.setParameterValue('FORMULA', self.builder.expressionText())
|
||||||
self.alg.setOutputValue('OUTPUT_LAYER',
|
self.alg.setOutputValue('OUTPUT_LAYER',
|
||||||
self.leOutputFile.text())
|
self.leOutputFile.text())
|
||||||
|
|
||||||
|
msg = self.alg.checkParameterValuesBeforeExecuting()
|
||||||
|
if msg:
|
||||||
|
QMessageBox.warning(
|
||||||
|
self, self.tr('Unable to execute algorithm'), msg)
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
@ -199,11 +205,6 @@ class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator):
|
|||||||
not keepOpen)
|
not keepOpen)
|
||||||
if not keepOpen:
|
if not keepOpen:
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
else:
|
|
||||||
QMessageBox.critical(self,
|
|
||||||
self.tr('Unable to execute algorithm'),
|
|
||||||
self.tr('Wrong or missing parameter '
|
|
||||||
'values'))
|
|
||||||
finally:
|
finally:
|
||||||
QApplication.restoreOverrideCursor()
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user