Source Code Cross Referenced for DisplayUI.java in  » Development » jdec » net » sf » jdec » ui » core » 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 » Development » jdec » net.sf.jdec.ui.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  DisplayUI.java Copyright (c) 2006,07 Swaroop Belur
003:         *
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:        
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         * GNU General Public License for more details.
013:        
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software
016:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
017:         *
018:         */
019:
020:        package net.sf.jdec.ui.core;
021:
022:        import net.sf.jdec.ui.config.UIConfig;
023:        import net.sf.jdec.ui.main.UILauncher;
024:        import net.sf.jdec.ui.util.Preferences;
025:        import net.sf.jdec.ui.util.Tips;
026:
027:        import javax.swing.*;
028:        import java.awt.*;
029:        import java.awt.event.WindowAdapter;
030:        import java.awt.event.WindowEvent;
031:        import java.awt.event.WindowListener;
032:        import java.io.File;
033:        import java.io.IOException;
034:        import java.util.ArrayList;
035:
036:        /**
037:        
038:         *  @author swaroop belur
039:         */
040:
041:        public class DisplayUI {
042:
043:            private Manager manager = null;
044:
045:            private MainFrame mainFrame = null;
046:            private ToolBar bar = null;
047:            private Splitter splitPane = null;
048:            private AuxToolBar auxbar = null;
049:            JFrame jframe = null;
050:
051:            public JFrame getJframe() {
052:                return jframe;
053:            }
054:
055:            public void setJframe(JFrame jframe) {
056:                this .jframe = jframe;
057:            }
058:
059:            public void setManager(Manager manager) {
060:                this .manager = manager;
061:            }
062:
063:            public void renderComponenets() // NOTE: This will have to be changed if some more compoents will be added like
064:            // aux toolbar
065:            {
066:                ArrayList neededComponents = manager.getRegisteredComponents();
067:
068:                String mesg = "";
069:                for (int s = 0; s < neededComponents.size(); s++) {
070:                    UIObject uiObject = (UIObject) neededComponents.get(s);
071:
072:                    if (uiObject instanceof  MainFrame) {
073:                        setMainFrame((MainFrame) uiObject);
074:                    }
075:                    if (uiObject instanceof  ToolBar) {
076:                        setBar((ToolBar) uiObject);
077:                    }
078:                    if (uiObject instanceof  Splitter) {
079:                        setSplitPane((Splitter) uiObject);
080:                    }
081:                    if (uiObject instanceof  AuxToolBar) {
082:                        setAuxToolBar((AuxToolBar) uiObject);
083:                    }
084:
085:                }
086:
087:                JFrame mainWindow = mainFrame.getMainFrame();
088:                JMenuBar menuBar = bar.getBar();
089:                JSplitPane pane = splitPane.getSplitPlane();
090:                JToolBar aux = auxbar.getAuxBar();
091:
092:                Dimension d = mainWindow.getToolkit().getScreenSize();
093:                Container c = mainWindow.getContentPane();
094:                mainWindow.setSize((int) d.getWidth() - 10,
095:                        (int) d.getHeight() - 50);
096:                mainWindow.setJMenuBar(menuBar);
097:                UILauncher.setMainFrameRef(mainWindow);
098:                auxlabel = new JLabel("");
099:                auxPanel = new JPanel();
100:                auxPanel.add(aux, BorderLayout.EAST);
101:                //auxPanel.add(auxlabel,BorderLayout.WEST);
102:                c.add(aux, BorderLayout.NORTH);
103:                c.add(pane, BorderLayout.CENTER);
104:                WindowListener wndCloser = new WindowAdapter() {
105:                    public void windowClosing(WindowEvent e) {
106:                        try {
107:                            UIConfig uiconfig = UILauncher.getUIConfigRef();
108:                            synchronized (uiconfig) {
109:                                uiconfig.persistToFile();
110:                            }
111:                        } catch (IOException ioe) {
112:                            try {
113:
114:                                String msg = "***************************************************************";
115:                                msg += "\n" + "EXCEPTION STACK TRACE";
116:                                msg += "***************************************************************";
117:                                msg += "\n\n";
118:                                msg += "Message :" + ioe.getMessage();
119:                                msg += "\n" + "Cause :" + ioe.getCause();
120:                                ioe.printStackTrace();
121:                                Manager.getManager().setShowProgressBar(false);
122:
123:                            } catch (Exception ex) {
124:                            }
125:                        }
126:
127:                        int option = JOptionPane.showConfirmDialog(UILauncher
128:                                .getMainFrame(), "Are You Sure?",
129:                                "Close Jdec UI", JOptionPane.YES_NO_OPTION);
130:                        if (option == JOptionPane.NO_OPTION) {
131:
132:                            UILauncher
133:                                    .getMainFrame()
134:                                    .setDefaultCloseOperation(
135:                                            UILauncher.getMainFrame().DO_NOTHING_ON_CLOSE);
136:                        } else if (option == JOptionPane.YES_OPTION) {
137:                            boolean b = UILauncher.getUIutil()
138:                                    .hasConfigChanged();
139:                            if (b) {
140:                                int opt = JOptionPane
141:                                        .showConfirmDialog(
142:                                                UILauncher.getMainFrame(),
143:                                                "The Decompiler Configuration Has been updated...\nWould You Like to save the changes...",
144:                                                "Update Configuration ...?",
145:                                                JOptionPane.YES_NO_OPTION);
146:                                if (opt == JOptionPane.YES_OPTION) {
147:
148:                                    File src = new File(System
149:                                            .getProperty("user.home")
150:                                            + File.separator
151:                                            + "tempconfig.properties");
152:                                    File dest = new File("config.properties");
153:                                    UILauncher.getUIutil().copyFile(src, dest);
154:                                }
155:                                if (opt == JOptionPane.NO_OPTION) {
156:                                    UILauncher
157:                                            .getMainFrame()
158:                                            .setDefaultCloseOperation(
159:                                                    UILauncher.getMainFrame().DO_NOTHING_ON_CLOSE);
160:                                }
161:
162:                                if (opt == JOptionPane.CANCEL_OPTION) {
163:                                    UILauncher
164:                                            .getMainFrame()
165:                                            .setDefaultCloseOperation(
166:                                                    UILauncher.getMainFrame().DO_NOTHING_ON_CLOSE);
167:                                }
168:
169:                            }
170:
171:                            JFrame frame = UILauncher.getMainFrame();
172:                            frame.setVisible(false);
173:                            frame.setEnabled(false);
174:                            frame.dispose();
175:                            UILauncher.closeChildWindows();
176:                            File replaceMeFile = new File("***REPLACEME***");
177:                            if (replaceMeFile.exists()) {
178:                                replaceMeFile.delete();
179:                                if (replaceMeFile.exists()) {
180:                                    replaceMeFile.deleteOnExit();
181:                                }
182:                            }
183:                            replaceMeFile = new File("***REPLACE_ME***");
184:                            if (replaceMeFile.exists()) {
185:                                replaceMeFile.delete();
186:                                if (replaceMeFile.exists()) {
187:                                    replaceMeFile.deleteOnExit();
188:                                }
189:                            }
190:                        }
191:
192:                    }
193:                };
194:                mainWindow.addWindowListener(wndCloser);
195:
196:                // Store The Frame Reference for access
197:                this .jframe = mainWindow;
198:
199:                // Show The Frame
200:                UILauncher.splash.progress.setValue(80);
201:
202:                try {
203:                    // Check if System Property for lookNFeel was set by user
204:                    String def = System.getProperty("user.lookNfeel.choice");
205:                    boolean setlnf = true;
206:                    if (def != null) {
207:                        try {
208:                            //System.out.println(def);
209:
210:                            UIManager.setLookAndFeel(def);
211:                            setlnf = false;
212:                            Preferences.userProvidedAtLaunch = def;
213:                        } catch (Exception exp) {
214:                            System.out
215:                                    .println("LookNFeel class could not be loaded/instantiated\nPlease check 1>The path of class name\n2>Supporting jar is present\n");
216:                            System.out.println("Specified class : " + def);
217:                            System.out
218:                                    .println("\nChecking for other lookNfeels");
219:                            def = null;
220:                            setlnf = true;
221:                        }
222:                    }
223:                    if (def == null) {
224:                        def = UILauncher.getUIutil().getDefaultLnkNFeelName();
225:                    }
226:                    if (def != null) {
227:                        try {
228:                            //System.out.println(def);
229:                            UIManager.setLookAndFeel(def);
230:                            setlnf = false;
231:                        } catch (Exception exp) {
232:                            def = null;
233:                            setlnf = true;
234:                        }
235:                    }
236:                    if (def == null)
237:                        def = UIManager.getSystemLookAndFeelClassName();
238:                    if (def == null)
239:                        def = UIManager.getCrossPlatformLookAndFeelClassName();
240:                    if (setlnf)
241:                        UIManager.setLookAndFeel(def);
242:                    UILauncher.splash.progress.setValue(90);
243:                    SwingUtilities.updateComponentTreeUI(mainWindow);
244:                    //UILauncher.getMainFrame().repaint();
245:                    try {
246:                        Thread.sleep(2000);
247:                        UILauncher.splash.progress.setValue(100);
248:                        UILauncher.splash.st.setText("Done Loading");
249:                        Thread.sleep(1000); // Intentional For The splash screen to remain for some time
250:
251:                    } catch (InterruptedException ie) {
252:
253:                        UILauncher.splash.st.setText("Done Loading");
254:                    }
255:                    if (UILauncher.welcomeCreated) {
256:                        Splitter ref = Manager.getManager().getSplitterRef();
257:                        //JSplitPane right=ref.getRightSplitPane();
258:                        ref.resetRightSplitPane("hide");
259:                        ref.getSplitPlane().revalidate();
260:                        UILauncher.getMainFrame().validate();
261:                    }
262:
263:                    UILauncher.showSplash = false;
264:                    mainWindow.setVisible(true);
265:                    mainWindow.requestFocusInWindow();
266:                    UILauncher.getUIutil().setCurrentLNF(
267:                            UILauncher.getUIutil().getTypeGivenClassName(def));
268:                } catch (Exception looknfeel) {
269:                    try {
270:
271:                        String msg = "***************************************************************";
272:                        msg += "\n" + "EXCEPTION STACK TRACE";
273:                        msg += "***************************************************************";
274:                        msg += "\n\n";
275:                        msg += "Message :" + looknfeel.getMessage();
276:                        msg += "\n" + "Cause :" + looknfeel.getCause();
277:                        Manager.getManager().setShowProgressBar(false);
278:                        looknfeel.printStackTrace();
279:
280:                    } catch (Exception ex) {
281:                    }
282:                }
283:
284:                UIConfig configref = UILauncher.getUIConfigRef();
285:                boolean show = configref.showTip();
286:                if (show) {
287:                    Tips tips = new Tips();
288:                } else {
289:                    String showtip = configref.getPref("ShowTip");
290:                    if (showtip != null && showtip.equalsIgnoreCase("true")) {
291:                        Tips tips = new Tips();
292:                    }
293:                }
294:
295:            }
296:
297:            public void updateUI() {
298:                renderComponenets();
299:            }
300:
301:            private ToolBar getBar() {
302:                return bar;
303:            }
304:
305:            private void setBar(ToolBar bar) {
306:                this .bar = bar;
307:            }
308:
309:            private MainFrame getMainFrame() {
310:                return mainFrame;
311:            }
312:
313:            private void setMainFrame(MainFrame mainFrame) {
314:                this .mainFrame = mainFrame;
315:            }
316:
317:            private Splitter getSplitPane() {
318:                return splitPane;
319:            }
320:
321:            private void setSplitPane(Splitter splitPane) {
322:                this .splitPane = splitPane;
323:            }
324:
325:            private void setAuxToolBar(AuxToolBar auxBar) {
326:                this .auxbar = auxBar;
327:            }
328:
329:            public static JPanel auxPanel = null;
330:            public static JLabel auxlabel = null;
331:
332:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.