org.eclipse.swt.events.VerifyEvent Java Examples
The following examples show how to use
org.eclipse.swt.events.VerifyEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YesNoMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Read a yes or no string * * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#charEvent(org.eclipse.swt.events.VerifyEvent) */ protected void charEvent(VerifyEvent event) { event.doit = false; switch (event.character) { case 0x0D: // CR - execute command (if complete) \r case 0x1B: // ESC - another way to leave case 0x08: // BS case 0x7F: // DEL super.charEvent(event); break; default: if (immediately && (YESORNO_Y.equalsIgnoreCase(String.valueOf(event.character)) || YESORNO_N.equalsIgnoreCase(String.valueOf(event.character) ))) { // respond immediately to a character super.charEvent(event); executeCR(event); } else if (!immediately && Character.isLetter(event.character) && ((event.stateMask & SWT.MODIFIER_MASK) == 0)) { // accept if plain letter super.charEvent(event); } else { beep(); } } }
Example #2
Source File: ExecutingMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * charEvent fragment: only allow numbers or edits & escapes * @param event */ protected void numCharEvent(VerifyEvent event) { event.doit = false; switch (event.character) { case 0x0D: // CR - execute command (if complete) \r case 0x1B: // ESC - another way to leave case 0x08: // BS case 0x7F: // DEL super.charEvent(event); break; default: if (checkAlt(event)) { // enable history events if (dispatchAlt(event)) { event.doit = false; break; } } else if ((Character.isDigit(event.character) && ((event.stateMask & SWT.MODIFIER_MASK) == 0)) || ('-' == event.character)) { // accept if plain number or minus super.charEvent(event); } else { beep(); } } }
Example #3
Source File: MyVerifyListener.java From CogniCrypt with Eclipse Public License 2.0 | 6 votes |
@Override public void verifyText(final VerifyEvent e) { { final String currentText = ((Text) e.widget).getText(); final String port = currentText.substring(0, e.start) + e.text + currentText.substring(e.end); try { final int portNum = Integer.valueOf(port); if (portNum < 0 || portNum > 65535) { e.doit = false; } } catch (final NumberFormatException ex) { if (!port.equals("")) { e.doit = false; } } } }
Example #4
Source File: WithMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
protected void handleKey(VerifyEvent event) { try { if (!event.doit) return; if (event.character != 0) { // process typed character charEvent(event); } else { // some other key down noCharEvent(event); } } catch (Exception e) { System.out.println(e); e.printStackTrace(); } finally { setLastKeyCode(event.keyCode); } }
Example #5
Source File: SWTUtil.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent) */ @Override public void verifyText(VerifyEvent e) { boolean doit = true; // only let digits pass (and del, backspace) if (!(Character.isDigit(e.character) || e.character == SWT.DEL || e.character == SWT.BS)) { doit = false; } // check if inserted text is an integer if (!doit) { try { Integer.parseInt(e.text); doit = true; } catch (NumberFormatException ex) { doit = false; } } e.doit = doit; if (!e.doit) { Display.getCurrent().beep(); } }
Example #6
Source File: HistoryMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Handle the history navigation commands (via arrow keys) * * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#noCharEvent(org.eclipse.swt.events.VerifyEvent) */ protected void noCharEvent(VerifyEvent event) { switch (event.keyCode) { case NEXT_ARROW: historyChange(event,YankRotate.BACKWARD); event.doit = false; break; case PREV_ARROW: historyChange(event,YankRotate.FORWARD); event.doit = false; break; default: super.noCharEvent(event); break; } }
Example #7
Source File: KbdMacroExecuteHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) */ public void verifyKey(VerifyEvent event) { // ignore the stateMask keyCodes, otherwise require a match if (!isSpecial(event.keyCode)) { // A real (user) key event must have happened if (event.keyCode != keyCode || event.stateMask != stateMask) { event.doit = false; // short circuit and beep setInterrupted(true); Beeper.beep(); // this will notify } else { // detect kbd macro key event clearKeyEvent(); notifyLock(); PlatformUI.getWorkbench().getDisplay().post(upEvent(event)); } } }
Example #8
Source File: ValueCombo.java From birt with Eclipse Public License 1.0 | 6 votes |
public void verifyText( VerifyEvent e ) { // TODO Auto-generated method stub // System.out.print( "Verify Listener is involved.\n" ); selected = false; String eText = e.text; ValueCombo combo = (ValueCombo) e.widget; if ( combo.indexOf( eText ) >= 0 ) { selected = true; if ( combo.indexOf( combo.getText( ) ) < 0 ) { oldValueList.add( combo.getText( ) ); shouldClearValues = false; shouldSaveValue = false; } return; } if ( !eText.equals( "" ) ) { shouldClearValues = true; shouldSaveValue = true; } }
Example #9
Source File: ConfigurableCompletionProposal.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) { if (event.character == '\0') return null; for (char c: exitCharacters) { if (event.character == c) { return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false); } } switch (event.character) { case SWT.CR: return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false); default: return null; } }
Example #10
Source File: SearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#handleKey(org.eclipse.swt.events.VerifyEvent) */ @Override protected void handleKey(VerifyEvent event) { boolean isQuoting = quoting; try { if (isQuoting) { event.data = QUOTING; } if (event.keyCode != SWT.ALT) { // ignore naked alt setYanked(false); } setSearching(true); super.handleKey(event); } finally { if (isQuoting){ quoting = false; } setWasYanked(yanked); setSearching(false); } }
Example #11
Source File: SearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
protected boolean dispatchAlt(VerifyEvent event) { boolean result = false; switch (event.keyCode) { case YANK: // yank (or yank pop) killed text onto end of search string and search for it. switch(search_exit_option) { case t: yankStr(isGnuYankCommands()); result = true; event.doit = false; break; case nil: quoting = true; result = true; break; case disable: result = super.dispatchCtrl(event); break; } break; default: result = super.dispatchAlt(event); } return result; }
Example #12
Source File: UniversalMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
private boolean isUniversalKey(VerifyEvent event) { boolean result = false; if (result= (event.character == triggerChar && event.stateMask == triggerMask)) { if (triggerChar == '-') { uprefix = getTrigger(event.keyCode,event.stateMask); result = false; } else if (result = (event.character == uTriggerChar && (event.stateMask & SWT.MODIFIER_MASK) == uTriggerMask)) { // the universal reset value uprefix = getTrigger(event.keyCode,event.stateMask); } } else if (triggerMask == 0) { // likely invoked by M-x universal-argument or from kbd macro if (result = (event.character == uTriggerChar && (event.stateMask & SWT.MODIFIER_MASK) == uTriggerMask)){ updatePrefix(' '); } } return result; }
Example #13
Source File: BracketInserter.java From texlipse with Eclipse Public License 1.0 | 6 votes |
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { if (fSize == fStack.size() && !isMasked(offset)) { if (event.character == fExitCharacter) { BracketLevel level= (BracketLevel) fStack.peek(); if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset) return null; if (level.fSecondPosition.offset == offset && length == 0) // don't enter the character if if its the closing peer return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false); } // when entering an anonymous class between the parenthesis', we don't want // to jump after the closing parenthesis when return is pressed if (event.character == SWT.CR && offset > 0) { IDocument document= sourceViewer.getDocument(); try { if (document.getChar(offset - 1) == '{') return new ExitFlags(ILinkedModeListener.EXIT_ALL, true); } catch (BadLocationException e) { } } } return null; }
Example #14
Source File: SearchReplaceMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#dispatchAltCtrl(org.eclipse.swt.events.VerifyEvent) */ protected boolean dispatchAltCtrl(VerifyEvent event) { boolean result = false; switch(state) { case Query: // only when building search string result = super.dispatchAltCtrl(event,true); break; case Replace: case Search: default: finish(); break; } return result; }
Example #15
Source File: ContentAssistant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Verifies key events by notifying the registered listeners. Each listener is allowed to indicate that the * event has been handled and should not be further processed. * * @param e * the verify event * @see VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) */ public void verifyKey(VerifyEvent e) { IContentAssistListener[] listeners = fListeners.clone(); for (int i = 0; i < listeners.length; i++) { if (listeners[i] != null) { if (!listeners[i].verifyKey(e) || !e.doit) { break; } } } if (fAutoAssistListener != null) { fAutoAssistListener.keyPressed(e); } }
Example #16
Source File: ISearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#dispatchCtrl(org.eclipse.swt.events.VerifyEvent) */ @Override protected boolean dispatchCtrl(VerifyEvent event) { boolean result = true; switch (checkKeyCode(event)) { case FORWARD: forwardSearch(); break; case REVERSE: reverseSearch(); break; default: result = super.dispatchCtrl(event); } return result; }
Example #17
Source File: OpenTagCloser.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Allows quick return if we happen to be in a partition where we don't want auto-closed tags. Currently will only * auto-close when in HTML partitions. * * @param document * @param offset * @param event * @return */ protected boolean shouldAutoClose(IDocument document, int offset, VerifyEvent event) { // Only auto-close XML Tags ITypedRegion partition = document.getDocumentPartitioner().getPartition(offset - 1); if (partition != null) { if (!validPartition(partition)) { return false; } try { int length = Math.min(partition.getLength(), offset - partition.getOffset()); String tagContents = document.get(partition.getOffset(), length); return !inString(tagContents, length); } catch (BadLocationException e) { IdeLog.logError(XMLPlugin.getDefault(), e); } } return false; }
Example #18
Source File: ISearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#dispatchAlt(org.eclipse.swt.events.VerifyEvent) */ protected boolean dispatchAlt(VerifyEvent event) { boolean result = true; switch (checkKeyCode(event)) { case FORWARD: forwardSearch(); break; case REVERSE: reverseSearch(); break; case CASE: toggleCase(super.isCaseSensitive()); break; default: result = super.dispatchAlt(event); } return result; }
Example #19
Source File: ExitPolicy.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { if (shouldInsertNewline()) { if (event.character == '\n' || event.character == '\r') { return new ExitFlags(ILinkedModeListener.EXIT_ALL, true); } } if (event.character != fExitCharacter) return null; if (fSize == fStack.size() && !isEscaped(offset)) { BracketLevel level = fStack.peek(); if (offset < level.fFirstPosition.offset || level.fSecondPosition.offset < offset) return null; if (level.fSecondPosition.offset == offset && length == 0) // don't enter the character if it is the closing peer return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false); } return null; }
Example #20
Source File: CompilationUnitEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { if (fSize == fStack.size() && !isMasked(offset)) { if (event.character == fExitCharacter) { BracketLevel level= fStack.peek(); if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset) return null; if (level.fSecondPosition.offset == offset && length == 0) // don't enter the character if if its the closing peer return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false); } // when entering an anonymous class between the parenthesis', we don't want // to jump after the closing parenthesis when return is pressed if (event.character == SWT.CR && offset > 0) { IDocument document= getSourceViewer().getDocument(); try { if (document.getChar(offset - 1) == '{') return new ExitFlags(ILinkedModeListener.EXIT_ALL, true); } catch (BadLocationException e) { } } } return null; }
Example #21
Source File: SearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#noCharEvent(org.eclipse.swt.events.VerifyEvent) */ protected void noCharEvent(VerifyEvent event) { switch (event.keyCode) { // remove minimal support for in line editing case SWT.HOME: case SWT.END: case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.PAGE_DOWN: case SWT.PAGE_UP: // Since we've disabled the key filter force the action by // disabling the key, and calling the command directly // since Mac doesn't handle simple resendEvent well event.doit = false; ITextEditor ed= this.getEditor(); leave(); executeBinding(ed, event.stateMask, event); break; default: super.noCharEvent(event); break; } }
Example #22
Source File: RenameLinkedMode.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { showPreview = (event.stateMask & SWT.CTRL) != 0 && (event.character == SWT.CR || event.character == SWT.LF); if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) { LinkedPosition position = model.findPosition(new LinkedPosition(document, offset, 0, LinkedPositionGroup.NO_STOP)); if (position != null) { if (event.character == SWT.BS) { if (offset - 1 < position.getOffset()) { // skip backspace at beginning of linked position event.doit = false; } } else /* event.character == SWT.DEL */{ if (offset + 1 > position.getOffset() + position.getLength()) { // skip delete at end of linked position event.doit = false; } } } } return null; // don't change behavior }
Example #23
Source File: ISearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#handleKey(org.eclipse.swt.events.VerifyEvent) */ @Override protected void handleKey(VerifyEvent event) { // ensure flag is only enabled for one round // to allow CR after history update if (!isSpecial(event) && (checkHistoryUpdated = historyUpdated)) { setHistoryUpdated(false); } super.handleKey(event); }
Example #24
Source File: WithMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Default handler for Ctrl+<X> and Alt+<X> verify key events * Look for a binding and send it if bound, and leave * * @param event * @return true (always leave) */ protected boolean defaultDispatch(VerifyEvent event) { // default behavior queue binding and leaves ITextEditor ed = editor; leave(); executeBinding(ed,event); return true; }
Example #25
Source File: ISearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
protected void addIt(VerifyEvent event, boolean searcher) { try { isAdding = true; super.addIt(event, searcher); } finally { isAdding = false; updateStatusLine(); } }
Example #26
Source File: CompletionMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * When searching, remove a character from the search string * * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#backSpaceChar(org.eclipse.swt.events.VerifyEvent) */ protected void backSpaceChar(VerifyEvent event) { if (isSearching) { int index = searchStr.length(); if (index > 0) { searchStr.deleteCharAt(index-1); updateSearch(); } else { beep(); } event.doit = false; } else { super.backSpaceChar(event); } }
Example #27
Source File: IPAddressFormatter.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void verifyText(VerifyEvent e) { if (ignore) return; e.doit = false; // when knocking backspace or delete key,the caret should be have a different action // so there are two clear functions if (e.keyCode == SWT.BS) { e.start = bspaceClear(e.start, e.end); } else if (e.keyCode == SWT.DEL) { e.start = delClear(e.start, e.end); } else { e.start = insert(e.text, e.start); } updateText(inputCache.toString(), e.start); }
Example #28
Source File: CompletionMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Support ^s and ^r for searching within buffer list and ^g to break out of search * * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#dispatchCtrl(org.eclipse.swt.events.VerifyEvent) */ @Override protected boolean dispatchCtrl(VerifyEvent event) { boolean result = false; switch (event.keyCode) { case 's': forwardSearch(); break; case 'r': backwardSearch(); break; case 'k': // revert to initial state resetSearch(); break; case 'g': if (isSearching) { resetSearch(); break; } // otherwise, ^g interrupts default: leave(); result = true; } return result; }
Example #29
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates the controls for the type name field. Expects a <code>GridLayout</code> with at * least 2 columns. * * @param composite the parent composite * @param nColumns number of columns to span */ protected void createTypeNameControls(Composite composite, int nColumns) { fTypeNameDialogField.doFillIntoGrid(composite, nColumns - 1); DialogField.createEmptySpace(composite); Text text= fTypeNameDialogField.getTextControl(null); LayoutUtil.setWidthHint(text, getMaxFieldWidth()); TextFieldNavigationHandler.install(text); text.addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { if (fCanModifyPackage && ! fEnclosingTypeSelection.isSelected() && e.start == 0 && e.end == ((Text) e.widget).getCharCount()) { String typeNameWithoutParameters= getTypeNameWithoutParameters(e.text); int lastDot= typeNameWithoutParameters.lastIndexOf('.'); if (lastDot == -1 || lastDot == typeNameWithoutParameters.length() - 1) return; String pack= typeNameWithoutParameters.substring(0, lastDot); if (validatePackageName(pack, null).getSeverity() == IStatus.ERROR) return; fPackageDialogField.setText(pack); e.text= e.text.substring(lastDot + 1); } } }); }
Example #30
Source File: StyledTextCellEditor.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void verifyKey(VerifyEvent event) { NattableUtil.refreshCommand(AddSegmentToTMPropertyTester.PROPERTY_NAMESPACE, AddSegmentToTMPropertyTester.PROPERTY_ENABLED); NattableUtil.refreshCommand(SignOffPropertyTester.PROPERTY_NAMESPACE, SignOffPropertyTester.PROPERTY_ENABLED); NattableUtil.refreshCommand(UnTranslatedPropertyTester.PROPERTY_NAMESPACE, UnTranslatedPropertyTester.PROPERTY_ENABLED); }