public TableIntegerProperty(JTable myTable, PropertySheet currentPS, String propName) { super(propName, myTable, currentPS); this.s4Integer = (S4Integer) currentPS.getProperty(propName, S4Integer.class).getAnnotation(); doubleEditor = new IntegerEditor(s4Integer.range()[0], s4Integer.range()[1]); Object rawValue = propSheet.getInt(propName); if (rawValue != null) doubleEditor.ftf.setValue(rawValue); doubleEditor.ftf.invalidate(); // else // doubleEditor.ftf.setValue(null); }
/** * Gets a list of components associated with the given parameter name * * @param <T> parent component * @param name the parameter name * @param tclass the class of the list elements * @return the component associated with the name * @throws PropertyException if the component does not exist or is of the wrong type. */ public <T> List<T> getComponentList(String name, Class<T> tclass) throws InternalConfigurationException { getProperty(name, S4ComponentList.class); List<?> components = (List<?>) propValues.get(name); assert registeredProperties.get(name).getAnnotation() instanceof S4ComponentList; S4ComponentList annotation = (S4ComponentList) registeredProperties.get(name).getAnnotation(); // no components names are available and no component list was yet // loaded therefore load the default list of components from the // annotation if (components == null) { List<Class<? extends Configurable>> defClasses = Arrays.asList(annotation.defaultList()); // if (annotation.mandatory() && defClasses.isEmpty()) // throw new InternalConfigurationException(getInstanceName(), name, // "mandatory property is not set!"); List<Configurable> defaultComponents = new ArrayList<Configurable>(); for (Class<? extends Configurable> defClass : defClasses) { defaultComponents.add(ConfigurationManager.getInstance(defClass)); } propValues.put(name, defaultComponents); } else if (!components.isEmpty() && !(components.get(0) instanceof Configurable)) { List<Configurable> resolvedComponents = new ArrayList<Configurable>(); for (Object componentName : components) { Configurable configurable = cm.lookup((String) componentName); if (configurable != null) { resolvedComponents.add(configurable); } else if (!annotation.beTolerant()) { throw new InternalConfigurationException( name, (String) componentName, "lookup of list-element '" + componentName + "' failed!"); } } propValues.put(name, resolvedComponents); } List<?> values = (List<?>) propValues.get(name); ArrayList<T> result = new ArrayList<T>(); for (Object obj : values) { if (tclass.isInstance(obj)) { result.add(tclass.cast(obj)); } else { throw new InternalConfigurationException( getInstanceName(), name, "Not all elements have required type " + tclass + " Found one of type " + obj.getClass()); } } return result; }
/** * Gets a list of float numbers associated with the given parameter name * * @param name the parameter name * @return a list of floats associated with the name. * @throws InternalConfigurationException if parameters are not double values. */ public List<String> getStringList(String name) throws InternalConfigurationException { getProperty(name, S4StringList.class); return ConfigurationManagerUtils.toStringList(propValues.get(name)); }