save project default properties

This commit is contained in:
bancika
2011-01-15 15:05:07 +00:00
parent b99d438eb8
commit f05c3ccc86
5 changed files with 29 additions and 29 deletions
@@ -1,27 +1,8 @@
<map>
<entry>
<string>default.org.diylc.components.passive.Resistor:Value</string>
<org.diylc.core.measures.Resistance>
<value>100.0</value>
<unit class="org.diylc.core.measures.ResistanceUnit">K</unit>
</org.diylc.core.measures.Resistance>
</entry>
<entry>
<string>metric</string>
<boolean>true</boolean>
</entry>
<entry>
<string>lastPath</string>
<string>C:\Documents and Settings\Branislav Stojkovic\Desktop</string>
</entry>
<entry>
<string>default.org.diylc.components.semiconductors.DIL_IC:Value</string>
<string>LM366</string>
</entry>
<entry>
<string>default.org.diylc.components.passive.AxialFilmCapacitor:Width</string>
<string>default.org.diylc.core.Project:Grid spacing</string>
<org.diylc.core.measures.Size>
<value>0.7</value>
<value>0.2</value>
<unit class="org.diylc.core.measures.SizeUnit">in</unit>
</org.diylc.core.measures.Size>
</entry>
@@ -289,7 +289,17 @@ public interface IPlugInPort {
* @param value
* new default value, must not be null
*/
void setDefaultPropertyValue(String propertyName, Object value);
void setSelectionDefaultPropertyValue(String propertyName, Object value);
/**
* Sets default value for the specified property name for projects.
*
* @param propertyName
* display name for property
* @param value
* new default value, must not be null
*/
void setProjectDefaultPropertyValue(String propertyName, Object value);
/**
* @return a list of properties that are mutual for all the selected
@@ -198,7 +198,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
// Save default values.
for (PropertyWrapper property : editor.getDefaultedProperties()) {
if (property.getValue() != null) {
plugInPort.setDefaultPropertyValue(property.getName(),
plugInPort.setProjectDefaultPropertyValue(property.getName(),
property.getValue());
}
}
@@ -217,7 +217,7 @@ class CanvasPanel extends JComponent implements Autoscroll {
// Save default values.
for (PropertyWrapper property : editor.getDefaultedProperties()) {
if (property.getValue() != null) {
plugInPort.setDefaultPropertyValue(property.getName(),
plugInPort.setSelectionDefaultPropertyValue(property.getName(),
property.getValue());
}
}
@@ -264,7 +264,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
// Save default values.
for (PropertyWrapper property : editor.getDefaultedProperties()) {
if (property.getValue() != null) {
plugInPort.setDefaultPropertyValue(property.getName(), property.getValue());
plugInPort.setProjectDefaultPropertyValue(property.getName(), property.getValue());
}
}
}
@@ -299,7 +299,7 @@ public class ClipboardManager implements IPlugIn, ClipboardOwner {
// Save default values.
for (PropertyWrapper property : editor.getDefaultedProperties()) {
if (property.getValue() != null) {
plugInPort.setDefaultPropertyValue(property.getName(), property.getValue());
plugInPort.setSelectionDefaultPropertyValue(property.getName(), property.getValue());
}
}
}
@@ -829,8 +829,8 @@ public class Presenter implements IPlugInPort {
@SuppressWarnings("unchecked")
@Override
public void setDefaultPropertyValue(String propertyName, Object value) {
LOG.info(String.format("setDefaultPropertyValue(%s, %s)", propertyName, value));
public void setSelectionDefaultPropertyValue(String propertyName, Object value) {
LOG.info(String.format("setSelectionDefaultPropertyValue(%s, %s)", propertyName, value));
for (IDIYComponent component : selectedComponents) {
String className = component.getClass().getName();
LOG.debug("Default property value set for " + className + ":" + propertyName);
@@ -839,6 +839,14 @@ public class Presenter implements IPlugInPort {
}
}
@Override
public void setProjectDefaultPropertyValue(String propertyName, Object value) {
LOG.info(String.format("setProjectDefaultPropertyValue(%s, %s)", propertyName, value));
LOG.debug("Default property value set for " + Project.class.getName() + ":" + propertyName);
ConfigurationManager.getInstance().setConfigurationItem(
DEFAULTS_KEY + Project.class.getName() + ":" + propertyName, value);
}
@Override
public void setMetric(boolean isMetric) {
ConfigurationManager.getInstance().setConfigurationItem(Presenter.METRIC_KEY, isMetric);
@@ -1104,7 +1112,8 @@ public class Presenter implements IPlugInPort {
}
} catch (Exception e) {
LOG.error("Could not apply selection properties", e);
view.showMessage("Could not apply changes to the selection. Check the log for details.",
view.showMessage(
"Could not apply changes to the selection. Check the log for details.",
"Error", JOptionPane.ERROR_MESSAGE);
} finally {
// Notify the listeners.