Skip to content
Permalink
Browse files

[processing] enabled inut checks for field calculator algorithm

fixes #12586
  • Loading branch information
volaya committed Apr 28, 2015
1 parent 2950146 commit 55108ae70908212b794c99cae0fc9f617ff51a12
@@ -147,15 +147,13 @@ def processAlgorithm(self, progress):

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 @@ def setParamValues(self):
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 @@ def accept(self):
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()

0 comments on commit 55108ae

Please sign in to comment.
You can’t perform that action at this time.