Index: palm/trunk/SCRIPTS/palmrungui
===================================================================
--- palm/trunk/SCRIPTS/palmrungui	(revision 4428)
+++ palm/trunk/SCRIPTS/palmrungui	(revision 4470)
@@ -25,4 +25,7 @@
 # -----------------
 # $Id$
+# Added file size output, more I/O functionalities, new/removed buttons
+# 
+# 4428 2020-02-27 11:43:53Z maronga
 # Bugfix for update button
 # 
@@ -96,5 +99,6 @@
 import shutil
 
-
+global update_frequency
+update_frequency = 5*60000
 
 # Determine PALM directories
@@ -103,4 +107,5 @@
    palm_dir = os.getcwd()
    palm_bin = palm_dir + '/trunk/SCRIPTS'
+   palm_source = palm_dir + '/trunk/SOURCE'
    job_dir = palm_dir + '/JOBS'
    user_dir = palm_dir + '/USER_CODE'
@@ -113,4 +118,15 @@
 
 
+# returns the human readable file size of filename
+def file_size(filename, suffix='B'):
+   size_raw = os.stat(filename).st_size
+   for unit in [' ',' K',' M',' G',' T']:
+      if abs(size_raw) < 1024.0:
+         return "%i%s%s" % (size_raw, unit, suffix)
+      size_raw /= 1024.0
+   return "%.1f%s%s" % (num, 'Y', suffix)
+
+
+
 palmrunline = ""
 set_list = []
@@ -135,5 +151,13 @@
         self.setupUi(self)
     
-        self.palm_logo.setPixmap(QtGui.QPixmap(palm_dir + "/trunk/SCRIPTS/palmrungui_files/logo.png"))        
+        self.palm_logo.setPixmap(QtGui.QPixmap(palm_bin + "/palmrungui_files/logo.png"))        
+        
+        with open(palm_bin + "/palmrungui") as search:
+           for line in search:
+              line = line.rstrip()
+              if "$Id" in line:
+                 version = "Version: r" + line.split(" ")[3] + " (" + line.split(" ")[4] + ")"
+                 self.groupBox.findChild(QtGui.QLabel,"label_version").setText(version)
+                 break
         
         self.recent_jobs(50)
@@ -176,10 +200,26 @@
 
 
-
-    
         QtGui.QApplication.processEvents()
 
 
-        
+        # Start refresh timer. On timeout perform update
+        self.timer = QtCore.QTimer(self)
+        self.timer.timeout.connect(self.update_all)
+        self.timer.setSingleShot(False)
+        self.timer.start(update_frequency)
+
+        # The timetimer counts the time since last update
+        self.timetimer= QtCore.QElapsedTimer()
+        self.timetimer.start()
+
+        # The labeltimer induces the update of the remaining time in the UI
+        self.labeltimer = QtCore.QTimer(self)
+        self.labeltimer.timeout.connect(self.UpdatePush)
+        self.labeltimer.setSingleShot(False)
+
+        # Update in the UI will be performed at each 1/10 of the update interval
+        self.labeltimer.start(update_frequency/10)
+        self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)")
+
     # starts xterm with palmrun commandline
     #######################################
@@ -200,31 +240,34 @@
         self.groupBox.findChild(QtGui.QPushButton,"button_start").setText("wait...")      
         self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText("Executing palmrun in xterm...")        
-        
+
         # Wait until all commands have been executed (ugly) ?
         #for i in range(0,21):
         #    qApp->processEvents()       
-        
+
         # Start xterm as QProcess
         palmrun = QProcess()
         palmrun.setProcessChannelMode(QProcess.MergedChannels) # mergedChannels
         palmrun.setWorkingDirectory(palm_dir)
-    
+
         geomet = self.frameGeometry()
-        
+
         posx = geomet.x()+geomet.width()
         posy = geomet.y()
-      
-        s = " -title \"Executing palmrun...\" -fa \"Monospace\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
-        palmrunline = "%s%s;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'"))
-        
+
+        if ( os.path.isfile("palmrungui.log") ):
+           os.remove("palmrungui.log")
+
+        s = " -title \"Executing palmrun...\" -fa \"Monospace\" -l -lf \"palmrungui.log\" -fs 11 -geometry \"80x38+%d+%d\" -e \"" % (posx,posy)
+        palmrunline = "%s%s ;echo -n '--> Press enter to continue...';read yesno\"</dev/stdin" % (s, palmrunline.replace("\"","\'"))
+
         mString = "xterm %s" % (palmrunline)
         palmrun.start(mString)
-    
+
         if( palmrun.waitForStarted() is False ):
             return
-        
+
         # Wait until palmrun has finished or wait for 200 minutes
         palmrun.waitForFinished(3600000)        
-        
+
         # Jobs has been submitted or aborted. Continuing...
         # Save the palmrun command to history file
@@ -249,12 +292,24 @@
         
         
-        
+       
+    # Update the label
+    def UpdatePush(self):
+        remaining_time = (update_frequency - self.timetimer.elapsed()) / 1000 / 60
+        self.push_update.setText("Update (" + str(remaining_time) + " min)")
+
+
     # starts xterm with palmbuild commandline
     #######################################
     def startpalmbuild(self):
         palmbuildline = 'palmbuild -c ' + str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
-        
+
+        full_build = self.group_execution.findChild(QtGui.QCheckBox,"check_rebuild").checkState()
+
+        if ( full_build == 2 ):
+           for filename in os.listdir(palm_source):
+              os.utime(palm_source + "/" + filename, None)
+
         palmrunline_save = str(self.groupBox.findChild(QtGui.QLineEdit,"commandline").text())
-        
+
         # Disable the main window
         palmbuildline_save = palmbuildline
@@ -312,5 +367,5 @@
         else:
             return
-        
+
         file = open(fileDir,"r")
         history = file.readlines()
@@ -330,12 +385,20 @@
             listitem = history[i][17:len(history[i])-1]
             tagitem = listitem
+            configitem = listitem
             matchitems = list_jobname.findItems(listitem, QtCore.Qt.MatchExactly)
 
             if ( len(matchitems) == 0 ):
                 listitem = filter(None,listitem.split(" -r"))[1]
-                listitem = filter(None,listitem.split(" -"))[0]
-                listitem = listitem.replace(" ","") 
+                listitem = listitem.strip()
+                listitem = filter(None,listitem.split(" "))[0]
+                listitem = listitem.replace("\"","") 
                 list_jobname.addItem(listitem)
-                s = "%s: %s" % (timestamp,listitem)
+                
+                configitem = filter(None,configitem.split(" -c"))[1]
+                configitem = configitem.strip()
+                configitem = filter(None,configitem.split(" "))[0]
+                configitem = configitem.replace("\"","") 
+
+                s = "%s: %s (%s)" % (timestamp,listitem,configitem)
                 tmphistory.append(s)
                 
@@ -384,8 +447,8 @@
         list_jobname = self.group_history.findChild(QtGui.QListWidget,"list_jobname")
         filename = str(list_jobname.currentItem().text())
-            
+
         timestamp = filename[:16]
-        jobname = filename[18:]
-                
+        jobname = filename[18:].split(" ")[0]
+
         itemint = list_jobname.currentRow()
 
@@ -415,6 +478,7 @@
             listitem = history[i-1][17:len(history[i-1])-1]
             listitem = filter(None,listitem.split(" -r"))[1]
-            listitem = filter(None,listitem.split(" -"))[0]
-            listitem = listitem.replace(" ","")  
+            listitem = listitem.strip()
+            listitem = filter(None,listitem.split(" "))[0]
+            listitem = listitem.replace("\"","") 
 
             # Select command line with correct timestamp and jobname
@@ -509,29 +573,4 @@
             else:
 
-                # Check if _p3dr file is available, otherwise notice user
-                drop_job = self.group_execution.findChild(QtGui.QComboBox,"drop_job").currentText()
-                if ( self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").checkState() == 2 or 
-                     drop_job == "Restart run" or drop_job == "Restart run (coupled atmosphere ocean)"     ):
-
-                    jobname = self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text()
-                    restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
-
-                    if (os.path.exists(restartfile) == True):                  
-                        self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
-               
-
-                        if ( drop_job == "Restart run (coupled atmosphere ocean)" ):
-		            restartfileo = "%s/JOBS/%s/INPUT/%s_p3dor" % (palm_dir,jobname,jobname)
-                            if (os.path.exists(restartfileo) == True):                  
-                                self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("hooo")
-                  
-                            else:       
-                                self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dor file found!</font>")   
-               
-                    else:       
-                        self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>")
-         
-               
-                        
                 self.group_execution.setEnabled(True)
                 self.drop_job.setEnabled(True)
@@ -577,17 +616,5 @@
             if (status_restarts == 2):
                 param[0]="%s restart" % (param[0])
-    
-                # Check if _p3dr file is available, otherwise notice user
-                if (status_restarts == 2):
-                    jobname = str(self.group_execution.findChild(QtGui.QLineEdit, "line_jobname").text())
-                    restartfile = "%s/JOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
-                    if (os.path.exists(restartfile) == True):                   
-                        self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
-                   
-                    else:                   
-                        self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file found!</font>")
-
-            else:  
-                self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("")
+
 
             status_cycfill = self.group_execution.findChild(QtGui.QCheckBox,"check_cycfill").checkState()
@@ -831,25 +858,5 @@
         self.load_jobs()
         
-    # Safes current commandline and user Parameters to .sav file
-    #################################################################################
-    def save_to_file(self):
-        user_string = self.group_advanced.findChild(QtGui.QLineEdit,"line_user").text()
-        cmd_string = self.groupBox.findChild(QtGui.QLineEdit,"commandline").text()
-        
-        string_to_file = cmd_string
-        if (user_string != ""): 
-            string_to_file = "%s%s" % (string_to_file,user_string)
-            
-        #filename = QtGui.QInputDialog.getText(self, "Save File naming Dialog", "Insert filename", QtGui.QLineEdit.Normal)
-        filename = str(QtGui.QFileDialog.getSaveFileName(self, "Save File","filename.sav"))
-        extension = ".sav"
-        filename = "%s%s" % (filename, "")
-        tmstamp = strftime("%Y/%m/%d %H:%M")
-        
-        file = open(filename,"w")
-        s = "%s %s" % (tmstamp, string_to_file)
-        file.write(s)
-        file.close()
-        
+
     # Safes current commandline and user parameters to default file
     ################################################################################
@@ -932,5 +939,5 @@
                 
             elif ( parameter == "c"):
-                tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options,QtCore.Qt.MatchExactly)
+                tmpindex = self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").findText(options.strip(),QtCore.Qt.MatchExactly)
                 if tmpindex != -1: 
                    self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").setCurrentIndex(tmpindex)
@@ -1050,13 +1057,5 @@
                     if (options_all == "restart"):
                         self.group_execution.findChild(QtGui.QCheckBox,"check_restarts").setChecked(True) 
-                        # Check if _pdf file is available, otherwise notice user
-                        jobname = str(self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").text()) 
-                        
-                        restartfile = "%sJOBS/%s/INPUT/%s_p3dr" % (palm_dir,jobname,jobname)
-                        if (os.path.exists(restartfile) == True):   
-                            self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("") 
-                       
-                        else:
-                            self.group_execution.findChild(QtGui.QLabel,"label_restart").setText("<font color='red'>Warning: No p3dr file \found!</font>") 
+
                     j = j+1
 
@@ -1100,55 +1099,45 @@
             self.group_advanced.setEnabled(True) 
             self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setEnabled(True)
-         
+
+
         self.tabWidget.setCurrentIndex(0)
-         
-    # open saved commandline
-    ##################################
+
+
+    ## Open from history
+    ###################################
     def open_from_file(self):
-        
-        # Select filename and open it
-        filename = QtGui.QFileDialog.getOpenFileName(self, "Open File","Save files (*.sav)") 
-        
-        if ( filename != ""):
-            file = open(filename, "r")
-          
-            if ( file is not None ):
-                # File opened successfully
-                palmrunline = file.read()
-                file.close() 
-    
-            # In case a palmrunline was found, load it to mainwindow
-            if ( palmrunline != ""):
-                palmrunline = palmrunline[17:] 
-                self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) 
-                self.setup_gui(palmrunline)
-         
-    # open saved commandline   
-    ##################################
-    def open_last(self): 
-        # Select filename and open it
-        filename = "%s/.palmrungui.history" % (palm_dir)
-        
-        if os.path.exists(filename):
-            pass
-        else:
-            return
-        
-        file = open(filename, "r")  
-        if ( file is not None ):
-            # File opened successfully
-            lines = file.readlines()
-            palmrunline = lines[len(lines)-1]
-            palmrunline = palmrunline[:len(palmrunline)-1]
-            file.close() 
-
-        # In case a palmrunline was found, load it to mainwindow
-        if ( palmrunline != ""):
-            palmrunline = palmrunline[17:len(palmrunline)] 
-            self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline) 
-            self.setup_gui(palmrunline)        
-
+
+#      Show History
+       opt = OpenHistoryBox()
+       opt.exec_()
+
+       palmrunline = str(history_entry)
+       palmrunline = palmrunline[17:]
+       palmrunline = palmrunline[:len(palmrunline)-1]
+       palmrunline = filter(None,palmrunline.split("("))[0]
+       self.groupBox.findChild(QtGui.QLineEdit,"commandline").setText(palmrunline)
+
+#      Set selected item to jobname in "available jobs" list
+       jobname = str(history_entry[17:])
+       jobname = filter(None,jobname.split(" -r"))[1]
+       jobname = jobname.strip()
+       jobname = filter(None,jobname.split(" "))[0]
+       jobname = jobname.replace("\"","") 
+       item2int = self.list_jobs.findItems(jobname,QtCore.Qt.MatchCaseSensitive)
+
+       if ( item2int != [] ):
+          self.list_jobs.setCurrentItem(item2int[0])
+          self.update_input()
+
+#      Add tooltip tag
+       tag = str(history_entry).split('\n')[0]
+       tag = filter(None,tag.split("("))[1]
+       tag = tag.replace(")","")
+       self.groupBox.findChild(QtGui.QLineEdit,"line_tag").setText(tag)
  
-   
+#      Process palmrungui to set up gui controls
+       self.setup_gui(palmrunline)
+
+
     def update_all(self):
  
@@ -1162,4 +1151,5 @@
        self.update_input()
 
+
     # Load jobs into list
     def load_jobs(self):
@@ -1173,7 +1163,4 @@
 
        self.list_jobs.clear() 
-       self.push_copy.setEnabled(False)
-       self.push_create_set.setEnabled(False)      
-      
        self.line_path.setText(job_dir + "/")
        
@@ -1197,4 +1184,7 @@
     # Update input and user code lists
     def update_input(self):
+
+       self.labeltimer.stop() 
+
       
        self.list_input.clear() 
@@ -1202,6 +1192,4 @@
        self.list_monitoring.clear()
        self.list_output.clear()
-       self.push_copy.setEnabled(True)
-       self.push_create_set.setEnabled(True)
        
        jobitem = self.list_jobs.currentItem()
@@ -1219,5 +1207,5 @@
              
                 if ( os.path.isfile(tmp_file) ):
-                   self.list_input.addItem(str(list_of_files[i]))
+                   self.list_input.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
   
           job_to_show = job_dir + "/" + jobitem.text() + "/USER_CODE"
@@ -1243,26 +1231,31 @@
 
                 if ( os.path.isfile(tmp_file) ):
-                   self.list_monitoring.addItem(str(list_of_files[i]))
+                   self.list_monitoring.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
 
           job_to_show = job_dir + "/" + jobitem.text() + "/OUTPUT"
 
           if ( os.path.isdir(job_to_show) ):
-          
+
              list_of_files = os.listdir(job_to_show)
-          
+
              for i in range(0,len(list_of_files)):
                 tmp_file = job_to_show + "/" + list_of_files[i]
 
                 if ( os.path.isfile(tmp_file) ):
-                   self.list_output.addItem(str(list_of_files[i]))
+                   self.list_output.addItem(str(list_of_files[i]) + " (" + file_size(tmp_file) + ")")
   
           self.group_execution.findChild(QtGui.QLineEdit,"line_jobname").setText(jobitem.text())
        self.group_history.findChild(QtGui.QListWidget,"list_jobname").clearSelection()
 
+       self.timetimer.start()
+       self.timer.start(update_frequency)
+       self.labeltimer.start(update_frequency/10)
+       self.push_update.setText("Update (" + str(int(update_frequency/1000/60)) + " min)")
+       QtGui.QApplication.processEvents()
+
        # Change palmrunline accordingly
        self.change_commandline("r","")
-       self.change_commandline("a","")
-  
-  
+       self.change_commandline("a","")  
+
     # Make a copy of a job
     def copy_job(self):
@@ -1412,5 +1405,29 @@
        self.setEnabled(True) 
        set_list = []
-   
+
+
+ # Add a custom context menu for the job selection list
+    def openmenujob(self, position):
+
+        menu = QtGui.QMenu()
+
+        selection = self.list_jobs.selectedItems()
+
+        if ( len(selection) != 0 ):
+
+           copyAction = QtGui.QAction('Copy job', self)
+           copyAction.triggered.connect(self.copy_job)
+           createAction = QtGui.QAction('Create set from job', self)
+           createAction.triggered.connect(self.create_set)
+           delAction = QtGui.QAction('Delete job', self)
+           delAction.triggered.connect(self.DeleteJob)
+
+           menu.addAction(copyAction)
+           menu.addAction(createAction)
+           menu.addAction(delAction)
+
+           action = menu.exec_(self.list_jobs.mapToGlobal(position))
+       
+       
  # Add a custom context menu
     def openmenuinput(self, position):
@@ -1422,7 +1439,16 @@
         if ( len(selection) != 0 ):
 
-           openAction = menu.addAction('Open selected files')     
+
+           openAction = QtGui.QAction('Open file(s)', self)
            openAction.setStatusTip('Open file(s) in your favorite editor')
            openAction.triggered.connect(self.OpenFilesInput)
+
+
+           delAction = QtGui.QAction('Delete file(s)', self)
+           delAction.triggered.connect(self.DeleteFilesInput)
+
+           menu.addAction(openAction)
+           menu.addAction(delAction)
+
            action = menu.exec_(self.list_input.mapToGlobal(position))
 
@@ -1436,7 +1462,14 @@
         if ( len(selection) != 0 ):
 
-           openAction = menu.addAction('Open selected files')     
+           openAction = QtGui.QAction('Open file(s)', self)
            openAction.setStatusTip('Open file(s) in your favorite editor')
            openAction.triggered.connect(self.OpenFilesUser)
+
+
+           delAction = QtGui.QAction('Delete file(s)', self)
+           delAction.triggered.connect(self.DeleteFilesUser)
+
+           menu.addAction(openAction)
+           menu.addAction(delAction)
            action = menu.exec_(self.list_user.mapToGlobal(position))
 
@@ -1450,7 +1483,14 @@
         if ( len(selection) != 0 ):
 
-           openAction = menu.addAction('Open selected files')     
+           openAction = QtGui.QAction('Open file(s)', self)
            openAction.setStatusTip('Open file(s) in your favorite editor')
            openAction.triggered.connect(self.OpenFilesOutput)
+
+
+           delAction = QtGui.QAction('Delete file(s)', self)
+           delAction.triggered.connect(self.DeleteFilesOutput)
+
+           menu.addAction(openAction)
+           menu.addAction(delAction)
            action = menu.exec_(self.list_output.mapToGlobal(position))
 
@@ -1464,8 +1504,23 @@
         if ( len(selection) != 0 ):
 
-           openAction = menu.addAction('Open selected files')     
+           openAction = QtGui.QAction('Open file(s)', self)
            openAction.setStatusTip('Open file(s) in your favorite editor')
            openAction.triggered.connect(self.OpenFilesMonitoring)
+
+
+           delAction = QtGui.QAction('Delete file(s)', self)
+           delAction.triggered.connect(self.DeleteFilesMonitoring)
+
+           menu.addAction(openAction)
+           menu.addAction(delAction)
            action = menu.exec_(self.list_monitoring.mapToGlobal(position))
+
+    def OpenConfig(self):
+
+       config = str(self.group_execution.findChild(QtGui.QComboBox, "combo_configuration").currentText())
+       if ( config != "" ):
+          filename = ".palm.config." + config
+          open_file = "xdg-open " + filename
+          os.system(str(open_file))
 
     def OpenFilesInput(self):
@@ -1478,5 +1533,5 @@
        open_files = ""
        for i in range(0,len(sel_files)):
-          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
+          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0] + "; "
 
        os.system(str(open_files))
@@ -1505,5 +1560,5 @@
        open_files = ""
        for i in range(0,len(sel_files)):
-          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
+          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0]  + "; "
 
        os.system(str(open_files)) 
@@ -1519,42 +1574,192 @@
        open_files = ""
        for i in range(0,len(sel_files)):
-          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text() + "; "
+          open_files = open_files + "xdg-open " + input_dir +  sel_files[i].text().split("(")[0] + "; "
 
        os.system(str(open_files)) 
        selection = self.list_jobs.selectedItems()
-  
+
+    def DeleteFilesInput(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          sel_job = self.list_jobs.currentItem().text()
+          sel_files = self.list_input.selectedItems()
+
+          input_dir = job_dir + "/" + sel_job + "/INPUT/"
+
+          for i in range(0,len(sel_files)):
+             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
+             os.remove(filename)
+
+          self.update_all()
+
+
+    def DeleteFilesUser(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          sel_job = self.list_jobs.currentItem().text()
+          sel_files = self.list_user.selectedItems()
+
+          input_dir = job_dir + "/" + sel_job + "/USER/"
+
+          for i in range(0,len(sel_files)):
+             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
+             os.remove(filename)
+
+          self.update_all()
+
+
+    def DeleteFilesMonitoring(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          sel_job = self.list_jobs.currentItem().text()
+          sel_files = self.list_monitoring.selectedItems()
+
+          input_dir = job_dir + "/" + sel_job + "/MONITORING/"
+
+          for i in range(0,len(sel_files)):
+             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
+             os.remove(filename)
+
+          self.update_all()
+
+
+    def DeleteFilesOutput(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete these files?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          sel_job = self.list_jobs.currentItem().text()
+          sel_files = self.list_output.selectedItems()
+
+          input_dir = job_dir + "/" + sel_job + "/OUTPUT/"
+
+          for i in range(0,len(sel_files)):
+             filename = input_dir +  sel_files[i].text().split("(")[0].trimmed()
+             os.remove(filename)
+
+          self.update_all()
+
+    def DeleteJob(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete this job?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          sel_job = self.list_jobs.currentItem().text()
+
+          input_dir = job_dir + "/" + sel_job
+          shutil.rmtree(str(input_dir))
+
+          self.update_all()
+
 # Message box for showing RUN_CONTROL output
 class CreateSetBox(QtGui.QDialog):
     def __init__(self):
-      
+
         super(CreateSetBox, self).__init__()
-        
+
         uic.loadUi(palm_bin + '/palmrungui_files/create_set.ui', self)
-        
+
         self.show()
-        
+
         return
 
 #   Cancel button
     def rejected(self):
-      
+
        self.close()
-     
+
        return
-  
 
 #   OK button
     def accept(self):
-      
+
        global set_list
-       
+
        text = self.list.toPlainText() 
        set_list = text.split('\n')
        self.close()
-     
+
        return
 
-
-        
+# Message box for showing RUN_CONTROL output
+class OpenHistoryBox(QtGui.QDialog):
+    def __init__(self):
+
+        super(OpenHistoryBox, self).__init__()
+
+        uic.loadUi(palm_bin + '/palmrungui_files/history.ui', self)
+
+        if os.path.exists(palm_dir + "/.palmrungui.history"):
+            pass
+        else:
+            return
+
+        filename = open(palm_dir + "/.palmrungui.history","r")
+        history = filename.readlines()
+        filename.close()
+
+
+        list_jobname = self.findChild(QtGui.QListWidget,"list_history")
+
+        # Read history entries and append to recent job list
+        len_history=len(history)-1
+        i = 0
+        while i<=len_history:
+            list_jobname.addItem(history[i])
+            i = i + 1
+
+        self.show()
+
+        return
+
+#   Select item / activate Load button
+    def ItemSelected(self):
+
+       self.push_open.setEnabled(True)
+
+       return
+
+
+#   Load job from history
+    def OpenFromHistory(self):
+
+       global history_entry
+       history_entry = self.list_history.selectedItems()[0].text()
+
+       self.close()
+
+       return
+
+#   Close history window
+    def DiscardHistory(self):
+
+
+       self.close()
+
+       return
+
+#   Clear history
+    def ClearHistory(self):
+
+       status = QtGui.QMessageBox.question(self,'Delete Confirmation', "Are you sure you want to delete your history?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
+
+       if status == QtGui.QMessageBox.Yes:
+
+          if os.path.exists(palm_dir + "/.palmrungui.history"):
+             os.remove(palm_dir + "/.palmrungui.history")
+
+
+       return
 
 if __name__ == "__main__":
