Ignore:
Timestamp:
2014-07-14T04:18:06+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] fix compilation warnings

Location:
applications/editors/josm/plugins/globalsat/src/org
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/Response.java

    r29854 r30532  
    1212 *
    1313 */
    14 public class Response
     14public class Response<E>
    1515{
    1616    final static public byte typeFileInfo = (byte)0xBB;
     
    2323    private int nextIdx = 0;
    2424    private Dg100Config config = null;
    25     private List data = new ArrayList(100);
     25    private List<E> data = new ArrayList<>(100);
    2626    private long id = 0;
    2727
     
    3535     * @param resp
    3636     */
    37     static public Response parseResponse(byte resp[], int len)
     37    static public Response<?> parseResponse(byte resp[], int len)
    3838    {
    3939        ByteBuffer buf = ByteBuffer.wrap(resp);
    4040        byte respType = buf.get(4);
    41         Response response = new Response(respType);
    4241        buf.position(5);
    4342        if (respType == typeFileInfo) // file info
    4443        {
     44            Response<FileInfoRec> response = new Response<>(respType);
    4545            int cntInfoCur = buf.getShort();
    4646            int nextIdx = buf.getShort();
     
    5252                response.addRec(fileInfoRec);
    5353            }
     54            return response;
    5455        }
    5556        else if (respType == typeGpsRec) // gps recs
    5657        {
     58            Response<GpsRec> response = new Response<>(respType);
    5759            int recType = 2;
    5860            // read part 1
     
    8587                recType = gpsRec.getDg100TypeOfNextRec();
    8688            }
     89            return response;
    8790        }
    8891        else if (respType == typeConfig) // config
    8992        {
     93            Response<?> response = new Response<>(respType);
    9094            Dg100Config config = new Dg100Config(buf);
    9195            response.config = config;
     96            return response;
    9297        }
    9398        else if (respType == typeId) // id
    9499        {
     100            Response<?> response = new Response<>(respType);
    95101            response.id = 0;
    96102            for (int ii = 0 ; ii < 8 ; ++ii)
     
    99105                response.id = response.id * 10 + digit;
    100106            }
     107            return response;
    101108        }
    102109        else
    103110        {
     111            return new Response<>(respType);
    104112        }
    105         return response;
    106113    }
    107114
    108     private void addRec(Object obj)
     115    private void addRec(E obj)
    109116    {
    110117        data.add(obj);
    111118    }
    112119
    113     public List getRecs()
     120    public List<E> getRecs()
    114121    {
    115122        return data;
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatConfigDialog.java

    r29854 r30532  
    55
    66import static org.openstreetmap.josm.tools.I18n.tr;
    7 import gnu.io.CommPortIdentifier;
    87
    98import java.awt.Dimension;
     
    1312import java.awt.event.ActionListener;
    1413import java.awt.event.KeyEvent;
    15 import java.util.LinkedList;
    16 import java.util.List;
    1714
    1815import javax.swing.BoxLayout;
    1916import javax.swing.ButtonGroup;
    2017import javax.swing.JCheckBox;
    21 import javax.swing.JComboBox;
    2218import javax.swing.JLabel;
    2319import javax.swing.JOptionPane;
     
    2824import org.kaintoch.gps.globalsat.dg100.Dg100Config;
    2925import org.openstreetmap.josm.Main;
    30 
    3126
    3227/**
     
    5550    }
    5651
    57 
    58 
    59     // the JOptionPane that contains this dialog. required for the closeDialog() method.
    60     private JOptionPane optionPane;
    61     private JCheckBox delete;
    62     private JComboBox portCombo;
    6352    private JRadioButton formatPosOnly = new JRadioButton(tr("Position only"));
    6453    private JRadioButton formatPosTDS = new JRadioButton(tr("Position, Time, Date, Speed"));
     
    7968    private JTextField cMeters = new IntegerTextField();
    8069
    81     private JLabel memUsage = new JLabel();
    82 
    8370    private JCheckBox disableLogDist, disableLogSpeed;
    8471    private JTextField minLogDist, minLogSpeed;
    8572
    86     private List<CommPortIdentifier> ports = new LinkedList<CommPortIdentifier>();
    87 
    8873    private Dg100Config conf;
    89 
    9074
    9175    public GlobalsatConfigDialog(Dg100Config config) {
     
    326310
    327311    /**
    328      * Has to be called after this dialog has been added to a JOptionPane.
    329      * @param optionPane
    330      */
    331     public void setOptionPane(JOptionPane optionPane) {
    332         this.optionPane = optionPane;
    333     }
    334 
    335     /**
    336312     * Get the selected configuration.
    337313     */
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatDg100.java

    r26509 r30532  
    5050
    5151    /** delete file: A0 A2 00 02 BC 01 00 BD B0 B3 */
    52     private static byte dg100CmdSwitch2Nmea[] =
     52    /*private static byte dg100CmdSwitch2Nmea[] =
    5353    { (byte) 0xA0, (byte) 0xA2, (byte) 0x00, (byte) 0x18, (byte) 0x81,
    5454      (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01,
     
    5858      (byte) 0x00, (byte) 0x25, (byte) 0x80, (byte) 0x00, (byte) 0x00,
    5959      (byte) 0xB0, (byte) 0xB3
    60     };
     60    };*/
    6161    /** delete file: A0 A2 00 02 BC 01 00 BD B0 B3 */
    62     private static byte dg100CmdEnterGMouse[] =
     62    /*private static byte dg100CmdEnterGMouse[] =
    6363    { (byte) 0xA0, (byte) 0xA2, (byte) 0x00, (byte) 0x02, (byte) 0xBC
    6464      , (byte) 0x01, (byte) 0x00, (byte) 0xBD, (byte) 0xB0, (byte) 0xB3
    65     };
     65    };*/
    6666    /** delete file: A0 A2 00 03 BA FF FF 02 B8 B0 B3 */
    6767    private static byte dg100CmdDelFile[] =
     
    104104    };
    105105    /** read config: A0 A2 00 01 BF 00 BF B0 B3 */
    106     private static byte dg100CmdGetId[] =
     106    /*private static byte dg100CmdGetId[] =
    107107    { (byte) 0xA0, (byte) 0xA2, (byte) 0x00, (byte) 0x01, (byte) 0xBF
    108       , (byte) 0x00, (byte) 0xBF, (byte) 0xB0, (byte) 0xB3 };
     108      , (byte) 0x00, (byte) 0xBF, (byte) 0xB0, (byte) 0xB3 };*/
    109109    /** read config: A0 A2 00 01 BF 00 BF B0 B3 */
    110     private static byte dg100CmdSetId[] =
     110    /*private static byte dg100CmdSetId[] =
    111111    { (byte) 0xA0, (byte) 0xA2, (byte) 0x00, (byte) 0x09, (byte) 0xC0
    112112      , (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
    113113      , (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
    114       , (byte) 0x00, (byte) 0xC0, (byte) 0xB0, (byte) 0xB3};
     114      , (byte) 0x00, (byte) 0xC0, (byte) 0xB0, (byte) 0xB3};*/
    115115
    116116    private byte[] response = new byte[65536];
     
    187187        }
    188188        try{
    189             Response response = sendCmdDelFiles();
     189            sendCmdDelFiles();
    190190        }catch(Exception e){
    191191            throw new ConnectionException(e);
     
    220220        try{
    221221            do{
    222                 Response response = sendCmdGetFileInfo(nextIdx);
     222                Response<FileInfoRec> response = sendCmdGetFileInfo(nextIdx);
    223223                nextIdx = response.getNextIdx();
    224224                result.addAll(response.getRecs());
     
    232232    public List<GpsRec> readGpsRecList(List<FileInfoRec> fileInfoList) throws ConnectionException
    233233    {
    234         int cnt = 0;
    235234        List<GpsRec> result = new ArrayList<GpsRec>(200);
    236235
    237236        try{
    238237            for(FileInfoRec fileInfoRec:fileInfoList){
    239                 cnt++;
    240                 Response response = sendCmdGetGpsRecs(fileInfoRec.getIdx());
     238                Response<GpsRec> response = sendCmdGetGpsRecs(fileInfoRec.getIdx());
    241239                result.addAll(response.getRecs());
    242240            }
     
    247245    }
    248246
    249     private Response sendCmdDelFiles() throws IOException, UnsupportedCommOperationException
     247    private Response<?> sendCmdDelFiles() throws IOException, UnsupportedCommOperationException
    250248    {
    251249        System.out.println("deleting data...");
     
    254252    }
    255253
    256     private Response sendCmdGetFileInfo(int idx) throws IOException, UnsupportedCommOperationException
     254    @SuppressWarnings("unchecked")
     255    private Response<FileInfoRec> sendCmdGetFileInfo(int idx) throws IOException, UnsupportedCommOperationException
    257256    {
    258257        byte[] src = dg100CmdGetFileInfo;
     
    262261        updateCheckSum(buf);
    263262        int len = sendCmd(src, response, -1);
    264         return Response.parseResponse(response, len);
    265     }
    266 
    267     private Response sendCmdGetConfig() throws IOException, UnsupportedCommOperationException
     263        return (Response<FileInfoRec>) Response.parseResponse(response, len);
     264    }
     265
     266    private Response<?> sendCmdGetConfig() throws IOException, UnsupportedCommOperationException
    268267    {
    269268        byte[] src = dg100CmdGetConfig;
     
    277276                connect();
    278277            }
    279             Response response = sendCmdGetConfig();
    280             return response.getConfig();
     278            return sendCmdGetConfig().getConfig();
    281279        }catch(Exception e){
    282280            throw new ConnectionException(e);
    283281        }
    284282    }
    285 
    286283
    287284    private void sendCmdSetConfig(Dg100Config config) throws IOException, UnsupportedCommOperationException
     
    310307    }
    311308
    312     private Response sendCmdGetGpsRecs(int idx) throws IOException, UnsupportedCommOperationException
     309    @SuppressWarnings("unchecked")
     310    private Response<GpsRec> sendCmdGetGpsRecs(int idx) throws IOException, UnsupportedCommOperationException
    313311    {
    314312        byte[] src = dg100CmdGetGpsRecs;
     
    318316        updateCheckSum(buf);
    319317        int len = sendCmd(src, response, 2074);
    320         return Response.parseResponse(response, len);
     318        return (Response<GpsRec>) Response.parseResponse(response, len);
    321319    }
    322320
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatImportDialog.java

    r29854 r30532  
    1010import java.awt.event.ActionListener;
    1111import java.util.Enumeration;
    12 import java.util.LinkedList;
    13 import java.util.List;
    1412
    1513import javax.swing.JButton;
     
    3331public class GlobalsatImportDialog extends JPanel {
    3432
    35     // the JOptionPane that contains this dialog. required for the closeDialog() method.
    36     private JOptionPane optionPane;
    3733    private JCheckBox delete;
    38     private JComboBox portCombo;
    39     private List<CommPortIdentifier> ports = new LinkedList<CommPortIdentifier>();
     34    private JComboBox<CommPortIdentifier> portCombo;
    4035
    4136    public GlobalsatImportDialog() {
     
    4540        setLayout(new GridBagLayout());
    4641
    47         portCombo = new JComboBox();
    48         portCombo.setRenderer(new ListCellRenderer(){
    49                 public java.awt.Component getListCellRendererComponent(JList list, Object o, int x, boolean a, boolean b){
    50                     String value = ((CommPortIdentifier)o).getName();
     42        portCombo = new JComboBox<>();
     43        portCombo.setRenderer(new ListCellRenderer<CommPortIdentifier>(){
     44                public java.awt.Component getListCellRendererComponent(JList<? extends CommPortIdentifier> list, CommPortIdentifier o, int x, boolean a, boolean b){
     45                    String value = o.getName();
    5146                    if(value == null){
    5247                        value = "null";
     
    10398                        JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    10499                        JDialog dlg = pane.createDialog(Main.parent, tr("Configure Device"));
    105                         dialog.setOptionPane(pane);
    106100                        dlg.setVisible(true);
    107101                        if(((Integer)pane.getValue()) == JOptionPane.OK_OPTION){
     
    140134        portCombo.removeAllItems();
    141135
    142         Enumeration e = CommPortIdentifier.getPortIdentifiers();
     136        Enumeration<?> e = CommPortIdentifier.getPortIdentifiers();
    143137        for(e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ){
    144138            CommPortIdentifier port = (CommPortIdentifier)e.nextElement();
     
    163157        return (CommPortIdentifier)portCombo.getSelectedItem();
    164158    }
    165     /**
    166      * Has to be called after this dialog has been added to a JOptionPane.
    167      * @param optionPane
    168      */
    169     public void setOptionPane(JOptionPane optionPane) {
    170         this.optionPane = optionPane;
    171     }
    172159}
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatPlugin.java

    r27852 r30532  
    77import java.awt.event.KeyEvent;
    88import java.io.IOException;
    9 import java.util.Enumeration;
    109
    1110import javax.swing.JDialog;
     
    8685    }
    8786
    88 
    8987    GlobalsatImportAction importAction;
    9088    public GlobalsatPlugin(PluginInformation info) {
     
    9290        boolean error = false;
    9391        try{
    94             Enumeration e = CommPortIdentifier.getPortIdentifiers();
     92            CommPortIdentifier.getPortIdentifiers();
    9593        }catch(java.lang.UnsatisfiedLinkError e){
    9694            error = true;
     
    114112            JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    115113            JDialog dlg = pane.createDialog(Main.parent, tr("Import"));
    116             dialog.setOptionPane(pane);
    117114            dlg.setVisible(true);
    118115            if(((Integer)pane.getValue()) == JOptionPane.OK_OPTION){
Note: See TracChangeset for help on using the changeset viewer.