KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > serverconfig > PreviewConfigDialog


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.serverconfig;
20
21 import java.awt.*;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25
26 import org.openharmonise.vfs.*;
27 import org.openharmonise.vfs.context.*;
28
29
30 /**
31  *
32  * @author matt treanor
33  * @version $Revision: 1.1 $
34  *
35  */

36 public class PreviewConfigDialog extends JDialog implements LayoutManager, ActionListener, ContextListener {
37
38     private JButton m_buttonOK = null;
39     private JButton m_buttonCancel = null;
40     private JButton m_buttonApply = null;
41     private AbstractVirtualFileSystem m_vfs = null;
42     private String JavaDoc m_sPath = null;
43     private JTabbedPane m_tabs = null;
44     private PagePreviewConfigOptions m_pageOptions = null;
45     private DocumentPreviewConfigOptions m_docOptions = null;
46
47     /**
48      * @param arg0
49      * @param arg1
50      * @throws java.awt.HeadlessException
51      */

52     public PreviewConfigDialog(Frame arg0, String JavaDoc arg1)
53             throws HeadlessException {
54         super(arg0, arg1);
55         setup();
56     }
57     
58     private void setup() {
59         ContextHandler.getInstance().addListener(ContextType.CONTEXT_APP_FOCUS, this);
60             
61             this.setResizable(false);
62             
63         try {
64             this.getContentPane().setLayout(this);
65         
66             this.setSize(485,360);
67             int x = this.getGraphicsConfiguration().getBounds().width/2-this.getSize().width/2;
68             int y = this.getGraphicsConfiguration().getBounds().height/2-this.getSize().height/2;
69         
70             this.setLocation(x, y);
71
72             String JavaDoc fontName = "Dialog";
73             int fontSize = 11;
74             Font font = new Font(fontName, Font.PLAIN, fontSize);
75             this.getContentPane().setBackground(new Color(224,224,224));
76         
77             this.m_buttonOK = new JButton("OK");
78             this.m_buttonOK.setActionCommand("OK");
79             this.m_buttonOK.addActionListener(this);
80             this.m_buttonOK.setFont(font);
81             this.getContentPane().add(this.m_buttonOK);
82
83             this.m_buttonCancel = new JButton("Cancel");
84             this.m_buttonCancel.setActionCommand("CANCEL");
85             this.m_buttonCancel.addActionListener(this);
86             this.m_buttonCancel.setFont(font);
87             this.getContentPane().add(this.m_buttonCancel);
88             
89             this.m_buttonApply = new JButton("Apply");
90             this.m_buttonApply.setActionCommand("APPLY");
91             this.m_buttonApply.addActionListener(this);
92             this.m_buttonApply.setFont(font);
93             m_buttonApply.setEnabled(false);
94             this.getContentPane().add(this.m_buttonApply);
95             
96             m_tabs = new JTabbedPane();
97             m_tabs.setFont(font);
98             
99             m_pageOptions = new PagePreviewConfigOptions(this);
100             m_tabs.addTab("Pages",m_pageOptions);
101             
102             m_docOptions = new DocumentPreviewConfigOptions(this);
103             m_tabs.addTab("Documents",m_docOptions);
104             
105             getContentPane().add(this.m_tabs);
106         
107         } catch (Exception JavaDoc e) {
108             e.printStackTrace(System.err);
109         }
110         
111     }
112
113     /* (non-Javadoc)
114      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
115      */

116     public void layoutContainer(Container arg0) {
117         int width = getSize().width;
118         int height = getSize().height;
119         
120         this.m_tabs.setSize(width-25, height-70);
121         this.m_tabs.setLocation(10, 10);
122         
123         int x = 100;
124         
125         this.m_buttonOK.setSize(70, 20);
126         this.m_buttonOK.setLocation(x, height-50);
127         
128         this.m_buttonCancel.setSize(70, 20);
129         this.m_buttonCancel.setLocation(x+110, height-50);
130         
131         this.m_buttonApply.setSize(70,20);
132         this.m_buttonApply.setLocation(x+220, height-50);
133         
134     }
135     /**
136      * @throws java.awt.HeadlessException
137      */

138     public PreviewConfigDialog() throws HeadlessException {
139         super();
140     }
141
142     /**
143      * @param arg0
144      * @throws java.awt.HeadlessException
145      */

146     public PreviewConfigDialog(Dialog arg0) throws HeadlessException {
147         super(arg0);
148     }
149
150     /**
151      * @param arg0
152      * @param arg1
153      * @throws java.awt.HeadlessException
154      */

155     public PreviewConfigDialog(Dialog arg0, boolean arg1)
156             throws HeadlessException {
157         super(arg0, arg1);
158     }
159
160     /**
161      * @param arg0
162      * @throws java.awt.HeadlessException
163      */

164     public PreviewConfigDialog(Frame arg0) throws HeadlessException {
165         super(arg0);
166     }
167     /**
168      * @param arg0
169      * @param arg1
170      * @throws java.awt.HeadlessException
171      */

172     public PreviewConfigDialog(Dialog arg0, String JavaDoc arg1)
173             throws HeadlessException {
174         super(arg0, arg1);
175     }
176
177     /**
178      * @param arg0
179      * @param arg1
180      * @param arg2
181      * @throws java.awt.HeadlessException
182      */

183     public PreviewConfigDialog(Dialog arg0, String JavaDoc arg1, boolean arg2)
184             throws HeadlessException {
185         super(arg0, arg1, arg2);
186     }
187
188     /**
189      * @param arg0
190      * @param arg1
191      * @throws java.awt.HeadlessException
192      */

193     public PreviewConfigDialog(Frame arg0, boolean arg1)
194             throws HeadlessException {
195         super(arg0, arg1);
196     }
197
198     /**
199      * @param arg0
200      * @param arg1
201      * @param arg2
202      * @throws java.awt.HeadlessException
203      */

204     public PreviewConfigDialog(Frame arg0, String JavaDoc arg1, boolean arg2)
205             throws HeadlessException {
206         super(arg0, arg1, arg2);
207     }
208
209     /**
210      * @param arg0
211      * @param arg1
212      * @param arg2
213      * @param arg3
214      * @throws java.awt.HeadlessException
215      */

216     public PreviewConfigDialog(Dialog arg0, String JavaDoc arg1, boolean arg2,
217             GraphicsConfiguration arg3) throws HeadlessException {
218         super(arg0, arg1, arg2, arg3);
219     }
220
221     /**
222      * @param arg0
223      * @param arg1
224      * @param arg2
225      * @param arg3
226      */

227     public PreviewConfigDialog(Frame arg0, String JavaDoc arg1, boolean arg2,
228             GraphicsConfiguration arg3) {
229         super(arg0, arg1, arg2, arg3);
230     }
231
232     /* (non-Javadoc)
233      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
234      */

235     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
236     }
237
238     /* (non-Javadoc)
239      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
240      */

241     public Dimension minimumLayoutSize(Container arg0) {
242         return null;
243     }
244
245     /* (non-Javadoc)
246      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
247      */

248     public Dimension preferredLayoutSize(Container arg0) {
249         return null;
250     }
251
252     /* (non-Javadoc)
253      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
254      */

255     public void actionPerformed(ActionEvent ae) {
256         if (ae.getActionCommand().equals("OK")) {
257             m_pageOptions.save();
258             m_docOptions.save();
259             this.hide();
260         } if (ae.getActionCommand().equals("APPLY")){
261             m_pageOptions.save();
262             m_docOptions.save();
263             this.m_buttonApply.setEnabled(false);
264         } else if (ae.getActionCommand().equals("CANCEL")) {
265             this.hide();
266         }
267         
268     }
269
270     /* (non-Javadoc)
271      * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
272      */

273     public void contextMessage(ContextEvent ce) {
274     }
275
276     /* (non-Javadoc)
277      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
278      */

279     public void removeLayoutComponent(Component arg0) {
280     }
281
282     /**
283      *
284      */

285     public void changesMade() {
286         this.m_buttonApply.setEnabled(true);
287     }
288 }
289
Popular Tags