Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] enabled inut checks for field calculator algorithm
fixes #12586
  • Loading branch information
volaya committed Apr 28, 2015
1 parent 2950146 commit 55108ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 4 additions & 6 deletions python/plugins/processing/algs/qgis/FieldsCalculator.py
Expand Up @@ -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)
11 changes: 6 additions & 5 deletions python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py
Expand Up @@ -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):
Expand All @@ -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()

Expand Down

0 comments on commit 55108ae

Please sign in to comment.