Ignore:
Timestamp:
2017-06-13T22:43:27+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm7057 - NPE

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatConfigDialog.java

    r32958 r33394  
    1111import java.awt.Insets;
    1212import java.awt.event.KeyEvent;
     13import java.util.Objects;
    1314
    1415import javax.swing.AbstractButton;
     
    7778
    7879    public GlobalsatConfigDialog(Dg100Config config) {
    79         conf = config;
     80        conf = Objects.requireNonNull(config);
    8081        GridBagConstraints c = new GridBagConstraints();
    8182
  • applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatImportDialog.java

    r32649 r33394  
    2020import javax.swing.ListCellRenderer;
    2121
     22import org.kaintoch.gps.globalsat.dg100.Dg100Config;
    2223import org.openstreetmap.josm.Main;
    2324
     
    9899                @Override
    99100                public void actionPerformed(java.awt.event.ActionEvent e) {
    100                     System.out.println("configureing the device");
     101                    System.out.println("configuring the device");
    101102                    try {
    102 
    103                         GlobalsatConfigDialog dialog = new GlobalsatConfigDialog(GlobalsatPlugin.dg100().getConfig());
    104                         JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    105                         JDialog dlg = pane.createDialog(Main.parent, tr("Configure Device"));
    106                         dlg.setVisible(true);
    107                         if (((Integer) pane.getValue()) == JOptionPane.OK_OPTION) {
    108                             GlobalsatPlugin.dg100().setConfig(dialog.getConfig());
     103                        Dg100Config conf = GlobalsatPlugin.dg100().getConfig();
     104                        if (conf != null) {
     105                            GlobalsatConfigDialog dialog = new GlobalsatConfigDialog(conf);
     106                            JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
     107                            JDialog dlg = pane.createDialog(Main.parent, tr("Configure Device"));
     108                            dlg.setVisible(true);
     109                            if (((Integer) pane.getValue()) == JOptionPane.OK_OPTION) {
     110                                GlobalsatPlugin.dg100().setConfig(dialog.getConfig());
     111                            }
     112                            dlg.dispose();
     113                        } else {
     114                            JOptionPane.showMessageDialog(Main.parent, tr("Connection Error."), tr("Connection Error."), JOptionPane.ERROR);
    109115                        }
    110                         dlg.dispose();
    111 
    112116                    } catch (GlobalsatDg100.ConnectionException ex) {
    113117                        JOptionPane.showMessageDialog(Main.parent, tr("Connection Error.") + " " + ex.toString());
    114118                    }
    115                     System.out.println("configureing the device finised");
     119                    System.out.println("configuring the device finished");
    116120                }
    117121            });
Note: See TracChangeset for help on using the changeset viewer.