Changeset 845 for trunk/quest-ui-swt/src/main/java/de/ugoe/cs
- Timestamp:
- 09/21/12 11:05:24 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-ui-swt/src/main/java/de/ugoe/cs/quest/ui/swt/SWTConsole.java
r828 r845 1 1 package de.ugoe.cs.quest.ui.swt; 2 2 3 import java.io.ByteArrayOutputStream; 4 import java.io.PrintStream; 5 import java.io.UnsupportedEncodingException; 3 6 import java.util.logging.Level; 4 7 … … 6 9 import org.eclipse.swt.custom.StyleRange; 7 10 import org.eclipse.swt.custom.StyledText; 11 import org.eclipse.swt.widgets.MessageBox; 8 12 9 13 import de.ugoe.cs.util.StringTools; … … 11 15 import de.ugoe.cs.util.console.listener.ICommandListener; 12 16 import de.ugoe.cs.util.console.listener.IErrorListener; 17 import de.ugoe.cs.util.console.listener.IExceptionListener; 13 18 import de.ugoe.cs.util.console.listener.IOutputListener; 14 19 import de.ugoe.cs.util.console.listener.ITraceListener; 15 20 16 21 public class SWTConsole implements IOutputListener, IErrorListener, ITraceListener, 17 ICommandListener 22 ICommandListener, IExceptionListener 18 23 { 19 24 … … 27 32 Console.getInstance().registerTraceListener(this); 28 33 Console.getInstance().registerCommandListener(this); 34 Console.getInstance().registerExceptionListener(this); 29 35 this.output = styledText; 30 36 this.traceLevel = traceLevel; … … 65 71 output.setStyleRange(styleRange); 66 72 } 73 74 @Override 75 public void logException(Exception e) { 76 MessageBox messageBox = new MessageBox(output.getShell(), SWT.ERROR); 77 messageBox.setText("Error"); 78 messageBox.setMessage(e.getMessage()); 79 messageBox.open(); 80 81 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 82 PrintStream ps = new PrintStream(baos); 83 e.printStackTrace(ps); 84 String stackTrace = null; 85 try { 86 stackTrace = baos.toString("UTF-8"); 87 } 88 catch (UnsupportedEncodingException e1) { 89 } 90 if( stackTrace!=null ) { 91 appendColored(stackTrace, SWT.COLOR_RED); 92 } else { 93 appendColored(e.getMessage(), SWT.COLOR_RED); 94 } 95 96 } 67 97 }
Note: See TracChangeset
for help on using the changeset viewer.