Search in sources :

Example 36 with SuppressFBWarnings

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++;
    }
}
Also used : SerialTrafficController(jmri.jmrix.cmri.serial.SerialTrafficController) CMRISystemConnectionMemo(jmri.jmrix.cmri.CMRISystemConnectionMemo) SerialNode(jmri.jmrix.cmri.serial.SerialNode) Element(org.jdom2.Element) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 37 with SuppressFBWarnings

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();
}
Also used : Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) SerialMessage(jmri.jmrix.cmri.serial.SerialMessage) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 38 with SuppressFBWarnings

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());
            }
        }
    });
}
Also used : FileDrop(jmri.util.iharder.dnd.FileDrop) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) PropertyChangeListener(java.beans.PropertyChangeListener) Listener(jmri.util.iharder.dnd.FileDrop.Listener) File(java.io.File) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 39 with SuppressFBWarnings

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) ArrayList(java.util.ArrayList) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) BorderLayout(java.awt.BorderLayout) JSplitPane(javax.swing.JSplitPane) Vector(java.util.Vector)

Example 40 with SuppressFBWarnings

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;
}
Also used : InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)169 ArrayList (java.util.ArrayList)29 PreparedStatement (java.sql.PreparedStatement)27 File (java.io.File)24 IOException (java.io.IOException)24 SQLException (java.sql.SQLException)22 Connection (java.sql.Connection)21 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)21 JPanel (javax.swing.JPanel)14 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)13 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)13 ResultSet (java.sql.ResultSet)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 FlowLayout (java.awt.FlowLayout)8 BoxLayout (javax.swing.BoxLayout)7 Dimension (java.awt.Dimension)5 FileOutputStream (java.io.FileOutputStream)5 Iterator (java.util.Iterator)5 List (java.util.List)5