Changeset 9918 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-03-04T00:25:08+01:00 (8 years ago)
Author:
Don-vip
Message:

fix/add unit tests

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r9134 r9918  
    66
    77import java.awt.Dimension;
     8import java.awt.GraphicsEnvironment;
    89import java.awt.GridBagLayout;
    910import java.awt.event.ActionEvent;
     
    108109            formats.setToolTipText(tr("Select image format for WMS layer"));
    109110
    110             if (1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}) { {
    111                 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
    112                 scrollPane.setPreferredSize(new Dimension(400, 400));
    113                 final JPanel panel = new JPanel(new GridBagLayout());
    114                 panel.add(scrollPane, GBC.eol().fill());
    115                 panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
    116                 setContent(panel);
    117             } }.showDialog().getValue()) {
    118                 return null;
     111            if (!GraphicsEnvironment.isHeadless()) {
     112                if (1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), new String[]{tr("Add layers"), tr("Cancel")}) { {
     113                    final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
     114                    scrollPane.setPreferredSize(new Dimension(400, 400));
     115                    final JPanel panel = new JPanel(new GridBagLayout());
     116                    panel.add(scrollPane, GBC.eol().fill());
     117                    panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
     118                    setContent(panel);
     119                } }.showDialog().getValue()) {
     120                    return null;
     121                }
    119122            }
    120123
     
    141144            return ret;
    142145        } catch (MalformedURLException ex) {
    143             JOptionPane.showMessageDialog(Main.parent, tr("Invalid service URL."),
    144                     tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     146            if (!GraphicsEnvironment.isHeadless()) {
     147                JOptionPane.showMessageDialog(Main.parent, tr("Invalid service URL."),
     148                        tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     149            }
     150            Main.error(ex, false);
    145151        } catch (IOException ex) {
    146             JOptionPane.showMessageDialog(Main.parent, tr("Could not retrieve WMS layer list."),
    147                     tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     152            if (!GraphicsEnvironment.isHeadless()) {
     153                JOptionPane.showMessageDialog(Main.parent, tr("Could not retrieve WMS layer list."),
     154                        tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     155            }
     156            Main.error(ex, false);
    148157        } catch (WMSImagery.WMSGetCapabilitiesException ex) {
    149             JOptionPane.showMessageDialog(Main.parent, tr("Could not parse WMS layer list."),
    150                     tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     158            if (!GraphicsEnvironment.isHeadless()) {
     159                JOptionPane.showMessageDialog(Main.parent, tr("Could not parse WMS layer list."),
     160                        tr("WMS Error"), JOptionPane.ERROR_MESSAGE);
     161            }
    151162            Main.error("Could not parse WMS layer list. Incoming data:\n"+ex.getIncomingData());
    152163        }
  • trunk/src/org/openstreetmap/josm/gui/HelpAwareOptionPane.java

    r9917 r9918  
    245245            doShowOptionDialog(parentComponent, title, options, defaultOption, helpTopic, buttons, pane);
    246246        }
    247         return (Integer) pane.getValue();
     247        return pane.getValue() instanceof Integer ? (Integer) pane.getValue() : JOptionPane.OK_OPTION;
    248248    }
    249249
Note: See TracChangeset for help on using the changeset viewer.