Source Code Cross Referenced for PNLSwingExplorer.java in  » Swing-Library » swingexplorer » org » swingexplorer » 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 » Swing Library » swingexplorer » org.swingexplorer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Swing Explorer. Tool for developers exploring Java/Swing-based application internals. 
003:         * Copyright (C) 2008, Maxim Zakharenkov
004:         *
005:         * This program is free software; you can redistribute it and/or modify
006:         * it under the terms of the GNU General Public License as published by
007:         * the Free Software Foundation; either version 2 of the License, or
008:         * (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 along
016:         * with this program; if not, write to the Free Software Foundation, Inc.,
017:         * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
018:         * 
019:         * $Header: /cvs/swingexplorer/src/org/swingexplorer/PNLSwingExplorer.java,v 1.4 2008/03/07 11:46:50 maxz1 Exp $
020:         */
021:        package org.swingexplorer;
022:
023:        import java.awt.Dimension;
024:        import java.awt.event.ItemEvent;
025:        import java.awt.event.ItemListener;
026:        import java.beans.PropertyChangeEvent;
027:        import java.beans.PropertyChangeListener;
028:
029:        import javax.swing.DefaultComboBoxModel;
030:        import javax.swing.ImageIcon;
031:        import javax.swing.JComboBox;
032:        import javax.swing.event.PopupMenuEvent;
033:        import javax.swing.event.PopupMenuListener;
034:
035:        import org.swingexplorer.graphics.CurrentOperationChangeEvent;
036:        import org.swingexplorer.graphics.ImageEvent;
037:        import org.swingexplorer.graphics.OperationResetEvent;
038:        import org.swingexplorer.graphics.PlayerListener;
039:        import org.swingexplorer.graphics.StateEvent;
040:        import org.swingexplorer.plaf.CustomSplitPaneUI;
041:
042:        /**
043:         *
044:         * @author  Maxim Zakharenkov
045:         */
046:        public class PNLSwingExplorer extends javax.swing.JPanel {
047:
048:            /** Creates new form PNLSwingExplorer */
049:            public PNLSwingExplorer() {
050:                initComponents();
051:            }
052:
053:            /** This method is called from within the constructor to
054:             * initialize the form.
055:             * WARNING: Do NOT modify this code. The content of this method is
056:             * always regenerated by the Form Editor.
057:             */
058:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
059:            private void initComponents() {
060:
061:                sppMain = new javax.swing.JSplitPane();
062:                pnlWorkArea = new javax.swing.JPanel();
063:                tlbWorkArea = new org.swingexplorer.RichToolbar();
064:                txtPath = new javax.swing.JTextField();
065:                lblDisplayedPath = new javax.swing.JLabel();
066:                sppRight = new javax.swing.JSplitPane();
067:                scpDisplay = new javax.swing.JScrollPane();
068:                pnlGuiDisplay = new org.swingexplorer.PNLGuiDisplay();
069:                tbpBottom = new javax.swing.JTabbedPane();
070:                scpComponentDetails = new javax.swing.JScrollPane();
071:                pnlComponentDetails = new org.swingexplorer.PNLComponentDetails();
072:                pnlPlayerControls = new org.swingexplorer.PNLPlayerControls();
073:                pnlAWTEvents = new org.swingexplorer.awt_events.PNLAwtEvents();
074:                pnlEDTMonitor = new org.swingexplorer.edt_monitor.PNLEDTMonitor();
075:                pnlComponentTree = new org.swingexplorer.PNLComponentTree();
076:                pnlStatusBar = new org.swingexplorer.PNLStatusBar();
077:
078:                sppMain.setBorder(null);
079:                sppMain.setDividerLocation(180);
080:                sppMain.setMinimumSize(new java.awt.Dimension(0, 0));
081:
082:                pnlWorkArea.setPreferredSize(new java.awt.Dimension(0, 0));
083:
084:                tlbWorkArea.setFloatable(false);
085:                tlbWorkArea.setMinimumSize(new java.awt.Dimension(0, 0));
086:
087:                txtPath.setEditable(false);
088:
089:                lblDisplayedPath.setText("Displayed:");
090:
091:                sppRight.setBorder(null);
092:                sppRight.setDividerLocation(319);
093:                sppRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
094:                sppRight.setResizeWeight(1.0);
095:
096:                org.jdesktop.layout.GroupLayout pnlGuiDisplayLayout = new org.jdesktop.layout.GroupLayout(
097:                        pnlGuiDisplay);
098:                pnlGuiDisplay.setLayout(pnlGuiDisplayLayout);
099:                pnlGuiDisplayLayout.setHorizontalGroup(pnlGuiDisplayLayout
100:                        .createParallelGroup(
101:                                org.jdesktop.layout.GroupLayout.LEADING).add(0,
102:                                536, Short.MAX_VALUE));
103:                pnlGuiDisplayLayout.setVerticalGroup(pnlGuiDisplayLayout
104:                        .createParallelGroup(
105:                                org.jdesktop.layout.GroupLayout.LEADING).add(0,
106:                                416, Short.MAX_VALUE));
107:
108:                scpDisplay.setViewportView(pnlGuiDisplay);
109:
110:                sppRight.setTopComponent(scpDisplay);
111:
112:                tbpBottom.setMinimumSize(new java.awt.Dimension(0, 0));
113:
114:                scpComponentDetails.setBorder(javax.swing.BorderFactory
115:                        .createEmptyBorder(1, 1, 1, 1));
116:
117:                pnlComponentDetails.setBorder(javax.swing.BorderFactory
118:                        .createEmptyBorder(5, 5, 5, 5));
119:                pnlComponentDetails
120:                        .setMinimumSize(new java.awt.Dimension(0, 0));
121:                scpComponentDetails.setViewportView(pnlComponentDetails);
122:
123:                tbpBottom.addTab("Selection", scpComponentDetails);
124:
125:                pnlPlayerControls.setBorder(javax.swing.BorderFactory
126:                        .createEmptyBorder(0, 0, 0, 0));
127:                tbpBottom.addTab("Player", pnlPlayerControls);
128:                tbpBottom.addTab("AWT Events", pnlAWTEvents);
129:                tbpBottom.addTab("EDT monitor", pnlEDTMonitor);
130:
131:                sppRight.setRightComponent(tbpBottom);
132:
133:                org.jdesktop.layout.GroupLayout pnlWorkAreaLayout = new org.jdesktop.layout.GroupLayout(
134:                        pnlWorkArea);
135:                pnlWorkArea.setLayout(pnlWorkAreaLayout);
136:                pnlWorkAreaLayout
137:                        .setHorizontalGroup(pnlWorkAreaLayout
138:                                .createParallelGroup(
139:                                        org.jdesktop.layout.GroupLayout.LEADING)
140:                                .add(
141:                                        pnlWorkAreaLayout
142:                                                .createSequentialGroup()
143:                                                .add(lblDisplayedPath)
144:                                                .addPreferredGap(
145:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
146:                                                .add(
147:                                                        txtPath,
148:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
149:                                                        489, Short.MAX_VALUE))
150:                                .add(
151:                                        sppRight,
152:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
153:                                        543, Short.MAX_VALUE)
154:                                .add(
155:                                        tlbWorkArea,
156:                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
157:                                        543, Short.MAX_VALUE));
158:                pnlWorkAreaLayout
159:                        .setVerticalGroup(pnlWorkAreaLayout
160:                                .createParallelGroup(
161:                                        org.jdesktop.layout.GroupLayout.LEADING)
162:                                .add(
163:                                        pnlWorkAreaLayout
164:                                                .createSequentialGroup()
165:                                                .add(
166:                                                        tlbWorkArea,
167:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
168:                                                        25,
169:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
170:                                                .addPreferredGap(
171:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
172:                                                .add(
173:                                                        pnlWorkAreaLayout
174:                                                                .createParallelGroup(
175:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
176:                                                                .add(
177:                                                                        lblDisplayedPath)
178:                                                                .add(
179:                                                                        txtPath,
180:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
181:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
182:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
183:                                                .addPreferredGap(
184:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
185:                                                .add(
186:                                                        sppRight,
187:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
188:                                                        494, Short.MAX_VALUE)));
189:
190:                sppMain.setRightComponent(pnlWorkArea);
191:
192:                pnlComponentTree.setMinimumSize(new java.awt.Dimension(0, 0));
193:                sppMain.setTopComponent(pnlComponentTree);
194:
195:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
196:                        this );
197:                this .setLayout(layout);
198:                layout.setHorizontalGroup(layout.createParallelGroup(
199:                        org.jdesktop.layout.GroupLayout.LEADING).add(
200:                        pnlStatusBar,
201:                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 728,
202:                        Short.MAX_VALUE).add(
203:                        org.jdesktop.layout.GroupLayout.TRAILING, sppMain,
204:                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 728,
205:                        Short.MAX_VALUE));
206:                layout
207:                        .setVerticalGroup(layout
208:                                .createParallelGroup(
209:                                        org.jdesktop.layout.GroupLayout.LEADING)
210:                                .add(
211:                                        org.jdesktop.layout.GroupLayout.TRAILING,
212:                                        layout
213:                                                .createSequentialGroup()
214:                                                .add(
215:                                                        sppMain,
216:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
217:                                                        551, Short.MAX_VALUE)
218:                                                .addPreferredGap(
219:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
220:                                                .add(
221:                                                        pnlStatusBar,
222:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
223:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
224:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));
225:            }// </editor-fold>//GEN-END:initComponents
226:
227:            // Variables declaration - do not modify//GEN-BEGIN:variables
228:            private javax.swing.JLabel lblDisplayedPath;
229:            private org.swingexplorer.awt_events.PNLAwtEvents pnlAWTEvents;
230:            private org.swingexplorer.PNLComponentDetails pnlComponentDetails;
231:            private org.swingexplorer.PNLComponentTree pnlComponentTree;
232:            private org.swingexplorer.edt_monitor.PNLEDTMonitor pnlEDTMonitor;
233:            private org.swingexplorer.PNLGuiDisplay pnlGuiDisplay;
234:            private org.swingexplorer.PNLPlayerControls pnlPlayerControls;
235:            private org.swingexplorer.PNLStatusBar pnlStatusBar;
236:            private javax.swing.JPanel pnlWorkArea;
237:            private javax.swing.JScrollPane scpComponentDetails;
238:            private javax.swing.JScrollPane scpDisplay;
239:            private javax.swing.JSplitPane sppMain;
240:            private javax.swing.JSplitPane sppRight;
241:            private javax.swing.JTabbedPane tbpBottom;
242:            private org.swingexplorer.RichToolbar tlbWorkArea;
243:            private javax.swing.JTextField txtPath;
244:            // End of variables declaration//GEN-END:variables
245:
246:            Launcher application;
247:
248:            ModelListener listener = new ModelListener();
249:            PlayerListener playerListener = new PlayerListenerImpl();
250:
251:            JComboBox cmbScale = new JComboBox();
252:
253:            ActRefreshTreeModel actRefreshTreeModel;
254:            ActDisplayComponent actDisplayComponent;
255:            ActTreeSelectionChanged actTreeSelectionChanged;
256:            ActZoomIn actZoomIn;
257:            ActZoomOut actZoomOut;
258:            ActRefreshDisplay actRefreshDisplay;
259:            ActMoveOverDisplay actMoveOverDisplay;
260:            ActMouseClickOnDisplay actClickOnDisplay;
261:            ActKeyOnDisplay actKeyOnDisplay;
262:
263:            void initActions() {
264:                actRefreshTreeModel = new ActRefreshTreeModel(pnlComponentTree);
265:                pnlComponentTree.addAction(actRefreshTreeModel);
266:
267:                actDisplayComponent = new ActDisplayComponent(
268:                        application.model, pnlComponentTree);
269:                pnlComponentTree.addAction(actDisplayComponent);
270:                pnlComponentTree.setDefaultTreeAction(actDisplayComponent);
271:
272:                actTreeSelectionChanged = new ActTreeSelectionChanged(
273:                        application.model, pnlComponentTree);
274:                pnlComponentTree
275:                        .setTreeSelectionAction(actTreeSelectionChanged);
276:
277:                pnlGuiDisplay.setModel(application.model);
278:                pnlComponentTree.setModel(application.model);
279:                pnlComponentDetails.setModel(application.model);
280:                pnlStatusBar.setModel(application.model);
281:                application.model.addPropertyChangeListener(listener);
282:
283:                application.player.addPlayerListener(playerListener);
284:
285:                actRefreshDisplay = new ActRefreshDisplay(application.model);
286:                addAction(actRefreshDisplay);
287:
288:                actZoomOut = new ActZoomOut(application.model);
289:                addAction(actZoomOut);
290:
291:                cmbScale.setEditable(true);
292:                //cmbScale.setPreferredSize(new Dimension(20,16));
293:                cmbScale.setMaximumSize(new Dimension(60, 20));
294:                cmbScale.setModel(new DefaultComboBoxModel(new String[] {
295:                        "25%", "50%", "75%", "100%", "125%", "150%", "175%",
296:                        "200%" }));
297:                tlbWorkArea.add(cmbScale);
298:                cmbScale.getEditor().setItem(
299:                        "" + (int) (application.model.getDisplayScale() * 100)
300:                                + "%");
301:
302:                ComboScaleListener scaleListener = new ComboScaleListener();
303:                cmbScale.addItemListener(scaleListener);
304:                cmbScale.addPopupMenuListener(scaleListener);
305:
306:                actZoomIn = new ActZoomIn(application.model);
307:                addAction(actZoomIn);
308:
309:                actMoveOverDisplay = new ActMoveOverDisplay(pnlGuiDisplay,
310:                        application.model);
311:                actKeyOnDisplay = new ActKeyOnDisplay(pnlGuiDisplay,
312:                        application.model);
313:                pnlGuiDisplay.addMouseMotionListener(actMoveOverDisplay);
314:                pnlGuiDisplay.addMouseListener(actMoveOverDisplay);
315:                pnlGuiDisplay.addKeyListener(actKeyOnDisplay);
316:                pnlGuiDisplay.setFocusable(true);
317:
318:                actClickOnDisplay = new ActMouseClickOnDisplay(pnlGuiDisplay,
319:                        application.model);
320:                pnlGuiDisplay.addMouseListener(actClickOnDisplay);
321:
322:                pnlPlayerControls.setPlayer(application.player);
323:                pnlAWTEvents.setShowEventSourceAction(new ActShowEventSource(
324:                        application.model, pnlAWTEvents));
325:            }
326:
327:            class ComboScaleListener implements  ItemListener, PopupMenuListener {
328:
329:                void changeScale() {
330:                    String item = (String) cmbScale.getSelectedItem();
331:
332:                    int percentIndex = item.lastIndexOf("%");
333:                    if (percentIndex != -1) {
334:                        item = item.substring(0, percentIndex);
335:                    }
336:                    application.model.setDisplayScale(Double.parseDouble(item
337:                            .toString()) / 100);
338:                }
339:
340:                public void itemStateChanged(ItemEvent e) {
341:                    if (ItemEvent.SELECTED == e.getStateChange()) {
342:                        if (!cmbScale.isPopupVisible()) {
343:                            changeScale();
344:                        }
345:                    }
346:                }
347:
348:                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
349:                    changeScale();
350:                }
351:
352:                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
353:                }
354:
355:                public void popupMenuCanceled(PopupMenuEvent e) {
356:                }
357:            }
358:
359:            public void addAction(RichAction act) {
360:                tlbWorkArea.addActionEx(act);
361:                act.setApplication(application);
362:            }
363:
364:            class ModelListener implements  PropertyChangeListener {
365:
366:                public void propertyChange(PropertyChangeEvent evt) {
367:                    String propName = evt.getPropertyName();
368:                    if ("displayedComponent".equals(propName)) {
369:                        actRefreshTreeModel.actionPerformed(null);
370:                        txtPath.setText(application.model
371:                                .getComponentPath(application.model
372:                                        .getDisplayedComponent(), true));
373:                        application.player.setOperations(application.model
374:                                .getDisplayedComponent());
375:                    } else if ("displayScale".equals(propName)) {
376:                        cmbScale
377:                                .getEditor()
378:                                .setItem(
379:                                        ""
380:                                                + (int) (application.model
381:                                                        .getDisplayScale() * 100)
382:                                                + "%");
383:                    }
384:                }
385:            }
386:
387:            class PlayerListenerImpl implements  PlayerListener {
388:
389:                public void imageRendered(ImageEvent evt) {
390:                    application.model.setDisplayedComponentImage(new ImageIcon(
391:                            evt.getImage()));
392:                }
393:
394:                public void stateChanged(StateEvent evt) {
395:                }
396:
397:                public void operationsReset(OperationResetEvent operations) {
398:                }
399:
400:                public void currentOperationChanged(
401:                        CurrentOperationChangeEvent evt) {
402:
403:                }
404:            }
405:
406:            public void setApplication(Launcher app) {
407:                application = app;
408:                initActions();
409:            }
410:
411:            public Launcher getApplication() {
412:                return application;
413:            }
414:        }
415:
416:        /*
417:         * $Log: PNLSwingExplorer.java,v $
418:         * Revision 1.4  2008/03/07 11:46:50  maxz1
419:         * Added thread violation monitor and EDT hang monitor. Changed L & F.
420:         *
421:         * Revision 1.3  2008/02/13 21:52:11  maxz1
422:         * Added event filtering functionality
423:         *
424:         * Revision 1.2  2008/02/06 08:36:09  maxz1
425:         * Changed license header
426:         *
427:         * Revision 1.1  2007/06/27 19:41:38  maxz1
428:         * new
429:         *
430:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.