1 /* (c) Copyright 2003 Caleigo AB, All rights reserved.
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */
18
19 package org.caleigo.core.event;
20
21 import org.caleigo.core.*;
22
23 /*** Event for relaying notifications of performed operations in IEntity objects.
24 *
25 * @author Dennis Zikovic
26 * @version 1.00
27 *
28 *//*
29 *
30 * WHEN WHO WHY & WHAT
31 * ------------------------------------------------------------------------------
32 * 2001-10-23 Dennis Zikovic Creation
33 */
34 public class EntityEvent extends java.util.EventObject
35 {
36 // Constants ---------------------------------------------------------------
37 public static final int STORED = 1;
38 public static final int DELETED = 2;
39 public static final int REFRESHED = 3;
40 public static final int DATA_CHANGED = 4;
41 public static final int STATUS_CHANGED = 5;
42
43 // Data members ------------------------------------------------------------
44 private int mEventType;
45
46 // Constructors ------------------------------------------------------------
47
48 /*** Creates new EntityCollectionEvent
49 */
50 public EntityEvent(IEntity sourceEntity, int eventType)
51 {
52 super(sourceEntity);
53 mEventType = eventType;
54 }
55
56 // Superclass overrides ----------------------------------------------------
57 public String toString()
58 {
59 String params = null;
60 switch(mEventType)
61 {
62 case STORED:
63 params = "STORED";
64 break;
65 case DELETED:
66 params = "DELETED";
67 break;
68 case REFRESHED:
69 params = "REFRESHED";
70 break;
71 case DATA_CHANGED:
72 params = "DATA_CHANGED";
73 break;
74 case STATUS_CHANGED:
75 params = "STATUS_CHANGED";
76 break;
77 default:
78 params = "UNKNOWN_TYPE";
79 break;
80 }
81 return getClass().getName()+"["+params+"] on "+source.toString();
82 }
83
84 // Access methods ----------------------------------------------------------
85 public IEntity getSourceEntity()
86 {
87 return (IEntity)this.getSource();
88 }
89
90 public int getEventType()
91 {
92 return mEventType;
93 }
94 }