/** * Clears the console. * <p> * Since a console may or may not support direct manipulation * of its document's contents, this method should be called to clear a text console's * document. The default implementation sets this console's document content * to the empty string directly. Subclasses should override as required. * </p> */ public void clearConsole() { IDocument document = getDocument(); if (document != null) { document.set(""); //$NON-NLS-1$ } }
public void matchFound(PatternMatchEvent event) { try { int offset = event.getOffset(); int length = event.getLength(); String url = console.getDocument().get(offset, length); IHyperlink link = new UrlHyperLink(url); console.addHyperlink(link, offset, length); } catch (BadLocationException e) { } }
public void run() { ((TextConsole) con).clearConsole(); } });
/** * Returns the hyperlink at the given offset of <code>null</code> if none. * * @param offset offset for which a hyperlink is requested * @return the hyperlink at the given offset of <code>null</code> if none */ public IHyperlink getHyperlink(int offset) { try { IDocument document = getDocument(); if (document != null) { Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); Position position = findPosition(offset, positions); if (position instanceof ConsoleHyperlinkPosition) { return ((ConsoleHyperlinkPosition) position).getHyperLink(); } } } catch (BadPositionCategoryException e) { } return null; }
this.console = console; IDocument document = console.getDocument(); setDocument(document); styledText.addLineBackgroundListener(this); styledText.setEditable(true); styledText.setBackground(console.getBackground()); setFont(console.getFont()); styledText.addMouseTrackListener(this); styledText.addListener(SWT.MouseUp, mouseUpListener);
/** * Returns this link's text * * @exception CoreException if unable to retrieve the text */ protected String getLinkText() throws CoreException { try { IDocument document = getConsole().getDocument(); IRegion region = getConsole().getRegion(this); int regionOffset = region.getOffset(); int lineNumber = document.getLineOfOffset(regionOffset); IRegion lineInformation = document.getLineInformation(lineNumber); int lineOffset = lineInformation.getOffset(); String line = document.get(lineOffset, lineInformation.getLength()); int regionOffsetInLine = regionOffset - lineOffset; int linkEnd = line.indexOf(')', regionOffsetInLine); int linkStart = line.lastIndexOf(' ', regionOffsetInLine); return line.substring(linkStart==-1?0:linkStart+1,linkEnd+1); } catch (BadLocationException e) { IStatus status = new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), 0, ConsoleMessages.JavaStackTraceHyperlink_Unable_to_retrieve_hyperlink_text__8, e); throw new CoreException(status); } }
protected IStatus run(IProgressMonitor monitor) { IDocument doc = fConsole.getDocument(); String text = null; int prevBaseOffset = -1; fConsole.matcherFinished(); } else if (fScheduleFinal) { fFinalMatch = true;
/** * Constructs a new viewer in the given parent for the specified console. * * @param parent * containing widget * @param console * text console */ public TextConsoleViewer(Composite parent, TextConsole console) { super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); this.console = console; IDocument document = console.getDocument(); setDocument(document); StyledText styledText = getTextWidget(); styledText.setDoubleClickEnabled(true); styledText.addLineStyleListener(this); styledText.addLineBackgroundListener(this); styledText.setEditable(true); setFont(console.getFont()); styledText.addMouseTrackListener(this); styledText.addListener(SWT.MouseUp, mouseUpListener); ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); propertyChangeListener = new HyperlinkColorChangeListener(); colorRegistry.addListener(propertyChangeListener); revealJob.setSystem(true); document.addDocumentListener(documentListener); document.addPositionUpdater(positionUpdater); }
public void createControl(Composite parent) { fViewer = createViewer(parent); fViewer.setConsoleWidth(fConsole.getConsoleWidth()); fViewer.setTabWidth(fConsole.getTabWidth()); fConsole.addPropertyChangeListener(this); JFaceResources.getFontRegistry().addListener(this); String id = "#ContextMenu"; //$NON-NLS-1$ if (getConsole().getType() != null) { id = getConsole().getType() + "." + id; //$NON-NLS-1$ } fMenuManager= new MenuManager("#ContextMenu", id); //$NON-NLS-1$ fMenuManager.setRemoveAllWhenShown(true); fMenuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } }); Menu menu = fMenuManager.createContextMenu(getControl()); getControl().setMenu(menu); createActions(); configureToolBar(getSite().getActionBars().getToolBarManager()); getSite().registerContextMenu(id, fMenuManager, fViewer); getSite().setSelectionProvider(fViewer); fViewer.getSelectionProvider().addSelectionChangedListener(selectionChangedListener); fViewer.addTextListener(textListener); }
public void matchFound(PatternMatchEvent event) { try { int offset = event.getOffset(); int length = event.getLength(); IHyperlink link = new JavaStackTraceHyperlink(fConsole); fConsole.addHyperlink(link, offset+1, length-2); } catch (BadLocationException e) { } }
/** * Disposes this console. */ @Override protected void dispose() { super.dispose(); partitioner.disconnect(); //make a copy of the open streams and close them all //a copy is needed as close the streams results in a callback that //removes the streams from the openStreams collection (bug 152794) List<Closeable> list = new ArrayList<Closeable>(openStreams); for (Closeable closable : list) { try { closable.close(); } catch (IOException e) { // e.printStackTrace(); } } inputStream = null; }
/** * This console's partitioner should call this method when it is not expecting any new data * to be appended to the document. */ public void partitionerFinished() { fPatternMatcher.forceFinalMatching(); fPartitionerFinished = true; checkFinished(); }
public IOConsolePage(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); }
PatternMatchListener patternMatchListener = new PatternMatchListener(extension); try { textConsole.addPatternMatchListener(patternMatchListener); list.add(patternMatchListener); } catch (PatternSyntaxException e) {
/** * Returns the hyperlink at the given offset of <code>null</code> if none. * * @param offset offset for which a hyperlink is requested * @return the hyperlink at the given offset of <code>null</code> if none */ public IHyperlink getHyperlink(int offset) { try { IDocument document = getDocument(); if (document != null) { Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); Position position = findPosition(offset, positions); if (position instanceof ConsoleHyperlinkPosition) { return ((ConsoleHyperlinkPosition) position).getHyperLink(); } } } catch (BadPositionCategoryException e) { } return null; }
/** * Returns this link's text * * @exception CoreException * if unable to retrieve the text */ protected String getLinkText() throws CoreException { try { IDocument document = getConsole().getDocument(); IRegion region = getConsole().getRegion(this); int regionOffset = region.getOffset(); int lineNumber = document.getLineOfOffset(regionOffset); IRegion lineInformation = document.getLineInformation(lineNumber); int lineOffset = lineInformation.getOffset(); String line = document.get(lineOffset, lineInformation.getLength()); int regionOffsetInLine = regionOffset - lineOffset; int linkEnd = line.indexOf(')', regionOffsetInLine); int linkStart = line.lastIndexOf(' ', regionOffsetInLine); return line.substring(linkStart == -1 ? 0 : linkStart + 1, linkEnd + 1); } catch (BadLocationException e) { IStatus status = new Status(IStatus.ERROR, DLTKDebugUIPlugin.getUniqueIdentifier(), 0, ConsoleMessages.RutaFileHyperlink_Unable_to_retrieve_hyperlink_text__8, e); throw new CoreException(status); } }
@Override protected IStatus run(IProgressMonitor monitor) { IDocument doc = fConsole.getDocument(); String text = null; int prevBaseOffset = -1; fConsole.matcherFinished(); } else if (fScheduleFinal) { fFinalMatch = true;
@Override public void createControl(Composite parent) { fViewer = createViewer(parent); fViewer.setConsoleWidth(fConsole.getConsoleWidth()); fViewer.setTabWidth(fConsole.getTabWidth()); fConsole.addPropertyChangeListener(this); JFaceResources.getFontRegistry().addListener(this); String id = "#ContextMenu"; //$NON-NLS-1$ if (getConsole().getType() != null) { id = getConsole().getType() + "." + id; //$NON-NLS-1$ } fMenuManager= new MenuManager("#ContextMenu", id); //$NON-NLS-1$ fMenuManager.setRemoveAllWhenShown(true); fMenuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } }); Menu menu = fMenuManager.createContextMenu(getControl()); getControl().setMenu(menu); createActions(); configureToolBar(getSite().getActionBars().getToolBarManager()); getSite().registerContextMenu(id, fMenuManager, fViewer); getSite().setSelectionProvider(fViewer); fViewer.getSelectionProvider().addSelectionChangedListener(selectionChangedListener); fViewer.addTextListener(textListener); }
public void matchFound(PatternMatchEvent event) { try { int offset = event.getOffset(); int length = event.getLength(); IHyperlink link = new RutaFileHyperlink(console); console.addHyperlink(link, offset + 1, length - 2); } catch (BadLocationException e) { } } }
/** * @see org.eclipse.ui.console.TextConsole#dispose() */ protected void dispose() { saveDocument(); JFaceResources.getFontRegistry().removeListener(propertyListener); super.dispose(); }