2012-10-04 19:33:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
EditScriptAction.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 by Victor Olaya
|
|
|
|
Email : volayaf at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Victor Olaya'
|
|
|
|
__date__ = 'August 2012'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-04 19:33:47 +02:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-04 19:33:47 +02:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2013-08-12 20:44:27 +02:00
|
|
|
from processing.gui.ContextAction import ContextAction
|
2012-12-08 19:42:43 +02:00
|
|
|
from processing.gui.ScriptEditorDialog import ScriptEditorDialog
|
2014-04-17 01:41:25 +02:00
|
|
|
from processing.algs.r.RAlgorithm import RAlgorithm
|
2012-12-08 19:42:43 +02:00
|
|
|
from processing.script.ScriptAlgorithm import ScriptAlgorithm
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2016-05-27 19:04:25 +03:00
|
|
|
|
2012-09-15 18:25:25 +03:00
|
|
|
class EditScriptAction(ContextAction):
|
|
|
|
|
2012-12-08 19:42:43 +02:00
|
|
|
SCRIPT_PYTHON = 0
|
|
|
|
SCRIPT_R = 1
|
|
|
|
|
|
|
|
def __init__(self, scriptType):
|
2014-10-03 14:44:01 +03:00
|
|
|
self.name = self.tr('Edit script', 'EditScriptAction')
|
2012-12-08 19:42:43 +02:00
|
|
|
self.scriptType = scriptType
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def isEnabled(self):
|
2012-12-08 19:42:43 +02:00
|
|
|
if self.scriptType == ScriptEditorDialog.SCRIPT_PYTHON:
|
2016-04-06 10:50:54 +02:00
|
|
|
return isinstance(self.itemData, ScriptAlgorithm) and self.itemData.allowEdit
|
2012-12-08 19:42:43 +02:00
|
|
|
elif self.scriptType == ScriptEditorDialog.SCRIPT_R:
|
2016-04-06 10:50:54 +02:00
|
|
|
return isinstance(self.itemData, RAlgorithm)
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
def execute(self):
|
2016-04-06 10:50:54 +02:00
|
|
|
dlg = ScriptEditorDialog(self.scriptType, self.itemData)
|
2012-12-08 19:42:43 +02:00
|
|
|
dlg.show()
|