KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > ManagedObjectClientComposition > stateChangeSegImpl


1 /*====================================================================
2
3 This file was produced by the OpenCCM CIF_JIMPL generator.
4
5 OpenCCM: The Open CORBA Component Model Platform
6 Copyright (C) 2000-2003 INRIA - USTL - LIFL - GOAL
7 Contact: openccm@objectweb.org
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA
23
24 Initial developer(s): Christophe Demarey.
25 Contributor(s): ______________________________________.
26
27 ====================================================================*/

28
29 package ist.coach.coachEmfClientComponents.ManagedObjectClientComposition;
30
31 import intt.itu.itut_x780.*;
32 import java.text.DateFormat JavaDoc;
33 import ist.coach.coachEmfCommon.Utils;
34
35 /**
36  * This is the CIDL-based implementation of the
37  * OMG IDL3 CIDL:coach.ist/coachEmfClientComponents/ManagedObjectClientComposition/ManagedObjectClientHome_impl/ManagedObjectClient_impl/stateChangeSeg:1.0 segment type.
38  *
39  * @author OpenCCM CIF_Jimpl Compiler.
40  */

41 public class stateChangeSegImpl
42      extends ist.coach.coachEmfClientComponents.ManagedObjectClientComposition.stateChangeSeg
43 {
44     // ==================================================================
45
//
46
// Internal states.
47
//
48
// ==================================================================
49

50     // ==================================================================
51
//
52
// Constructors.
53
//
54
// ==================================================================
55

56     public stateChangeSegImpl()
57     {
58
59     }
60
61     // ==================================================================
62
//
63
// Methods.
64
//
65
// ==================================================================
66

67     /**
68      * Implementation of the ::itut_q816Components::CCM_StateChangedEventConsumer::push operation.
69      */

70     public void
71     push(ist.coach.itut_q816Components.StateChangedEvent event)
72     {
73        //
74
// DONE : implement
75
//
76
System.err.println("---->StateChangedEvent received: ");
77         System.err.println("Source Object Name = " + Utils.name2string(event.source));
78         System.err.println("Source Object Type = " + event.sourceClass);
79         System.err.println("Notification Id = " + event.notificationIdentifier);
80         String JavaDoc details = new String JavaDoc();
81         for(int i = 0; i < event.attributeList.length; i++) {
82           details += event.attributeList[i].attributeName + " changed ";
83           if (event.attributeList[i].oldValue != null) {
84             OperationalStateType oldState = OperationalStateTypeHelper.extract(
85                       event.attributeList[i].oldValue);
86             details += " from ";
87             switch(oldState.value()) {
88               case OperationalStateType._disabled :
89                 details += "Disabled";
90                  break;
91               case OperationalStateType._enabled :
92                 details += "Enabled";
93                 break;
94               default:
95                 details += "Unknown";
96            }
97           }
98           if (event.attributeList[i].newValue != null) {
99             OperationalStateType newState = OperationalStateTypeHelper.extract(
100                       event.attributeList[i].newValue);
101             details += " to ";
102             switch(newState.value()) {
103               case OperationalStateType._disabled :
104                 details += "Disabled";
105                  break;
106               case OperationalStateType._enabled :
107                 details += "Enabled";
108                 break;
109               default:
110                 details += "Unknown";
111            }
112           }
113         }
114
115         System.err.println("Details = " + details);
116         java.util.Date JavaDoc event_date = new java.util.Date JavaDoc(event.eventTime.time);
117         DateFormat JavaDoc df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
118         String JavaDoc time_str = df.format(event_date);
119         System.err.println("Date = " + time_str);
120
121         ManagedObjectClientImpl main_segment = (ManagedObjectClientImpl) get_main_segment();
122         //System.err.println("StateChange is pushed to Gui Client");
123
main_segment.ui_client.print_alarm(time_str,
124                 ist.coach.coachEmfClientComponents.gui.GuiMessages.state_changed_alarm,
125                 Utils.name2string(event.source), event.sourceClass,
126                 String.valueOf(event.notificationIdentifier), details);
127     }
128
129 }
130
Popular Tags