summaryrefslogtreecommitdiffstats
path: root/awt/java/awt/event/HierarchyEvent.java
blob: c1d22f44cef665b14c8bbe98b761562d86a1c5af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * @author Michael Danilov
 * @version $Revision$
 */
package java.awt.event;

import java.awt.AWTEvent;
import java.awt.Component;
//???AWT: import java.awt.Container;

/**
 * This class is not supported in Android 1.0. It is merely provided to maintain
 * interface compatibility with desktop Java implementations.
 * 
 * @since Android 1.0
 */
public class HierarchyEvent extends AWTEvent {

    private static final long serialVersionUID = -5337576970038043990L;

    public static final int HIERARCHY_FIRST = 1400;

    public static final int HIERARCHY_CHANGED = 1400;

    public static final int ANCESTOR_MOVED = 1401;

    public static final int ANCESTOR_RESIZED = 1402;

    public static final int HIERARCHY_LAST = 1402;

    public static final int PARENT_CHANGED = 1;

    public static final int DISPLAYABILITY_CHANGED = 2;

    public static final int SHOWING_CHANGED = 4;

    //???AWT: private Container changedParent;
    private Component changed;
    private long changeFlag;

    //???AWT
    /*
    public HierarchyEvent(Component source, int id, Component changed, 
                          Container changedParent) {
        this(source, id, changed, changedParent, 0l);
    }
    */

    //???AWT
    /*
    public HierarchyEvent(Component source, int id, Component changed,
            Container changedParent, long changeFlags) {
        super(source, id);

        this.changed = changed;
        this.changedParent = changedParent;
        this.changeFlag = changeFlags;
    }
    */
    //???AWT: Fake constructor, should be as above.
    public HierarchyEvent(Component source, int id, Component changed,
            Object changedParent, long changeFlags) {
        super(source, id);

//        this.changed = changed;
//        this.changedParent = changedParent;
//        this.changeFlag = changeFlags;
    }
    
    public Component getComponent() {
        return (Component) source;
    }

    public long getChangeFlags() {
        return changeFlag;
    }

    public Component getChanged() {
        return changed;
    }

    //???AWT
    /*
    public Container getChangedParent() {
        return changedParent;

    }
    */

    @Override
    public String paramString() {
        /* The format is based on 1.5 release behavior 
         * which can be revealed by the following code:
         * 
         * HierarchyEvent e = new HierarchyEvent(new Button("Button"),
         *          HierarchyEvent.HIERARCHY_CHANGED,
         *          new Panel(), new Container());
         * System.out.println(e);
         */
        String paramString = null;

        switch (id) {
        case HIERARCHY_CHANGED:
            paramString = "HIERARCHY_CHANGED"; //$NON-NLS-1$
            break;
        case ANCESTOR_MOVED:
            paramString = "ANCESTOR_MOVED"; //$NON-NLS-1$
            break;
        case ANCESTOR_RESIZED:
            paramString = "ANCESTOR_RESIZED"; //$NON-NLS-1$
            break;
        default:
            paramString = "unknown type"; //$NON-NLS-1$
        }

        paramString += " ("; //$NON-NLS-1$

        if (id == HIERARCHY_CHANGED) {
            if ((changeFlag & PARENT_CHANGED) > 0) {
                paramString += "PARENT_CHANGED,"; //$NON-NLS-1$
            }
            if ((changeFlag & DISPLAYABILITY_CHANGED) > 0) {
                paramString += "DISPLAYABILITY_CHANGED,"; //$NON-NLS-1$
            }
            if ((changeFlag & SHOWING_CHANGED) > 0) {
                paramString += "SHOWING_CHANGED,"; //$NON-NLS-1$
            }
        }

        //???AWT
        /*
        return paramString + "changed=" + changed +  //$NON-NLS-1$
                ",changedParent=" + changedParent + ")"; //$NON-NLS-1$ //$NON-NLS-2$
        */
        return paramString;
    }

}