KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > client > widgets > ManagedWindow


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package org.lucane.client.widgets;
21
22 import java.awt.*;
23 import java.awt.event.KeyListener JavaDoc;
24 import java.awt.event.WindowListener JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import javax.swing.*;
30
31 import org.lucane.client.Client;
32 import org.lucane.client.Plugin;
33
34  
35 public class ManagedWindow
36 {
37     private String JavaDoc name;
38     private ArrayList JavaDoc propertyListeners = new ArrayList JavaDoc();
39     private ArrayList JavaDoc windowListeners = new ArrayList JavaDoc();
40     private ArrayList JavaDoc keyListeners = new ArrayList JavaDoc();
41     private JRootPane rootPane = new JRootPane();
42     private String JavaDoc title = null;
43     private Image iconImage = null;
44     private boolean resizeable = true;
45     private Dimension maximumSize = null;
46     private Dimension minimumSize = null;
47     private Dimension preferredSize = null;
48     private Plugin owner;
49     private boolean exitPluginOnClose = false;
50     private boolean discardWidgetState = false;
51     private ArrayList JavaDoc managedWidgets = new ArrayList JavaDoc();
52     
53     public ManagedWindow(Plugin owner, String JavaDoc title)
54     {
55         this.owner = owner;
56         this.title = title;
57         setIconImage(owner.getImageIcon(owner.getIcon()).getImage());
58     }
59
60     public Plugin getOwner()
61     {
62         return this.owner;
63     }
64     
65     public void setDiscardWidgetState(boolean discard)
66     {
67         this.discardWidgetState = discard;
68     }
69     
70     public boolean discardWidgetState()
71     {
72         return discardWidgetState;
73     }
74     
75     public void setExitPluginOnClose(boolean exit)
76     {
77         this.exitPluginOnClose = exit;
78     }
79     
80     public boolean mustExitPluginOnClose()
81     {
82         return exitPluginOnClose;
83     }
84
85     public void show()
86     {
87         Client.getInstance().getWindowManager().show(this);
88     }
89         
90     public void hide()
91     {
92         Client.getInstance().getWindowManager().hide(this);
93     }
94     
95     public boolean isVisible()
96     {
97         return Client.getInstance().getWindowManager().isVisible(this);
98     }
99     
100     public void dispose()
101     {
102         Client.getInstance().getWindowManager().dispose(this);
103     }
104     
105     public void setName(String JavaDoc name)
106     {
107         this.name = name;
108     }
109     
110     public String JavaDoc getName()
111     {
112         return this.name;
113     }
114
115     public void setMaximumSize(Dimension size)
116     {
117         this.maximumSize = size;
118     }
119     
120     public Dimension getMaximumSize()
121     {
122         return maximumSize;
123     }
124     
125     public void setMinimumSize(Dimension size)
126     {
127         this.minimumSize = size;
128     }
129     
130     public Dimension getMinimumSize()
131     {
132         return minimumSize;
133     }
134     
135     public void setPreferredSize(Dimension size)
136     {
137         this.preferredSize = size;
138     }
139
140     public Dimension getPreferredSize()
141     {
142         return preferredSize;
143     }
144     
145     public void addWindowListener(WindowListener JavaDoc listener)
146     {
147         this.windowListeners.add(listener);
148     }
149     
150     public Iterator JavaDoc getWindowListeners()
151     {
152         return this.windowListeners.iterator();
153     }
154     
155     public void addKeyListener(KeyListener JavaDoc listener)
156     {
157         this.keyListeners.add(listener);
158     }
159     
160     public Iterator JavaDoc getKeyListeners()
161     {
162         return this.keyListeners.iterator();
163     }
164     
165     public void addPropertyChangeListener(PropertyChangeListener JavaDoc listener)
166     {
167         this.propertyListeners.add(listener);
168     }
169     
170     public void setTitle(String JavaDoc title)
171     {
172         this.title = title;
173     }
174     
175     public String JavaDoc getTitle()
176     {
177         return this.title;
178     }
179     
180     public void setIconImage(Image image)
181     {
182         this.iconImage = image;
183     }
184     
185     public Image getIconImage()
186     {
187         return this.iconImage;
188     }
189     
190     public void setContentPane(Container container)
191     {
192         rootPane.setContentPane(container);
193     }
194
195     public Container getContentPane()
196     {
197         return rootPane.getContentPane();
198     }
199     
200     public void setJMenuBar(JMenuBar menu)
201     {
202         rootPane.setJMenuBar(menu);
203     }
204     
205     public JMenuBar getJMenuBar()
206     {
207         return rootPane.getJMenuBar();
208     }
209     
210     public void setResizeable(boolean resizeable)
211     {
212         this.resizeable = resizeable;
213     }
214     
215     public boolean isResizeable()
216     {
217         return this.resizeable;
218     }
219     
220     public void manageWidget(JComponent widget)
221     {
222         this.managedWidgets.add(widget);
223     }
224     
225     public Iterator JavaDoc getManagedWidgets()
226     {
227         return this.managedWidgets.iterator();
228     }
229 }
Popular Tags