Skip to content

Commit

Permalink
Merge branch 'master' into bachrusMessageFix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pugwash1 committed Oct 16, 2018
2 parents cdd2887 + 1db86bd commit 985c9d3
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 84 deletions.
2 changes: 2 additions & 0 deletions help/en/html/doc/Technical/CI-status.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
</a>
</td><td align="center">
<b><a href="jacoco_sort_report.php">JaCoCo Sortable Coverage Report</a></b>
<br>
<b><a href="jacoco_difference.php ">Compare Two JaCoCo Runs</a></b>
</td></tr>

<tr><td><a href="http://jmri.tagadab.com/jenkins/job/Development/job/Builds/">Builds</a> - Unit Test Results<br>
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion java/src/jmri/CatalogTreeManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jmri;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;

/**
* Locate a CatalogTree object representing some specific information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,9 @@ private boolean validateDCCAddress() {

@Nonnull JComboBox<String> copyFromMastSelection() {
JComboBox<String> mastSelect = new JComboBox<>();
List<String> names = InstanceManager.getDefault(jmri.SignalMastManager.class).getSystemNameList();
for (String name : names) {
if ((InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBean(name) instanceof DccSignalMast)){
mastSelect.addItem(InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBean(name).getDisplayName());
for (SignalMast mast : InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBeanSet()) {
if (mast instanceof DccSignalMast){
mastSelect.addItem(mast.getDisplayName());
}
}
if (mastSelect.getItemCount() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,9 @@ public void actionPerformed(ActionEvent e) {

JComboBox<String> copyFromMastSelection() {
JComboBox<String> mastSelect = new JComboBox<>();
List<String> names = InstanceManager.getDefault(jmri.SignalMastManager.class).getSystemNameList();
for (String name : names) {
// only accept MatrixSignalMast masts
if (InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBean(name) instanceof MatrixSignalMast) {
SignalMast m = InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBean(name);
if (m!=null) {
mastSelect.addItem(m.getDisplayName());
} else {
log.error("Can't copy from mast {} as it doesn't exist", name);
}
for (SignalMast mast : InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBeanSet()) {
if (mast instanceof DccSignalMast){
mastSelect.addItem(mast.getDisplayName());
}
}
if (mastSelect.getItemCount() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,24 @@ void setSlaveBoxLists() {
_addRepeater.setEnabled(false);
return;
}
java.util.Iterator<String> iter
= dsmm.getSystemNameList().iterator();
java.util.Iterator<SignalMast> iter
= dsmm.getNamedBeanSet().iterator();

// don't return an element if there are not sensors to include
if (!iter.hasNext()) {
return;
}
ArrayList<NamedBean> excludeList = new ArrayList<>();
while (iter.hasNext()) {
String mname = iter.next();
if (mname != null) {
SignalMast s = dsmm.getBySystemName(mname);
if (s.getAppearanceMap() != masterMast.getAppearanceMap()) {
excludeList.add(s);
} else if (s == masterMast) {
excludeList.add(s);
}
SignalMast s = iter.next();
if (s.getAppearanceMap() != masterMast.getAppearanceMap()) {
excludeList.add(s);
} else if (s == masterMast) {
excludeList.add(s);
}
}
_SlaveBox.excludeItems(excludeList);
if (excludeList.size() == dsmm.getSystemNameList().size()) {
if (excludeList.size() == dsmm.getNamedBeanSet().size()) {
_SlaveBox.setEnabled(false);
_addRepeater.setEnabled(false);
} else {
Expand Down
16 changes: 10 additions & 6 deletions java/src/jmri/jmrit/catalog/CatalogTreeFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ boolean filter(String ext) {
}
return false;
}

int count = 0;
int leafcount = 0;

/**
* Recursively add nodes to the tree
Expand Down Expand Up @@ -81,8 +84,8 @@ public void insertNodes(String pName, String pPath, CatalogTreeNode pParent) {
insertNodeInto(newElement, pParent, pParent.getChildCount());
String[] sp = fp.list();
for (int i = 0; i < sp.length; i++) {
log.debug("Descend into resource: {}",sp[i]);
insertNodes(sp[i], pPath + "/" + sp[i], newElement);
log.debug("Descend into resource: {} count {}",sp[i], count++);
insertNodes(sp[i], pPath + File.separator + sp[i], newElement);
}
} else /* leaf */ {
String ext = jmri.util.FileChooserFilter.getFileExtension(fp);
Expand All @@ -93,37 +96,38 @@ public void insertNodes(String pName, String pPath, CatalogTreeNode pParent) {
if (index > 0) {
filename = filename.substring(0, index);
}
log.debug("add leaf: {} count {}", filename, leafcount++);
pParent.addLeaf(filename, pPath);
}
}

@Override
public void setProperty(String key, Object value) {
if (parameters == null) {
parameters = new HashMap<String, Object>();
parameters = new HashMap<>();
}
parameters.put(key, value);
}

@Override
public Object getProperty(String key) {
if (parameters == null) {
parameters = new HashMap<String, Object>();
parameters = new HashMap<>();
}
return parameters.get(key);
}

@Override
public java.util.Set<String> getPropertyKeys() {
if (parameters == null) {
parameters = new HashMap<String, Object>();
parameters = new HashMap<>();
}
return parameters.keySet();
}

@Override
public void removeProperty(String key) {
if (parameters == null || key == null) {
if (parameters == null) {
return;
}
parameters.remove(key);
Expand Down
41 changes: 22 additions & 19 deletions java/src/jmri/jmrit/catalog/CatalogTreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import java.util.ArrayList;
import java.util.Enumeration;
import javax.swing.tree.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;

/**
* Node of a CatalogTree.
Expand Down Expand Up @@ -32,26 +31,30 @@ public void addLeaf(CatalogTreeLeaf leaf) {
}

/**
* Insert leaf according to height.
* Insert leaf according to height. Dan Boudreau 10/15/2018 eliminated the
* check for valid icon and the sorting of the icons by height. Improves
* load time at initialization by an order of magnitude.
*
* @param name name of the new leaf
* @param path path to the new leaf
*/
public void addLeaf(String name, String path) {
// check path
NamedIcon icon = NamedIcon.getIconByName(path);
if (icon == null) {
log.warn("path \"" + path + "\" is not a NamedIcon.");
return;
}
int h = icon.getIconHeight();
for (int i = 0; i < _leafs.size(); i++) {
CatalogTreeLeaf leaf = _leafs.get(i);
if (h < leaf.getSize()) {
_leafs.add(i + 1, new CatalogTreeLeaf(name, path, h));
return;
}
}
// NamedIcon icon = NamedIcon.getIconByName(path);
// if (icon == null) {
// log.warn("path \" {} \" is not a NamedIcon.", path);
// return;
// }
// int h = icon.getIconHeight();
// log.debug("_leafs size {}", _leafs.size());
// for (int i = 0; i < _leafs.size(); i++) {
// CatalogTreeLeaf leaf = _leafs.get(i);
// if (h < leaf.getSize()) {
// _leafs.add(i + 1, new CatalogTreeLeaf(name, path, h));
// return;
// }
// }
int h = 0;
_leafs.add(new CatalogTreeLeaf(name, path, h));
}

Expand Down Expand Up @@ -109,7 +112,7 @@ public ArrayList<CatalogTreeLeaf> getLeaves(String name) {

@Override
@SuppressWarnings("unchecked")
public Enumeration<TreeNode> children() { // for JDK 9 typing
public Enumeration<TreeNode> children() { // for JDK 9 typing
return super.children();
}

Expand All @@ -125,5 +128,5 @@ public void setLeaves(ArrayList<CatalogTreeLeaf> leafs) {
_leafs = leafs;
}

private final static Logger log = LoggerFactory.getLogger(CatalogTreeNode.class);
// private final static Logger log = LoggerFactory.getLogger(CatalogTreeNode.class);
}
2 changes: 2 additions & 0 deletions java/src/jmri/jmrix/loconet/hexfile/HexFileFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,12 @@ public boolean disposeThrottle(DccThrottle t, jmri.ThrottleListener l) {
sourceThread.start();
}

@SuppressWarnings("deprecation") // Thread.suspend() not being removed
public void filePauseButtonActionPerformed(java.awt.event.ActionEvent e) {
sourceThread.suspend();
}

@SuppressWarnings("deprecation") // Thread.resume() not being removed
public void jButton1ActionPerformed(java.awt.event.ActionEvent e) { // resume button
sourceThread.resume();
}
Expand Down
20 changes: 12 additions & 8 deletions java/test/jmri/jmrit/display/layoutEditor/LayoutSlipTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,7 @@ public static void afterClass() {
}

@Before
public void setUp() throws Exception {
JUnitUtil.setUp();
public void setUp() {
jmri.util.JUnitUtil.resetProfileManager();
if (!GraphicsEnvironment.isHeadless()) {
lts = new LayoutSlip("single", new Point2D.Double(50.0, 100.0), +45.0, layoutEditor, LayoutTurnout.SINGLE_SLIP);
Expand All @@ -734,12 +733,17 @@ public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
lts = null;
ltd = null;

// reset the instance manager.
JUnitUtil.tearDown();
public void tearDown() {
if(lts!=null) {
lts.remove();
lts.dispose();
lts = null;
}
if(ltd!=null) {
ltd.remove();
ltd.dispose();
ltd = null;
}
}
//private final static Logger log = LoggerFactory.getLogger(LayoutSlipTest.class);
}
66 changes: 41 additions & 25 deletions java/test/jmri/jmrit/display/layoutEditor/LayoutTurnoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
public class LayoutTurnoutTest {

private static LayoutEditor layoutEditor = null;
LayoutTurnout ltRH = null;
LayoutTurnout ltLH = null;
LayoutTurnout ltWY = null;
LayoutTurnout ltDX = null;
LayoutTurnout ltRX = null;
LayoutTurnout ltLX = null;
private LayoutTurnout ltRH = null;
private LayoutTurnout ltLH = null;
private LayoutTurnout ltWY = null;
private LayoutTurnout ltDX = null;
private LayoutTurnout ltRX = null;
private LayoutTurnout ltLX = null;

@Test
public void testNew() {
Expand Down Expand Up @@ -471,22 +471,22 @@ public void testGetCoordsForConnectionType() {
public void testGetBounds() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
Assert.assertEquals("ltRH.getBounds() is equal to...",
new Rectangle2D.Double(132.0, 87.0, 36.0, 36.0),
new Rectangle2D.Double(121.0, 80.0, 58.0, 55.0),
ltRH.getBounds());
Assert.assertEquals("ltLH.getBounds() is equal to...",
new Rectangle2D.Double(189.0, 149.0, 33.0, 52.0),
new Rectangle2D.Double(184.0, 135.0, 50.0, 80.0),
ltLH.getBounds());
Assert.assertEquals("ltWY.getBounds() is equal to...",
new Rectangle2D.Double(238.0, 218.5, 16.5, 64.5),
new Rectangle2D.Double(232.0, 201.0, 25.0, 100.0),
ltWY.getBounds());
Assert.assertEquals("ltDX.getBounds() is equal to...",
new Rectangle2D.Double(253.0, 273.0, 94.0, 104.0),
new Rectangle2D.Double(199.0, 213.0, 202.0, 224.0),
ltDX.getBounds());
Assert.assertEquals("ltRX.getBounds() is equal to...",
new Rectangle2D.Double(290.0, 376.0, 120.0, 48.0),
new Rectangle2D.Double(223.0, 345.0, 254.0, 110.0),
ltRX.getBounds());
Assert.assertEquals("ltLX.getBounds() is equal to...",
new Rectangle2D.Double(334.0, 447.0, 132.0, 56.0),
new Rectangle2D.Double(259.0, 413.0, 282.0, 124.0),
ltLX.getBounds());
}

Expand Down Expand Up @@ -756,10 +756,8 @@ public static void afterClass() {

@Before
public void setUp() throws Exception {
JUnitUtil.setUp();
JUnitUtil.resetProfileManager();
if (!GraphicsEnvironment.isHeadless()) {
layoutEditor = new LayoutEditor();
Point2D point = new Point2D.Double(150.0, 100.0);
Point2D delta = new Point2D.Double(50.0, 75.0);

Expand Down Expand Up @@ -790,18 +788,36 @@ public void setUp() throws Exception {

@After
public void tearDown() throws Exception {
if (layoutEditor != null) {
JUnitUtil.dispose(layoutEditor);
if(ltRH!=null){
ltRH.remove();
ltRH.dispose();
ltRH = null;
}
if(ltLH!=null){
ltLH.remove();
ltLH.dispose();
ltLH = null;
}
if(ltWY!=null){
ltWY.remove();
ltWY.dispose();
ltWY = null;
}
if(ltDX!=null){
ltDX.remove();
ltDX.dispose();
ltDX = null;
}
if(ltRX!=null){
ltRX.remove();
ltRX.dispose();
ltRX = null;
}
if(ltLX!=null){
ltLX.remove();
ltLX.dispose();
ltLX = null;
}
layoutEditor = null;
ltRH = null;
ltLH = null;
ltWY = null;
ltDX = null;
ltRX = null;
ltLX = null;
// reset the instance manager.
JUnitUtil.tearDown();
}
// private final static Logger log = LoggerFactory.getLogger(LayoutSlipTest.class);
}
Loading

0 comments on commit 985c9d3

Please sign in to comment.