@import "alarm.css"
setStyleSheets
, as shown in Configuring the network component.
void step5(Container container) throws Exception{
alarms.xml
that contains the declaration of the custom dynamic class
Alarm
, and a number of its instances.
mainDataSource.parse("alarms.xml");
Alarm
class is described as follows in the XML data file:
<classes> <class> <name>Alarm</name> <attribute> <name>identifier</name> <javaClass>java.lang.String</javaClass> </attribute> <attribute> <name>perceivedSeverity</name> <javaClass>java.lang.Integer</javaClass> </attribute> <attribute> <name>acknowledged</name> <javaClass>java.lang.Boolean</javaClass> </attribute> <attribute> <name>creationTime</name> <javaClass>java.util.Date</javaClass> </attribute> </class> </classes>
java.lang.String
for the
id
attribute.
Alarm
class are defined by giving specific values to the attributes
of the class. For example:
<addObject id="alarm1"> <class>Alarm</class> <parent>London</parent> <attribute name="identifier">Alarm 1</attribute> <attribute name="perceivedSeverity">5</attribute> <attribute name="acknowledged">true</attribute> <attribute name="creationTime">2001-12-12T15:42:17</attribute> </addObject>
alarmTableComponent = new IlpTable();
alarmTableComponent
. This table will be used to display the alarms.
Alarm
class.
final IlpClass alarmClass = context.getClassManager().getClass("Alarm");
Alarm
class only.
alarmTableComponent.setDataSource(mainDataSource, alarmClass);
mainDataSource
. The class of business objects to be displayed from this data
source is specified as
alarmClass
.
initTableTab(container, alarmTableComponent);
tableComponent
and
alarmTableComponent
and places them in a tabbed pane. It is written in pure Swing
code.
treeAlarmFilter
. The method
accept
is used to test the acceptability of the objects offered to
this filter. The method returns
true
if the filter accepts an object.
IlpFilter treeAlarmFilter = new IlpFilter(){ public boolean accept (Object object){ IlpObject ilpObject = (IlpObject)object; if (ilpObject.getIlpClass().equals(alarmClass)) { IlpAttribute perceivedSeverityAttr = alarmClass.getAttribute("perceivedSeverity");
Object severityValue =
ilpObject.getAttributeValue(perceivedSeverityAttr);
return (new Integer(3).compareTo(alarmClass)<0); } return true; } };
Alarm
class has the attributes
perceivedSeverity
and
acknowledged
. Only alarms with a severity greater than 3 and with the
acknowledged
attribute set to
false
will be included in the table.
treeComponent.setFilter(treeAlarmFilter); }