001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.serverconfig;
020:
021: import java.awt.*;
022: import java.awt.event.*;
023:
024: import javax.swing.*;
025:
026: import org.openharmonise.vfs.*;
027: import org.openharmonise.vfs.context.*;
028:
029: /**
030: *
031: * @author matt treanor
032: * @version $Revision: 1.1 $
033: *
034: */
035: public class PreviewConfigDialog extends JDialog implements
036: LayoutManager, ActionListener, ContextListener {
037:
038: private JButton m_buttonOK = null;
039: private JButton m_buttonCancel = null;
040: private JButton m_buttonApply = null;
041: private AbstractVirtualFileSystem m_vfs = null;
042: private String m_sPath = null;
043: private JTabbedPane m_tabs = null;
044: private PagePreviewConfigOptions m_pageOptions = null;
045: private DocumentPreviewConfigOptions m_docOptions = null;
046:
047: /**
048: * @param arg0
049: * @param arg1
050: * @throws java.awt.HeadlessException
051: */
052: public PreviewConfigDialog(Frame arg0, String arg1)
053: throws HeadlessException {
054: super (arg0, arg1);
055: setup();
056: }
057:
058: private void setup() {
059: ContextHandler.getInstance().addListener(
060: ContextType.CONTEXT_APP_FOCUS, this );
061:
062: this .setResizable(false);
063:
064: try {
065: this .getContentPane().setLayout(this );
066:
067: this .setSize(485, 360);
068: int x = this .getGraphicsConfiguration().getBounds().width
069: / 2 - this .getSize().width / 2;
070: int y = this .getGraphicsConfiguration().getBounds().height
071: / 2 - this .getSize().height / 2;
072:
073: this .setLocation(x, y);
074:
075: String fontName = "Dialog";
076: int fontSize = 11;
077: Font font = new Font(fontName, Font.PLAIN, fontSize);
078: this .getContentPane().setBackground(
079: new Color(224, 224, 224));
080:
081: this .m_buttonOK = new JButton("OK");
082: this .m_buttonOK.setActionCommand("OK");
083: this .m_buttonOK.addActionListener(this );
084: this .m_buttonOK.setFont(font);
085: this .getContentPane().add(this .m_buttonOK);
086:
087: this .m_buttonCancel = new JButton("Cancel");
088: this .m_buttonCancel.setActionCommand("CANCEL");
089: this .m_buttonCancel.addActionListener(this );
090: this .m_buttonCancel.setFont(font);
091: this .getContentPane().add(this .m_buttonCancel);
092:
093: this .m_buttonApply = new JButton("Apply");
094: this .m_buttonApply.setActionCommand("APPLY");
095: this .m_buttonApply.addActionListener(this );
096: this .m_buttonApply.setFont(font);
097: m_buttonApply.setEnabled(false);
098: this .getContentPane().add(this .m_buttonApply);
099:
100: m_tabs = new JTabbedPane();
101: m_tabs.setFont(font);
102:
103: m_pageOptions = new PagePreviewConfigOptions(this );
104: m_tabs.addTab("Pages", m_pageOptions);
105:
106: m_docOptions = new DocumentPreviewConfigOptions(this );
107: m_tabs.addTab("Documents", m_docOptions);
108:
109: getContentPane().add(this .m_tabs);
110:
111: } catch (Exception e) {
112: e.printStackTrace(System.err);
113: }
114:
115: }
116:
117: /* (non-Javadoc)
118: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
119: */
120: public void layoutContainer(Container arg0) {
121: int width = getSize().width;
122: int height = getSize().height;
123:
124: this .m_tabs.setSize(width - 25, height - 70);
125: this .m_tabs.setLocation(10, 10);
126:
127: int x = 100;
128:
129: this .m_buttonOK.setSize(70, 20);
130: this .m_buttonOK.setLocation(x, height - 50);
131:
132: this .m_buttonCancel.setSize(70, 20);
133: this .m_buttonCancel.setLocation(x + 110, height - 50);
134:
135: this .m_buttonApply.setSize(70, 20);
136: this .m_buttonApply.setLocation(x + 220, height - 50);
137:
138: }
139:
140: /**
141: * @throws java.awt.HeadlessException
142: */
143: public PreviewConfigDialog() throws HeadlessException {
144: super ();
145: }
146:
147: /**
148: * @param arg0
149: * @throws java.awt.HeadlessException
150: */
151: public PreviewConfigDialog(Dialog arg0) throws HeadlessException {
152: super (arg0);
153: }
154:
155: /**
156: * @param arg0
157: * @param arg1
158: * @throws java.awt.HeadlessException
159: */
160: public PreviewConfigDialog(Dialog arg0, boolean arg1)
161: throws HeadlessException {
162: super (arg0, arg1);
163: }
164:
165: /**
166: * @param arg0
167: * @throws java.awt.HeadlessException
168: */
169: public PreviewConfigDialog(Frame arg0) throws HeadlessException {
170: super (arg0);
171: }
172:
173: /**
174: * @param arg0
175: * @param arg1
176: * @throws java.awt.HeadlessException
177: */
178: public PreviewConfigDialog(Dialog arg0, String arg1)
179: throws HeadlessException {
180: super (arg0, arg1);
181: }
182:
183: /**
184: * @param arg0
185: * @param arg1
186: * @param arg2
187: * @throws java.awt.HeadlessException
188: */
189: public PreviewConfigDialog(Dialog arg0, String arg1, boolean arg2)
190: throws HeadlessException {
191: super (arg0, arg1, arg2);
192: }
193:
194: /**
195: * @param arg0
196: * @param arg1
197: * @throws java.awt.HeadlessException
198: */
199: public PreviewConfigDialog(Frame arg0, boolean arg1)
200: throws HeadlessException {
201: super (arg0, arg1);
202: }
203:
204: /**
205: * @param arg0
206: * @param arg1
207: * @param arg2
208: * @throws java.awt.HeadlessException
209: */
210: public PreviewConfigDialog(Frame arg0, String arg1, boolean arg2)
211: throws HeadlessException {
212: super (arg0, arg1, arg2);
213: }
214:
215: /**
216: * @param arg0
217: * @param arg1
218: * @param arg2
219: * @param arg3
220: * @throws java.awt.HeadlessException
221: */
222: public PreviewConfigDialog(Dialog arg0, String arg1, boolean arg2,
223: GraphicsConfiguration arg3) throws HeadlessException {
224: super (arg0, arg1, arg2, arg3);
225: }
226:
227: /**
228: * @param arg0
229: * @param arg1
230: * @param arg2
231: * @param arg3
232: */
233: public PreviewConfigDialog(Frame arg0, String arg1, boolean arg2,
234: GraphicsConfiguration arg3) {
235: super (arg0, arg1, arg2, arg3);
236: }
237:
238: /* (non-Javadoc)
239: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
240: */
241: public void addLayoutComponent(String arg0, Component arg1) {
242: }
243:
244: /* (non-Javadoc)
245: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
246: */
247: public Dimension minimumLayoutSize(Container arg0) {
248: return null;
249: }
250:
251: /* (non-Javadoc)
252: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
253: */
254: public Dimension preferredLayoutSize(Container arg0) {
255: return null;
256: }
257:
258: /* (non-Javadoc)
259: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
260: */
261: public void actionPerformed(ActionEvent ae) {
262: if (ae.getActionCommand().equals("OK")) {
263: m_pageOptions.save();
264: m_docOptions.save();
265: this .hide();
266: }
267: if (ae.getActionCommand().equals("APPLY")) {
268: m_pageOptions.save();
269: m_docOptions.save();
270: this .m_buttonApply.setEnabled(false);
271: } else if (ae.getActionCommand().equals("CANCEL")) {
272: this .hide();
273: }
274:
275: }
276:
277: /* (non-Javadoc)
278: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
279: */
280: public void contextMessage(ContextEvent ce) {
281: }
282:
283: /* (non-Javadoc)
284: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
285: */
286: public void removeLayoutComponent(Component arg0) {
287: }
288:
289: /**
290: *
291: */
292: public void changesMade() {
293: this .m_buttonApply.setEnabled(true);
294: }
295: }
|