Skip to content

Commit

Permalink
Refs #9077 Modified checks, File-> Close and Coadd
Browse files Browse the repository at this point in the history
The following has been fixed:
* File->Close Refl Gui now actually closes it, as until now it had loaded help.
* Clearing, reloading or opening a table will now do a modifed check and offer to save
* Clearing the table no longer sets the mdoified flag
* Coadding workspaces now works as intended
  • Loading branch information
keithnbrown committed Feb 24, 2014
1 parent e8f39c6 commit 57030f8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 15 deletions.
53 changes: 45 additions & 8 deletions Code/Mantid/scripts/Interface/ui/reflectometer/refl_gui.py
Expand Up @@ -64,7 +64,7 @@ def on_actionSave_As_triggered(self):
def on_actionSave_Workspaces_triggered(self):
self.saveWorkspaces()
def actionClose_Refl_Gui_triggered(self):
self.showHelp()
self.windowRefl.close()
def on_actionMantid_Help_triggered(self):
self.showHelp()
def on_tableMain_modified(self):
Expand All @@ -89,6 +89,7 @@ def setupUi(self, windowRefl):
'''
Setup instrument options with defaults assigned.
'''
self.windowRefl = windowRefl
self.instrument_list = ['INTER', 'SURF', 'CRISP', 'POLREF']
self.polarisation_instruments = ['CRISP', 'POLREF']
self.comboInstrument.addItems(self.instrument_list)
Expand All @@ -114,19 +115,26 @@ def setupUi(self, windowRefl):
self.statusMain.addWidget(self.labelStatus)
self.initTable()
self.populateList()
self.windowRefl = windowRefl
self.connectSlots()

def initTable(self):

#first check if the table has been changed before clearing it
if self.windowRefl.modFlag:
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Do you want to save your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Save:
self.save()
elif ret == QtGui.QMessageBox.Cancel:
return
self.currentTable = None
self.accMethod = None

self.tableMain.resizeColumnsToContents()

for column in range(self.tableMain.columnCount()):
for row in range(self.tableMain.rowCount()):

if (column == 0) or (column == 5) or (column == 10):
item = QtGui.QTableWidgetItem()
item.setText('')
Expand Down Expand Up @@ -154,6 +162,9 @@ def initTable(self):
item = QtGui.QTableWidgetItem()
item.setText('')
self.tableMain.setItem(row, column, item)
self.tableMain.resizeColumnsToContents()
self.windowRefl.modFlag = False

def connectSlots(self):
self.checkTickAll.stateChanged.connect(self.on_checkTickAll_stateChanged)
self.comboInstrument.activated.connect(self.on_comboInstrument_activated)
Expand Down Expand Up @@ -249,7 +260,6 @@ def create_workspace_display_name(self, candidate):
todisplay = groupGet(mtd[candidate], "samp", "run_number")
return todisplay


def transfer(self):
col = 0
row = 0
Expand Down Expand Up @@ -541,6 +551,21 @@ def loadTable(self):
loadDialog.setNameFilter("Table Files (*.tbl);;All files (*.*)")
if loadDialog.exec_():
try:
#before loading make sure you give them a chance to save
if self.windowRefl.modFlag:
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Do you want to save your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Save)
msgBox.setEscapeButton(QtGui.QMessageBox.Cancel)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.Save:
self.save()
elif ret == QtGui.QMessageBox.Cancel:
#if they hit cancel abort the load
self.loading = False
return
filename = loadDialog.selectedFiles()[0]
self.current_table = filename
reader = csv.reader(open(filename, "rb"))
Expand All @@ -558,6 +583,18 @@ def loadTable(self):
self.windowRefl.modFlag = False
def reloadTable(self):
self.loading = True
if self.windowRefl.modFlag:
msgBox = QtGui.QMessageBox()
msgBox.setText("The table has been modified. Are you sure you want to reload the table and lose your changes?")
msgBox.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
msgBox.setIcon(QtGui.QMessageBox.Question)
msgBox.setDefaultButton(QtGui.QMessageBox.Yes)
msgBox.setEscapeButton(QtGui.QMessageBox.No)
ret = msgBox.exec_()
if ret == QtGui.QMessageBox.No:
#if they hit No abort the reload
self.loading = False
return
filename = self.current_table
if filename:
try:
Expand Down
Expand Up @@ -45,7 +45,9 @@ def to_workspace(cls, candidate):
if mantid.api.AnalysisDataService.doesExist(candidate.strip()):
_workspace = mantid.api.AnalysisDataService.retrieve(candidate.strip())
else:
_workspace = msi.Load(Filename=candidate)
ws_name = "_" + str(candidate.strip())
msi.Load(Filename=candidate, OutputWorkspace=ws_name)
_workspace = mantid.api.AnalysisDataService.retrieve(ws_name)
else:
raise ValueError("Unknown source item %s" % candidate)
return _workspace
Expand All @@ -55,7 +57,6 @@ def __to_workspace_list(self, source_list):
for item in source_list:
temp.append(ConvertToWavelength.to_workspace(item))
self.__ws_list = temp


def __init__(self, source):
"""
Expand Down Expand Up @@ -149,8 +150,3 @@ def convert(self, wavelength_min, wavelength_max, detector_workspace_indexes, mo

msi.DeleteWorkspace(Workspace=sum_wavelength.getName())
return (_monitor_ws, _detector_ws)





0 comments on commit 57030f8

Please sign in to comment.