Skip to content
Permalink
Browse files

keySet iterators spotted by SpotBugs for other masts

whitespace, javadoc
  • Loading branch information...
silverailscolo committed Jun 2, 2019
1 parent 2ac8d7c commit fda4d6c4c0e5f89c89b8014afdf9843539614b28
@@ -16,7 +16,7 @@
import org.openide.util.lookup.ServiceProvider;

/**
* A pane for configuring MatrixSignalMast objects
* A pane for configuring MatrixSignalMast objects.
*
* @see jmri.jmrit.beantable.signalmast.SignalMastAddPane
* @author Bob Jacobsen Copyright (C) 2018
@@ -37,7 +37,6 @@ public DccSignalMastAddPane() {
dccMastScroll = new JScrollPane(dccMastPanel);
dccMastScroll.setBorder(BorderFactory.createEmptyBorder());
add(dccMastScroll);

}

/** {@inheritDoc} */
@@ -62,7 +61,7 @@ public DccSignalMastAddPane() {
SignalSystem sigsys;

/**
* Check if a command station will work for this subtype
* Check if a command station will work for this subtype.
*/
protected boolean usableCommandStation(CommandStation cs) {
return true;
@@ -109,12 +108,12 @@ public void setAspectNames(@Nonnull SignalAppearanceMap map,
dccAspectAddressField.setText("");
dccMastPanel.add(dccAspectAddressField);

for (String aspect : dccAspect.keySet()) {
log.trace(" aspect: {}", aspect);
dccMastPanel.add(dccAspect.get(aspect).getPanel());
for (Map.Entry<String, DCCAspectPanel> entry : dccAspect.entrySet()) {
log.trace(" aspect: {}", entry.getKey());
dccMastPanel.add(entry.getValue().getPanel());
}

dccMastPanel.add(new JLabel(Bundle.getMessage("DCCMastCopyAspectId") + ":"));
dccMastPanel.add(new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("DCCMastCopyAspectId"))));
dccMastPanel.add(copyFromMastSelection());

dccMastPanel.setLayout(new jmri.util.javaworld.GridLayout2(0, 2)); // 0 means enough
@@ -124,7 +123,6 @@ public void setAspectNames(@Nonnull SignalAppearanceMap map,
log.trace("setAspectNames(...) end");
}


/** {@inheritDoc} */
@Override
public boolean canHandleMast(@Nonnull SignalMast mast) {
@@ -161,7 +159,6 @@ public void setMast(SignalMast mast) {
if (!currentMast.isAspectDisabled(key)) {
dccPanel.setAspectId(currentMast.getOutputForAppearance(key));
}

}
}
List<jmri.CommandStation> connList = jmri.InstanceManager.getList(jmri.CommandStation.class);
@@ -206,15 +203,15 @@ static boolean validateAspectId(@Nonnull String strAspect) {
}

/**
* Return the first part of the system name
* for the specific mast type
* Get the first part of the system name
* for the specific mast type.
*/
protected @Nonnull String getNamePrefix() {
return "F$dsm:";
}

/**
* Create a mast of the specific subtype
* Create a mast of the specific subtype.
*/
protected DccSignalMast constructMast(@Nonnull String name) {
return new DccSignalMast(name);
@@ -250,13 +247,13 @@ public boolean createMast(@Nonnull
InstanceManager.getDefault(jmri.SignalMastManager.class).register(currentMast);
}

for (String aspect : dccAspect.keySet()) {
dccMastPanel.add(dccAspect.get(aspect).getPanel()); // update mast from aspect subpanel panel
currentMast.setOutputForAppearance(aspect, dccAspect.get(aspect).getAspectId());
if (dccAspect.get(aspect).isAspectDisabled()) {
currentMast.setAspectDisabled(aspect);
for (Map.Entry<String, DCCAspectPanel> entry : dccAspect.entrySet()) {
dccMastPanel.add(entry.getValue().getPanel()); // update mast from aspect subpanel panel
currentMast.setOutputForAppearance(entry.getKey(), entry.getValue().getAspectId());
if (entry.getValue().isAspectDisabled()) {
currentMast.setAspectDisabled(entry.getKey());
} else {
currentMast.setAspectEnabled(aspect);
currentMast.setAspectEnabled(entry.getKey());
}
}
if (!username.equals("")) {
@@ -340,7 +337,7 @@ public void actionPerformed(ActionEvent e) {
}

/**
* Copy aspects by name from another DccSignalMast
* Copy aspects by name from another DccSignalMast.
*/
void copyFromAnotherDCCMastAspect(@Nonnull String strMast) {
DccSignalMast mast = (DccSignalMast) InstanceManager.getDefault(jmri.SignalMastManager.class).getNamedBean(strMast);
@@ -349,22 +346,22 @@ void copyFromAnotherDCCMastAspect(@Nonnull String strMast) {
return;
}
Vector<String> validAspects = mast.getValidAspects();
for (String aspect : dccAspect.keySet()) {
if (validAspects.contains(aspect) || mast.isAspectDisabled(aspect)) { // valid doesn't include disabled
for (Map.Entry<String, DCCAspectPanel> entry : dccAspect.entrySet()) {
if (validAspects.contains(entry.getKey()) || mast.isAspectDisabled(entry.getKey())) { // valid doesn't include disabled
// present, copy
dccAspect.get(aspect).setAspectId(mast.getOutputForAppearance(aspect));
dccAspect.get(aspect).setAspectDisabled(mast.isAspectDisabled(aspect));
entry.getValue().setAspectId(mast.getOutputForAppearance(entry.getKey()));
entry.getValue().setAspectDisabled(mast.isAspectDisabled(entry.getKey()));
} else {
// not present, log
log.info("Can't get aspect \"{}\" from head \"{}\", leaving unchanged", aspect, mast);
log.info("Can't get aspect \"{}\" from head \"{}\", leaving unchanged", entry.getKey(), mast);
}
}
}

/**
* JPanel to define properties of an Aspect for a DCC Signal Mast.
* <p>
* Invoked from the AddSignalMastPanel class when a DCC Signal Mast is
* Invoked from the {@link AddSignalMastPanel} class when a DCC Signal Mast is
* selected.
*/
static class DCCAspectPanel {
@@ -455,4 +452,5 @@ public void actionPerformed(ActionEvent e) {
}

private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(DccSignalMastAddPane.class);

}
@@ -17,7 +17,7 @@
import org.openide.util.lookup.ServiceProvider;

/**
* A pane for configuring SignalHeadSignalMast objects
* A pane for configuring SignalHeadSignalMast objects.
*
* @see jmri.jmrit.beantable.signalmast.SignalMastAddPane
* @author Bob Jacobsen Copyright (C) 2018
@@ -110,13 +110,12 @@ public void setAspectNames(@Nonnull
disabledAspects.put(aspect, disabled);
}

for (String aspect : disabledAspects.keySet()) {
disabledAspectsPanel.add(disabledAspects.get(aspect));
for (Map.Entry<String, JCheckBox> entry : disabledAspects.entrySet()) {
disabledAspectsPanel.add(entry.getValue());
}

disabledAspectsPanel.setLayout(new jmri.util.javaworld.GridLayout2(0, 1)); // 0 means enough
disabledAspectsPanel.revalidate();

}

/** {@inheritDoc} */
@@ -158,7 +157,6 @@ public void setMast(SignalMast mast) {
signalHeadPanel.add(includeUsed);
signalHeadPanel.revalidate();


List<String> disabled = currentMast.getDisabledAspects();
if (disabled != null) {
for (String aspect : disabled) {
@@ -205,17 +203,17 @@ public boolean createMast(@Nonnull String sigsysname, @Nonnull String mastname,
return false; // without creating
}
}

// heads are attached via the system name

for (String aspect : disabledAspects.keySet()) {
if (disabledAspects.get(aspect).isSelected()) {
currentMast.setAspectDisabled(aspect);
// load a new or existing mast
for (Map.Entry<String, JCheckBox> entry : disabledAspects.entrySet()) {
if (entry.getValue().isSelected()) {
currentMast.setAspectDisabled(entry.getKey());
} else {
currentMast.setAspectEnabled(aspect);
currentMast.setAspectEnabled(entry.getKey());
}
}

// heads are attached via the system name
if (!username.equals("")) {
currentMast.setUserName(username);
}
@@ -265,4 +263,5 @@ void handleCreateException(String sysName) {
}

private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SignalHeadSignalMastAddPane.class);

}
@@ -17,7 +17,7 @@
import org.openide.util.lookup.ServiceProvider;

/**
* A pane for configuring TurnoutSignalMast objects
* A pane for configuring TurnoutSignalMast objects.
*
* @see jmri.jmrit.beantable.signalmast.SignalMastAddPane
* @author Bob Jacobsen Copyright (C) 2017, 2018
@@ -38,7 +38,6 @@ public TurnoutSignalMastAddPane() {
turnoutMastScroll = new JScrollPane(turnoutMastPanel);
turnoutMastScroll.setBorder(BorderFactory.createEmptyBorder());
add(turnoutMastScroll);

}

/** {@inheritDoc} */
@@ -73,9 +72,9 @@ public void setAspectNames(@Nonnull
}

turnoutMastPanel.removeAll();
for (String aspect : turnoutAspect.keySet()) {
log.trace(" aspect: {}", aspect);
turnoutMastPanel.add(turnoutAspect.get(aspect).getPanel());
for (Map.Entry<String, TurnoutAspectPanel> entry : turnoutAspect.entrySet()) {
log.trace(" aspect: {}", entry.getKey());
turnoutMastPanel.add(entry.getValue().getPanel());
}

turnoutMastPanel.add(resetPreviousState);
@@ -157,14 +156,14 @@ public boolean createMast(@Nonnull String sigsysname, @Nonnull String mastname,
name = currentMast.getSystemName();

// load a new or existing mast
for (String aspect : turnoutAspect.keySet()) {
turnoutAspect.get(aspect).setReference(name + ":" + aspect);
turnoutMastPanel.add(turnoutAspect.get(aspect).getPanel());
if (turnoutAspect.get(aspect).isAspectDisabled()) {
currentMast.setAspectDisabled(aspect);
for (Map.Entry<String, TurnoutAspectPanel> entry : turnoutAspect.entrySet()) {
entry.getValue().setReference(name + ":" + entry.getKey());
turnoutMastPanel.add(entry.getValue().getPanel());
if (entry.getValue().isAspectDisabled()) {
currentMast.setAspectDisabled(entry.getKey());
} else {
currentMast.setAspectEnabled(aspect);
currentMast.setTurnout(aspect, turnoutAspect.get(aspect).getTurnoutName(), turnoutAspect.get(aspect).getTurnoutState());
currentMast.setAspectEnabled(entry.getKey());
currentMast.setTurnout(entry.getKey(), entry.getValue().getTurnoutName(), entry.getValue().getTurnoutState());
}
}
currentMast.resetPreviousStates(resetPreviousState.isSelected());
@@ -312,4 +311,5 @@ JPanel getPanel() {
}

private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TurnoutSignalMastAddPane.class);

}
@@ -16,7 +16,7 @@
import org.openide.util.lookup.ServiceProvider;

/**
* A pane for configuring VirtualSignalMast objects
* A pane for configuring VirtualSignalMast objects.
*
* @see jmri.jmrit.beantable.signalmast.SignalMastAddPane
* @author Bob Jacobsen Copyright (C) 2018
@@ -68,10 +68,11 @@ public void setAspectNames(@Nonnull
JCheckBox disabled = new JCheckBox(aspect);
disabledAspects.put(aspect, disabled);
}
for (String aspect : disabledAspects.keySet()) {
disabledAspectsPanel.add(disabledAspects.get(aspect));

for (Map.Entry<String, JCheckBox> entry : disabledAspects.entrySet()) {
disabledAspectsPanel.add(entry.getValue());
}

disabledAspectsPanel.setLayout(new jmri.util.javaworld.GridLayout2(0, 1)); // 0 means enough

disabledAspectsPanel.revalidate();
@@ -134,13 +135,13 @@ public boolean createMast(@Nonnull
currentMast.setMastType(mastname.substring(11, mastname.length() - 4));
InstanceManager.getDefault(jmri.SignalMastManager.class).register(currentMast);
}

// load a new or existing mast
for (String aspect : disabledAspects.keySet()) {
if (disabledAspects.get(aspect).isSelected()) {
currentMast.setAspectDisabled(aspect);
for (Map.Entry<String, JCheckBox> entry : disabledAspects.entrySet()) {
if (entry.getValue().isSelected()) {
currentMast.setAspectDisabled(entry.getKey());
} else {
currentMast.setAspectEnabled(aspect);
currentMast.setAspectEnabled(entry.getKey());
}
}
currentMast.setAllowUnLit(allowUnLit.isSelected());
@@ -163,4 +164,5 @@ public boolean createMast(@Nonnull
}

private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(VirtualSignalMastAddPane.class);

}

0 comments on commit fda4d6c

Please sign in to comment.
You can’t perform that action at this time.