Source Code Cross Referenced for MenuBarBuilder.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfpshare » builder » menu » 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 » ERP CRM Financial » Personal Finance Manager » br.com.gfpshare.builder.menu 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 07/03/2004
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2004  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         * 
022:         */
023:        package br.com.gfpshare.builder.menu;
024:
025:        import java.net.URL;
026:        import java.util.ArrayList;
027:        import java.util.Enumeration;
028:        import java.util.Iterator;
029:
030:        import javax.swing.JMenu;
031:        import javax.xml.parsers.DocumentBuilder;
032:        import javax.xml.parsers.DocumentBuilderFactory;
033:
034:        import org.w3c.dom.Document;
035:        import org.w3c.dom.NamedNodeMap;
036:        import org.w3c.dom.Node;
037:        import org.w3c.dom.NodeList;
038:
039:        import br.com.gfpshare.beans.IMenuBar;
040:        import br.com.gfpshare.plugin.core.DynamicClassLoader;
041:
042:        /**
043:         * @author Igor Regis da Silva Simões
044:         */
045:        public abstract class MenuBarBuilder extends IMenuBar {
046:            private ArrayList<JMenu> menus = new ArrayList<JMenu>();
047:
048:            private DynamicClassLoader classLoader = DynamicClassLoader
049:                    .getClassLoader();
050:
051:            /** 
052:             *  Cria uma nova instância de MenuJanelaFacotry
053:             * @param xmlFile
054:             * @param fileOpen boolean indicando se existe um arquivo aberto
055:             * @throws MenuCreationException
056:             */
057:            public MenuBarBuilder(String xmlFile, boolean fileOpen)
058:                    throws MenuCreationException {
059:                try {
060:                    Enumeration enu = DynamicClassLoader.getClassLoader()
061:                            .getResources(xmlFile);
062:                    while (enu.hasMoreElements()) //for each xml file...
063:                    {
064:                        DocumentBuilderFactory factory = DocumentBuilderFactory
065:                                .newInstance();
066:                        factory.setValidating(true);
067:                        factory.setNamespaceAware(true);
068:
069:                        URL url = (URL) enu.nextElement();
070:
071:                        DocumentBuilder builder = factory.newDocumentBuilder();
072:                        Document document = builder.parse(url.openStream(), url
073:                                .toString()); //We load/parse the file
074:
075:                        NodeList menus = document.getLastChild()
076:                                .getChildNodes();
077:
078:                        for (int i = 0; i < menus.getLength(); i++) {
079:                            Node n = null;
080:                            if ((n = menus.item(i)).getNodeName()
081:                                    .equals("Menu")) {
082:
083:                                NamedNodeMap atributos = n.getAttributes();
084:                                Node atributo = null;
085:                                String builderName = null;
086:                                /*TODO É necessário controle de acesso para menus?
087:                                if ((atributo = atributos.getNamedItem("SecurityName")) != null)
088:                                	System.out.println(atributo.getNodeValue());
089:                                 */
090:
091:                                builderName = atributos.getNamedItem("Builder")
092:                                        .getNodeValue();
093:                                JMenu menu = (JMenu) classLoader.loadClass(
094:                                        builderName).getConstructor(
095:                                        new Class[] { boolean.class })
096:                                        .newInstance(
097:                                                new Object[] { Boolean
098:                                                        .valueOf(fileOpen) });
099:
100:                                menu.setText(MenuBuilderMessages.getMessages()
101:                                        .getString(
102:                                                n.getLastChild().getNodeValue()
103:                                                        .trim()));
104:
105:                                if ((atributo = atributos
106:                                        .getNamedItem("Mnemonic")) != null)
107:                                    menu.setMnemonic(atributo.getNodeValue()
108:                                            .charAt(0));
109:
110:                                MenuBarBuilder.this .menus.add(menu);
111:                            }
112:                        }
113:                    }
114:                } catch (Exception e) {
115:                    throw new MenuCreationException(e);
116:                }
117:                rebuildMenu();
118:            }
119:
120:            /**
121:             * Indica se o usuário atual possui acesso pára o determinado nivel de segurança
122:             * @param securityLevel Nivel de segurança a ser checado o direito de acesso
123:             * @return Indica false caso o ususário não possua acesso
124:             */
125:            public abstract boolean hasAccess(String securityLevel);
126:
127:            /**
128:             *
129:             */
130:            public void rebuildMenu() {
131:                this .removeAll();
132:
133:                Iterator menus = this .menus.iterator();
134:                while (menus.hasNext()) {
135:                    add((JMenu) menus.next());
136:                }
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.