@Override public void set(String text) { if (hasActiveRewriteSession()) { fPendingRequests.clear(); fPendingRequests.add(new Request(text)); return; } fDelegate.set(text); }
@Override public void set(String text) { if (hasActiveRewriteSession()) { fPendingRequests.clear(); fPendingRequests.add(new Request(text)); return; } fDelegate.set(text); }
@Override public void repairLineInformation() { getTracker().set(get()); }
@Override public void repairLineInformation() { getTracker().set(get()); }
private static String changeLineDelimiter(String code, String lineDelim) { try { ILineTracker tracker= new DefaultLineTracker(); tracker.set(code); int nLines= tracker.getNumberOfLines(); if (nLines == 1) { return code; } StringBuffer buf= new StringBuffer(); for (int i= 0; i < nLines; i++) { if (i != 0) { buf.append(lineDelim); } IRegion region = tracker.getLineInformation(i); String line= code.substring(region.getOffset(), region.getOffset() + region.getLength()); buf.append(line); } return buf.toString(); } catch (BadLocationException e) { // can not happen return code; } }
private static String changeLineDelimiter(String code, String lineDelim) { try { ILineTracker tracker= new DefaultLineTracker(); tracker.set(code); int nLines= tracker.getNumberOfLines(); if (nLines == 1) { return code; } StringBuilder buf= new StringBuilder(); for (int i= 0; i < nLines; i++) { if (i != 0) { buf.append(lineDelim); } IRegion region = tracker.getLineInformation(i); String line= code.substring(region.getOffset(), region.getOffset() + region.getLength()); buf.append(line); } return buf.toString(); } catch (BadLocationException e) { // can not happen return code; } }
private static String changeLineDelimiter(String code, String lineDelim) { try { ILineTracker tracker= new DefaultLineTracker(); tracker.set(code); int nLines= tracker.getNumberOfLines(); if (nLines == 1) { return code; } StringBuffer buf= new StringBuffer(); for (int i= 0; i < nLines; i++) { if (i != 0) { buf.append(lineDelim); } IRegion region = tracker.getLineInformation(i); String line= code.substring(region.getOffset(), region.getOffset() + region.getLength()); buf.append(line); } return buf.toString(); } catch (BadLocationException e) { // can not happen return code; } }
public void run() { String text = new String(content); int offset = calculateBacklogOffset(); String currentText = getStore().get(offset,getStore().getLength() - offset); currentText = currentText.concat(text); getStore().set(currentText); getTracker().set(currentText); if(isFirstTimeRead) { offset = calculateBacklogOffset(); currentText = getStore().get(offset,getStore().getLength() - offset); getStore().set(currentText); getTracker().set(currentText); } //int newOffset = getStore().getLength() > content.length ? getStore().getLength() - content.length : 0; DocumentEvent event = new DocumentEvent(LogDocument.this, getStore().getLength(), content.length, text); fireDocumentChanged(event); } };
/** * Converts the given string into an array of lines. The lines * don't contain any line delimiter characters. * * @return the string converted into an array of strings. Returns <code> * null</code> if the input string can't be converted in an array of lines. */ public static String[] convertIntoLines(String input) { try { ILineTracker tracker= new DefaultLineTracker(); tracker.set(input); int size= tracker.getNumberOfLines(); String result[]= new String[size]; for (int i= 0; i < size; i++) { IRegion region= tracker.getLineInformation(i); int offset= region.getOffset(); result[i]= input.substring(offset, offset + region.getLength()); } return result; } catch (BadLocationException e) { return null; } }
@Override public void set(String text, long modificationStamp) { int length= getStore().getLength(); DocumentEvent e= new DocumentEvent(this, 0, length, text); fireDocumentAboutToBeChanged(e); getStore().set(text); getTracker().set(text); fModificationStamp= modificationStamp; fNextModificationStamp= Math.max(fModificationStamp, fNextModificationStamp); e.fModificationStamp= fModificationStamp; fireDocumentChanged(e); }
@Override public void set(String text, long modificationStamp) { int length= getStore().getLength(); DocumentEvent e= new DocumentEvent(this, 0, length, text); fireDocumentAboutToBeChanged(e); getStore().set(text); getTracker().set(text); fModificationStamp= modificationStamp; fNextModificationStamp= Math.max(fModificationStamp, fNextModificationStamp); e.fModificationStamp= fModificationStamp; fireDocumentChanged(e); }
/** * if the monitor parameter is true and the current FileTail instance thread * is not running the Thread will be inovked and the tail begins to update * this document. * * if the monitor parameter is false the FileTail instance thread is notified * to stop at the next possbile exit point. * @param monitor */ public void setMonitor(boolean monitorIn) { if(monitorIn && !monitor) { getStore().set(""); //$NON-NLS-1$ getTracker().set(""); //$NON-NLS-1$ } monitor = monitorIn; reader.setMonitorStatus(monitor); file.setMonitor(monitor); }
/** * Creates a new document clone with the given content. * * @param content the content * @param lineDelimiters the line delimiters */ public DocumentClone(String content, String[] lineDelimiters) { super(); setTextStore(new StringTextStore(content)); ConfigurableLineTracker tracker= new ConfigurableLineTracker(lineDelimiters); setLineTracker(tracker); getTracker().set(content); completeInitialization(); } }
/** * Creates a new document clone with the given content. * * @param content the content * @param lineDelimiters the line delimiters */ public DocumentClone(String content, String[] lineDelimiters) { super(); setTextStore(new StringTextStore(content)); ConfigurableLineTracker tracker= new ConfigurableLineTracker(lineDelimiters); setLineTracker(tracker); getTracker().set(content); completeInitialization(); } }
/** * Creates a new document clone with the given content. * * @param content the content * @param lineDelimiters the line delimiters */ public DocumentClone(String content, String[] lineDelimiters) { super(); setTextStore(new StringTextStore(content)); ConfigurableLineTracker tracker= new ConfigurableLineTracker(lineDelimiters); setLineTracker(tracker); getTracker().set(content); completeInitialization(); } }
@Override public void switchView(String viewName) { // TODO: Optimize the text retrieval and update notification handling // Currently the text must be changed before switchView is called ... // HACK: // Replace the text like set() would do, // but without sending out notifications. // The stop and resume notification methods do not yield // the desired effect String text = transformText(getCAS().getView(viewName).getDocumentText()); getStore().set(text); getTracker().set(text); // Note: Sends out view update notification ((DocumentUimaImpl) mDocument).switchView(viewName); }
/** * Creates a new document with the given initial content. * * @param initialContent the document's initial content */ public Document(String initialContent) { super(); setTextStore(new CopyOnWriteTextStore(new GapTextStore())); setLineTracker(new DefaultLineTracker()); getStore().set(initialContent); getTracker().set(initialContent); completeInitialization(); }
/** * Creates a new document with the given initial content. * * @param initialContent the document's initial content */ public Document(String initialContent) { super(); setTextStore(new CopyOnWriteTextStore(new GapTextStore())); setLineTracker(new DefaultLineTracker()); getStore().set(initialContent); getTracker().set(initialContent); completeInitialization(); }
/** * Creates a projection document for the given master document. * * @param masterDocument the master document */ public ProjectionDocument(IDocument masterDocument) { super(); fMasterDocument= masterDocument; if (fMasterDocument instanceof IDocumentExtension) fMasterDocumentExtension= (IDocumentExtension) fMasterDocument; fSegmentsCategory= SEGMENTS_CATEGORY; fFragmentsCategory= FRAGMENTS_CATEGORY_PREFIX + hashCode(); fMasterDocument.addPositionCategory(fFragmentsCategory); fFragmentsUpdater= new FragmentUpdater(fFragmentsCategory); fMasterDocument.addPositionUpdater(fFragmentsUpdater); fMapping= new ProjectionMapping(masterDocument, fFragmentsCategory, this, fSegmentsCategory); ITextStore s= new ProjectionTextStore(masterDocument, fMapping); ILineTracker tracker= new DefaultLineTracker(); setTextStore(s); setLineTracker(tracker); completeInitialization(); initializeProjection(); tracker.set(s.get(0, s.getLength())); }
/** * Creates a projection document for the given master document. * * @param masterDocument the master document */ public ProjectionDocument(IDocument masterDocument) { super(); fMasterDocument= masterDocument; if (fMasterDocument instanceof IDocumentExtension) fMasterDocumentExtension= (IDocumentExtension) fMasterDocument; fSegmentsCategory= SEGMENTS_CATEGORY; fFragmentsCategory= FRAGMENTS_CATEGORY_PREFIX + hashCode(); fMasterDocument.addPositionCategory(fFragmentsCategory); fFragmentsUpdater= new FragmentUpdater(fFragmentsCategory); fMasterDocument.addPositionUpdater(fFragmentsUpdater); fMapping= new ProjectionMapping(masterDocument, fFragmentsCategory, this, fSegmentsCategory); ITextStore s= new ProjectionTextStore(masterDocument, fMapping); ILineTracker tracker= new DefaultLineTracker(); setTextStore(s); setLineTracker(tracker); completeInitialization(); initializeProjection(); tracker.set(s.get(0, s.getLength())); }