GNOME Bugzilla – Bug 109402
Wrong object for object:state-changed:expanded event for tree items in java apps
Last modified: 2004-12-22 21:47:04 UTC
When using a java app and a tree node expands or collapses no "object:state-changed:expanded" is emitted. Steps to reproduce: 1. start SwingSet 2. open JTree demo page (last button from toolbar). 3. expand or collapse nodes from tree on opened page.
Contrary to the comments above, the state changed events are being emitted - though incorrectly. Java emits a state-changed:collapsed when the tree is expanded, and a state-changed:expanded when collapsed! Though, this is not how GTK+ is behaving (even when I switch the events). GTK+ is sending an: state-changed:expanded with a detail1 set to 1 or 0 depending on whether the tree is expanded or collapsed, respectively. I think this is incorrect behaviour too, since there is the presence of the COLLAPSED state, GTK+ should also send a notification for this and that's what Gnopernicus should be relying on.
The state ATK_STATE_COLLAPSED was removed from atk on 2001/11/20.
yes, the correct states of interest are ATK_STATE_EXPANDABLE and ATK_STATE_EXPANDED. at-spi has the corresponding states SPI_STATE_EXPANDABLE and SPI_STATE_EXPANDED.
So the correct behaviour is to send: object:state-changed:expanded 1 when the tree is expanded, and object:state-changed:expanded 0 when it's collapsed, is that correct?
I believe so.
Yes, events are emitted, but for tree, not for node which is expanded or collapsed. If user expands a node using arrows key, then event can be asociated with for focused object. But if user expands a node using mouse (pressing the sign which shows node state) then no chance to identify which node changes it state. In my opinion, these events should be emitted for node which change it state. Also emitting state-changed:collapsed and state-changed:expanded are redundant. A event like state-changed:expanded should be emitted when state is changing from expanded to collapsed or form collapsed to expanded, the event details should show the current state (1 if is expanded or 0 if it is not). In this scenarios, when a node becames EXPANDED are emitted events: - state-changed:expanded detail1=1 - state-changed:collapsed detail1=0 When a node becames COLLAPSED are emitted events: - state-changed:expanded detail1=0 - state-changed:collapsed detail1=1 So, emitting both events are redundant. An event like state-changed:XXXX should be emitted when the object state XXXX is changing. I mean changed from contained in object state in not contained in object state or from contained to not contained. The event detail1 parameter should show the direction of this change. Behaviour described above is the one observed by me. If it is not right, please correct me.
we don't (or shouldn't) emit 'collapsed' anymore, just 'expanded' since as Adi says they are redundant. I agree that it seems as though the expanded/collapsed node should emit the state. However, this can conflict with the MANAGES_DESCENDANTS state; treeview cells are normally TRANSIENT aren't they, and thus don't emit events? Perhaps we should indeed make exception for transience in such cases, so that the node/cell that expanded can be identified in the case of GtkTreeView.
It seem that the oldValue was being used in preference to the newValue, hence the mixup of COLLAPSED being sent in the case of an expansion and vice versa - this I can fix in the bridge. In Java though, the state-changed event is emitted by the TREE - not the NODE - this is a problem in that there is no way to know which of the NODEs has expanded/collapsed. I think that if we're to allow MANAGES_DESCENDENTS objects to have children have focus events fired, certain states (like EXPANDED) should be able to be emitted too - the question is where to draw the line. The problem is that you don't "need" to have focus on the parent of the sub-tree to expand/collapse the sub-tree.
Hmm, checking out the 1.4.2 pre-release builds, it seems that the correct node is being sent in the state-changed:expanded events now... Still a problem in all currently public Java releases though. But, the parent seems to be the node itself, not the tree - ie. for these type of events the parent is the object itself, ie it's cyclic - I've logged a bug against the Java implementation for JTree.
In Swing JTree, the nodes aren't TRANSIENT. This is a potential problem if/when the TreeModel is generating something very large (e.g. your hard drive, or Internet nodes). But as they aren't TRANSIENT at present, the nodes should emit the state change events.
Remus, Can you please verify that this is fixed in the latest build of GNOME 2.2, with a JDK version of 1.4.1 or higher.
Remus, Can you please verify this fix? Thanks, Darren.
Now, expanded event is sent by parent. To get the child who generated this event should I call AccessibleChildChangedEvent_getChildAccessible? I called it, but allway a NULL pointer is obtained. Can somebody check this? Thanks.
I believe that the problem is that the object returned in state-changed:expanded event is the JTree. If I understand Darren correctly this is fixed in jdk 1.4.2. The Sun bugtraq bug is 4839971. For GTK apps the object returned in the state-changed:expanded event is the cell which was expanded or collapsed.
Apologies for spam... marking as GNOMEVER2.3 so it appears on the official GNOME bug list :)
*** Bug 119852 has been marked as a duplicate of this bug. ***
I am closing this bug as NOTGNOME. I have confirmed that the problem is fixed in java version "1.4.2_04".