Changeset 13559 in josm for trunk/src/org


Ignore:
Timestamp:
2018-03-25T03:25:55+02:00 (7 years ago)
Author:
Don-vip
Message:

extract DownloadPolicy / UploadPolicy to separate classes

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

Legend:

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

    r13486 r13559  
    1010
    1111import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask;
    12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     12import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1414import org.openstreetmap.josm.gui.MainApplication;
  • trunk/src/org/openstreetmap/josm/actions/UpdateModifiedAction.java

    r13497 r13559  
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.data.osm.DataSet;
    13 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     13import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1414import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1515import org.openstreetmap.josm.io.OnlineResource;
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r13486 r13559  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.data.osm.DataSet;
    18 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     18import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1919import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
  • trunk/src/org/openstreetmap/josm/actions/relation/AbstractRelationAction.java

    r13486 r13559  
    1010import org.openstreetmap.josm.actions.OsmPrimitiveAction;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     12import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1414import org.openstreetmap.josm.data.osm.Relation;
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r13497 r13559  
    107107
    108108    /**
    109      * Download policy.
    110      *
    111      * Determines if download from the OSM server is intended, discouraged, or disabled / blocked.
    112      * @see UploadPolicy
    113      * @since 13453
    114      */
    115     public enum DownloadPolicy {
    116         /**
    117          * Normal dataset, download intended.
    118          */
    119         NORMAL("true"),
    120         /**
    121          * Download blocked.
    122          * Download options completely disabled. Intended for private layers, see #8039.
    123          */
    124         BLOCKED("never");
    125 
    126         final String xmlFlag;
    127 
    128         DownloadPolicy(String xmlFlag) {
    129             this.xmlFlag = xmlFlag;
    130         }
    131 
    132         /**
    133          * Get the corresponding value of the <code>upload='...'</code> XML-attribute
    134          * in the .osm file.
    135          * @return value of the <code>download</code> attribute
    136          */
    137         public String getXmlFlag() {
    138             return xmlFlag;
    139         }
    140 
    141         /**
    142          * Returns the {@code DownloadPolicy} for the given <code>upload='...'</code> XML-attribute
    143          * @param xmlFlag <code>download='...'</code> XML-attribute to convert
    144          * @return {@code DownloadPolicy} value
    145          * @throws IllegalArgumentException for invalid values
    146          */
    147         public static DownloadPolicy of(String xmlFlag) {
    148             for (DownloadPolicy policy : values()) {
    149                 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
    150                     return policy;
    151                 }
    152             }
    153             throw new IllegalArgumentException(xmlFlag);
    154         }
    155     }
    156 
    157     /**
    158      * Upload policy.
    159      *
    160      * Determines if upload to the OSM server is intended, discouraged, or disabled / blocked.
    161      * @see DownloadPolicy
    162      */
    163     public enum UploadPolicy {
    164         /**
    165          * Normal dataset, upload intended.
    166          */
    167         NORMAL("true"),
    168         /**
    169          * Upload discouraged, for example when using or distributing a private dataset.
    170          */
    171         DISCOURAGED("false"),
    172         /**
    173          * Upload blocked.
    174          * Upload options completely disabled. Intended for special cases
    175          * where a warning dialog is not enough, see #12731.
    176          *
    177          * For the user, it shouldn't be too easy to disable this flag.
    178          */
    179         BLOCKED("never");
    180 
    181         final String xmlFlag;
    182 
    183         UploadPolicy(String xmlFlag) {
    184             this.xmlFlag = xmlFlag;
    185         }
    186 
    187         /**
    188          * Get the corresponding value of the <code>upload='...'</code> XML-attribute
    189          * in the .osm file.
    190          * @return value of the <code>upload</code> attribute
    191          */
    192         public String getXmlFlag() {
    193             return xmlFlag;
    194         }
    195 
    196         /**
    197          * Returns the {@code UploadPolicy} for the given <code>upload='...'</code> XML-attribute
    198          * @param xmlFlag <code>upload='...'</code> XML-attribute to convert
    199          * @return {@code UploadPolicy} value
    200          * @throws IllegalArgumentException for invalid values
    201          * @since 13434
    202          */
    203         public static UploadPolicy of(String xmlFlag) {
    204             for (UploadPolicy policy : values()) {
    205                 if (policy.getXmlFlag().equalsIgnoreCase(xmlFlag)) {
    206                     return policy;
    207                 }
    208             }
    209             throw new IllegalArgumentException(xmlFlag);
    210         }
    211     }
    212 
    213     /**
    214109     * Maximum number of events that can be fired between beginUpdate/endUpdate to be send as single events (ie without DatasetChangedEvent)
    215110     */
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowserModel.java

    r13486 r13559  
    88
    99import org.openstreetmap.josm.data.osm.DataSet;
    10 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     10import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1111import org.openstreetmap.josm.data.osm.Relation;
    1212import org.openstreetmap.josm.data.osm.RelationMember;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java

    r13509 r13559  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    12 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     12import org.openstreetmap.josm.data.osm.DownloadPolicy;
    1313import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
    1414import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r13558 r13559  
    6464import org.openstreetmap.josm.data.osm.DataSelectionListener;
    6565import org.openstreetmap.josm.data.osm.DataSet;
    66 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    67 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
     66import org.openstreetmap.josm.data.osm.DownloadPolicy;
     67import org.openstreetmap.josm.data.osm.UploadPolicy;
    6868import org.openstreetmap.josm.data.osm.DataSetMerger;
    6969import org.openstreetmap.josm.data.osm.DatasetConsistencyTest;
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r13453 r13559  
    2828import org.openstreetmap.josm.data.osm.Changeset;
    2929import org.openstreetmap.josm.data.osm.DataSet;
    30 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    31 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
     30import org.openstreetmap.josm.data.osm.DownloadPolicy;
     31import org.openstreetmap.josm.data.osm.UploadPolicy;
    3232import org.openstreetmap.josm.data.osm.Node;
    3333import org.openstreetmap.josm.data.osm.NodeData;
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r13485 r13559  
    1818import org.openstreetmap.josm.data.osm.Changeset;
    1919import org.openstreetmap.josm.data.osm.DataSet;
    20 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    21 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
     20import org.openstreetmap.josm.data.osm.DownloadPolicy;
     21import org.openstreetmap.josm.data.osm.UploadPolicy;
    2222import org.openstreetmap.josm.data.osm.INode;
    2323import org.openstreetmap.josm.data.osm.IPrimitive;
  • trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java

    r13485 r13559  
    2424import org.openstreetmap.josm.data.coor.LatLon;
    2525import org.openstreetmap.josm.data.osm.DataSet;
    26 import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    27 import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
     26import org.openstreetmap.josm.data.osm.DownloadPolicy;
     27import org.openstreetmap.josm.data.osm.UploadPolicy;
    2828import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2929import org.openstreetmap.josm.data.osm.Relation;
Note: See TracChangeset for help on using the changeset viewer.