Changeset 5025 in josm for trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
- Timestamp:
- 2012-02-26T16:10:39+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r4701 r5025 13 13 import java.awt.Graphics2D; 14 14 import java.awt.GridBagLayout; 15 import java.awt.Image; 15 16 import java.awt.Point; 16 17 import java.awt.Rectangle; … … 21 22 import java.io.File; 22 23 import java.util.ArrayList; 24 import java.util.Arrays; 23 25 import java.util.Collection; 24 26 import java.util.HashMap; … … 30 32 import javax.swing.Action; 31 33 import javax.swing.Icon; 34 import javax.swing.ImageIcon; 32 35 import javax.swing.JLabel; 33 36 import javax.swing.JOptionPane; … … 37 40 38 41 import org.openstreetmap.josm.Main; 42 import org.openstreetmap.josm.actions.ExpertToggleAction; 39 43 import org.openstreetmap.josm.actions.RenameLayerAction; 44 import org.openstreetmap.josm.actions.ToggleUploadDiscouragedLayerAction; 40 45 import org.openstreetmap.josm.data.Bounds; 41 46 import org.openstreetmap.josm.data.SelectionChangedListener; … … 214 219 } 215 220 221 protected Icon getBaseIcon() { 222 return ImageProvider.get("layer", "osmdata_small"); 223 } 224 216 225 /** 217 226 * TODO: @return Return a dynamic drawn icon of the map data. The icon is … … 219 228 */ 220 229 @Override public Icon getIcon() { 221 return ImageProvider.get("layer", "osmdata_small"); 230 Icon baseIcon = getBaseIcon(); 231 if (isUploadDiscouraged()) { 232 return ImageProvider.overlay(baseIcon, 233 new ImageIcon(ImageProvider.get("warning-small").getImage().getScaledInstance(8, 8, Image.SCALE_SMOOTH)), 234 ImageProvider.OverlayPosition.SOUTHEAST); 235 } else { 236 return baseIcon; 237 } 222 238 } 223 239 … … 395 411 396 412 @Override public boolean isMergable(final Layer other) { 397 return other instanceof OsmDataLayer ;413 return other instanceof OsmDataLayer && (isUploadDiscouraged() == ((OsmDataLayer)other).isUploadDiscouraged()); 398 414 } 399 415 … … 457 473 p.add(new JLabel(wayText, ImageProvider.get("data", "way"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0)); 458 474 p.add(new JLabel(relationText, ImageProvider.get("data", "relation"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0)); 459 p.add(new JLabel(tr("API version: {0}", (data.getVersion() != null) ? data.getVersion() : tr("unset")))); 475 p.add(new JLabel(tr("API version: {0}", (data.getVersion() != null) ? data.getVersion() : tr("unset"))), GBC.eop().insets(15,0,0,0)); 476 if (isUploadDiscouraged()) { 477 p.add(new JLabel(tr("Upload is discouraged")), GBC.eop().insets(15,0,0,0)); 478 } 460 479 461 480 return p; … … 475 494 SeparatorLayerAction.INSTANCE, 476 495 new LayerListPopup.InfoAction(this)}; 477 return new Action[]{ 496 ArrayList<Action> actions = new ArrayList<Action>(); 497 actions.addAll(Arrays.asList(new Action[]{ 478 498 LayerListDialog.getInstance().createActivateLayerAction(this), 479 499 LayerListDialog.getInstance().createShowHideLayerAction(), … … 486 506 new ConvertToGpxLayerAction(), 487 507 SeparatorLayerAction.INSTANCE, 488 new RenameLayerAction(getAssociatedFile(), this), 508 new RenameLayerAction(getAssociatedFile(), this)})); 509 if (ExpertToggleAction.isExpert() && Main.pref.getBoolean("data.layer.upload_discouragement.menu_item", false)) { 510 actions.add(new ToggleUploadDiscouragedLayerAction(this)); 511 } 512 actions.addAll(Arrays.asList(new Action[]{ 489 513 new ConsistencyTestAction(), 490 514 SeparatorLayerAction.INSTANCE, 491 new LayerListPopup.InfoAction(this)}; 515 new LayerListPopup.InfoAction(this)})); 516 return actions.toArray(new Action[0]); 492 517 } 493 518 … … 702 727 */ 703 728 } 729 730 public final boolean isUploadDiscouraged() { 731 return data.isUploadDiscouraged(); 732 } 733 734 public final void setUploadDiscouraged(boolean uploadDiscouraged) { 735 data.setUploadDiscouraged(uploadDiscouraged); 736 } 704 737 }
Note:
See TracChangeset
for help on using the changeset viewer.