001: package tools.tracesviewer;
002:
003: import javax.swing.*;
004: import java.awt.*;
005: import java.awt.event.*;
006:
007: /**
008: *
009: *@version 1.2
010: *
011: *@author Olivier Deruelle <br/>
012: *
013: *
014: *
015: */
016: public class ListenerTracesViewer {
017:
018: public TracesViewer tracesViewer;
019: public TracesSessionsDisplayer tracesSessionsDisplayer;
020:
021: public boolean ANIMATION_STARTED;
022: public AboutFrame aboutFrame;
023: public HelpBox helpBox;
024: public ScriptFrame scriptFrame;
025:
026: /** Creates new ListenerTraceViewer */
027: public ListenerTracesViewer(TracesViewer tracesViewer) {
028: this .tracesViewer = tracesViewer;
029: ANIMATION_STARTED = false;
030: aboutFrame = new AboutFrame();
031: tracesSessionsDisplayer = new TracesSessionsDisplayer();
032: helpBox = new HelpBox();
033: scriptFrame = new ScriptFrame();
034: }
035:
036: public void debugActionPerformed(ActionEvent evt) {
037: TracesMessage debug = tracesViewer.tracesCanvas.debugTracesMessage;
038: //System.out.println("******************BEGIN******************************");
039: //System.out.println(debug.beforeDebug);
040: //System.out.println(debug.afterDebug);
041: //System.out.println("******************END********************************");
042: if (debug == null)
043: return;
044:
045: if (debug.beforeDebug != null && debug.beforeDebug != null
046: && !debug.beforeDebug.trim().equals("")
047: && !debug.afterDebug.trim().equals("")) {
048: DebugWindow debugWindow = new DebugWindow(
049: debug.beforeDebug, debug.afterDebug,
050: debug.debugLine);
051:
052: debugWindow.show();
053: }
054: }
055:
056: public void displayAllSessionsMouseEvent(MouseEvent evt) {
057: tracesSessionsDisplayer.show(tracesViewer.getTracesSessions());
058: }
059:
060: public void helpMenuMouseEvent(MouseEvent evt) {
061: helpBox.show();
062: }
063:
064: public void aboutMenuMouseEvent(MouseEvent evt) {
065: aboutFrame.animationThread.start();
066: aboutFrame.show();
067: }
068:
069: public void animationActionPerformed(ActionEvent evt) {
070: if (tracesViewer.tracesCanvas.arrows.size() == 0) {
071: new AlertFrame("Please hit Refresh, first!",
072: JOptionPane.ERROR_MESSAGE);
073: } else if (ANIMATION_STARTED) {
074:
075: tracesViewer.animationMenuItem
076: .setBackground(Color.lightGray);
077: tracesViewer.animationThread.stop();
078: ANIMATION_STARTED = false;
079: } else {
080:
081: tracesViewer.animationThread.start();
082:
083: tracesViewer.animationMenuItem.setBackground(Color.green);
084: ANIMATION_STARTED = true;
085: }
086: }
087:
088: /*
089: public void refreshActionPerformed(ActionEvent evt){
090: if (ANIMATION_STARTED)
091: new AlertFrame("You must stop the animation before refreshing the traces!",JOptionPane.ERROR_MESSAGE);
092: else {
093: TracesSessions tracesSessions=tracesViewerLauncher.refreshTracesSessions();
094: tracesViewerLauncher.tracesSessionsList.setTracesSessions(tracesSessions);
095: tracesViewerLauncher.tracesSessionsList.updateTracesCanvas();
096: tracesViewerLauncher.initComboBox();
097: if (tracesSessionsDisplayer.isVisible())
098: tracesSessionsDisplayer.show(tracesSessions);
099: }
100:
101: }
102: */
103:
104: public void refreshActionPerformed(MouseEvent evt) {
105: if (ANIMATION_STARTED)
106: new AlertFrame(
107: "You must stop the animation before refreshing the traces!",
108: JOptionPane.ERROR_MESSAGE);
109: else {
110: TracesSessions tracesSessions = tracesViewer
111: .refreshTracesSessions();
112: tracesViewer.tracesSessionsList
113: .setTracesSessions(tracesSessions);
114: tracesViewer.tracesSessionsList.updateTracesCanvas();
115:
116: if (tracesSessionsDisplayer.isVisible())
117: tracesSessionsDisplayer.show(tracesSessions);
118: }
119:
120: }
121:
122: public void scriptActionPerformed(ActionEvent evt) {
123:
124: }
125:
126: public void tracesSessionsListStateChanged(ItemEvent e) {
127: if (ANIMATION_STARTED) {
128: tracesViewer.animationMenuItem
129: .setBackground(Color.lightGray);
130: tracesViewer.animationThread.stop();
131: ANIMATION_STARTED = false;
132: }
133: tracesViewer.tracesSessionsList.updateTracesCanvas(e);
134: }
135:
136: }
|