I am trying to split my extension functions into database and GUI activities to speed up the GUI. I’ve used system.util.invokeLater and system.util.invokeAsychronous successfully on a button’s actionPerformed eventHandler. However, I’m trying to do this on the extension functions of a power table with no success. I don’t get any errors, just that the configureEditor doesn’t display dropdown nor does the configureCell replace text or color coat the cell, which was working prior to implementing these (2) functions.
configureEditor
def async():
def getlist(clist):
#move the data into a python list of tuples
cust_list = []
for row in clist:
thisList = []
for item in row:
thisList.append(item)
thisTuple = tuple(thisList)
cust_list.append(thisTuple)
return cust_list
query = "SELECT TypeID, TypeName FROM PMType ORDER BY TypeName DESC"
clist = system.db.runPrepQuery(query)
type = getlist(clist)
query = "SELECT FreqID, FreqName FROM PMFreq"
clist = system.db.runPrepQuery(query)
freq = getlist(clist)
query = "SELECT ComponentID, ComponentName FROM PMComponent ORDER BY ComponentName DESC"
clist = system.db.runPrepQuery(query)
comp = getlist(clist)
query = "SELECT SiteID, Site FROM PMSite ORDER BY Site DESC"
clist = system.db.runPrepQuery(query)
site = getlist(clist)
def later():
#Return drop down list of tuples
if colName == 'TypeID':
return {'options': type}
elif colName == 'FreqID':
return {'options': freq}
elif colName == 'ComponentID':
return {'options': comp}
elif colName == 'SiteID':
return {'options': site}
elif colName == 'SystemID':
return {'options': [(1, 'P1'), (2, 'P2'), (3, 'P3'), (4, 'P4')]}
elif colName == 'Criticality':
return {'options': [(1, 'Low'), (2, 'Medium'), (3, 'High')]}
system.util.invokeLater(later)
system.util.invokeAsynchronous(async)
configureCell
def async():
from datetime import datetime
def render(value,col,tbl,ID):
query = "SELECT %s FROM %s WHERE %s = ?" % (col,tbl,ID)
results = system.db.runScalarPrepQuery(query,[value],'MSSQLtest')
return results
def later(value=value):
if colName == 'TypeID':
if value:
return {'text': render(value,'TypeName','PMType','TypeID')}
else:
return {'text': ''}
elif colName == 'FreqID':
if value:
return {'text': render(value,'FreqName','PMFreq','FreqID')}
else:
return {'text': ''}
elif colName == 'ComponentID':
if value:
return {'text': render(value,'ComponentName','PMComponent','ComponentID')}
else:
return {'text': ''}
elif colName == 'SiteID':
if value:
return {'text': render(value,'Site','PMSite','SiteID')}
else:
return {'text': ''}
elif colName == 'SystemID':
if value == 1:
return {'text': ("P1")}
elif value == 2:
return {'text': ("P2")}
elif value == 3:
return {'text': ("P3")}
elif value == 4:
return {'text': ("P4")}
elif colName == 'Criticality':
if value == 1:
return {'text': ("Low"), 'background': system.gui.color(255,255,71)}
elif value == 2:
return {'text': ("Medium"), 'background': system.gui.color(255,172,71)}
elif value == 3:
return {'text': ("High"), 'background': system.gui.color(255,71,71)}
elif colName == 'LastCompletionDate':
if value:
value = system.date.parse(value, 'yyyy-MM-dd')
#return {'text': (type(value))}
#else:
#return {'text': (type(value))}
system.util.invokeLater(later)
system.util.invokeAsynchronous(async)
Any thoughts would be appreciated.
Thanks,
Josh