/** * Puts <code>document</code> into the set of managed documents. This * involves registering the document listener and adding our position * category. * * @param document the new document */ private void manageDocument(IDocument document) { if (!fDocuments.contains(document)) { fDocuments.add(document); document.addPositionCategory(getCategory()); document.addPositionUpdater(fUpdater); document.addDocumentListener(fDocumentListener); } }
/** * Puts <code>document</code> into the set of managed documents. This * involves registering the document listener and adding our position * category. * * @param document the new document */ private void manageDocument(IDocument document) { if (!fDocuments.contains(document)) { fDocuments.add(document); document.addPositionCategory(getCategory()); document.addPositionUpdater(fUpdater); document.addDocumentListener(fDocumentListener); } }
IDocument doc= it.next(); try { doc.removePositionCategory(getCategory()); } catch (BadPositionCategoryException e) {
/** * Registers a <code>LinkedPosition</code> with this model. Called * by <code>PositionGroup</code>. * * @param position the position to register * @throws BadLocationException if the position cannot be added to its * document */ void register(LinkedPosition position) throws BadLocationException { Assert.isNotNull(position); IDocument document= position.getDocument(); manageDocument(document); try { document.addPosition(getCategory(), position); } catch (BadPositionCategoryException e) { // won't happen as the category has been added by manageDocument() Assert.isTrue(false); } int seqNr= position.getSequenceNumber(); if (seqNr != LinkedPositionGroup.NO_STOP) { fPositionSequence.add(position); } }
/** * Causes this model to exit. Called either if an illegal document change * is detected, or by the UI. * * @param flags the exit flags as defined in {@link ILinkedModeListener} */ public void exit(int flags) { if (!fIsActive) return; fIsActive= false; for (IDocument doc : fDocuments) { try { doc.removePositionCategory(getCategory()); } catch (BadPositionCategoryException e) { // won't happen Assert.isTrue(false); } doc.removePositionUpdater(fUpdater); doc.removeDocumentListener(fDocumentListener); } fDocuments.clear(); fGroups.clear(); List<ILinkedModeListener> listeners= new ArrayList<>(fListeners); fListeners.clear(); for (ILinkedModeListener listener : listeners) { listener.left(this, flags); } if (fParentEnvironment != null) fParentEnvironment.resume(flags); }
/** * Registers a <code>LinkedPosition</code> with this model. Called * by <code>PositionGroup</code>. * * @param position the position to register * @throws BadLocationException if the position cannot be added to its * document */ void register(LinkedPosition position) throws BadLocationException { Assert.isNotNull(position); IDocument document= position.getDocument(); manageDocument(document); try { document.addPosition(getCategory(), position); } catch (BadPositionCategoryException e) { // won't happen as the category has been added by manageDocument() Assert.isTrue(false); } int seqNr= position.getSequenceNumber(); if (seqNr != LinkedPositionGroup.NO_STOP) { fPositionSequence.add(position); } }