Skip to content

Commit

Permalink
Add release note items. Add test for coverage. Fix location error in
Browse files Browse the repository at this point in the history
Circuit Builder
  • Loading branch information
petecressman committed Apr 16, 2020
1 parent fc181ad commit ecf1fe0
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 25 deletions.
28 changes: 24 additions & 4 deletions help/en/releasenotes/current-draft-note.shtml
Expand Up @@ -327,12 +327,32 @@
<li></li>
</ul>

<h3>Circuit Builder</h3>
<a id="CB" name="CB"></a>
<h3>Control Panel Editor</h3>
<a id="CPE" name="CPE"></a>
<ul>
<li>The <strong>Palette</strong> and <strong>Circuit Builder</strong>
windows make a "best effort" to open at a position minimizing
any area that may obscure the panel display.</li>
<h4>Circuit Builder</h4>
<a id="CPE-CB" name="CPE-CB"></a>
<ul>
<li>The system name is auto generated when the<strong>Add New Detector Circuit
</strong> window is opened. This name may be changed before the Occupancy
Block is created. After creating, the field is removed from the window.</li>
</strong> window is opened. This name may be changed before the Occupancy
Block is created. After creating, the field is removed from the window
since the system name can no longer be edited.</li>
</ul>
<h4>Palette</h4>
<a id="CPE-P" name="CPE-P"></a>
<ul>
<li>Each tab resizes to display itself with its preferred dimensions.</li>
<li>The <strong>Memory</strong> Tab has been modified to display generic
forms of their respective devices. Dragging is best accomplished by
mouse down within the <strong>Drag to Panel</strong> box, but outside
of the device icon itself.</li>
<li>Bugs in the <strong>Signal Mast</strong> and <strong>Background</strong>
tabs have been fixed.</li>
<li>The <strong>Text</strong> tab items have been rearranged.</li>
</ul>
</ul>

<h3>DecoderPro</h3>
Expand Down
15 changes: 1 addition & 14 deletions java/src/jmri/jmrit/display/controlPanelEditor/EditFrame.java
Expand Up @@ -31,8 +31,6 @@ public abstract class EditFrame extends jmri.util.JmriJFrame {
protected boolean _suppressWarnings = false;

static int STRUT_SIZE = 10;
static Point _loc = new Point(-1, -1);
static Dimension _dim = new Dimension();

public EditFrame(String title, CircuitBuilder parent, OBlock block) {
super(false, false);
Expand Down Expand Up @@ -62,12 +60,7 @@ public void windowClosing(java.awt.event.WindowEvent e) {
setContentPane(contentPane);

pack();
if (_loc.x < 0) {
InstanceManager.getDefault(jmri.util.PlaceWindow.class).nextTo(_parent._editor, null, this);
} else {
setLocation(_loc);
setSize(_dim);
}
InstanceManager.getDefault(jmri.util.PlaceWindow.class).nextTo(_parent._editor, null, this);
setVisible(true);
}

Expand Down Expand Up @@ -151,14 +144,8 @@ protected boolean closingEvent(boolean close, String msg) {
}
}
}
storeLocDim(getLocation(_loc), getSize(_dim));
_parent.closeCircuitBuilder(_homeBlock);
dispose();
return true;
}

private static void storeLocDim(@Nonnull Point location, @Nonnull Dimension size) {
_loc = location;
_dim = size;
}
}
2 changes: 1 addition & 1 deletion java/src/jmri/jmrit/display/palette/ColorDialog.java
Expand Up @@ -151,8 +151,8 @@ public void windowClosing(java.awt.event.WindowEvent e) {
setContentPane(panel);

pack();
setVisible(true);
InstanceManager.getDefault(jmri.util.PlaceWindow.class).nextTo(client, t, this);
setVisible(true);
}

JPanel makePanel(JPanel p) {
Expand Down
6 changes: 4 additions & 2 deletions java/src/jmri/util/PlaceWindow.java
Expand Up @@ -95,7 +95,7 @@ public int getScreenNum(Window window) {
try {
for (int i = 0; i < _screenSize.length; i++) {
x += _screenSize[i].width;
if (window.getLocationOnScreen().x < x) {
if (window.getLocation().x < x) {
return i;
}
}
Expand All @@ -120,7 +120,9 @@ public Dimension getScreenSize(int screenNum) {
* minimize the amount the target window is off screen. The method guarantees
* a non-null component will not be obscured.\p
* If the component is null, the target window is placed beside the parent
* window, to the Left, Right, Below or Above it.
* window, to the Left, Right, Below or Above it.\b
* Should be called after target is packed and <strong>before</strong> target is
* set visible.
* @param parent Window containing the Component
* @param comp Component contained in the parent Window. May be null.
* @param target a popup or some kind of window associated with the component
Expand Down
Expand Up @@ -130,16 +130,15 @@ public void testEditSignalFrame() {
}

@Test
@org.junit.Ignore ("'OK' button does not dismiss dialog.")
public void testEditPortalError() {
getCPEandCB();

/*
new Thread(() -> {
JFrameOperator jfo = new JFrameOperator("Edit \"WestSiding\" Portals");
JDialogOperator jdo = new JDialogOperator(jfo, Bundle.getMessage("incompleteCircuit"));
JButtonOperator jbo = new JButtonOperator(jdo, "OK");
jbo.push();
}).start();
}).start();*/

cb.editPortalError("EastExit-EastJunction");

Expand Down
26 changes: 25 additions & 1 deletion java/test/jmri/util/PlaceWindowTest.java
Expand Up @@ -40,9 +40,9 @@ public void testNextTo() {
w2.getContentPane().add(Box.createRigidArea(new Dimension(200, 200)));
w2.setLocation(100, 100);
w2.pack();
w2.setVisible(true);

PlaceWindow pw = new PlaceWindow();
w2.setVisible(true);
Point pt = pw.nextTo(w1, null, w2); // w2 to the right of w1
// weaken assertion for test environments with different screen environment
Assert.assertTrue("pt.x=", pt.x >= 600);
Expand All @@ -57,6 +57,30 @@ public void testNextTo() {
w1.dispose();
w2.dispose();
}

@Test
public void testNextToBig() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
java.awt.Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
JFrame w1 = new JFrame();
w1.getContentPane().add(Box.createRigidArea(new Dimension(rect.width - 20, rect.height-60)));
w1.setLocation(10, 50);
w1.pack();
w1.setVisible(true);

JFrame w2 = new JFrame();
w2.getContentPane().add(Box.createRigidArea(new Dimension(200, 200)));
w2.setLocation(100, 100);
w2.pack();
w2.setVisible(true);

PlaceWindow pw = new PlaceWindow();
Point pt = pw.nextTo(w1, null, w2);
// w2 position should be centered within a pixel and overlap from above
Assert.assertTrue("pt.x at screen center", Math.abs((rect.width/2-100) - pt.x) <= 2);
Assert.assertEquals("pt.y at screen top",0, pt.y);
}

// The minimal setup for log4J
@Before
public void setUp() {
Expand Down

0 comments on commit ecf1fe0

Please sign in to comment.