Skip to content
Permalink
Browse files

beantable spotbugs

  • Loading branch information...
icklesteve committed May 30, 2019
1 parent 6b741a3 commit 11c22c4d258129a511701e9e93616758db15067f
@@ -842,7 +842,7 @@ public void deactivateLightControl() {
}
break;
default:
log.warn("Unexpected control type when activating Light: " + _parentLight.getSystemName());
log.warn("Unexpected control type when activating Light: {}", _parentLight.getSystemName());
}
_active = false;
}
@@ -441,11 +441,10 @@ public Component getTableCellEditorComponent(
return updateLabel((String) value, row);
}

@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "CF_USELESS_CONTROL_FLOW",
justification = "OK to compare floats, as even tiny differences should trigger update")
public JLabel updateLabel(String value, int row) {
if (iconHeight > 0) { // if necessary, increase row height;
//table.setRowHeight(row, Math.max(table.getRowHeight(), iconHeight - 5)); // TODO adjust table row height for Lights
log.debug("TODO adjust table row height for Lights?");
//table.setRowHeight(row, Math.max(table.getRowHeight(), iconHeight - 5));
}
if (value.equals(Bundle.getMessage("StateOff")) && offIcon != null) {
label = new JLabel(offIcon);
@@ -828,10 +827,10 @@ protected void prefixChanged() {
// Update tooltip in the Add Light pane to match system connection selected from combobox.
log.debug("Connection choice = [{}]", connectionChoice);
// get tooltip from ProxyLightManager
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
if (jmri.InstanceManager.getDefault(LightManager.class) instanceof jmri.managers.AbstractProxyManager) {
jmri.managers.ProxyLightManager proxy = (jmri.managers.ProxyLightManager) jmri.InstanceManager.getDefault(LightManager.class);
List<Manager<Light>> managerList = proxy.getDisplayOrderManagerList();
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
for (Manager<Light> mgr : managerList) {
if (mgr.getSystemPrefix().equals(systemPrefix)) {
// get tooltip from ProxyLightManager
@@ -841,7 +840,7 @@ protected void prefixChanged() {
break;
}
}
} else if (lightManager.allowMultipleAdditions(ConnectionNameFromSystemName.getPrefixFromName(connectionChoice))) {
} else if (lightManager.allowMultipleAdditions(systemPrefix)) {
addRangeBox.setEnabled(true);
log.debug("L add box enabled2");
// get tooltip from light manager
@@ -1702,6 +1701,19 @@ protected void createControlPressed(ActionEvent e) {
if (typeBox.getSelectedItem().equals(noControl)) {
return;
}
if (typeBox.getSelectedItem().equals(fastClockControl)) {
try {
fastHourSpinner1.commitEdit();
fastHourSpinner2.commitEdit();
fastMinuteSpinner1.commitEdit();
fastMinuteSpinner2.commitEdit();
}
catch (java.text.ParseException pe) {
// unlikely to be thrown as values set to original if incorrect on commitEdit()
log.error("Incorrect value found in a FastClock Time: {}",pe);
return;
}
}
lc = new LightControl();
if (setControlInformation(lc)) {
controlList.add(lc);
@@ -1719,6 +1731,19 @@ protected void createControlPressed(ActionEvent e) {
}

protected void updateControlPressed(ActionEvent e) {
if (typeBox.getSelectedItem().equals(fastClockControl)) {
try {
fastHourSpinner1.commitEdit();
fastHourSpinner2.commitEdit();
fastMinuteSpinner1.commitEdit();
fastMinuteSpinner2.commitEdit();
}
catch (java.text.ParseException pe) {
// unlikely to be thrown as values set to original if incorrect on commitEdit()
log.error("Incorrect value found in a FastClock Time: {}",pe);
return;
}
}
if (setControlInformation(lc)) {
lightControlChanged = true;
lightControlTableModel.fireTableDataChanged();
@@ -2396,10 +2421,8 @@ public boolean isValid() {
/** {@inheritDoc} */
@Override
public boolean shouldYieldFocus(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {

boolean inputOK = verify(input);
if (inputOK) {
if (input instanceof CheckedTextField ) {
if (verify(input)) {
input.setBackground(Color.white);
return true;
} else {
@@ -2416,7 +2439,7 @@ public boolean shouldYieldFocus(javax.swing.JComponent input) {
@Override
public boolean verify(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {
return ((CheckedTextField) input).isValid();
return input.isValid();
} else {
return false;
}
@@ -513,10 +513,10 @@ private void canAddRange(ActionEvent e) {
// Tab All or first time opening, default tooltip
connectionChoice = "TBD";
}
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
if (InstanceManager.getDefault(ReporterManager.class).getClass().getName().contains("ProxyReporterManager")) {
jmri.managers.ProxyReporterManager proxy = (jmri.managers.ProxyReporterManager) InstanceManager.getDefault(ReporterManager.class);
List<Manager<Reporter>> managerList = proxy.getDisplayOrderManagerList();
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
for (Manager<Reporter> mgr : managerList) {
if (mgr.getSystemPrefix().equals(systemPrefix)) {
rangeCheckBox.setEnabled(((ReporterManager) mgr).allowMultipleAdditions(systemPrefix));
@@ -526,7 +526,7 @@ private void canAddRange(ActionEvent e) {
break;
}
}
} else if (reportManager.allowMultipleAdditions(ConnectionNameFromSystemName.getPrefixFromName((String) prefixBox.getSelectedItem()))) {
} else if (reportManager.allowMultipleAdditions(systemPrefix)) {
rangeCheckBox.setEnabled(true);
log.debug("R add box enabled2");
// get tooltip from reporter manager
@@ -642,10 +642,8 @@ public boolean isValid() {
*/
@Override
public boolean shouldYieldFocus(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {

boolean inputOK = verify(input);
if (inputOK) {
if (input instanceof CheckedTextField ) {
if (verify(input)) {
input.setBackground(Color.white);
return true;
} else {
@@ -664,7 +662,7 @@ public boolean shouldYieldFocus(javax.swing.JComponent input) {
@Override
public boolean verify(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {
return ((CheckedTextField) input).isValid();
return input.isValid();
} else {
return false;
}
@@ -345,10 +345,10 @@ private void canAddRange(ActionEvent e) {
// Tab All or first time opening, default tooltip
connectionChoice = "TBD";
}
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
if (InstanceManager.sensorManagerInstance().getClass().getName().contains("ProxySensorManager")) {
jmri.managers.ProxySensorManager proxy = (jmri.managers.ProxySensorManager) InstanceManager.sensorManagerInstance();
List<Manager<Sensor>> managerList = proxy.getDisplayOrderManagerList();
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
for (Manager<Sensor> mgr : managerList) {
if (mgr.getSystemPrefix().equals(systemPrefix)) {
rangeBox.setEnabled(((SensorManager) mgr).allowMultipleAdditions(systemPrefix));
@@ -358,7 +358,7 @@ private void canAddRange(ActionEvent e) {
break;
}
}
} else if (senManager.allowMultipleAdditions(ConnectionNameFromSystemName.getPrefixFromName(connectionChoice))) {
} else if (senManager.allowMultipleAdditions(systemPrefix)) {
rangeBox.setEnabled(true);
log.debug("S add box enabled2");
// get tooltip from sensor manager
@@ -712,10 +712,8 @@ public boolean isValid() {
*/
@Override
public boolean shouldYieldFocus(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {

boolean inputOK = verify(input);
if (inputOK) {
if (input instanceof CheckedTextField ) {
if (verify(input)) {
input.setBackground(Color.white);
return true;
} else {
@@ -1884,10 +1884,10 @@ private void canAddRange(ActionEvent e) {
// Tab All or first time opening, use default tooltip
connectionChoice = "TBD";
}
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
if (InstanceManager.turnoutManagerInstance() instanceof jmri.managers.AbstractProxyManager) {
jmri.managers.ProxyTurnoutManager proxy = (jmri.managers.ProxyTurnoutManager) InstanceManager.turnoutManagerInstance();
List<Manager<Turnout>> managerList = proxy.getDisplayOrderManagerList();
String systemPrefix = ConnectionNameFromSystemName.getPrefixFromName(connectionChoice);
for (Manager<Turnout> turnout : managerList) {
jmri.TurnoutManager mgr = (jmri.TurnoutManager) turnout;
if (mgr.getSystemPrefix().equals(systemPrefix)) {
@@ -1898,7 +1898,7 @@ private void canAddRange(ActionEvent e) {
break;
}
}
} else if (turnManager.allowMultipleAdditions(ConnectionNameFromSystemName.getPrefixFromName(connectionChoice))) {
} else if (turnManager.allowMultipleAdditions(systemPrefix)) {
rangeBox.setEnabled(true);
log.debug("T Add box enabled2");
// get tooltip from turnout manager
@@ -2082,10 +2082,8 @@ public boolean isValid() {

@Override
public boolean shouldYieldFocus(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {

boolean inputOK = verify(input);
if (inputOK) {
if (input instanceof CheckedTextField ) {
if (verify(input)) {
input.setBackground(Color.white);
return true;
} else {
@@ -2101,7 +2099,7 @@ public boolean shouldYieldFocus(javax.swing.JComponent input) {
@Override
public boolean verify(javax.swing.JComponent input) {
if (input.getClass() == CheckedTextField.class) {
return ((CheckedTextField) input).isValid();
return input.isValid();
} else {
return false;
}

0 comments on commit 11c22c4

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