下面列出了org.eclipse.swt.widgets.Spinner#addListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createAnimationGroup(Composite parent) {
Group animationGroup = createEmptyGroup(parent, "Animation");
animationGroup.setLayout(new RowLayout());
bAnimation = createButton(animationGroup, SWT.CHECK, "Animations", false, false);
bAnimation.addListener(SWT.Selection, groupParamSelectionListener);
cAnimationMovement = new Combo(animationGroup, SWT.READ_ONLY);
cAnimationMovement.setItems(new String[] { "ExpoOut", "BounceOut", "ElasticOut", "LinearInOut" });
cAnimationMovement.setText("ExpoOut");
cAnimationMovement.addListener(SWT.Selection, groupParamSelectionListener);
sAnimationDuration = new Spinner(animationGroup, SWT.NONE);
sAnimationDuration.setMinimum(250);
sAnimationDuration.setMaximum(5000);
sAnimationDuration.setIncrement(100);
sAnimationDuration.setSelection(500);
sAnimationDuration.addListener(SWT.Selection, groupParamSelectionListener);
}
private void createDecoratorsGroup(Composite parent) {
Group dataGroup = createEmptyGroup(parent, "Decorators");
dataGroup.setLayout(new RowLayout());
sDecoratorNumber = new Spinner(dataGroup, SWT.NONE);
sDecoratorNumber.setMinimum(1);
sDecoratorNumber.setMaximum(5);
sDecoratorNumber.setIncrement(1);
sDecoratorNumber.setSelection(1);
sDecoratorNumber.addListener(SWT.Selection, contentParamSelectionListener);
bDecoratorLeft = createButton(dataGroup, SWT.CHECK, "Top Left", false, false);
bDecoratorLeft.addListener(SWT.Selection, contentParamSelectionListener);
bDecoratorUp = createButton(dataGroup, SWT.CHECK, "Top Right", false, false);
bDecoratorUp.addListener(SWT.Selection, contentParamSelectionListener);
bDecoratorRight = createButton(dataGroup, SWT.CHECK, "Bottom Right", false, false);
bDecoratorRight.addListener(SWT.Selection, contentParamSelectionListener);
bDecoratorDown = createButton(dataGroup, SWT.CHECK, "Bottom Left", false, false);
bDecoratorDown.addListener(SWT.Selection, contentParamSelectionListener);
}
private void createItemParametersGroup(Composite parent) {
Group dataGroup = createEmptyGroup(parent, "Item parameters");
dataGroup.setLayout(new RowLayout());
cItemRenderer = new Combo(dataGroup, SWT.READ_ONLY);
cItemRenderer.setItems(new String[] { "Icon", "List" });
cItemRenderer.setText("Icon");
cItemRenderer.addListener(SWT.Selection, itemRendererParamSelectionListener);
bItemDropShadow = createButton(dataGroup, SWT.CHECK, "Drop shadow", false, true);
sItemDropShadowSize = new Spinner(dataGroup, SWT.NONE);
sItemDropShadowSize.setMinimum(0);
sItemDropShadowSize.setMaximum(20);
sItemDropShadowSize.setIncrement(1);
sItemDropShadowSize.setSelection(5);
sItemDropShadowSize.addListener(SWT.Selection, itemRendererParamSelectionListener);
bItemLabel = createButton(dataGroup, SWT.CHECK, "Display labels", false, true);
}
/**
* @see org.eclipse.nebula.widgets.opal.preferencewindow.widgets.PWWidget#build(org.eclipse.swt.widgets.Composite)
*/
@Override
public Control build(final Composite parent) {
buildLabel(parent, GridData.CENTER);
final Spinner spinner = new Spinner(parent, SWT.HORIZONTAL | SWT.BORDER);
addControl(spinner);
spinner.setMinimum(min);
spinner.setMaximum(max);
final Integer originalValue = (Integer) PreferenceWindow.getInstance().getValueFor(getPropertyKey());
spinner.setSelection(originalValue.intValue());
spinner.addListener(SWT.Modify, event -> {
PreferenceWindow.getInstance().setValue(getPropertyKey(), Integer.valueOf(spinner.getSelection()));
});
return spinner;
}
private Spinner createPageCountSpinner(Composite parent,
Listener selectionListener) {
Spinner spinner = new Spinner(parent, SWT.BORDER);
spinner.setMinimum(1);
spinner.setMaximum(99);
spinner.addListener(SWT.Selection, selectionListener);
return spinner;
}
private Spinner createPageCountSpinner(Composite parent,
Listener selectionListener) {
Spinner spinner = new Spinner(parent, SWT.BORDER);
spinner.setMinimum(1);
spinner.setMaximum(99);
spinner.addListener(SWT.Selection, selectionListener);
return spinner;
}
private void placeComponents( )
{
GridLayout glNumberStandard = new GridLayout( );
glNumberStandard.verticalSpacing = 5;
glNumberStandard.numColumns = 4;
glNumberStandard.marginHeight = 2;
glNumberStandard.marginWidth = 2;
GridData gdGRPNumberStandard = new GridData( GridData.FILL_BOTH );
this.setLayoutData( gdGRPNumberStandard );
this.setLayout( glNumberStandard );
lblPrefix = new Label( this, SWT.NONE );
GridData gdLBLPrefix = new GridData( );
lblPrefix.setLayoutData( gdLBLPrefix );
lblPrefix.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Prefix" ) ); //$NON-NLS-1$
txtPrefix = new Text( this, SWT.BORDER | SWT.SINGLE );
GridData gdTXTPrefix = new GridData( GridData.FILL_HORIZONTAL );
gdTXTPrefix.widthHint = 60;
txtPrefix.setLayoutData( gdTXTPrefix );
txtPrefix.addModifyListener( this );
lblSuffix = new Label( this, SWT.NONE );
GridData gdLBLSuffix = new GridData( );
lblSuffix.setLayoutData( gdLBLSuffix );
lblSuffix.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Suffix" ) ); //$NON-NLS-1$
txtSuffix = new Text( this, SWT.BORDER | SWT.SINGLE );
GridData gdTXTSuffix = new GridData( GridData.FILL_HORIZONTAL );
gdTXTSuffix.widthHint = 60;
txtSuffix.setLayoutData( gdTXTSuffix );
txtSuffix.addModifyListener( this );
lblMultiplier = new Label( this, SWT.NONE );
GridData gdLBLMultiplier = new GridData( );
lblMultiplier.setLayoutData( gdLBLMultiplier );
lblMultiplier.setText( Messages.getString( "FormatSpecifierComposite.Lbl.Multiplier" ) ); //$NON-NLS-1$
txtMultiplier = new LocalizedNumberEditorComposite( this,
SWT.BORDER | SWT.SINGLE );
new TextNumberEditorAssistField( txtMultiplier.getTextControl( ), null );
GridData gdTXTMultiplier = new GridData( GridData.FILL_HORIZONTAL );
gdTXTMultiplier.widthHint = 60;
txtMultiplier.setLayoutData( gdTXTMultiplier );
txtMultiplier.addModifyListener( this );
lblFractionDigit = new Label( this, SWT.NONE );
GridData gdLBLFractionDigit = new GridData( );
lblFractionDigit.setLayoutData( gdLBLFractionDigit );
lblFractionDigit.setText( Messages.getString( "FormatSpecifierComposite.Lbl.FractionDigits" ) ); //$NON-NLS-1$
iscFractionDigits = new Spinner( this, SWT.BORDER );
GridData gdISCFractionDigits = new GridData( GridData.FILL_HORIZONTAL );
gdISCFractionDigits.widthHint = 60;
iscFractionDigits.setLayoutData( gdISCFractionDigits );
iscFractionDigits.setSelection( 2 );
iscFractionDigits.addListener( SWT.Selection, this );
}