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


001:        /*
002:         * MenuJanelaFacotry.java Criado em 7 de Março de 2004, 11:24
003:         */
004:
005:        package br.com.gfp.windows.builders;
006:
007:        import java.awt.Component;
008:        import java.awt.event.ActionEvent;
009:        import java.awt.event.ActionListener;
010:        import java.awt.event.ItemEvent;
011:        import java.awt.event.ItemListener;
012:        import java.beans.PropertyVetoException;
013:
014:        import javax.swing.ButtonGroup;
015:        import javax.swing.JInternalFrame;
016:        import javax.swing.JMenu;
017:        import javax.swing.JMenuItem;
018:        import javax.swing.JRadioButtonMenuItem;
019:        import javax.swing.JSeparator;
020:
021:        import br.com.gfp.dao.GFPController;
022:        import br.com.gfp.internationalization.MenuJanelaBuilderMessages;
023:        import br.com.gfp.util.SimpleLog;
024:        import br.com.gfpshare.beans.IDesktopPane;
025:        import br.com.gfpshare.builder.menu.MenuCreationException;
026:        import br.com.gfpshare.plaf.util.LookAndFeelLoader;
027:
028:        /**
029:         * @author Igor Regis da Silva Simões
030:         */
031:        public class MenuJanelaBuilder extends GFPMenuBuilder {
032:            private IDesktopPane desktop = (IDesktopPane) GFPController
033:                    .getGFPController().getContexto()
034:                    .get(GFPController.DESKTOP);
035:
036:            private JMenu jmOrganizar;
037:
038:            private JRadioButtonMenuItem jrbmiHorizontal;
039:
040:            private JRadioButtonMenuItem jrbmiVertical;
041:
042:            private JRadioButtonMenuItem jrbmiCascata;
043:
044:            private JRadioButtonMenuItem jrbmiAleatorio;
045:
046:            private JMenu jmLookAndFeel;
047:
048:            protected MenuJanelaListener listener = new MenuJanelaListener();
049:
050:            /**
051:             * Cria uma nova instância de MenuJanelaFacotry
052:             * @param fileOpen boolean indicando se existe um arquivo aberto 
053:             * @throws MenuCreationException
054:             */
055:            public MenuJanelaBuilder(boolean fileOpen)
056:                    throws MenuCreationException {
057:                super ("/xml/menu/MenuJanela.xml", fileOpen);
058:
059:                jmLookAndFeel = new JMenu(
060:                        "       " + MenuJanelaBuilderMessages.getMessages().getString("aparencia")); //$NON-NLS-1$
061:                jmLookAndFeel.setMnemonic('A');
062:
063:                jmOrganizar = new JMenu(
064:                        "       " + MenuJanelaBuilderMessages.getMessages().getString("organizar")); //$NON-NLS-1$
065:                jmOrganizar.setMnemonic('O');
066:
067:                jrbmiHorizontal = new JRadioButtonMenuItem(
068:                        MenuJanelaBuilderMessages.getMessages().getString(
069:                                "horizontal")); //$NON-NLS-1$
070:                jrbmiHorizontal.setMnemonic('H');
071:                jrbmiHorizontal.addItemListener(listener);
072:                jmOrganizar.add(jrbmiHorizontal);
073:
074:                jrbmiVertical = new JRadioButtonMenuItem(
075:                        MenuJanelaBuilderMessages.getMessages().getString(
076:                                "vertical")); //$NON-NLS-1$
077:                jrbmiVertical.setMnemonic('V');
078:                jrbmiVertical.addItemListener(listener);
079:                jmOrganizar.add(jrbmiVertical);
080:
081:                jrbmiCascata = new JRadioButtonMenuItem(
082:                        MenuJanelaBuilderMessages.getMessages().getString(
083:                                "cascata")); //$NON-NLS-1$
084:                jrbmiCascata.setMnemonic('C');
085:                jrbmiCascata.addItemListener(listener);
086:                jmOrganizar.add(jrbmiCascata);
087:
088:                jrbmiAleatorio = new JRadioButtonMenuItem(
089:                        MenuJanelaBuilderMessages.getMessages().getString(
090:                                "aleatorio")); //$NON-NLS-1$
091:                jrbmiAleatorio.setMnemonic('A');
092:                jrbmiAleatorio.addItemListener(listener);
093:                jmOrganizar.add(jrbmiAleatorio);
094:            }
095:
096:            @Override
097:            protected void rebuildMenu(boolean removeAll) {
098:                this .removeAll();
099:                if (jmLookAndFeel == null)
100:                    return;
101:                this .add(jmLookAndFeel);
102:                this .add(jmOrganizar);
103:
104:                jrbmiHorizontal.setSelected(this .desktop
105:                        .getOrganizacaoJanelas() == IDesktopPane.HORIZONTAL);
106:                jrbmiVertical
107:                        .setSelected(this .desktop.getOrganizacaoJanelas() == IDesktopPane.VERTICAL);
108:                jrbmiCascata
109:                        .setSelected(this .desktop.getOrganizacaoJanelas() == IDesktopPane.CASCATA);
110:                jrbmiAleatorio
111:                        .setSelected(this .desktop.getOrganizacaoJanelas() == IDesktopPane.PERSONALIZADA);
112:
113:                ButtonGroup grupo = new ButtonGroup();
114:                grupo.add(jrbmiHorizontal);
115:                grupo.add(jrbmiVertical);
116:                grupo.add(jrbmiCascata);
117:                grupo.add(jrbmiAleatorio);
118:
119:                jmLookAndFeel.removeAll();
120:                String[] lookAndFeel = LookAndFeelLoader.getLookAndFeelLoader()
121:                        .getLookAndFeelInstalados();
122:                for (int i = 0; i < lookAndFeel.length; i++) {
123:                    if (lookAndFeel[i].indexOf("Metal") != -1 || lookAndFeel[i].indexOf("Kunststoff") != -1) //$NON-NLS-1$
124:                    {
125:                        final JMenu lookAndFeelMenu = new JMenu(lookAndFeel[i]);
126:                        lookAndFeelMenu.setMnemonic(lookAndFeelMenu.getText()
127:                                .charAt(0));
128:                        jmLookAndFeel.add(lookAndFeelMenu);
129:                        (new Thread() {
130:                            @Override
131:                            public void run() {
132:                                for (int j = 0; j < LookAndFeelLoader
133:                                        .getLookAndFeelLoader()
134:                                        .getMetalThemes().length; j++) {
135:                                    JMenuItem lookAndFeelMenuItem = new JMenuItem(
136:                                            LookAndFeelLoader
137:                                                    .getLookAndFeelLoader()
138:                                                    .getMetalThemes()[j]
139:                                                    .getName());
140:                                    lookAndFeelMenuItem
141:                                            .addActionListener(listener);
142:                                    lookAndFeelMenuItem
143:                                            .setActionCommand(lookAndFeelMenu
144:                                                    .getText()
145:                                                    + ".mudarThema"); //$NON-NLS-1$
146:                                    lookAndFeelMenuItem
147:                                            .setMnemonic(lookAndFeelMenuItem
148:                                                    .getText().charAt(0));
149:                                    lookAndFeelMenu.add(lookAndFeelMenuItem);
150:                                    lookAndFeelMenu.getPopupMenu().pack();
151:                                }
152:                            }
153:                        }).start();
154:                    } else if (lookAndFeel[i].indexOf("Skin") != -1) {
155:                        JMenu lookAndFeelMenu = new JMenu(lookAndFeel[i]);
156:                        lookAndFeelMenu.setMnemonic(lookAndFeelMenu.getText()
157:                                .charAt(0));
158:                        jmLookAndFeel.add(lookAndFeelMenu);
159:                        String[] themes = LookAndFeelLoader
160:                                .getLookAndFeelLoader().getSkinThemeNames();
161:                        for (int j = 0; j < themes.length; j++) {
162:                            JMenuItem lookAndFeelMenuItem = new JMenuItem(
163:                                    themes[j]);
164:                            lookAndFeelMenuItem.addActionListener(listener);
165:                            lookAndFeelMenuItem
166:                                    .setActionCommand(lookAndFeelMenu.getText()
167:                                            + ".mudarSkin"); //$NON-NLS-1$
168:                            lookAndFeelMenuItem.setMnemonic(lookAndFeelMenuItem
169:                                    .getText().charAt(0));
170:                            lookAndFeelMenu.add(lookAndFeelMenuItem);
171:                        }
172:                    } else {
173:                        JMenuItem lookAndFeelMenuItem = new JMenuItem(
174:                                lookAndFeel[i]);
175:                        lookAndFeelMenuItem.addActionListener(listener);
176:                        lookAndFeelMenuItem
177:                                .setActionCommand("mudarLookAndFeel"); //$NON-NLS-1$
178:                        lookAndFeelMenuItem.setMnemonic(lookAndFeelMenuItem
179:                                .getText().charAt(0));
180:                        jmLookAndFeel.add(lookAndFeelMenuItem);
181:                    }
182:                }
183:
184:                super .rebuildMenu(false);
185:
186:                JInternalFrame[] janelas = this .desktop.getAllFrames();
187:
188:                if (janelas != null && janelas.length > 0)
189:                    this .add(new JSeparator());
190:                for (int i = 0; i < janelas.length; i++) {
191:                    if (janelas[i].isVisible()) {
192:                        JMenuItem janela = new JMenuItem(janelas[i].getTitle());
193:                        janela.setIcon(janelas[i].getFrameIcon());
194:                        janela.addActionListener(listener);
195:                        this .add(janela);
196:                    }
197:                }
198:            }
199:
200:            /**
201:             *
202:             */
203:            private class MenuJanelaListener implements  ItemListener,
204:                    ActionListener {
205:                /**
206:                 * @param c
207:                 * @return O Frame Principal
208:                 */
209:                private Component getFramePrincipal(Component c) {
210:                    return (Component) GFPController.getGFPController()
211:                            .getContexto().get(GFPController.FRAME_PRINCIPAL);
212:                }
213:
214:                /**
215:                 * @param e
216:                 */
217:                public void actionPerformed(final ActionEvent e) {
218:                    if (e.getActionCommand().equals("mudarLookAndFeel")) //$NON-NLS-1$
219:                    {
220:                        try {
221:                            LookAndFeelLoader.getLookAndFeelLoader()
222:                                    .setLookAndFeel(
223:                                            ((JMenuItem) e.getSource())
224:                                                    .getText(),
225:                                            getFramePrincipal(desktop));
226:                        } catch (ClassNotFoundException e1) {
227:                            ((SimpleLog) GFPController.getGFPController()
228:                                    .getContexto().get(GFPController.LOG))
229:                                    .log("Erro ao alterar LookAndFeel!");
230:                            ((SimpleLog) GFPController.getGFPController()
231:                                    .getContexto().get(GFPController.LOG))
232:                                    .log(e1.getLocalizedMessage());
233:                            ((SimpleLog) GFPController.getGFPController()
234:                                    .getContexto().get(GFPController.LOG))
235:                                    .log(e1);
236:                        }
237:                    } else if (e.getActionCommand().indexOf("mudarThema") != -1) //$NON-NLS-1$
238:                    {
239:                        try {
240:                            String lookAndFeel = e.getActionCommand();
241:                            LookAndFeelLoader.getLookAndFeelLoader()
242:                                    .setMetalTheme(
243:                                            lookAndFeel.substring(0,
244:                                                    lookAndFeel.indexOf('.')),
245:                                            ((JMenuItem) e.getSource())
246:                                                    .getText(),
247:                                            getFramePrincipal(desktop));
248:                        } catch (ClassNotFoundException e1) {
249:                            ((SimpleLog) GFPController.getGFPController()
250:                                    .getContexto().get(GFPController.LOG))
251:                                    .log("Erro ao alterar tema!");
252:                            ((SimpleLog) GFPController.getGFPController()
253:                                    .getContexto().get(GFPController.LOG))
254:                                    .log(e1.getLocalizedMessage());
255:                            ((SimpleLog) GFPController.getGFPController()
256:                                    .getContexto().get(GFPController.LOG))
257:                                    .log(e1);
258:                        }
259:                    } else if (e.getActionCommand().indexOf("mudarSkin") != -1) //$NON-NLS-1$
260:                    {
261:                        try {
262:                            LookAndFeelLoader.getLookAndFeelLoader()
263:                                    .setSkinTheme(
264:                                            ((JMenuItem) e.getSource())
265:                                                    .getText(),
266:                                            getFramePrincipal(desktop));
267:                        } catch (Exception e1) {
268:                            ((SimpleLog) GFPController.getGFPController()
269:                                    .getContexto().get(GFPController.LOG))
270:                                    .log("Erro ao alterar skin!");
271:                            ((SimpleLog) GFPController.getGFPController()
272:                                    .getContexto().get(GFPController.LOG))
273:                                    .log(e1.getLocalizedMessage());
274:                            ((SimpleLog) GFPController.getGFPController()
275:                                    .getContexto().get(GFPController.LOG))
276:                                    .log(e1);
277:                        }
278:                    } else {
279:                        (new Thread() {
280:                            @Override
281:                            public void run() {
282:                                JInternalFrame[] janelas = MenuJanelaBuilder.this .desktop
283:                                        .getAllFrames();
284:                                for (int i = 0; i < janelas.length; i++) {
285:                                    if (((JMenuItem) e.getSource()).getText()
286:                                            .equals(janelas[i].getTitle()))
287:                                        try {
288:                                            janelas[i].setSelected(true);
289:                                            break;
290:                                        } catch (PropertyVetoException e) {
291:                                            ((SimpleLog) GFPController
292:                                                    .getGFPController()
293:                                                    .getContexto().get(
294:                                                            GFPController.LOG))
295:                                                    .log("Erro ao selecionar janela: "
296:                                                            + janelas[i]);
297:                                            ((SimpleLog) GFPController
298:                                                    .getGFPController()
299:                                                    .getContexto().get(
300:                                                            GFPController.LOG))
301:                                                    .log(e
302:                                                            .getLocalizedMessage());
303:                                            ((SimpleLog) GFPController
304:                                                    .getGFPController()
305:                                                    .getContexto().get(
306:                                                            GFPController.LOG))
307:                                                    .log(e);
308:                                        }
309:                                }
310:                            }
311:                        }).start();
312:                    }
313:                }
314:
315:                /**
316:                 * @param e
317:                 */
318:                public void itemStateChanged(ItemEvent e) {
319:                    if (e.getSource() == jrbmiHorizontal)
320:                        MenuJanelaBuilder.this.desktop
321:                                .setOrganizacaoJanelas(IDesktopPane.HORIZONTAL);
322:                    else if (e.getSource() == jrbmiVertical)
323:                        MenuJanelaBuilder.this.desktop
324:                                .setOrganizacaoJanelas(IDesktopPane.VERTICAL);
325:                    else if (e.getSource() == jrbmiCascata)
326:                        MenuJanelaBuilder.this.desktop
327:                                .setOrganizacaoJanelas(IDesktopPane.CASCATA);
328:                    else if (e.getSource() == jrbmiAleatorio)
329:                        MenuJanelaBuilder.this.desktop
330:                                .setOrganizacaoJanelas(IDesktopPane.PERSONALIZADA);
331:                }
332:            }
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.