/** * Finds the closest position to <code>toFind</code>. * * @param toFind the linked position for which to find the closest position * @return the closest position to <code>toFind</code>. */ LinkedPosition getPosition(LinkedPosition toFind) { for (LinkedPosition p : fPositions) { if (p.includes(toFind)) return p; } return null; }
/** * Returns <code>true</code> if <code>offset</code> is contained in any * position in this group. * * @param offset the offset to check * @return <code>true</code> if offset is contained by this group */ boolean contains(int offset) { for (LinkedPosition pos : fPositions) { if (pos.includes(offset)) { return true; } } return false; }
/** * Finds the closest position to <code>toFind</code>. * * @param toFind the linked position for which to find the closest position * @return the closest position to <code>toFind</code>. */ LinkedPosition getPosition(LinkedPosition toFind) { for (Iterator<LinkedPosition> it= fPositions.iterator(); it.hasNext(); ) { LinkedPosition p= it.next(); if (p.includes(toFind)) return p; } return null; }
/** * Returns <code>true</code> if <code>offset</code> is contained in any * position in this group. * * @param offset the offset to check * @return <code>true</code> if offset is contained by this group */ boolean contains(int offset) { for (Iterator<LinkedPosition> it= fPositions.iterator(); it.hasNext(); ) { LinkedPosition pos= it.next(); if (pos.includes(offset)) { return true; } } return false; }
public LinkedPosition getCurrentLinkedPosition() { Point selection= fEditor.getViewer().getSelectedRange(); int start= selection.x; int end= start + selection.y; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (position.includes(start) && position.includes(end)) return position; } return null; }
public LinkedPosition getCurrentLinkedPosition() { Point selection = editor.getInternalSourceViewer().getSelectedRange(); int start = selection.x; int end = start + selection.y; LinkedPosition[] positions = linkedPositionGroup.getPositions(); for (int i = 0; i < positions.length; i++) { LinkedPosition position = positions[i]; if (position.includes(start) && position.includes(end)) return position; } return null; }
public LinkedPosition getCurrentLinkedPosition() { Point selection= fEditor.getViewer().getSelectedRange(); int start= selection.x; int end= start + selection.y; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (position.includes(start) && position.includes(end)) return position; } return null; }
public LinkedPosition getCurrentLinkedPosition() { Point selection= fEditor.getViewer().getSelectedRange(); int start= selection.x; int end= start + selection.y; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (position.includes(start) && position.includes(end)) return position; } return null; }
for (Iterator<LinkedPosition> it2= fPositions.iterator(); it2.hasNext(); ) { LinkedPosition myPos= it2.next(); if (myPos.includes(pos)) { if (found == null) found= myPos;
/** * Returns whether this position includes <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position includes * <code>position</code>,<code>false</code> otherwise */ public boolean includes(LinkedPosition position) { return includes(position.getDocument(), position.getOffset(), position.getLength()); }
/** * Returns whether this position includes <code>event</code>. * * @param event the event to check. * @return <code>true</code> if this position includes <code>event</code>, * <code>false</code> otherwise */ public boolean includes(DocumentEvent event) { return includes(event.getDocument(), event.getOffset(), event.getLength()); }
/** * Returns whether this position includes <code>position</code>. * * @param position the position to check. * @return <code>true</code> if this position includes * <code>position</code>,<code>false</code> otherwise */ public boolean includes(LinkedPosition position) { return includes(position.getDocument(), position.getOffset(), position.getLength()); }
/** * Returns whether this position includes <code>event</code>. * * @param event the event to check. * @return <code>true</code> if this position includes <code>event</code>, * <code>false</code> otherwise */ public boolean includes(DocumentEvent event) { return includes(event.getDocument(), event.getOffset(), event.getLength()); }
/** * Returns the position in this group that encompasses all positions in * <code>group</code>. * * @param group the group to be adopted * @return a position in the receiver that contains all positions in <code>group</code>, * or <code>null</code> if none can be found * @throws BadLocationException if more than one position are affected by * <code>group</code> */ LinkedPosition adopt(LinkedPositionGroup group) throws BadLocationException { LinkedPosition found= null; for (LinkedPosition pos : group.fPositions) { LinkedPosition localFound= null; for (LinkedPosition myPos : fPositions) { if (myPos.includes(pos)) { if (found == null) found= myPos; else if (found != myPos) throw new BadLocationException(); if (localFound == null) localFound= myPos; } } if (localFound != found) throw new BadLocationException(); } return found; }
private void restoreFullSelection() { if (fOriginalSelection.y != 0) { int originalOffset= fOriginalSelection.x; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (! position.isDeleted() && position.includes(originalOffset)) { fEditor.getViewer().setSelectedRange(position.offset, position.length); return; } } } }
private void restoreFullSelection() { if (fOriginalSelection.y != 0) { int originalOffset= fOriginalSelection.x; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (! position.isDeleted() && position.includes(originalOffset)) { fEditor.getViewer().setSelectedRange(position.offset, position.length); return; } } } }
private void restoreFullSelection() { if (fOriginalSelection.y != 0) { int originalOffset= fOriginalSelection.x; LinkedPosition[] positions= fLinkedPositionGroup.getPositions(); for (int i= 0; i < positions.length; i++) { LinkedPosition position= positions[i]; if (! position.isDeleted() && position.includes(originalOffset)) { fEditor.getViewer().setSelectedRange(position.offset, position.length); return; } } } }
@Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection= event.getSelection(); if (selection instanceof ITextSelection) { ITextSelection textsel= (ITextSelection) selection; if (event.getSelectionProvider() instanceof ITextViewer) { IDocument doc= ((ITextViewer) event.getSelectionProvider()).getDocument(); if (doc != null) { int offset= textsel.getOffset(); int length= textsel.getLength(); if (offset >= 0 && length >= 0) { LinkedPosition find= new LinkedPosition(doc, offset, length, LinkedPositionGroup.NO_STOP); LinkedPosition pos= fModel.findPosition(find); if (pos == null && fExitPosition != null && fExitPosition.includes(find)) pos= fExitPosition; if (pos != null) switchPosition(pos, false, false); } } } } }
@Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection= event.getSelection(); if (selection instanceof ITextSelection) { ITextSelection textsel= (ITextSelection) selection; if (event.getSelectionProvider() instanceof ITextViewer) { IDocument doc= ((ITextViewer) event.getSelectionProvider()).getDocument(); if (doc != null) { int offset= textsel.getOffset(); int length= textsel.getLength(); if (offset >= 0 && length >= 0) { LinkedPosition find= new LinkedPosition(doc, offset, length, LinkedPositionGroup.NO_STOP); LinkedPosition pos= fModel.findPosition(find); if (pos == null && fExitPosition != null && fExitPosition.includes(find)) pos= fExitPosition; if (pos != null) switchPosition(pos, false, false); } } } } }
LinkedModeUI ui = new EditorLinkedModeUI(linkedModeModel, viewer); ui.setExitPolicy(new ExitPolicy(document)); if (currentPosition.includes(originalSelection.x)) ui.setExitPosition(viewer, originalSelection.x, 0, Integer.MAX_VALUE); ui.enter(); if (currentPosition.includes(originalSelection.x) && currentPosition.includes(originalSelection.x + originalSelection.y)) viewer.setSelectedRange(originalSelection.x, originalSelection.y); if (viewer instanceof IEditingSupportRegistry) {