rojects with a resistor, capacitor or other leaded component whose Width or Length had been cleared in the property editor could not be opened; such values now fall back to the default size, and Width and Length can no longer be left empty

This commit is contained in:
Bane Stojkovic
2026-11-10 16:58:23 +01:00
parent 47d67d6311
commit 9f6124f719
3 changed files with 56 additions and 3 deletions
@@ -45,7 +45,7 @@ import org.diylc.common.ObjectCache;
import org.diylc.common.VerticalAlignment;
import org.diylc.core.*;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.PositiveNonZeroMeasureValidator;
import org.diylc.core.annotations.RequiredPositiveNonZeroMeasureValidator;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.presenter.CalcUtils;
@@ -637,8 +637,12 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
this.borderColor = borderColor;
}
@EditableProperty(name = "Length", defaultable = true, validatorClass = PositiveNonZeroMeasureValidator.class, sortOrder = 101)
@EditableProperty(name = "Length", defaultable = true, validatorClass = RequiredPositiveNonZeroMeasureValidator.class, sortOrder = 101)
public Size getLength() {
// from 5.13 until this value became required, the property editor could clear it and files store null
if (length == null && getDefaultLength() != null) {
length = new Size(getDefaultLength().getValue(), getDefaultLength().getUnit());
}
return length;
}
@@ -672,8 +676,12 @@ public abstract class AbstractLeadedComponent<T> extends AbstractLabeledComponen
}
}
@EditableProperty(name = "Width", defaultable = true, validatorClass = PositiveNonZeroMeasureValidator.class, sortOrder = 102)
@EditableProperty(name = "Width", defaultable = true, validatorClass = RequiredPositiveNonZeroMeasureValidator.class, sortOrder = 102)
public Size getWidth() {
// from 5.13 until this value became required, the property editor could clear it and files store null
if (width == null && getDefaultWidth() != null) {
width = new Size(getDefaultWidth().getValue(), getDefaultWidth().getUnit());
}
return width;
}