Java Code Examples for org.eclipse.swt.SWT#TAB

The following examples show how to use org.eclipse.swt.SWT#TAB . These examples are extracted from open source projects. 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 Project: nebula   File: Day.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void keyPressed(KeyEvent e) {
	switch (e.keyCode) {
		case SWT.ARROW_LEFT:
			if (monthPosition.x > 0) {
				traverse(SWT.TRAVERSE_TAB_PREVIOUS);
			}
			return;
		case SWT.ARROW_RIGHT:
			if (monthPosition.x < 6) {
				traverse(SWT.TRAVERSE_TAB_NEXT);
			}
			return;
		case SWT.TAB:
			if ((e.stateMask & SWT.SHIFT) != 0) {
				traverse(SWT.TRAVERSE_TAB_PREVIOUS);
				return;
			}
			traverse(SWT.TRAVERSE_TAB_NEXT);
			return;
	}
}
 
Example 2
private boolean isModifierKey(int keyCode)
{
	// TODO Add more non alphanumeric keys we should skip!
	switch (keyCode)
	{
		case SWT.SHIFT:
		case SWT.BS:
		case SWT.CR:
		case SWT.DEL:
		case SWT.ESC:
		case SWT.LF:
		case SWT.TAB:
		case SWT.CTRL:
		case SWT.COMMAND:
		case SWT.ALT:
		case SWT.ARROW_DOWN:
		case SWT.ARROW_LEFT:
		case SWT.ARROW_RIGHT:
		case SWT.ARROW_UP:
			return true;
	}
	return false;
}
 
Example 3
/**
 * Java name space names verify key checks for java identifier and periods.
 *
 * @param event the event
 * @return true, if successful
 */
@Override
public boolean verifyKeyChecks(VerifyEvent event) {
  if (event.keyCode == SWT.CR || event.keyCode == SWT.TAB)
    return true;
  if (Character.isJavaIdentifierPart(event.character))
    return true;
  StyledText w = (StyledText) event.widget;
  String text = w.getText();
  int len = text.length();
  if (event.character == '.') {
    if (len == 0)
      return false;
    return true;
  }
  return false;
}
 
Example 4
Source Project: birt   File: CustomPreviewTable.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void keyTraversed( TraverseEvent e )
{
	if ( e.character != SWT.TAB )
	{
		e.doit = false;
	}
}
 
Example 5
Source Project: e4macs   File: StrictMinibuffer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Read a string that must be one of the candidate strings
 * 
 * @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;
		case ' ': //
			handleCompleting(event);
			break;
		case SWT.TAB:
			if (handlesTab()) {
				handleCompleting(event);
				break;
			}
		default:
			if (checkControl(event)) {
				if (dispatchCtrl(event)) {
					event.doit = false;
					break;
				}
			} else if (Character.isLetter(event.character) && ((event.stateMask & SWT.MODIFIER_MASK) == 0)
					&& (canBeCandidate(getMBString() + event.character))) {
				super.charEvent(event);
			} else {
				beep();
			}
	}
}
 
Example 6
/**
 * Called for many widgets.
 *
 * @param event the event
 * @return true, if successful
 */
@Override
public boolean verifyKeyChecks(VerifyEvent event) {
  if (event.keyCode == SWT.CR || event.keyCode == SWT.TAB)
    return true;

  if (Character.isJavaIdentifierPart(event.character) || event.character == '.')
    return true;

  if ((event.widget == xrUrlUI || event.widget == xrUrlSuffixUI)
          && (event.character == '/' || event.character == ':'))
    return true;
  return false;
}
 
Example 7
Source Project: uima-uimaj   File: AddFeatureDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean verifyKeyChecks(VerifyEvent event) {
  if (event.keyCode == SWT.CR || event.keyCode == SWT.TAB)
    return true;
  if (Character.isJavaIdentifierPart(event.character))
    return true;
  if (event.widget == featureRangeNameUI && event.character == '.')
    return true;
  return false;
}
 
Example 8
Source Project: uima-uimaj   File: AddSofaDialog.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean verifyKeyChecks(VerifyEvent event) {
  if (event.keyCode == SWT.CR || event.keyCode == SWT.TAB)
    return true;
  if (Character.isJavaIdentifierPart(event.character) ||
      event.character == '*' ||
      event.character == '.')
    return true;
  return false;
}
 
Example 9
/**
     * Handle any key presses.
     * 
     * @param event key event
     */
    private void handleKeyPressed(KeyEvent event) {
        if ((event.stateMask & SWT.SHIFT) != 0 && Character.isISOControl(event.character)) {
            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                selectRight();
                break;
            case SWT.ARROW_LEFT:
                selectLeft();
                break;
            case SWT.ARROW_DOWN:
                selectDown();
                break;
            case SWT.ARROW_UP:
                selectUp();
                break;

            default:
                // do nothing
                break;
            }
        } else if ((event.stateMask & SWT.CONTROL) != 0 && Character.isISOControl(event.character)) {
            // TODO keybindings hard coded is ok for now
            // System.out.println("keycode "+event.keyCode);
            switch (event.keyCode) {
            case 'c':
                copy();
                break;
            case 'x':
                cut();
                break;
            case 'v':
                paste();
                break;
            case 'a':
                selectAll();
                break;

            default:
                // do nothing
                break;
            }

        } else {
            _lastKeySelect = null;
            _firstKeySelect = null;

            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                focusRight();
                break;
            case SWT.ARROW_LEFT:
                focusLeft();
                break;
            case SWT.ARROW_DOWN:
                focusDown();
                break;
            case SWT.ARROW_UP:
                focusUp();
                break;
            case SWT.TAB:
                focusRight();
                break;
            case SWT.F2:
//                startEditing(_focussedRow, _focussedColumn, (char) 0);
                break;

            default:
                if (event.character == ' ' && isHierarchyColumn(_focussedRow, _focussedColumn)) {
                    toggleExpanded(_focussedRow);
                } else if (!Character.isISOControl(event.character)) {
//                    startEditing(event.character);
                }
                // do nothing
                break;
            }
        }

    }
 
Example 10
/**
     * Handle any key presses.
     * 
     * @param event key event
     */
    private void handleKeyPressed(KeyEvent event) {
        if ((event.stateMask & SWT.SHIFT) != 0 && Character.isISOControl(event.character)) {
            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                selectRight();
                break;
            case SWT.ARROW_LEFT:
                selectLeft();
                break;
            case SWT.ARROW_DOWN:
                selectDown();
                break;
            case SWT.ARROW_UP:
                selectUp();
                break;

            default:
                // do nothing
                break;
            }
        } else if ((event.stateMask & SWT.CONTROL) != 0 && Character.isISOControl(event.character)) {
            // TODO keybindings hard coded is ok for now
            // System.out.println("keycode "+event.keyCode);
            switch (event.keyCode) {
            case 'c':
                copy();
                break;
            case 'x':
                cut();
                break;
            case 'v':
                paste();
                break;
            case 'a':
                selectAll();
                break;

            default:
                // do nothing
                break;
            }

        } else {
            _lastKeySelect = null;
            _firstKeySelect = null;

            switch (event.keyCode) {
            case SWT.ARROW_RIGHT:
                focusRight();
                break;
            case SWT.ARROW_LEFT:
                focusLeft();
                break;
            case SWT.ARROW_DOWN:
                focusDown();
                break;
            case SWT.ARROW_UP:
                focusUp();
                break;
            case SWT.TAB:
                focusRight();
                break;
            case SWT.F2:
//                startEditing(_focussedRow, _focussedColumn, (char) 0);
                break;

            default:
                if (event.character == ' ' && isHierarchyColumn(_focussedRow, _focussedColumn)) {
                    toggleExpanded(_focussedRow);
                } else if (!Character.isISOControl(event.character)) {
//                    startEditing(event.character);
                }
                // do nothing
                break;
            }
        }

    }
 
Example 11
public void keyPressed( KeyEvent e )
{
	switch ( e.keyCode )
	{
		case SWT.ARROW_DOWN :
			if ( iSelectedIndex < elPaletteEntries1.size( ) - 1 )
			{
				iSelectedIndex++;
				scrollToView( iSelectedIndex );
				coPaletteEntries.redraw( );
			}
			break;
		case SWT.ARROW_UP :
			if ( iSelectedIndex > 0 )
			{
				iSelectedIndex--;
				scrollToView( iSelectedIndex );
				coPaletteEntries.redraw( );
			}
			break;
		case SWT.CR :
			if ( coPaletteEntries.isFocusControl( ) )
			{
				coEditor.setFocus( );
			}
			break;
		case SWT.PAGE_DOWN :
			iSelectedIndex += 8;
			if ( iSelectedIndex > elPaletteEntries1.size( ) )
			{
				iSelectedIndex = elPaletteEntries1.size( ) - 1;
			}
			scrollToView( iSelectedIndex );
			sb.setSelection( sb.getMaximum( )
					* ( iSelectedIndex + 1 )
					/ elPaletteEntries1.size( ) );
			coPaletteEntries.redraw( );
			break;
		case SWT.PAGE_UP :
			iSelectedIndex -= 8;
			if ( iSelectedIndex < 0 )
			{
				iSelectedIndex = 0;
			}
			scrollToView( iSelectedIndex );
			sb.setSelection( sb.getMaximum( )
					* iSelectedIndex
					/ elPaletteEntries1.size( ) );
			coPaletteEntries.redraw( );
			break;
		case SWT.TAB :
			btnAdd.setFocus( );
			break;
		case SWT.ESC :
			this.getShell( ).close( );
			break;
	}
}
 
Example 12
Source Project: e4macs   File: WithMinibuffer.java    License: Eclipse Public License 1.0 4 votes vote down vote up
protected void charEvent(VerifyEvent event) {

		switch (event.character) {

		case 0x0D: // CR - execute command (if complete) \r
			if (isQuoting(event)) {
				event.doit = false;
				dispatchCtrl(event);
				break;
			}
			executeCR(event);
			break;
		case 0x1B: // ESC - another way to leave
			// TODO - could also be ^[
			KbdMacroSupport.getInstance().exitWhenDefining();				
			leave(true);
			event.doit = false;
			break;

		case 0x08: // BS
			backSpaceChar(event);
			break;
		case 0x7F: // DEL
			deleteChar(event);
			break;
		case SWT.TAB: // disable after tab traversal interception
			if (handlesTab()){
				dispatchTab(event);
			}
			event.doit = false;
			break;
			//case '?': // ? completion disabled as its used as a simple wildcard
		case ' ': // space completion
			if (isCompleting()) {
				showCompletions();
				event.doit = false;
				break;
			}
		default:
			// If we're on a mac, then treat ALT & COMMAND the same in the minibuffer
			boolean ismac = isMac();
			// mask away any extraneous modifier characters for any direct equality tests. see SWT.MODIFIER_MASK
			// make ALT and COMMAND behave equivalently on the mac for Ctrl or Alt dispatch
			int sm = event.stateMask & SWT.MODIFIER_MASK;
			if (checkControl(event)) {
				if (dispatchCtrl(event)) {
					event.doit = false;
					break;
				} 
			} else if (checkAlt(event)) {
				if (dispatchAlt(event)) {
					event.doit = false;
					break;
				}
			} else if (checkAltCtrl(event) && dispatchAltCtrl(event)) {
					event.doit = false;
					break;
			} else {
				// SWT.ALT | SWT.CTRL covers AltGraph - used in international keyboards (see Eclipse bug 43049)
				// Also special chars on MacOs (see Eclipse bug 272994)					
				// Although, testing on a mac shows that the Option-<char>, comes in as keyCode == 0 and no modifiers
				boolean special = (ismac ? ((sm == (SWT.ALT | SWT.SHIFT)) || sm == SWT.ALT) : sm == (SWT.ALT | SWT.CTRL));
				// but if the key has a command binding associated, then leave and process 
				if (special && hasBinding(event)) {
					ITextEditor ed = editor;					
					leave();
					executeBinding(ed,event);
					event.doit = false;
				} else if (sm == 0 || sm == SWT.SHIFT || special) {
					event.doit = false;
					if (event.keyCode != 0 || (ismac && event.character != 0)) {
						addIt(event);
					}
				}
			}
		}
	}
 
Example 13
Source Project: uima-uimaj   File: CommonInputDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean verifyKeyChecks(VerifyEvent event) {
  char ch = event.character;

  boolean validateDottedName = ((validation & DOTTED_NAME) == DOTTED_NAME);
  boolean validateSpaces = ((validation & SPACED_NAMES) == SPACED_NAMES);
  boolean validateLanguage = ((validation & LANGUAGE) == LANGUAGE);
  boolean validateAllOK = ((validation & ALLOK) == ALLOK);
  boolean validateTrueFalse = ((validation & TRUE_FALSE) == TRUE_FALSE);
  boolean validateInteger = ((validation & INTEGER) == INTEGER);
  boolean validateFloat = ((validation & FLOAT) == FLOAT);

  if (event.keyCode == SWT.CR || event.keyCode == SWT.TAB || event.keyCode == SWT.BS)
    return true;

  if (validateTrueFalse) {
    return ("truefalse".indexOf(ch) >= 0);
  }

  if (validateSpaces && ch == ' ')
    return true;

  if (validateDottedName && ch == '.')
    return true;

  if ((!validateTrueFalse) && (!validateInteger) && (!validateFloat)
          && Character.isJavaIdentifierPart(ch))
    return true;

  if (validateLanguage && ch == '-')
    return true;

  if (validateAllOK)
    return true;

  if (validateInteger)
    if (Character.isDigit(ch) || ch == '-')
      return true;

  if (validateFloat) {
    if (Character.isDigit(ch) || ch == '-' || ch == 'E' || ch == 'e' || ch == '.')
      return true;
  }
  return false;
}