當前位置: 首頁>>代碼示例>>Java>>正文


Java LabeledEnum類代碼示例

本文整理匯總了Java中org.springframework.core.enums.LabeledEnum的典型用法代碼示例。如果您正苦於以下問題:Java LabeledEnum類的具體用法?Java LabeledEnum怎麽用?Java LabeledEnum使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LabeledEnum類屬於org.springframework.core.enums包,在下文中一共展示了LabeledEnum類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerDefaultBinders

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
protected void registerDefaultBinders()
{
    registerBinderForPropertyType(String.class, new TextComponentBinder());
    registerBinderForPropertyType(boolean.class, new CheckBoxBinder());
    registerBinderForPropertyType(Boolean.class, new CheckBoxBinder());
    registerBinderForPropertyType(LabeledEnum.class, new LabeledEnumComboBoxBinder());
    registerBinderForControlType(JTextComponent.class, new TextComponentBinder());
    registerBinderForControlType(JFormattedTextField.class, new FormattedTextFieldBinder(null));
    registerBinderForControlType(JTextArea.class, new TextAreaBinder());
    registerBinderForControlType(JToggleButton.class, new ToggleButtonBinder());
    registerBinderForControlType(JCheckBox.class, new CheckBoxBinder());
    registerBinderForControlType(JComboBox.class, new ComboBoxBinder());
    registerBinderForControlType(JList.class, new ListBinder());
    registerBinderForControlType(JLabel.class, new LabelBinder());
    registerBinderForControlType(JScrollPane.class, new ScrollPaneBinder(this, JTextArea.class));
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:17,代碼來源:SwingBinderSelectionStrategy.java

示例2: doBindControl

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
protected void doBindControl(ListModel bindingModel) {
    setRenderer(new LabeledEnumListRenderer(getMessageSource()));
    setEditor(new LabeledEnumComboBoxEditor(getMessageSource(), getEditor()));
    CompoundComparator comparator = new CompoundComparator();
    comparator.addComparator(LabeledEnum.LABEL_ORDER);
    comparator.addComparator(new ComparableComparator());
    setComparator(comparator);
    super.doBindControl(bindingModel);
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:10,代碼來源:LabeledEnumComboBoxBinding.java

示例3: setItem

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
/**
 * @see javax.swing.ComboBoxEditor#setItem(java.lang.Object)
 */
public void setItem(Object anObject) {
	current = anObject;
	if (anObject != null) {
		if (messages != null && anObject instanceof MessageSourceResolvable) {
			inner.setItem(messages.getMessage((MessageSourceResolvable)anObject, Locale.getDefault()));
		}
		else {
			inner.setItem(((LabeledEnum)anObject).getLabel());
		}
	}
	else {
		inner.setItem(null);
	}
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:18,代碼來源:LabeledEnumComboBoxEditor.java

示例4: getListCellRendererComponent

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
		boolean cellHasFocus) {
	super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
	if (value == null) {
		return this;
	}
	if (messages != null && value instanceof MessageSourceResolvable) {
		setText(messages.getMessage((MessageSourceResolvable)value, Locale.getDefault()));
	}
	else {
		setText(((LabeledEnum)value).getLabel());
	}
	return this;
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:15,代碼來源:LabeledEnumListRenderer.java

示例5: configureForEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public void configureForEnum(JComboBox comboBox, Class enumType) {
	Collection enumValues = getEnumResolver().getLabeledEnumSet(enumType);
	if (logger.isDebugEnabled()) {
		logger.debug("Populating combo box model with enums of type '" + enumType.getName() + "'; enums are ["
				+ enumValues + "]");
	}
	CompoundComparator comparator = new CompoundComparator();
	comparator.addComparator(LabeledEnum.LABEL_ORDER);
	comparator.addComparator(new ComparableComparator());
	comboBox.setModel(new ComboBoxListModel(new ArrayList(enumValues), comparator));
	comboBox.setRenderer(new LabeledEnumListRenderer(messageSource));
	comboBox.setEditor(new LabeledEnumComboBoxEditor(messageSource, comboBox.getEditor()));
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:14,代碼來源:DefaultComponentFactory.java

示例6: getTableCellRendererComponent

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    if (value != null) {
        if (messages != null && value instanceof MessageSourceResolvable) {
            value = messages.getMessage((MessageSourceResolvable) value, Locale.getDefault());
        } else {
            value = ((LabeledEnum) value).getLabel();
        }
    }
    return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:12,代碼來源:LabeledEnumTableCellRenderer.java

示例7: setLabeledEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public void setLabeledEnum( String key, LabeledEnum value ) {
    Assert.notNull( key, "Key cannot be null" );

    LabeledEnum old = getLabeledEnum( key );
    internalSet( key, enumToString( value ) );
    afterSet( key, old, value );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:8,代碼來源:AbstractSettings.java

示例8: getLabeledEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public LabeledEnum getLabeledEnum( String key ) {
    Assert.notNull( key, "Key cannot be null" );

    String value = internalGet( key );
    if( !StringUtils.hasText( value ) ) {
        return getDefaultLabeledEnum( key );
    }
    return stringToEnum( value );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:10,代碼來源:AbstractSettings.java

示例9: testEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public final void testEnum() {
    String key = "enum-value";
    LabeledEnum defaultValue = null;
    LabeledEnum newValue = TestEnum.ENUM2;

    // default value
    assertEquals( defaultValue, settings.getLabeledEnum( key ) );
    assertEquals( defaultValue, settings.getDefaultLabeledEnum( key ) );
    assertTrue( settings.isDefault( key ) );
    assertFalse( settings.contains( key ) );

    // change the value
    settings.setLabeledEnum( key, newValue );

    assertEquals( newValue, settings.getLabeledEnum( key ) );
    assertFalse( settings.isDefault( key ) );
    assertTrue( settings.contains( key ) );

    // check property change event
    assertPropertyChangeEventFired( key, defaultValue, newValue );
    propertyChangeListener.reset();

    // change the value to the same value, no property change event should
    // be fired
    settings.setLabeledEnum( key, newValue );
    assertEquals( 0, propertyChangeListener.getCount() );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:28,代碼來源:SettingsAbstractTests.java

示例10: isEnumeration

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
protected boolean isEnumeration(FormModel formModel, String formPropertyPath) {
    return LabeledEnum.class.isAssignableFrom(getPropertyType(formModel, formPropertyPath));
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:4,代碼來源:AbstractBinderSelectionStrategy.java

示例11: stringToEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
private LabeledEnum stringToEnum( String s ) {
    if( s == null || s.trim().equals( "" ) ) {
        return null;
    }
    return (LabeledEnum) ClassUtils.getFieldValue( s );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:7,代碼來源:AbstractSettings.java

示例12: enumToString

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
private String enumToString( LabeledEnum e ) {
    return e == null ? "" : ClassUtils.getClassFieldNameWithValue( e.getClass(), e );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:4,代碼來源:AbstractSettings.java

示例13: setDefaultLabeledEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public void setDefaultLabeledEnum( String key, LabeledEnum value ) {
    Assert.notNull( key, "Key cannot be null" );

    defaults.put( key, enumToString( value ) );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:6,代碼來源:AbstractSettings.java

示例14: getDefaultLabeledEnum

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
public LabeledEnum getDefaultLabeledEnum( String key ) {
    Assert.notNull( key, "Key cannot be null" );
    return stringToEnum( (String) defaults.get( key ) );
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:5,代碼來源:AbstractSettings.java

示例15: isSimpleScalar

import org.springframework.core.enums.LabeledEnum; //導入依賴的package包/類
/**
 * Does the provided bean class represent a simple scalar property? A simple
 * scalar property is considered a value property; that is, it is not
 * another bean. Examples include primitives, primitive wrappers, Enums, and
 * Strings.
 */
public static boolean isSimpleScalar(Class clazz) {
	return clazz.isPrimitive() || simpleClasses.contains(clazz) || LabeledEnum.class.isAssignableFrom(clazz);
}
 
開發者ID:shevek,項目名稱:spring-rich-client,代碼行數:10,代碼來源:ClassUtils.java


注:本文中的org.springframework.core.enums.LabeledEnum類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。