/** * 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); }
/** * State machine. Changes state given the current state and the incoming * change. * * @param change the incoming change */ private void handleChange(Change change) { if (change.getType() == TypingRun.NO_CHANGE) return; if (DEBUG) System.err.println("Last change: " + fLastChange); //$NON-NLS-1$ if (!change.canFollow(fLastChange)) endIfStarted(change); fLastChange= change; if (change.isModification()) startOrContinue(); if (DEBUG) System.err.println("New change: " + change); //$NON-NLS-1$ }
/** * State machine. Changes state given the current state and the incoming * change. * * @param change the incoming change */ private void handleChange(Change change) { if (change.getType() == TypingRun.NO_CHANGE) return; if (DEBUG) System.err.println("Last change: " + fLastChange); //$NON-NLS-1$ if (!change.canFollow(fLastChange)) endIfStarted(change); fLastChange= change; if (change.isModification()) startOrContinue(); if (DEBUG) System.err.println("New change: " + change); //$NON-NLS-1$ }
/** * State machine. Changes state given the current state and the incoming * change. * * @param change the incoming change */ private void handleChange(Change change) { if (change.getType() == TypingRun.NO_CHANGE) return; if (DEBUG) System.err.println("Last change: " + fLastChange); //$NON-NLS-1$ if (!change.canFollow(fLastChange)) endIfStarted(change); fLastChange= change; if (change.isModification()) startOrContinue(); if (DEBUG) System.err.println("New change: " + change); //$NON-NLS-1$ }
/** * Ends any active run and informs all listeners. If there is none, nothing * happens. * * @param change the change that triggered ending the active run */ private void endIfStarted(Change change) { if (hasRun()) { ensureSelectionListenerRemoved(); if (DEBUG) System.err.println("-End run"); //$NON-NLS-1$ fireRunEnded(fRun, change.getType()); fRun= null; } }
/** * Ends any active run and informs all listeners. If there is none, nothing * happens. * * @param change the change that triggered ending the active run */ private void endIfStarted(Change change) { if (hasRun()) { ensureSelectionListenerRemoved(); if (DEBUG) System.err.println("-End run"); //$NON-NLS-1$ fireRunEnded(fRun, change.getType()); fRun= null; } }
/** * Ends any active run and informs all listeners. If there is none, nothing * happens. * * @param change the change that triggered ending the active run */ private void endIfStarted(Change change) { if (hasRun()) { ensureSelectionListenerRemoved(); if (DEBUG) System.err.println("-End run"); //$NON-NLS-1$ fireRunEnded(fRun, change.getType()); fRun= null; } }
/** * Starts a new run if there is none and informs all listeners. If there * already is a run, nothing happens. */ private void startOrContinue() { if (!hasRun()) { if (DEBUG) System.err.println("+Start run"); //$NON-NLS-1$ fRun= new TypingRun(fLastChange.getType()); ensureSelectionListenerAdded(); fireRunBegun(fRun); } }
/** * Starts a new run if there is none and informs all listeners. If there * already is a run, nothing happens. */ private void startOrContinue() { if (!hasRun()) { if (DEBUG) System.err.println("+Start run"); //$NON-NLS-1$ fRun= new TypingRun(fLastChange.getType()); ensureSelectionListenerAdded(); fireRunBegun(fRun); } }
/** * Starts a new run if there is none and informs all listeners. If there * already is a run, nothing happens. */ private void startOrContinue() { if (!hasRun()) { if (DEBUG) System.err.println("+Start run"); //$NON-NLS-1$ fRun= new TypingRun(fLastChange.getType()); ensureSelectionListenerAdded(); fireRunBegun(fRun); } }
/** * 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)); }
/** * 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)); }