Changeset 11101 in josm for trunk


Ignore:
Timestamp:
2016-10-08T03:22:40+02:00 (8 years ago)
Author:
Don-vip
Message:

add more unit tests

Location:
trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r10984 r11101  
    1919        <classpathentry kind="lib" path="test/lib/reflections/guava-19.0.jar"/>
    2020        <classpathentry kind="lib" path="test/lib/reflections/javassist-3.20.0-GA.jar"/>
     21        <classpathentry kind="lib" path="test/lib/system-rules-1.16.0.jar"/>
    2122        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_102"/>
    2223        <classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r11093 r11101  
    102102     */
    103103    public static boolean saveUnsavedModifications(Iterable<? extends Layer> selectedLayers, Reason reason) {
    104         SaveLayersDialog dialog = new SaveLayersDialog(Main.parent);
    105         List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
    106         for (Layer l: selectedLayers) {
    107             if (!(l instanceof AbstractModifiableLayer)) {
    108                 continue;
    109             }
    110             AbstractModifiableLayer odl = (AbstractModifiableLayer) l;
    111             if (odl.isModified() &&
    112                     ((!odl.isSavable() && !odl.isUploadable()) ||
    113                             odl.requiresSaveToFile() ||
    114                             (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
    115                 layersWithUnmodifiedChanges.add(odl);
    116             }
    117         }
    118         dialog.prepareForSavingAndUpdatingLayers(reason);
    119         if (!layersWithUnmodifiedChanges.isEmpty()) {
    120             dialog.getModel().populate(layersWithUnmodifiedChanges);
    121             dialog.setVisible(true);
    122             switch(dialog.getUserAction()) {
    123                 case PROCEED: return true;
    124                 case CANCEL:
    125                 default: return false;
     104        if (!GraphicsEnvironment.isHeadless()) {
     105            SaveLayersDialog dialog = new SaveLayersDialog(Main.parent);
     106            List<AbstractModifiableLayer> layersWithUnmodifiedChanges = new ArrayList<>();
     107            for (Layer l: selectedLayers) {
     108                if (!(l instanceof AbstractModifiableLayer)) {
     109                    continue;
     110                }
     111                AbstractModifiableLayer odl = (AbstractModifiableLayer) l;
     112                if (odl.isModified() &&
     113                        ((!odl.isSavable() && !odl.isUploadable()) ||
     114                                odl.requiresSaveToFile() ||
     115                                (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) {
     116                    layersWithUnmodifiedChanges.add(odl);
     117                }
     118            }
     119            dialog.prepareForSavingAndUpdatingLayers(reason);
     120            if (!layersWithUnmodifiedChanges.isEmpty()) {
     121                dialog.getModel().populate(layersWithUnmodifiedChanges);
     122                dialog.setVisible(true);
     123                switch(dialog.getUserAction()) {
     124                    case PROCEED: return true;
     125                    case CANCEL:
     126                    default: return false;
     127                }
    126128            }
    127129        }
Note: See TracChangeset for help on using the changeset viewer.