@SuppressWarnings({"HardCodedStringLiteral"}) private void loadEnumProperties(final String className, final Element enumPropertyElement) { Map<String, IntEnumEditor.Pair[]> map = new HashMap<String, IntEnumEditor.Pair[]>(); for(final Object o: enumPropertyElement.getChildren("property")) { final Element e = (Element) o; final String name = LwXmlReader.getRequiredString(e, "name"); final List list = e.getChildren("constant"); IntEnumEditor.Pair[] pairs = new IntEnumEditor.Pair[list.size()]; for(int i=0; i<list.size(); i++) { Element constant = (Element) list.get(i); int value = LwXmlReader.getRequiredInt(constant, "value"); String message = constant.getAttributeValue("message"); String text = (message != null) ? UIDesignerBundle.message(message) : LwXmlReader.getRequiredString(constant, "name"); pairs [i] = new IntEnumEditor.Pair(value, text); } map.put(name, pairs); } if (map.size() > 0) { myClass2EnumProperties.put(className, map); } }
@SuppressWarnings({"HardCodedStringLiteral"}) private void loadEnumProperties(final String className, final Element enumPropertyElement) { Map<String, IntEnumEditor.Pair[]> map = new HashMap<>(); for(final Object o : enumPropertyElement.getChildren("property")) { final Element e = (Element) o; final String name = LwXmlReader.getRequiredString(e, "name"); final List list = e.getChildren("constant"); IntEnumEditor.Pair[] pairs = new IntEnumEditor.Pair[list.size()]; for(int i = 0; i < list.size(); i++) { Element constant = (Element) list.get(i); int value = LwXmlReader.getRequiredInt(constant, "value"); String message = constant.getAttributeValue("message"); String text = (message != null) ? UIDesignerBundle.message(message) : LwXmlReader.getRequiredString(constant, "name"); pairs[i] = new IntEnumEditor.Pair(value, text); } map.put(name, pairs); } if(map.size() > 0) { myClass2EnumProperties.put(className, map); } }
/** * Helper method */ private static IntroIntProperty createIntEnumProperty( final String name, final Method readMethod, final Method writeMethod, final IntEnumEditor.Pair[] pairs ) { return new IntroIntProperty( name, readMethod, writeMethod, new IntEnumRenderer(pairs), new IntEnumEditor(pairs), false); }
private IntEnumEditor.Pair[] getPairs() { return new IntEnumEditor.Pair[] { new IntEnumEditor.Pair(GridConstraints.ALIGN_LEFT, myHorizontal ? UIDesignerBundle.message("property.left") : UIDesignerBundle.message("property.top")), new IntEnumEditor.Pair(GridConstraints.ALIGN_CENTER, UIDesignerBundle.message("property.center")), new IntEnumEditor.Pair(GridConstraints.ALIGN_RIGHT, myHorizontal ? UIDesignerBundle.message("property.right") : UIDesignerBundle.message("property.bottom")), new IntEnumEditor.Pair(GridConstraints.ALIGN_FILL, UIDesignerBundle.message("property.fill")) }; }
private void initPairs() { if (myPairs == null) { myPairs = new IntEnumEditor.Pair[] { new IntEnumEditor.Pair(FlowLayout.CENTER, UIDesignerBundle.message("property.center")), new IntEnumEditor.Pair(FlowLayout.LEFT, UIDesignerBundle.message("property.left")), new IntEnumEditor.Pair(FlowLayout.RIGHT, UIDesignerBundle.message("property.right")), new IntEnumEditor.Pair(FlowLayout.LEADING, UIDesignerBundle.message("property.leading")), new IntEnumEditor.Pair(FlowLayout.TRAILING, UIDesignerBundle.message("property.trailing")) }; } }
@Nullable public IntEnumEditor.Pair[] getEnumPairs(final Class aClass, final String name) { for (Class c = aClass; c != null; c = c.getSuperclass()) { final Map<String, IntEnumEditor.Pair[]> map = myClass2EnumProperties.get(c.getName()); if (map != null) { return map.get(name); } } return null; }
/** * Helper method */ private static IntroIntProperty createIntEnumProperty( final String name, final Method readMethod, final Method writeMethod, final IntEnumEditor.Pair[] pairs ){ return new IntroIntProperty( name, readMethod, writeMethod, new IntEnumRenderer(pairs), new IntEnumEditor(pairs), false); }
@Nullable public IntEnumEditor.Pair[] getEnumPairs(final Class aClass, final String name) { for(Class c = aClass; c != null; c = c.getSuperclass()) { final Map<String, IntEnumEditor.Pair[]> map = myClass2EnumProperties.get(c.getName()); if(map != null) { return map.get(name); } } return null; }
public IntEnumRenderer(@NotNull final IntEnumEditor.Pair[] pairs) { myPairs = pairs; }
public Properties(){ myClass2InplaceProperty = new HashMap<String,String>(); myClass2ExpertProperties = new HashMap<String,HashSet<String>>(); myClass2EnumProperties = new HashMap<String, Map<String, IntEnumEditor.Pair[]>>(); myClass2DeprecatedProperties = new HashMap<String, Set<String>>(); }