source: josm/trunk/src/org/openstreetmap/josm/gui/layer/AbstractModifiableLayer.java@ 11167

Last change on this file since 11167 was 9751, checked in by Don-vip, 8 years ago

see #12462 - Extend Save Layers dialog for more layer types (patch by holgermappt, modified for checkstyle compliance)

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import org.openstreetmap.josm.gui.io.AbstractIOTask;
5import org.openstreetmap.josm.gui.io.AbstractUploadDialog;
6import org.openstreetmap.josm.gui.progress.ProgressMonitor;
7
8/**
9 * A modifiable layer.
10 * @since 7358
11 */
12public abstract class AbstractModifiableLayer extends Layer implements UploadToServer, SaveToFile {
13
14 /**
15 * Constructs a new {@code ModifiableLayer}.
16 * @param name Layer name
17 */
18 public AbstractModifiableLayer(String name) {
19 super(name);
20 }
21
22 /**
23 * Determines if the layer is able to upload data and implements the
24 * {@code UploadToServer} interface.
25 *
26 * @return true if the layer is able to upload data; false, otherwise
27 */
28 @Override
29 public boolean isUploadable() {
30 // Override if needed
31 return false;
32 }
33
34 /**
35 * Determines if the data managed by this layer needs to be uploaded to
36 * the server because it contains modified data.
37 *
38 * @return true if the data managed by this layer needs to be uploaded to
39 * the server because it contains modified data; false, otherwise
40 */
41 @Override
42 public boolean requiresUploadToServer() {
43 // Override if needed
44 return false;
45 }
46
47 /**
48 * Determines if the data managed by this layer needs to be saved to
49 * a file. Only replies true if a file is assigned to this layer and
50 * if the data managed by this layer has been modified since the last
51 * save operation to the file.
52 *
53 * @return true if the data managed by this layer needs to be saved to a file
54 */
55 @Override
56 public boolean requiresSaveToFile() {
57 // Override if needed
58 return false;
59 }
60
61 /**
62 * Determines if upload of data managed by this layer is discouraged.
63 * This feature allows to use "private" data layers.
64 *
65 * @return true if upload is discouraged for this layer; false, otherwise
66 */
67 @Override
68 public boolean isUploadDiscouraged() {
69 // Override if needed
70 return false;
71 }
72
73 /**
74 * Determines if data managed by this layer has been modified.
75 * @return true if data has been modified; false, otherwise
76 */
77 public abstract boolean isModified();
78
79 /**
80 * Initializes the layer after a successful save of data to a file.
81 */
82 @Override
83 public void onPostSaveToFile() {
84 // Override if needed
85 }
86
87 /**
88 * Initializes the layer after a successful upload to the server.
89 */
90 @Override
91 public void onPostUploadToServer() {
92 // Override if needed
93 }
94
95 /**
96 * Creates a new {@code AbstractIOTask} for uploading data.
97 * @param monitor The progress monitor
98 * @return a new {@code AbstractIOTask} for uploading data, or {@code null} if not applicable
99 */
100 @Override
101 public AbstractIOTask createUploadTask(ProgressMonitor monitor) {
102 // Override if needed
103 return null;
104 }
105
106 /**
107 * Returns the upload dialog for this layer.
108 * @return the upload dialog for this layer, or {@code null} if not applicable
109 */
110 @Override
111 public AbstractUploadDialog getUploadDialog() {
112 // Override if needed
113 return null;
114 }
115}
Note: See TracBrowser for help on using the repository browser.