1 26 30 package org.omg.lifl.eclipse.plugin.utils; 31 32 import java.util.Vector ; 33 34 import org.eclipse.swt.graphics.Point; 35 import org.eclipse.ui.IWorkbench; 36 import org.eclipse.ui.IWorkbenchPage; 37 import org.eclipse.ui.IWorkbenchWindow; 38 import org.eclipse.ui.PartInitException; 39 import org.eclipse.ui.PlatformUI; 40 import org.omg.lifl.eclipse.plugin.shell.views.OpenCCMConsole; 41 42 46 public class OutputToConsole { 47 private static String err; 48 private static String out; 49 private static OpenCCMConsole console; 50 private static StringBuffer textBuffer = new StringBuffer (); 51 private static Vector errorHighlight = new Vector (); 52 53 public static boolean init() 54 { 55 IWorkbenchWindow window; 56 IWorkbench workbench = PlatformUI.getWorkbench(); 57 window = workbench.getActiveWorkbenchWindow(); 58 if(window == null) 59 return false; 60 IWorkbenchPage page = window.getActivePage(); 61 if(page == null) 62 return false; 63 try 64 { 65 console = (OpenCCMConsole)page.findView(OpenCCMConsole.CONSOLE_ID); 66 if(console == null) 67 { 68 page.showView(OpenCCMConsole.CONSOLE_ID); 69 console = (OpenCCMConsole)page.findView("org.omg.lifl.eclipse.plugin.shell.views.OpenCCMConsole"); 70 } 71 if (console == null) System.out.println("console null"); 72 } 73 catch(PartInitException e) 74 { 75 e.printStackTrace(); 76 } 77 if(err == null) 78 err = ""; 79 if(out == null) 80 out = ""; 81 if(err == null) 82 if(out != null); 83 return true; 84 } 85 86 public static void addError(String errorString) 87 { 88 errorHighlight.addElement(new Point(textBuffer.length(), errorString.length() - 1)); 89 textBuffer.append(errorString); 90 } 91 92 public static void addOutString(String outString) 93 { 94 textBuffer.append(outString); 95 } 96 97 public static void clear() 98 { 99 textBuffer = new StringBuffer (); 100 errorHighlight = new Vector (); 101 start(); 102 } 103 104 public static void start() 105 { 106 console.refresh(textBuffer.toString(), errorHighlight); 107 } 108 109 110 113 public static OpenCCMConsole getConsole() { 114 return console; 115 } 116 117 120 public static void setConsole(OpenCCMConsole console) { 121 OutputToConsole.console = console; 122 } 123 124 } 125 | Popular Tags |