/** * Computes the change abstraction given a text event. * * @param event the text event to analyze * @return a change object describing the event */ private Change computeChange(TextEvent event) { DocumentEvent e= event.getDocumentEvent(); if (e == null) return new Change(TypingRun.NO_CHANGE, -1); int start= e.getOffset(); int end= e.getOffset() + e.getLength(); String newText= e.getText(); if (newText == null) newText= new String(); if (start == end) { // no replace / delete / overwrite if (newText.length() == 1) return new Change(TypingRun.INSERT, end + 1); } else if (start == end - 1) { if (newText.length() == 1) return new Change(TypingRun.OVERTYPE, end); if (newText.length() == 0) return new Change(TypingRun.DELETE, start); } return new Change(TypingRun.UNKNOWN, -1); }
/** * Computes the change abstraction given a text event. * * @param event the text event to analyze * @return a change object describing the event */ private Change computeChange(TextEvent event) { DocumentEvent e= event.getDocumentEvent(); if (e == null) return new Change(TypingRun.NO_CHANGE, -1); int start= e.getOffset(); int end= e.getOffset() + e.getLength(); String newText= e.getText(); if (newText == null) newText= new String(); if (start == end) { // no replace / delete / overwrite if (newText.length() == 1) return new Change(TypingRun.INSERT, end + 1); } else if (start == end - 1) { if (newText.length() == 1) return new Change(TypingRun.OVERTYPE, end); if (newText.length() == 0) return new Change(TypingRun.DELETE, start); } return new Change(TypingRun.UNKNOWN, -1); }
/** * Computes the change abstraction given a text event. * * @param event the text event to analyze * @return a change object describing the event */ private Change computeChange(TextEvent event) { DocumentEvent e= event.getDocumentEvent(); if (e == null) return new Change(TypingRun.NO_CHANGE, -1); int start= e.getOffset(); int end= e.getOffset() + e.getLength(); String newText= e.getText(); if (newText == null) newText= new String(); if (start == end) { // no replace / delete / overwrite if (newText.length() == 1) return new Change(TypingRun.INSERT, end + 1); } else if (start == end - 1) { if (newText.length() == 1) return new Change(TypingRun.OVERTYPE, end); if (newText.length() == 0) return new Change(TypingRun.DELETE, start); } return new Change(TypingRun.UNKNOWN, -1); }
/** * Handles an incoming selection event. */ void handleSelectionChanged() { handleChange(new Change(TypingRun.SELECTION, -1)); }
/** * Initializes the state variables and registers any permanent listeners. */ private void connect() { if (fViewer != null) { fLastChange= new Change(TypingRun.UNKNOWN, -1); fRun= null; fSelectionListener= null; fViewer.addTextListener(fTextListener); } }
/** * Handles an incoming selection event. */ void handleSelectionChanged() { handleChange(new Change(TypingRun.SELECTION, -1)); }
/** * Initializes the state variables and registers any permanent listeners. */ private void connect() { if (fViewer != null) { fLastChange= new Change(TypingRun.UNKNOWN, -1); fRun= null; fSelectionListener= null; fViewer.addTextListener(fTextListener); } }
/** * Initializes the state variables and registers any permanent listeners. */ private void connect() { if (fViewer != null) { fLastChange= new Change(TypingRun.UNKNOWN, -1); fRun= null; fSelectionListener= null; fViewer.addTextListener(fTextListener); } }
/** * Handles an incoming selection event. */ void handleSelectionChanged() { handleChange(new Change(TypingRun.SELECTION, -1)); }