/** * * @param jrEnum * @param nullable * @param skipPositions * - 0-based index of the JREnum to be skipped * @return */ public static String[] getEnumNames(JREnum[] jrEnum, NullEnum nullable, Integer... skipPositions) { List<String> res = new ArrayList<String>(); if (nullable != NullEnum.NOTNULL) res.add(nullable.getName()); for (int i = 0; i < jrEnum.length; i++) { boolean skip = false; for (int j = 0; j < skipPositions.length; j++) { if (i == skipPositions[j]) { skip = true; } } if (!skip) { res.add(MessagesByKeys.getString(jrEnum[i].getName())); } } return res.toArray(new String[res.size()]); }
public static JREnum getSetValue(JREnum[] values, Object value, int offset, boolean isNull) { if (value != null) { if (value instanceof JREnum) return (JREnum) value; else if (value instanceof Number) { if (isNull && offset == 0) offset = -1; else if (!isNull && offset == 1) offset = 1; else offset = 0; return EnumUtil.getByValue(values, ((Number) value).intValue() + offset); } } return null; }
public JSSEnumPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type, int skipPositions) { super(id, displayName, EnumHelper.getEnumNames(jrEnum.getEnumConstants(), type, skipPositions)); this.type = type; jrEnums = jrEnum.getEnumConstants(); this.start = jrEnums[0].getValue(); }
public JSSPopupPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, EnumHelper.getEnumNames(jrEnum.getEnumConstants(), type)); this.type = type; jrEnums = jrEnum.getEnumConstants(); this.start = jrEnums[0].getValue(); setItemsToDefault(); }
public JSSPopupPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type, List<ComboItem> items) { super(id, displayName, EnumHelper.getEnumNames(jrEnum.getEnumConstants(), type)); jrEnums = jrEnum.getEnumConstants(); this.start = jrEnums[0].getValue(); this.items = items; }
private void setItemsToDefault() { items = new ArrayList<ComboItem>(); int offset = 0; if (type != NullEnum.NOTNULL) { items.add(new ComboItem(type.getName(), true, 0, type, 0)); offset = 1; } for (int i = 0; i < jrEnums.length; i++) { JREnum actualValue = jrEnums[i]; items.add(new ComboItem(actualValue.getName(), true, i + offset, actualValue, i + offset)); } }
public void setData(Integer et, String group, String[] items) { hasFirstFakeElement = false; int selection = 0; JREnum sel = EnumHelper.getSetValue(getEnumValues(), et, 1, false); boolean found = false; for (int i = 0; i < items.length; i++) { if (items[i].equals(sel.getName())) { selection = i; found = true; break; } if (items[i].startsWith(GROUPPREFIX) && sel.equals(getGroupEnum())) { if (items[i].substring(GROUPPREFIX.length()).equals(group)) { selection = i; found = true; break; } } } String[] comboItems = items; // If the group can't be found set a fake item if (!found && group != null && !group.isEmpty()) { List<String> newItems = new ArrayList<String>(); newItems.add(MessageFormat.format(Messages.SPGroupTypeCombo_groupNotFounError, group)); newItems.addAll(new ArrayList<String>(Arrays.asList(items))); comboItems = newItems.toArray(new String[newItems.size()]); hasFirstFakeElement = true; } combo.setItems(comboItems); combo.select(selection); }
public static String[] getEnumNames(JREnum[] jrEnum, NullEnum nullable) { List<String> res = new ArrayList<String>(); if (nullable != NullEnum.NOTNULL) res.add(nullable.getName()); for (int i = 0; i < jrEnum.length; i++) { res.add(MessagesByKeys.getString(jrEnum[i].getName())); } return res.toArray(new String[res.size()]); }
public static Integer getValue(JREnum jrEnum, int offset, boolean isNull) { if (jrEnum == null) return new Integer(0); if (isNull && offset == 0) offset = -1; else if (!isNull && offset == 1) offset = 1; else offset = 0; return new Integer(jrEnum.getValue() - offset); }
/** * Retrieves the correct {@link JREnum} instance which name translation matches the specified one. * * @param enums * a list of enumerations to look into * @param translatedName * the translated name to match * @return the correct enum, <code>null</code> otherwise */ public static JREnum getEnumByTranslatedName(JREnum[] enums, String translatedName) { Assert.isNotNull(translatedName); for(JREnum e : enums){ if (translatedName.equals(MessagesByKeys.getString(e.getName()))){ return e; } } return null; }
public XmlConstantPropertyRule(String attributeName, JREnum[] values) { this(attributeName, (NamedEnum[]) values); }
public XmlConstantPropertyRule(String attributeName, String propertyName, JREnum[] values) { this(attributeName, propertyName, (NamedEnum[]) values); }
public void addAttribute(String name, JREnum value) { addAttribute(name, (NamedEnum) value); }
public void addAttribute(String name, JREnum value, JREnum defaultValue) { addAttribute(name, (NamedEnum) value, (NamedEnum) defaultValue); }
public VAlignPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
public EdgePropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
public HAlignPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
public RotationPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
public JSSEnumPropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, EnumHelper.getEnumNames(jrEnum.getEnumConstants(), type)); this.type = type; jrEnums = jrEnum.getEnumConstants(); this.start = jrEnums[0].getValue(); }
public Integer getEnumValue(JREnum jrvalue) { return EnumHelper.getValue(jrvalue, start, type != NullEnum.NOTNULL); }
public JREnum getEnumValue(Object value) { return EnumHelper.getSetValue(jrEnums, value, start, type != NullEnum.NOTNULL); }
public JREnum[] getJrEnums() { return jrEnums; }
public OpaqueModePropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
public LineStylePropertyDescriptor(Object id, String displayName, Class<? extends JREnum> jrEnum, NullEnum type) { super(id, displayName, jrEnum, type); }
@Override protected JREnum[] getEnumValues() { return EvaluationTimeEnum.values(); }
@Override protected JREnum getGroupEnum() { return EvaluationTimeEnum.GROUP; }
@Override protected JREnum getByName(String name) { return EvaluationTimeEnum.getByName(name); }
@Override protected JREnum[] getEnumValues() { return IncrementTypeEnum.values(); }
@Override protected JREnum getGroupEnum() { return IncrementTypeEnum.GROUP; }
@Override protected JREnum getByName(String name) { return IncrementTypeEnum.getByName(name); }
@Override protected JREnum[] getEnumValues() { return ResetTypeEnum.values(); }
@Override protected JREnum getGroupEnum() { return ResetTypeEnum.GROUP; }
@Override protected JREnum getByName(String name) { return ResetTypeEnum.getByName(name); }
public static String[] getEnumNames(Class<? extends JREnum> jrEnum, NullEnum type) { JREnum[] enums = jrEnum.getEnumConstants(); return getEnumNames(enums, type); }
public static Integer getValue(JREnum jrEnum) { return getValue(jrEnum, 1, false); }
/** * Return the enumerations selectable on this element * * @return the list of enumerations that can be selected */ protected abstract JREnum[] getEnumValues();
/** * Return the group enumeration for the element * * @return the enumeration corresponding to group */ protected abstract JREnum getGroupEnum();