01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2003 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //This library is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: //Lesser General Public License for more details.
13: //
14: //You should have received a copy of the GNU Lesser General Public
15: //License along with this library; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17:
18: package net.ar.webonswing.wrapping.swing;
19:
20: import java.awt.*;
21:
22: import javax.swing.*;
23:
24: import net.ar.webonswing.managers.windows.*;
25: import net.ar.webonswing.wrapping.*;
26:
27: public class SwingWindowManager extends DefaultWindowManager {
28: protected boolean isWindowEquals(Object aComponent,
29: VisualWindow theWindowWrapper) {
30: if (aComponent instanceof Window) {
31: Window theWindow = (Window) aComponent;
32: return ((ComponentWrapper) theWindowWrapper)
33: .getWrappedComponent().equals(theWindow);
34: }
35: return false;
36: }
37:
38: protected VisualWindow getNewVisualWindowFor(Object aWindowToShow) {
39: VisualWindow theWindowToShowWrapper = new SwingWindowWrapper(
40: aWindowToShow);
41: return theWindowToShowWrapper;
42: }
43:
44: protected void showNormal(Object aWindowToShow) {
45: ((Window) aWindowToShow).show();
46: }
47:
48: protected void hideNormal(Object aWindow) {
49: ((Window) aWindow).hide();
50: }
51:
52: protected boolean isWindowModal(Object aWindowToShow) {
53: if (aWindowToShow instanceof Dialog)
54: return ((Dialog) aWindowToShow).isModal();
55: else
56: return false;
57: }
58:
59: protected WindowManager getWindowManager(Object anOpenerWindow) {
60: return (WindowManager) getWindowProperty(anOpenerWindow,
61: WINDOW_MANAGER_PROPERTY);
62: }
63:
64: protected void setWindowManager(Object aWindow,
65: WindowManager aWindowManager) {
66: if (aWindow instanceof ComponentWrapper)
67: setWindowProperty(((ComponentWrapper) aWindow)
68: .getWrappedComponent(), WINDOW_MANAGER_PROPERTY,
69: aWindowManager);
70: else if (aWindow instanceof Window)
71: setWindowProperty(aWindow, WINDOW_MANAGER_PROPERTY,
72: aWindowManager);
73: }
74:
75: protected Object getRealWindow(Object aWindow) {
76: return ((ComponentWrapper) aWindow).getWrappedComponent();
77: }
78:
79: public static Object getWindowProperty(Object aWindow,
80: String aPropertyName) {
81: if (aWindow instanceof RootPaneContainer)
82: return ((JComponent) ((RootPaneContainer) aWindow)
83: .getContentPane()).getClientProperty(aPropertyName);
84:
85: return null;
86: }
87:
88: public static Object setWindowProperty(Object aWindow,
89: String aPropertyName, Object aValue) {
90: if (aWindow instanceof RootPaneContainer) {
91: ((JComponent) ((RootPaneContainer) aWindow)
92: .getContentPane()).putClientProperty(aPropertyName,
93: aValue);
94: return aValue;
95: }
96:
97: return null;
98: }
99: }
|