%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.portlets.layout.LayoutEvent |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.portlets.layout; |
|
18 | ||
19 | import org.apache.jetspeed.om.page.Fragment; |
|
20 | ||
21 | /** |
|
22 | * A LayoutEvent is used by ColumnLayout to notify its LayoutAeventListeners |
|
23 | * that there have been a change in the position of a fragment within the layout. |
|
24 | * <h3>Constant Values</h3> |
|
25 | * <ul> |
|
26 | * <li>ADDED == 0</li> |
|
27 | * <li>MOVED_UP == 1</li> |
|
28 | * <li>MOVED_DOWN == 2</li> |
|
29 | * <li>MOVED_LEFT == 3</li> |
|
30 | * <li>MOVED_RIGHT == 4</li> |
|
31 | * </ul> |
|
32 | * |
|
33 | * |
|
34 | * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a> |
|
35 | * @see org.apache.jetspeed.om.page.Fragment |
|
36 | * @see org.apache.jetspeed.portlets.layout.LayoutEventListener |
|
37 | * @see org.apache.jetspeed.portlets.layout.ColumnLayout |
|
38 | * |
|
39 | */ |
|
40 | public class LayoutEvent |
|
41 | { |
|
42 | /**Event type value that notifies that a fragment has been added */ |
|
43 | public static final int ADDED =0; |
|
44 | /**Event type value that notifies that a fragment has been moved up */ |
|
45 | public static final int MOVED_UP = 1; |
|
46 | /**Event type value that notifies that a fragment has been moved down */ |
|
47 | public static final int MOVED_DOWN = 2; |
|
48 | /**Event type value that notifies that a fragment has been moved left */ |
|
49 | public static final int MOVED_LEFT = 3; |
|
50 | /**Event type value that notifies that a fragment has been moved right */ |
|
51 | public static final int MOVED_RIGHT = 4; |
|
52 | ||
53 | private final int eventType; |
|
54 | private final Fragment fragment; |
|
55 | private final LayoutCoordinate originalCoordinate; |
|
56 | private final LayoutCoordinate newCoordinate; |
|
57 | ||
58 | /** |
|
59 | * |
|
60 | * @param eventType The type of event (see the event constants) |
|
61 | * @param fragment Fragment that is the target of this event. |
|
62 | * @param originalCoordinate the previous LayoutCoordinate of this Fragment |
|
63 | * @param newCoordinate the new and current coordinates of this fragment. |
|
64 | * @see org.apache.jetspeed.om.page.Fragment |
|
65 | */ |
|
66 | public LayoutEvent(int eventType, Fragment fragment, LayoutCoordinate originalCoordinate, LayoutCoordinate newCoordinate) |
|
67 | { |
|
68 | 0 | super(); |
69 | 0 | this.eventType = eventType; |
70 | 0 | this.fragment = fragment; |
71 | 0 | this.originalCoordinate = originalCoordinate; |
72 | 0 | this.newCoordinate = newCoordinate; |
73 | 0 | } |
74 | ||
75 | ||
76 | /** |
|
77 | * Returns the event type (see event constants) |
|
78 | * @return the event type (see event constants) |
|
79 | * @see ColumnLayout#layoutType |
|
80 | */ |
|
81 | public int getEventType() |
|
82 | { |
|
83 | 0 | return eventType; |
84 | } |
|
85 | ||
86 | /** |
|
87 | * Returns the fragment that is the target of this event. |
|
88 | * @return Fragment the fragment that is the target of this event. |
|
89 | * @see org.apache.jetspeed.om.page.Fragment |
|
90 | */ |
|
91 | public Fragment getFragment() |
|
92 | { |
|
93 | 0 | return fragment; |
94 | } |
|
95 | ||
96 | /** |
|
97 | * Returns the new/current coordinate of the Fragment targeted by this event. |
|
98 | * @return the new/current coordinate of the Fragment targeted by this event. |
|
99 | * @see LayoutCoordinate |
|
100 | */ |
|
101 | public LayoutCoordinate getNewCoordinate() |
|
102 | { |
|
103 | 0 | return newCoordinate; |
104 | } |
|
105 | ||
106 | /** |
|
107 | * Returns the original (prior to the event) coordinate of the Fragment targeted by this event. |
|
108 | * @return the original (prior to the event) coordinate of the Fragment targeted by this event. |
|
109 | * @see LayoutCoordinate |
|
110 | */ |
|
111 | public LayoutCoordinate getOriginalCoordinate() |
|
112 | { |
|
113 | 0 | return originalCoordinate; |
114 | } |
|
115 | ||
116 | ||
117 | public boolean equals(Object obj) |
|
118 | { |
|
119 | 0 | if(obj instanceof LayoutEvent) |
120 | { |
|
121 | 0 | LayoutEvent event = (LayoutEvent) obj; |
122 | 0 | return event.fragment.equals(fragment) |
123 | && event.eventType == eventType |
|
124 | && event.originalCoordinate.equals(originalCoordinate) |
|
125 | && event.newCoordinate.equals(newCoordinate); |
|
126 | ||
127 | } |
|
128 | else |
|
129 | { |
|
130 | 0 | return false; |
131 | } |
|
132 | } |
|
133 | ||
134 | ||
135 | public String toString() |
|
136 | { |
|
137 | 0 | return "event_target="+fragment.getId()+",event_type_code="+ eventType + ",orginial_coordinate="+ originalCoordinate+ |
138 | ",new_coordinate="+newCoordinate; |
|
139 | } |
|
140 | ||
141 | ||
142 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |