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

The following examples show how to use org.eclipse.swt.SWT#ARROW_UP . 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: AttributeListPanel.java    From Rel with Apache License 2.0 6 votes vote down vote up
private void addRow(String name, int rowNum, boolean last, boolean selected) {
	Label lblNewLabel = new Label(this, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText(name);
	labelAttributes.add(lblNewLabel);

	Button checkBox = new Button(this, SWT.CHECK);
	checkBox.setSelection(selected);
	checkAttributes.add(checkBox);

	Composite buttonPanel = new Composite(this, SWT.NONE);
	buttonPanel.setLayout(new FillLayout(SWT.HORIZONTAL));
	Button btnUp = new Button(buttonPanel, SWT.ARROW | SWT.UP | SWT.ARROW_UP);
	btnUp.addListener(SWT.Selection, e -> moveAttributeRow(rowNum, rowNum - 1));
	btnUp.setVisible(!(rowNum == 0));
	Button btnDown = new Button(buttonPanel, SWT.ARROW | SWT.DOWN | SWT.ARROW_DOWN);
	btnDown.addListener(SWT.Selection, e -> moveAttributeRow(rowNum, rowNum + 1));
	btnDown.setVisible(!last);
}
 
Example 2
Source File: TableCellKeyDelegate.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
void scrollViewer( KeyEvent event )
{
	if ( !( getViewer( ).getControl( ) instanceof FigureCanvas ) )
		return;
	FigureCanvas figCanvas = (FigureCanvas) getViewer( ).getControl( );
	Point loc = figCanvas.getViewport( ).getViewLocation( );
	Rectangle area = figCanvas.getViewport( )
			.getClientArea( Rectangle.SINGLETON )
			.scale( .1 );
	switch ( event.keyCode )
	{
		case SWT.ARROW_DOWN :
			figCanvas.scrollToY( loc.y + area.height );
			break;
		case SWT.ARROW_UP :
			figCanvas.scrollToY( loc.y - area.height );
			break;
		case SWT.ARROW_LEFT :
			figCanvas.scrollToX( loc.x - area.width );
			break;
		case SWT.ARROW_RIGHT :
			figCanvas.scrollToX( loc.x + area.width );
	}
}
 
Example 3
Source File: CSpinner.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Processes up/down key event
 * 
 * @param e
 *            The key event type.
 */
protected void traverse( Event e )
{
	switch ( e.detail )
	{
		case SWT.TRAVERSE_ARROW_PREVIOUS :
			if ( e.keyCode == SWT.ARROW_UP )
			{
				e.doit = true;
				e.detail = SWT.NULL;
				up( );
			}
			break;
		case SWT.TRAVERSE_ARROW_NEXT :
			if ( e.keyCode == SWT.ARROW_DOWN )
			{
				e.doit = true;
				e.detail = SWT.NULL;
				down( );
			}
	}
}
 
Example 4
Source File: SWTNullableSpinner.java    From atdl4j with MIT License 6 votes vote down vote up
void traverse(Event e) {
	switch (e.detail) {
	case SWT.TRAVERSE_ARROW_PREVIOUS:
		if (e.keyCode == SWT.ARROW_UP) {
			e.doit = true;
			e.detail = SWT.NULL;
			up();
		}
		break;

	case SWT.TRAVERSE_ARROW_NEXT:
		if (e.keyCode == SWT.ARROW_DOWN) {
			e.doit = true;
			e.detail = SWT.NULL;
			down();
		}
		break;
	}
}
 
Example 5
Source File: DatePicker.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * perform the scroll by making a call to {@link #adjustDays(int, int)} with
 * the <code>field</code> set to Calendar.DATE and the <code>amount</code>
 * corresponding to the keycode.
 */
private void scrollCalendar(int keycode) {
    if (scrollable) {
        switch (keycode) {
        case SWT.ARROW_DOWN:
            adjustDays(Calendar.DATE, 7);
            break;
        case SWT.ARROW_UP:
            adjustDays(Calendar.DATE, -7);
            break;
        case SWT.END:
            adjustDays(Calendar.YEAR, 1);
            break;
        case SWT.HOME:
            adjustDays(Calendar.YEAR, -1);
            break;
        case SWT.PAGE_DOWN:
            adjustDays(Calendar.MONTH, 1);
            break;
        case SWT.PAGE_UP:
            adjustDays(Calendar.MONTH, -1);
            break;
        }
    }
}
 
Example 6
Source File: SorterPanel.java    From Rel with Apache License 2.0 6 votes vote down vote up
private void addRow(SorterPanel.SortedAttribute attribute, int rowNum, boolean last) {
	Label lblNewLabel = new Label(this, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText(attribute.getName());
	labelAttributes.add(lblNewLabel);

	SortOrderPicker ordering = new SortOrderPicker(this, SWT.NONE);
	ordering.setState(attribute.getSort());
	orderAttributes.add(ordering);

	Composite buttonPanel = new Composite(this, SWT.NONE);
	buttonPanel.setLayout(new FillLayout(SWT.HORIZONTAL));
	Button btnUp = new Button(buttonPanel, SWT.ARROW | SWT.UP | SWT.ARROW_UP);
	btnUp.addListener(SWT.Selection, e -> moveAttributeRow(rowNum, rowNum - 1));
	btnUp.setVisible(!(rowNum == 0));
	btnUp.setToolTipText("Move up; increase sort priority.");
	
	Button btnDown = new Button(buttonPanel, SWT.ARROW | SWT.DOWN | SWT.ARROW_DOWN);
	btnDown.addListener(SWT.Selection, e -> moveAttributeRow(rowNum, rowNum + 1));
	btnDown.setVisible(!last);
	btnDown.setToolTipText("Move down; decrease sort priority.");
}
 
Example 7
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
@GuiToolbarElement(
  root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = TOOLBAR_ITEM_DISTRIBUTE_VERTICALLY,
  // label = "Vertically distribute selected transforms",
  toolTip = "Distribute the selected transforms evenly between the top-most and bottom-most transform in your selection",
  image = "ui/images/toolbar/distribute-vertically.svg",
  disabledImage = "ui/images/toolbar/distribute-vertically-disabled.svg"
)
@GuiKeyboardShortcut( alt = true, key = SWT.ARROW_UP )
@GuiOsxKeyboardShortcut( alt = true, key = SWT.ARROW_UP )
public void distributeVertical() {
  createSnapAllignDistribute().distributevertical();
}
 
Example 8
Source File: PatternImageEditorDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void processKeyDown( int keyCode )
{
	switch ( keyCode )
	{
		case SWT.ESC :
			break;
		case SWT.CR :
		case SWT.KEYPAD_CR :
			doToggleDropDown( );
			break;
		case SWT.HOME :
			select( 0 );
			break;
		case SWT.END :
			select( context.getBitmaps( ).size( ) - 1 );
			break;
		case SWT.ARROW_LEFT :
			select( context.getIndex( ) - 1 );
			break;
		case SWT.ARROW_RIGHT :
			select( context.getIndex( ) + 1 );
			break;
		case SWT.ARROW_UP :
			select( context.getIndex( ) - columns );
			break;
		case SWT.ARROW_DOWN :
			select( context.getIndex( ) + columns );
			break;
	}

}
 
Example 9
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
@GuiToolbarElement(
  root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = TOOLBAR_ITEM_DISTRIBUTE_VERTICALLY,
  toolTip = "Distribute the selected actions evenly between the top-most and bottom-most action in your selection",
  image = "ui/images/toolbar/distribute-vertically.svg",
  disabledImage = "ui/images/toolbar/distribute-vertically-disabled.svg"
)
@GuiKeyboardShortcut( alt = true, key = SWT.ARROW_UP )
@GuiOsxKeyboardShortcut( alt = true, key = SWT.ARROW_UP )
public void distributeVertical() {
  createSnapAllignDistribute().distributevertical();
}
 
Example 10
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
@GuiToolbarElement(
  root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = TOOLBAR_ITEM_ALIGN_TOP,
  toolTip = "Align the transforms with the top-most transform in your selection",
  image = "ui/images/toolbar/align-top.svg",
  disabledImage = "ui/images/toolbar/align-top-disabled.svg"
)
@GuiKeyboardShortcut( control = true, key = SWT.ARROW_UP )
@GuiOsxKeyboardShortcut( command = true, key = SWT.ARROW_UP )
public void alignTop() {
  createSnapAllignDistribute().alligntop();
}
 
Example 11
Source File: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Handle a keyPressed event on any row control.
 * 
 * @param sender
 *            The row that is sending the event
 * @param e
 *            the actual KeyEvent
 */
public void keyPressed(TableRow sender, KeyEvent e) {
	if (doMakeFocusedRowVisible()) return;
	
	if ((e.stateMask & SWT.CONTROL) != 0) {
		switch (e.keyCode) {
		case SWT.HOME:
               doFocusInitialRow();
			return;
		case SWT.END:
               doFocusLastRow();
			return;
		case SWT.INSERT:
               doInsertRow();
			return;
		case SWT.DEL:
               doDeleteRow();
			return;
		default:
			return;
		}
	}
	switch (e.keyCode) {
	case SWT.ARROW_UP:
           doRowUp();
		return;
	case SWT.ARROW_DOWN:
           doRowDown();
		return;
	case SWT.PAGE_UP:
           doPageUp();
		return;
	case SWT.PAGE_DOWN:
           doPageDown();
		return;
	}
}
 
Example 12
Source File: TableCellKeyDelegate.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
boolean acceptScroll( KeyEvent event )
{
	return ( ( event.stateMask & SWT.CTRL ) != 0
			&& ( event.stateMask & SWT.SHIFT ) != 0 && ( event.keyCode == SWT.ARROW_DOWN
			|| event.keyCode == SWT.ARROW_LEFT
			|| event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP ) );
}
 
Example 13
Source File: TimeCompressionBar.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void keyPressedEvent(KeyEvent event) {
    if (fTooltip != null) {
        fTooltip.hideToolTip();
    }
    if (!isFocusControl() || getViewControl().isFocusControl()) {
        Control[] child = getParent().getChildren();
        for (int i = 0; i < child.length; i++) {
            if (child[i].isFocusControl()) {
                break;
            }
        }
    }
    setFocus(-1);

    boolean top = false;
    if (fNextNodeY == 0) {
        top = true;
    }
    if ((fFrame != null) && (fNextNodeY == 0)) {
        for (int i = 0; i < fNodeList.size() - 1 && i < 1; i++) {
            SDTimeEvent m1 = fNodeList.get(i);
            SDTimeEvent m2 = fNodeList.get(i + 1);
            if (skipIfLifelineIsNull(m1, m2)) {
                continue;
            }

            PairOfYs poy = adjustHeights(m1, m2);

            fPrevNodeY = Math.round(poy.getY1() * fZoomValue);
            fNextNodeY = Math.round(poy.getY2() * fZoomValue);
        }
    }

    if (fLifeline != null) {
        for (int j = 0; j < fListenerList.size(); j++) {
            ITimeCompressionListener list = fListenerList.get(j);
            list.deltaSelected(fLifeline, fLifelineStart, fLifelineNumEvents, fLifelineColor);
        }
    }

    if (event.keyCode == SWT.ARROW_DOWN) {
        if (!top) {
            selectTimeDelta(fNextNodeY + 1, 1);
        } else {
            selectTimeDelta(fPrevNodeY + 1, 1);
        }
        setFocus(1);
    } else if (event.keyCode == SWT.ARROW_UP) {
        selectTimeDelta(fPrevNodeY - 1, 2);
        setFocus(1);
    } else if (event.keyCode == SWT.ARROW_RIGHT) {
        selectTimeDelta(fPrevNodeY, 1);
        setFocus(1);
    }
    super.keyPressedEvent(event);
}
 
Example 14
Source File: TableCellKeyDelegate.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler#keyPressed(org.eclipse.swt.events.KeyEvent)
 */
public boolean keyPressed( KeyEvent event )
{
	if ( event.character == ' ' )
	{
		processSelect( event );
		return true;
	}
	else if ( acceptIntoContainer( event ) )
	{
		navigateIntoContainer( event );
		return true;
	}
	else if ( acceptOutOf( event ) )
	{
		navigateOut( event );
		return true;
	}
	else if ( acceptConnection( event ) )
	{
		navigateConnections( event );
		return true;
	}
	else if ( acceptScroll( event ) )
	{
		scrollViewer( event );
		return true;
	}
	else if ( acceptLeaveConnection( event ) )
	{
		navigateOutOfConnection( event );
		return true;
	}
	else if ( acceptLeaveContents( event ) )
	{
		navigateIntoContainer( event );
		return true;
	}

	switch ( event.keyCode )
	{
		case SWT.ARROW_LEFT :
			if ( navigateNextSibling( event, PositionConstants.WEST ) )
				return true;
			break;
		case SWT.ARROW_RIGHT :
			if ( navigateNextSibling( event, PositionConstants.EAST ) )
				return true;
			break;
		case SWT.ARROW_UP :
			if ( navigateNextSibling( event, PositionConstants.NORTH ) )
				return true;
			break;
		case SWT.ARROW_DOWN :
			if ( navigateNextSibling( event, PositionConstants.SOUTH ) )
				return true;
			break;

		case SWT.HOME :
			if ( navigateJumpSibling( event, PositionConstants.WEST ) )
				return true;
			break;
		case SWT.END :
			if ( navigateJumpSibling( event, PositionConstants.EAST ) )
				return true;
			break;
		case SWT.PAGE_DOWN :
			if ( navigateJumpSibling( event, PositionConstants.SOUTH ) )
				return true;
			break;
		case SWT.PAGE_UP :
			if ( navigateJumpSibling( event, PositionConstants.NORTH ) )
				return true;
	}
	return super.keyPressed( event );
}
 
Example 15
Source File: HorizontalScrollbarHandler.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public void handleEvent(Event e) {
	_scrolling = true;

	int cur = getScrollBarPosition();

	// same as last (happens when user clicks the thumb without dragging)
	if (_lastScrollbarPosition == cur) {
		// if the mouse lets go of a scrollbar drag, update the scrollbars again
		if (e.detail == 0 && _lastDetailEvent != 0 && _fixed) {
			recalculate();
		}

		if (_infinite && e.detail == 0) {
			_scrollBar.setSelection(_center);
			_lastScrollbarPosition = _center;
		}

		_gc.killDialogs();

		return;
	}

	_lastDetailEvent = e.detail;

	boolean left = false;
	int diff = cur - _lastScrollbarPosition;
	if (diff < 0) {
		left = true;
		diff = _lastScrollbarPosition - cur;
	}

	if (e.detail == SWT.PAGE_UP || e.detail == SWT.PAGE_DOWN) {
		scrollViewportByPage(scrollDirectionForEventDetail(e.detail), diff);
	} else if (e.detail == SWT.ARROW_UP || e.detail == SWT.ARROW_DOWN) {
		scrollViewportByOffset(scrollDirectionForEventDetail(e.detail), diff);
	} else if (e.detail == SWT.DRAG) {
		scrollViewportTo(left ? SWT.LEFT : SWT.RIGHT, _scrollBar.getSelection(), diff);
	}

	if ((_infinite && e.detail == 0) ) {
		_scrollBar.setSelection(_center);
		_lastScrollbarPosition = _center;
		_gc.killDialogs();
		return;
	}

	_lastScrollbarPosition = getScrollBarPosition();

	_scrolling = false;

}
 
Example 16
Source File: DatePicker.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
private void onKeyDown(KeyEvent e){
	if (e.character == SWT.ESC) {
		onDateSelected(false);
		return;
	}
	
	if ((e.character == ' ') || (e.character == '\r')) {
		onDateSelected(true);
		return;
	}
	
	int day = cal.get(Calendar.DAY_OF_MONTH);
	int month = cal.get(Calendar.MONTH);
	int oldDay = day;
	int oldMonth = month;
	
	if (e.keyCode == SWT.ARROW_LEFT) {
		day--;
	}
	
	if (e.keyCode == SWT.ARROW_RIGHT) {
		day++;
	}
	
	if (e.keyCode == SWT.ARROW_UP) {
		day = ((day - 7) < 1 ? oldDay : day - 7);
	}
	
	if (e.keyCode == SWT.ARROW_DOWN) {
		day = ((day + 7) > getMaxDay() ? oldDay : day + 7);
	}
	
	if (e.keyCode == SWT.PAGE_UP) {
		month--;
	}
	
	if (e.keyCode == SWT.PAGE_DOWN) {
		month++;
	}
	
	cal.set(Calendar.MONTH, month);
	cal.set(Calendar.DAY_OF_MONTH, day);
	
	if ((day != oldDay) || (month != oldMonth)) {
		redraw();
		
		if (month != oldMonth) {
			updateMonthLabel();
		}
	}
}
 
Example 17
Source File: CDateTime.java    From nebula with 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 18
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void widgetSelected( SelectionEvent e )
{
	if ( e.getSource( ) instanceof ScrollBar )
	{
		ScrollBar sb = (ScrollBar) e.getSource( );
		if ( ( sb.getStyle( ) | SWT.H_SCROLL ) == SWT.H_SCROLL )
		{
			if ( iLastProcessedHorizontalScrollPosition == 0 )
			{
				// Initialize the value
				iLastProcessedHorizontalScrollPosition = cnvCells.getVisibleTableWidth( );
			}
			if ( sb.getSelection( ) == iLastProcessedHorizontalScrollPosition )
			{
				return;
			}

			if ( ( sb.getStyle( ) | SWT.H_SCROLL ) == SWT.H_SCROLL )
			{
				// CALCULATE PIXEL SHIFT IN BUTTON POSITION
				int iShift = 0;
				if ( e.detail == SWT.ARROW_UP
						|| e.detail == SWT.PAGE_UP )
				{
					// SHIFT HEADERS ONE COLUMN TO THE RIGHT
					iShift = -SCROLL_HORIZONTAL_STEP;
				}
				else if ( e.detail == SWT.ARROW_DOWN
						|| e.detail == SWT.PAGE_DOWN )
				{
					// SHIFT HEADERS ONE COLUMN TO THE LEFT
					iShift = SCROLL_HORIZONTAL_STEP;
				}
				else
				{
					iShift = sb.getSelection( )
							- iLastProcessedHorizontalScrollPosition;
				}
				iHiddenWidth += iShift;
				// Correction for negative value or overflow
				if ( iHiddenWidth < 0 )
				{
					iShift -= iHiddenWidth;
					iHiddenWidth = 0;
				}
				else if ( iHiddenWidth + getVisibleTableWidth( ) > getMaxTableWidth( ) )
				{
					int diff = getMaxTableWidth( )
							- getVisibleTableWidth( )
							- iHiddenWidth;
					iShift += diff;
					iHiddenWidth += diff;
				}
				// APPLY PIXEL SHIFT TO RELOCATE BUTTONS
				if ( btnHeaders.size( ) > 0 )
				{
					// MOVE ALL BUTTONS TO THE LEFT...AS MUCH AS THE
					// SCROLLING VALUE
					Button btn = btnHeaders.get( 0 );
					( (FormData) btn.getLayoutData( ) ).left = new FormAttachment( 0,
							btn.getLocation( ).x - iShift );
				}
				cmpHeaders.layout( );
				// UPDATE LAST HORIZONTAL SCROLL POSITION
				iLastProcessedHorizontalScrollPosition = sb.getSelection( );
			}
		}
		else
		{
			if ( getVerticalBar( ).getSelection( ) == iLastProcessedVerticalScrollPosition )
			{
				return;
			}

			if ( e.detail == SWT.ARROW_UP || e.detail == SWT.PAGE_UP )
			{
				if ( iVScroll > 0 )
				{
					iVScroll--;
				}
			}
			else if ( e.detail == SWT.ARROW_DOWN
					|| e.detail == SWT.PAGE_DOWN )
			{
				iVScroll++;
			}
			else
			{
				iVScroll += ( sb.getSelection( ) - iLastProcessedVerticalScrollPosition );
			}
			iLastProcessedVerticalScrollPosition = sb.getSelection( );
		}
		redraw( );
	}
}
 
Example 19
Source File: OfflineActionTarget.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void verifyKey(VerifyEvent event) {

    if (!event.doit)
        return;

    if (event.character == 0) {

        switch (event.keyCode) {

            case SWT.ARROW_DOWN:
                //special case: 
                //if there's a key dialog with a table shown, set its focus when down is pressed
                synchronized (lock) {
                    KeyAssistDialog tempKeyAssistDialog = this.keyAssistDialog;
                    if (tempKeyAssistDialog != null) {
                        Table completionsTable = this.keyAssistDialog.getCompletionsTable();
                        if (completionsTable != null && !completionsTable.isDisposed()) {
                            completionsTable.setFocus();
                            completionsTable.setSelection(0);
                            event.doit = false;
                            break;
                        }
                    }
                }
                // ALT, CTRL, ARROW_LEFT, ARROW_RIGHT == leave
            case SWT.ARROW_LEFT:
            case SWT.ARROW_RIGHT:
            case SWT.HOME:
            case SWT.END:
            case SWT.PAGE_DOWN:
            case SWT.PAGE_UP:
            case SWT.ARROW_UP:
                leave();
                break;

        }

        // event.character != 0
    } else {

        switch (event.character) {

        // ESC = quit
            case 0x1B:
                leave();
                event.doit = false;
                break;

            //CR = exec and quit
            case 0x0D:
                boolean executed = doExec();
                event.doit = false;
                if (!executed) {
                    return; //we don't want to update the status
                }
                break;

            // backspace    and delete
            case 0x08:
            case 0x7F:
                removeLastCharSearch();
                event.doit = false;
                break;

            default:
                if (event.stateMask == 0 || event.stateMask == SWT.SHIFT || event.stateMask == (SWT.ALT | SWT.CTRL)) { // SWT.ALT | SWT.CTRL covers AltGr (see bug 43049)
                    event.doit = false;
                    if (addCharSearch(event.character)) {
                        //ok, triggered some automatic action (does not need enter)
                        executed = doExec();
                        if (!executed) {
                            return; //we don't want to update the status
                        }

                    }
                }
                break;
        }
    }
    updateStatus();
}
 
Example 20
Source File: WithMinibuffer.java    From e4macs with Eclipse Public License 1.0 4 votes vote down vote up
protected void noCharEvent(VerifyEvent event) {

		switch (event.keyCode) {
		case SWT.CTRL:	
			if (handlesCtrl()) {
				break;
			}
			closeDialog();	// else close dialog and leave 
			leave();
			break;
		case SWT.ALT:
			if (handlesAlt()) {
				break;
			}
			closeDialog();	// else close dialog and leave 
			leave();
			break;
		case SWT.PAGE_DOWN:	// leave
		case SWT.PAGE_UP:
		case SWT.ARROW_DOWN:
		case SWT.ARROW_UP:
			leave();
			break;

			// minimal support for in line editing
		case SWT.HOME:
			getMB().toBegin();
			event.doit = false;
			break;

		case SWT.END:
			getMB().toEnd();
			event.doit = false;
			break;

		case SWT.ARROW_LEFT:
			getMB().toLeft();
			event.doit = false;
			break;

		case SWT.ARROW_RIGHT:
			getMB().toRight();			
			event.doit = false;
			break;
		}
	}