类org.eclipse.ui.console.IOConsoleOutputStream源码实例Demo

下面列出了怎么用org.eclipse.ui.console.IOConsoleOutputStream的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xds-ide   文件: XdsConsole.java
@Override
  public void setEncoding(String enc) {
      if (enc != null) {
          // check if the encoding is supported
          try {
              new String(new byte[] { 'z' }, 0, 1, enc); // LSA80 : �����, �� ������� �����? ���� ����� - �� ������ ��� �� �����
              // � �����-������ EncodingUtils � Core?
          } catch (UnsupportedEncodingException e) {
              enc = null;
          }
      }
      encoding = enc;
      synchronized (rgb2streamMap) {
      	for (IOConsoleOutputStream cs : rgb2streamMap.values()) {
      		cs.setEncoding(enc);
      	} 
}
  }
 
源代码2 项目: xds-ide   文件: XdsConsole.java
@Override
  public OutputStream getConsoleStream(ColorStreamType cs) {
      final RGB rgb = cs.getRgb();
      IOConsoleOutputStream stream;
      synchronized (rgb2streamMap) {
      	stream = rgb2streamMap.get(rgb);
      	if (stream == null) {
      		stream = newOutputStream();
      		stream.setEncoding(encoding);
      		rgb2streamMap.put(rgb, stream);
      	}
}
      final IOConsoleOutputStream streamParam = stream;
      Display.getDefault().syncExec(new Runnable(){
	@Override
	public void run() {
		streamParam.setColor(SharedResourceManager.getColor(rgb));
	}
});
      
return stream;
  }
 
源代码3 项目: xds-ide   文件: XdsConsole.java
private void outItem(ConsoleTextItem it) {
    if (!isLogFiltered || !it.filterIt) {
        IOConsoleOutputStream str = (IOConsoleOutputStream) getConsoleStream(it.cs);
        if (str != null) {
            try {
                int len = it.line.length() + crlf.length();
                if (it.link != null) {
                    alLinkInfo.add(new LinkInfo(it.link, printedSize.get(), printedSize.get() + len));
                }
                printedSize.addAndGet(len); 
                str.write(it.line);
                str.write(crlf);
            } catch (Exception e) {
                LogHelper.logError(e);
            }
        }
    }
}
 
源代码4 项目: APICloud-Studio   文件: ConsoleThemer.java
/**
 * applyTheme
 * 
 * @param name
 * @param stream
 * @param defaultColor
 * @return
 */
private void applyTheme(String name, IOConsoleOutputStream stream, Color defaultColor)
{
	Theme theme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
	Color color = defaultColor;
	int style = SWT.NONE;

	// grab theme values, if they exist
	if (theme.hasEntry(name))
	{
		TextAttribute attr = theme.getTextAttribute(name);

		color = theme.getForeground(name);
		style = attr.getStyle();
	}

	// apply new values
	stream.setColor(color);
	stream.setFontStyle(style);
}
 
源代码5 项目: e4macs   文件: EmacsPlusConsole.java
protected void printMessage(String message, Color c, int style) {

		if (message != null) {
			IOConsoleOutputStream outputStream = getOutputStream();
			outputStream.setActivateOnWrite(true);
			if (c != null) {
				outputStream.setColor(c);
			}
			outputStream.setFontStyle(style);
			try {
				outputStream.write(message);
				outputStream.flush();
				outputStream.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
 
源代码6 项目: Pydev   文件: MessageConsoles.java
public static IOConsoleOutputStream getConsoleOutputStream(String name, String iconPath) {
    synchronized (lock) {
        IOConsoleOutputStream outputStream = consoleOutputs.get(name);
        if (outputStream == null) {
            MessageConsole console = getConsole(name, iconPath);

            HashMap<IOConsoleOutputStream, String> themeConsoleStreamToColor = new HashMap<IOConsoleOutputStream, String>();
            outputStream = console.newOutputStream();
            themeConsoleStreamToColor.put(outputStream, "console.output");
            console.setAttribute("themeConsoleStreamToColor", themeConsoleStreamToColor);
            ConsoleColorCache.getDefault().keepConsoleColorsSynched(console);
            consoles.put(name, console);
            consoleOutputs.put(name, outputStream);
        }
        return outputStream;
    }
}
 
public FileConsoleMonitorThread(String consoleName, File inputFile, IOConsoleOutputStream output) {

		this.inputFile = inputFile;
		this.output = output;

		setPriority(Thread.MIN_PRIORITY + 1);
		setDaemon(true);
		setName(consoleName + " MonitorThread"); //$NON-NLS-1$
	}
 
@SuppressWarnings({ "unchecked", "rawtypes" })
public void init(IPageBookViewPage page, IConsole console)
{
	if (console instanceof TextConsole)
	{
		TextConsole textConsole = (TextConsole) console;
		Object themeConsoleStreamToColor = textConsole.getAttribute(THEME_CONSOLE_STREAM_TO_COLOR_ATTRIBUTE);
		if (themeConsoleStreamToColor instanceof Map<?, ?>)
		{
			Map m = (Map) themeConsoleStreamToColor;
			Set<Map.Entry> entrySet = m.entrySet();
			for (Map.Entry entry : entrySet)
			{
				if (!(entry.getKey() instanceof IOConsoleOutputStream) || !(entry.getValue() instanceof String))
				{
					return; // Cannot handle it.
				}
			}
			this.extension = new ConsoleThemer(textConsole, (Map) themeConsoleStreamToColor);
		}
		if (page instanceof TextConsolePage)
		{
			TextConsolePage tcp = (TextConsolePage) page;
			TextViewerThemer themer = new TextViewerThemer(tcp.getViewer());
			themer.apply();
		}
	}
	this.page = page;
}
 
源代码9 项目: Pydev   文件: ScriptOutput.java
/**
 * Constructor - Uses the properties from the JyScriptingPreferencesPage to know if we should write to
 * the console or not
 * 
 * @param color the color of the output written
 */
public ScriptOutput(ICallback0<IOConsoleOutputStream> outputStream) {
    this(outputStream, JyScriptingPreferencesPage.getShowScriptingOutput());
    IPropertyChangeListener listener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            writeToConsole = JyScriptingPreferencesPage.getShowScriptingOutput();
        }
    };
    JythonPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
}
 
源代码10 项目: Pydev   文件: ScriptOutput.java
/**
 * OutputStream interface
 */
@Override
public void write(int b) throws IOException {
    if (writeToConsole) {
        IOConsoleOutputStream out = getOutputStream();
        out.write(b);
    }
}
 
源代码11 项目: Pydev   文件: JythonPlugin.java
/**
 * Creates a new Python interpreter (with jython) and returns it.
 *
 * Note that if the sys is not shared, clients should be in a Thread for it to be really separate).
 */
public static IPythonInterpreter newPythonInterpreter(boolean redirect, boolean shareSys) {
    setupJython(); //Important: setup the pythonpath for the jython process.

    IPythonInterpreter interpreter;
    if (shareSys) {
        interpreter = new PythonInterpreterWrapper();
    } else {
        interpreter = new PythonInterpreterWrapperNotShared();
    }
    if (redirect) {
        interpreter.setOut(new ScriptOutput(new ICallback0<IOConsoleOutputStream>() {

            @Override
            public IOConsoleOutputStream call() {
                getConsole(); //Just to make sure it's initialized.
                return fOutputStream;
            }
        }));

        interpreter.setErr(new ScriptOutput(new ICallback0<IOConsoleOutputStream>() {

            @Override
            public IOConsoleOutputStream call() {
                getConsole(); //Just to make sure it's initialized.
                return fErrorStream;
            }
        }));
    } else {
        interpreter.setErr(NullOutputStream.singleton);
        interpreter.setOut(NullOutputStream.singleton);
    }
    return interpreter;
}
 
源代码12 项目: Pydev   文件: Py2To3.java
@Override
protected int doActionOnResource(IResource next, IProgressMonitor monitor) {
    this.refresh = new ArrayList<IContainer>();
    AbstractRunner runner = UniversalRunner.getRunner(natureUsed);
    if (next instanceof IContainer) {
        this.refresh.add((IContainer) next);
    } else {
        this.refresh.add(next.getParent());
    }

    String dir = next.getLocation().toOSString();
    File workingDir = new File(dir);
    if (!workingDir.exists()) {
        Log.log("Received file that does not exist for 2to3: " + workingDir);
        return 0;
    }
    if (!workingDir.isDirectory()) {
        workingDir = workingDir.getParentFile();
        if (!workingDir.isDirectory()) {
            Log.log("Unable to find working dir for 2to3. Found invalid: " + workingDir);
            return 0;
        }
    }
    ArrayList<String> parametersWithResource = new ArrayList<String>(parameters);
    parametersWithResource.add(0, dir);
    Tuple<String, String> tup = runner.runCodeAndGetOutput(RUN_2_TO_3_CODE,
            parametersWithResource.toArray(new String[0]), workingDir, monitor);
    IOConsoleOutputStream out = MessageConsoles.getConsoleOutputStream("2To3", UIConstants.PY_INTERPRETER_ICON);
    try {
        out.write(tup.o1);
        out.write("\n");
        out.write(tup.o2);
    } catch (IOException e) {
        Log.log(e);
    }
    return 1;
}
 
源代码13 项目: olca-app   文件: FormulaConsoleAction.java
@Override
protected IStatus run(IProgressMonitor monitor) {
	console.activate();
	IOConsoleOutputStream out = console.newOutputStream();
	IOConsoleOutputStream err = console.newOutputStream();
	Repl repl = new Repl(console.getInputStream(),
			new PrintStream(out), new PrintStream(err));
	repl.start();
	return Status.OK_STATUS;
}
 
源代码14 项目: spotbugs   文件: Reporter.java
public void setReportingStream(IOConsoleOutputStream stream) {
    this.stream = stream;
}
 
源代码15 项目: spotbugs   文件: FindBugs2Eclipse.java
@SuppressWarnings("boxing")
private void reportExtraData(AnalysisData data) {
    SortedBugCollection bugCollection = reporter.getBugCollection();
    if (bugCollection == null) {
        return;
    }
    if (FindBugsConsole.getConsole() == null) {
        return;
    }
    IOConsoleOutputStream out = FindBugsConsole.getConsole().newOutputStream();
    PrintWriter pw = new PrintWriter(out);

    ProjectStats stats = bugCollection.getProjectStats();
    Footprint footprint = new Footprint(stats.getBaseFootprint());
    Profiler profiler = stats.getProfiler();
    Profile profile = profiler.getProfile(ClassDataAnalysisEngine.class);
    long totalClassReadTime = TimeUnit.MILLISECONDS.convert(profile.getTotalTime(), TimeUnit.NANOSECONDS);
    long totalTime = TimeUnit.MILLISECONDS.convert(footprint.getClockTime(), TimeUnit.MILLISECONDS);

    double classReadSpeed = totalClassReadTime > 0 ? data.byteSize * 1000.0 / totalClassReadTime : 0;
    double classCountSpeed = totalTime > 0 ? data.classCount * 1000.0 / totalTime : 0;
    double classPart = totalTime > 0 ? totalClassReadTime * 100.0 / totalTime : 0;
    double appPart = data.byteSize > 0 ? data.byteSizeApp * 100.0 / data.byteSize : 0;
    double bytesPerClass = data.classCount > 0 ? ((double) data.byteSize) / data.classCount : 0;
    long peakMemory = footprint.getPeakMemory() / (1024 * 1024);
    pw.printf("%n");
    pw.printf("Total bugs            : %1$ 20d %n", stats.getTotalBugs());
    pw.printf("Peak memory (MB)      : %1$ 20d %n", peakMemory);
    pw.printf("Total classes         : %1$ 20d %n", data.classCount);
    pw.printf("Total time (msec)     : %1$ 20d %n", totalTime);
    pw.printf("Class read time (msec): %1$ 20d %n", totalClassReadTime);
    pw.printf("Class read time (%%)   : %1$ 20.0f %n", classPart);
    pw.printf("Total bytes read      : %1$ 20d %n", data.byteSize);
    pw.printf("Application bytes     : %1$ 20d %n", data.byteSizeApp);
    pw.printf("Application bytes (%%) : %1$ 20.0f %n", appPart);
    pw.printf("Avg. bytes per class  : %1$ 20.0f %n", bytesPerClass);
    pw.printf("Analysis class/sec    : %1$ 20.0f %n", classCountSpeed);
    pw.printf("Read     bytes/sec    : %1$ 20.0f %n", classReadSpeed);
    pw.printf("            MB/sec    : %1$ 20.1f %n", classReadSpeed / (1024 * 1024));
    pw.flush();

    pw.close();

}
 
源代码16 项目: LogViewer   文件: LogViewer.java
public IOConsoleOutputStream getConsoleStream() {
    if (console == null)
        createConsole();
    return console.getOutStream();
}
 
源代码17 项目: LogViewer   文件: LogViewerConsole.java
public IOConsoleOutputStream getOutStream() {
	if (outStream == null)
		outStream = newOutputStream();
	return outStream;
}
 
源代码18 项目: APICloud-Studio   文件: ConsoleThemer.java
/**
 * applyTheme
 */
private void applyTheme()
{
	IWorkbench workbench = null;

	try
	{
		workbench = PlatformUI.getWorkbench();
	}
	catch (IllegalStateException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}

	if (workbench != null)
	{
		final Display display = workbench.getDisplay();

		display.syncExec(new Runnable()
		{
			@SuppressWarnings("unchecked")
			public void run()
			{
				// set colors
				ThemePlugin plugin = ThemePlugin.getDefault();
				ColorManager colorManager = plugin.getColorManager();
				Theme theme = plugin.getThemeManager().getCurrentTheme();

				// set background color
				// NOTE: we have to force the background color to change; otherwise, even
				// with a forced redraw, the background will not be drawn
				fConsole.setBackground(null);
				fConsole.setBackground(colorManager.getColor(theme.getBackground()));

				// set default stream colors
				// Note that some colors are repeated because they're used in different scenarios.
				HashMap<String, Color> colorNameToDefault = new HashMap<String, Color>();
				Color blue = display.getSystemColor(SWT.COLOR_DARK_BLUE);
				Color green = display.getSystemColor(SWT.COLOR_DARK_GREEN);
				Color yellow = display.getSystemColor(SWT.COLOR_DARK_YELLOW);
				Color red = display.getSystemColor(SWT.COLOR_DARK_RED);

				colorNameToDefault.put(CONSOLE_ERROR, red);

				// Info is the same as input color
				colorNameToDefault.put(CONSOLE_INFO, green);
				colorNameToDefault.put(CONSOLE_INPUT, green);

				// For CONSOLE_OUTPUT stream we should use the foreground color of the theme
				colorNameToDefault.put(CONSOLE_OUTPUT, colorManager.getColor(theme.getForeground()));

				// Prompt is the same as trace color.
				colorNameToDefault.put(CONSOLE_PROMPT, blue);
				colorNameToDefault.put(CONSOLE_TRACE, blue);
				colorNameToDefault.put(CONSOLE_WARNING, yellow);

				Set<Map.Entry> entrySet = fThemeConsoleStreamToColor.entrySet();
				for (Map.Entry entry : entrySet)
				{
					if (entry.getValue() instanceof String && entry.getKey() instanceof IOConsoleOutputStream)
					{
						String colorName = (String) entry.getValue();
						IOConsoleOutputStream stream = (IOConsoleOutputStream) entry.getKey();
						applyTheme(colorName, stream, colorNameToDefault.get(colorName));
					}
				}

				refresh();
			}

		});
	}
}
 
源代码19 项目: tesb-studio-se   文件: RuntimeConsoleUtil.java
public static IOConsoleOutputStream getOutputStream() {
    IOConsoleOutputStream outputStream = findConsole().newOutputStream();
    outputStream.setEncoding(System.getProperty("sun.jnu.encoding", "UTF-8"));
    return outputStream;
}
 
源代码20 项目: e4macs   文件: EmacsPlusConsole.java
private IOConsoleOutputStream getOutputStream() {
	return newOutputStream();			
}
 
源代码21 项目: Pydev   文件: ScriptOutput.java
/**
 * @return the output stream to use
 */
private IOConsoleOutputStream getOutputStream() throws MalformedURLException {
    return out.call();
}
 
源代码22 项目: goclipse   文件: ToolsConsole.java
public IOConsoleOutputStreamExt(IOConsoleOutputStream console) {
	this.console = assertNotNull(console);
}
 
源代码23 项目: goclipse   文件: ToolsConsole.java
public IOConsoleOutputStream console() {
	return console;
}
 
源代码24 项目: Pydev   文件: ScriptOutput.java
/**
 * Constructor - the user is able to define whether he wants to write to the console or not.
 * 
 * @param color the color of the output written
 */
public ScriptOutput(ICallback0<IOConsoleOutputStream> outputStream, boolean writeToConsole) {
    this.writeToConsole = writeToConsole;
    out = outputStream;
}
 
 类所在包
 类方法
 同包方法