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

The following examples show how to use org.eclipse.swt.SWT#END . 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: DataQualityShell.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
private void createButtons(Composite parent) {
	Composite composite = toolkit.createComposite(parent);
	UI.gridLayout(composite, 3);
	GridData gd = UI.gridData(composite, true, false);
	gd.horizontalAlignment = SWT.END;
	toolkit.paintBordersFor(composite);
	Button okBtn = toolkit.createButton(composite, M.OK, SWT.NONE);
	UI.gridData(okBtn, false, false).widthHint = 60;
	okBtn.addSelectionListener(new DataQualityFinishHandler(this, (s) -> onOk.accept(s)));
	if (dqEntry != null) {
		Button deleteBtn = toolkit.createButton(composite, M.Delete, SWT.NONE);
		UI.gridData(deleteBtn, false, false).widthHint = 60;
		deleteBtn.addSelectionListener(new DataQualityFinishHandler(this, (s) -> onDelete.accept(s)));
	}
	Button cancelBtn = toolkit.createButton(composite, M.Cancel, SWT.NONE);
	cancelBtn.addSelectionListener(new DataQualityFinishHandler(this, null));
	UI.gridData(cancelBtn, false, false).widthHint = 60;
}
 
Example 2
Source File: SelectExistingOrCreateNewDialog.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected TreeViewer createTreeViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    GridLayout gridLayout = new GridLayout(2, false);
    gridLayout.marginWidth = 0;
    composite.setLayout(gridLayout);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(layoutData);

    TreeViewer ret = super.createTreeViewer(composite);

    Composite buttonBox = new Composite(composite, SWT.NULL);
    GridData gridData = new GridData(SWT.END, SWT.FILL, false, false);
    buttonBox.setLayoutData(gridData);

    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 0;
    buttonBox.setLayout(layout);
    btAdd = createPushButton(buttonBox, "Add");
    btRemove = createPushButton(buttonBox, "Remove (DEL)");

    return ret;
}
 
Example 3
Source File: SearchMinibuffer.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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 4
Source File: ChartPlotSheetImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void createButtonGroup( Composite parent )
{
	Composite cmp = new Composite( parent, SWT.NONE );
	{
		cmp.setLayout( new GridLayout( ) );
		GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
		gridData.horizontalSpan = 2;
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = SWT.END;
		cmp.setLayoutData( gridData );
	}

	ITaskPopupSheet popup = new PlotClientAreaSheet( Messages.getString( "ChartPlotSheetImpl.Label.AreaFormat" ), //$NON-NLS-1$
			getContext( ) );
	Button btnArea = createToggleButton( cmp,
			BUTTON_AREA_FORMAT,
			Messages.getString( "ChartPlotSheetImpl.Label.AreaFormat&" ), popup ); //$NON-NLS-1$
	btnArea.addSelectionListener( this );
}
 
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: ColumnMappingDialog.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void createButtonArea( Composite right )
{
	Composite composite = new Composite( right, SWT.NONE );
	GridLayout layout = new GridLayout( 1, false );
	composite.setLayout( layout );
	composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

	editBtn = new Button( composite, SWT.PUSH );
	editBtn.setText( Messages.getString( "ColumnMappingDialog.button.edit" ) ); //$NON-NLS-1$
	GridData gd = new GridData( );
	gd.horizontalAlignment = SWT.END;
	gd.grabExcessHorizontalSpace = true;
	gd.widthHint = editBtn.computeSize( -1, -1 ).x
			- editBtn.getBorderWidth( ) + 20;
	editBtn.setLayoutData( gd );
	editBtn.setEnabled( false );
	editBtn.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			doEditPrameter( );
		}
	} );

}
 
Example 7
Source File: ReorgUserInputPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected Control addLabel(Composite parent) {
	Label label= new Label(parent, SWT.WRAP);
	String text;
	int resources= getResources().length;
	int javaElements= getJavaElements().length;

	if (resources == 0 && javaElements == 1) {
		text= Messages.format(
				ReorgMessages.ReorgUserInputPage_choose_destination_single,
				JavaElementLabels.getElementLabel(getJavaElements()[0], LABEL_FLAGS));
	} else if (resources == 1 && javaElements == 0) {
		text= Messages.format(
				ReorgMessages.ReorgUserInputPage_choose_destination_single,
				BasicElementLabels.getResourceName(getResources()[0]));
	} else {
		text= Messages.format(
				ReorgMessages.ReorgUserInputPage_choose_destination_multi,
				String.valueOf(resources + javaElements));
	}

	label.setText(text);
	GridData data= new GridData(SWT.FILL, SWT.END, true, false);
	data.widthHint= convertWidthInCharsToPixels(50);
	label.setLayoutData(data);
	return label;
}
 
Example 8
Source File: AbstractNewModelWizardPage.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
Label createLabel(final Composite c, final String t) {
	final Label label = new Label(c, t == null ? SWT.NULL : SWT.RIGHT);
	final GridData d = new GridData(SWT.END, SWT.CENTER, false, false);
	// d.minimumHeight = 20;
	// d.heightHint = 30;
	label.setLayoutData(d);
	label.setFont(GamaFonts.getLabelfont());
	label.setText(t == null ? " " : t);
	return label;
}
 
Example 9
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 10
Source File: TreeCompoundTask.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the compound task's title area.
 * 
 * @param parent
 *            the SWT parent for the title area composite.
 * @return the created title area composite.
 */
protected Composite createTitleArea( Composite parent )
{
	Composite cmpTitle = new Composite( parent, SWT.NONE );
	GridLayout layout = new GridLayout( 2, false );
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	cmpTitle.setLayout( layout );

	GridData gridData = new GridData( GridData.FILL_BOTH );
	cmpTitle.setLayoutData( gridData );

	Label label = new Label( cmpTitle, SWT.NONE );
	{
		label.setFont( JFaceResources.getBannerFont( ) );
		label.setText( getTitleAreaString( ) );
	}

	if ( needHistory )
	{
		ToolBar historyBar = new ToolBar( cmpTitle, SWT.HORIZONTAL
				| SWT.FLAT );
		{
			GridData gd = new GridData( );
			gd.horizontalAlignment = SWT.END;
			historyBar.setLayoutData( gd );
			ToolBarManager historyManager = new ToolBarManager( historyBar );
			history.createHistoryControls( historyBar, historyManager );
			historyManager.update( false );
		}
	}
	else
	{
		new Label( cmpTitle, SWT.NONE );
	}
	return cmpTitle;
}
 
Example 11
Source File: DocumentManager.java    From ContentAssist with MIT License 5 votes vote down vote up
/**
 * Tests if a given key event may move the current cursor position.
 * @param event the key event
 * @return <code>true</code> if the key event may move the current cursor position, otherwise <code>false</code>
 */
private boolean cursorMoved(Event event) {
    final int key = (SWT.KEY_MASK & event.keyCode);
    switch (key) {
        case SWT.ARROW_DOWN:
        case SWT.ARROW_LEFT:
        case SWT.ARROW_RIGHT: 
        case SWT.ARROW_UP: 
        case SWT.HOME:
        case SWT.END: 
        case SWT.PAGE_DOWN:
            return true;
    }
    return false;
}
 
Example 12
Source File: VGridLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private int getX(GridData data, int cellStart, int cellSpan, int controlSpan) {
	switch(data.horizontalAlignment) {
	case SWT.FILL:
	case SWT.LEFT:
	case SWT.BEGINNING:
		return cellStart + data.horizontalIndent;
	case SWT.RIGHT:
	case SWT.END:
		return cellStart + cellSpan - controlSpan;
	case SWT.CENTER:
	default:
		return cellStart + ((cellSpan - controlSpan) / 2);
	}
}
 
Example 13
Source File: ContextDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
private void onKeyPressed( KeyEvent event ) {

		if ( filteredItems.isEmpty() ) {
			return;
		}

		Rectangle area = wCanvas.getClientArea();
		int pageRows = Math.floorDiv( area.height, cellHeight );
		int nrColumns = calculateNrColumns();
		int nrRows = calculateNrRows();
		int index = filteredItems.indexOf( selectedItem );

		switch ( event.keyCode ) {
			case SWT.ARROW_DOWN:
				if ( index + nrColumns < filteredItems.size() ) {
					index += nrColumns;
				}
				break;
			case SWT.ARROW_UP:
				if ( index - nrColumns >= 0 ) {
					index -= nrColumns;
				}
				break;
			case SWT.PAGE_UP:
				if ( index - ( pageRows * nrColumns ) > 0 ) {
					index -= pageRows * nrColumns;
				} else {
					index = Math.floorMod( index, nrColumns );
				}
				break;
			case SWT.PAGE_DOWN:
				if ( index + ( pageRows * nrColumns ) < filteredItems.size() - 1 ) {
					index += pageRows * nrColumns;
				} else {
					index = ( nrRows - 1 ) * nrColumns + Math.floorMod( index, nrColumns );
					if ( index > filteredItems.size() - 1 ) {
						index = ( nrRows - 2 ) * nrColumns + Math.floorMod( index, nrColumns );
					}
				}
				break;
			case SWT.ARROW_LEFT:
				if ( index > 0 ) {
					index--;
				}
				break;
			case SWT.ARROW_RIGHT:
				if ( index < filteredItems.size() - 1 ) {
					index++;
				}
				break;
			case SWT.HOME:
				// Position on the first row and column of the screen
				index = 0;
				break;
			case SWT.END:
				// Position on the last row and column of the screen
				index = filteredItems.size() - 1;
				break;
		}

		if (index>=0 && index<filteredItems.size()) {
			selectItem( filteredItems.get( index ) );
		}
	}
 
Example 14
Source File: CGridData.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns a string containing a concise, human-readable
 * description of the receiver.
 *
 * @return a string representation of the GridData object
 */
public String toString () {
	String hAlign = "";
	switch (horizontalAlignment) {
		case SWT.FILL: hAlign = "SWT.FILL"; break;
		case SWT.BEGINNING: hAlign = "SWT.BEGINNING"; break;
		case SWT.LEFT: hAlign = "SWT.LEFT"; break;
		case SWT.END: hAlign = "SWT.END"; break;
		case END: hAlign = "GridData.END"; break;
		case SWT.RIGHT: hAlign = "SWT.RIGHT"; break;
		case SWT.CENTER: hAlign = "SWT.CENTER"; break;
		case CENTER: hAlign = "GridData.CENTER"; break;
		default: hAlign = "Undefined "+horizontalAlignment; break;
	}
	String vAlign = "";
	switch (verticalAlignment) {
		case SWT.FILL: vAlign = "SWT.FILL"; break;
		case SWT.BEGINNING: vAlign = "SWT.BEGINNING"; break;
		case SWT.TOP: vAlign = "SWT.TOP"; break;
		case SWT.END: vAlign = "SWT.END"; break;
		case END: vAlign = "GridData.END"; break;
		case SWT.BOTTOM: vAlign = "SWT.BOTTOM"; break;
		case SWT.CENTER: vAlign = "SWT.CENTER"; break;
		case CENTER: vAlign = "GridData.CENTER"; break;
		default: vAlign = "Undefined "+verticalAlignment; break;
	}
 	String string = getName()+" {";
 	string += "horizontalAlignment="+hAlign+" ";
 	if (horizontalIndent != 0) string += "horizontalIndent="+horizontalIndent+" ";
 	if (horizontalSpan != 1) string += "horizontalSpan="+horizontalSpan+" ";
 	if (grabExcessHorizontalSpace) string += "grabExcessHorizontalSpace="+grabExcessHorizontalSpace+" ";
 	if (widthHint != SWT.DEFAULT) string += "widthHint="+widthHint+" ";
 	if (minimumWidth != 0) string += "minimumWidth="+minimumWidth+" ";
 	string += "verticalAlignment="+vAlign+" ";
 	if (verticalIndent != 0) string += "verticalIndent="+verticalIndent+" ";
	if (verticalSpan != 1) string += "verticalSpan="+verticalSpan+" ";
 	if (grabExcessVerticalSpace) string += "grabExcessVerticalSpace="+grabExcessVerticalSpace+" ";
 	if (heightHint != SWT.DEFAULT) string += "heightHint="+heightHint+" ";
 	if (minimumHeight != 0) string += "minimumHeight="+minimumHeight+" ";
 	if (exclude) string += "exclude="+exclude+" ";
 	string = string.trim();
 	string += "}";
	return string;
}
 
Example 15
Source File: Histogram.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Move the currently selected bar cursor.
 *
 * @param keyCode
 *            the SWT key code
 */
protected void moveCursor(final int keyCode) {

    int index;
    switch (keyCode) {

    case SWT.HOME:
        fScaledData.fSelectionBeginBucket = 0;
        break;

    case SWT.END:
        fScaledData.fSelectionBeginBucket = fScaledData.fWidth - 1;
        break;

    case SWT.ARROW_RIGHT: {
        long prevStartTime = getTimestamp(fScaledData.fSelectionBeginBucket);
        index = Math.max(0, Math.min(fScaledData.fWidth - 1, fScaledData.fSelectionBeginBucket + 1));
        while (index < fScaledData.fWidth && (fScaledData.fData[index].isEmpty() || prevStartTime == getTimestamp(index))) {
            prevStartTime = getTimestamp(index);
            index++;
        }
        if (index >= fScaledData.fWidth) {
            index = fScaledData.fWidth - 1;
        }
        fScaledData.fSelectionBeginBucket = index;
        break;
    }

    case SWT.ARROW_LEFT: {
        long prevEndTime = getTimestamp(fScaledData.fSelectionBeginBucket + 1);
        index = Math.max(0, Math.min(fScaledData.fWidth - 1, fScaledData.fSelectionBeginBucket - 1));
        while (index >= 0 && (fScaledData.fData[index].isEmpty() || prevEndTime == getTimestamp(index + 1))) {
            prevEndTime = getTimestamp(index + 1);
            index--;
        }
        if (index <= 0) {
            index = 0;
        }
        fScaledData.fSelectionBeginBucket = index;
        break;
    }

    default:
        return;
    }

    fScaledData.fSelectionEndBucket = fScaledData.fSelectionBeginBucket;
    fSelectionBegin = getTimestamp(fScaledData.fSelectionBeginBucket);
    fSelectionEnd = fSelectionBegin;
    updateSelectionTime();
}
 
Example 16
Source File: AbstractAxisSubtask.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void createButtonGroup( Composite parent )
{
	Composite cmp = new Composite( parent, SWT.NONE );
	{
		cmp.setLayout( new GridLayout( 6, false ) );
		GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
		gridData.horizontalSpan = 2;
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = SWT.END;
		gridData.horizontalAlignment = SWT.BEGINNING;
		cmp.setLayoutData( gridData );
	}

	ITaskPopupSheet popup;
	if ( getAxisAngleType( ) != AngleType.Z )
	{
		// Scale
		popup = new AxisScaleSheet( Messages.getString( "AxisYSheetImpl.Label.Scale" ), //$NON-NLS-1$
				getContext( ),
				getAxisForProcessing( ),
				getAxisAngleType( ),
				getDefaultValueAxis( ) );
		Button btnScale = createToggleButton( cmp,
				BUTTON_SCALE,
				Messages.getString( "AxisYSheetImpl.Label.Scale&" ), //$NON-NLS-1$
				popup );
		btnScale.addSelectionListener( this );
	}

	// Title
	popup = new AxisTitleSheet( Messages.getString( "AxisYSheetImpl.Label.TitleFormat" ), //$NON-NLS-1$
			getContext( ),
			getAxisForProcessing( ),
			getAxisAngleType( ),
			getDefaultValueAxis( ) );
	Button btnAxisTitle = createToggleButton( cmp,
			BUTTON_TITLE,
			Messages.getString( "AxisYSheetImpl.Label.TitleFormat&" ), //$NON-NLS-1$
			popup,
			getContext().getUIFactory( ).canEnableUI( btnTitleVisible ) );
	btnAxisTitle.addSelectionListener( this );

	// Label
	popup = new AxisLabelSheet( Messages.getString( "AxisYSheetImpl.Label.LabelFormat" ), //$NON-NLS-1$
			getContext( ),
			getAxisForProcessing( ),
			getAxisAngleType( ),
			getDefaultValueAxis( ) );
	Button btnAxisLabel = createToggleButton( cmp,
			BUTTON_LABEL,
			Messages.getString( "AxisYSheetImpl.Label.LabelFormat&" ), //$NON-NLS-1$
			popup,
			getContext().getUIFactory( ).canEnableUI( btnLabelVisible ) );
	btnAxisLabel.addSelectionListener( this );

	// Gridlines
	popup = new AxisGridLinesSheet( Messages.getString( "AxisYSheetImpl.Label.Gridlines" ), //$NON-NLS-1$
			getContext( ),
			getAxisForProcessing( ),
			getAxisAngleType( ),
			getDefaultValueAxis( ) );
	Button btnGridlines = createToggleButton( cmp,
			BUTTON_GRIDLINES,
			Messages.getString( "AxisYSheetImpl.Label.Gridlines&" ), //$NON-NLS-1$
			popup );
	btnGridlines.addSelectionListener( this );

	if ( getAxisAngleType( ) != AngleType.Z )
	{
		// Marker
		// Marker is not supported for 3D
		createMarkersUI( cmp );
	}

	// Interactivity
	if ( isInteractivityEnabled( ) )
	{
		popup = new InteractivitySheet( Messages.getString( "AbstractAxisSubtask.Label.Interactivity" ), //$NON-NLS-1$
				getContext( ),
				getAxisForProcessing( ).getTriggers( ),
				getAxisForProcessing( ),
				TriggerSupportMatrix.TYPE_AXIS,
				TriggerDataComposite.ENABLE_SHOW_TOOLTIP_VALUE );
		Button btnInteractivity = createToggleButton( cmp,
				BUTTON_INTERACTIVITY,
				Messages.getString( "SeriesYSheetImpl.Label.Interactivity&" ), //$NON-NLS-1$
				popup,
				getChart( ).getInteractivity( ).isEnable( ) );
		btnInteractivity.addSelectionListener( this );
	}
}
 
Example 17
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 18
Source File: Launcher.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Code executed when a key is pressed
 *
 * @param event Event
 */
private void handleKeyPressedEvent(final Event event) {
	switch (event.keyCode) {
		case SWT.ARROW_LEFT:
			if (selection == -1) {
				selection = 0;
				changeColor(selection, true);
				return;
			}

			if (selection % 2 != 0) {
				changeColor(selection, false);
				selection--;
				changeColor(selection, true);
			}
			break;
		case SWT.ARROW_UP:
			if (selection == -1) {
				selection = 0;
				changeColor(selection, true);
				return;
			}
			if (selection >= 2) {
				changeColor(selection, false);
				selection -= 2;
				changeColor(selection, true);
			}
			break;
		case SWT.ARROW_RIGHT:
			if (selection == -1) {
				selection = 0;
				changeColor(selection, true);
				return;
			}
			if (selection % 2 == 0) {
				changeColor(selection, false);
				selection++;
				changeColor(selection, true);
			}
			break;
		case SWT.ARROW_DOWN:
			if (selection == -1) {
				selection = 0;
				changeColor(selection, true);
				return;
			}
			if (selection <= items.size() - 2) {
				changeColor(selection, false);
				selection += 2;
				changeColor(selection, true);
			}
			break;
		case SWT.HOME:
			changeColor(selection, false);
			selection = 0;
			changeColor(selection, true);
			break;
		case SWT.END:
			changeColor(selection, false);
			selection = items.size() - 1;
			changeColor(selection, true);
			break;
	}

}
 
Example 19
Source File: ChartSheetImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void createButtonGroup( Composite parent )
{
	Composite cmp = new Composite( parent, SWT.NONE );
	{
		cmp.setLayout( new GridLayout( 5, false ) );
		GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
		gridData.horizontalSpan = 3;
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = SWT.END;
		cmp.setLayoutData( gridData );
	}

	ITaskPopupSheet popup;

	popup = new BlockPropertiesSheet( Messages.getString( "ChartSheetImpl.Text.Outline" ), //$NON-NLS-1$
			getContext( ) );
	Button btnBlockProp = createToggleButton( cmp,
			BUTTON_OUTLINE,
			Messages.getString( "ChartSheetImpl.Text.Outline&" ), //$NON-NLS-1$
			popup );
	btnBlockProp.addSelectionListener( this );
	
	// Chart Visibility
	popup = new VisibilitySheet( Messages.getString( "ChartSheetImpl.Group.EmptyMessage" ), //$NON-NLS-1$
			getContext( ) );
	Button btnVisibilityProp = createToggleButton( cmp,
			BUTTON_VISIBILITY,
			Messages.getString( "ChartSheetImpl.Group.EmptyMessage&" ), //$NON-NLS-1$
			popup );
	btnVisibilityProp.addSelectionListener( this );

	popup = new GeneralPropertiesChartSheet( Messages.getString( "ChartSheetImpl.Text.GeneralProperties" ), //$NON-NLS-1$
			getContext( ) );
	Button btnGeneralProp = createToggleButton( cmp,
			BUTTON_GERNERAL,
			Messages.getString( "ChartSheetImpl.Text.GeneralProperties&" ), //$NON-NLS-1$
			popup );
	btnGeneralProp.addSelectionListener( this );

	popup = new CustomPropertiesSheet( Messages.getString( "ChartSheetImpl.Text.CustomProperties" ), //$NON-NLS-1$
			getContext( ) );
	Button btnCustomProp = createToggleButton( cmp,
			BUTTON_CUSTOM,
			Messages.getString( "ChartSheetImpl.Text.CustomProperties&" ), //$NON-NLS-1$
			popup );
	btnCustomProp.addSelectionListener( this );

	// Interactivity
	if ( getContext( ).isInteractivityEnabled( ) )
	{
		popup = new InteractivitySheet( Messages.getString( "ChartSheetImpl.Label.Interactivity" ), //$NON-NLS-1$
				getContext( ),
				getChart( ).getBlock( ).getTriggers( ),
				getChart( ).getBlock( ),
				TriggerSupportMatrix.TYPE_CHARTAREA,
				TriggerDataComposite.ENABLE_SHOW_TOOLTIP_VALUE );
		Button btnInteractivity = createToggleButton( cmp,
				BUTTON_INTERACTIVITY,
				Messages.getString( "SeriesYSheetImpl.Label.Interactivity&" ), //$NON-NLS-1$
				popup,
				getChart( ).getInteractivity( ).isEnable( ) );
		btnInteractivity.addSelectionListener( this );
	}
}
 
Example 20
Source File: ChartTitleSheetImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void createButtonGroup( Composite parent )
{
	Composite cmp = new Composite( parent, SWT.NONE );
	{
		cmp.setLayout( new GridLayout( 5, false ) );
		GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
		gridData.grabExcessVerticalSpace = true;
		gridData.verticalAlignment = SWT.END;
		cmp.setLayoutData( gridData );
	}

	ITaskPopupSheet popup;
	// Title Text
	popup = new TitleTextSheet( Messages.getString( "ChartTitleSheetImpl.Text.TitleText" ), //$NON-NLS-1$
			getContext( ) );
	Button btnTitleProp = createToggleButton( cmp,
			BUTTON_TEXT,
			Messages.getString( "ChartTitleSheetImpl.Text.TitleText&" ), //$NON-NLS-1$
			popup,
			getChart( ).getTitle( ).isVisible( ) );
	btnTitleProp.addSelectionListener( this );

	// Title Layout
	popup = new TitleBlockSheet( Messages.getString( "ChartTitleSheetImpl.Text.TitleLayout" ), //$NON-NLS-1$
			getContext( ) );
	Button btnBlockProp = createToggleButton( cmp,
			BUTTON_LAYOUT,
			Messages.getString( "ChartTitleSheetImpl.Text.Layout&" ), //$NON-NLS-1$
			popup,
			getChart( ).getTitle( ).isVisible( ) );
	btnBlockProp.addSelectionListener( this );

	// Interactivity
	if ( getContext( ).isInteractivityEnabled( ) )
	{
		popup = new InteractivitySheet( Messages.getString( "ChartTitleSheetImpl.Label.Interactivity" ), //$NON-NLS-1$
				getContext( ),
				getChart( ).getTitle( ).getTriggers( ),
				getChart( ).getTitle( ),
				TriggerSupportMatrix.TYPE_CHARTTITLE,
				TriggerDataComposite.ENABLE_SHOW_TOOLTIP_VALUE );
		Button btnInteractivity = createToggleButton( cmp,
				BUTTON_INTERACTIVITY,
				Messages.getString( "SeriesYSheetImpl.Label.Interactivity&" ), //$NON-NLS-1$
				popup,
				getChart( ).getInteractivity( ).isEnable( ) );
		btnInteractivity.addSelectionListener( this );
	}
}