Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 5864 Details for
Bug 42024
KeySequenceText should have API to limit number of key strokes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for KeysPreferencePage and KeySequenceText
org.eclipse.ui.workbench-Bug42024.patch (text/plain), 6.31 KB, created by
Douglas Pollock
on 2003-08-26 17:28:50 EDT
(
hide
)
Description:
Patch for KeysPreferencePage and KeySequenceText
Filename:
MIME Type:
Creator:
Douglas Pollock
Created:
2003-08-26 17:28:50 EDT
Size:
6.31 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/commands/KeysPreferencePage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/commands/KeysPreferencePage.java,v >retrieving revision 1.19 >diff -u -r1.19 KeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/commands/KeysPreferencePage.java 26 Aug 2003 21:21:29 -0000 1.19 >+++ Eclipse UI/org/eclipse/ui/internal/commands/KeysPreferencePage.java 26 Aug 2003 21:25:35 -0000 >@@ -607,6 +607,7 @@ > gridData.horizontalSpan = 2; > gridData.widthHint = 300; > textKeySequence.setLayoutData(gridData); >+ textKeySequence.setMaxStrokes(4); > > textKeySequence.addModifyListener(new ModifyListener() { > public void modifyText(ModifyEvent e) { >Index: Eclipse UI/org/eclipse/ui/internal/keys/KeySequenceText.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/KeySequenceText.java,v >retrieving revision 1.7 >diff -u -r1.7 KeySequenceText.java >--- Eclipse UI/org/eclipse/ui/internal/keys/KeySequenceText.java 25 Aug 2003 22:03:39 -0000 1.7 >+++ Eclipse UI/org/eclipse/ui/internal/keys/KeySequenceText.java 26 Aug 2003 21:25:36 -0000 >@@ -37,10 +37,18 @@ > */ > public final class KeySequenceText { > >+ /** >+ * The special integer value for the maximum number of strokes indicating >+ * that an infinite number should be allowed. >+ */ >+ public static final int INFINITE = -1; > /** An empty string instance for use in clearing text values. */ > private static final String EMPTY_STRING = ""; //$NON-NLS-1$ >+ > /** The text of the key sequence -- containing only the complete key strokes. */ > private KeySequence keySequence = null; >+ /** The maximum number of key strokes permitted in the sequence. */ >+ private int maxStrokes = INFINITE; > /** The incomplete key stroke, if any. */ > private KeyStroke temporaryStroke = null; > /** The text widget that is wrapped for this class. */ >@@ -56,12 +64,12 @@ > public KeySequenceText(final Composite composite) { > // Set up the text field. > text = new Text(composite, SWT.BORDER); >- >+ > /* TODO doug: pls. investigate. works until one backspaces to an empty text field, at which point the font gets changed somehow > if ("carbon".equals(SWT.getPlatform())) { > // don't worry about this font name here, it is the official menu font and point size on the mac. > final Font font = new Font(text.getDisplay(), "Lucida Grande", 13, SWT.NORMAL); //$NON-NLS-1$ >- >+ > text.addDisposeListener(new DisposeListener() { > public void widgetDisposed(DisposeEvent e) { > font.dispose(); >@@ -142,18 +150,17 @@ > } > > /** >- * A mutator for the layout information associated with the wrapped widget. >- * @param layoutData The layout information; must not be <code>null</code>. >- */ >- public final void setLayoutData(final Object layoutData) { >- text.setLayoutData(layoutData); >- } >- >- /** >+ * <p> > * A mutator for the key sequence and incomplete stroke stored within this > * widget. This does some checking to see if the incomplete stroke is > * really incomplete; if it is complete, then it is rolled into the key > * sequence. The text and caret position are updated. >+ * </p> >+ * <p> >+ * All sequences are limited to maxStrokes number of strokes in length. >+ * If there are already that number of strokes, then it does not show >+ * incomplete strokes, and does not keep track of them. >+ * </p> > * > * @param newKeySequence The new key sequence for this widget; may be > * <code>null</code> if none. >@@ -164,16 +171,42 @@ > // Figure out whether the stroke should be rolled in. > if (isComplete(incompleteStroke)) { > if (newKeySequence == null) { >+ // This is guaranteed to be possible by setMaxStrokes > keySequence = KeySequence.getInstance(incompleteStroke); > } else { > final List keyStrokes = new ArrayList(newKeySequence.getKeyStrokes()); > keyStrokes.add(incompleteStroke); >+ if (maxStrokes != INFINITE) { >+ final int keyStrokesSize = keyStrokes.size(); >+ for (int i = keyStrokesSize - 1; i >= maxStrokes; i--) { >+ keyStrokes.remove(i); >+ } >+ } > keySequence = KeySequence.getInstance(keyStrokes); > } > temporaryStroke = null; > } else { >- keySequence = newKeySequence; >- temporaryStroke = incompleteStroke; >+ if ((newKeySequence != null) && (maxStrokes != INFINITE)) { >+ final List untrimmedKeyStrokes = newKeySequence.getKeyStrokes(); >+ final int keyStrokesSize = untrimmedKeyStrokes.size(); >+ if (keyStrokesSize > maxStrokes) { >+ final List keyStrokes = new ArrayList(untrimmedKeyStrokes); >+ for (int i = keyStrokesSize - 1; i >= maxStrokes; i--) { >+ keyStrokes.remove(i); >+ } >+ keySequence = KeySequence.getInstance(keyStrokes); >+ temporaryStroke = null; >+ } else if (keyStrokesSize == maxStrokes) { >+ keySequence = newKeySequence; >+ temporaryStroke = null; >+ } else { >+ keySequence = newKeySequence; >+ temporaryStroke = incompleteStroke; >+ } >+ } else { >+ keySequence = newKeySequence; >+ temporaryStroke = incompleteStroke; >+ } > } > > /* Create a dummy (and rather invalid) sequence to get localized display >@@ -195,10 +228,31 @@ > dummySequence = KeySequence.getInstance(keyStrokes); > } > >- text.setText(/* TODO "carbon".equals(SWT.getPlatform()) ? KeySupport.formatCarbon(dummySequence) : */ dummySequence.format()); >+ text.setText(/* TODO "carbon".equals(SWT.getPlatform()) ? KeySupport.formatCarbon(dummySequence) : */ >+ dummySequence.format()); > > // Update the caret position. > text.setSelection(text.getText().length()); >+ } >+ >+ /** >+ * A mutator for the layout information associated with the wrapped widget. >+ * @param layoutData The layout information; must not be <code>null</code>. >+ */ >+ public final void setLayoutData(final Object layoutData) { >+ text.setLayoutData(layoutData); >+ } >+ >+ /** >+ * A mutator for the maximum number of strokes that are permitted in this >+ * widget at one time. >+ * @param maximumStrokes The maximum number of strokes; should be a positive >+ * integer or <code>INFINITE</code>. >+ */ >+ public final void setMaxStrokes(final int maximumStrokes) { >+ if ((maximumStrokes > 0) || (maximumStrokes == INFINITE)) { >+ maxStrokes = maximumStrokes; >+ } > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 42024
: 5864