Source Code Cross Referenced for ServerConfigDialog.java in  » Content-Management-System » harmonise » org » openharmonise » him » serverconfig » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » harmonise » org.openharmonise.him.serverconfig 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        import java.util.*;
024:
025:        import javax.swing.*;
026:
027:        import org.openharmonise.him.configuration.*;
028:        import org.openharmonise.him.context.StateHandler;
029:        import org.openharmonise.him.serverconfig.cache.*;
030:        import org.openharmonise.him.serverconfig.errors.*;
031:        import org.openharmonise.him.serverconfig.permissions.*;
032:        import org.openharmonise.him.serverconfig.security.*;
033:        import org.openharmonise.him.window.messages.*;
034:        import org.openharmonise.vfs.context.*;
035:        import org.openharmonise.vfs.gui.*;
036:
037:        /**
038:         * Dialog for setting configuration options on a Harmonise
039:         * Information Server.
040:         * 
041:         * @author Matthew Large
042:         * @version $Revision: 1.1 $
043:         *
044:         */
045:        public class ServerConfigDialog extends JDialog implements 
046:                LayoutManager, ActionListener, ContextListener {
047:
048:            /**
049:             * List of {@link ApplyChangesListener} listeners.
050:             */
051:            private ArrayList m_listeners = new ArrayList();
052:
053:            /**
054:             * Options tabs.
055:             */
056:            private JTabbedPane m_tabs = null;
057:
058:            /**
059:             * OK button.
060:             */
061:            private JButton m_buttonOK = null;
062:
063:            /**
064:             * Cancel button.
065:             */
066:            private JButton m_buttonCancel = null;
067:
068:            /**
069:             * Apply changes button.
070:             */
071:            private JButton m_buttonApply = null;
072:
073:            /**
074:             * Constructs a new server configuration dialog.
075:             * 
076:             * @param arg0 frame this dialog is associated to.
077:             * @param arg1 title for this dialog.
078:             * @throws java.awt.HeadlessException thrown when called in an environment that does not support a keyboard, display, or mouse.
079:             */
080:            public ServerConfigDialog(Frame arg0, String arg1)
081:                    throws HeadlessException {
082:                super (arg0, arg1, true);
083:                this .setup();
084:            }
085:
086:            /**
087:             * Initialises this component.
088:             *
089:             */
090:            private void setup() {
091:                ContextHandler.getInstance().addListener(
092:                        ContextType.CONTEXT_APP_FOCUS, this );
093:
094:                this .setResizable(false);
095:
096:                StateHandler.getInstance().addWait("SERVER-PROP-OPEN",
097:                        "Contacting server...");
098:                try {
099:                    this .getContentPane().setLayout(this );
100:
101:                    this .setSize(400, 500);
102:                    int x = this .getGraphicsConfiguration().getBounds().width
103:                            / 2 - this .getSize().width / 2;
104:                    int y = this .getGraphicsConfiguration().getBounds().height
105:                            / 2 - this .getSize().height / 2;
106:
107:                    this .setLocation(x, y);
108:
109:                    String fontName = "Dialog";
110:                    int fontSize = 11;
111:                    Font font = new Font(fontName, Font.PLAIN, fontSize);
112:                    this .getContentPane().setBackground(
113:                            new Color(224, 224, 224));
114:
115:                    this .m_buttonOK = new JButton("OK");
116:                    this .m_buttonOK.setActionCommand("OK");
117:                    this .m_buttonOK.addActionListener(this );
118:                    this .m_buttonOK.setFont(font);
119:                    this .getContentPane().add(this .m_buttonOK);
120:
121:                    this .m_buttonCancel = new JButton("Cancel");
122:                    this .m_buttonCancel.setActionCommand("CANCEL");
123:                    this .m_buttonCancel.addActionListener(this );
124:                    this .m_buttonCancel.setFont(font);
125:                    this .getContentPane().add(this .m_buttonCancel);
126:
127:                    this .m_buttonApply = new JButton("Apply");
128:                    this .m_buttonApply.setActionCommand("APPLY");
129:                    this .m_buttonApply.addActionListener(this );
130:                    this .m_buttonApply.setFont(font);
131:                    this .getContentPane().add(this .m_buttonApply);
132:
133:                    this .m_tabs = new JTabbedPane();
134:                    this .m_tabs.setFont(font);
135:
136:                    SecurityServerConfigOptions securityOptions = new SecurityServerConfigOptions(
137:                            this );
138:
139:                    this .m_tabs.addTab("Password Policy", securityOptions);
140:
141:                    ErrorServerConfigOptions errorOptions = new ErrorServerConfigOptions(
142:                            this );
143:
144:                    this .m_tabs.addTab("Errors", errorOptions);
145:
146:                    DevelopmentServerConfigOptions developmentOptions = new DevelopmentServerConfigOptions(
147:                            this );
148:
149:                    this .m_tabs.addTab("Development Utilities",
150:                            developmentOptions);
151:
152:                    CacheServerConfigOptions cacheOptions = new CacheServerConfigOptions(
153:                            this );
154:                    JScrollPane scroller = new JScrollPane(cacheOptions,
155:                            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
156:                            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
157:
158:                    this .m_tabs.addTab("Caches", scroller);
159:
160:                    PermissionsServerConfigOptions permissionsOptions = new PermissionsServerConfigOptions(
161:                            this );
162:                    this .m_tabs.addTab("Permissions", permissionsOptions);
163:
164:                    this .getContentPane().add(this .m_tabs);
165:                    this .m_buttonApply.setEnabled(false);
166:                } catch (Exception e) {
167:                    e.printStackTrace(System.err);
168:                } finally {
169:                    StateHandler.getInstance().removeWait("SERVER-PROP-OPEN");
170:                }
171:
172:            }
173:
174:            /* (non-Javadoc)
175:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
176:             */
177:            public void layoutContainer(Container arg0) {
178:                this .m_tabs.setSize(this .getSize().width - 10, 430);
179:                this .m_tabs.setLocation(0, 0);
180:
181:                this .m_buttonOK.setSize(70, 20);
182:                this .m_buttonOK.setLocation(150, 440);
183:
184:                this .m_buttonCancel.setSize(70, 20);
185:                this .m_buttonCancel.setLocation(230, 440);
186:
187:                this .m_buttonApply.setSize(70, 20);
188:                this .m_buttonApply.setLocation(310, 440);
189:            }
190:
191:            /* (non-Javadoc)
192:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
193:             */
194:            public void actionPerformed(ActionEvent ae) {
195:                if (ae.getActionCommand().equals("OK")) {
196:                    StateHandler.getInstance().addWait(this , "SERVER-PROP-OK");
197:                    if (this .fireApplyChanges()) {
198:                        MessageHandler.getInstance().fireMessageEvent(
199:                                "Changes saved to the Harmonise server.",
200:                                MessageHandler.TYPE_CONFIRM);
201:                    } else {
202:                        MessageHandler
203:                                .getInstance()
204:                                .fireMessageEvent(
205:                                        "There was a problem saving the changes to the Harmonise server.",
206:                                        MessageHandler.TYPE_ERROR);
207:                    }
208:                    ContextHandler.getInstance().removeListener(
209:                            ContextType.CONTEXT_APP_FOCUS, this );
210:                    this .hide();
211:                    StateHandler.getInstance().removeWait(this ,
212:                            "SERVER-PROP-OK");
213:                } else if (ae.getActionCommand().equals("CANCEL")) {
214:                    this .fireDiscardChanges();
215:                    ContextHandler.getInstance().removeListener(
216:                            ContextType.CONTEXT_APP_FOCUS, this );
217:                    this .hide();
218:                } else if (ae.getActionCommand().equals("APPLY")) {
219:                    StateHandler.getInstance().addWait(this ,
220:                            "SERVER-PROP-APPLY");
221:                    this .m_buttonApply.setEnabled(false);
222:                    if (fireApplyChanges()) {
223:                        MessageHandler.getInstance().fireMessageEvent(
224:                                "Changes saved to the Harmonise server.",
225:                                MessageHandler.TYPE_CONFIRM);
226:                    } else {
227:                        MessageHandler
228:                                .getInstance()
229:                                .fireMessageEvent(
230:                                        "There was a problem saving the changes to the Harmonise server.",
231:                                        MessageHandler.TYPE_ERROR);
232:                    }
233:                    StateHandler.getInstance().removeWait(this ,
234:                            "SERVER-PROP-APPLY");
235:                }
236:            }
237:
238:            /**
239:             * Adds an {@link ApplyChangesListener} listener.
240:             * 
241:             * @param listener Listener to add.
242:             */
243:            public void addApplyChangesListener(ApplyChangesListener listener) {
244:                this .m_listeners.add(listener);
245:            }
246:
247:            /**
248:             * Removes an {@link ApplyChangesListener} listener.
249:             * 
250:             * @param listener Listener to remove.
251:             */
252:            public void removeApplyChangesListener(ApplyChangesListener listener) {
253:                this .m_listeners.remove(listener);
254:            }
255:
256:            /**
257:             * Informs all {@link ApplyChangesListener} listeners that
258:             * they should apply their changes.
259:             * 
260:             * @return true if all changes were applied successfully.
261:             */
262:            private boolean fireApplyChanges() {
263:                boolean bOk = true;
264:                Iterator itor = this .m_listeners.iterator();
265:                while (itor.hasNext()) {
266:                    ApplyChangesListener listener = (ApplyChangesListener) itor
267:                            .next();
268:                    if (listener.applyChanges() == false) {
269:                        bOk = false;
270:                    }
271:                }
272:                return bOk;
273:            }
274:
275:            /**
276:             * Informs all {@link ApplyChangesListener} listeners that
277:             * they should discard their changes.
278:             * 
279:             */
280:            private void fireDiscardChanges() {
281:                Iterator itor = this .m_listeners.iterator();
282:                while (itor.hasNext()) {
283:                    ApplyChangesListener listener = (ApplyChangesListener) itor
284:                            .next();
285:                    listener.discardChanges();
286:                }
287:            }
288:
289:            /**
290:             * Enables the apply button.
291:             *
292:             */
293:            public void changesMade() {
294:                this .m_buttonApply.setEnabled(true);
295:            }
296:
297:            /**
298:             * @throws java.awt.HeadlessException
299:             */
300:            private ServerConfigDialog() throws HeadlessException {
301:                super ();
302:            }
303:
304:            /**
305:             * @param arg0
306:             * @throws java.awt.HeadlessException
307:             */
308:            private ServerConfigDialog(Dialog arg0) throws HeadlessException {
309:                super (arg0);
310:            }
311:
312:            /**
313:             * @param arg0
314:             * @param arg1
315:             * @throws java.awt.HeadlessException
316:             */
317:            private ServerConfigDialog(Dialog arg0, boolean arg1)
318:                    throws HeadlessException {
319:                super (arg0, arg1);
320:            }
321:
322:            /**
323:             * @param arg0
324:             * @throws java.awt.HeadlessException
325:             */
326:            private ServerConfigDialog(Frame arg0) throws HeadlessException {
327:                super (arg0);
328:            }
329:
330:            /**
331:             * @param arg0
332:             * @param arg1
333:             * @throws java.awt.HeadlessException
334:             */
335:            private ServerConfigDialog(Frame arg0, boolean arg1)
336:                    throws HeadlessException {
337:                super (arg0, arg1);
338:            }
339:
340:            /**
341:             * @param arg0
342:             * @param arg1
343:             * @param arg2
344:             * @throws java.awt.HeadlessException
345:             */
346:            private ServerConfigDialog(Dialog arg0, String arg1, boolean arg2)
347:                    throws HeadlessException {
348:                super (arg0, arg1, arg2);
349:            }
350:
351:            /**
352:             * @param arg0
353:             * @param arg1
354:             * @throws java.awt.HeadlessException
355:             */
356:            private ServerConfigDialog(Dialog arg0, String arg1)
357:                    throws HeadlessException {
358:                super (arg0, arg1);
359:            }
360:
361:            /**
362:             * @param arg0
363:             * @param arg1
364:             * @param arg2
365:             * @throws java.awt.HeadlessException
366:             */
367:            private ServerConfigDialog(Frame arg0, String arg1, boolean arg2)
368:                    throws HeadlessException {
369:                super (arg0, arg1, arg2);
370:            }
371:
372:            /**
373:             * @param arg0
374:             * @param arg1
375:             * @param arg2
376:             * @param arg3
377:             * @throws java.awt.HeadlessException
378:             */
379:            private ServerConfigDialog(Dialog arg0, String arg1, boolean arg2,
380:                    GraphicsConfiguration arg3) throws HeadlessException {
381:                super (arg0, arg1, arg2, arg3);
382:            }
383:
384:            /**
385:             * @param arg0
386:             * @param arg1
387:             * @param arg2
388:             * @param arg3
389:             */
390:            private ServerConfigDialog(Frame arg0, String arg1, boolean arg2,
391:                    GraphicsConfiguration arg3) {
392:                super (arg0, arg1, arg2, arg3);
393:            }
394:
395:            /* (non-Javadoc)
396:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
397:             */
398:            public void removeLayoutComponent(Component arg0) {
399:            }
400:
401:            /* (non-Javadoc)
402:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
403:             */
404:            public void addLayoutComponent(String arg0, Component arg1) {
405:            }
406:
407:            /* (non-Javadoc)
408:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
409:             */
410:            public Dimension minimumLayoutSize(Container arg0) {
411:                return this .getSize();
412:            }
413:
414:            /* (non-Javadoc)
415:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
416:             */
417:            public Dimension preferredLayoutSize(Container arg0) {
418:                return this .getSize();
419:            }
420:
421:            /* (non-Javadoc)
422:             * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
423:             */
424:            public void contextMessage(ContextEvent ce) {
425:                if (ce.CONTEXT_TYPE == ContextType.CONTEXT_APP_FOCUS) {
426:                    this.toFront();
427:                }
428:            }
429:
430:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.