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

The following examples show how to use org.eclipse.swt.SWT#ARROW_DOWN . 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: Rel   File: AttributeListPanel.java    License: 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 Project: birt   File: CSpinner.java    License: 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 3
public void keyPressed( KeyEvent e )
{
	if ( e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR )
	{
		if ( bTextModified )
		{
			fireEvent( );
		}
	}
	else if ( e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP )
	{
		Event event = new Event();
		event.keyCode = e.keyCode;
		event.stateMask = e.stateMask;
		this.notifyListeners( SWT.KeyDown, event );
	}
}
 
Example 4
Source Project: hop   File: HopGuiPipelineGraph.java    License: Apache License 2.0 5 votes vote down vote up
@GuiToolbarElement(
  root = GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = TOOLBAR_ITEM_ALIGN_BOTTOM,
  // label = "Bottom-align selected transforms",
  toolTip = "Align the transforms with the bottom-most transform in your selection",
  image = "ui/images/toolbar/align-bottom.svg",
  disabledImage = "ui/images/toolbar/align-bottom-disabled.svg"
)
@GuiKeyboardShortcut( control = true, key = SWT.ARROW_DOWN )
@GuiOsxKeyboardShortcut( command = true, key = SWT.ARROW_DOWN )
public void alignBottom() {
  createSnapAllignDistribute().allignbottom();
}
 
Example 5
/**
 * 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 6
Source Project: birt   File: CustomPreviewTable.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void keyPressed( KeyEvent event )
{
	if ( ( event.stateMask == SWT.CTRL )
			&& ( event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT ) )
	{
		scrollTable( cnvCells.getHorizontalBar( ), event );
	}
	else if ( event.keyCode == SWT.PAGE_UP
			|| event.keyCode == SWT.PAGE_DOWN
			|| ( ( event.stateMask == SWT.CTRL ) && ( event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN ) ) )
	{
		scrollTable( cnvCells.getVerticalBar( ), event );
	}

}
 
Example 7
/**
 * Processes a key stroke while the info popup is up.
 * 
 * @param e
 *            the verify event describing the key stroke
 * @return <code>true</code> if processing can be stopped
 */
private boolean contextInfoPopupKeyPressed(KeyEvent e)
{
	char key = e.character;
	if (key == 0)
	{
		switch (e.keyCode)
		{
			case SWT.ARROW_LEFT:
			case SWT.ARROW_RIGHT:
			case SWT.ARROW_UP:
			case SWT.ARROW_DOWN:
				validateContextInformation();
				break;
			default:
				if (e.keyCode != SWT.CAPS_LOCK && e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2
						&& e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
				{
					hideContextInfoPopup();
				}
				break;
		}

	}
	else if (key == SWT.ESC)
	{
		e.doit = false;
		hideContextInfoPopup();
	}
	else
	{
		validateContextInformation();
	}
	return true;
}
 
Example 8
private void processKeyDown( int keyCode )
{
	switch ( keyCode )
	{
		case SWT.ESC :
			onDropDonwFocusOut( );
			break;
		case SWT.CR :
		case SWT.KEYPAD_CR :
			toggleCell( iRowAct, iColAct );
			break;
		case SWT.HOME :
			moveTo( 0, 0 );
			dropDown.redraw( );
			break;
		case SWT.END :
			moveTo( 7, 7 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_LEFT :
			moveTo( iRowAct, iColAct - 1 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_RIGHT :
			moveTo( iRowAct, iColAct + 1 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_UP :
			moveTo( iRowAct - 1, iColAct );
			dropDown.redraw( );
			break;
		case SWT.ARROW_DOWN :
			moveTo( iRowAct + 1, iColAct );
			dropDown.redraw( );
			break;
	}

}
 
Example 9
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;
	}
}
 
Example 10
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 11
private boolean scrollIncrement( GraphicalEditPart part, KeyEvent event )
{
	if ( ( event.stateMask & SWT.CONTROL ) == 0 )
	{
		return false;
	}
	if ( !( part.getViewer( ) instanceof DeferredGraphicalViewer ) )
	{
		return false;
	}
	DeferredGraphicalViewer viewer = (DeferredGraphicalViewer) part.getViewer( );
	FigureCanvas canvas = viewer.getFigureCanvas( );
	int code = event.keyCode;
	int increment = 0;
	if ( code == SWT.ARROW_RIGHT )
	{
		increment = canvas.getHorizontalBar( ).getSelection( )
				+ canvas.getHorizontalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_LEFT )
	{
		increment = canvas.getHorizontalBar( ).getSelection( )
				- canvas.getHorizontalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_DOWN )
	{
		increment = canvas.getVerticalBar( ).getSelection( )
				+ canvas.getVerticalBar( ).getIncrement( );
	}
	else if ( code == SWT.ARROW_UP )
	{
		increment = canvas.getVerticalBar( ).getSelection( )
				- canvas.getVerticalBar( ).getIncrement( );
	}

	if ( code == SWT.ARROW_RIGHT || code == SWT.ARROW_LEFT )
	{
		canvas.scrollToX( increment );
	}
	if ( code == SWT.ARROW_UP || code == SWT.ARROW_DOWN )
	{
		canvas.scrollToY( increment );
	}
	return true;

}
 
Example 12
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 13
/**
 * @see org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler#keyPressed(org.eclipse.swt.events.KeyEvent)
 */
public boolean keyPressed( KeyEvent event )
{
	GraphicalEditPart part = getFocusEditPart( );

	switch ( event.keyCode )
	{
		case SWT.ARROW_LEFT :

		case SWT.ARROW_RIGHT :

		case SWT.ARROW_UP :

		case SWT.ARROW_DOWN :
			if ( scrollIncrement( part, event ) )
			{
				return true;
			}
			break;

		case SWT.PAGE_DOWN :

		case SWT.PAGE_UP :
			if ( scrollPageIncrement( part, event.keyCode ) )
			{
				return true;
			}
			break;
		default :
			break;
	}
	/**
	 * Hacks Table Cell key behaviors.
	 */
	if ( part instanceof AbstractCellEditPart )
	{
		return tableCellKeyPressed( event );
	}

	return super.keyPressed( event );
}
 
Example 14
/**
     * 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 15
Source Project: pentaho-kettle   File: JobGraph.java    License: Apache License 2.0 4 votes vote down vote up
public void keyPressed( KeyEvent e ) {

    // Delete
    if ( e.keyCode == SWT.DEL ) {
      List<JobEntryCopy> copies = jobMeta.getSelectedEntries();
      if ( copies != null && copies.size() > 0 ) {
        delSelected();
      }
    }

    if ( e.keyCode == SWT.F1 ) {
      spoon.browseVersionHistory();
    }

    // CTRL-UP : allignTop();
    if ( e.keyCode == SWT.ARROW_UP && ( e.stateMask & SWT.MOD1 ) != 0 ) {
      alligntop();
    }
    // CTRL-DOWN : allignBottom();
    if ( e.keyCode == SWT.ARROW_DOWN && ( e.stateMask & SWT.MOD1 ) != 0 ) {
      allignbottom();
    }
    // CTRL-LEFT : allignleft();
    if ( e.keyCode == SWT.ARROW_LEFT && ( e.stateMask & SWT.MOD1 ) != 0 ) {
      allignleft();
    }
    // CTRL-RIGHT : allignRight();
    if ( e.keyCode == SWT.ARROW_RIGHT && ( e.stateMask & SWT.MOD1 ) != 0 ) {
      allignright();
    }
    // ALT-RIGHT : distributeHorizontal();
    if ( e.keyCode == SWT.ARROW_RIGHT && ( e.stateMask & SWT.ALT ) != 0 ) {
      distributehorizontal();
    }
    // ALT-UP : distributeVertical();
    if ( e.keyCode == SWT.ARROW_UP && ( e.stateMask & SWT.ALT ) != 0 ) {
      distributevertical();
    }
    // ALT-HOME : snap to grid
    if ( e.keyCode == SWT.HOME && ( e.stateMask & SWT.ALT ) != 0 ) {
      snaptogrid( ConstUI.GRID_SIZE );
    }
    // CTRL-W or CTRL-F4 : close tab
    if ( ( e.keyCode == 'w' && ( e.stateMask & SWT.MOD1 ) != 0 )
      || ( e.keyCode == SWT.F4 && ( e.stateMask & SWT.MOD1 ) != 0 ) ) {
      spoon.tabCloseSelected();
    }
  }
 
Example 16
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 17
/**
 * @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 18
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 19
void keyDown( Event event )
{
	if ( event.keyCode == SWT.ESC )
	{
		cmpDropDown.getShell( ).close( );
		return;
	}
	if ( selectedIndex == -1 )
	{
		if ( event.keyCode == SWT.ARROW_LEFT
				|| event.keyCode == SWT.ARROW_RIGHT
				|| event.keyCode == SWT.ARROW_UP
				|| event.keyCode == SWT.ARROW_DOWN )
		{
			selectedIndex = 0;
		}
	}
	else
	{
		switch ( event.keyCode )
		{
			case SWT.ARROW_LEFT :
				if ( selectedIndex - 1 >= 0 )
				{
					selectedIndex -= 1;
				}
				break;
			case SWT.ARROW_RIGHT :
				if ( selectedIndex + 1 < ROW_SIZE * COLUMN_SIZE )
				{
					selectedIndex += 1;
				}
				break;
			case SWT.ARROW_UP :
				if ( selectedIndex - ROW_SIZE >= 0 )
				{
					selectedIndex -= ROW_SIZE;
				}
				break;
			case SWT.ARROW_DOWN :
				if ( selectedIndex + ROW_SIZE < ROW_SIZE * COLUMN_SIZE )
				{
					selectedIndex += ROW_SIZE;
				}
				break;
			case SWT.CR :
			case SWT.KEYPAD_CR :
				setColorToModel( colorMap[selectedIndex] );
				cmpDropDown.getShell( ).close( );
				break;
		}
	}
	if ( !cmpDropDown.isDisposed( ) )
	{
		colorSelection = null;
		redraw( );
	}
}
 
Example 20
Source Project: birt   File: CustomPreviewTable.java    License: 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( );
	}
}