Notification when a subnetwork is collapsed or expanded

Article ID: 2151
Last updated: 28 May, 2018
Article ID: 2151
Last updated: 28 May, 2018
Revision: 3
Views: 628
Posted: 15 Sep, 2003
by Dean J.
Updated: 28 May, 2018
by Gargani A.

Question

How to receive notification when a subnetwork is collapsed or expanded?

Answer

The proper way to "listen" to the expansion or collapsing of elements (subnetworks) requested through IlpExpandObjectAction or IlpCollapseObjectAction is to set a custom IlpNetworkHandler to the IlpNetwork in question, so that it overrides the triggered handleCollapseObject and handleExpandObject methods, as shown below:

IlpNetwork network;

network.setHandler(

new IlpNetworkHandlerWithDataSource (

network,

network.getAdapter(),

(IlpMutableDataSource)subnetwork.getDataSource()) {

public void handleCollapseObject (IlpRepresentationObject object) {

//add your code here

//...

super.handleCollapseObject(object);

}

public void handleExpandObject (IlpRepresentationObject object) {

//add your code here

//...

super.handleExpandObject(object);

}

});

To "listen" to the expansion or collapsing of elements not triggered by an interactor (the default behaviour when the user clicks or double-clicks a subnetwork), that is, when the expansion or collapsing is done programmatically, you can add a ilog.cpl.graph.NodeExpansionListener to the target view using IlpGraphView.addNodeExpansionListener(NodeExpansionListener listener) method.

If you need to catch the expand or collapse event before the action is performed, then you need to subclass the IlpNetworkView and overriding the collapseObject and expandObject methods and to set it to the IlpNetwork in question.

IlpNetwork network;

network.setView(

new IlpNetworkView () {

public void collapseObject (IlpRepresentationObject object) {

//add your code here

//...

super.collapseObject(object);

}

public void expandObject (IlpRepresentationObject object) {

//add your code here

//...

super.expandObject(object);

}

});

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2151
Last updated: 28 May, 2018
Revision: 3
Views: 628
Posted: 15 Sep, 2003 by Dean J.
Updated: 28 May, 2018 by Gargani A.
Also listed in


Others in this category