001: package tide.execute;
002:
003: import tide.outputtabs.OutputTextPanel;
004: import tide.execute.stacktracebrowser.SwingTreeDebugBrowser;
005: import tide.execute.stacktracebrowser.StacktraceBrowser;
006: import tide.project.*;
007: import tide.editor.*;
008: import tide.sources.*;
009: import snow.utils.storage.*;
010: import snow.texteditor.*;
011: import snow.datatransfer.*;
012:
013: import javax.swing.*;
014: import java.awt.*;
015: import java.awt.event.*;
016: import javax.swing.border.*;
017: import javax.swing.text.*;
018: import java.util.*;
019: import java.io.*;
020: import java.text.*;
021:
022: /** Used for execution outputs and Profiler panel
023: */
024: public class ExecutionOutputPanel extends OutputTextPanel {
025:
026: public ExecutionOutputPanel(boolean editable) {
027: super (editable);
028: }
029:
030: /** here we recognize stacktrace elements...
031: example:
032: >java.lang.Throwable
033: > at a.b$1.run(Hello.java:11)
034: > at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
035: > at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
036: > at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
037: > at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
038: > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
039: > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
040: > at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
041:
042: the first is a type named b at line 11 of Hello.java in package a
043: */
044: @Override
045: public void lineClicked(MouseEvent me) {
046: int pt = pane.viewToModel(me.getPoint());
047: Element elt = doc.getParagraphElement(pt); // the whole clicked line
048: String clickedLine = doc.getTextFromTo(elt.getStartOffset(),
049: elt.getEndOffset());
050:
051: if (clickedLine.indexOf(".java") > 0 // also without lien number
052: || clickedLine.indexOf("(Unknown Source)") > 0) // TODO: may have been renamed by Proguard => (HELLO) !
053: {
054: //MainEditorFrame.debugOut("Clicked1: "+clickedLine);
055: if (OutputPanels
056: .recognizeStackTraceLine_AndSelectInEditorIfFound(clickedLine) != null) {
057: setHighlightedElementOnly(elt);
058: } else {
059: setHighlightedElementOnly(null);
060: }
061: } else if (clickedLine.indexOf("\tat ") >= 0) { // [Jan2007]
062: if (OutputPanels
063: .recognizeSimpleSyntaxLine_AndSelectInEditorIfFound(clickedLine) != null) {
064: setHighlightedElementOnly(elt);
065: } else {
066: setHighlightedElementOnly(null);
067: }
068: } else if (clickedLine.indexOf("contains ") >= 0) // ProGuard
069: { // [June2007]
070: if (OutputPanels
071: .recognizeSimpleSyntaxLine_AndSelectInEditorIfFound(clickedLine) != null) {
072: setHighlightedElementOnly(elt);
073: } else {
074: setHighlightedElementOnly(null);
075: }
076: } else {
077: setHighlightedElementOnly(null);
078: }
079: }
080:
081: /** Installs copy paste ops very useful to paste stacktraces
082: from client exceptions for example...
083: */
084: @Override
085: public void showPopup(MouseEvent me) {
086: JPopupMenu popup = createPopupBase(me);
087:
088: popup.addSeparator();
089: JMenuItem parseTraces = new JMenuItem("Browse stacktraces");
090: popup.add(parseTraces);
091: parseTraces.addActionListener(new ActionListener() {
092: public void actionPerformed(ActionEvent ae) {
093: new StacktraceBrowser(doc);
094: }
095: });
096:
097: popup.addSeparator();
098: JMenuItem parseSwingDebug = new JMenuItem("Parse swing tree");
099: parseSwingDebug
100: .setToolTipText("obtained on application with Ctrl+Shift+F1)");
101: popup.add(parseSwingDebug);
102: parseSwingDebug.addActionListener(new ActionListener() {
103: public void actionPerformed(ActionEvent ae) {
104: new SwingTreeDebugBrowser(doc);
105: }
106: });
107:
108: popup.show(pane, me.getX(), me.getY());
109: }
110:
111: /* test output line recognition
112: public static void main(String[] arguments)
113: {
114: System.out.println("\tat tide.execute.ExecutionOutputPanel(ExecutionOutputPanel.java:12)");
115: System.out.println("\tat tide.execute.ExecutionOutputPanel(ExecutionOutputPanel.java)");
116: //not as output
117: System.out.println("\tat tide.execute.ExecutionOutputPanel.java:9");
118: //not as output
119: System.out.println("\tat tide.execute.ExecutionOutputPanel.java");
120: System.out.println("\tat java.lang.String(String.java)");
121: }*/
122:
123: }
|