Handle the visibility of the objects

Article ID: 2130
Last updated: 28 May, 2018
Article ID: 2130
Last updated: 28 May, 2018
Revision: 3
Views: 673
Posted: 04 Mar, 2010
by Dean J.
Updated: 28 May, 2018
by Gargani A.

Question

How do I handle the visibility of the objects?

Answer

Using a filter 
The first option is to use a filter mechanism. You can find a complete paragraph on the subject in the "User's Manual, IBM ILOG JViews TGO / Programmers documentation / Graphic components / Network component /Netowkr component services / Filtering "

If you use a filter and specify a visibility criterion, only the business objects that meet this criterion are transformed into representation objects and are visible.

The filter is set to the adapter. 
If you work with an IlpNetwork, you can retrieve an instance of IlpNetworkAdapter by using the method IlpNetwork.getAdapter()
If you work with an IlpEquipment, you can retrieve an instance of IlpEquipementAdapter by using the method IlpEquipment.getAdapter()
If you work with an IlpTree, you can retrieve an instance of IlpContainmentTreeAdapter by using the method IlpTree.getAdapter()
If you work with an IlpTable, you can retrieve an instance of IlpListAdapter by using the method IlpTable.getAdapter()

Once you have retrieved the corresponding adapter, you can use the methodsetFilter(filter).

Following is a code segment which illustrate the way to implement a filter. 
In this basic case, the object with the ID "Paris" is filtered. Of course, in more complex cases, you can set the criterion on the class of the objects or anything else.

IlpNetwork network;
IltDefaultDataSource dataSource;
IlpNetworkAdapter adapter = network.getAdapter();
adapter.setDataSource(dataSource);
adapter.setFilter(new IlpFilter() {
public boolean accept(Object object) {
 IlpObject bo = (IlpObject)object;
 if (bo.getID().equals("Paris") == true)
    return false;
 return true;
}

When this filter is set, the object named "Paris" will not be visible.

If you want to cancel your filter, you can set a null value as argument to the method setFilter, as follows: 
adapter.setFilter(null);

Removing the objects from the data source 
Another way to make objects unvisible is to remove them from the data source. In some cases, it might be easier than using a filter. 
Here are some methods of the class IlpDefaultDataSource that you can use: 
public IlpObject removeObject(Object idOrIlpObject, boolean childrenToo); 
public java.util.List removeObjects(java.util.List idsOrIlpObjects, boolean childrenToo); 

public java.util.List removeObjects(java.util.List idsOrIlpObjects, java.util.List childrenTooList);

See also the following FAQs:

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2130
Last updated: 28 May, 2018
Revision: 3
Views: 673
Posted: 04 Mar, 2010 by Dean J.
Updated: 28 May, 2018 by Gargani A.
Also listed in


Others in this category