Skip to content

Commit 1f812af

Browse files
committed
[sextante] added "delete R script" action
1 parent 58d076e commit 1f812af

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
DeleteRScriptAction.py
6+
---------------------
7+
Date : August 2012
8+
Copyright : (C) 2012 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Victor Olaya'
21+
__date__ = 'August 2012'
22+
__copyright__ = '(C) 2012, Victor Olaya'
23+
# This will get replaced with a git SHA1 when you do a git archive
24+
__revision__ = '$Format:%H$'
25+
26+
from sextante.r.RAlgorithm import RAlgorithm
27+
from sextante.gui.ContextAction import ContextAction
28+
import os
29+
from PyQt4 import QtGui
30+
31+
class DeleteRScriptAction(ContextAction):
32+
33+
def __init__(self):
34+
self.name="Delete script"
35+
36+
def isEnabled(self):
37+
return isinstance(self.alg, RAlgorithm)
38+
39+
def execute(self, alg):
40+
reply = QtGui.QMessageBox.question(None, 'Confirmation',
41+
"Are you sure you want to delete this script?", QtGui.QMessageBox.Yes |
42+
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
43+
if reply == QtGui.QMessageBox.Yes:
44+
os.remove(self.alg.descriptionFile)
45+
self.toolbox.updateTree()

python/plugins/sextante/r/RAlgorithmProvider.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from PyQt4.QtGui import *
2828
import os.path
2929
from sextante.script.WrongScriptException import WrongScriptException
30+
from sextante.r.DeleteRScriptAction import DeleteRScriptAction
3031
from sextante.core.SextanteConfig import SextanteConfig, Setting
3132
from sextante.core.SextanteLog import SextanteLog
3233
from sextante.core.AlgorithmProvider import AlgorithmProvider
@@ -43,7 +44,7 @@ def __init__(self):
4344
AlgorithmProvider.__init__(self)
4445
self.activate = False
4546
self.actions.append(CreateNewRScriptAction())
46-
self.contextMenuActions = [EditRScriptAction()]
47+
self.contextMenuActions = [EditRScriptAction(), DeleteRScriptAction()]
4748

4849
def initializeSettings(self):
4950
AlgorithmProvider.initializeSettings(self)

0 commit comments

Comments
 (0)