Source Code Cross Referenced for AboutDialog.java in  » Content-Management-System » harmonise » org » openharmonise » him » window » about » 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.window.about 
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.window.about;
020:
021:        import java.awt.*;
022:        import java.awt.event.*;
023:        import java.net.*;
024:        import java.util.*;
025:        import java.util.List;
026:
027:        import javax.swing.*;
028:        import javax.swing.event.*;
029:
030:        import org.openharmonise.him.*;
031:        import org.openharmonise.him.context.StateHandler;
032:        import org.openharmonise.him.serverconfig.permissions.*;
033:        import org.openharmonise.vfs.*;
034:        import org.openharmonise.vfs.authentication.*;
035:        import org.openharmonise.vfs.context.*;
036:        import org.openharmonise.vfs.metadata.*;
037:        import org.openharmonise.vfs.metadata.range.*;
038:        import org.openharmonise.vfs.metadata.value.*;
039:        import org.openharmonise.vfs.servers.*;
040:
041:        /**
042:         * The about dialog which presents information to the user about this
043:         * application. 
044:         * 
045:         * @author Matthew Large
046:         * @version $Revision: 1.1 $
047:         *
048:         */
049:        public class AboutDialog extends JDialog implements  ActionListener,
050:                LayoutManager, ContextListener, ChangeListener {
051:
052:            /**
053:             * OK button.
054:             */
055:            private JButton m_buttonOK = null;
056:
057:            /**
058:             * Tabs.
059:             */
060:            private JTabbedPane m_tabs = null;
061:
062:            /**
063:             * Scroll pane containing the current user's details.
064:             */
065:            private JScrollPane m_userDetails = null;
066:
067:            /**
068:             * Constructs a new about dialog.
069:             * 
070:             * @param arg0
071:             * @throws java.awt.HeadlessException
072:             */
073:            public AboutDialog(Frame arg0) throws HeadlessException {
074:                super (arg0, "About", true);
075:                this .setup();
076:            }
077:
078:            /**
079:             * Initialises this component.
080:             *
081:             */
082:            private void setup() {
083:
084:                ContextHandler.getInstance().addListener(
085:                        ContextType.CONTEXT_APP_FOCUS, this );
086:
087:                this .setResizable(false);
088:
089:                this .getContentPane().setLayout(this );
090:
091:                this .setSize(400, 500);
092:                int x = this .getGraphicsConfiguration().getBounds().width / 2
093:                        - this .getSize().width / 2;
094:                int y = this .getGraphicsConfiguration().getBounds().height / 2
095:                        - this .getSize().height / 2;
096:
097:                this .setLocation(x, y);
098:
099:                String fontName = "Dialog";
100:                int fontSize = 11;
101:                Font font = new Font(fontName, Font.PLAIN, fontSize);
102:                this .getContentPane().setBackground(new Color(224, 224, 224));
103:
104:                this .m_buttonOK = new JButton("OK");
105:                this .m_buttonOK.setActionCommand("OK");
106:                this .m_buttonOK.addActionListener(this );
107:                this .m_buttonOK.setFont(font);
108:                this .getContentPane().add(this .m_buttonOK);
109:
110:                this .m_tabs = new JTabbedPane();
111:                this .m_tabs.setFont(font);
112:                m_tabs.addChangeListener(this );
113:
114:                this .getContentPane().add(this .m_tabs);
115:
116:                this .addHTMLPane("Contact info",
117:                        "/org/openharmonise/him/icons/files/contactinfo.html");
118:                this .addHTMLPane("Credits",
119:                        "/org/openharmonise/him/icons/files/credits.html");
120:                this .addHTMLPane("Version",
121:                        "/org/openharmonise/him/icons/files/version.html");
122:                this .addHTMLPane("Legal",
123:                        "/org/openharmonise/him/icons/files/licence.html");
124:
125:                m_tabs.add("Who am I", null);
126:            }
127:
128:            /* (non-Javadoc)
129:             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
130:             */
131:            public void actionPerformed(ActionEvent arg0) {
132:                ContextHandler.getInstance().removeListener(
133:                        ContextType.CONTEXT_APP_FOCUS, this );
134:                this .hide();
135:            }
136:
137:            /**
138:             * Adds a tab which contains a HTML page at the given resource URL (i.e. it
139:             * is in the classpath).
140:             * 
141:             * @param sTitle title for tab.
142:             * @param sURL URL to the HTML for the tab contents.
143:             */
144:            private void addHTMLPane(String sTitle, String sURL) {
145:                try {
146:                    URL url = getClass().getResource(sURL);
147:                    JEditorPane html = new JEditorPane(url);
148:                    html.setEditable(false);
149:
150:                    JScrollPane scroller = new JScrollPane();
151:                    JViewport vp = scroller.getViewport();
152:                    vp.add(html);
153:                    this .m_tabs.addTab(sTitle, scroller);
154:                } catch (Exception e) {
155:                    e.printStackTrace(System.out);
156:                }
157:            }
158:
159:            /* (non-Javadoc)
160:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
161:             */
162:            public void layoutContainer(Container arg0) {
163:                this .m_tabs.setSize(this .getSize().width - 10, 430);
164:                this .m_tabs.setLocation(0, 0);
165:
166:                this .m_buttonOK.setSize(70, 20);
167:                this .m_buttonOK.setLocation(this .getSize().width - 100, 440);
168:
169:            }
170:
171:            /* (non-Javadoc)
172:             * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
173:             */
174:            public void contextMessage(ContextEvent ce) {
175:                if (ce.CONTEXT_TYPE == ContextType.CONTEXT_APP_FOCUS) {
176:                    this .toFront();
177:                }
178:            }
179:
180:            /**
181:             * @throws java.awt.HeadlessException
182:             */
183:            private AboutDialog() throws HeadlessException {
184:                super ();
185:            }
186:
187:            /**
188:             * @param arg0
189:             * @throws java.awt.HeadlessException
190:             */
191:            private AboutDialog(Dialog arg0) throws HeadlessException {
192:                super (arg0);
193:            }
194:
195:            /**
196:             * @param arg0
197:             * @param arg1
198:             * @throws java.awt.HeadlessException
199:             */
200:            private AboutDialog(Dialog arg0, boolean arg1)
201:                    throws HeadlessException {
202:                super (arg0, arg1);
203:            }
204:
205:            /**
206:             * @param arg0
207:             * @param arg1
208:             * @throws java.awt.HeadlessException
209:             */
210:            private AboutDialog(Frame arg0, boolean arg1)
211:                    throws HeadlessException {
212:                super (arg0, arg1);
213:            }
214:
215:            /**
216:             * @param arg0
217:             * @param arg1
218:             * @throws java.awt.HeadlessException
219:             */
220:            private AboutDialog(Dialog arg0, String arg1)
221:                    throws HeadlessException {
222:                super (arg0, arg1);
223:            }
224:
225:            /**
226:             * @param arg0
227:             * @param arg1
228:             * @param arg2
229:             * @throws java.awt.HeadlessException
230:             */
231:            private AboutDialog(Dialog arg0, String arg1, boolean arg2)
232:                    throws HeadlessException {
233:                super (arg0, arg1, arg2);
234:            }
235:
236:            /**
237:             * @param arg0
238:             * @param arg1
239:             * @throws java.awt.HeadlessException
240:             */
241:            private AboutDialog(Frame arg0, String arg1)
242:                    throws HeadlessException {
243:                super (arg0, arg1);
244:            }
245:
246:            /**
247:             * @param arg0
248:             * @param arg1
249:             * @param arg2
250:             * @throws java.awt.HeadlessException
251:             */
252:            private AboutDialog(Frame arg0, String arg1, boolean arg2)
253:                    throws HeadlessException {
254:                super (arg0, arg1, arg2);
255:            }
256:
257:            /**
258:             * @param arg0
259:             * @param arg1
260:             * @param arg2
261:             * @param arg3
262:             * @throws java.awt.HeadlessException
263:             */
264:            private AboutDialog(Dialog arg0, String arg1, boolean arg2,
265:                    GraphicsConfiguration arg3) throws HeadlessException {
266:                super (arg0, arg1, arg2, arg3);
267:            }
268:
269:            /**
270:             * @param arg0
271:             * @param arg1
272:             * @param arg2
273:             * @param arg3
274:             */
275:            private AboutDialog(Frame arg0, String arg1, boolean arg2,
276:                    GraphicsConfiguration arg3) {
277:                super (arg0, arg1, arg2, arg3);
278:            }
279:
280:            /* (non-Javadoc)
281:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
282:             */
283:            public void removeLayoutComponent(Component arg0) {
284:            }
285:
286:            /* (non-Javadoc)
287:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
288:             */
289:            public void addLayoutComponent(String arg0, Component arg1) {
290:            }
291:
292:            /* (non-Javadoc)
293:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
294:             */
295:            public Dimension minimumLayoutSize(Container arg0) {
296:                return this .getSize();
297:            }
298:
299:            /* (non-Javadoc)
300:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
301:             */
302:            public Dimension preferredLayoutSize(Container arg0) {
303:                return this .getSize();
304:            }
305:
306:            /**
307:             * Gets a user details panel.
308:             * 
309:             * @return user details panel.
310:             */
311:            private JScrollPane getUserDetails() {
312:                StateHandler.getInstance().addWait("USER_DETAILS",
313:                        "Getting user details...");
314:                String sRole = "";
315:                Server server = null;
316:                boolean isSuper = false;
317:                server = ServerList.getInstance().getHarmoniseServer();
318:                AbstractVirtualFileSystem vfs = server.getVFS();
319:                VirtualFileSystemView vfsView = vfs.getVirtualFileSystemView();
320:                AuthInfo auth = vfs.getAuthentication();
321:                StringBuffer sbuff = new StringBuffer();
322:                if (auth.getUser().isSuperUser()) {
323:                    sRole = "super";
324:                    isSuper = true;
325:                } else {
326:                    Iterator itor = PermissionsServerConfigOptions
327:                            .getObjectPropertyDefinitions().iterator();
328:                    String sRolePath = auth.getUser().getRolePath();
329:                    VirtualFile vfRole = vfs.getVirtualFile(sRolePath)
330:                            .getResource();
331:                    sRole = ValueCache.getInstance().getValue(sRolePath)
332:                            .getDisplayName();
333:                    sbuff.append("<table>");
334:                    sbuff
335:                            .append("<tr><td><STRONG><font face='Arial'>Harmonise Object</font></STRONG></td>"
336:                                    + "<td><STRONG><font face='Arial'>Permissions</font></STRONG></td></tr>");
337:                    while (itor.hasNext()) {
338:                        String sPermission = "";
339:                        Property prop = (Property) itor.next();
340:                        ValueRange range = (ValueRange) prop.getRange();
341:                        PropertyInstance propInst = vfRole.getProperty(prop
342:                                .getNamespace(), prop.getName());
343:                        sbuff.append("<tr><td><font face='Arial'>"
344:                                + propInst.getName() + "</font></td>");
345:                        sbuff
346:                                .append("<td  bgColor=#efefef><font face='Arial'>");
347:                        List vals = propInst.getValues();
348:                        int size = 0;
349:                        if (vals == null || vals.size() == 0) {
350:                            sPermission = "none";
351:                        } else {
352:                            size = vals.size();
353:                        }
354:                        for (int i = 0; i < vals.size(); i++) {
355:                            ValueValue valInst = (ValueValue) vals.get(i);
356:                            Value val = ValueCache.getInstance().getValue(
357:                                    valInst.getValue());
358:                            sPermission += val.getDisplayName();
359:                            if (i < size - 1) {
360:                                sPermission += ", ";
361:                            }
362:                        }
363:                        sbuff.append(sPermission + "</font></td></tr>");
364:                    }
365:                    sbuff.append("</table>");
366:                }
367:                JEditorPane html = new JEditorPane();
368:                html.setContentType("text/html");
369:                String text = "<html><head></head>"
370:                        + "<body><font face='Arial'>"
371:                        + "<p>You are logged on as <b>" + auth.getUsername()
372:                        + "</b>" + " with a role of <b>" + sRole + "</b>.";
373:                if (isSuper) {
374:                    text += "<p>A super user has a special privilege level, "
375:                            + "with unlimited access to all Resources, "
376:                            + "Collections, and commands.</p>";
377:                } else {
378:                    text += "<p>You have the following permissions.</p>"
379:                            + "<p>" + sbuff.toString() + "</p>";
380:                }
381:                text += "</font></body></html>";
382:                html.setText(text);
383:                html.setEditable(false);
384:                JScrollPane scroller = new JScrollPane();
385:                JViewport vp = scroller.getViewport();
386:                vp.add(html);
387:                m_userDetails = scroller;
388:
389:                StateHandler.getInstance().removeWait("USER_DETAILS");
390:
391:                return scroller;
392:            }
393:
394:            /* (non-Javadoc)
395:             * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
396:             */
397:            public void stateChanged(ChangeEvent e) {
398:                int index = m_tabs.getSelectedIndex();
399:                String sTab = m_tabs.getTitleAt(index);
400:                if (sTab.equalsIgnoreCase("Who am I")) {
401:                    if (m_userDetails == null) {
402:                        m_userDetails = getUserDetails();
403:                    }
404:                    m_tabs.setComponentAt(index, m_userDetails);
405:                    System.out.println(m_userDetails.getVerticalScrollBar()
406:                            .getValue());
407:                    m_userDetails.getVerticalScrollBar().setValue(0);
408:                }
409:            }
410:
411:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.