001: /*
002: * Lucane - a collaborative platform
003: * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: */
019:
020: package org.lucane.client.widgets;
021:
022: import java.awt.*;
023: import java.awt.event.KeyListener;
024: import java.awt.event.WindowListener;
025: import java.beans.PropertyChangeListener;
026: import java.util.ArrayList;
027: import java.util.Iterator;
028:
029: import javax.swing.*;
030:
031: import org.lucane.client.Client;
032: import org.lucane.client.Plugin;
033:
034: public class ManagedWindow {
035: private String name;
036: private ArrayList propertyListeners = new ArrayList();
037: private ArrayList windowListeners = new ArrayList();
038: private ArrayList keyListeners = new ArrayList();
039: private JRootPane rootPane = new JRootPane();
040: private String title = null;
041: private Image iconImage = null;
042: private boolean resizeable = true;
043: private Dimension maximumSize = null;
044: private Dimension minimumSize = null;
045: private Dimension preferredSize = null;
046: private Plugin owner;
047: private boolean exitPluginOnClose = false;
048: private boolean discardWidgetState = false;
049: private ArrayList managedWidgets = new ArrayList();
050:
051: public ManagedWindow(Plugin owner, String title) {
052: this .owner = owner;
053: this .title = title;
054: setIconImage(owner.getImageIcon(owner.getIcon()).getImage());
055: }
056:
057: public Plugin getOwner() {
058: return this .owner;
059: }
060:
061: public void setDiscardWidgetState(boolean discard) {
062: this .discardWidgetState = discard;
063: }
064:
065: public boolean discardWidgetState() {
066: return discardWidgetState;
067: }
068:
069: public void setExitPluginOnClose(boolean exit) {
070: this .exitPluginOnClose = exit;
071: }
072:
073: public boolean mustExitPluginOnClose() {
074: return exitPluginOnClose;
075: }
076:
077: public void show() {
078: Client.getInstance().getWindowManager().show(this );
079: }
080:
081: public void hide() {
082: Client.getInstance().getWindowManager().hide(this );
083: }
084:
085: public boolean isVisible() {
086: return Client.getInstance().getWindowManager().isVisible(this );
087: }
088:
089: public void dispose() {
090: Client.getInstance().getWindowManager().dispose(this );
091: }
092:
093: public void setName(String name) {
094: this .name = name;
095: }
096:
097: public String getName() {
098: return this .name;
099: }
100:
101: public void setMaximumSize(Dimension size) {
102: this .maximumSize = size;
103: }
104:
105: public Dimension getMaximumSize() {
106: return maximumSize;
107: }
108:
109: public void setMinimumSize(Dimension size) {
110: this .minimumSize = size;
111: }
112:
113: public Dimension getMinimumSize() {
114: return minimumSize;
115: }
116:
117: public void setPreferredSize(Dimension size) {
118: this .preferredSize = size;
119: }
120:
121: public Dimension getPreferredSize() {
122: return preferredSize;
123: }
124:
125: public void addWindowListener(WindowListener listener) {
126: this .windowListeners.add(listener);
127: }
128:
129: public Iterator getWindowListeners() {
130: return this .windowListeners.iterator();
131: }
132:
133: public void addKeyListener(KeyListener listener) {
134: this .keyListeners.add(listener);
135: }
136:
137: public Iterator getKeyListeners() {
138: return this .keyListeners.iterator();
139: }
140:
141: public void addPropertyChangeListener(
142: PropertyChangeListener listener) {
143: this .propertyListeners.add(listener);
144: }
145:
146: public void setTitle(String title) {
147: this .title = title;
148: }
149:
150: public String getTitle() {
151: return this .title;
152: }
153:
154: public void setIconImage(Image image) {
155: this .iconImage = image;
156: }
157:
158: public Image getIconImage() {
159: return this .iconImage;
160: }
161:
162: public void setContentPane(Container container) {
163: rootPane.setContentPane(container);
164: }
165:
166: public Container getContentPane() {
167: return rootPane.getContentPane();
168: }
169:
170: public void setJMenuBar(JMenuBar menu) {
171: rootPane.setJMenuBar(menu);
172: }
173:
174: public JMenuBar getJMenuBar() {
175: return rootPane.getJMenuBar();
176: }
177:
178: public void setResizeable(boolean resizeable) {
179: this .resizeable = resizeable;
180: }
181:
182: public boolean isResizeable() {
183: return this .resizeable;
184: }
185:
186: public void manageWidget(JComponent widget) {
187: this .managedWidgets.add(widget);
188: }
189:
190: public Iterator getManagedWidgets() {
191: return this.managedWidgets.iterator();
192: }
193: }
|