1 19 20 package org.netbeans.core.output2; 21 22 import java.io.IOException ; 23 import javax.swing.Action ; 24 import org.openide.util.Exceptions; 25 import org.openide.util.NbBundle; 26 import org.openide.windows.IOProvider; 27 import org.openide.windows.InputOutput; 28 import org.openide.windows.OutputWriter; 29 30 34 public final class NbIOProvider extends IOProvider { 35 private static final PairMap namesToIos = new PairMap(); 36 37 private static final String STDOUT = NbBundle.getMessage(NbIOProvider.class, 38 "LBL_STDOUT"); 40 public OutputWriter getStdOut() { 41 if (Controller.LOG) { 42 Controller.log("NbIOProvider.getStdOut"); 43 } 44 InputOutput stdout = getIO (STDOUT, false, null); 45 NbWriter out = ((NbIO)stdout).writer(); 46 47 Controller.ensureViewInDefault ((NbIO) stdout, true); 48 if (out != null && out.isClosed()) { 50 try { 51 out.reset(); 52 out = (NbWriter) stdout.getOut(); 53 } catch (IOException e) { 54 Exceptions.printStackTrace(e); 55 stdout = getIO (STDOUT, true, null); 56 out = (NbWriter) stdout.getOut(); 57 } 58 } else { 59 out = (NbWriter) stdout.getOut(); 60 } 61 return out; 62 } 63 64 65 public InputOutput getIO(String name, boolean newIO) { 66 return getIO (name, newIO, new Action [0]); 67 } 68 69 public InputOutput getIO(String name, Action [] toolbarActions) { 70 return getIO (name, true, toolbarActions); 71 } 72 73 private InputOutput getIO(String name, boolean newIO, Action [] toolbarActions) { 74 if (Controller.LOG) { 75 Controller.log("GETIO: " + name + " new:" + newIO); 76 } 77 NbIO result = namesToIos.get(name); 78 79 if (result == null || newIO) { 80 result = new NbIO(name, toolbarActions); 81 namesToIos.add (name, result); 82 Controller.ensureViewInDefault (result, newIO); 83 } else { 84 } 87 return result; 88 } 89 90 91 static void dispose (NbIO io) { 92 namesToIos.remove (io); 93 } 94 95 100 static void setWeak(boolean value) { 101 namesToIos.setWeak(value); 102 } 103 } 104 105 | Popular Tags |