Changeset 8789 in josm for trunk/src/org
- Timestamp:
- 2015-09-23T20:44:12+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r8764 r8789 805 805 * The action to merge the currently selected layer into another layer. 806 806 */ 807 public final class MergeAction extends AbstractAction implements IEnabledStateUpdating {807 public final class MergeAction extends AbstractAction implements IEnabledStateUpdating, LayerAction, Layer.MultiLayerAction { 808 808 private transient Layer layer; 809 private transient List<Layer> layers; 809 810 810 811 /** … … 814 815 */ 815 816 public MergeAction(Layer layer) { 816 this( );817 this(layer, null); 817 818 CheckParameterUtil.ensureParameterNotNull(layer, "layer"); 819 } 820 821 /** 822 * Constructs a new {@code MergeAction}. 823 * @param layers the layer list 824 * @throws IllegalArgumentException if {@code layers} is null 825 */ 826 public MergeAction(List<Layer> layers) { 827 this(null, layers); 828 CheckParameterUtil.ensureParameterNotNull(layers, "layers"); 829 } 830 831 /** 832 * Constructs a new {@code MergeAction}. 833 */ 834 private MergeAction(Layer layer, List<Layer> layers) { 818 835 this.layer = layer; 819 putValue(NAME, tr("Merge")); 820 updateEnabledState(); 821 } 822 823 /** 824 * Constructs a new {@code MergeAction}. 825 */ 826 public MergeAction() { 836 this.layers = layers; 827 837 putValue(NAME, tr("Merge")); 828 838 putValue(SMALL_ICON, ImageProvider.get("dialogs", "mergedown")); … … 836 846 if (layer != null) { 837 847 Main.main.menu.merge.merge(layer); 848 } else if (layers != null) { 849 Main.main.menu.merge.merge(layers); 838 850 } else { 839 851 if (getModel().getSelectedLayers().size() == 1) { … … 846 858 } 847 859 848 protected boolean isActiveLayer(Layer layer) {849 if (!Main.isDisplayingMapView()) return false;850 return Main.map.mapView.getActiveLayer() == layer;851 }852 853 860 @Override 854 861 public void updateEnabledState() { 855 if (layer == null ) {862 if (layer == null && layers == null) { 856 863 if (getModel().getSelectedLayers().isEmpty()) { 857 864 setEnabled(false); … … 870 877 setEnabled(!targets.isEmpty()); 871 878 } 872 } else {879 } else if (layer != null) { 873 880 List<Layer> targets = getModel().getPossibleMergeTargets(layer); 874 881 setEnabled(!targets.isEmpty()); 875 } 882 } else { 883 setEnabled(supportLayers(layers)); 884 } 885 } 886 887 @Override 888 public boolean supportLayers(List<Layer> layers) { 889 for (Layer l : layers) { 890 if (!(l instanceof OsmDataLayer)) { 891 return false; 892 } 893 } 894 return true; 895 } 896 897 @Override 898 public Component createMenuComponent() { 899 return new JMenuItem(this); 900 } 901 902 @Override 903 public MergeAction getMultiLayerAction(List<Layer> layers) { 904 return new MergeAction(layers); 876 905 } 877 906 }
Note:
See TracChangeset
for help on using the changeset viewer.