Source Code Cross Referenced for StackPanel.java in  » IDE » J » org » armedbear » j » jdb » 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 » IDE » J » org.armedbear.j.jdb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * StackPanel.java
003:         *
004:         * Copyright (C) 2002-2003 Peter Graves
005:         * $Id: StackPanel.java,v 1.4 2003/06/09 16:33:04 piso Exp $
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:
022:        package org.armedbear.j.jdb;
023:
024:        import com.sun.jdi.AbsentInformationException;
025:        import com.sun.jdi.Location;
026:        import com.sun.jdi.Method;
027:        import com.sun.jdi.ReferenceType;
028:        import com.sun.jdi.StackFrame;
029:        import com.sun.jdi.ThreadReference;
030:        import java.awt.Component;
031:        import java.awt.event.InputEvent;
032:        import java.awt.event.MouseEvent;
033:        import java.awt.event.MouseListener;
034:        import java.util.Iterator;
035:        import java.util.List;
036:        import java.util.Vector;
037:        import javax.swing.JList;
038:        import javax.swing.JScrollPane;
039:        import javax.swing.SwingUtilities;
040:        import org.armedbear.j.Buffer;
041:        import org.armedbear.j.Editor;
042:        import org.armedbear.j.EditorIterator;
043:        import org.armedbear.j.File;
044:        import org.armedbear.j.FastStringBuffer;
045:        import org.armedbear.j.JavaSource;
046:        import org.armedbear.j.Log;
047:
048:        public final class StackPanel implements  ContextListener, MouseListener {
049:            private final Jdb jdb;
050:            private final JdbControlDialog dialog;
051:            private final JList list;
052:            private final JScrollPane scrollPane;
053:
054:            private List frames;
055:
056:            public StackPanel(Jdb jdb, JdbControlDialog dialog) {
057:                this .jdb = jdb;
058:                this .dialog = dialog;
059:                Vector v = new Vector();
060:                list = new JList(v);
061:                scrollPane = new JScrollPane(list);
062:                jdb.addContextListener(this );
063:                list.addMouseListener(this );
064:            }
065:
066:            public Component getComponent() {
067:                return scrollPane;
068:            }
069:
070:            public void contextChanged() {
071:                ThreadReference threadRef = jdb.getCurrentThread();
072:                if (threadRef != null) {
073:                    try {
074:                        frames = threadRef.frames();
075:                        final Vector v = new Vector();
076:                        int selectedIndex = -1;
077:                        if (frames.size() > 0) {
078:                            StackFrame currentStackFrame = jdb
079:                                    .getCurrentStackFrame();
080:                            if (currentStackFrame == null) {
081:                                currentStackFrame = (StackFrame) frames.get(0);
082:                                jdb.setCurrentStackFrame(currentStackFrame);
083:                            }
084:                            int index = 1;
085:                            Iterator iter = frames.iterator();
086:                            while (iter.hasNext()) {
087:                                StackFrame frame = (StackFrame) iter.next();
088:                                if (frame != null
089:                                        && frame.equals(currentStackFrame))
090:                                    selectedIndex = index - 1;
091:                                Location location = frame.location();
092:                                Method method = location.method();
093:                                FastStringBuffer sb = new FastStringBuffer();
094:                                if (index < 10)
095:                                    sb.append(' ');
096:                                sb.append(index++);
097:                                sb.append(' ');
098:                                sb
099:                                        .append(getSimpleName(method
100:                                                .declaringType()));
101:                                sb.append('.');
102:                                sb.append(method.name());
103:                                if (method.isNative()) {
104:                                    sb.append(" (native method)");
105:                                } else {
106:                                    String sourceName = null;
107:                                    try {
108:                                        sourceName = location.sourceName();
109:                                    } catch (AbsentInformationException ignored) {
110:                                    }
111:                                    int lineNumber = location.lineNumber();
112:                                    if (sourceName != null
113:                                            && sourceName.length() > 0) {
114:                                        sb.append(" (");
115:                                        sb.append(sourceName);
116:                                        if (lineNumber > 0) {
117:                                            sb.append(':');
118:                                            sb.append(lineNumber);
119:                                        }
120:                                        sb.append(')');
121:                                    }
122:                                }
123:                                v.add(sb.toString());
124:                            }
125:                        }
126:                        final int finalSelectedIndex = selectedIndex;
127:                        // Update UI in event dispatch thread.
128:                        Runnable r = new Runnable() {
129:                            public void run() {
130:                                list.setListData(v);
131:                                list.setSelectedIndex(finalSelectedIndex);
132:                            }
133:                        };
134:                        SwingUtilities.invokeLater(r);
135:                    } catch (Exception e) {
136:                        Log.error(e);
137:                    }
138:                }
139:            }
140:
141:            private static String getSimpleName(ReferenceType refType) {
142:                String name = refType.name();
143:                int index = name.lastIndexOf('.');
144:                if (index >= 0)
145:                    return name.substring(index + 1);
146:                else
147:                    return name;
148:            }
149:
150:            public void mousePressed(MouseEvent e) {
151:                if (!jdb.isSuspended())
152:                    return;
153:
154:                // Mask off the bits we don't care about (Java 1.4).
155:                int modifiers = e.getModifiers() & 0x1f;
156:
157:                if (modifiers == InputEvent.BUTTON1_MASK
158:                        || modifiers == InputEvent.BUTTON2_MASK) {
159:                    if (modifiers == InputEvent.BUTTON2_MASK)
160:                        list.setSelectedIndex(list
161:                                .locationToIndex(e.getPoint()));
162:                    list.paintImmediately(0, 0, list.getWidth(), list
163:                            .getHeight());
164:                    int index = list.getSelectedIndex();
165:                    if (frames != null && index >= 0 && index < frames.size()) {
166:                        StackFrame stackFrame = (StackFrame) frames.get(index);
167:                        jdb.setCurrentStackFrame(stackFrame);
168:                        Location location = stackFrame.location();
169:                        Method method = location.method();
170:                        if (method != null && !method.isNative()) {
171:                            String className = location.declaringType().name();
172:                            int i = className.indexOf('$');
173:                            if (i > 0)
174:                                className = className.substring(0, i);
175:                            File file = JavaSource.findSource(className, jdb
176:                                    .getSourcePath());
177:                            if (file != null) {
178:                                Buffer buffer = Editor.getBuffer(file);
179:                                if (buffer != null) {
180:                                    Editor editor = null;
181:                                    for (EditorIterator it = new EditorIterator(); it
182:                                            .hasNext();) {
183:                                        Editor ed = it.nextEditor();
184:                                        if (ed.getBuffer() instanceof  Jdb) {
185:                                            editor = ed;
186:                                            break;
187:                                        }
188:                                    }
189:                                    if (editor != null) {
190:                                        editor.makeNext(buffer);
191:                                        editor = editor
192:                                                .activateInOtherWindow(buffer);
193:                                    } else {
194:                                        editor = Editor.currentEditor();
195:                                        editor.makeNext(buffer);
196:                                        editor.activate(buffer);
197:                                    }
198:                                    int lineNumber = location.lineNumber();
199:                                    if (lineNumber > 0) {
200:                                        editor.jumpToLine(lineNumber - 1);
201:                                        editor.updateDisplay();
202:                                    }
203:                                }
204:                            }
205:                        }
206:                    }
207:                }
208:                dialog.requestDefaultFocus();
209:            }
210:
211:            public void mouseReleased(MouseEvent e) {
212:            }
213:
214:            public void mouseClicked(MouseEvent e) {
215:            }
216:
217:            public void mouseEntered(MouseEvent e) {
218:            }
219:
220:            public void mouseExited(MouseEvent e) {
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.