Ignore:
Timestamp:
2012-02-26T16:10:39+01:00 (12 years ago)
Author:
Don-vip
Message:

see #4043 - Have an 'upload prohibited' flag in .osm files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r4701 r5025  
    1313import java.awt.Graphics2D;
    1414import java.awt.GridBagLayout;
     15import java.awt.Image;
    1516import java.awt.Point;
    1617import java.awt.Rectangle;
     
    2122import java.io.File;
    2223import java.util.ArrayList;
     24import java.util.Arrays;
    2325import java.util.Collection;
    2426import java.util.HashMap;
     
    3032import javax.swing.Action;
    3133import javax.swing.Icon;
     34import javax.swing.ImageIcon;
    3235import javax.swing.JLabel;
    3336import javax.swing.JOptionPane;
     
    3740
    3841import org.openstreetmap.josm.Main;
     42import org.openstreetmap.josm.actions.ExpertToggleAction;
    3943import org.openstreetmap.josm.actions.RenameLayerAction;
     44import org.openstreetmap.josm.actions.ToggleUploadDiscouragedLayerAction;
    4045import org.openstreetmap.josm.data.Bounds;
    4146import org.openstreetmap.josm.data.SelectionChangedListener;
     
    214219    }
    215220
     221    protected Icon getBaseIcon() {
     222        return ImageProvider.get("layer", "osmdata_small");
     223    }
     224   
    216225    /**
    217226     * TODO: @return Return a dynamic drawn icon of the map data. The icon is
     
    219228     */
    220229    @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        }
    222238    }
    223239
     
    395411
    396412    @Override public boolean isMergable(final Layer other) {
    397         return other instanceof OsmDataLayer;
     413        return other instanceof OsmDataLayer && (isUploadDiscouraged() == ((OsmDataLayer)other).isUploadDiscouraged());
    398414    }
    399415
     
    457473        p.add(new JLabel(wayText, ImageProvider.get("data", "way"), JLabel.HORIZONTAL), GBC.eop().insets(15,0,0,0));
    458474        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        }
    460479
    461480        return p;
     
    475494                SeparatorLayerAction.INSTANCE,
    476495                new LayerListPopup.InfoAction(this)};
    477         return new Action[]{
     496        ArrayList<Action> actions = new ArrayList<Action>();
     497        actions.addAll(Arrays.asList(new Action[]{
    478498                LayerListDialog.getInstance().createActivateLayerAction(this),
    479499                LayerListDialog.getInstance().createShowHideLayerAction(),
     
    486506                new ConvertToGpxLayerAction(),
    487507                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[]{
    489513                new ConsistencyTestAction(),
    490514                SeparatorLayerAction.INSTANCE,
    491                 new LayerListPopup.InfoAction(this)};
     515                new LayerListPopup.InfoAction(this)}));
     516        return actions.toArray(new Action[0]);
    492517    }
    493518
     
    702727         */
    703728    }
     729
     730    public final boolean isUploadDiscouraged() {
     731        return data.isUploadDiscouraged();
     732    }
     733
     734    public final void setUploadDiscouraged(boolean uploadDiscouraged) {
     735        data.setUploadDiscouraged(uploadDiscouraged);
     736    }
    704737}
Note: See TracChangeset for help on using the changeset viewer.