001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.plugins.commonplugin.reporter.actions; 005 006 import graphlab.platform.core.BlackBoard; 007 import graphlab.platform.core.exception.ExceptionOccuredData; 008 import graphlab.plugins.commonplugin.reporter.Browser; 009 import graphlab.plugins.main.core.actions.StatusBarMessage; 010 import graphlab.ui.components.GComponentInterface; 011 012 import javax.swing.*; 013 import javax.swing.border.LineBorder; 014 import java.awt.*; 015 import java.awt.event.ActionEvent; 016 import java.awt.event.ActionListener; 017 import java.net.URL; 018 import java.net.MalformedURLException; 019 020 public class ExceptionReport extends graphlab.platform.core.AbstractAction implements GComponentInterface { 021 String s; 022 023 public ExceptionReport(BlackBoard bb) { 024 super(bb); 025 listen4Event(ExceptionOccuredData.EVENT_KEY); 026 } 027 028 @Override 029 public void performAction(String eventName, Object value) { 030 ExceptionOccuredData exceptionData = blackboard.getData(ExceptionOccuredData.EVENT_KEY); 031 StackTraceElement[] ee = exceptionData.e.getStackTrace(); 032 s = exceptionData.e.toString() + "\n"; 033 for (StackTraceElement _ : ee) { 034 s += "\tat " + _.toString() + "\n"; 035 } 036 //just for debugging reasons 037 System.err.println(s); 038 show.setVisible(true); 039 StatusBarMessage.showQuickMessage(blackboard, "There was an error!"); 040 show.setBackground(Color.red.brighter()); 041 new Timer(5000, new ActionListener() { 042 public void actionPerformed(ActionEvent e) { 043 show.setBackground(Color.white); 044 } 045 }).start(); 046 // try { 047 // b.browse(new URL("http://sourceforge.net/tracker/?func=add&group_id=134117&atid=728827")); 048 // } catch (MalformedURLException e) { 049 // e.printStackTrace(); 050 // } 051 } 052 053 // Browser b=new Browser(); 054 JButton show = new JButton("View Error Details"); 055 056 public Component getComponent(BlackBoard bb) { 057 show.setVisible(false); 058 show.setBorder(new LineBorder(Color.red.darker())); 059 show.setBackground(Color.red.brighter()); 060 show.addActionListener(new ActionListener() { 061 public void actionPerformed(ActionEvent e) { 062 try { 063 Browser.browse(new URL("http://graphlab.sharif.edu/trac/newticket")); 064 } catch (MalformedURLException e1) { 065 e1.printStackTrace(); 066 } 067 } 068 }); 069 return show; 070 } 071 }