This commit is contained in:
bancika
2011-01-09 00:42:00 +00:00
parent 9a2fdc264f
commit 672aef6799
@@ -58,7 +58,7 @@ public class Presenter implements IPlugInPort {
private static final Logger LOG = Logger.getLogger(Presenter.class); private static final Logger LOG = Logger.getLogger(Presenter.class);
public static final VersionNumber CURRENT_VERSION = new VersionNumber(0, 0, 0); public static final VersionNumber CURRENT_VERSION = new VersionNumber(0, 0, 0);
public static final String DEFAULTS_KEY = "defaults"; public static final String DEFAULTS_KEY = "default.";
public static final String METRIC_KEY = "metric"; public static final String METRIC_KEY = "metric";
public static final int CONTROL_POINT_SENSITIVITY = 4; public static final int CONTROL_POINT_SENSITIVITY = 4;
@@ -642,16 +642,11 @@ public class Presenter implements IPlugInPort {
@Override @Override
public void setDefaultPropertyValue(String propertyName, Object value) { public void setDefaultPropertyValue(String propertyName, Object value) {
LOG.debug(String.format("setDefaultPropertyValue(%s, %s)", propertyName, value)); LOG.debug(String.format("setDefaultPropertyValue(%s, %s)", propertyName, value));
Map<String, Object> defaultMap = (Map<String, Object>) ConfigurationManager.getInstance()
.getConfigurationItem(DEFAULTS_KEY);
if (defaultMap == null) {
defaultMap = new HashMap<String, Object>();
ConfigurationManager.getInstance().setConfigurationItem(DEFAULTS_KEY, defaultMap);
}
for (IDIYComponent component : selectedComponents) { for (IDIYComponent component : selectedComponents) {
String className = component.getClass().getName(); String className = component.getClass().getName();
LOG.debug("Default property value set for " + className + ":" + propertyName); LOG.debug("Default property value set for " + className + ":" + propertyName);
defaultMap.put(className + ":" + propertyName, value); ConfigurationManager.getInstance().setConfigurationItem(
DEFAULTS_KEY + className + ":" + propertyName, value);
} }
} }
@@ -672,10 +667,7 @@ public class Presenter implements IPlugInPort {
for (IDIYComponent<?> component : selectedComponents) { for (IDIYComponent<?> component : selectedComponents) {
Area componentArea = componentAreaMap.get(component); Area componentArea = componentAreaMap.get(component);
if (componentArea != null) { if (componentArea != null) {
LOG.warn("Area added!" + componentArea.getBounds());
area.add(componentArea); area.add(componentArea);
} else {
LOG.warn("No area!");
} }
} }
double width = area.getBounds2D().getWidth(); double width = area.getBounds2D().getWidth();
@@ -758,13 +750,9 @@ public class Presenter implements IPlugInPort {
componentType.getInstanceClass()); componentType.getInstanceClass());
// Override with default values if available. // Override with default values if available.
for (PropertyWrapper property : properties) { for (PropertyWrapper property : properties) {
Object defaultValue = null; Object defaultValue = ConfigurationManager.getInstance().getConfigurationItem(
Map<String, Object> defaultMap = (Map<String, Object>) ConfigurationManager DEFAULTS_KEY + componentType.getInstanceClass().getName() + ":"
.getInstance().getConfigurationItem(DEFAULTS_KEY);
if (defaultMap != null) {
defaultValue = defaultMap.get(componentType.getInstanceClass().getName() + ":"
+ property.getName()); + property.getName());
}
if (defaultValue != null) { if (defaultValue != null) {
property.setValue(cloner.deepClone(defaultValue)); property.setValue(cloner.deepClone(defaultValue));
property.writeTo(component); property.writeTo(component);