/** * 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()); } }
/** * Clears the text field and resets all the internal values. */ public void clear() { final KeySequence oldKeySequence = keySequence; keySequence = KeySequence.getInstance(); text.setText(EMPTY_STRING); firePropertyChangeEvent(oldKeySequence); }
/** * Tests whether the cursor is in the last position. This means that the * selection extends to the last position. * * @return <code>true</code> if the selection extends to the last * position; <code>false</code> otherwise. */ private boolean isCursorInLastPosition() { return (text.getSelection().y >= getText().length()); }
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes; if ((hasIncompleteStroke()) && (!keySequence.isEmpty())) { final int newKeyStrokesLength = oldKeyStrokes.length - 1; newKeyStrokes = new KeyStroke[newKeyStrokesLength]; int index = deleteSelection(newKeyStrokes, false, deletedKeyStrokes); if (index == -1) { index = 0; final KeyStroke[] keyStrokes = insertStrokeAt(newKeyStrokes, stroke, index); keyFilter.clearInsertionIndex(); setKeySequence(KeySequence.getInstance(keyStrokes));
fKeySequenceText = new KeySequenceText(fBindingText); fKeySequenceText.setKeyStrokeLimit(4); fKeySequenceText .addPropertyChangeListener(event -> { if (!event.getOldValue().equals(event.getNewValue())) { final KeySequence keySequence = fKeySequenceText.getKeySequence(); if (!keySequence.isComplete()) { return; menuItem.setText(trappedKey.format()); menuItem.addSelectionListener(widgetSelectedAdapter(e -> { fKeySequenceText.insert(trappedKey); fBindingText.setFocus(); fBindingText.setSelection(fBindingText.getTextLimit()); KeySequence trigger = (KeySequence) bindingElement .getTrigger(); fKeySequenceText.setKeySequence(trigger);
String currentString = getText(); String newString = keySequence.format(); if (!currentString.equals(newString)) { text.setText(keySequence.format()); text.addModifyListener(updateSequenceListener); text.setSelection(getText().length()); firePropertyChangeEvent(oldKeySequence);
/** * Returns the current trigger sequence. * * @return The trigger sequence; may be empty, but never <code>null</code>. */ private KeySequence getKeySequence() { return textTriggerSequenceManager.getKeySequence(); }
/** * Sets the current trigger sequence. * * @param keySequence * The trigger sequence; may be <code>null</code>. */ private void setKeySequence(final KeySequence keySequence) { textTriggerSequenceManager.setKeySequence(keySequence); }
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes; if ((hasIncompleteStroke()) && (!keySequence.isEmpty())) { final int newKeyStrokesLength = oldKeyStrokes.length - 1; newKeyStrokes = new KeyStroke[newKeyStrokesLength]; int index = deleteSelection(newKeyStrokes, false, deletedKeyStrokes); if (index == -1) { index = 0; final KeyStroke[] keyStrokes = insertStrokeAt(newKeyStrokes, stroke, index); keyFilter.clearInsertionIndex(); setKeySequence(KeySequence.getInstance(keyStrokes));
String currentString = getText(); String newString = keySequence.format(); if (!currentString.equals(newString)) { text.setText(keySequence.format()); text.addModifyListener(updateSequenceListener); text.setSelection(getText().length()); firePropertyChangeEvent(oldKeySequence);
/** * 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); } } }
final KeySequence keySequence = getKeySequence(); final KeyStroke[] oldKeyStrokes = keySequence.getKeyStrokes(); final KeyStroke[] newKeyStrokes; if ((hasIncompleteStroke()) && (!keySequence.isEmpty())) { final int newKeyStrokesLength = oldKeyStrokes.length - 1; newKeyStrokes = new KeyStroke[newKeyStrokesLength]; int index = deleteSelection(newKeyStrokes, false, deletedKeyStrokes); if (index == -1) { index = 0; final KeyStroke[] keyStrokes = insertStrokeAt(newKeyStrokes, stroke, index); keyFilter.clearInsertionIndex(); setKeySequence(KeySequence.getInstance(keyStrokes));
/** * 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()); } }
String currentString = getText(); String newString = keySequence.format(); if (!currentString.equals(newString)) { text.setText(keySequence.format()); text.addModifyListener(updateSequenceListener); text.setSelection(getText().length()); firePropertyChangeEvent(oldKeySequence);
/** * 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); } } }
/** * Clears the text field and resets all the internal values. */ public void clear() { final KeySequence oldKeySequence = keySequence; keySequence = KeySequence.getInstance(); text.setText(EMPTY_STRING); firePropertyChangeEvent(oldKeySequence); }
/** * Tests whether the cursor is in the last position. This means that the * selection extends to the last position. * * @return <code>true</code> if the selection extends to the last * position; <code>false</code> otherwise. */ private boolean isCursorInLastPosition() { return (text.getSelection().y >= getText().length()); }
/** * 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 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); } } }
/** * Clears the text field and resets all the internal values. */ public void clear() { final KeySequence oldKeySequence = keySequence; keySequence = KeySequence.getInstance(); text.setText(EMPTY_STRING); firePropertyChangeEvent(oldKeySequence); }