001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.layer; 003 004import org.openstreetmap.josm.gui.io.AbstractIOTask; 005import org.openstreetmap.josm.gui.io.AbstractUploadDialog; 006import org.openstreetmap.josm.gui.progress.ProgressMonitor; 007 008/** 009 * A modifiable layer. 010 * @since 7358 011 */ 012public abstract class AbstractModifiableLayer extends Layer { 013 014 /** 015 * Constructs a new {@code ModifiableLayer}. 016 * @param name Layer name 017 */ 018 public AbstractModifiableLayer(String name) { 019 super(name); 020 } 021 022 /** 023 * Determines if the data managed by this layer needs to be uploaded to 024 * the server because it contains modified data. 025 * 026 * @return true if the data managed by this layer needs to be uploaded to 027 * the server because it contains modified data; false, otherwise 028 */ 029 public boolean requiresUploadToServer() { 030 // Override if needed 031 return false; 032 } 033 034 /** 035 * Determines if the data managed by this layer needs to be saved to 036 * a file. Only replies true if a file is assigned to this layer and 037 * if the data managed by this layer has been modified since the last 038 * save operation to the file. 039 * 040 * @return true if the data managed by this layer needs to be saved to a file 041 */ 042 public boolean requiresSaveToFile() { 043 // Override if needed 044 return false; 045 } 046 047 /** 048 * Determines if upload of data managed by this layer is discouraged. 049 * This feature allows to use "private" data layers. 050 * 051 * @return true if upload is discouraged for this layer; false, otherwise 052 */ 053 public boolean isUploadDiscouraged() { 054 // Override if needed 055 return false; 056 } 057 058 /** 059 * Determines if data managed by this layer has been modified. 060 * @return true if data has been modified; false, otherwise 061 */ 062 public abstract boolean isModified(); 063 064 /** 065 * Initializes the layer after a successful save of data to a file. 066 */ 067 public void onPostSaveToFile() { 068 // Override if needed 069 } 070 071 /** 072 * Initializes the layer after a successful upload to the server. 073 */ 074 public void onPostUploadToServer() { 075 // Override if needed 076 } 077 078 /** 079 * Creates a new {@code AbstractIOTask} for uploading data. 080 * @param monitor The progress monitor 081 * @return a new {@code AbstractIOTask} for uploading data, or {@code null} if not applicable 082 */ 083 public AbstractIOTask createUploadTask(ProgressMonitor monitor) { 084 // Override if needed 085 return null; 086 } 087 088 /** 089 * Returns the upload dialog for this layer. 090 * @return the upload dialog for this layer, or {@code null} if not applicable 091 */ 092 public AbstractUploadDialog getUploadDialog() { 093 // Override if needed 094 return null; 095 } 096}