mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Added ability to set board size explicitly by typing in dimensions,
instead of dragging two control points
This commit is contained in:
@@ -29,5 +29,5 @@ package org.diylc.core;
|
|||||||
public class AllowAllValidator implements IPropertyValidator {
|
public class AllowAllValidator implements IPropertyValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Object value) throws ValidationException {}
|
public void validate(Object owner, Object value) throws ValidationException {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import org.diylc.core.annotations.EditableProperty;
|
|||||||
*
|
*
|
||||||
* @param <T> type of component values, e.g. Resistance for resistors or String for transistors.
|
* @param <T> type of component values, e.g. Resistance for resistors or String for transistors.
|
||||||
*/
|
*/
|
||||||
public interface IDIYComponent<T> extends Serializable {
|
public interface IDIYComponent<T> extends Serializable, Cloneable {
|
||||||
|
|
||||||
public static final int CHASSIS = 1;
|
public static final int CHASSIS = 1;
|
||||||
public static final int BOARD = 2;
|
public static final int BOARD = 2;
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ package org.diylc.core;
|
|||||||
public interface IPropertyValidator {
|
public interface IPropertyValidator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param owner
|
||||||
* @param value
|
* @param value
|
||||||
* @throws ValidationException if validation fails. Message will contain the reason.
|
* @throws ValidationException if validation fails. Message will contain the reason.
|
||||||
*/
|
*/
|
||||||
void validate(Object value) throws ValidationException;
|
void validate(Object owner, Object value) throws ValidationException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import org.diylc.core.measures.SizeUnit;
|
|||||||
*
|
*
|
||||||
* @author Branislav Stojkovic
|
* @author Branislav Stojkovic
|
||||||
*/
|
*/
|
||||||
public class Project implements Serializable {
|
public class Project implements Serializable, Cloneable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -292,8 +292,8 @@ public class Project implements Serializable {
|
|||||||
public static class SpacingValidator extends PositiveMeasureValidator {
|
public static class SpacingValidator extends PositiveMeasureValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Object value) throws ValidationException {
|
public void validate(Object owner, Object value) throws ValidationException {
|
||||||
super.validate(value);
|
super.validate(owner, value);
|
||||||
Size size = (Size) value;
|
Size size = (Size) value;
|
||||||
if (size.compareTo(new Size(0.1d, SizeUnit.mm)) < 0) {
|
if (size.compareTo(new Size(0.1d, SizeUnit.mm)) < 0) {
|
||||||
throw new ValidationException("must be at least 0.1mm");
|
throw new ValidationException("must be at least 0.1mm");
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import org.diylc.core.measures.AbstractMeasure;
|
|||||||
public class PositiveMeasureValidator implements IPropertyValidator {
|
public class PositiveMeasureValidator implements IPropertyValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Object value) throws ValidationException {
|
public void validate(Object owner, Object value) throws ValidationException {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return;
|
return;
|
||||||
if (value instanceof AbstractMeasure) {
|
if (value instanceof AbstractMeasure) {
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ import org.diylc.core.measures.AbstractMeasure;
|
|||||||
public class PositiveNonZeroMeasureValidator implements IPropertyValidator {
|
public class PositiveNonZeroMeasureValidator implements IPropertyValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Object value) throws ValidationException {
|
public void validate(Object owner, Object value) throws ValidationException {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return;
|
return;
|
||||||
if (value instanceof AbstractMeasure) {
|
if (value instanceof AbstractMeasure) {
|
||||||
|
|||||||
@@ -55,15 +55,6 @@ public class AbstractMeasure<T extends Enum<? extends Unit>> implements Serializ
|
|||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
|
||||||
* Flag that designates if measure value should be converted between different units. eg. 2.54mm <-> 0.1in
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isConvertible() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|||||||
@@ -66,9 +66,4 @@ public class Size extends AbstractMeasure<SizeUnit> implements Comparable<Size>
|
|||||||
public int compareTo(Size o) {
|
public int compareTo(Size o) {
|
||||||
return new Double(value * unit.getFactor()).compareTo(o.getValue() * o.getUnit().getFactor());
|
return new Double(value * unit.getFactor()).compareTo(o.getValue() * o.getUnit().getFactor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConvertible() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2710,6 +2710,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added "Tape Measure" component for measuring the distance between any two points on the drawing</description>
|
<description>Added "Tape Measure" component for measuring the distance between any two points on the drawing</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Added ability to set board size explicitly by typing in dimensions, instead of dragging two control points</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>New app bundle for Mac OS using appbundler instead of javabundler</description>
|
<description>New app bundle for Mac OS using appbundler instead of javabundler</description>
|
||||||
|
|||||||
Binary file not shown.
@@ -66,11 +66,17 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
protected CoordinateDisplay coordinateDisplay = CoordinateDisplay.One_Side;
|
protected CoordinateDisplay coordinateDisplay = CoordinateDisplay.One_Side;
|
||||||
protected CoordinateType yType = CoordinateType.Letters;
|
protected CoordinateType yType = CoordinateType.Letters;
|
||||||
|
|
||||||
|
protected Size length;
|
||||||
|
protected Size width;
|
||||||
|
protected BoardSizingMode mode = BoardSizingMode.TwoPoints;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke(1));
|
||||||
|
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Composite oldComposite = g2d.getComposite();
|
Composite oldComposite = g2d.getComposite();
|
||||||
// render as transparent when dragging
|
// render as transparent when dragging
|
||||||
int alpha = componentState == ComponentState.DRAGGING ? 0 : this.alpha;
|
int alpha = componentState == ComponentState.DRAGGING ? 0 : this.alpha;
|
||||||
@@ -78,7 +84,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f * alpha / MAX_ALPHA));
|
||||||
}
|
}
|
||||||
g2d.setColor(boardColor);
|
g2d.setColor(boardColor);
|
||||||
g2d.fillRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.fillRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
|
|
||||||
// Do not track any changes that follow because the whole board has been
|
// Do not track any changes that follow because the whole board has been
|
||||||
@@ -86,7 +92,17 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
drawingObserver.stopTracking();
|
drawingObserver.stopTracking();
|
||||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: borderColor);
|
: borderColor);
|
||||||
g2d.drawRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Point getFinalSecondPoint() {
|
||||||
|
Point finalSecondPoint;
|
||||||
|
if (getMode() == BoardSizingMode.TwoPoints)
|
||||||
|
finalSecondPoint = secondPoint;
|
||||||
|
else
|
||||||
|
finalSecondPoint = new Point((int)(firstPoint.x + getLength().convertToPixels()),
|
||||||
|
(int)(firstPoint.y + getWidth().convertToPixels()));
|
||||||
|
return finalSecondPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawCoordinates(Graphics2D g2d, int spacing, Project project) {
|
protected void drawCoordinates(Graphics2D g2d, int spacing, Project project) {
|
||||||
@@ -97,6 +113,8 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
int halfSpace = spacing / 2;
|
int halfSpace = spacing / 2;
|
||||||
CoordinateOrigin origin = getCoordinateOrigin();
|
CoordinateOrigin origin = getCoordinateOrigin();
|
||||||
|
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
if (getCoordinateDisplay() != CoordinateDisplay.None) {
|
if (getCoordinateDisplay() != CoordinateDisplay.None) {
|
||||||
int range;
|
int range;
|
||||||
int yOffset;
|
int yOffset;
|
||||||
@@ -104,12 +122,12 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
Point drawPoint = new Point(firstPoint);
|
Point drawPoint = new Point(firstPoint);
|
||||||
|
|
||||||
if (origin == CoordinateOrigin.Top_Left || origin == CoordinateOrigin.Top_Right) {
|
if (origin == CoordinateOrigin.Top_Left || origin == CoordinateOrigin.Top_Right) {
|
||||||
range = (int) ((secondPoint.y - firstPoint.y + halfSpace) / spacing);
|
range = (int) ((finalSecondPoint.y - firstPoint.y + halfSpace) / spacing);
|
||||||
yOffset = spacing;
|
yOffset = spacing;
|
||||||
} else {
|
} else {
|
||||||
range = (int) ((secondPoint.y - firstPoint.y + halfSpace) / spacing);
|
range = (int) ((finalSecondPoint.y - firstPoint.y + halfSpace) / spacing);
|
||||||
yOffset = -spacing;
|
yOffset = -spacing;
|
||||||
drawPoint.y = secondPoint.y;
|
drawPoint.y = finalSecondPoint.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 1; c < range; c++) {
|
for (int c = 1; c < range; c++) {
|
||||||
@@ -122,7 +140,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
HorizontalAlignment.LEFT, VerticalAlignment.CENTER);
|
||||||
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
|
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
|
||||||
StringUtils.drawCenteredText(g2d, label,
|
StringUtils.drawCenteredText(g2d, label,
|
||||||
secondPoint.x - xOffset, drawPoint.y,
|
finalSecondPoint.x - xOffset, drawPoint.y,
|
||||||
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
HorizontalAlignment.RIGHT, VerticalAlignment.CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,12 +153,12 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
Point drawPoint = new Point(firstPoint);
|
Point drawPoint = new Point(firstPoint);
|
||||||
|
|
||||||
if (origin == CoordinateOrigin.Top_Left || origin == CoordinateOrigin.Bottom_Left) {
|
if (origin == CoordinateOrigin.Top_Left || origin == CoordinateOrigin.Bottom_Left) {
|
||||||
range = (int) ((secondPoint.x - firstPoint.x + halfSpace) / spacing);
|
range = (int) ((finalSecondPoint.x - firstPoint.x + halfSpace) / spacing);
|
||||||
xOffset = spacing;
|
xOffset = spacing;
|
||||||
} else {
|
} else {
|
||||||
range = (int) ((secondPoint.x - firstPoint.x + halfSpace) / spacing);
|
range = (int) ((finalSecondPoint.x - firstPoint.x + halfSpace) / spacing);
|
||||||
xOffset = -spacing;
|
xOffset = -spacing;
|
||||||
drawPoint.x = secondPoint.x;
|
drawPoint.x = finalSecondPoint.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 1; c < range; c++) {
|
for (int c = 1; c < range; c++) {
|
||||||
@@ -152,7 +170,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
HorizontalAlignment.CENTER, VerticalAlignment.TOP);
|
||||||
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
|
if (getCoordinateDisplay() == CoordinateDisplay.Both_Sides) {
|
||||||
StringUtils.drawCenteredText(g2d, label,
|
StringUtils.drawCenteredText(g2d, label,
|
||||||
drawPoint.x, (int) (secondPoint.y - COORDINATE_FONT_SIZE),
|
drawPoint.x, (int) (finalSecondPoint.y - COORDINATE_FONT_SIZE),
|
||||||
HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
|
HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,7 +281,7 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
public VisibilityPolicy getControlPointVisibilityPolicy(int index) {
|
||||||
return VisibilityPolicy.WHEN_SELECTED;
|
return getMode() == BoardSizingMode.TwoPoints ? VisibilityPolicy.WHEN_SELECTED : VisibilityPolicy.NEVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -286,6 +304,35 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Explicit Length", validatorClass = BoardModeValidator.class)
|
||||||
|
public Size getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(Size length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Explicit Width", validatorClass = BoardModeValidator.class)
|
||||||
|
public Size getWidth() {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Size width) {
|
||||||
|
this.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EditableProperty(name = "Sizing Mode")
|
||||||
|
public BoardSizingMode getMode() {
|
||||||
|
if (mode == null)
|
||||||
|
mode = BoardSizingMode.TwoPoints;
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(BoardSizingMode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
public static enum CoordinateType {
|
public static enum CoordinateType {
|
||||||
Letters, Numbers
|
Letters, Numbers
|
||||||
}
|
}
|
||||||
@@ -307,4 +354,19 @@ public abstract class AbstractBoard extends AbstractTransparentComponent<String>
|
|||||||
return super.toString().replace('_', ' ');
|
return super.toString().replace('_', ' ');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum BoardSizingMode {
|
||||||
|
TwoPoints("Opposing Points"), Explicit("Explicit Dimensions");
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private BoardSizingMode(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.awt.AlphaComposite;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Composite;
|
import java.awt.Composite;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
|
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.ObjectCache;
|
||||||
@@ -58,9 +59,11 @@ public class BlankBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,9 +75,9 @@ public class BlankBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
g2d.setColor(boardColor);
|
g2d.setColor(boardColor);
|
||||||
if (getType() == Type.SQUARE)
|
if (getType() == Type.SQUARE)
|
||||||
g2d.fillRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.fillRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
else
|
else
|
||||||
g2d.fillOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.fillOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
g2d.setComposite(oldComposite);
|
g2d.setComposite(oldComposite);
|
||||||
}
|
}
|
||||||
// Do not track any changes that follow because the whole board has been
|
// Do not track any changes that follow because the whole board has been
|
||||||
@@ -83,9 +86,9 @@ public class BlankBoard extends AbstractBoard {
|
|||||||
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
g2d.setColor(componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING ? SELECTION_COLOR
|
||||||
: borderColor);
|
: borderColor);
|
||||||
if (getType() == Type.SQUARE)
|
if (getType() == Type.SQUARE)
|
||||||
g2d.drawRect(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.drawRect(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
else
|
else
|
||||||
g2d.drawOval(firstPoint.x, firstPoint.y, secondPoint.x - firstPoint.x, secondPoint.y - firstPoint.y);
|
g2d.drawOval(firstPoint.x, firstPoint.y, finalSecondPoint.x - firstPoint.x, finalSecondPoint.y - firstPoint.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package org.diylc.components.boards;
|
||||||
|
|
||||||
|
import org.diylc.components.boards.AbstractBoard.BoardSizingMode;
|
||||||
|
import org.diylc.core.IPropertyValidator;
|
||||||
|
import org.diylc.core.ValidationException;
|
||||||
|
import org.diylc.core.measures.Size;
|
||||||
|
|
||||||
|
public class BoardModeValidator implements IPropertyValidator {
|
||||||
|
|
||||||
|
public BoardModeValidator() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object owner, Object value) throws ValidationException {
|
||||||
|
AbstractBoard board = (AbstractBoard)owner;
|
||||||
|
Size size = (Size)value;
|
||||||
|
if (board.getMode() == BoardSizingMode.Explicit && (value == null || size.getValue() == null || size.getUnit() == null))
|
||||||
|
throw new ValidationException("Dimensions are required when mode is set to " + BoardSizingMode.Explicit);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,9 +69,11 @@ public class EyeletBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
@@ -84,10 +86,10 @@ public class EyeletBoard extends AbstractBoard {
|
|||||||
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
|
|
||||||
while (p.y < secondPoint.y - spacing) {
|
while (p.y < finalSecondPoint.y - spacing) {
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
while (p.x < secondPoint.x - spacing - diameter) {
|
while (p.x < finalSecondPoint.x - spacing - diameter) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(eyeletColor);
|
g2d.setColor(eyeletColor);
|
||||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||||
|
|||||||
@@ -67,9 +67,11 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
@@ -81,10 +83,10 @@ public class MarshallPerfBoard extends AbstractBoard {
|
|||||||
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
|
|
||||||
while (p.y < secondPoint.y - spacing) {
|
while (p.y < finalSecondPoint.y - spacing) {
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
while (p.x < secondPoint.x - spacing - holeDiameter) {
|
while (p.x < finalSecondPoint.x - spacing - holeDiameter) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
g2d.fillOval(p.x - holeDiameter / 2, p.y - holeDiameter / 2, holeDiameter, holeDiameter);
|
||||||
|
|||||||
@@ -62,9 +62,11 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
@@ -77,10 +79,10 @@ public class PerfBoard extends AbstractBoard {
|
|||||||
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
int holeDiameter = getClosestOdd((int) HOLE_SIZE.convertToPixels());
|
||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
|
|
||||||
while (p.y < secondPoint.y - spacing) {
|
while (p.y < finalSecondPoint.y - spacing) {
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
while (p.x < secondPoint.x - spacing - diameter) {
|
while (p.x < finalSecondPoint.x - spacing - diameter) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(padColor);
|
g2d.setColor(padColor);
|
||||||
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
g2d.fillOval(p.x - diameter / 2, p.y - diameter / 2, diameter, diameter);
|
||||||
|
|||||||
@@ -65,9 +65,11 @@ public class TriPadBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
@@ -82,13 +84,13 @@ public class TriPadBoard extends AbstractBoard {
|
|||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
|
|
||||||
if (orientation == OrientationHV.HORIZONTAL) {
|
if (orientation == OrientationHV.HORIZONTAL) {
|
||||||
while (p.y < secondPoint.y - spacing) {
|
while (p.y < finalSecondPoint.y - spacing) {
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
|
|
||||||
while (p.x + spacing < secondPoint.x) {
|
while (p.x + spacing < finalSecondPoint.x) {
|
||||||
|
|
||||||
int remainingSpace = secondPoint.x - p.x;
|
int remainingSpace = finalSecondPoint.x - p.x;
|
||||||
int spacesToDraw = stripSpan;
|
int spacesToDraw = stripSpan;
|
||||||
|
|
||||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||||
@@ -111,7 +113,7 @@ public class TriPadBoard extends AbstractBoard {
|
|||||||
// draw holes
|
// draw holes
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
|
|
||||||
while (p.x < secondPoint.x - spacing - holeSize) {
|
while (p.x < finalSecondPoint.x - spacing - holeSize) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||||
@@ -120,13 +122,13 @@ public class TriPadBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (p.x < secondPoint.x - spacing) {
|
while (p.x < finalSecondPoint.x - spacing) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
p.y = firstPoint.y;
|
p.y = firstPoint.y;
|
||||||
|
|
||||||
while (p.y + spacing < secondPoint.y) {
|
while (p.y + spacing < finalSecondPoint.y) {
|
||||||
|
|
||||||
int remainingSpace = secondPoint.y - p.y;
|
int remainingSpace = finalSecondPoint.y - p.y;
|
||||||
int spacesToDraw = stripSpan;
|
int spacesToDraw = stripSpan;
|
||||||
|
|
||||||
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
if (remainingSpace < (stripSize + (stripSpan * spacing))) {
|
||||||
@@ -148,7 +150,7 @@ public class TriPadBoard extends AbstractBoard {
|
|||||||
// draw holes
|
// draw holes
|
||||||
p.y = firstPoint.y;
|
p.y = firstPoint.y;
|
||||||
|
|
||||||
while (p.y < secondPoint.y - spacing - holeSize) {
|
while (p.y < finalSecondPoint.y - spacing - holeSize) {
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||||
|
|||||||
@@ -65,9 +65,11 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
public void draw(Graphics2D g2d, ComponentState componentState, boolean outlineMode, Project project,
|
||||||
IDrawingObserver drawingObserver) {
|
IDrawingObserver drawingObserver) {
|
||||||
|
Point finalSecondPoint = getFinalSecondPoint();
|
||||||
|
|
||||||
Shape clip = g2d.getClip();
|
Shape clip = g2d.getClip();
|
||||||
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, secondPoint.y)
|
if (checkPointsClipped(clip) && !clip.contains(firstPoint.x, finalSecondPoint.y)
|
||||||
&& !clip.contains(secondPoint.x, firstPoint.y)) {
|
&& !clip.contains(finalSecondPoint.x, firstPoint.y)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
super.draw(g2d, componentState, outlineMode, project, drawingObserver);
|
||||||
@@ -82,16 +84,16 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
int spacing = (int) this.spacing.convertToPixels();
|
int spacing = (int) this.spacing.convertToPixels();
|
||||||
|
|
||||||
if (orientation == OrientationHV.HORIZONTAL) {
|
if (orientation == OrientationHV.HORIZONTAL) {
|
||||||
while (p.y < secondPoint.y - spacing) {
|
while (p.y < finalSecondPoint.y - spacing) {
|
||||||
p.x = firstPoint.x;
|
p.x = firstPoint.x;
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(stripColor);
|
g2d.setColor(stripColor);
|
||||||
drawingObserver.startTrackingContinuityArea(true);
|
drawingObserver.startTrackingContinuityArea(true);
|
||||||
g2d.fillRect(p.x + spacing / 2, p.y - stripSize / 2, secondPoint.x - spacing - p.x, stripSize);
|
g2d.fillRect(p.x + spacing / 2, p.y - stripSize / 2, finalSecondPoint.x - spacing - p.x, stripSize);
|
||||||
drawingObserver.stopTrackingContinuityArea();
|
drawingObserver.stopTrackingContinuityArea();
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawRect(p.x + spacing / 2, p.y - stripSize / 2, secondPoint.x - spacing - p.x, stripSize);
|
g2d.drawRect(p.x + spacing / 2, p.y - stripSize / 2, finalSecondPoint.x - spacing - p.x, stripSize);
|
||||||
while (p.x < secondPoint.x - spacing - holeSize) {
|
while (p.x < finalSecondPoint.x - spacing - holeSize) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||||
@@ -100,16 +102,16 @@ public class VeroBoard extends AbstractBoard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (p.x < secondPoint.x - spacing) {
|
while (p.x < finalSecondPoint.x - spacing) {
|
||||||
p.x += spacing;
|
p.x += spacing;
|
||||||
p.y = firstPoint.y;
|
p.y = firstPoint.y;
|
||||||
g2d.setColor(stripColor);
|
g2d.setColor(stripColor);
|
||||||
drawingObserver.startTrackingContinuityArea(true);
|
drawingObserver.startTrackingContinuityArea(true);
|
||||||
g2d.fillRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, secondPoint.y - spacing - p.y);
|
g2d.fillRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, finalSecondPoint.y - spacing - p.y);
|
||||||
drawingObserver.stopTrackingContinuityArea();
|
drawingObserver.stopTrackingContinuityArea();
|
||||||
g2d.setColor(stripColor.darker());
|
g2d.setColor(stripColor.darker());
|
||||||
g2d.drawRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, secondPoint.y - spacing - p.y);
|
g2d.drawRect(p.x - stripSize / 2, p.y + spacing / 2, stripSize, finalSecondPoint.y - spacing - p.y);
|
||||||
while (p.y < secondPoint.y - spacing - holeSize) {
|
while (p.y < finalSecondPoint.y - spacing - holeSize) {
|
||||||
p.y += spacing;
|
p.y += spacing;
|
||||||
g2d.setColor(Constants.CANVAS_COLOR);
|
g2d.setColor(Constants.CANVAS_COLOR);
|
||||||
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
g2d.fillOval(p.x - holeSize / 2, p.y - holeSize / 2, holeSize, holeSize);
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ public class DiodeSymbol extends AbstractTubeSymbol {
|
|||||||
public class HeaterValidator implements IPropertyValidator {
|
public class HeaterValidator implements IPropertyValidator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validate(Object value) throws ValidationException {
|
public void validate(Object owner, Object value) throws ValidationException {
|
||||||
if (value != null && value instanceof Boolean) {
|
if (value != null && value instanceof Boolean) {
|
||||||
boolean b = (Boolean) value;
|
boolean b = (Boolean) value;
|
||||||
if (!b && getDirectlyHeated()) {
|
if (!b && getDirectlyHeated()) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -89,7 +89,7 @@ public class MeasureEditor extends Container {
|
|||||||
try {
|
try {
|
||||||
Constructor<?> ctor = property.getType().getConstructors()[0];
|
Constructor<?> ctor = property.getType().getConstructors()[0];
|
||||||
Double newValue = valueField.getValue();
|
Double newValue = valueField.getValue();
|
||||||
if (newValue != null && property.isReadOnly() && measure.isConvertible()) {
|
if (newValue != null && property.isReadOnly()) {
|
||||||
double oldFactor = ((Unit)((AbstractMeasure<?>)property.getValue()).getUnit()).getFactor();
|
double oldFactor = ((Unit)((AbstractMeasure<?>)property.getValue()).getUnit()).getFactor();
|
||||||
double newFactor = ((Unit)unitBox.getSelectedItem()).getFactor();
|
double newFactor = ((Unit)unitBox.getSelectedItem()).getFactor();
|
||||||
newValue = newValue * oldFactor / newFactor;
|
newValue = newValue * oldFactor / newFactor;
|
||||||
@@ -111,7 +111,7 @@ public class MeasureEditor extends Container {
|
|||||||
|
|
||||||
if (property.isReadOnly()) {
|
if (property.isReadOnly()) {
|
||||||
valueField.setEnabled(false);
|
valueField.setEnabled(false);
|
||||||
unitBox.setEnabled(measure.isConvertible());
|
unitBox.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!property.isUnique()) {
|
if (!property.isUnique()) {
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
|
*
|
||||||
DIY Layout Creator (DIYLC).
|
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
|
||||||
Copyright (c) 2009-2018 held jointly by the individual authors.
|
*
|
||||||
|
* This file is part of DIYLC.
|
||||||
This file is part of DIYLC.
|
*
|
||||||
|
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
|
||||||
DIYLC is free software: you can redistribute it and/or modify
|
* General Public License as published by the Free Software Foundation, either version 3 of the
|
||||||
it under the terms of the GNU General Public License as published by
|
* License, or (at your option) any later version.
|
||||||
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
|
||||||
DIYLC is distributed in the hope that it will be useful,
|
* Public License for more details.
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
*
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
|
||||||
GNU General Public License for more details.
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
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.swing.gui.editor;
|
package org.diylc.swing.gui.editor;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
@@ -30,6 +27,7 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -61,7 +59,8 @@ public class PropertyEditorDialog extends ButtonDialog {
|
|||||||
private Component componentToFocus = null;
|
private Component componentToFocus = null;
|
||||||
private boolean saveDefaults;
|
private boolean saveDefaults;
|
||||||
|
|
||||||
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title, boolean saveDefaults) {
|
public PropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title,
|
||||||
|
boolean saveDefaults) {
|
||||||
super(owner, title, new String[] {ButtonDialog.OK, ButtonDialog.CANCEL});
|
super(owner, title, new String[] {ButtonDialog.OK, ButtonDialog.CANCEL});
|
||||||
this.saveDefaults = saveDefaults;
|
this.saveDefaults = saveDefaults;
|
||||||
|
|
||||||
@@ -79,12 +78,32 @@ public class PropertyEditorDialog extends ButtonDialog {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean validateInput(String button) {
|
protected boolean validateInput(String button) {
|
||||||
if (button.equals(ButtonDialog.OK)) {
|
if (button.equals(ButtonDialog.OK)) {
|
||||||
|
Object testObject = null;
|
||||||
|
if (properties.size() > 0) {
|
||||||
|
if (properties.get(0).getOwnerObject() instanceof Cloneable) {
|
||||||
|
try {
|
||||||
|
Object object = ((Cloneable) properties.get(0).getOwnerObject());
|
||||||
|
Method method = object.getClass().getMethod("clone");
|
||||||
|
method.setAccessible(true);
|
||||||
|
testObject = method.invoke(object);
|
||||||
|
for (PropertyWrapper property : properties) {
|
||||||
|
property.writeTo(testObject);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Could not clone test object", e);
|
||||||
|
testObject = properties.get(0).getOwnerObject();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
testObject = properties.get(0).getOwnerObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
for (PropertyWrapper property : properties) {
|
for (PropertyWrapper property : properties) {
|
||||||
try {
|
try {
|
||||||
property.getValidator().validate(property.getValue());
|
property.getValidator().validate(testObject, property.getValue());
|
||||||
} catch (ValidationException ve) {
|
} catch (ValidationException ve) {
|
||||||
JOptionPane.showMessageDialog(PropertyEditorDialog.this, "Input error for \"" + property.getName() + "\": "
|
JOptionPane.showMessageDialog(PropertyEditorDialog.this,
|
||||||
+ ve.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
|
"Input error for \"" + property.getName() + "\": " + ve.getMessage(), "Error",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +164,8 @@ public class PropertyEditorDialog extends ButtonDialog {
|
|||||||
|
|
||||||
// Make value field focused
|
// Make value field focused
|
||||||
try {
|
try {
|
||||||
if (componentToFocus == null && property.getGetter().getName().equalsIgnoreCase("getValue")) {
|
if (componentToFocus == null
|
||||||
|
&& property.getGetter().getName().equalsIgnoreCase("getValue")) {
|
||||||
componentToFocus = editor;
|
componentToFocus = editor;
|
||||||
}
|
}
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user