1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.caleigo.core.event;
20
21 import org.caleigo.core.*;
22
23 /*** Event for relaying changes in the content of EntityCollection 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 SelectionEvent extends java.util.EventObject
35 {
36
37 public static final int CONTENTS_CHANGED = 1;
38 public static final int ENTITY_ADDED = 3;
39 public static final int ENTITY_REMOVED = 4;
40
41
42 private int mEventType;
43 private IEntity mEntity;
44 private int mRowIndex;
45
46
47
48 /*** Creates new EntityCollectionEvent with the type CONTENTS_CHANGED.
49 */
50 public SelectionEvent(ISelection source)
51 {
52 super(source);
53 mEventType = CONTENTS_CHANGED;
54 }
55
56 /*** Creates new EntityCollectionEvent with the specified type and entity.
57 */
58 public SelectionEvent(ISelection source, int eventType, IEntity entity, int row)
59 {
60 super(source);
61 mEventType = eventType;
62 mEntity = entity;
63 mRowIndex = row;
64 }
65
66
67 public String toString()
68 {
69 String params = null;
70 switch(mEventType)
71 {
72 case CONTENTS_CHANGED:
73 params = "CONTENTS_CHANGED";
74 break;
75 case ENTITY_ADDED:
76 params = "ENTITY_ADDED";
77 break;
78 case ENTITY_REMOVED:
79 params = "ENTITY_REMOVED";
80 break;
81 default:
82 params = "UNKNOWN_TYPE";
83 break;
84 }
85 return getClass().getName()+"["+params+"] on "+source.toString();
86 }
87
88
89 public ISelection getSourceSelection()
90 {
91 return (ISelection)this.getSource();
92 }
93
94 public int getEventType()
95 {
96 return mEventType;
97 }
98
99 public IEntity getEntity()
100 {
101 return mEntity;
102 }
103
104 public int getRowIndex()
105 {
106 return mRowIndex;
107 }
108 }