⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 builderconsole.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2007 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.ui.console;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.console.ConsoleColorProvider;
import org.eclipse.debug.ui.console.IConsoleColorProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleOutputStream;

import eclipseme.core.console.BuildConsoleProxy;
import eclipseme.core.console.IBuildConsoleProxy;

/**
 * A console that holds the information from the execution of the 
 * EclipseME builders.
 * <p />
 * Copyright (c) 2003-2007 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision$
 * <br>
 * $Date$
 * <br>
 * @author Craig Setera
 */
public class BuilderConsole extends IOConsole implements IBuildConsoleProxy {
    private static final String CONSOLE_TYPE = "EclipseMEBuildConsole";
    
    private Map writers;
    private Map colors;
    private IConsoleColorProvider colorProvider;
    
	public BuilderConsole() 
	{
		super(
			"EclipseME Build Console", 
			CONSOLE_TYPE, 
			null, 
			true);
		
		colorProvider = new ConsoleColorProvider();
		BuildConsoleProxy.instance.setProxy(this);
		
		writers = new HashMap(3);
		colors = new HashMap(3);
		colors.put(
			IBuildConsoleProxy.ID_ERROR_STREAM,
			colorProvider.getColor(IDebugUIConstants.ID_STANDARD_ERROR_STREAM));
		colors.put(
			IBuildConsoleProxy.ID_OUTPUT_STREAM,
			colorProvider.getColor(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM));
		colors.put(
			IBuildConsoleProxy.ID_TRACE_STREAM,
			new Color(Display.getDefault(), 0, 128, 128));
	}

	/**
	 * @see eclipseme.core.console.IBuildConsoleProxy#getConsoleWriter(java.lang.String)
	 */
	public PrintWriter getConsoleWriter(String id) {
		PrintWriter writer = (PrintWriter) writers.get(id);
		if (writer == null) {
			final Color color = getColor(id);
			final IOConsoleOutputStream stream = newOutputStream();
			
			writer = new PrintWriter(stream);
			writers.put(id, writer);			
			
			if (color != null) {
				Display.getDefault().asyncExec(new Runnable() {
					public void run() {
						stream.setColor(color);
					}
				});
			}
		}
		
		return writer;
	}

	/**
	 * Return the color to be used for the specified console writer.
	 * 
	 * @param id
	 * @return
	 */
	private Color getColor(String id) {
		return (Color) colors.get(id);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -