Ignore:
Timestamp:
2011-08-11T00:52:52+02:00 (13 years ago)
Author:
pieren
Message:

Improve configuration checks to avoid complains like the one reported in JOSM ticket #6632

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r26509 r26510  
    154154    static private boolean menuEnabled = false;
    155155
     156    private static String LAYER_BULDINGS = "CDIF:LS2";
     157    private static String STYLE_BUILDING = "LS2_90";
     158    private static String LAYER_WATER = "CDIF:LS3";
     159    private static String STYLE_WATER = "LS3_90";
     160    private static String LAYER_SYMBOL = "CDIF:LS1";
     161    private static String STYLE_SYMBOL = "LS1_90";
     162    private static String LAYER_PARCELS = "CDIF:PARCELLE";
     163    private static String STYLE_PARCELS = "PARCELLE_90";
     164    private static String LAYER_NUMERO = "CDIF:NUMERO";
     165    private static String STYLE_NUMERO = "NUMERO_90";
     166    private static String LAYER_LABEL = "CDIF:PT3,CDIF:PT2,CDIF:PT1";
     167    private static String STYLE_LABEL = "PT3_90,PT2_90,PT1_90";
     168    private static String LAYER_LIEUDIT = "CDIF:LIEUDIT";
     169    private static String STYLE_LIEUDIT = "LIEUDIT_90";
     170    private static String LAYER_SECTION = "CDIF:SUBSECTION,CDIF:SECTION";
     171    private static String STYLE_SECTION = "SUBSECTION_90,SECTION_90";
     172    private static String LAYER_COMMUNE = "CDIF:COMMUNE";
     173    private static String STYLE_COMMUNE = "COMMUNE_90";
     174   
    156175    /**
    157176     * Creates the plugin and setup the default settings if necessary
     
    276295        grabLayers = "";
    277296        grabStyles = "";
     297        int countLayers = 0;
    278298        if (Main.pref.getBoolean("cadastrewms.layerWater", true)) {
    279             grabLayers += "CDIF:LS3,";
    280             grabStyles += "LS3_90,";
     299            grabLayers += LAYER_WATER + ",";
     300            grabStyles += STYLE_WATER + ",";
     301            countLayers++;
    281302        }
    282303        if (Main.pref.getBoolean("cadastrewms.layerBuilding", true)) {
    283             grabLayers += "CDIF:LS2,";
    284             grabStyles += "LS2_90,";
     304            grabLayers += LAYER_BULDINGS + ",";
     305            grabStyles += STYLE_BUILDING + ",";
     306            countLayers++;
    285307        }
    286308        if (Main.pref.getBoolean("cadastrewms.layerSymbol", true)) {
    287             grabLayers += "CDIF:LS1,";
    288             grabStyles += "LS1_90,";
     309            grabLayers += LAYER_SYMBOL + ",";
     310            grabStyles += STYLE_SYMBOL + ",";
     311            countLayers++;
    289312        }
    290313        if (Main.pref.getBoolean("cadastrewms.layerParcel", true)) {
    291             grabLayers += "CDIF:PARCELLE,";
    292             grabStyles += "PARCELLE_90,";
     314            grabLayers += LAYER_PARCELS + ",";
     315            grabStyles += STYLE_PARCELS + ",";
     316            countLayers++;
    293317        }
    294318        if (Main.pref.getBoolean("cadastrewms.layerNumero", true)) {
    295             grabLayers += "CDIF:NUMERO,";
    296             grabStyles += "NUMERO_90,";
     319            grabLayers += LAYER_NUMERO + ",";
     320            grabStyles += STYLE_NUMERO + ",";
     321            countLayers++;
    297322        }
    298323        if (Main.pref.getBoolean("cadastrewms.layerLabel", true)) {
    299             grabLayers += "CDIF:PT3,CDIF:PT2,CDIF:PT1,";
    300             grabStyles += "PT3_90,PT2_90,PT1_90,";
     324            grabLayers += LAYER_LABEL + ",";
     325            grabStyles += STYLE_LABEL + ",";
     326            countLayers++;
    301327        }
    302328        if (Main.pref.getBoolean("cadastrewms.layerLieudit", true)) {
    303             grabLayers += "CDIF:LIEUDIT,";
    304             grabStyles += "LIEUDIT_90,";
     329            grabLayers += LAYER_LIEUDIT + ",";
     330            grabStyles += STYLE_LIEUDIT + ",";
     331            countLayers++;
    305332        }
    306333        if (Main.pref.getBoolean("cadastrewms.layerSection", true)) {
    307             grabLayers += "CDIF:SUBSECTION,CDIF:SECTION,";
    308             grabStyles += "SUBSECTION_90,SECTION_90,";
     334            grabLayers += LAYER_SECTION + ",";
     335            grabStyles += STYLE_SECTION + ",";
     336            countLayers++;
    309337        }
    310338        if (Main.pref.getBoolean("cadastrewms.layerCommune", true)) {
    311             grabLayers += "CDIF:COMMUNE,";
    312             grabStyles += "COMMUNE_90,";
    313         }
    314         if (grabLayers.length() > 0) { // remove the last ','
     339            grabLayers += LAYER_COMMUNE + ",";
     340            grabStyles += STYLE_COMMUNE + ",";
     341            countLayers++;
     342        }
     343        if (countLayers > 2) { // remove the last ','
    315344            grabLayers = grabLayers.substring(0, grabLayers.length()-1);
    316345            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
     346        } else {
     347            JOptionPane.showMessageDialog(Main.parent,tr("Please enable at least two WMS layers in the cadastre-fr "
     348                    + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default."));
     349            Main.pref.put("cadastrewms.layerBuilding", true);
     350            Main.pref.put("cadastrewms.layerParcel", true);
     351            grabLayers += LAYER_BULDINGS + "," + LAYER_PARCELS;
     352            grabStyles += STYLE_BUILDING + "," + STYLE_PARCELS;
    317353        }
    318354    }
Note: See TracChangeset for help on using the changeset viewer.