org.eclipse.ui.console.TextConsolePage Java Examples
The following examples show how to use
org.eclipse.ui.console.TextConsolePage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceUtils.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
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; }
Example #2
Source File: ConsoleThemePageParticipant.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@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; }
Example #3
Source File: EmacsPlusConsole.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @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; }
Example #4
Source File: ConsoleAutoScrollPageParticipant.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
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); } }
Example #5
Source File: EmacsPlusCmdHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
/** * @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(); } } }