/** * Returns the current trigger sequence. * * @return The trigger sequence; may be empty, but never <code>null</code>. */ private KeySequence getKeySequence() { return textTriggerSequenceManager.getKeySequence(); }
/** * A mutator for the maximum number of strokes that are permitted in this * widget at one time. * * @param keyStrokeLimit * The maximum number of strokes; must be a positive integer or * <code>INFINITE</code>. */ public void setKeyStrokeLimit(int keyStrokeLimit) { if (keyStrokeLimit > 0 || keyStrokeLimit == INFINITE) { this.maxStrokes = keyStrokeLimit; } else { throw new IllegalArgumentException(); } // Make sure we are obeying the new limit. setKeySequence(getKeySequence()); } }
/** * A mutator for the maximum number of strokes that are permitted in this * widget at one time. * * @param keyStrokeLimit * The maximum number of strokes; must be a positive integer or * <code>INFINITE</code>. */ public void setKeyStrokeLimit(int keyStrokeLimit) { if (keyStrokeLimit > 0 || keyStrokeLimit == INFINITE) { this.maxStrokes = keyStrokeLimit; } else { throw new IllegalArgumentException(); } // Make sure we are obeying the new limit. setKeySequence(getKeySequence()); } }
/** * A mutator for the maximum number of strokes that are permitted in this * widget at one time. * * @param keyStrokeLimit * The maximum number of strokes; must be a positive integer or * <code>INFINITE</code>. */ public void setKeyStrokeLimit(int keyStrokeLimit) { if (keyStrokeLimit > 0 || keyStrokeLimit == INFINITE) { this.maxStrokes = keyStrokeLimit; } else { throw new IllegalArgumentException(); } // Make sure we are obeying the new limit. setKeySequence(getKeySequence()); } }
/** * Fires a property change event to all of the listeners. * * @param oldKeySequence * The old key sequence; must not be <code>null</code>. * @since 3.2 */ protected final void firePropertyChangeEvent( final KeySequence oldKeySequence) { if (listeners != null) { final Iterator<IPropertyChangeListener> listenerItr = listeners.iterator(); final PropertyChangeEvent event = new PropertyChangeEvent(this, P_KEY_SEQUENCE, oldKeySequence, getKeySequence()); while (listenerItr.hasNext()) { final IPropertyChangeListener listener = listenerItr.next(); listener.propertyChange(event); } } }
/** * Fires a property change event to all of the listeners. * * @param oldKeySequence * The old key sequence; must not be <code>null</code>. * @since 3.2 */ protected final void firePropertyChangeEvent( final KeySequence oldKeySequence) { if (listeners != null) { final Iterator listenerItr = listeners.iterator(); final PropertyChangeEvent event = new PropertyChangeEvent(this, P_KEY_SEQUENCE, oldKeySequence, getKeySequence()); while (listenerItr.hasNext()) { final IPropertyChangeListener listener = (IPropertyChangeListener) listenerItr .next(); listener.propertyChange(event); } } }
/** * Fires a property change event to all of the listeners. * * @param oldKeySequence * The old key sequence; must not be <code>null</code>. */ protected final void firePropertyChangeEvent( final KeySequence oldKeySequence) { if (listeners != null) { final Iterator listenerItr = listeners.iterator(); final PropertyChangeEvent event = new PropertyChangeEvent(this, P_KEY_SEQUENCE, oldKeySequence, getKeySequence()); while (listenerItr.hasNext()) { final IPropertyChangeListener listener = (IPropertyChangeListener) listenerItr .next(); listener.propertyChange(event); } } }
/** * Handles the modify event on the underlying text widget. * * @param event * The triggering event; ignored. */ public void modifyText(ModifyEvent event) { try { // The original sequence. KeySequence originalSequence = getKeySequence(); // The new sequence drawn from the text. String contents = getText(); KeySequence newSequence = KeySequence.getInstance(contents); // Check to see if they're the same. if (!originalSequence.equals(newSequence)) { setKeySequence(newSequence); } } catch (ParseException e) { // Abort any cut/paste-driven modifications setKeySequence(getKeySequence()); } } }
/** * Handles the modify event on the underlying text widget. * * @param event * The triggering event; ignored. */ @Override public void modifyText(ModifyEvent event) { try { // The original sequence. KeySequence originalSequence = getKeySequence(); // The new sequence drawn from the text. String contents = getText(); KeySequence newSequence = KeySequence.getInstance(contents); // Check to see if they're the same. if (!originalSequence.equals(newSequence)) { setKeySequence(newSequence); } } catch (ParseException e) { // Abort any cut/paste-driven modifications setKeySequence(getKeySequence()); } } }
/** * Handles the modify event on the underlying text widget. * * @param event * The triggering event; ignored. */ @Override public void modifyText(ModifyEvent event) { try { // The original sequence. KeySequence originalSequence = getKeySequence(); // The new sequence drawn from the text. String contents = getText(); KeySequence newSequence = KeySequence.getInstance(contents); // Check to see if they're the same. if (!originalSequence.equals(newSequence)) { setKeySequence(newSequence); } } catch (ParseException e) { // Abort any cut/paste-driven modifications setKeySequence(getKeySequence()); } } }
/** * Handles the key pressed and released events on the wrapped text * widget. This makes sure to either add the pressed key to the * temporary key stroke, or complete the current temporary key stroke * and prompt for the next. In the case of a key release, this makes * sure that the temporary stroke is correctly displayed -- * corresponding with modifier keys that may have been released. * * @param event * The triggering event; must not be <code>null</code>. */ public void handleEvent(Event event) { KeyStroke[] keyStrokes = getKeySequence().getKeyStrokes(); // Dispatch the event to the correct handler. if (event.type == SWT.KeyDown) { keyStrokes = handleKeyDown(event, keyStrokes); } else if (event.type == SWT.KeyUp) { keyStrokes = handleKeyUp(event, keyStrokes); } // Update the underlying widget. setKeySequence(KeySequence.getInstance(keyStrokes)); // Prevent the event from reaching the widget. event.doit = false; }
/** * Handles the key pressed and released events on the wrapped text * widget. This makes sure to either add the pressed key to the * temporary key stroke, or complete the current temporary key stroke * and prompt for the next. In the case of a key release, this makes * sure that the temporary stroke is correctly displayed -- * corresponding with modifier keys that may have been released. * * @param event * The triggering event; must not be <code>null</code>. */ @Override public void handleEvent(Event event) { KeyStroke[] keyStrokes = getKeySequence().getKeyStrokes(); // Dispatch the event to the correct handler. if (event.type == SWT.KeyDown) { keyStrokes = handleKeyDown(event, keyStrokes); } else if (event.type == SWT.KeyUp) { keyStrokes = handleKeyUp(event, keyStrokes); } // Update the underlying widget. setKeySequence(KeySequence.getInstance(keyStrokes)); // Prevent the event from reaching the widget. event.doit = false; }
final KeyStroke[] oldKeyStrokes = getKeySequence() .getKeyStrokes(); final int newKeyStrokesLength = oldKeyStrokes.length - 1;
final KeyStroke[] oldKeyStrokes = getKeySequence() .getKeyStrokes(); final int newKeyStrokesLength = oldKeyStrokes.length - 1;
final KeyStroke[] oldKeyStrokes = getKeySequence() .getKeyStrokes(); final int newKeyStrokesLength = oldKeyStrokes.length - 1;
/** * Handles the key pressed and released events on the wrapped text * widget. This makes sure to either add the pressed key to the * temporary key stroke, or complete the current temporary key stroke * and prompt for the next. In the case of a key release, this makes * sure that the temporary stroke is correctly displayed -- * corresponding with modifier keys that may have been released. * * @param event * The triggering event; must not be <code>null</code>. */ @Override public void handleEvent(Event event) { KeyStroke[] keyStrokes = getKeySequence().getKeyStrokes(); // Dispatch the event to the correct handler. if (event.type == SWT.KeyDown) { keyStrokes = handleKeyDown(event, keyStrokes); } else if (event.type == SWT.KeyUp) { keyStrokes = handleKeyUp(event, keyStrokes); } // Update the underlying widget. setKeySequence(KeySequence.getInstance(keyStrokes)); // Prevent the event from reaching the widget. event.doit = false; }
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes;
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes;
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes;
.addPropertyChangeListener(event -> { if (!event.getOldValue().equals(event.getNewValue())) { final KeySequence keySequence = fKeySequenceText.getKeySequence(); if (!keySequence.isComplete()) { return;