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

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

源代码1 项目: LogViewer   文件: ResourceUtils.java
public static ITextViewer getViewer(IPage page) {
    if(page == null){
        return null;
    }
    if(page instanceof TextConsolePage) {
        return ((TextConsolePage)page).getViewer();
    }
    if(page.getClass().equals(MessagePage.class)){
        // empty page placeholder
        return null;
    }
    try {
        /*
         * org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePage does not
         * extend TextConsolePage, so we get access to the viewer with dirty tricks
         */
        Method method = page.getClass().getDeclaredMethod("getViewer", (Class<?>[])null);
        method.setAccessible(true);
        return (ITextViewer) method.invoke(page, (Object[])null);
    } catch (Exception e) {
        // AnyEditToolsPlugin.logError("Can't get page viewer from the console page", e);
    }
    return null;
}
 
@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;
}
 
源代码3 项目: e4macs   文件: EmacsPlusConsole.java
/**
    * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView)
    */
public IPageBookViewPage createPage(IConsoleView view) {
   	IPageBookViewPage page = super.createPage(view);
       if (page instanceof TextConsolePage) {
       	myPage = (TextConsolePage)page;
       }
       return page;
   }
 
public void init(IPageBookViewPage page, IConsole console)
{
	if (console.getType() != IDebugUIConstants.ID_PROCESS_CONSOLE_TYPE || !(page instanceof TextConsolePage))
	{
		return;
	}
	TextConsolePage consolePage = (TextConsolePage) page;
	TextConsoleViewer textViewer = consolePage.getViewer();
	if (!(textViewer instanceof IOConsoleViewer))
	{
		return;
	}
	final IOConsoleViewer viewer = (IOConsoleViewer) textViewer;
	scrollActionEnabled = viewer.isAutoScroll();
	final IToolBarManager toolBarManager = consolePage.getSite().getActionBars().getToolBarManager();
	IAction slAction = null;
	// Look for the ScrollLockAction
	for (IContributionItem item : toolBarManager.getItems())
	{
		if (item instanceof ActionContributionItem)
		{
			IAction action = ((ActionContributionItem) item).getAction();
			if (action instanceof ScrollLockAction)
			{
				slAction = action;
				break;
			}
		}
	}
	textWidget = viewer.getTextWidget();
	listener = new ConsoleListener(viewer, toolBarManager, slAction);

	// Based on Eclipse Snippet191 - Detects scrolling that were initiated by the user.
	textWidget.addListener(SWT.MouseDown, listener);
	textWidget.addListener(SWT.MouseMove, listener);
	textWidget.addListener(SWT.MouseUp, listener);
	textWidget.addListener(SWT.KeyDown, listener);
	textWidget.addListener(SWT.KeyUp, listener);
	ScrollBar vBar = textWidget.getVerticalBar();
	if (vBar != null)
	{
		vBar.addListener(SWT.Selection, listener);
	}
}
 
源代码5 项目: e4macs   文件: EmacsPlusCmdHandler.java
/**
 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent event) throws ExecutionException {
	ITextEditor editor = getTextEditor(event);
	if (editor == null) { 
		if (isWindowCommand()) {
			Object result = checkExecute(event); 
			if (result == Check.Fail) {
				beep();
				result = null;
			}
			return result; 
		} else if (isConsoleCommand()) {
			// intercept and dispatch execution if console supported and used in a console view
			IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
			if (activePart != null && (activePart instanceof IConsoleView) && (activePart instanceof PageBookView)) {
				IPage textPage = ((PageBookView)activePart).getCurrentPage();
				if (textPage instanceof TextConsolePage) {
					return ((IConsoleDispatch)this).consoleDispatch(((TextConsolePage)textPage).getViewer(),(IConsoleView)activePart,event);
				}				
			}
		}
	}
	try {
		setThisEditor(editor);
		isEditable = getEditable();
		if (editor == null || isBlocked()) {
			beep();
			asyncShowMessage(editor, INEDITABLE_BUFFER, true);
			return null;
		}
		
		// Retrieve the universal-argument parameter value if passed 
		if (extractUniversalCount(event) != 1) {
			// check if we should dispatch a related command based on the universal argument
			String dispatchId = checkDispatchId(event.getCommand().getId());
			if (dispatchId != null) {
				// recurse on new id (inverse or arg value driven)
				return dispatchId(editor, dispatchId, getParams(event.getCommand(), event.getParameters()));
			}
		}
		
		setThisDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput()));

		// Get the current selection
		ISelectionProvider selectionProvider = editor.getSelectionProvider();
		ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
		preTransform(editor, selection);
		return transformWithCount(editor, getThisDocument(), selection, event);
		
	} finally {
		// normal commands clean up here
		if (isTransform()) {
			postExecute();
		}
	}
}
 
 类所在包
 同包方法