@Override public void addPosition(Position position) throws BadLocationException { try { addPosition(DEFAULT_CATEGORY, position); } catch (BadPositionCategoryException e) { } }
/** * Returns the document's document listeners. * * @return the document's document listeners */ protected List<IDocumentListener> getDocumentListeners() { return asList(fDocumentListeners); }
/** * Computes the index in the list of positions at which a position with the given * offset would be inserted. The position is supposed to become the first in this list * of all positions with the same offset. * * @param positions the list in which the index is computed * @param offset the offset for which the index is computed * @return the computed index * * @see IDocument#computeIndexInCategory(String, int) * @deprecated As of 3.4, replaced by {@link #computeIndexInPositionList(List, int, boolean)} */ @Deprecated protected int computeIndexInPositionList(List<? extends Position> positions, int offset) { return computeIndexInPositionList(positions, offset, true); }
/** * Updates the internal document structures and informs all document listeners * if listener notification has been enabled. Otherwise it remembers the event * to be sent to the listeners on resume. * * @param event the document event to be sent out */ protected void fireDocumentChanged(DocumentEvent event) { updateDocumentStructures(event); if (fStoppedListenerNotification == 0) doFireDocumentChanged(event); else fDeferredDocumentEvent= event; }
@Override public String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException { if ((0 > offset) || (offset > getLength())) throw new BadLocationException(); IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning); if (partitioner instanceof IDocumentPartitionerExtension2) { checkStateOfPartitioner(partitioner, partitioning); return ((IDocumentPartitionerExtension2) partitioner).getContentType(offset, preferOpenPartitions); } else if (partitioner != null) { checkStateOfPartitioner(partitioner, partitioning); return partitioner.getContentType(offset); } else if (DEFAULT_PARTITIONING.equals(partitioning)) return DEFAULT_CONTENT_TYPE; else throw new BadPartitioningException(); }
@Override public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException { if (0 > offset || offset > getLength()) throw new BadLocationException(); List<Position> c= fPositions.get(category); if (c == null) throw new BadPositionCategoryException(); return computeIndexInPositionList(c, offset); }
/** * Initializes document listeners, positions, and position updaters. * Must be called inside the constructor after the implementation plug-ins * have been set. */ protected void completeInitialization() { fPositions= new HashMap<>(); fEndPositions= new HashMap<>(); fPositionUpdaters= new ArrayList<>(); fDocumentListeners= new ListenerList<>(ListenerList.IDENTITY); fPrenotifiedDocumentListeners= new ListenerList<>(ListenerList.IDENTITY); fDocumentPartitioningListeners= new ListenerList<>(ListenerList.IDENTITY); fDocumentRewriteSessionListeners= new ArrayList<>(); addPositionCategory(DEFAULT_CATEGORY); addPositionUpdater(new DefaultPositionUpdater(DEFAULT_CATEGORY)); }
@Override public void addPositionCategory(String category) { if (category == null) return; if (!containsPositionCategory(category)) { fPositions.put(category, new ArrayList<>()); fEndPositions.put(category, new ArrayList<>()); } }
/** * Resumes the document listener notification by sending out the remembered * partition changed and document event. * * @since 2.1 */ private void resumeDocumentListenerNotification() { if (fDeferredDocumentEvent != null) { DocumentEvent event= fDeferredDocumentEvent; fDeferredDocumentEvent= null; doFireDocumentChanged(event); } }
@Override public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException { ITypedRegion[] partitioning= null; try { partitioning= computePartitioning(DEFAULT_PARTITIONING, offset, length, false); Assert.isNotNull(partitioning); } catch (BadPartitioningException e) { Assert.isTrue(false); } return partitioning; }
/** * Notifies all listeners about the given document change. * Uses a robust iterator. <p> * Executes all registered post notification replace operation. * * @param event the event to be sent out * @param firePartitionChange <code>true</code> if a partition change notification should be sent * @param partitionChange the region whose partitioning changed * @since 2.0 * @deprecated as of 3.0. Use <code>doFireDocumentChanged2(DocumentEvent)</code> instead; this method will be removed. */ @Deprecated protected void doFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange) { doFireDocumentChanged2(event); }
@Override public String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException { if ((0 > offset) || (offset > getLength())) throw new BadLocationException(); IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning); if (partitioner instanceof IDocumentPartitionerExtension2) { checkStateOfPartitioner(partitioner, partitioning); return ((IDocumentPartitionerExtension2) partitioner).getContentType(offset, preferOpenPartitions); } else if (partitioner != null) { checkStateOfPartitioner(partitioner, partitioning); return partitioner.getContentType(offset); } else if (DEFAULT_PARTITIONING.equals(partitioning)) return DEFAULT_CONTENT_TYPE; else throw new BadPartitioningException(); }
@Override public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException { if (0 > offset || offset > getLength()) throw new BadLocationException(); List<Position> c= fPositions.get(category); if (c == null) throw new BadPositionCategoryException(); return computeIndexInPositionList(c, offset); }
/** * Updates the internal document structures and informs all document listeners * if listener notification has been enabled. Otherwise it remembers the event * to be sent to the listeners on resume. * * @param event the document event to be sent out */ protected void fireDocumentChanged(DocumentEvent event) { updateDocumentStructures(event); if (fStoppedListenerNotification == 0) doFireDocumentChanged(event); else fDeferredDocumentEvent= event; }
/** * Initializes document listeners, positions, and position updaters. * Must be called inside the constructor after the implementation plug-ins * have been set. */ protected void completeInitialization() { fPositions= new HashMap<>(); fEndPositions= new HashMap<>(); fPositionUpdaters= new ArrayList<>(); fDocumentListeners= new ListenerList<>(ListenerList.IDENTITY); fPrenotifiedDocumentListeners= new ListenerList<>(ListenerList.IDENTITY); fDocumentPartitioningListeners= new ListenerList<>(ListenerList.IDENTITY); fDocumentRewriteSessionListeners= new ArrayList<>(); addPositionCategory(DEFAULT_CATEGORY); addPositionUpdater(new DefaultPositionUpdater(DEFAULT_CATEGORY)); }
@Override public void addPositionCategory(String category) { if (category == null) return; if (!containsPositionCategory(category)) { fPositions.put(category, new ArrayList<>()); fEndPositions.put(category, new ArrayList<>()); } }
/** * Resumes the document listener notification by sending out the remembered * partition changed and document event. * * @since 2.1 */ private void resumeDocumentListenerNotification() { if (fDeferredDocumentEvent != null) { DocumentEvent event= fDeferredDocumentEvent; fDeferredDocumentEvent= null; doFireDocumentChanged(event); } }
@Override public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException { ITypedRegion[] partitioning= null; try { partitioning= computePartitioning(DEFAULT_PARTITIONING, offset, length, false); Assert.isNotNull(partitioning); } catch (BadPartitioningException e) { Assert.isTrue(false); } return partitioning; }
/** * Notifies all listeners about the given document change. * Uses a robust iterator. <p> * Executes all registered post notification replace operation. * * @param event the event to be sent out * @param firePartitionChange <code>true</code> if a partition change notification should be sent * @param partitionChange the region whose partitioning changed * @since 2.0 * @deprecated as of 3.0. Use <code>doFireDocumentChanged2(DocumentEvent)</code> instead; this method will be removed. */ @Deprecated protected void doFireDocumentChanged(DocumentEvent event, boolean firePartitionChange, IRegion partitionChange) { doFireDocumentChanged2(event); }
@Override public ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException { if ((0 > offset) || (offset > getLength())) throw new BadLocationException(); IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning); if (partitioner instanceof IDocumentPartitionerExtension2) { checkStateOfPartitioner(partitioner, partitioning); return ((IDocumentPartitionerExtension2) partitioner).getPartition(offset, preferOpenPartitions); } else if (partitioner != null) { checkStateOfPartitioner(partitioner, partitioning); return partitioner.getPartition(offset); } else if (DEFAULT_PARTITIONING.equals(partitioning)) return new TypedRegion(0, getLength(), DEFAULT_CONTENT_TYPE); else throw new BadPartitioningException(); }