Merged gcj-eclipse branch to trunk.
From-SVN: r120621
This commit is contained in:
parent
c648dedbde
commit
97b8365caf
17478 changed files with 606493 additions and 100744 deletions
|
@ -1,5 +1,5 @@
|
|||
/* Window.java --
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation
|
||||
Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -140,7 +140,7 @@ public class Window extends Container implements Accessible
|
|||
this();
|
||||
graphicsConfiguration = gc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes a new instance of <code>Window</code> with the specified
|
||||
* parent. The window will initially be invisible.
|
||||
|
@ -250,13 +250,13 @@ public class Window extends Container implements Accessible
|
|||
/**
|
||||
* Shows on-screen this window and any of its owned windows for whom
|
||||
* isVisible returns true.
|
||||
* @specnote: Deprecated starting in 1.5.
|
||||
*/
|
||||
@Deprecated
|
||||
public void show()
|
||||
{
|
||||
synchronized (getTreeLock())
|
||||
{
|
||||
if (parent != null && ! parent.isDisplayable())
|
||||
parent.addNotify();
|
||||
if (peer == null)
|
||||
addNotify();
|
||||
|
||||
|
@ -298,11 +298,24 @@ public class Window extends Container implements Accessible
|
|||
if (initialFocusOwner != null)
|
||||
initialFocusOwner.requestFocusInWindow();
|
||||
|
||||
// Post WINDOW_OPENED from here.
|
||||
if (windowListener != null
|
||||
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
|
||||
{
|
||||
WindowEvent ev = new WindowEvent(this,
|
||||
WindowEvent.WINDOW_OPENED);
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
tk.getSystemEventQueue().postEvent(ev);
|
||||
}
|
||||
shown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @specnote: Deprecated starting in 1.5.
|
||||
*/
|
||||
@Deprecated
|
||||
public void hide()
|
||||
{
|
||||
// Hide visible owned windows.
|
||||
|
@ -349,9 +362,15 @@ public class Window extends Container implements Accessible
|
|||
component[i].removeNotify();
|
||||
this.removeNotify();
|
||||
|
||||
// Post a WINDOW_CLOSED event.
|
||||
WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
|
||||
getToolkit().getSystemEventQueue().postEvent(we);
|
||||
// Post WINDOW_CLOSED from here.
|
||||
if (windowListener != null
|
||||
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
|
||||
{
|
||||
WindowEvent ev = new WindowEvent(this,
|
||||
WindowEvent.WINDOW_CLOSED);
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
tk.getSystemEventQueue().postEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,7 +498,11 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public synchronized void addWindowListener(WindowListener listener)
|
||||
{
|
||||
windowListener = AWTEventMulticaster.add(windowListener, listener);
|
||||
if (listener != null)
|
||||
{
|
||||
newEventsOnly = true;
|
||||
windowListener = AWTEventMulticaster.add(windowListener, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -536,7 +559,12 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void addWindowFocusListener (WindowFocusListener wfl)
|
||||
{
|
||||
windowFocusListener = AWTEventMulticaster.add (windowFocusListener, wfl);
|
||||
if (wfl != null)
|
||||
{
|
||||
newEventsOnly = true;
|
||||
windowFocusListener = AWTEventMulticaster.add (windowFocusListener,
|
||||
wfl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -546,7 +574,12 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
public void addWindowStateListener (WindowStateListener wsl)
|
||||
{
|
||||
windowStateListener = AWTEventMulticaster.add (windowStateListener, wsl);
|
||||
if (wsl != null)
|
||||
{
|
||||
newEventsOnly = true;
|
||||
windowStateListener = AWTEventMulticaster.add (windowStateListener,
|
||||
wsl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,42 +610,21 @@ public class Window extends Container implements Accessible
|
|||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
public EventListener[] getListeners(Class listenerType)
|
||||
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
|
||||
{
|
||||
if (listenerType == WindowListener.class)
|
||||
return getWindowListeners();
|
||||
return (T[]) getWindowListeners();
|
||||
return super.getListeners(listenerType);
|
||||
}
|
||||
|
||||
void dispatchEventImpl(AWTEvent e)
|
||||
{
|
||||
// Make use of event id's in order to avoid multiple instanceof tests.
|
||||
if (e.id <= WindowEvent.WINDOW_LAST
|
||||
&& e.id >= WindowEvent.WINDOW_FIRST
|
||||
&& (windowListener != null
|
||||
|| windowFocusListener != null
|
||||
|| windowStateListener != null
|
||||
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
|
||||
processEvent(e);
|
||||
else
|
||||
if (e.getID() == ComponentEvent.COMPONENT_RESIZED)
|
||||
{
|
||||
if (peer != null && (e.id == ComponentEvent.COMPONENT_RESIZED
|
||||
|| e.id == ComponentEvent.COMPONENT_MOVED))
|
||||
{
|
||||
Rectangle bounds = peer.getBounds();
|
||||
x = bounds.x;
|
||||
y = bounds.y;
|
||||
height = bounds.height;
|
||||
width = bounds.width;
|
||||
|
||||
if (e.id == ComponentEvent.COMPONENT_RESIZED)
|
||||
{
|
||||
invalidate();
|
||||
validate();
|
||||
}
|
||||
}
|
||||
super.dispatchEventImpl(e);
|
||||
invalidate();
|
||||
validate();
|
||||
}
|
||||
super.dispatchEventImpl(e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -626,7 +638,28 @@ public class Window extends Container implements Accessible
|
|||
protected void processEvent(AWTEvent evt)
|
||||
{
|
||||
if (evt instanceof WindowEvent)
|
||||
processWindowEvent((WindowEvent) evt);
|
||||
{
|
||||
WindowEvent we = (WindowEvent) evt;
|
||||
switch (evt.getID())
|
||||
{
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
processWindowEvent(we);
|
||||
break;
|
||||
case WindowEvent.WINDOW_GAINED_FOCUS:
|
||||
case WindowEvent.WINDOW_LOST_FOCUS:
|
||||
processWindowFocusEvent(we);
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
processWindowStateEvent(we);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
super.processEvent(evt);
|
||||
}
|
||||
|
@ -641,54 +674,35 @@ public class Window extends Container implements Accessible
|
|||
*/
|
||||
protected void processWindowEvent(WindowEvent evt)
|
||||
{
|
||||
int id = evt.getID();
|
||||
|
||||
if (id == WindowEvent.WINDOW_GAINED_FOCUS
|
||||
|| id == WindowEvent.WINDOW_LOST_FOCUS)
|
||||
processWindowFocusEvent (evt);
|
||||
else if (id == WindowEvent.WINDOW_STATE_CHANGED)
|
||||
processWindowStateEvent (evt);
|
||||
else
|
||||
if (windowListener != null)
|
||||
{
|
||||
if (windowListener != null)
|
||||
{
|
||||
switch (evt.getID())
|
||||
{
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
windowListener.windowActivated(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
windowListener.windowClosed(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
windowListener.windowClosing(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
windowListener.windowDeactivated(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
windowListener.windowDeiconified(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
windowListener.windowIconified(evt);
|
||||
break;
|
||||
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
windowListener.windowOpened(evt);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (evt.getID())
|
||||
{
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
windowListener.windowActivated(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
windowListener.windowClosed(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
windowListener.windowClosing(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
windowListener.windowDeactivated(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
windowListener.windowDeiconified(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
windowListener.windowIconified(evt);
|
||||
break;
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
windowListener.windowOpened(evt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Identifies if this window is active. The active window is a Frame or
|
||||
* Dialog that has focus or owns the active window.
|
||||
|
@ -1233,6 +1247,42 @@ public class Window extends Container implements Accessible
|
|||
return "win" + getUniqueLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to handle WindowEvents.
|
||||
*
|
||||
* @return <code>true</code> when the specified event type is enabled,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean eventTypeEnabled(int type)
|
||||
{
|
||||
boolean enabled = false;
|
||||
switch (type)
|
||||
{
|
||||
case WindowEvent.WINDOW_OPENED:
|
||||
case WindowEvent.WINDOW_CLOSED:
|
||||
case WindowEvent.WINDOW_CLOSING:
|
||||
case WindowEvent.WINDOW_ICONIFIED:
|
||||
case WindowEvent.WINDOW_DEICONIFIED:
|
||||
case WindowEvent.WINDOW_ACTIVATED:
|
||||
case WindowEvent.WINDOW_DEACTIVATED:
|
||||
enabled = ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0)
|
||||
|| windowListener != null;
|
||||
break;
|
||||
case WindowEvent.WINDOW_GAINED_FOCUS:
|
||||
case WindowEvent.WINDOW_LOST_FOCUS:
|
||||
enabled = ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0)
|
||||
|| windowFocusListener != null;
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
enabled = ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0)
|
||||
|| windowStateListener != null;
|
||||
break;
|
||||
default:
|
||||
enabled = super.eventTypeEnabled(type);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private static synchronized long getUniqueLong()
|
||||
{
|
||||
return next_window_number++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue