Source Code Cross Referenced for TracesViewer.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » tools » tracesviewer » 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 » 6.0 JDK Modules » Java Advanced Imaging » tools.tracesviewer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * TraceViewer.java
003:         *
004:         * Created on April 16, 2002, 2:41 PM
005:         */
006:
007:        package tools.tracesviewer;
008:
009:        import javax.swing.*;
010:        import javax.swing.border.*;
011:        import java.awt.*;
012:        import java.awt.event.*;
013:        import java.util.*;
014:        import java.net.*;
015:        import java.io.*;
016:
017:        /**
018:         *
019:         * @author  deruelle
020:         * @version 1.0
021:         */
022:        public class TracesViewer extends javax.swing.JFrame {
023:
024:            private boolean standaloneViewer = false;
025:
026:            private String logFile;
027:
028:            // Menus
029:            protected JMenuBar menuBar;
030:            protected JMenu displayAllSessionsMenu;
031:            protected JMenu optionsMenu;
032:            protected JMenu refreshMenu;
033:            protected JMenu aboutMenu;
034:            protected JMenu helpMenu;
035:            protected JMenu quitMenu;
036:
037:            protected JMenuItem animationMenuItem;
038:            protected JMenuItem stackIdMenuItem;
039:
040:            // The container: contain panels (one left and one center)
041:            protected JPanel firstPanel;
042:            protected JPanel secondPanel;
043:            protected JPanel firstSubPanel;
044:            protected JPanel secondSubPanel;
045:            protected JPanel thirdSubPanel;
046:
047:            protected JButton scriptButton;
048:            //protected JButton refreshButton;
049:            protected Choice choice;
050:
051:            protected ListenerTracesViewer listenerTracesViewer;
052:
053:            // All the components inside the second panel
054:            protected JLabel sessionsLabel;
055:            protected TracesSessionsList tracesSessionsList;
056:            protected JButton messageContentButton;
057:            protected TextArea messageContentTextArea;
058:
059:            protected TracesSessions tracesSessions;
060:            protected TracesCanvas tracesCanvas;
061:
062:            protected static String rmiHost;
063:            protected static String rmiPort;
064:            protected static String stackId;
065:
066:            protected static Image actorsImage = null;
067:            protected static Image backgroundImage = null;
068:            protected static Image facesImage = null;
069:            protected static Image logoNist = null;
070:
071:            protected TracesAnimationThread animationThread = null;
072:
073:            /** 
074:             * Call this constructor when you want to construct a visualizer
075:             * from traces that you have already read.
076:             *
077:             *@param titles is an array containing the titles for the traces.
078:             *@param traces is an array containing an array of XML Formatted traces.
079:             *
080:             */
081:            public TracesViewer(Hashtable traces, String logName,
082:                    String logDescription, String auxInfo) {
083:                //System.out.println("**** TRACE ******:\n"+trace+"\n");
084:                TracesSessions tss = new TracesSessions();
085:                Enumeration elements = traces.elements();
086:                tss.setName(logName);
087:                logFile = logName;
088:                while (elements.hasMoreElements()) {
089:                    MessageLogList mll = (MessageLogList) elements
090:                            .nextElement();
091:                    TracesSession ts = new TracesSession(mll);
092:                    ts.setName(logName);
093:                    ts.setInfo(auxInfo);
094:                    ts.setLogDescription(logDescription);
095:                    tss.add(ts);
096:                }
097:
098:                listenerTracesViewer = new ListenerTracesViewer(this );
099:
100:                // The order is important!!!!!
101:                // Look at the rmi registry for new traces 
102:                // tracesSessions=refreshTracesSessions();
103:                this .tracesSessions = tss;
104:                this .standaloneViewer = true;
105:                initComponents();
106:                // Initialisation of the tracesSessionsList:
107:                tracesSessionsList.setTracesSessions(this .tracesSessions);
108:                // Initialisation of the Thread for the animations:
109:                animationThread = new TracesAnimationThread(tracesCanvas);
110:
111:                // width, height
112:                this .setSize(670, 620);
113:                this .setLocation(0, 0);
114:            }
115:
116:            // Constructor for the GUILauncher only!!!!!
117:            public TracesViewer(String title, String aRmiHost, String aRmiPort,
118:                    String aStackId) {
119:                super (title);
120:                try {
121:                    /*
122:                        Toolkit toolkit=Toolkit.getDefaultToolkit();
123:                        backgroundImage=toolkit.getImage("./images/back.gif");
124:                        actorsImage=toolkit.getImage("./images/comp.gif");
125:                        facesImage=toolkit.getImage("./images/faces.jpg");
126:                        logoNist=toolkit.getImage("./images/nistBanner.jpg");
127:                     */
128:
129:                    Toolkit toolkit = Toolkit.getDefaultToolkit();
130:                    // this.backgroundImage=toolkit.getImage(back);
131:                    URL url = TracesViewer.class.getResource("images/back.gif");
132:                    // System.out.println("url:"+url.toString());
133:                    backgroundImage = toolkit.getImage(url);
134:                    url = TracesViewer.class.getResource("images/comp.gif");
135:                    actorsImage = toolkit.getImage(url);
136:                    url = TracesViewer.class.getResource("images/faces.jpg");
137:                    facesImage = toolkit.getImage(url);
138:                    url = TracesViewer.class
139:                            .getResource("images/nistBanner.jpg");
140:                    logoNist = toolkit.getImage(url);
141:
142:                } catch (Exception e) {
143:                    backgroundImage = null;
144:                    actorsImage = null;
145:                    facesImage = null;
146:                    logoNist = null;
147:                    System.out
148:                            .println("Problem with the Toolkit: no loaded images!!!");
149:                    e.printStackTrace();
150:                }
151:
152:                rmiHost = aRmiHost;
153:                rmiPort = aRmiPort;
154:                stackId = aStackId;
155:
156:                listenerTracesViewer = new ListenerTracesViewer(this );
157:
158:                // The order is important!!!!!
159:                // Look at the rmi registry for new traces 
160:                tracesSessions = refreshTracesSessions();
161:                initComponents();
162:                // Initialisation of the tracesSessionsList:
163:                tracesSessionsList.setTracesSessions(tracesSessions);
164:                // Initialisation of the Thread for the animations:
165:                animationThread = new TracesAnimationThread(tracesCanvas);
166:
167:                // width, height
168:                this .setSize(670, 620);
169:                // this.setLocation(0,0);
170:                this .show();
171:            }
172:
173:            // Constructor for the Application only!!!!!
174:            public TracesViewer(String title, String aRmiHost, String aRmiPort,
175:                    String aStackId, String back, String faces, String actors,
176:                    String aLogoNist) {
177:                super (title);
178:                try {
179:                    Toolkit toolkit = Toolkit.getDefaultToolkit();
180:                    //System.out.println("back:"+back);
181:                    // this.backgroundImage=toolkit.getImage(back);
182:                    URL url = TracesViewer.class.getResource(back);
183:                    //  System.out.println("url:"+url.toString());
184:                    backgroundImage = toolkit.getImage(url);
185:                    url = TracesViewer.class.getResource(actors);
186:                    actorsImage = toolkit.getImage(url);
187:                    url = TracesViewer.class.getResource(faces);
188:                    facesImage = toolkit.getImage(url);
189:                    url = TracesViewer.class.getResource(aLogoNist);
190:                    logoNist = toolkit.getImage(url);
191:
192:                } catch (Exception e) {
193:                    backgroundImage = null;
194:                    actorsImage = null;
195:                    facesImage = null;
196:                    logoNist = null;
197:                    System.out.println("Images are not loaded.");
198:
199:                    e.printStackTrace();
200:                }
201:
202:                rmiHost = aRmiHost;
203:                rmiPort = aRmiPort;
204:                stackId = aStackId;
205:
206:                listenerTracesViewer = new ListenerTracesViewer(this );
207:
208:                // The order is important!!!!!
209:                // Look at the rmi registry for new traces 
210:                tracesSessions = refreshTracesSessions();
211:                initComponents();
212:                // Initialisation of the tracesSessionsList:
213:                tracesSessionsList.setTracesSessions(tracesSessions);
214:                // Initialisation of the Thread for the animations:
215:                animationThread = new TracesAnimationThread(tracesCanvas);
216:
217:                // width, height
218:                this .setSize(670, 620);
219:                this .setLocation(0, 0);
220:                this .show();
221:            }
222:
223:            /*********** constructor for the proxy ****************************************/
224:
225:            // Constructor for the Application only!!!!!
226:            public TracesViewer(String logFile, Hashtable traces,
227:                    String logName, String logDescription, String auxInfo,
228:                    String title, String back, String faces, String actors,
229:                    String aLogoNist) {
230:                super (title);
231:                this .logFile = logFile;
232:                //System.out.println("back:"+back);
233:                try {
234:
235:                    Toolkit toolkit = Toolkit.getDefaultToolkit();
236:                    //System.out.println("back:"+back);
237:                    // this.backgroundImage=toolkit.getImage(back);
238:                    URL url = TracesViewer.class.getResource(back);
239:                    //  System.out.println("url:"+url.toString());
240:                    backgroundImage = toolkit.getImage(url);
241:                    url = TracesViewer.class.getResource(actors);
242:                    actorsImage = toolkit.getImage(url);
243:                    url = TracesViewer.class.getResource(faces);
244:                    facesImage = toolkit.getImage(url);
245:                    url = TracesViewer.class.getResource(aLogoNist);
246:                    logoNist = toolkit.getImage(url);
247:
248:                    /*
249:                       Toolkit toolkit=Toolkit.getDefaultToolkit();
250:                       backgroundImage=toolkit.getImage(back);
251:                       actorsImage=toolkit.getImage(actors);
252:                       facesImage=toolkit.getImage(faces);
253:                       this.logoNist=logoNist;
254:                     */
255:                } catch (Exception e) {
256:                    backgroundImage = null;
257:                    actorsImage = null;
258:                    facesImage = null;
259:                    logoNist = null;
260:                    System.out.println("Images are not loaded.");
261:
262:                    e.printStackTrace();
263:                }
264:
265:                TracesSessions tss = new TracesSessions();
266:                tss.setName(logName);
267:                if (traces != null) {
268:                    Enumeration elements = traces.elements();
269:                    while (elements.hasMoreElements()) {
270:                        MessageLogList mll = (MessageLogList) elements
271:                                .nextElement();
272:                        TracesSession ts = new TracesSession(mll);
273:                        ts.setName(logName);
274:                        ts.setInfo(auxInfo);
275:                        ts.setLogDescription(logDescription);
276:                        tss.add(ts);
277:                    }
278:                }
279:                if (tss.isEmpty()) {
280:                    TracesSession ts = new TracesSession();
281:                    ts.setName("No available session, refresh");
282:                    tss.add(ts);
283:                }
284:
285:                listenerTracesViewer = new ListenerTracesViewer(this );
286:
287:                this .tracesSessions = tss;
288:                initComponents();
289:                // Initialisation of the tracesSessionsList:
290:                tracesSessionsList.setTracesSessions(this .tracesSessions);
291:                // Initialisation of the Thread for the animations:
292:                animationThread = new TracesAnimationThread(tracesCanvas);
293:
294:                // width, height
295:                this .setSize(670, 620);
296:                this .setLocation(0, 0);
297:            }
298:
299:            /** Use this constructor when retrieving a trace from  a log file.
300:             */
301:            public TracesViewer(String title, String logFile, String back,
302:                    String faces, String actors, String logoNist) {
303:                super (title);
304:                this .logFile = logFile;
305:                listenerTracesViewer = new ListenerTracesViewer(this );
306:
307:                // The order is important!!!!!
308:                // Look at the rmi registry for new traces 
309:                tracesSessions = refreshTracesSessions();
310:                initComponents();
311:                // Initialisation of the tracesSessionsList:
312:                tracesSessionsList.setTracesSessions(tracesSessions);
313:                // Initialisation of the Thread for the animations:
314:                animationThread = new TracesAnimationThread(tracesCanvas);
315:
316:                // width, height
317:                this .setSize(670, 620);
318:                this .setLocation(0, 0);
319:                this .show();
320:
321:            }
322:
323:            /*********************************************************************************/
324:
325:            // Constructor for the daemon only!!!!!
326:            public TracesViewer(String port, String logFile, Hashtable traces,
327:                    String logName, String logDescription, String auxInfo,
328:                    String title, String back, String faces, String actors,
329:                    String aLogoNist) {
330:                super (title);
331:                this .logFile = logFile;
332:
333:                try {
334:                    Toolkit toolkit = Toolkit.getDefaultToolkit();
335:                    URL url = TracesViewer.class.getResource(back);
336:                    backgroundImage = toolkit.getImage(url);
337:                    url = TracesViewer.class.getResource(actors);
338:                    actorsImage = toolkit.getImage(url);
339:                    url = TracesViewer.class.getResource(faces);
340:                    facesImage = toolkit.getImage(url);
341:                    url = TracesViewer.class.getResource(aLogoNist);
342:                    logoNist = toolkit.getImage(url);
343:                } catch (Exception e) {
344:                    backgroundImage = null;
345:                    actorsImage = null;
346:                    facesImage = null;
347:                    logoNist = null;
348:                    System.out.println("Images are not loaded.");
349:
350:                    e.printStackTrace();
351:                }
352:
353:                TracesSessions tss = new TracesSessions();
354:                tss.setName(logName);
355:                if (traces != null) {
356:                    Enumeration elements = traces.elements();
357:                    while (elements.hasMoreElements()) {
358:                        MessageLogList mll = (MessageLogList) elements
359:                                .nextElement();
360:                        TracesSession ts = new TracesSession(mll);
361:                        ts.setName(logName);
362:                        ts.setInfo(auxInfo);
363:                        ts.setLogDescription(logDescription);
364:                        tss.add(ts);
365:                    }
366:                }
367:                if (tss.isEmpty()) {
368:                    TracesSession ts = new TracesSession();
369:                    ts.setName("No available session, refresh");
370:                    tss.add(ts);
371:                }
372:
373:                listenerTracesViewer = new ListenerTracesViewer(this );
374:
375:                this .tracesSessions = tss;
376:                initComponents();
377:                // Initialisation of the tracesSessionsList:
378:                tracesSessionsList.setTracesSessions(this .tracesSessions);
379:                // Initialisation of the Thread for the animations:
380:                animationThread = new TracesAnimationThread(tracesCanvas);
381:
382:                // width, height
383:                this .setSize(670, 620);
384:                this .setLocation(0, 0);
385:
386:                try {
387:                    // Try to open a connection:
388:                    TracesSocket ts = new TracesSocket(logFile, port);
389:                    ts.start();
390:                } catch (Exception e) {
391:                    e.printStackTrace();
392:                }
393:                this .show();
394:            }
395:
396:            /*****************************************************************************/
397:
398:            public TracesSessions refreshTracesSessions() {
399:                TracesSessions retval = null;
400:                TracesSessions tss = new TracesSessions();
401:                String trace = null;
402:                try {
403:                    if (this .logFile != null) {
404:                        File file = new File(this .logFile);
405:                        char[] cbuf = new char[(int) file.length()];
406:                        FileReader fr = new FileReader(file);
407:                        fr.read(cbuf);
408:                        fr.close();
409:                        trace = new String(cbuf);
410:
411:                    }
412:                    //System.out.println("**** TRACE ******:\n"+trace+"\n");
413:                    if (trace != null && !trace.equals("")) {
414:                        LogFileParser parser = new LogFileParser();
415:                        Hashtable traces = parser.parseLogsFromString(trace);
416:                        Enumeration elements = traces.elements();
417:                        while (elements.hasMoreElements()) {
418:                            MessageLogList mll = (MessageLogList) elements
419:                                    .nextElement();
420:                            TracesSession ts = new TracesSession(mll);
421:                            ts.setName(parser.logName);
422:                            ts.setLogDescription(parser.logDescription);
423:                            ts.setInfo(parser.auxInfo);
424:                            tss.add(ts);
425:                        }
426:                        tss.setName(parser.logName);
427:
428:                        retval = tss;
429:                    } else {
430:                        TracesSession ts = new TracesSession();
431:                        ts.setName("No available session, refresh");
432:                        tss.add(ts);
433:                        retval = tss;
434:                    }
435:                } catch (Exception e) {
436:                    System.out.println("*** Exception retrieving trace ***");
437:                    e.printStackTrace();
438:                    TracesSession ts = new TracesSession();
439:                    ts.setName("No available session, refresh");
440:                    tss.add(ts);
441:                    retval = tss;
442:                }
443:
444:                tracesSessions = retval;
445:                return tracesSessions;
446:            }
447:
448:            public TracesSessions getTracesSessions() {
449:                return tracesSessions;
450:            }
451:
452:            /**************************************************************************/
453:
454:            private void initComponents() {
455:
456:                /********************** The main container ****************************/
457:
458:                Container container = this .getContentPane();
459:                container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
460:                //container.setLayout( new PercentLayout() );
461:                container.setBackground(Color.black);
462:
463:                addWindowListener(new WindowAdapter() {
464:                    public void windowClosing(WindowEvent e) {
465:                        System.out.println("Trace viewer closed!");
466:                        // System.exit(0);
467:                    }
468:                });
469:
470:                /********************** Menu bar **************************************/
471:                menuBar = new JMenuBar();
472:                setJMenuBar(menuBar);
473:
474:                //Build a second menu in the menu bar.
475:                optionsMenu = new JMenu("      Options      ");
476:                optionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
477:                optionsMenu.setToolTipText("Some options related to the GUI");
478:                animationMenuItem = new JMenuItem("    Animation    ");
479:                animationMenuItem
480:                        .setToolTipText("Animation of the entire selected session");
481:                animationMenuItem.addActionListener(new ActionListener() {
482:                    public void actionPerformed(ActionEvent evt) {
483:                        listenerTracesViewer.animationActionPerformed(evt);
484:                    }
485:                });
486:                optionsMenu.add(animationMenuItem);
487:                menuBar.add(optionsMenu);
488:
489:                // create a menu and add it to the menubar
490:                displayAllSessionsMenu = new JMenu("    Display Sessions    ");
491:                displayAllSessionsMenu.setBorder(new BevelBorder(
492:                        BevelBorder.RAISED));
493:                displayAllSessionsMenu
494:                        .setToolTipText("Display all the retrieved sessions in a separate windows");
495:                displayAllSessionsMenu.addMouseListener(new MouseAdapter() {
496:                    public void mouseClicked(MouseEvent evt) {
497:                        listenerTracesViewer.displayAllSessionsMouseEvent(evt);
498:                    }
499:                });
500:                // add the Controls menu to the menu bar
501:                menuBar.add(displayAllSessionsMenu);
502:
503:                // create a menu and add it to the menubar
504:                refreshMenu = new JMenu("   Refresh   ");
505:                refreshMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
506:                refreshMenu.setBackground(new Color(51, 153, 255));
507:                refreshMenu.setToolTipText("Get the new traces");
508:                refreshMenu.addMouseListener(new MouseAdapter() {
509:                    public void mouseClicked(MouseEvent evt) {
510:                        listenerTracesViewer.refreshActionPerformed(evt);
511:                    }
512:                });
513:                // add the Controls menu to the menu bar
514:                menuBar.add(refreshMenu);
515:
516:                //...create and add some menus...
517:                menuBar.add(Box.createHorizontalGlue());
518:
519:                helpMenu = new JMenu("    Help    ");
520:                helpMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
521:                helpMenu.setToolTipText("Some useful notes about this tool");
522:                helpMenu.addMouseListener(new MouseAdapter() {
523:                    public void mouseClicked(MouseEvent evt) {
524:                        listenerTracesViewer.helpMenuMouseEvent(evt);
525:                    }
526:                });
527:                menuBar.add(helpMenu);
528:
529:                aboutMenu = new JMenu("    About    ");
530:                aboutMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
531:                aboutMenu.setToolTipText("Some advertises about the creators!");
532:                aboutMenu.addMouseListener(new MouseAdapter() {
533:                    public void mouseClicked(MouseEvent evt) {
534:                        listenerTracesViewer.aboutMenuMouseEvent(evt);
535:                    }
536:                });
537:                menuBar.add(aboutMenu);
538:
539:                quitMenu = new JMenu("    Quit    ");
540:                quitMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
541:                quitMenu.setToolTipText("Quit the traces viewer");
542:                quitMenu.addMouseListener(new MouseAdapter() {
543:                    public void mouseClicked(MouseEvent evt) {
544:                        close();
545:                    }
546:                });
547:                menuBar.add(quitMenu);
548:
549:                /********************    FIRST PANEL         ********************************/
550:
551:                firstPanel = new JPanel();
552:                // If put to False: we see the container's background
553:                firstPanel.setOpaque(false);
554:                firstPanel.setLayout(new PercentLayout());
555:                //firstPanel.setLayout(  new BorderLayout() );
556:                container.add(firstPanel);
557:
558:                // Sub right panel:
559:                // topx %, topy %, width %, height % 73, 100-> 65, 95
560:                PercentLayoutConstraint firstPanelConstraint = new PercentLayoutConstraint(
561:                        30, 0, 70, 100);
562:                tracesSessionsList = new TracesSessionsList();
563:                tracesSessionsList.addItemListener(new ItemListener() {
564:                    public void itemStateChanged(ItemEvent e) {
565:                        listenerTracesViewer.tracesSessionsListStateChanged(e);
566:                    }
567:                });
568:                tracesSessionsList.setForeground(Color.black);
569:                tracesSessionsList.setFont(new Font("Dialog", 1, 14));
570:
571:                ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
572:                TracesSession tracesSession = (TracesSession) tracesSessions
573:                        .firstElement();
574:                String name = tracesSession.getName();
575:                String logDescription = tracesSession.getLogDescription();
576:                String callId = tracesSessionsList.getCallId(name);
577:                String origin = tracesSessionsList.getOrigin(name);
578:
579:                // Warning: to put before for the canvas!!!!
580:                TextArea messageContentTextArea = new TextArea();
581:                messageContentButton = new JButton("SIP Message:");
582:                if (name.equals("No available session, refresh")) {
583:                    tracesCanvas = new TracesCanvas(tracesSession,
584:                            messageContentTextArea, "unknown", this );
585:                } else if (logDescription == null
586:                        || logDescription.trim().equals("")) {
587:                    tracesCanvas = new TracesCanvas(tracesSession,
588:                            messageContentTextArea, origin, this );
589:                } else {
590:                    //  System.out.println("logDesc44:"+logDescription);   
591:                    tracesCanvas = new TracesCanvas(tracesSession,
592:                            messageContentTextArea, logDescription, this );
593:                }
594:
595:                tracesSessionsList.setTracesCanvas(tracesCanvas);
596:                // The ScrollPane for the Canvas
597:                scroll.add(tracesCanvas);
598:                firstPanel.add(scroll, firstPanelConstraint);
599:
600:                /***************************    SECOND PANEL         ********************************/
601:
602:                //  left panel: 
603:                secondPanel = new JPanel();
604:                secondPanel.setBackground(Color.black);
605:                // rows, columns
606:                //  secondPanel.setLayout(new GridLayout(3,1,0,0) );
607:                secondPanel.setLayout(new BorderLayout());
608:                // topx %, topy %, width %, height %
609:                PercentLayoutConstraint secondPanelConstraint = new PercentLayoutConstraint(
610:                        0, 0, 30, 100);
611:                firstPanel.add(secondPanel, secondPanelConstraint);
612:
613:                /****************************** FIRST SUB PANEL **********************************/
614:
615:                // Sub left panel:
616:                firstSubPanel = new JPanel();
617:                firstSubPanel.setBackground(Color.black);
618:                // Top, left, bottom, right
619:                firstSubPanel.setBorder(BorderFactory.createEmptyBorder(5, 5,
620:                        7, 5));
621:
622:                if (!standaloneViewer) {
623:                    // rows, columns, gap, gap
624:                    firstSubPanel.setLayout(new GridLayout(2, 1, 3, 6));
625:                    secondPanel.add(firstSubPanel, BorderLayout.NORTH);
626:
627:                    JPanel panelGrid = new JPanel();
628:                    panelGrid.setBorder(BorderFactory.createEmptyBorder(5, 5,
629:                            5, 5));
630:                    panelGrid.setLayout(new GridLayout(2, 1, 0, 0));
631:
632:                    JPanel panelBox = new JPanel();
633:                    panelBox.setBorder(BorderFactory.createEmptyBorder(3, 3, 3,
634:                            3));
635:                    panelBox.setLayout(new BorderLayout());
636:
637:                    JLabel scriptLabel = new JLabel("Display the event script:");
638:                    scriptLabel
639:                            .setToolTipText("Display the content of the selected script");
640:
641:                    scriptLabel.setHorizontalAlignment(AbstractButton.CENTER);
642:                    scriptLabel.setForeground(Color.black);
643:                    scriptLabel.setFont(new Font("Dialog", 1, 14));
644:                    // If put to true: we see the label's background
645:                    scriptLabel.setOpaque(true);
646:                    panelGrid.add(scriptLabel);
647:
648:                    choice = new Choice();
649:                    panelBox.add(choice, BorderLayout.CENTER);
650:
651:                    scriptButton = new JButton("Open");
652:                    scriptButton
653:                            .setToolTipText("Get the script controlling the current session");
654:                    scriptButton.setFont(new Font("Dialog", 1, 14));
655:                    scriptButton.setFocusPainted(false);
656:                    scriptButton.setBackground(new Color(186, 175, 175));
657:                    scriptButton.setBorder(new BevelBorder(BevelBorder.RAISED));
658:                    scriptButton.setVerticalAlignment(AbstractButton.CENTER);
659:                    scriptButton.setHorizontalAlignment(AbstractButton.CENTER);
660:                    panelBox.add(scriptButton, BorderLayout.EAST);
661:                    scriptButton.addActionListener(new ActionListener() {
662:                        public void actionPerformed(ActionEvent evt) {
663:                            listenerTracesViewer.scriptActionPerformed(evt);
664:                        }
665:                    });
666:                    panelGrid.add(panelBox);
667:                    firstSubPanel.add(panelGrid);
668:                    //initComboBox();
669:
670:                    /*
671:                    refreshButton=new JButton("Refresh");
672:                    refreshButton.setToolTipText("Refresh all the sessions");
673:                    refreshButton.setFont(new Font ("Dialog", 1, 14));
674:                    refreshButton.setFocusPainted(false);
675:                    //refreshButton.setBackground(new Color(186,175,175));
676:                    refreshButton.setBackground( new Color(51,153,255));
677:                    refreshButton.setBorder(new BevelBorder(BevelBorder.RAISED));
678:                    refreshButton.setVerticalAlignment(AbstractButton.CENTER);
679:                    refreshButton.setHorizontalAlignment(AbstractButton.CENTER);
680:                    firstSubPanel.add(refreshButton);
681:                    refreshButton.addActionListener(new ActionListener() {
682:                    public void actionPerformed(ActionEvent evt) {
683:                             listenerTracesViewer.refreshActionPerformed(evt);
684:                       }
685:                    }
686:                    );
687:                     */
688:                    ImageIcon icon;
689:                    if (logoNist != null) {
690:                        icon = new ImageIcon(logoNist);
691:
692:                        JLabel label = new JLabel(icon);
693:                        label.setVisible(true);
694:                        label.setToolTipText("The NIST logo!!!");
695:                        //label.setHorizontalAlignment(AbstractButton.CENTER);
696:                        label.setForeground(Color.black);
697:                        //label.setFont(new Font ("Dialog", 1, 14));
698:                        label.setOpaque(false);
699:                        firstSubPanel.add(label);
700:                    }
701:                } else {
702:                    // rows, columns, gap, gap
703:                    firstSubPanel.setLayout(new GridLayout(1, 1, 3, 6));
704:                    secondPanel.add(firstSubPanel, BorderLayout.NORTH);
705:
706:                    ImageIcon icon;
707:                    if (logoNist != null) {
708:                        icon = new ImageIcon(logoNist);
709:                        JLabel label = new JLabel(icon);
710:                        label.setVisible(true);
711:                        label.setToolTipText("The NIST logo!!!");
712:                        label.setHorizontalAlignment(AbstractButton.CENTER);
713:                        label.setForeground(Color.black);
714:                        label.setFont(new Font("Dialog", 1, 14));
715:                        label.setOpaque(false);
716:                        firstSubPanel.add(label);
717:                    }
718:                }
719:
720:                /****************** SECOND SUB PANEL ****************************************/
721:                JPanel panel = new JPanel();
722:                panel.setLayout(new GridLayout(2, 1, 0, 0));
723:                secondPanel.add(panel, BorderLayout.CENTER);
724:                secondSubPanel = new JPanel();
725:                secondSubPanel.setBackground(Color.black);
726:                secondSubPanel.setLayout(new BorderLayout());
727:                //secondPanel.add(secondSubPanel);
728:                panel.add(secondSubPanel);
729:
730:                sessionsLabel = new JLabel("Sessions available:");
731:                sessionsLabel
732:                        .setToolTipText("All the sessions currently available");
733:                // Alignment of the text
734:                sessionsLabel.setHorizontalAlignment(AbstractButton.CENTER);
735:                // Color of the text
736:                sessionsLabel.setForeground(Color.black);
737:                // Size of the text
738:                sessionsLabel.setFont(new Font("Dialog", 1, 14));
739:                // If put to true: we see the label's background
740:                sessionsLabel.setOpaque(true);
741:                sessionsLabel.setBackground(Color.lightGray);
742:                sessionsLabel.setBorder(BorderFactory
743:                        .createLineBorder(Color.darkGray));
744:                secondSubPanel.add(sessionsLabel, BorderLayout.NORTH);
745:
746:                ScrollPane scrollList = new ScrollPane(
747:                        ScrollPane.SCROLLBARS_ALWAYS);
748:                scrollList.add(tracesSessionsList);
749:                //secondSubPanel.add(scrollList,BorderLayout.CENTER);
750:                secondSubPanel.add(tracesSessionsList, BorderLayout.CENTER);
751:
752:                /******************** THIRD SUB PANEL ****************************************/
753:
754:                thirdSubPanel = new JPanel();
755:                thirdSubPanel.setBackground(Color.black);
756:                thirdSubPanel.setLayout(new BorderLayout());
757:                //secondPanel.add(thirdSubPanel);
758:                panel.add(thirdSubPanel);
759:
760:                messageContentButton
761:                        .setToolTipText("Display all the content of the current SIP message");
762:                // Alignment of the text
763:                messageContentButton
764:                        .setHorizontalAlignment(AbstractButton.CENTER);
765:                // Color of the text
766:                messageContentButton.setForeground(Color.black);
767:                // Size of the text
768:                messageContentButton.setFont(new Font("Dialog", 1, 14));
769:                // If put to true: we see the label's background
770:                messageContentButton.setOpaque(true);
771:                messageContentButton.setBackground(Color.lightGray);
772:                messageContentButton.setBorder(BorderFactory
773:                        .createLineBorder(Color.darkGray));
774:                messageContentButton.addActionListener(new ActionListener() {
775:                    public void actionPerformed(ActionEvent evt) {
776:                        listenerTracesViewer.debugActionPerformed(evt);
777:                    }
778:                });
779:                messageContentTextArea.setBackground(Color.white);
780:                messageContentTextArea.setEditable(false);
781:                messageContentTextArea.setFont(new Font("Dialog", 1, 12));
782:                messageContentTextArea.setForeground(Color.black);
783:                thirdSubPanel.add(messageContentButton, BorderLayout.NORTH);
784:                thirdSubPanel.add(messageContentTextArea, BorderLayout.CENTER);
785:
786:                validateTree();
787:            }
788:
789:            public void close() {
790:                System.out.println("Trace viewer closed!");
791:                this .dispose();
792:                //  System.exit(0);
793:
794:            }
795:
796:            public static void usage() {
797:                System.out.println("***************************************");
798:                System.out.println("*** missing or incorrect parameters ***");
799:                System.out.println("*************************************\n");
800:                System.out.println("When you create your SIP Stack specify");
801:                System.out
802:                        .println("gov.nist.javax.sip.stack.SERVER_LOG = fileName\n");
803:                System.out
804:                        .println("gov.nist.javax.sip.stack.DEBUG_LOG = debugFileName\n");
805:                System.out.println("*************************************");
806:                System.out
807:                        .println("Use this tool to view the signaling trace as a sequence Diagram");
808:                System.out.println("Usage (if classpath correctly set):\n\n");
809:                System.out
810:                        .println("When viewing from a server file:\n"
811:                                + " --> java tools.tracesviewer.tracesViewer -debug_file debugFileName\n");
812:                System.out
813:                        .println("When viewing from a debug file:\n"
814:                                + " --> java tools.tracesviewer.tracesViewer -server_file fileName");
815:                System.out.println("*************************************\n");
816:                System.exit(0);
817:            }
818:
819:            // This method is only used by the GUI proxy!!!!!
820:            // We do not need to use the prompt!!!
821:            public static void main(String args[]) {
822:                try {
823:                    if (args.length == 0) {
824:                        System.out.println("Using default parameters!");
825:                        System.out
826:                                .println("Everything is Ok ... Launching the Traces viewer");
827:                        TracesViewer tracesViewer = new TracesViewer(
828:                                "Traces viewer", "127.0.0.1", "1099",
829:                                "127.0.0.1:5060");
830:
831:                    } else if (args[0].equals("-debug_file")) {
832:                        String fileName = args[1];
833:                        LogFileParser parser = new LogFileParser();
834:                        Hashtable traces = parser
835:                                .parseLogsFromDebugFile(fileName);
836:
837:                        new TracesViewer(fileName, traces, parser.logName,
838:                                parser.logDescription, parser.auxInfo,
839:                                "traces viewer", "images/back.gif",
840:                                "images/faces.jpg", "images/comp.gif",
841:                                "images/nistBanner.jpg").show();
842:
843:                        return;
844:
845:                    } else if (args[0].equals("-server_file")) {
846:                        String fileName = args[1];
847:                        LogFileParser parser = new LogFileParser();
848:                        Hashtable traces = parser.parseLogsFromFile(fileName);
849:
850:                        new TracesViewer(fileName, traces, parser.logName,
851:                                parser.logDescription, parser.auxInfo,
852:                                "traces viewer", "images/back.gif",
853:                                "images/faces.jpg", "images/comp.gif",
854:                                "images/nistBanner.jpg").show();
855:
856:                        return;
857:
858:                    } else if (args[0].equals("-daemon")) {
859:
860:                        int length = args.length;
861:
862:                        String port = "10000";
863:                        String fileName = "NOT SET";
864:                        for (int k = 0; k < length; k++) {
865:
866:                            if (args[k].equals("-server_file")) {
867:                                fileName = args[k + 1];
868:                                k++;
869:                            } else if (args[k].equals("-port")) {
870:                                port = args[k + 1];
871:                                k++;
872:                            }
873:                        }
874:                        LogFileParser parser = new LogFileParser();
875:                        Hashtable traces = parser.parseLogsFromFile(fileName);
876:
877:                        new TracesViewer(port, fileName, traces,
878:                                parser.logName, parser.logDescription,
879:                                parser.auxInfo, "traces viewer daemon",
880:                                "images/back.gif", "images/faces.jpg",
881:                                "images/comp.gif", "images/nistBanner.jpg")
882:                                .show();
883:
884:                        return;
885:
886:                    } else {
887:                        int length = args.length;
888:
889:                        String rmiHost = "127.0.0.1";
890:                        String rmiPort = "1099";
891:                        String stackId = null;
892:                        String back = null;
893:                        String faces = null;
894:                        String actors = null;
895:                        String logoNist = null;
896:                        boolean launcher = false;
897:                        for (int k = 0; k < length; k++) {
898:                            if (args[k].equals("-rmihost")) {
899:                                rmiHost = args[k + 1];
900:                                k++;
901:                            } else if (args[k].equals("-rmiport")) {
902:                                rmiPort = args[k + 1];
903:                                k++;
904:                            } else if (args[k].equals("-stackId")) {
905:                                stackId = args[k + 1];
906:                                k++;
907:                            } else if (args[k].equals("-back")) {
908:                                launcher = true;
909:                                back = args[k + 1];
910:                                k++;
911:                            } else if (args[k].equals("-faces")) {
912:                                faces = args[k + 1];
913:                                k++;
914:                            } else if (args[k].equals("-actors")) {
915:                                actors = args[k + 1];
916:                                k++;
917:                            } else if (args[k].equals("-logoNist")) {
918:                                logoNist = args[k + 1];
919:                                k++;
920:                            } else
921:                                usage();
922:                        }
923:                        TracesViewer tracesViewer;
924:                        if (rmiHost == null) {
925:                            System.out.println("Assuming RMI host = 127.0.0.1");
926:                        }
927:                        if (stackId == null) {
928:                            System.out
929:                                    .println("Stack Id (name) not specified Bailing!"
930:                                            + " Please specify stackId (JAIN stack name) "
931:                                            + " using -stackId flag");
932:                            System.exit(0);
933:                        }
934:
935:                        if (launcher)
936:                            tracesViewer = new TracesViewer("Traces viewer",
937:                                    rmiHost, rmiPort, stackId, back, faces,
938:                                    actors, logoNist);
939:                        else
940:                            tracesViewer = new TracesViewer("Traces viewer",
941:                                    rmiHost, rmiPort, stackId);
942:                        System.out
943:                                .println("Everything is Ok ... Launching the Traces viewer");
944:                    }
945:                } catch (Exception e) {
946:                    System.out.println("Problem starting viewer. I give up :)");
947:                    e.printStackTrace();
948:                }
949:            }
950:
951:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.