Changeset 9751 in josm
- Timestamp:
- 2016-02-07T17:06:04+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r9276 r9751 1046 1046 } 1047 1047 AbstractModifiableLayer odl = (AbstractModifiableLayer) l; 1048 if ((odl.requiresSaveToFile() || (odl.requiresUploadToServer() && !odl.isUploadDiscouraged())) && odl.isModified()) { 1048 if (odl.isModified() && 1049 ((!odl.isSavable() && !odl.isUploadable()) || 1050 odl.requiresSaveToFile() || 1051 (odl.requiresUploadToServer() && !odl.isUploadDiscouraged()))) { 1049 1052 layersWithUnmodifiedChanges.add(odl); 1050 1053 } -
trunk/src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java
r9078 r9751 57 57 ActionMap am = getActionMap(); 58 58 for (final JCheckBox b : checkBoxes) { 59 add(b, GBC.eol().fill(GBC.HORIZONTAL));60 59 b.setPreferredSize(new Dimension(b.getPreferredSize().width, 19)); 61 60 b.addActionListener(al); … … 68 67 }); 69 68 } 70 71 setToolTipText(tr("<html>"+72 "Select which actions to perform for this layer, if you click the leftmost button.<br/>"+73 "Check \"upload\" to upload the changes to the OSM server.<br/>"+74 "Check \"Save\" to save the layer to the file specified on the left."+75 "</html>"));76 69 } 77 70 … … 91 84 } 92 85 86 private void updatePanel(SaveLayerInfo info) { 87 StringBuilder sb = new StringBuilder(); 88 sb.append("<html>"); 89 sb.append(tr("Select which actions to perform for this layer, if you click the leftmost button.")); 90 removeAll(); 91 if (info != null) { 92 if (info.isUploadable()) { 93 sb.append("<br/>"); 94 sb.append(tr("Check \"Upload\" to upload the changes to the OSM server.")); 95 add(checkBoxes[0], GBC.eol().fill(GBC.HORIZONTAL)); 96 } 97 if (info.isSavable()) { 98 sb.append("<br/>"); 99 sb.append(tr("Check \"Save\" to save the layer to the file specified on the left.")); 100 add(checkBoxes[1], GBC.eol().fill(GBC.HORIZONTAL)); 101 } 102 } 103 sb.append("</html>"); 104 setToolTipText(sb.toString()); 105 } 106 93 107 @Override 94 108 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 109 updatePanel((SaveLayerInfo) value); 95 110 updateCheckboxes(value); 96 111 return this; … … 138 153 @Override 139 154 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { 155 updatePanel((SaveLayerInfo) value); 140 156 updateCheckboxes(value); 141 157 return this; -
trunk/src/org/openstreetmap/josm/gui/io/LayerNameAndFilePathTableCell.java
r9246 r9751 81 81 StringBuilder sb = new StringBuilder(); 82 82 sb.append("<html>") 83 .append(addLblLayerName(info)) 84 .append("<br>"); 85 add(btnFileChooser, GBC.std()); 86 sb.append(addLblFilename(info)) 87 .append("</html>"); 83 .append(addLblLayerName(info)); 84 if (info.isSavable()) { 85 add(btnFileChooser, GBC.std()); 86 sb.append("<br>") 87 .append(addLblFilename(info)); 88 } 89 sb.append("</html>"); 88 90 setToolTipText(sb.toString()); 89 91 return this; … … 99 101 StringBuilder sb = new StringBuilder(); 100 102 sb.append("<html>") 101 .append(addLblLayerName(info)) 102 .append("<br/>"); 103 104 add(btnFileChooser, GBC.std()); 105 add(tfFilename, GBC.eol().fill(GBC.HORIZONTAL).insets(1, 0, 0, 0)); 106 tfFilename.selectAll(); 107 108 sb.append(tfFilename.getToolTipText()) 109 .append("</html>"); 103 .append(addLblLayerName(info)); 104 105 if (info.isSavable()) { 106 add(btnFileChooser, GBC.std()); 107 add(tfFilename, GBC.eol().fill(GBC.HORIZONTAL).insets(1, 0, 0, 0)); 108 tfFilename.selectAll(); 109 110 sb.append("<br>") 111 .append(tfFilename.getToolTipText()); 112 } 113 sb.append("</html>"); 110 114 setToolTipText(sb.toString()); 111 115 return this; -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayerInfo.java
r9078 r9751 47 47 48 48 /** 49 * Replies true if the layer can be saved to a file 50 * 51 * @return {@code true} if the layer can be saved to a file; {@code false} otherwise 52 */ 53 public boolean isSavable() { 54 return layer.isSavable(); 55 } 56 57 /** 58 * Replies true if the layer can be uploaded to a server 59 * 60 * @return {@code true} if the layer can be uploaded to a server; {@code false} otherwise 61 */ 62 public boolean isUploadable() { 63 return layer.isUploadable(); 64 } 65 66 /** 49 67 * Replies true if preconditions should be checked before saving; false, otherwise 50 68 * … … 81 99 */ 82 100 public void setDoSaveToFile(boolean doSaveToFile) { 83 this.doSaveToFile = doSaveToFile;101 this.doSaveToFile = isSavable() ? doSaveToFile : false; 84 102 } 85 103 … … 94 112 95 113 /** 96 * Sets whether this layer should be uploaded to a file114 * Sets whether this layer should be uploaded to a server 97 115 * 98 116 * @param doUploadToServer {@code true} to upload; {@code false}, to skip uploading 99 117 */ 100 101 118 public void setDoUploadToServer(boolean doUploadToServer) { 102 this.doUploadToServer = doUploadToServer;119 this.doUploadToServer = isUploadable() ? doUploadToServer : false; 103 120 } 104 121 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersModel.java
r9556 r9751 103 103 @Override 104 104 public void setValueAt(Object value, int row, int column) { 105 final SaveLayerInfo info = this.layerInfo.get(row); 105 106 switch(column) { 106 107 case columnFilename: 107 this.layerInfo.get(row).setFile((File) value); 108 this.layerInfo.get(row).setDoSaveToFile(true); 108 info.setFile((File) value); 109 if (info.isSavable()) { 110 info.setDoSaveToFile(true); 111 } 109 112 break; 110 113 case columnActions: 111 114 boolean[] values = (boolean[]) value; 112 this.layerInfo.get(row).setDoUploadToServer(values[0]);113 this.layerInfo.get(row).setDoSaveToFile(values[1]);115 info.setDoUploadToServer(values[0]); 116 info.setDoSaveToFile(values[1]); 114 117 break; 115 118 } -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTableColumnModel.java
r8960 r9751 47 47 48 48 } else { 49 panel.add(pnlEmpty, defaultCellStyle); 49 if (info.isUploadable()) { 50 panel.add(pnlEmpty, defaultCellStyle); 51 } 50 52 if (info.getLayer().requiresUploadToServer()) { 51 53 sb.append(tr("Layer ''{0}'' has modifications which are discouraged to be uploaded.", info.getName())); … … 61 63 info.getName(), info.getFile().toString())); 62 64 } else { 63 panel.add(pnlEmpty, defaultCellStyle); 65 if (info.isSavable()) { 66 panel.add(pnlEmpty, defaultCellStyle); 67 } 64 68 sb.append(tr("Layer ''{0}'' has no modifications to be saved.", info.getName())); 65 69 } -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractModifiableLayer.java
r7937 r9751 10 10 * @since 7358 11 11 */ 12 public abstract class AbstractModifiableLayer extends Layer {12 public abstract class AbstractModifiableLayer extends Layer implements UploadToServer, SaveToFile { 13 13 14 14 /** … … 21 21 22 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 /** 23 35 * Determines if the data managed by this layer needs to be uploaded to 24 36 * the server because it contains modified data. … … 27 39 * the server because it contains modified data; false, otherwise 28 40 */ 41 @Override 29 42 public boolean requiresUploadToServer() { 30 43 // Override if needed … … 40 53 * @return true if the data managed by this layer needs to be saved to a file 41 54 */ 55 @Override 42 56 public boolean requiresSaveToFile() { 43 57 // Override if needed … … 51 65 * @return true if upload is discouraged for this layer; false, otherwise 52 66 */ 67 @Override 53 68 public boolean isUploadDiscouraged() { 54 69 // Override if needed … … 65 80 * Initializes the layer after a successful save of data to a file. 66 81 */ 82 @Override 67 83 public void onPostSaveToFile() { 68 84 // Override if needed … … 72 88 * Initializes the layer after a successful upload to the server. 73 89 */ 90 @Override 74 91 public void onPostUploadToServer() { 75 92 // Override if needed … … 81 98 * @return a new {@code AbstractIOTask} for uploading data, or {@code null} if not applicable 82 99 */ 100 @Override 83 101 public AbstractIOTask createUploadTask(ProgressMonitor monitor) { 84 102 // Override if needed … … 90 108 * @return the upload dialog for this layer, or {@code null} if not applicable 91 109 */ 110 @Override 92 111 public AbstractUploadDialog getUploadDialog() { 93 112 // Override if needed -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r8846 r9751 48 48 * @since 7522 49 49 */ 50 public class NoteLayer extends AbstractModifiableLayer implements MouseListener {50 public class NoteLayer extends AbstractModifiableLayer implements MouseListener, UploadToServer, SaveToFile { 51 51 52 52 private final NoteData noteData; … … 83 83 public boolean isModified() { 84 84 return noteData.isModified(); 85 } 86 87 @Override 88 public boolean isUploadable() { 89 return true; 85 90 } 86 91 -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r9721 r9751 109 109 * @since 17 110 110 */ 111 public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener {111 public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener, UploadToServer, SaveToFile { 112 112 /** Property used to know if this layer has to be saved on disk */ 113 113 public static final String REQUIRES_SAVE_TO_DISK_PROP = OsmDataLayer.class.getName() + ".requiresSaveToDisk"; … … 836 836 837 837 @Override 838 public boolean isUploadable() { 839 return true; 840 } 841 842 @Override 838 843 public boolean requiresUploadToServer() { 839 844 return requiresUploadToServer; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r9660 r9751 60 60 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToNextMarker; 61 61 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions.JumpToPreviousMarker; 62 import org.openstreetmap.josm.gui.layer.AbstractModifiableLayer; 62 63 import org.openstreetmap.josm.gui.layer.Layer; 63 64 import org.openstreetmap.josm.gui.util.GuiHelper; … … 69 70 * Layer displaying geottaged pictures. 70 71 */ 71 public class GeoImageLayer extends Layer implements PropertyChangeListener, JumpToMarkerLayer {72 public class GeoImageLayer extends AbstractModifiableLayer implements PropertyChangeListener, JumpToMarkerLayer { 72 73 73 74 private static List<Action> menuAdditions = new LinkedList<>(); … … 369 370 public String getToolTipText() { 370 371 return infoText(); 372 } 373 374 /** 375 * Determines if data managed by this layer has been modified. That is 376 * the case if one image has modified GPS data. 377 * @return {@code true} if data has been modified; {@code false}, otherwise 378 */ 379 @Override 380 public boolean isModified() { 381 if (data != null) { 382 for (ImageEntry e : data) { 383 if (e.hasNewGpsData()) { 384 return true; 385 } 386 } 387 } 388 return false; 371 389 } 372 390
Note:
See TracChangeset
for help on using the changeset viewer.