use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class ConnectionConfigXml method extendElement.
/**
* Write out the SerialNode objects too
*
* @param e Element being extended
*/
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
// though it would be good to fix it if you're working in this area
@Override
protected void extendElement(Element e) {
SerialTrafficController tc = ((CMRISystemConnectionMemo) adapter.getSystemConnectionMemo()).getTrafficController();
SerialNode node = (SerialNode) tc.getNode(0);
int index = 1;
while (node != null) {
// add node as an element
Element n = new Element("node");
n.setAttribute("name", "" + node.getNodeAddress());
e.addContent(n);
// add parameters to the node as needed
n.addContent(makeParameter("nodetype", "" + node.getNodeType()));
n.addContent(makeParameter("bitspercard", "" + node.getNumBitsPerCard()));
n.addContent(makeParameter("transmissiondelay", "" + node.getTransmissionDelay()));
n.addContent(makeParameter("num2lsearchlights", "" + node.getNum2LSearchLights()));
n.addContent(makeParameter("pulsewidth", "" + node.getPulseWidth()));
String value = "";
for (int i = 0; i < node.getLocSearchLightBits().length; i++) {
value = value + Integer.toHexString(node.getLocSearchLightBits()[i] & 0xF);
}
n.addContent(makeParameter("locsearchlightbits", "" + value));
value = "";
for (int i = 0; i < node.getCardTypeLocation().length; i++) {
value = value + Integer.toHexString(node.getCardTypeLocation()[i] & 0xF);
}
n.addContent(makeParameter("cardtypelocation", "" + value));
// look for the next node
node = (SerialNode) tc.getNode(index);
index++;
}
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class DiagnosticFrame method runOutputTest.
/**
* Local Method to run an Output Test
*/
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
protected // though it would be good to fix it if you're working in this area
void runOutputTest() {
// Set up timer to update output pattern periodically
outTimer = new Timer(obsDelay, new ActionListener() {
@Override
public void actionPerformed(ActionEvent evnt) {
if (testRunning && outTest) {
short[] outBitPattern = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
String[] portID = { "A", "B", "C", "D" };
// set new pattern
outBytes[curOutByte] = (byte) outBitPattern[curOutBit];
// send new pattern
SerialMessage m = createOutPacket();
m.setTimeout(50);
_memo.getTrafficController().sendSerialMessage(m, curFrame);
// update status panel to show bit that is on
statusText1.setText("Port " + portID[curOutByte - begOutByte] + " Bit " + Integer.toString(curOutBit) + " is on - Compare LED's with the pattern below");
statusText1.setVisible(true);
StringBuilder st = new StringBuilder();
for (int i = begOutByte; i <= endOutByte; i++) {
st.append(" ");
for (int j = 0; j < 8; j++) {
if ((i == curOutByte) && (j == curOutBit)) {
st.append("X ");
} else {
st.append("O ");
}
}
}
statusText2.setText(new String(st));
statusText2.setVisible(true);
// update bit pattern for next entry
curOutBit++;
if (curOutBit > 7) {
// Move to the next byte
curOutBit = 0;
outBytes[curOutByte] = 0;
curOutByte++;
if (curOutByte > endOutByte) {
// Pattern complete, recycle to first byte
curOutByte = begOutByte;
numIterations++;
}
}
}
}
});
// start timer
outTimer.start();
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class AppsLaunchPane method setJynstrumentSpace.
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only one application at a time")
protected void setJynstrumentSpace() {
_jynstrumentSpace = new JPanel();
_jynstrumentSpace.setLayout(new FlowLayout());
new FileDrop(_jynstrumentSpace, new Listener() {
@Override
public void filesDropped(File[] files) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
});
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class ListedTableFrame method initComponents.
@Override
public void initComponents() {
actionList = new ActionJList(this);
detailpanel = new JPanel();
detailpanel.setLayout(new CardLayout());
tabbedTableArray = new ArrayList<TabbedTableItem>(TabbedTableItemListArrayArray.size());
ArrayList<TabbedTableItemListArray> removeItem = new ArrayList<TabbedTableItemListArray>(5);
for (int x = 0; x < TabbedTableItemListArrayArray.size(); x++) {
/* Here we add all the tables into the panel*/
TabbedTableItemListArray item = TabbedTableItemListArrayArray.get(x);
try {
TabbedTableItem itemModel = new TabbedTableItem(item.getClassAsString(), item.getItemString(), item.getStandardTableModel());
itemBeingAdded = itemModel;
detailpanel.add(itemModel.getPanel(), itemModel.getClassAsString());
tabbedTableArray.add(itemModel);
itemBeingAdded.getAAClass().addToFrame(this);
} catch (Exception ex) {
detailpanel.add(errorPanel(item.getItemString()), item.getClassAsString());
log.error("Error when adding " + item.getClassAsString() + " to display\n" + ex);
ex.printStackTrace();
removeItem.add(item);
}
}
for (TabbedTableItemListArray dead : removeItem) {
TabbedTableItemListArrayArray.remove(dead);
}
list = new JList<String>(new Vector<String>(getChoices()));
listScroller = new JScrollPane(list);
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
list.setLayoutOrientation(JList.VERTICAL);
list.addMouseListener(actionList);
buttonpanel = new JPanel();
buttonpanel.setLayout(new BorderLayout(5, 0));
buttonpanel.setLayout(new BoxLayout(buttonpanel, BoxLayout.Y_AXIS));
buttonpanel.add(listScroller);
buildMenus(tabbedTableArray.get(0));
setTitle(tabbedTableArray.get(0).getItemString());
cardHolder = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, buttonpanel, detailpanel);
cardHolder.setDividerSize(8);
if (lastdivider != 0) {
cardHolder.setDividerLocation(lastdivider);
} else {
// if no specific size has been given we set it to the lists preferred width
cardHolder.setDividerLocation(listScroller.getPreferredSize().width);
}
cardHolder.addPropertyChangeListener(new PropertyChangeListener() {
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "We only intend to use/save the last position of the Split frame")
@Override
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals("dividerLocation")) {
lastdivider = (Integer) e.getNewValue();
}
}
});
cardHolder.setOneTouchExpandable(true);
getContentPane().add(cardHolder);
pack();
actionList.selectListItem(0);
}
use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.
the class InstallDecoderURLAction method copyfile.
@SuppressFBWarnings(value = "OBL_UNSATISFIED_OBLIGATION", justification = "Looks like false positive")
boolean copyfile(URL from, File toFile, JPanel who) {
InputStream in = null;
OutputStream out = null;
try {
in = from.openConnection().getInputStream();
// open for overwrite
out = new FileOutputStream(toFile);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// done - finally cleans up
} catch (FileNotFoundException ex) {
log.debug("" + ex);
JOptionPane.showMessageDialog(who, Bundle.getMessage("CopyError1"));
return false;
} catch (IOException e) {
log.debug("" + e);
JOptionPane.showMessageDialog(who, Bundle.getMessage("CopyError2"));
return false;
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e1) {
log.error("exception closing in stream", e1);
}
try {
if (out != null) {
out.close();
}
} catch (IOException e2) {
log.error("exception closing out stream", e2);
}
}
return true;
}
Aggregations