OSDN Git Service

auto import from //depot/cupcake/@135843
[android-x86/frameworks-native.git] / awt / java / awt / event / HierarchyEvent.java
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 /**
18  * @author Michael Danilov
19  * @version $Revision$
20  */
21 package java.awt.event;
22
23 import java.awt.AWTEvent;
24 import java.awt.Component;
25 //???AWT: import java.awt.Container;
26
27 /**
28  * This class is not supported in Android 1.0. It is merely provided to maintain
29  * interface compatibility with desktop Java implementations.
30  * 
31  * @since Android 1.0
32  */
33 public class HierarchyEvent extends AWTEvent {
34
35     private static final long serialVersionUID = -5337576970038043990L;
36
37     public static final int HIERARCHY_FIRST = 1400;
38
39     public static final int HIERARCHY_CHANGED = 1400;
40
41     public static final int ANCESTOR_MOVED = 1401;
42
43     public static final int ANCESTOR_RESIZED = 1402;
44
45     public static final int HIERARCHY_LAST = 1402;
46
47     public static final int PARENT_CHANGED = 1;
48
49     public static final int DISPLAYABILITY_CHANGED = 2;
50
51     public static final int SHOWING_CHANGED = 4;
52
53     //???AWT: private Container changedParent;
54     private Component changed;
55     private long changeFlag;
56
57     //???AWT
58     /*
59     public HierarchyEvent(Component source, int id, Component changed, 
60                           Container changedParent) {
61         this(source, id, changed, changedParent, 0l);
62     }
63     */
64
65     //???AWT
66     /*
67     public HierarchyEvent(Component source, int id, Component changed,
68             Container changedParent, long changeFlags) {
69         super(source, id);
70
71         this.changed = changed;
72         this.changedParent = changedParent;
73         this.changeFlag = changeFlags;
74     }
75     */
76     //???AWT: Fake constructor, should be as above.
77     public HierarchyEvent(Component source, int id, Component changed,
78             Object changedParent, long changeFlags) {
79         super(source, id);
80
81 //        this.changed = changed;
82 //        this.changedParent = changedParent;
83 //        this.changeFlag = changeFlags;
84     }
85     
86     public Component getComponent() {
87         return (Component) source;
88     }
89
90     public long getChangeFlags() {
91         return changeFlag;
92     }
93
94     public Component getChanged() {
95         return changed;
96     }
97
98     //???AWT
99     /*
100     public Container getChangedParent() {
101         return changedParent;
102
103     }
104     */
105
106     @Override
107     public String paramString() {
108         /* The format is based on 1.5 release behavior 
109          * which can be revealed by the following code:
110          * 
111          * HierarchyEvent e = new HierarchyEvent(new Button("Button"),
112          *          HierarchyEvent.HIERARCHY_CHANGED,
113          *          new Panel(), new Container());
114          * System.out.println(e);
115          */
116         String paramString = null;
117
118         switch (id) {
119         case HIERARCHY_CHANGED:
120             paramString = "HIERARCHY_CHANGED"; //$NON-NLS-1$
121             break;
122         case ANCESTOR_MOVED:
123             paramString = "ANCESTOR_MOVED"; //$NON-NLS-1$
124             break;
125         case ANCESTOR_RESIZED:
126             paramString = "ANCESTOR_RESIZED"; //$NON-NLS-1$
127             break;
128         default:
129             paramString = "unknown type"; //$NON-NLS-1$
130         }
131
132         paramString += " ("; //$NON-NLS-1$
133
134         if (id == HIERARCHY_CHANGED) {
135             if ((changeFlag & PARENT_CHANGED) > 0) {
136                 paramString += "PARENT_CHANGED,"; //$NON-NLS-1$
137             }
138             if ((changeFlag & DISPLAYABILITY_CHANGED) > 0) {
139                 paramString += "DISPLAYABILITY_CHANGED,"; //$NON-NLS-1$
140             }
141             if ((changeFlag & SHOWING_CHANGED) > 0) {
142                 paramString += "SHOWING_CHANGED,"; //$NON-NLS-1$
143             }
144         }
145
146         //???AWT
147         /*
148         return paramString + "changed=" + changed +  //$NON-NLS-1$
149                 ",changedParent=" + changedParent + ")"; //$NON-NLS-1$ //$NON-NLS-2$
150         */
151         return paramString;
152     }
153
154 }