本文整理汇总了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));
}
示例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);
}
示例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);
}
}
示例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;
}
示例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()));
}
示例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);
}
示例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 );
}
示例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 );
}
示例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() );
}
示例10: isEnumeration
import org.springframework.core.enums.LabeledEnum; //导入依赖的package包/类
protected boolean isEnumeration(FormModel formModel, String formPropertyPath) {
return LabeledEnum.class.isAssignableFrom(getPropertyType(formModel, formPropertyPath));
}
示例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 );
}
示例12: enumToString
import org.springframework.core.enums.LabeledEnum; //导入依赖的package包/类
private String enumToString( LabeledEnum e ) {
return e == null ? "" : ClassUtils.getClassFieldNameWithValue( e.getClass(), e );
}
示例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 ) );
}
示例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 ) );
}
示例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);
}