Knowing if we are in the select or edit panel on Roster Management Component in vision

hello, is there by means of distinguished the select or edit panel of the admin manager component?


i want to hide some component like Button if the user are in the édit panel

I was able to detect which pane was being displayed from a button using the following script:

from com.inductiveautomation.ignition.client.util.gui import SlidingPane
rosterManager = event.source.parent.getComponent('Roster Management')
def getSliderPane(rosterManager):
	for component in rosterManager.getComponents():
		if isinstance(component, SlidingPane):
			return component
		else:
			sliderPane = getSliderPane(component)
			if sliderPane is not None:
				return sliderPane
	return None
sliderPane = getSliderPane(rosterManager)
if sliderPane.getSelectedPane() == 1:
	print 'You are in the edit roster pane'
else:
	print 'You are in the select roster pane'

It simply finds the slider pane within the component, and then checks to see whether it is in position 0 which is the selction pane or position 1 which is the editor pane.

If you want this to happen automatically, here is a version that will run on the roster management tool's propertyChange event handler:

if event.propertyName == 'componentRunning':
	from com.inductiveautomation.ignition.client.util.gui import SlidingPane
	from java.beans import PropertyChangeListener
	rosterManager = event.source
	class SlidingPanePositionListener(PropertyChangeListener):
		def propertyChange(self, event):
			if event.propertyName == 'selectedPane' and event.newValue == 0:
				print 'You are in the select roster pane'
				#Modify the script here to suit your usage case
			elif event.propertyName == 'selectedPane' and event.newValue == 1:
				print 'You are in the edit roster pane'
				#Modify the script here to suit your usage case
	def getSliderPane(rosterManager):
		for component in rosterManager.getComponents():
			if isinstance(component, SlidingPane):
				return component
			else:
				sliderPane = getSliderPane(component)
				if sliderPane is not None:
					return sliderPane
		return None
	sliderPane = getSliderPane(rosterManager)
	listener = SlidingPanePositionListener()
	sliderPane.addPropertyChangeListener(listener)

This will add a listener to the component at run time that will detect when the slider pane shifts position. It is important to note that the designer would need to be in preview mode when the window is opened for the effects if this script to be seen in the designer.

Thank you it works perfectly

1 Like