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

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

源代码1 项目: LogViewer   文件: ResourceUtils.java
public static IConsole getConsole(IWorkbenchPart part) {
      if(!(part instanceof IViewPart)){
          return null;
      }

      IViewPart vp =(IViewPart) part;
      if (vp instanceof PageBookView) {
          IPage page = ((PageBookView) vp).getCurrentPage();
          ITextViewer viewer = getViewer(page);
          if (viewer == null || viewer.getDocument() == null)
          	return null;
      }

      IConsole con = null;
  	try {
  		con = ((IConsoleView)part).getConsole();
  	} catch (Exception e) {

}

return con;
  }
 
源代码2 项目: cppcheclipse   文件: Console.java
public void show() {
	
	Runnable runnable = new Runnable() {
		public void run() {
			// this should only be called from GUI thread
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
			if (window == null) {
				CppcheclipsePlugin.logError("Could not show console because there is no active workbench window");
				return;
			}
			IWorkbenchPage page = window.getActivePage();
			if (page == null) {
				CppcheclipsePlugin.logError("Could not show console because there is no active page");
				return;
			}
			try {
				IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
				view.display(messageConsole);
			} catch (PartInitException e) {
				CppcheclipsePlugin.logError("Could not show console", e);
			}
			
		}
	};
	Display.getDefault().asyncExec(runnable);
}
 
源代码3 项目: e4macs   文件: MarkExchangeHandler.java
/**
 * Support exchange for simple mark on TextConsole
 * 
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, org.eclipse.ui.console.IConsoleView, org.eclipse.core.commands.ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	int mark = viewer.getMark();
	StyledText st = viewer.getTextWidget(); 
	if (mark != -1) {
		try {
			st.setRedraw(false);
			int offset = st.getCaretOffset();
			viewer.setMark(offset);
			st.setCaretOffset(mark);
			int len = offset - mark;
			viewer.setSelectedRange(offset, -len);
		} finally {
			st.setRedraw(true);
		}
	}
	return null;
}
 
源代码4 项目: e4macs   文件: BackwardUpListHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.SexpBaseBackwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) {

	IDocument doc = viewer.getDocument();
	boolean isBackup = getUniversalCount() > 0;  	// normal direction
	ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
	try {
		int offset = doTransform(doc, selection, viewer.getTextWidget().getCaretOffset(),isBackup);
		if (offset == NO_OFFSET) {
			unbalanced(activePart,false);
		} else {
			endTransform(viewer, offset, selection, new TextSelection(null,offset,offset - selection.getOffset()));
		}
	} catch (BadLocationException e) {}
	return null;
}
 
源代码5 项目: e4macs   文件: SexpBaseBackwardHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {

	IDocument document = viewer.getDocument();
	ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection();
	ITextSelection selection = null;
	try {
		selection = getNextSexp(document, currentSelection);
		if (selection == null) {
			selection = currentSelection;
			unbalanced(activePart,true);
			return null;
		} else {
			return endTransform(viewer, selection.getOffset(), currentSelection, selection);
		}
	} catch (BadLocationException e) {
	}
	return null;
}
 
源代码6 项目: e4macs   文件: EmacsMovementHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	
	StyledText st = viewer.getTextWidget(); 
	String id = event.getCommand().getId(); 
	boolean isSelect =  isMarkEnabled(viewer,(ITextSelection)viewer.getSelection());
	int action = getDispatchId(id,isSelect);
	if (action > -1) {
		st.invokeAction(action);
	} else if ((id = getId(isSelect)) != null) {
		// support sexps 
		try {
			EmacsPlusUtils.executeCommand(id, null, activePart);
		} catch (Exception e) {
			e.printStackTrace();
		}			
	}
	return null;
}
 
源代码7 项目: e4macs   文件: SexpBaseForwardHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, org.eclipse.ui.console.IConsoleView, org.eclipse.core.commands.ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {

	IDocument document = viewer.getDocument();
	ITextSelection currentSelection = (ITextSelection)viewer.getSelectionProvider().getSelection();
	ITextSelection selection = new TextSelection(document, viewer.getTextWidget().getCaretOffset(), 0);
	try {
		selection = getNextSexp(document, selection);
		if (selection == null) {
			selection = currentSelection;
			unbalanced(activePart,true);
			return null;
		} else {
			return endTransform(viewer, selection.getOffset() + selection.getLength(), currentSelection, selection);
		}
	} catch (BadLocationException e) {
	}
	return null;
}
 
源代码8 项目: e4macs   文件: ConsoleCmdHandler.java
/**
	 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, IConsoleView, ExecutionEvent)
	 */
	public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
		IDocument doc = viewer.getDocument();
		int action = -1;
		try {
			StyledText st = viewer.getTextWidget();
			action = getDispatchId(getId(event, viewer));
			if (action > -1) {
				// set up for kill ring
				doc.addDocumentListener(KillRing.getInstance());
//  			setUpUndo(viewer);
				st.invokeAction(action);
			}
		} finally {
			// remove kill ring behavior
			if (action > -1) {
				doc.removeDocumentListener(KillRing.getInstance());
			}
			KillRing.getInstance().setKill(null, false);
		}
		return null;
	}
 
源代码9 项目: Pydev   文件: ScriptConsole.java
public static Iterable<IConsoleView> iterConsoles() {
    List<IConsoleView> consoles = new ArrayList<>();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {

            List<IViewPart> consoleParts = getConsoleParts(page, false);
            if (consoleParts.size() == 0) {
                consoleParts = getConsoleParts(page, true);
            }
            for (IViewPart iViewPart : consoleParts) {
                if (iViewPart instanceof IConsoleView) {
                    consoles.add((IConsoleView) iViewPart);
                }
            }
        }
    }
    return consoles;
}
 
源代码10 项目: n4js   文件: EclipseUtils.java
/**
 * Reveal the given console. If necessary, this will open the console view, bring it to the front, and reveal the
 * given console inside the console view.
 */
public static void revealConsole(IConsole console) {
	PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
		@Override
		public void run() {
			final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			try {
				final IConsoleView view = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
				view.display(console);
			} catch (PartInitException e) {
				// ignore
			}
		}
	});
}
 
源代码11 项目: xds-ide   文件: XdsConsolePage.java
public XdsConsolePage(TextConsole console, IConsoleView view) {
    super(console, view);

    fPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            String property = event.getProperty();
            if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) {
                setReadOnly();
            }
        }
    };
    console.addPropertyChangeListener(fPropertyChangeListener);
}
 
源代码12 项目: ice   文件: EclipseStreamingTextWidget.java
/**
 * (non-Javadoc)
 * 
 * @see IStreamingTextWidget#display()
 */
@Override
public void display() {

	// Must sync with the display thread
	Display.getDefault().asyncExec(new Runnable() {
		@Override
		public void run() {
			// Get the currently active page
			IWorkbenchPage page = PlatformUI.getWorkbench()
					.getActiveWorkbenchWindow().getActivePage();
			try {
				// Load the console view
				consoleView = (IConsoleView) page
						.showView(IConsoleConstants.ID_CONSOLE_VIEW);
				// Create the console instance that will be used to display
				// text from this widget.
				console = new MessageConsole("CLI", null);
				// Add the console to the console manager
				ConsolePlugin.getDefault().getConsoleManager()
						.addConsoles(new IConsole[] { console });
				// Show the console in the view
				consoleView.display(console);
				console.activate();
				// Get an output stream for the console
				msgStream = console.newMessageStream();
				msgStream.setActivateOnWrite(true);
				msgStream.println("Streaming output console activated.");
			} catch (PartInitException e) {
				// Complain
				logger.error("EclipseStreamingTextWidget Message: "
						+ "Unable to stream text!");
				logger.error(getClass().getName() + " Exception!", e);
			}

		}
	});

	return;
}
 
源代码13 项目: e4macs   文件: MarkSetHandler.java
/**
 * Support simple mark on TextConsole
 * 
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	int offset = viewer.getTextWidget().getCaretOffset();
	viewer.setSelectedRange(offset, 0);
	viewer.setMark(offset);
	return null;
}
 
源代码14 项目: e4macs   文件: ConsoleCopyCutHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
@Override
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	Object result = null;
	IDocument doc = viewer.getDocument();
	try {
		IWorkbenchPartSite site = activePart.getSite();
		if (site != null) {
			IHandlerService service = (IHandlerService) site.getService(IHandlerService.class);
			if (doc != null && service != null) {
				doc.addDocumentListener(KillRing.getInstance());
				String cmdId = getId(event, viewer);
				if (cmdId != null) {
					result = service.executeCommand(cmdId, null);
				}
			}
		}
	} catch (CommandException e) {
		// Shouldn't happen as the Command id will be null or valid
		e.printStackTrace();
	} finally {
		if (doc != null) {
			doc.removeDocumentListener(KillRing.getInstance());
		}
		// clear kill command flag
		KillRing.getInstance().setKill(null, false);
	}
	
	MarkUtils.clearConsoleMark(viewer);
	return result;
}
 
源代码15 项目: e4macs   文件: KillLineHandler.java
/**
 * When called from a console context, will use ST.CUT
 * 
 * @see com.mulgasoft.emacsplus.commands.ConsoleCmdHandler#consoleDispatch(TextConsoleViewer,
 *      IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	if (viewer.isEditable()) {
		IDocument doc = viewer.getDocument();
		StyledText st = viewer.getTextWidget();
		int offset = st.getCaretOffset();
		try {
			IRegion info = doc.getLineInformationOfOffset(offset);
			int noffset = info.getOffset() + info.getLength();
			if (offset == noffset) {
				int line = doc.getLineOfOffset(offset);
				if (++line < doc.getNumberOfLines()) {
					noffset = doc.getLineOffset(line);
					if (noffset == doc.getLength()) {
						noffset = offset;
					}
				}
			}
			if (offset != noffset) {
				st.redraw();
				st.setSelection(offset, noffset);
				KillRing.getInstance().setKill(CUT_LINE_TO_END, false);
				return super.consoleDispatch(viewer, activePart, event);
			}
			viewer.refresh();
		} catch (BadLocationException e) {
		}
	}
	return null;
}
 
源代码16 项目: e4macs   文件: RecenterHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {
	CS saveState = state;
	try {
		state = CS.C;
		StyledText st = viewer.getTextWidget();
		st.redraw();
		recenter(st);
	} finally {
		state = saveState;
	}
	return null;
}
 
源代码17 项目: e4macs   文件: BaseYankHandler.java
/**
 * When called from a console context, use paste
 * 
 * @see com.mulgasoft.emacsplus.commands.IConsoleDispatch#consoleDispatch(org.eclipse.ui.console.TextConsoleViewer, org.eclipse.ui.console.IConsoleView, org.eclipse.core.commands.ExecutionEvent)
 */
public Object consoleDispatch(TextConsoleViewer viewer, IConsoleView activePart, ExecutionEvent event) {

	StyledText st = viewer.getTextWidget();
	try {
		// set directly from the widget
		widgetEol = st.getLineDelimiter();
		paste(event,st,activePart.getConsole() instanceof IConsole);
	} finally {
		st.redraw();
		widgetEol = null;
	}
	
	return null;
}
 
源代码18 项目: e4macs   文件: DownListHandler.java
/**
 * @see com.mulgasoft.emacsplus.commands.SexpBaseForwardHandler#consoleDispatch(TextConsoleViewer, IConsoleView, ExecutionEvent)
 */
public Object consoleDispatch(final TextConsoleViewer viewer, final IConsoleView activePart, ExecutionEvent event) {

	IDocument doc = viewer.getDocument();
	ITextSelection currentSelection = (ITextSelection) viewer.getSelectionProvider().getSelection();
	ITextSelection selection = downList(doc, currentSelection);
	if (selection == null) {
		unbalanced(activePart,false);
	} else {
		endTransform(viewer,selection.getOffset() + selection.getLength(), currentSelection, selection);
	}
	return null;
}
 
源代码19 项目: 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;
   }
 
源代码20 项目: Pydev   文件: PyOpenLastConsoleHyperlink.java
@Override
public void run(IAction action) {
    for (IConsoleView c : ScriptConsole.iterConsoles()) {
        IConsole console = c.getConsole();
        if (console instanceof IOConsole) {
            IOConsole ioConsole = (IOConsole) console;
            processIOConsole(ioConsole);
            break;
        }
    }
}
 
源代码21 项目: Pydev   文件: ConsoleActivateDebugContext.java
@Override
public void init(IPageBookViewPage page, IConsole console) {
    this.page = page;
    this.console = (PydevConsole) console;

    view = (IConsoleView) page.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);
    DebugUITools.getDebugContextManager().getContextService(page.getSite().getWorkbenchWindow())
            .addDebugContextListener(this);
}
 
源代码22 项目: goclipse   文件: ScrollLockAction.java
public ScrollLockAction(IConsoleView consoleView) {
	super(ConsoleMessages.ScrollLockAction_Name);
	fConsoleView = consoleView;
	
	setToolTipText(ConsoleMessages.ScrollLockAction_Tooltip);
	setImageDescriptor(LangImages.IMG_SCROLL_LOCK.getDescriptor());
	boolean checked = fConsoleView.getScrollLock();
	setChecked(checked);
}
 
源代码23 项目: xds-ide   文件: XdsConsole.java
@Override
public IPageBookViewPage createPage(IConsoleView view) {
    xdsConsolePage = new XdsConsolePage(this, view);
    return xdsConsolePage;
}
 
源代码24 项目: CppStyle   文件: CppStyleMessageConsole.java
@Override
public IPageBookViewPage createPage(IConsoleView view) {
	page = new CppStyleConsolePage(this, view);
	return page;
}
 
源代码25 项目: CppStyle   文件: CppStyleConsolePage.java
public CppStyleConsolePage(CppStyleMessageConsole console, IConsoleView view) {
	super(console, view);
	this.console = console;
}
 
源代码26 项目: 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();
		}
	}
}
 
源代码27 项目: Pydev   文件: ScriptConsolePage.java
public ScriptConsolePage(ScriptConsole console, IConsoleView view, SourceViewerConfiguration cfg) {
    super(console, view);

    this.cfg = cfg;
}
 
源代码28 项目: Pydev   文件: ScriptConsole.java
/**
 * Creates the actual page to be shown to the user.
 */
@Override
public IPageBookViewPage createPage(IConsoleView view) {
    page = new ScriptConsolePage(this, view, createSourceViewerConfiguration());
    return page;
}
 
源代码29 项目: goclipse   文件: ToolsConsole.java
@Override
public IPageBookViewPage createPage(IConsoleView view) {
	return new ToolsConsolePage(this, view);
}
 
源代码30 项目: goclipse   文件: ToolsConsolePage.java
public ToolsConsolePage(TextConsole console, IConsoleView view) {
	super(console, view);
	
	setReadOnly();
}
 
 类所在包
 类方法
 同包方法