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


001:
002:        /*
003:         * TabChangeListener.java Copyright (c) 2006,07 Swaroop Belur 
004:         *  
005:         * This program is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU General Public License
007:         * as published by the Free Software Foundation; either version 2
008:         * of the License, or (at your option) any later version.
009:
010:         * This program is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013:         * GNU General Public License for more details.
014:
015:         * You should have received a copy of the GNU General Public License
016:         * along with this program; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
018:         *
019:         */
020:        package net.sf.jdec.ui.event;
021:
022:        import java.awt.Component;
023:        import java.io.File;
024:        import java.util.ArrayList;
025:
026:        import javax.swing.JDialog;
027:        import javax.swing.JOptionPane;
028:        import javax.swing.JTabbedPane;
029:        import javax.swing.event.ChangeEvent;
030:        import javax.swing.event.ChangeListener;
031:
032:        import net.sf.jdec.main.ConsoleLauncher;
033:        import net.sf.jdec.ui.adapter.DecompilerBridge;
034:        import net.sf.jdec.ui.core.JdecTree;
035:        import net.sf.jdec.ui.core.Manager;
036:        import net.sf.jdec.ui.main.UILauncher;
037:        import net.sf.jdec.ui.util.LogWriter;
038:        import net.sf.jdec.ui.util.UIConstants;
039:        import net.sf.jdec.ui.util.UIUtil;
040:        import net.sf.jdec.config.Configuration;
041:
042:        public class TabChangeLstener implements  ChangeListener {
043:
044:            public void stateChanged(ChangeEvent e) {
045:                try {
046:
047:                    final JTabbedPane rightTab = getRightTabbedPane();
048:                    if (e.getSource() == rightTab) {
049:                        Component c = rightTab.getSelectedComponent();
050:
051:                        int index = rightTab.getSelectedIndex();
052:                        String title = rightTab.getTitleAt(index);
053:                        String opt = Configuration.getDecompileroption();
054:
055:                        if (title.equals("Disassembled Output")) {
056:
057:                            final File f = ConsoleLauncher
058:                                    .getCurrentSourceFile();
059:                            if (f != null) {
060:                                //Writer outputwriter=Writer.getWriter("output");
061:                                //outputwriter.close("output");
062:                                Thread t1 = new Thread() {
063:
064:                                    public void run() {
065:                                        DecompilerBridge bridge = DecompilerBridge
066:                                                .getInstance(UIUtil.getUIUtil());
067:                                        bridge
068:                                                .setClassFile(f
069:                                                        .getAbsolutePath());
070:                                        Manager.getManager()
071:                                                .setShowProgressBar(true);
072:                                        bridge.execute("disassemble", "",
073:                                                false, "null");
074:                                        bridge.showResult(rightTab);
075:                                        resetTabs();
076:                                    }
077:                                };
078:                                Thread t2 = new Thread() {
079:
080:                                    public void run() {
081:
082:                                        JDialog proframe = UIUtil
083:                                                .launchProgressBarFrame();
084:                                        if (proframe != null) {
085:                                            proframe.setVisible(true);
086:                                        }
087:                                        //proframe.requestFocusInWindow();
088:
089:                                        while (Manager.getManager()
090:                                                .isShowProgressBar() == true) {
091:
092:                                            gotoSleep();
093:                                        }
094:
095:                                        if (!Manager.getManager()
096:                                                .isShowProgressBar()) {
097:                                            if (proframe != null) {
098:                                                proframe.setVisible(false);
099:                                                proframe.dispose();
100:                                            }
101:                                            proframe = null;
102:                                            if (ConsoleLauncher.fatalErrorOccured)
103:                                                JOptionPane
104:                                                        .showMessageDialog(
105:                                                                UILauncher
106:                                                                        .getMainFrame(),
107:                                                                UIConstants.jdecTaskError,
108:                                                                "Jdec Status",
109:                                                                JOptionPane.INFORMATION_MESSAGE);
110:                                        }
111:
112:                                    }
113:
114:                                };
115:                                t1.setPriority(Thread.MAX_PRIORITY);
116:                                t2.setPriority(Thread.NORM_PRIORITY);
117:                                Manager.getManager().setStatusThread(t1);
118:                                if (UIUtil.checkForInvalidEntries("")) {
119:                                    t1.setPriority(Thread.MAX_PRIORITY);
120:                                    t2.setPriority(Thread.NORM_PRIORITY);
121:                                    t1.start();
122:                                    t2.start();
123:                                } else {
124:                                    JOptionPane
125:                                            .showMessageDialog(
126:                                                    UILauncher.getMainFrame(),
127:                                                    "Please Check The Decompiler Configuration Property Values Again",
128:                                                    "JDEC WARNING",
129:                                                    JOptionPane.INFORMATION_MESSAGE);
130:                                }
131:
132:                            }
133:
134:                        } else if (title.equals("Decompiled Output")) {
135:
136:                            final File f = ConsoleLauncher
137:                                    .getCurrentSourceFile();
138:                            if (f != null) {
139:                                //Writer outputwriter=Writer.getWriter("output");
140:                                //outputwriter.close("output");
141:                                Thread t1 = new Thread() {
142:
143:                                    public void run() {
144:                                        Manager.getManager()
145:                                                .setShowProgressBar(true);
146:                                        DecompilerBridge bridge = DecompilerBridge
147:                                                .getInstance(UIUtil.getUIUtil());
148:                                        bridge
149:                                                .setClassFile(f
150:                                                        .getAbsolutePath());
151:                                        bridge.execute("decompileClass", "",
152:                                                false, "null");
153:                                        bridge.showResult(rightTab);
154:                                        resetTabs();
155:
156:                                    }
157:                                };
158:
159:                                Thread t2 = new Thread() {
160:
161:                                    public void run() {
162:
163:                                        JDialog proframe = UIUtil
164:                                                .launchProgressBarFrame();
165:                                        if (proframe != null) {
166:                                            proframe.setVisible(true);
167:                                        }
168:                                        //proframe.requestFocusInWindow();
169:
170:                                        while (Manager.getManager()
171:                                                .isShowProgressBar() == true) {
172:
173:                                            gotoSleep();
174:                                        }
175:
176:                                        if (!Manager.getManager()
177:                                                .isShowProgressBar()) {
178:                                            if (proframe != null) {
179:                                                proframe.setVisible(false);
180:                                                proframe.dispose();
181:                                            }
182:                                            proframe = null;
183:                                            if (ConsoleLauncher.fatalErrorOccured)
184:                                                JOptionPane
185:                                                        .showMessageDialog(
186:                                                                UILauncher
187:                                                                        .getMainFrame(),
188:                                                                UIConstants.jdecTaskError,
189:                                                                "Jdec Status",
190:                                                                JOptionPane.INFORMATION_MESSAGE);
191:                                        }
192:
193:                                    }
194:
195:                                };
196:
197:                                boolean b = fireOnTabChange(f.getAbsolutePath());
198:                                if (b) {
199:                                    if (UIUtil.checkForInvalidEntries("")) {
200:                                        t1.setPriority(Thread.MAX_PRIORITY);
201:                                        t2.setPriority(Thread.NORM_PRIORITY);
202:                                        t1.start();
203:                                        t2.start();
204:                                    } else {
205:                                        JOptionPane
206:                                                .showMessageDialog(
207:                                                        UILauncher
208:                                                                .getMainFrame(),
209:                                                        "Please Check The Decompiler Configuration Property Values Again",
210:                                                        "JDEC WARNING",
211:                                                        JOptionPane.INFORMATION_MESSAGE);
212:                                    }
213:                                }
214:
215:                            }
216:                        } else if (title.equals("Combined Output")) {
217:
218:                        }
219:
220:                    }
221:
222:                } catch (Exception ioe) {
223:                    // ignore
224:                }
225:
226:            }
227:
228:            private JTabbedPane getRightTabbedPane() {
229:                Manager manager = Manager.getManager();
230:                ArrayList paneList = manager.getCurrentSplitPaneComponents();
231:                JTabbedPane tabs = null;
232:                for (int s = 0; s < paneList.size(); s++) {
233:                    Object current = paneList.get(s);
234:                    if (current instanceof  JTabbedPane) {
235:                        tabs = (JTabbedPane) current;
236:                        Component c = tabs.getComponent(0);
237:                        if ((c instanceof  JdecTree) == false) {
238:                            if (tabs.getTabCount() > 2) {
239:                                break;
240:                            }
241:                        }
242:
243:                    }
244:                }
245:
246:                return tabs;
247:            }
248:
249:            private void gotoSleep() {
250:                try {
251:                    Thread.sleep(1000);
252:
253:                } catch (InterruptedException e) {
254:                    LogWriter l = LogWriter.getInstance();
255:                    e.printStackTrace(l.getPrintWriter());
256:                }
257:
258:            }
259:
260:            private static TabChangeLstener listener;
261:            private static Object lock;
262:            static {
263:                lock = new Object();
264:            }
265:
266:            public static TabChangeLstener getListener() {
267:                if (listener != null) {
268:                    return listener;
269:                } else {
270:                    synchronized (lock) {
271:                        listener = new TabChangeLstener();
272:                        return listener;
273:                    }
274:                }
275:
276:            }
277:
278:            private TabChangeLstener() {
279:
280:            }
281:
282:            private boolean fireOnTabChange(java.lang.String path) {
283:                ArrayList list = ConsoleLauncher.getTabChangeList();
284:                if (list != null && list.size() > 0) {
285:                    java.lang.String p = (java.lang.String) list.get(0);
286:                    if (p.equals(path)) {
287:                        return false;
288:                    }
289:                }
290:                return true;
291:            }
292:
293:            private void resetTabs() {
294:                JTabbedPane tabs = getRightTabbedPane();
295:                int index = tabs.indexOfTab("Jdec Configuration");
296:                if (index != -1)
297:                    tabs.remove(index);
298:                index = tabs.indexOfTab("Constant Pool");
299:                if (index != -1)
300:                    tabs.remove(index);
301:                index = tabs.indexOfTab("Class Details");
302:                if (index != -1)
303:                    tabs.remove(index);
304:                index = tabs.indexOfTab("Exception Tables");
305:                if (index != -1)
306:                    tabs.remove(index);
307:                index = tabs.indexOfTab("Local Variables");
308:                if (index != -1)
309:                    tabs.remove(index);
310:                index = tabs.indexOfTab("System Properties");
311:                if (index != -1)
312:                    tabs.remove(index);
313:                index = tabs.indexOfTab("Jdec Help");
314:                if (index != -1)
315:                    tabs.remove(index);
316:                index = tabs.indexOfTab("Skeleton Output");
317:                if (index != -1)
318:                    tabs.remove(index);
319:                index = tabs.indexOfTab("UILog Output");
320:                if (index != -1)
321:                    tabs.remove(index);
322:                index = tabs.indexOfTab("DecompilerLog Output");
323:                if (index != -1)
324:                    tabs.remove(index);
325:            }
326:
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.