Hello to everyone, I have code in a power table to add a progress bar to some columns of the table. The code is set in the extension function (Configure Cell). The code is doing what it's supposed to do, but the problem is that when the code is enabled, the designer and client become too slow when the window containing the power table is open.
I'm working with a trial license. I appreciate any help. Thanks
This is the code
def configureCell(self, value, textValue, selected, rowIndex, colIndex, colName, rowView, colView):
from javax.swing import JProgressBar
from java.awt import Color
from javax.swing.border import LineBorder
if colName=="kWh":
y=int(system.dataset.toPyDataSet(system.tag.read("[tp_TurbinePlant]La Loma Substation/Energy Hour Target/Target_PowerTable/Target_1_12").value)[rowIndex][0])
a = str(value)
ratio = (value/y)*100 if y != 0 else 0
if ratio < 100:
foreColor = Color(255,255,204,255)
elif ratio >= 100:
foreColor = Color(204,255,204,255)
bar = JProgressBar(0, y, stringPainted=True, string = a)
bar.setValue(value)
bar.background = Color.WHITE
bar.setForeground(foreColor)
return {'renderer': bar}
elif colName=="kWh_":
y=int(system.dataset.toPyDataSet(system.tag.read("[tp_TurbinePlant]La Loma Substation/Energy Hour Target/Target_PowerTable/Target_13_24").value)[rowIndex][0])
a = str(value)
ratio = (value/y)*100 if y != 0 else 0
if ratio < 100:
foreColor = Color(255,255,204,255)
elif ratio >= 100:
foreColor = Color(204,255,204,255)
bar = JProgressBar(0, y, stringPainted=True, string = a)
bar.setValue(value)
bar.background = Color.WHITE
bar.setForeground(foreColor)
return {'background': '#646464', 'foreground': '#FFFFFF', 'renderer': bar}
elif colName =="Hr":
X = system.tag.read("[tp_TurbinePlant]La Loma Substation/Energy Hour Target/Grid_MWH_Index").value
if value == X:
return {'border': LineBorder(system.gui.color(128,128,128), 2)}
elif colName =="Hr_":
X1 = system.tag.read("[tp_TurbinePlant]La Loma Substation/Energy Hour Target/Grid_MWH_Index").value
if value == X1:
return {'border': LineBorder(system.gui.color(128,128,128), 2)}