下面列出了org.eclipse.swt.widgets.Combo#getItemCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void fillExpression( Combo control )
{
if ( designHandle instanceof DataItemHandle
&& ( (DataItemHandle) designHandle ).getResultSetColumn( ) != null )
{
control.add( VALUE_OF_THIS_DATA_ITEM, 0 );
}
if ( control.getItemCount( ) == 0 )
{
control.add( DEUtil.resolveNull( null ) );
control.select( control.getItemCount( ) - 1 );
}
}
private void updateCombHistory(Combo combo) {
if (combo == null || combo.isDisposed()) {
return;
}
String value = combo.getText();
if (value == null || value.length() == 0) {
return;
}
int index = combo.indexOf(value);
if (index == 0) {
return;
}
if (index != -1) {
combo.remove(index);
}
int itemCount = combo.getItemCount();
if (itemCount == 0) {
combo.add(value, 0);
combo.setText(value);
return;
}
combo.add(value, 0);
combo.setText(value);
if (itemCount > 10) {
combo.remove(11);
}
}
private void fillExpression( Combo control )
{
if ( ( designHandle instanceof DataItemHandle )
&& ( ( (DataItemHandle) designHandle ).getResultSetColumn( ) != null ) )
{
control.add( VALUE_OF_THIS_DATA_ITEM, 0 );
}
if ( control.getItemCount( ) == 0 )
{
control.add( DEUtil.resolveNull( null ) );
control.select( control.getItemCount( ) - 1 );
}
}
/**
* If the combo is cascade then: If the value in the combo data list: then
* select the value else: then select the first item if items exists else :
* then set the value to combo
*
* @param value
* @param combo
* @param listParam
* @param isCascade
* @param comboData
*/
private void dealWithValueNotInComboList( Object value, Combo combo,
ScalarParameter listParam, boolean isCascade, Object comboData )
{
if ( !isCascade
|| ( isCascade && isContainValue( listParam.getDefaultObject( ),
comboData ) ) )
{
combo.setText( value == null ? NULL_VALUE_STR : value.toString( ) );
listParam.setSelectionValue( combo.getText( ) );
putConfigValue( listParam.getHandle( ).getName( ), combo.getText( ) );
}
else
{
if ( combo.getItemCount( ) > 0 )
{
combo.select( 0 );
listParam.setSelectionValue( combo.getText( ) );
putConfigValue( listParam.getHandle( ).getName( ),
combo.getData( String.valueOf( combo.getSelectionIndex( ) ) ) );
}
else
{
putConfigValue( listParam.getHandle( ).getName( ), null );
}
}
}
/**
* If value in combo data list ,then select it and return true; else do
* nothing and return false
*
* @param selectIndex
* : indicate which item will be selected
* @param value
* : the value which will be selected
* @param combo
* @param listParam
* @return
*/
private boolean dealWithValueInComboList( int selectIndex, Object value,
Combo combo, ScalarParameter listParam )
{
boolean found = false;
if ( selectIndex > 0 )
{
combo.select( selectIndex );
putConfigValue( listParam.getHandle( ).getName( ),
combo.getData( String.valueOf( combo.getSelectionIndex( ) ) ) );
listParam.setSelectionValue( lastConfigValues.get( listParam.getHandle( ).getName( ) ) );
found = true;
return found;
}
for ( int i = 0; i < combo.getItemCount( ); i++ )
{
Object data = combo.getData( String.valueOf( i ) );
if ( value == data || ( value != null && value.equals( data ) ) )
{
combo.select( i );
putConfigValue( listParam.getHandle( ).getName( ),
combo.getData( String.valueOf( combo.getSelectionIndex( ) ) ) );
listParam.setSelectionValue( lastConfigValues.get( listParam.getHandle( ).getName( ) ) );
found = true;
break;
}
}
return found;
}
/**
* Returns the index of the item, or adds it to the combo.
*
* @param combo
* @param value
* @return
*/
private int indexOf(Combo combo, char value){
for (int i=0; i < combo.getItems().length; i++) {
if (combo.getItem(i).toCharArray()[1]==value) {
return i;
}
}
combo.add("("+String.valueOf(value)+")"); //$NON-NLS-1$ //$NON-NLS-2$
return combo.getItemCount()-1;
}
/**
* Setups gateway SWT controls by populating a gateway combobox and configuring an information
* Label and the enabling checkbox.
*
* @param combo {@link Combo} selector to populate with discovered gateways
* @param info {@link Label} displaying status information of the discovery
* @param checkbox {@link Button} checkbox to enable/disable UPnP support
*/
private void populateGatewaySelectionControls(
List<GatewayDevice> gateways, final Combo combo, final Label info, final Button checkbox) {
combo.setEnabled(false);
checkbox.setEnabled(false);
combo.removeAll();
// if no devices are found, return now - nothing to populate
if (gateways == null || gateways.isEmpty()) {
info.setText(Messages.UPnPUIUtils_no_gateway);
info.getParent().pack();
return;
}
this.gateways = new ArrayList<GatewayDevice>();
// insert found gateways into combobox
for (GatewayDevice gw : gateways) {
try {
String name = gw.getFriendlyName();
if (!gw.isConnected()) name += Messages.UPnPUIUtils_disconnected;
combo.add(name);
this.gateways.add(gw);
} catch (Exception e) {
log.debug("Error updating UPnP selector:" + e.getMessage()); // $NON-NLS-1$
// ignore faulty gateway
}
}
// if valid gateway found, show info and enable
if (combo.getItemCount() > 0) {
checkbox.setEnabled(true);
combo.setEnabled(true);
combo.select(0);
combo.pack();
info.setVisible(false);
} else {
info.setText(Messages.UPnPUIUtils_no_valid_gateway);
}
info.getParent().pack();
}
@SuppressWarnings("unchecked")
@Override
protected Control createDialogArea(Composite parent){
lo = Extensions.getClasses(ExtensionPointConstantsData.RECHNUNGS_MANAGER, "outputter"); //$NON-NLS-1$ //$NON-NLS-2$
if (lo.isEmpty()) {
String msg = "Elexis has no textplugin configured for outputting bills!"; //$NON-NLS-1$
SWTHelper.alert(msg, msg);
return null;
}
Composite ret = new Composite(parent, SWT.NONE);
ret.setLayout(new GridLayout());
ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
cbLo = new Combo(ret, SWT.SINGLE | SWT.READ_ONLY);
cbLo.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
bCopy = new Button(ret, SWT.CHECK);
bCopy.setText(Messages.RnOutputDialog_markAsCopy); //$NON-NLS-1$
bCopy.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
final Composite bottom = new Composite(ret, SWT.NONE);
bottom.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
bottom.setLayout(stack);
for (IRnOutputter ro : lo) {
cbLo.add(ro.getDescription());
ctls.add((Control) ro.createSettingsControl(bottom));
}
cbLo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e){
int idx = cbLo.getSelectionIndex();
if (idx != -1) {
stack.topControl = ctls.get(idx);
bottom.layout();
CoreHub.localCfg.set(Preferences.RNN_DEFAULTEXPORTMODE, idx);
}
}
});
int lastSelected = CoreHub.localCfg.get(Preferences.RNN_DEFAULTEXPORTMODE, 0);
if ((lastSelected < 0) || (lastSelected >= cbLo.getItemCount())) {
lastSelected = 0;
CoreHub.localCfg.set(Preferences.RNN_DEFAULTEXPORTMODE, 0);
}
cbLo.select(lastSelected);
stack.topControl = ctls.get(cbLo.getSelectionIndex());
bottom.layout();
return ret;
}