Clearing Power Table Selection

Hello,

I have a customized ‘onMousePress’ extension function defined for a power table, in that function I validate that the cell is allowed to be selected based upon data in the selected cell as well as other criteria. My function is working properly as far as my tracing is concerned, but the Selected Row and Column are still sometimes being updated with the selected cell’s row/column value. Below is the customized portion of the method, and the trace output. I should NOT have gotten the PropertyChange events for TankOrderSelRow and TankOrderSelCol which are tied to the table SelectedRow and SelectedColumn properties.

I don’t understand what else could be changing this… Is there another way to problematically allow/disallow powertable cell selection?

 	rootContainer = self.parent
	logger = rootContainer.getLog(method="onMousePress", lib="com.mwes.heartland", src="onMousePress", useStack=True)
	currVal = self.getTankOrderSelValue( rowIndex, colIndex )
	logger.info("Row %d, Col %d, Value %d, %s" % (rowIndex, colIndex, currVal, str(value)))
	
	if currVal > 0 and currVal < 7:
		logger.info("Clear From...")
		self.clearTankOrderSelFrom ( rowIndex, colIndex )
		self.updateProductTableFlags ( )
		self.selectedRow = -1
		self.selectedColumn = -1
	elif not self.isValidTankOrderSel( rowIndex, colIndex ):
		logger.info("Invalid...")
		self.selectedRow = -1
		self.selectedColumn = -1
	else:
		logger.info("Ok...")
		pass

	if self.selectedRow < 0 or self.selectedCol < 0:
		rootContainer.TankOrderSelected = -1
	else:
		rootContainer.TankOrderSelected = self.selectedRow * 100 + self.selectedColumn
		
	logger.info("TankOrderSelected %d" % (rootContainer.TankOrderSelected))
	

Trace output

12:56:48.002 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Startup, from isValidTankOrderSel(1),  Row 1, Col 1, Weight (A, B, C, Req) (0, 0, 0, 0)
12:56:48.002 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Haven't Divided all Requested Weight yet
12:56:48.003 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Returning False
12:56:48.003 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - Invalid...
12:56:48.004 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - TankOrderSelected -1
12:56:48.370 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - Row 1, Col 1, Value 0, 0
12:56:48.370 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Startup, from isValidTankOrderSel(1),  Row 1, Col 1, Weight (A, B, C, Req) (0, 0, 0, 0)
12:56:48.371 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Haven't Divided all Requested Weight yet
12:56:48.371 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Returning False
12:56:48.371 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - Invalid...
12:56:48.372 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - TankOrderSelected -1
12:56:48.814 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - Row 2, Col 1, Value 0, 0
12:56:48.814 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Startup, from isValidTankOrderSel(1),  Row 2, Col 1, Weight (A, B, C, Req) (0, 0, 0, 0)
12:56:48.815 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Haven't Divided all Requested Weight yet
12:56:48.815 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.isValidTankOrderSel - Returning False
12:56:48.815 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - Invalid...
12:56:48.816 [AWT-EventQueue-0] INFO com.mwes.com.mwes.heartland.onMousePress.onMousePress - TankOrderSelected -1
12:56:48.923 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.propertyChange - Property TankOrderSelRow, NewValue 2, OldValue -1, SelRow 2, SelCol 1.  ComponentRunning True, LoadingData False, EditMode False
12:56:48.924 [AWT-EventQueue-0] INFO com.mwes.HeartlandFarms.SemiAutoTruckLoad.LoadTankSelection.propertyChange - Property TankOrderSelCol, NewValue 1, OldValue -1, SelRow -1, SelCol -1.  ComponentRunning True, LoadingData False, EditMode False
1

I don’t know enough about the rest of your code to say what your specific problem is, but you should know that propertyChange events nest inside each other as one section sets properties to new values, like when you set selectedRow and selectedColumn to -1.
I strongly recommend not attempting to prevent invalid values for properties that are really under control of the java component itself. Instead, feed all relevant properties to a script/expression that will pass only valid values to another set of (custom) properties. If consistency between multiple output values matters, route through an “atomic” dataset property. Use the “validated” custom properties in bindings in other components/contexts.

Thanks for the reply…

In this instance what I’m attempting to do is allow/disallow selection of a cell. This is not being done as part of the property change event. I was just using that event notification to catch WHEN the logic in the Table onMousePress event handler was being ignored.

That is the real problem I’m attempting to understand. If you look at the trace, the event handler indicated that the selection of the cell was invalid yet the Row and Column values were still being set to that cell rather than being set to -1.

Those properties react to component internal operations in ways that are non-intuitive and can nest with other events (Recursion!). You cannot stop them from being assigned values that you want to be invalid. Where you are trying to reverse such an assignment can be nested inside internal component operations that leave it with an undesired value. That’s my point. When you encounter such situations, create properties for filteredRow and filteredColumn. Have your logic pass valid row/column selections to those properties, and ignore invalid combinations. Use the filtered properties everywhere else, and the rest of your logic will never see invalid combinations.