Java Code Examples for org.eclipse.swt.custom.CCombo#addListener()

The following examples show how to use org.eclipse.swt.custom.CCombo#addListener() . 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: CComboWidget.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Control createControl() {
    final Composite container = new Composite(this, SWT.NONE);
    container.setLayout(GridLayoutFactory.fillDefaults().margins(1, 1).create());
    container.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(labelAbove ? 2 : 1, 1).create());
    container.setBackground(
            readOnly ? Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)
                    : Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    container.addListener(SWT.Paint, e -> drawBorder(container, e));

    int textStyle = 0;
    if (readOnly) {
        textStyle = SWT.READ_ONLY;
    }

    combo = new CCombo(container, textStyle);
    combo.setData(SWTBOT_WIDGET_ID_KEY, id);
    combo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    combo.addListener(SWT.FocusIn, event -> redraw(container));
    combo.addListener(SWT.FocusOut, event -> redraw(container));
    combo.setEditable(!readOnly);

    return container;
}
 
Example 2
Source File: OutputParametersMappingSection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private CCombo createSubprocessSourceCombo(final Composite outputMappingControl, final OutputMapping mapping) {
    final CCombo subprocessSourceCombo = getWidgetFactory().createCCombo(outputMappingControl, SWT.BORDER);
    for (final Data subprocessData : callActivityHelper.getCallActivityData()) {
        subprocessSourceCombo.add(subprocessData.getName());
    }
    subprocessSourceCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(15, 0).create());
    subprocessSourceCombo.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            getEditingDomain().getCommandStack()
                    .execute(
                            new SetCommand(getEditingDomain(), mapping,
                                    ProcessPackage.Literals.OUTPUT_MAPPING__SUBPROCESS_SOURCE, subprocessSourceCombo
                                            .getText()));
        }
    });
    if (mapping.getSubprocessSource() != null) {
        subprocessSourceCombo.setText(mapping.getSubprocessSource());
    }
    return subprocessSourceCombo;
}
 
Example 3
Source File: InputParametersMappingSection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected CCombo createInputMappingTargetCombo(final Composite outputMappingControl, final InputMapping mapping) {
    final CCombo targetCombo = getWidgetFactory().createCCombo(outputMappingControl, SWT.BORDER);
    final InputMappingAssignationType assignationType = mapping.getAssignationType();
    updateAvailableValuesInputMappingTargetCombo(targetCombo, assignationType);
    final GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    targetCombo.setLayoutData(layoutData);
    targetCombo.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            getEditingDomain().getCommandStack().execute(
                    new SetCommand(getEditingDomain(), mapping, ProcessPackage.Literals.INPUT_MAPPING__SUBPROCESS_TARGET,
                            targetCombo.getText()));
        }
    });
    if (mapping.getSubprocessTarget() != null) {
        targetCombo.setText(mapping.getSubprocessTarget());
    }
    targetCombo.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_CALLACTIVITY_MAPPING_INPUT_CALLEDTARGET);
    return targetCombo;
}
 
Example 4
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * New C combo with tip.
 *
 * @param parent the parent
 * @param tip the tip
 * @return the c combo
 */
protected CCombo newCComboWithTip(Composite parent, String tip) {
  CCombo ccombo = new CCombo(parent, SWT.FLAT | SWT.READ_ONLY);
  toolkit.adapt(ccombo, false, false);
  ccombo.setToolTipText(tip);
  ccombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
  ccombo.addListener(SWT.Selection, this);
  // Make the CCombo's border visible since CCombo is NOT a widget supported
  // by FormToolkit.
  // needed apparently by RedHat Linux 
  ccombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
  return ccombo;
}
 
Example 5
Source File: VfsFileChooserControls.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected void addFileWidgets() {
  Label wlLocation = new Label( this, SWT.RIGHT );
  wlLocation.setText( BaseMessages.getString( PKG, "VfsFileChooserControls.Location.Label" ) );
  wlLocation.setLayoutData( new FormDataBuilder( ).left( 0, 0 ).top( 0, 0 ).result() );
  wLocation = new CCombo( this, SWT.BORDER | SWT.READ_ONLY );
  List<VFSScheme> availableVFSSchemes = getAvailableVFSSchemes();
  availableVFSSchemes.forEach( scheme -> wLocation.add( scheme.schemeName ) );
  wLocation.addListener( SWT.Selection, event -> {
    this.selectedVFSScheme = availableVFSSchemes.get( wLocation.getSelectionIndex() );
    this.wPath.setText( "" );
  } );
  if ( !availableVFSSchemes.isEmpty() ) {
    wLocation.select( 0 );
    this.selectedVFSScheme = availableVFSSchemes.get( wLocation.getSelectionIndex() );
  }
  wLocation.addModifyListener( lsMod );
  wLocation.setLayoutData(
    new FormDataBuilder().left( 0, 0 ).top( wlLocation, FIELD_LABEL_SEP ).width( FIELD_SMALL ).result() );

  Label wlPath = new Label( this, SWT.RIGHT );
  wlPath.setText( BaseMessages.getString( PKG, "VfsFileChooserControls.Filename.Label" ) );
  wlPath.setLayoutData( new FormDataBuilder().left( 0, 0 ).top( wLocation, FIELDS_SEP ).result() );
  wPath = new TextVar( space, this, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  wPath.addModifyListener( lsMod );
  wPath.setLayoutData( new FormDataBuilder().left( 0, 0 ).top( wlPath, FIELD_LABEL_SEP ).width( FIELD_LARGE + VAR_EXTRA_WIDTH ).result() );

  wbBrowse = new Button( this, SWT.PUSH );
  wbBrowse.setText( BaseMessages.getString( PKG, "System.Button.Browse" ) );
  wbBrowse.addListener( SWT.Selection, event -> browseForFileInputPath() );
  int bOffset = ( wbBrowse.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y
    - wPath.computeSize( SWT.DEFAULT, SWT.DEFAULT, false ).y ) / 2;
  wbBrowse.setLayoutData( new FormDataBuilder().left( wPath, FIELD_LABEL_SEP ).top( wlPath, FIELD_LABEL_SEP - bOffset ).result() );
}
 
Example 6
Source File: ChartCubeFilterConditionBuilder.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private CCombo createExpressionValue( Composite parent )
{
	final CCombo expressionValue = new CCombo( parent, SWT.BORDER );
	expressionValue.add( CHOICE_SELECT_VALUE );
	expressionValue.addListener( SWT.Verify, expValueVerifyListener );
	expressionValue.addListener( SWT.Selection, expValueSelectionListener );
	Listener listener = new Listener( ) {

		public void handleEvent( Event event )
		{
			updateButtons( );
		}

	};
	expressionValue.addListener( SWT.Modify, listener );
	expressionValue.addListener( SWT.MouseDown, new Listener( ) {

		public void handleEvent( Event arg0 )
		{
			if ( isMeasureSelected( ) )
			{
				if ( expressionValue.getItemCount( ) > 0 )
				{
					expressionValue.remove( 0 );
				}
				expressionValue.setVisibleItemCount( 0 );
			}
			else
			{
				if ( expressionValue.getItemCount( ) == 0 )
				{
					expressionValue.add( CHOICE_SELECT_VALUE );
				}
				expressionValue.setVisibleItemCount( 1 );
			}
		}
	} );
	
	IExpressionButton ceb = ChartExpressionButtonUtil.createExpressionButton( parent,
			expressionValue,
			(ExtendedItemHandle) designHandle,
			expressionProvider );
	ceb.addListener( listener );

	return expressionValue;
}
 
Example 7
Source File: StandardChartDataSheet.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Composite createDataSelector( Composite parent )
{
	parentComposite = parent;
	// select the only data set
	if ( itemHandle.getDataBindingType( ) == ReportItemHandle.DATABINDING_TYPE_NONE
			&& itemHandle.getContainer( ) instanceof ModuleHandle )
	{
		DataSetInfo[] dataSets = dataProvider.getAllDataSets( );
		if ( dataProvider.getAllDataCubes( ).length == 0
				&& dataSets.length == 1 )
		{
			dataProvider.setDataSet( dataSets[0] );
		}
	}

	Composite cmpDataSet = ChartUIUtil.createCompositeWrapper( parent );
	{
		cmpDataSet.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	}

	Label label = new Label( cmpDataSet, SWT.NONE );
	{
		label.setText( Messages.getString( "StandardChartDataSheet.Label.SelectDataSet" ) ); //$NON-NLS-1$
		label.setFont( JFaceResources.getBannerFont( ) );
	}

	Composite cmpDetail = new Composite( cmpDataSet, SWT.NONE );
	{
		GridLayout gridLayout = new GridLayout( 2, false );
		gridLayout.marginWidth = 10;
		gridLayout.marginHeight = 0;
		cmpDetail.setLayout( gridLayout );
		cmpDetail.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	}

	Composite compRadios = ChartUIUtil.createCompositeWrapper( cmpDetail );
	{
		GridData gd = new GridData( );
		gd.verticalSpan = 2;
		compRadios.setLayoutData( gd );
	}

	btnInherit = new Button( compRadios, SWT.RADIO );
	btnInherit.setText( Messages.getString( "StandardChartDataSheet.Label.UseReportData" ) ); //$NON-NLS-1$
	btnInherit.addListener( SWT.Selection, this );

	btnUseData = new Button( compRadios, SWT.RADIO );
	btnUseData.setText( Messages.getString( "StandardChartDataSheet.Label.UseDataSet" ) ); //$NON-NLS-1$
	btnUseData.addListener( SWT.Selection, this );

	cmbInherit = new CCombo( cmpDetail, SWT.DROP_DOWN
			| SWT.READ_ONLY
			| SWT.BORDER );
	cmbInherit.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cmbInherit.addListener( SWT.Selection, this );

	cmbDataItems = new DataItemCombo( cmpDetail, SWT.DROP_DOWN
			| SWT.READ_ONLY
			| SWT.BORDER ) {

		@Override
		public boolean triggerSelection( int index )
		{
			int selectState = selectDataTypes.get( index ).intValue( );
			if ( selectState == SELECT_NEW_DATASET
					|| selectState == SELECT_NEW_DATACUBE )
			{
				return false;
			}
			return true;
		}

		@Override
		public boolean skipSelection( int index )
		{
			//skip out of boundary selection
			if(index>=0){
				int selectState = selectDataTypes.get( index ).intValue( );
				if ( selectState == SELECT_NEXT )
				{
					return true;
				}
			}
				
			return false;
		}
	};
	cmbDataItems.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
	cmbDataItems.addListener( SWT.Selection, this );
	cmbDataItems.setVisibleItemCount( 30 );

	initDataSelector( );
	updatePredefinedQueries( );
	checkDataBinding( );
	if ( dataProvider.checkState( IDataServiceProvider.IN_MULTI_VIEWS ) )
	{
		autoSelect( false );
	}
	return cmpDataSet;
}