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

The following examples show how to use org.eclipse.swt.SWT#TRAVERSE_TAB_PREVIOUS . 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
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			focusLost( new FocusEvent( event ) );
			break;

		case SWT.Traverse :
			switch ( event.detail )
			{
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
					// Indicates getting focus control rather than
					// cursor control
					event.doit = true;
					isPressingKey = true;
			}
			break;

	}
}
 
Example 2
private TraverseListener getTraverseListener( )
{
	return new TraverseListener( ) {

		/**
		 * @see org.eclipse.swt.events.TraverseListener#keyTraversed(TraverseEvent)
		 */
		public void keyTraversed( TraverseEvent e )
		{
			if ( e.widget instanceof StyledText )
			{
				if ( ( e.detail == SWT.TRAVERSE_TAB_NEXT )
						|| ( e.detail == SWT.TRAVERSE_TAB_PREVIOUS ) )
					e.doit = true;
			}
		}
	};
}
 
Example 3
/**
 * Handle the keyTraversed event on any child control in the table.
 * 
 * @param sender
 *            The row sending the event.
 * @param e
 *            The SWT TraverseEvent
 */
public void keyTraversed(TableRow sender, TraverseEvent e) {
	if (doMakeFocusedRowVisible()) return;

	if (parent.isTraverseOnTabsEnabled()) {
		if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
			if (currentColumn >= sender.getNumColumns() - 1) {
				e.detail = SWT.TRAVERSE_NONE;
				handleNextRowNavigation();
			}
		} else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
			if (currentColumn == 0) {
				e.detail = SWT.TRAVERSE_NONE;
				handlePreviousRowNavigation(sender);
			}
		} else if (e.detail == SWT.TRAVERSE_RETURN) {
			e.detail = SWT.TRAVERSE_NONE;
			if (currentColumn >= sender.getNumColumns() - 1) {
				handleNextRowNavigation();
			} else {
				deferredSetFocus(getControl(currentColumn + 1, currentRow),
						false);
			}
		}
	} else {
		if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
			if (currentColumn >= sender.getNumColumns() - 1) {
				e.detail = SWT.TRAVERSE_NONE;
			}
		} else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
			if (currentColumn == 0) {
				e.detail = SWT.TRAVERSE_NONE;
			}
		}
	}
}
 
Example 4
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.MouseDown :
		case SWT.Selection :
			doToggleDropDown( );
			break;
		case SWT.KeyDown :
			processKeyDown( event.keyCode );
			break;
		case SWT.Traverse :
			if ( event.detail == SWT.TRAVERSE_TAB_NEXT
					|| event.detail == SWT.TRAVERSE_TAB_PREVIOUS )
			{
				event.doit = true;
			}
			break;
		case SWT.FocusIn :
			view.redraw( );
			break;
		case SWT.FocusOut :
			view.redraw( );
			break;
	}

}
 
Example 5
Source Project: nebula   File: VTracker.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public void handleEvent(Event event) {
	switch (event.type){
	case SWT.Traverse:
		lastTraverse = event.detail;
		if(SWT.TRAVERSE_TAB_NEXT == event.detail || SWT.TRAVERSE_TAB_PREVIOUS == event.detail) {
			if(focusControl != null) {
				event.doit = true;
				focusControl.handleEvent(event);
				if(event.doit) {
					Composite comp = focusControl.getWidget();
					if(SWT.TRAVERSE_TAB_NEXT == event.detail) {
						setFocusToNext(comp);
					} else {
						setFocusToPrev(comp);
					}
				}
			}
		}
		break;
	case SWT.FocusIn:
		setFocusControl(getVControl(event.widget));
		break;
	case SWT.MouseDown:
		mouseButton = event.button;
		mouseDown = new Point(event.x, event.y);
		if(activeControl != null && activeControl.setState(VControl.STATE_MOUSE_DOWN, true)) {
			activeControl.redraw();
		}
		break;
	case SWT.MouseMove:
		if(panels.containsKey(event.widget)) {
			VControl vcontrol = panels.get(event.widget).getControl(event.x, event.y, true);
			if(vcontrol != activeControl && (vcontrol == null || vcontrol.isEnabled())) {
				activate(vcontrol);
			}
		} else if(activeControl != null && event.widget != activeControl.getControl()) {
			activeControl.deactivate();
			activeControl = null;
		}
		break;
	case SWT.MouseUp:
		mouseButton = -1;
		mouseDown = null;
		if(activeControl != null && activeControl.setState(VControl.STATE_MOUSE_DOWN, false)) {
			activeControl.redraw();
		}
		break;
	}
}
 
Example 6
Source Project: nebula   File: CDateTime.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The Travers event handler. Note that ARROW_UP and ARROW_DOWN are handled
 * in the <code>handleKey</code> method.
 * 
 * @param event
 *            the event
 */
void handleTraverse(Event event) {
	boolean allowTimeZoneEdit = this.allowedTimezones != null;

	switch (event.detail) {
	case SWT.TRAVERSE_ARROW_NEXT:
		if (event.keyCode == SWT.ARROW_RIGHT) {
			fieldNext();
		} else if (event.keyCode == SWT.ARROW_DOWN) {
			fieldAdjust(-1);
		}
		break;
	case SWT.TRAVERSE_ARROW_PREVIOUS:
		if (event.keyCode == SWT.ARROW_LEFT) {
			fieldPrev();
		} else if (event.keyCode == SWT.ARROW_UP) {
			fieldAdjust(1);
		}
		break;
	case SWT.CR:
		fieldNext();
		fireSelectionChanged();
		break;
	case SWT.TRAVERSE_TAB_NEXT:
		if (tabStops && hasSelection()) {
			// if we are at the last field, allow the tab out of the control
			// the last field is also considered to be the 2nd to last if
			// the last is a time zone
			// we now check if the control allows time zone editing
			if (activeField == field.length - 1
					|| activeField == field.length - 2
							&& Calendar.ZONE_OFFSET == getCalendarField(
									field[field.length - 1])
							&& !allowTimeZoneEdit) {
				event.doit = true;
			} else {
				event.doit = false;
				if (activeField < 0) {
					fieldPrev();
				} else {
					fieldNext();
				}
			}
		}
		break;
	case SWT.TRAVERSE_TAB_PREVIOUS:
		if (tabStops && hasSelection()) {
			// if we are at the 1st field, allow the tab out of the control
			// the 1st field is also considered to the the 2nd if the 1st
			// is a time zone
			if (activeField == 0 || activeField == 1
					&& Calendar.ZONE_OFFSET == getCalendarField(field[0])
					&& !allowTimeZoneEdit) {
				event.doit = true;
			} else {
				event.doit = false;
				if (activeField < 0) {
					fieldNext();
				} else {
					fieldPrev();
				}
			}
		}
		break;
	default:
	}
}
 
Example 7
boolean handleEditEvent(Event event) {
   if (klickedColumn == null || klickedCell == null) {
      return false;
   }

   final Control c;
   try {
      XViewerColumn xColumn =
         xv.getXViewerFactory().getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
      if (xColumn instanceof ExtendedViewerColumn) {
         ExtendedViewerColumn extendedColumn = (ExtendedViewerColumn) xColumn;
         CellEditDescriptor ced = extendedColumn.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
         if (ced != null) {
            if (ced.getControl() == null) {
               return false;
            }
            if (ced.getAction() != null && !ced.getAction().isEnabled()) {
               return false;
            }
            if (!converter.isValid(ced, klickedCell.getElement())) {
               return false;
            }
            c = factory.createControl(ced, xv);
            if (c == null) {
               return false;
            }
         } else {
            return false;
         }
      } else {
         return false;
      }

      if (((TreeItem) event.item) != null) {
         Listener myListener = e-> {
               switch (e.type) {
                  case SWT.FocusOut:
                     // set new value
                     getInput(c);
                     c.dispose();
                     break;
                  case SWT.Verify:
                     c.setBounds(klickedCell.getBounds());
                     break;
                  case SWT.Traverse:
                     boolean neighbor = false;
                     switch (e.detail) {
                        case SWT.TRAVERSE_RETURN:
                           // set new value
                           getInput(c);
                           //$FALL-THROUGH$
                        case SWT.TRAVERSE_ESCAPE:
                           c.dispose();
                           e.doit = false;
                           break;
                        case SWT.TRAVERSE_TAB_NEXT:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.RIGHT, true);
                           e.doit = false;
                           c.dispose();
                           Event eN = new Event();
                           eN.type = SWT.Selection;
                           eN.widget = xv.getTree();
                           if (neighbor) {
                              eN.item = klickedCell.getItem();
                           }
                           doHandleEvent(eN);
                           break;
                        case SWT.TRAVERSE_TAB_PREVIOUS:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.LEFT, true);
                           e.doit = false;
                           c.dispose();
                           Event eP = new Event();
                           eP.type = SWT.Selection;
                           eP.widget = xv.getTree();
                           if (neighbor) {
                              eP.item = klickedCell.getItem();
                           }
                           doHandleEvent(eP);
                           break;
                     }
               }
         };
         c.addListener(SWT.FocusOut, myListener);
         c.addListener(SWT.Traverse, myListener);
         c.addListener(SWT.Verify, myListener);
         // set old value
         setInput(c);
         c.setFocus();
         return true;
      }
   } catch (Exception ex) {
      return false;
   }
   return false;
}
 
Example 8
@Override
public void keyTraversed(TraverseEvent e) {
    if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
        e.doit = true;
    }
}
 
Example 9
@Override
public void keyTraversed(TraverseEvent e) {
    if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
        e.doit = true;
    }
}
 
Example 10
Source Project: tracecompass   File: SDWidget.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void keyTraversed(TraverseEvent e) {
    if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
        e.doit = true;
    }
}
 
Example 11
@Override
public void keyTraversed(TraverseEvent e) {
    if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS)) {
        e.doit = true;
    }
}
 
Example 12
void handleEventCanvas( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.KEYPAD_CR
					|| event.keyCode == SWT.CR
					|| event.keyCode == ' ' )
			{
				event.doit = true;
				toggleDropDown( );
			}
			break;
		}
		case SWT.MouseDown :
			if ( !bEnabled )
			{
				return;
			}
			// fireHandleEvent( MOUSE_CLICKED_EVENT );
			toggleDropDown( );
			break;
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_ESCAPE :
					getShell( ).close( );
					break;
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvSelection.redraw( );
			}
			break;
		}
	}
}
 
Example 13
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			if ( event.widget instanceof ColorSelectionCanvas )
			{
				( (ColorSelectionCanvas) event.widget ).redraw( );
			}
			if ( isPopupControl( event.widget ) )
			{
				Control cTmp = isPressingKey ? getDisplay( ).getFocusControl( )
						: getDisplay( ).getCursorControl( );
				// Set default value back
				isPressingKey = false;
				if ( cTmp != null )
				{
					// Condition added to handle behavior under Linux
					if ( isPopupControl( cTmp )
							|| SWT.getPlatform( ).indexOf( "win32" ) == 0//$NON-NLS-1$
							&& ( cTmp.equals( cnvSelection ) || cTmp.equals( btnDown ) ) )
					{
						return;
					}

					if ( cTmp.equals( cnvSelection )
							|| cTmp.equals( btnDown ) )
					{
						bJustFocusLost = true;
					}
				}

				cmpDropDown.getShell( ).close( );
			}
			break;

		case SWT.KeyDown :
			if ( cmpDropDown != null
					&& !cmpDropDown.getShell( ).isDisposed( ) )
			{
				if ( event.keyCode == SWT.ARROW_UP )
				{
					cmpDropDown.getShell( ).close( );
				}
				else if ( event.keyCode == SWT.CR
						|| event.keyCode == SWT.KEYPAD_CR )
				{
					if ( srTransparency != null )
					{
						this.iTransparency = srTransparency.getSelection( );
					}
					if ( fCurrent instanceof ColorDefinition
							&& bTransparencyChanged )
					{
						( (ColorDefinition) fCurrent ).setTransparency( this.iTransparency );
					}
					this.setFill( fCurrent );
					cmpDropDown.getShell( ).close( );
				}
			}
			break;

		case SWT.Traverse :
			switch ( event.detail )
			{
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
					// Indicates getting focus control rather than cursor
					// control
					isPressingKey = true;
					event.doit = true;
			}
			break;
	}

}
 
Example 14
private void canvasEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvMarker.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvMarker.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			// At this point the widget may have been disposed.
			// If so, do not continue.
			if ( isDisposed( ) )
				break;

			if ( event.keyCode == SWT.ARROW_DOWN
					|| event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				event.doit = true;
				toggleDropDown( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvMarker.redraw( );
			}

			break;
		}
		case SWT.Paint :
			paintMarker( event.gc, getMarker( ), LocationImpl.create( 10,
					10 ) );
			break;
	}
}
 
Example 15
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			focusLost( new FocusEvent( event ) );
			break;

		case SWT.FocusIn:
			focusedComposite = event.widget;
			break;
			
		case SWT.MouseDown :
			mouseDown( new MouseEvent( event ) );
			break;

		case SWT.Selection :
			widgetSelected( new SelectionEvent( event ) );
			break;

		case SWT.KeyDown :
			if ( event.keyCode == SWT.ESC )
			{
				getShell( ).close( );
			}
			else if ( event.widget == cmpType )
			{
				int newIndex;
				if ( event.keyCode == SWT.ARROW_LEFT )
				{
					if ( markerTypeIndex - 1 >= 0 )
					{
						newIndex = markerTypeIndex - 1;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_RIGHT )
				{
					if ( markerTypeIndex + 1 < typeNameSet.length )
					{
						newIndex = markerTypeIndex + 1;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_UP )
				{
					if ( markerTypeIndex - MARKER_ROW_MAX_NUMBER >= 0 )
					{
						newIndex = markerTypeIndex
								- MARKER_ROW_MAX_NUMBER;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_DOWN )
				{
					if ( markerTypeIndex + MARKER_ROW_MAX_NUMBER < typeNameSet.length )
					{
						newIndex = markerTypeIndex
								+ MARKER_ROW_MAX_NUMBER;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
			}
			break;

		case SWT.Traverse :
			// Indicates getting focus control rather than
			// cursor control
			if ( event.detail == SWT.TRAVERSE_TAB_NEXT
					|| event.detail == SWT.TRAVERSE_TAB_PREVIOUS )
			{
				event.doit = true;
				isPressingKey = true;
			}
			else if ( event.keyCode == getMnemonicByText( grpSize.getText( ) ) )
			{
				updateIsPressingKey( iscMarkerSize );
			}
			else if ( event.keyCode == getMnemonicByText( btnOutline.getButton( )
					.getText( ) ) )
			{
				updateIsPressingKey( btnOutline );
			}
			else if ( event.keyCode == getMnemonicByText( btnMarkerVisible.getButton( )
					.getText( ) ) )
			{
				updateIsPressingKey( btnMarkerVisible );
			}
	}
}
 
Example 16
void handleEventCanvasMarkers( Event event )
{
	switch ( event.type )
	{
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.ARROW_LEFT )
			{
				if ( iSelectedIndex - 1 >= 0 )
				{
					iSelectedIndex--;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_RIGHT )
			{
				if ( iSelectedIndex + 1 < getMarkers( ).size( ) )
				{
					iSelectedIndex++;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_UP )
			{
				if ( iSelectedIndex - MARKER_ROW_MAX_NUMBER >= 0 )
				{
					iSelectedIndex -= MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_DOWN )
			{
				if ( iSelectedIndex + MARKER_ROW_MAX_NUMBER < getMarkers( ).size( ) )
				{
					iSelectedIndex += MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			
			else if ( event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				currentMarkerEditor.setFocus( );
			}
			else if ( event.keyCode == SWT.ESC )
			{
				cnvMarkers.getShell( ).close( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvMarkers.redraw( );
			}
			break;
		}
		case SWT.Paint :
			paintControl( new PaintEvent( event ) );
			break;
		case SWT.MouseDown :
			mouseDown( new MouseEvent( event ) );
			break;
	}
}
 
Example 17
void handleEventCanvasSelection( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			// At this point the widget may have been disposed.
			// If so, do not continue.
			if ( isDisposed( ) )
				break;

			if ( event.keyCode == SWT.ARROW_UP
					|| event.keyCode == SWT.ARROW_DOWN )
			{
				toggleDropDown( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_ESCAPE :
					getShell( ).close( );
					break;
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvSelection.redraw( );
			}
			break;
		}
		case SWT.MouseDown :
			toggleDropDown( );
			break;
	}
}