Ignore:
Timestamp:
2009-09-20T13:01:42+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3546: Grey out preset buttons in toolbar on startup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r2128 r2170  
    4444import org.openstreetmap.josm.gui.ExtendedDialog;
    4545import org.openstreetmap.josm.gui.QuadStateCheckBox;
     46import org.openstreetmap.josm.gui.layer.Layer;
    4647import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     48import org.openstreetmap.josm.gui.layer.Layer.LayerChangeListener;
    4749import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache;
    4850import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority;
     
    6264 * It is also able to construct dialogs out of preset definitions.
    6365 */
    64 public class TaggingPreset extends AbstractAction {
     66public class TaggingPreset extends AbstractAction implements LayerChangeListener {
    6567
    6668    public TaggingPresetMenu group = null;
     
    480482     * Use this as default item for "do not select anything".
    481483     */
    482     public TaggingPreset() {}
     484    public TaggingPreset() {
     485        Layer.listeners.add(this);
     486        updateEnabledState();
     487    }
    483488
    484489    /**
     
    674679
    675680    public void actionPerformed(ActionEvent e) {
     681        if (Main.main == null) return;
     682        if (Main.main.getCurrentDataSet() == null) return;
    676683        Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected());
    677684        PresetPanel p = createPanel(sel);
     
    771778            return new SequenceCommand(tr("Change Properties"), cmds);
    772779    }
     780
     781    protected void updateEnabledState() {
     782        setEnabled(Main.main != null && Main.main.getCurrentDataSet() != null);
     783    }
     784
     785    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     786        updateEnabledState();
     787    }
     788
     789    public void layerAdded(Layer newLayer) {
     790        updateEnabledState();
     791    }
     792
     793    public void layerRemoved(Layer oldLayer) {
     794        updateEnabledState();
     795    }
    773796}
Note: See TracChangeset for help on using the changeset viewer.