mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 02:32:09 +10:00
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:
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
|
||||
DIY Layout Creator (DIYLC).
|
||||
Copyright (c) 2009-2025 held jointly by the individual authors.
|
||||
|
||||
This file is part of DIYLC.
|
||||
|
||||
DIYLC is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DIYLC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
package org.diylc.core.annotations;
|
||||
|
||||
import org.diylc.core.ValidationException;
|
||||
|
||||
/**
|
||||
* Same as {@link PositiveNonZeroMeasureValidator}, but also rejects an empty value. Use it for
|
||||
* measures the component cannot be drawn without.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class RequiredPositiveNonZeroMeasureValidator extends PositiveNonZeroMeasureValidator {
|
||||
|
||||
@Override
|
||||
public void validate(Object owner, Object value) throws ValidationException {
|
||||
if (value == null) {
|
||||
throw new ValidationException("must not be empty.");
|
||||
}
|
||||
super.validate(owner, value);
|
||||
}
|
||||
}
|
||||
@@ -637,6 +637,10 @@
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Rotated labels in pasted components and building blocks were drawn in the wrong place and at the wrong angle while following the mouse, until the components were placed</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
<org.diylc.appframework.update.Change>
|
||||
<changeType>BUG_FIX</changeType>
|
||||
<description>Projects 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</description>
|
||||
</org.diylc.appframework.update.Change>
|
||||
</changes>
|
||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||
</org.diylc.appframework.update.Version>
|
||||
|
||||
+11
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user