下面列出了org.eclipse.swt.widgets.Combo#setVisibleItemCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createParentMandatoryGroup(Group parent) {
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 10;
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
Group group = new Group(parent, SWT.NONE);
group.setLayout(gridLayout);
group.setLayoutData(gridData);
group.setText(ResourceString.getResourceString("label.mandatory"));
parentCardinalityCombo = new Combo(group, SWT.NONE);
parentCardinalityCombo.setLayoutData(gridData);
parentCardinalityCombo.setVisibleItemCount(5);
parentCardinalityCombo.add("1");
parentCardinalityCombo.add("0..1");
}
@Override
protected Control createDialogArea( Composite parent )
{
Composite content = new Composite( parent, SWT.NONE );
content.setLayoutData( GridDataFactory.swtDefaults( ).hint( 300,
SWT.DEFAULT ).create( ) );
content.setLayout( GridLayoutFactory.swtDefaults( )
.numColumns( 2 )
.margins( 15, 15 )
.create( ) );
new Label( content, SWT.NONE ).setText( Messages.getString("SelectVariableDialog.AvailableVariables") ); //$NON-NLS-1$
variablesCombo = new Combo( content, SWT.READ_ONLY );
variablesCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
variablesCombo.setVisibleItemCount( 30 );
variablesCombo.addSelectionListener( new SelectionAdapter( ) {
public void widgetSelected( SelectionEvent e )
{
validate( );
}
} );
UIUtil.bindHelp( parent, IHelpContextIds.SELECT_VARIABLE_DIALOG_ID );
return content;
}
private void createParentMandatoryGroup(final Group parent) {
final GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 10;
final GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
final Group group = new Group(parent, SWT.NONE);
group.setLayout(gridLayout);
group.setLayoutData(gridData);
group.setText(ResourceString.getResourceString("label.mandatory"));
parentCardinalityCombo = new Combo(group, SWT.NONE);
parentCardinalityCombo.setLayoutData(gridData);
parentCardinalityCombo.setVisibleItemCount(5);
parentCardinalityCombo.add(Relation.PARENT_CARDINALITY_1);
if (!relation.getForeignKeyColumns().get(0).isPrimaryKey()) {
parentCardinalityCombo.add(Relation.PARENT_CARDINALITY_0_OR_1);
}
}
private void createParentMandatoryGroup(Group parent) {
final GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 10;
final GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
final Group group = new Group(parent, SWT.NONE);
group.setLayout(gridLayout);
group.setLayoutData(gridData);
group.setText(DisplayMessages.getMessage("label.mandatory"));
parentCardinalityCombo = new Combo(group, SWT.NONE);
parentCardinalityCombo.setLayoutData(gridData);
parentCardinalityCombo.setVisibleItemCount(5);
parentCardinalityCombo.add("1");
parentCardinalityCombo.add("0..1");
}
private void createChildMandatoryGroup(Group parent) {
final GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 10;
final GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
final Group group = new Group(parent, SWT.NONE);
group.setLayout(gridLayout);
group.setLayoutData(gridData);
group.setText(DisplayMessages.getMessage("label.mandatory"));
childCardinalityCombo = new Combo(group, SWT.NONE);
childCardinalityCombo.setLayoutData(gridData);
childCardinalityCombo.setVisibleItemCount(5);
childCardinalityCombo.add("1..n");
childCardinalityCombo.add("0..n");
childCardinalityCombo.add("1");
childCardinalityCombo.add("0..1");
}
public void createContent( Composite parent )
{
controlTypeChooser = new Combo( parent, SWT.READ_ONLY | SWT.DROP_DOWN );
controlTypeChooser.setVisibleItemCount( 30 );
controlTypeChooser.addListener( SWT.Selection, new Listener( ) {
public void handleEvent( Event e )
{
List<Listener> listeners = DefaultParameterDialogControlTypeHelper.this.listeners.get( SWT.Selection );
if ( listeners == null )
return;
for ( int i = 0; i < listeners.size( ); i++ )
listeners.get( i ).handleEvent( e );
}
} );
}
protected Combo newComboControl( Composite composite, Key key,
String[] values, String[] valueLabels )
{
ControlData data = new ControlData( key, values );
Combo comboBox = new Combo( composite, SWT.READ_ONLY );
comboBox.setVisibleItemCount( 30 );
comboBox.setItems( valueLabels );
comboBox.setData( data );
comboBox.addSelectionListener( getSelectionListener( ) );
comboBox.setFont( JFaceResources.getDialogFont( ) );
String currValue = getValue( key );
comboBox.select( data.getSelection( currValue ) );
fComboBoxes.add( comboBox );
return comboBox;
}
protected Control createDialogArea( Composite parent )
{
getShell( ).setText( fShellTitle );
Composite composite = (Composite) super.createDialogArea( parent );
Composite innerComposite = new Composite( composite, SWT.NONE );
innerComposite.setLayoutData( new GridData( ) );
GridLayout gl = new GridLayout( );
gl.numColumns = 2;
innerComposite.setLayout( gl );
Label label = new Label( innerComposite, SWT.NONE );
label.setText( fLabelText );
label.setLayoutData( new GridData( ) );
final Combo combo = new Combo( innerComposite, SWT.READ_ONLY );
for ( int i = 0; i < fAllowedStrings.length; i++ )
{
combo.add( fAllowedStrings[i] );
}
if ( fInitialSelectionIndex != -1 )
{
combo.select( fInitialSelectionIndex );
fSelection = combo.getItem( combo.getSelectionIndex( ) );
}
GridData gd = new GridData( );
gd.widthHint = convertWidthInCharsToPixels( getMaxStringLength( ) );
combo.setLayoutData( gd );
combo.setVisibleItemCount( 30 );
combo.addSelectionListener( new SelectionAdapter( ) {
public void widgetSelected( SelectionEvent e )
{
fSelection = combo.getItem( combo.getSelectionIndex( ) );
}
} );
applyDialogFont( composite );
return composite;
}
public static Combo createEngineCombo(final Composite parent, final AbstractDialog dialog) {
final Combo combo = CompositeFactory.createCombo(dialog, parent, "label.storage.engine", 1);
combo.setVisibleItemCount(20);
initEngineCombo(combo);
return combo;
}
protected Control createDialogArea( Composite parent )
{
Composite composite = (Composite) super.createDialogArea( parent );
new Label( composite, SWT.NONE ).setText( Messages.getString( "dataset.editor.label.selectDataSource" ) ); //$NON-NLS-1$
combo = new Combo( composite, SWT.BORDER | SWT.READ_ONLY );
combo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
combo.setVisibleItemCount( 30 );
combo.setItems( dataSourceNames );
UIUtil.bindHelp( parent,
IHelpContextIds.ADD_DATA_SOURCE_SELECTION_DIALOG_ID );
return composite;
}
public static Combo createEngineCombo(Composite parent,
AbstractDialog dialog) {
Combo combo = CompositeFactory.createCombo(dialog, parent,
"label.storage.engine", 1);
combo.setVisibleItemCount(20);
initEngineCombo(combo);
return combo;
}
protected void initCategoryCombo(final Combo categoryCombo) {
categoryCombo.add(ResourceString.getResourceString("label.all"));
for (final Category category : categoryList) {
categoryCombo.add(category.getName());
}
categoryCombo.setVisibleItemCount(20);
}
@Override
protected Control createDialogArea(Composite parent){
Composite ret = new Composite(parent, SWT.NONE);
ret.setLayout(new GridLayout());
ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
cbStates = new Combo(ret, SWT.READ_ONLY);
cbStates.setItems(RnStatus.getStatusTexts());
cbStates.setVisibleItemCount(RnStatus.getStatusTexts().length);
cbStates.select(rn.getStatus());
cbStates.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
new Label(ret, SWT.WRAP).setText(Messages.RnDialogs_warningDontChangeManually); //$NON-NLS-1$
return ret;
}
public static Combo createEngineCombo(Composite parent, AbstractDialog dialog) {
final Combo combo = CompositeFactory.createCombo(dialog, parent, "label.storage.engine", 1);
combo.setVisibleItemCount(20);
initEngineCombo(combo);
return combo;
}
private void createReferredColumnSelector(Composite composite) {
final Label label = new Label(composite, SWT.NONE);
label.setText("Referred Column");
final GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
referredColumnSelector = new Combo(composite, SWT.READ_ONLY);
referredColumnSelector.setLayoutData(gridData);
referredColumnSelector.setVisibleItemCount(20);
}
private Combo createIntermediaryTypeCombo(Composite composite) {
final Combo textCombo= new Combo(composite, SWT.SINGLE | SWT.BORDER);
textCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
textCombo.setItems(fgIntermediaryTypes.toArray(new String[fgIntermediaryTypes.size()]));
textCombo.setVisibleItemCount(INTERMEDIARY_TYPE_COUNT);
JavaTypeCompletionProcessor processor= new JavaTypeCompletionProcessor(false, false, true);
processor.setPackageFragment(getIntroduceIndirectionRefactoring().getInvocationPackage());
ControlContentAssistHelper.createComboContentAssistant(textCombo, processor);
TextFieldNavigationHandler.install(textCombo);
return textCombo;
}
private void createRightComponent( Composite composite )
{
Label formatLabel = new Label( composite, SWT.CENTER | SWT.SINGLE );
formatLabel.setText( LABEL_FORMAT );
formatLabel.setBounds( 0, 8, 60, 30 );
combo = new Combo( composite, SWT.READ_ONLY | SWT.DROP_DOWN );
List list = TimeFormat.getDefaultFormat( ).getSupportList( );
String[] items = new String[list.size( )];
list.toArray( items );
combo.setBounds( 60, 2, 150, 30 );
combo.setVisibleItemCount( 30 );
combo.setItems( items );
combo.select( 0 );
Label zoneLabel = new Label( composite, SWT.CENTER );
zoneLabel.setText( LABEL_TIMEZONE );
zoneLabel.setBounds( 0, 108, 60, 30 );
zoneCombo = new Combo( composite, SWT.READ_ONLY | SWT.SINGLE );
zoneCombo.setVisibleItemCount( 30 );
items = TimeZone.getAvailableIDs( );
zoneCombo.setBounds( 60, 102, 150, 30 );
zoneCombo.setItems( items );
zoneCombo.select( 0 );
}
/**
* Creates the group area
*
* @param parent
* the parent composite
*/
private void createGroupArea( Composite parent )
{
Composite composite = new Composite( parent, SWT.NONE );
GridData layoutData = new GridData( GridData.FILL_HORIZONTAL
| GridData.VERTICAL_ALIGN_BEGINNING );
layoutData.verticalSpan = 2;
composite.setLayoutData( layoutData );
composite.setLayout( new GridLayout( ) );
sortingGroup = new Group( composite, SWT.NONE );
sortingGroup.setText( SORT_GROUP_TITLE );
sortingGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
sortingGroup.setLayout( new FillLayout( SWT.VERTICAL ) );
Composite sortingGroupComposite = new Composite( sortingGroup, SWT.NONE );
sortingGroupComposite.setLayout( new GridLayout( ) );
ascending = new Button( sortingGroupComposite, SWT.RADIO );
// ascending.setText( sortByAscending.getDisplayName( ) );
ascending.setText( Messages.getString( "GroupDialog.Button.Ascending" ) ); //$NON-NLS-1$
descending = new Button( sortingGroupComposite, SWT.RADIO );
// descending.setText( sortByDescending.getDisplayName( ) );
descending.setText( Messages.getString( "GroupDialog.Button.Descending" ) ); //$NON-NLS-1$
Group pagebreakGroup = new Group( composite, SWT.NONE );
pagebreakGroup.setText( Messages.getString( "GroupDialog.PageBreak" ) ); //$NON-NLS-1$
pagebreakGroup.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
GridLayout layout = new GridLayout( );
layout.numColumns = 3;
pagebreakGroup.setLayout( layout );
new Label( pagebreakGroup, SWT.NONE ).setText( Messages.getString( "GroupDialog.PageBreakBefore" ) ); //$NON-NLS-1$
pagebreakBeforeCombo = new Combo( pagebreakGroup, SWT.READ_ONLY
| SWT.DROP_DOWN );
for ( int i = 0; i < pagebreakBeforeChoicesAll.length; i++ )
{
pagebreakBeforeCombo.add( pagebreakBeforeChoicesAll[i].getDisplayName( ) );
}
pagebreakBeforeCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
pagebreakBeforeCombo.setVisibleItemCount( 30 );
WidgetUtil.createGridPlaceholder( pagebreakGroup, 1, true );
pagebreakBeforeCombo.setData( pagebreakBeforeChoicesAll );
new Label( pagebreakGroup, SWT.NONE ).setText( Messages.getString( "GroupDialog.PageBreakAfter" ) ); //$NON-NLS-1$
pagebreakAfterCombo = new Combo( pagebreakGroup, SWT.READ_ONLY
| SWT.DROP_DOWN );
for ( int i = 0; i < pagebreakAfterChoicesAll.length; i++ )
{
pagebreakAfterCombo.add( pagebreakAfterChoicesAll[i].getDisplayName( ) );
}
pagebreakAfterCombo.setVisibleItemCount( 30 );
pagebreakAfterCombo.setData( pagebreakAfterChoicesAll );
pagebreakAfterCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
WidgetUtil.createGridPlaceholder( pagebreakGroup, 1, true );
new Label( pagebreakGroup, SWT.NONE ).setText( Messages.getString( "GroupDialog.PageBreakInside" ) ); //$NON-NLS-1$
pagebreakInsideCombo = new Combo( pagebreakGroup, SWT.READ_ONLY
| SWT.DROP_DOWN );
for ( int i = 0; i < pagebreakInsideChoicesAll.length; i++ )
{
pagebreakInsideCombo.add( pagebreakInsideChoicesAll[i].getDisplayName( ) );
}
pagebreakInsideCombo.setVisibleItemCount( 30 );
pagebreakInsideCombo.setData( pagebreakInsideChoicesAll );
pagebreakInsideCombo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
WidgetUtil.createGridPlaceholder( pagebreakGroup, 1, true );
repeatHeaderButton = new Button( pagebreakGroup, SWT.CHECK );
repeatHeaderButton.setText( Messages.getString( "GroupDialog.RepeatHeader" ) ); //$NON-NLS-1$
GridData data = new GridData( );
data.horizontalSpan = 3;
repeatHeaderButton.setLayoutData( data );
PropertyHandle propertyHandle = inputGroup.getPropertyHandle( TableHandle.SORT_PROP );
if ( propertyHandle.iterator( ).hasNext( ) )
{
ascending.setEnabled( false );
descending.setEnabled( false );
}
}
/**
* Sets the default visible item count for {@link Combo}s.
* Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=7845 .
*
* @param combo the combo
*
* @see Combo#setVisibleItemCount(int)
* @see #COMBO_VISIBLE_ITEM_COUNT
*
* @since 3.5
*/
public static void setDefaultVisibleItemCount(Combo combo) {
combo.setVisibleItemCount(COMBO_VISIBLE_ITEM_COUNT);
}
/**
* Sets the default visible item count for {@link Combo}s.
* Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=7845 .
*
* @param combo the combo
*
* @see Combo#setVisibleItemCount(int)
* @see #COMBO_VISIBLE_ITEM_COUNT
*
* @since 3.5
*/
public static void setDefaultVisibleItemCount(Combo combo) {
combo.setVisibleItemCount(COMBO_VISIBLE_ITEM_COUNT);
}