001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Michael Danilov
019: * @version $Revision$
020: */package java.awt.event;
021:
022: import java.awt.AWTEvent;
023: import java.awt.Component;
024: import java.awt.Container;
025:
026: public class HierarchyEvent extends AWTEvent {
027:
028: private static final long serialVersionUID = -5337576970038043990L;
029:
030: public static final int HIERARCHY_FIRST = 1400;
031:
032: public static final int HIERARCHY_CHANGED = 1400;
033:
034: public static final int ANCESTOR_MOVED = 1401;
035:
036: public static final int ANCESTOR_RESIZED = 1402;
037:
038: public static final int HIERARCHY_LAST = 1402;
039:
040: public static final int PARENT_CHANGED = 1;
041:
042: public static final int DISPLAYABILITY_CHANGED = 2;
043:
044: public static final int SHOWING_CHANGED = 4;
045:
046: private Container changedParent;
047: private Component changed;
048: private long changeFlag;
049:
050: public HierarchyEvent(Component source, int id, Component changed,
051: Container changedParent) {
052: this (source, id, changed, changedParent, 0l);
053: }
054:
055: public HierarchyEvent(Component source, int id, Component changed,
056: Container changedParent, long changeFlags) {
057: super (source, id);
058:
059: this .changed = changed;
060: this .changedParent = changedParent;
061: this .changeFlag = changeFlags;
062: }
063:
064: public Component getComponent() {
065: return (Component) source;
066: }
067:
068: public long getChangeFlags() {
069: return changeFlag;
070: }
071:
072: public Component getChanged() {
073: return changed;
074: }
075:
076: public Container getChangedParent() {
077: return changedParent;
078: }
079:
080: @Override
081: public String paramString() {
082: /* The format is based on 1.5 release behavior
083: * which can be revealed by the following code:
084: *
085: * HierarchyEvent e = new HierarchyEvent(new Button("Button"),
086: * HierarchyEvent.HIERARCHY_CHANGED,
087: * new Panel(), new Container());
088: * System.out.println(e);
089: */
090: String paramString = null;
091:
092: switch (id) {
093: case HIERARCHY_CHANGED:
094: paramString = "HIERARCHY_CHANGED"; //$NON-NLS-1$
095: break;
096: case ANCESTOR_MOVED:
097: paramString = "ANCESTOR_MOVED"; //$NON-NLS-1$
098: break;
099: case ANCESTOR_RESIZED:
100: paramString = "ANCESTOR_RESIZED"; //$NON-NLS-1$
101: break;
102: default:
103: paramString = "unknown type"; //$NON-NLS-1$
104: }
105:
106: paramString += " ("; //$NON-NLS-1$
107:
108: if (id == HIERARCHY_CHANGED) {
109: if ((changeFlag & PARENT_CHANGED) > 0) {
110: paramString += "PARENT_CHANGED,"; //$NON-NLS-1$
111: }
112: if ((changeFlag & DISPLAYABILITY_CHANGED) > 0) {
113: paramString += "DISPLAYABILITY_CHANGED,"; //$NON-NLS-1$
114: }
115: if ((changeFlag & SHOWING_CHANGED) > 0) {
116: paramString += "SHOWING_CHANGED,"; //$NON-NLS-1$
117: }
118: }
119:
120: return paramString + "changed=" + changed + //$NON-NLS-1$
121: ",changedParent=" + changedParent + ")"; //$NON-NLS-1$ //$NON-NLS-2$
122: }
123:
124: }
|