Changeset 1474 in josm for trunk


Ignore:
Timestamp:
2009-03-08T18:06:32+01:00 (16 years ago)
Author:
stoecker
Message:

fixed #2219 - default presets checkboxes no longer ignored

File:
1 edited

Legend:

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

    r1427 r1474  
    190190        private QuadStateCheckBox check;
    191191        private QuadStateCheckBox.State initialState;
     192        private boolean def;
    192193
    193194        @Override public void addToPanel(JPanel p, Collection<OsmPrimitive> sel) {
     
    195196            // find out if our key is already used in the selection.
    196197            Usage usage = determineBooleanUsage(sel, key);
     198            def = default_;
    197199
    198200            if(locale_text == null)
     
    202204            for (String s : usage.values) oneValue = s;
    203205            if (usage.values.size() < 2 && (oneValue == null || OsmUtils.trueval.equals(oneValue) || OsmUtils.falseval.equals(oneValue))) {
    204                 if(default_)
     206                if(def)
    205207                {
    206208                    for (OsmPrimitive s : sel)
    207                         if(s.keys != null && s.keys.size() > 0) default_ = false;
     209                        if(s.keys != null && s.keys.size() > 0) def = false;
    208210                }
    209211
     
    214216                            OsmUtils.falseval.equals(oneValue) ?
    215217                            QuadStateCheckBox.State.NOT_SELECTED :
    216                             default_ ? QuadStateCheckBox.State.SELECTED
     218                            def ? QuadStateCheckBox.State.SELECTED
    217219                            : QuadStateCheckBox.State.UNSET;
    218220                check = new QuadStateCheckBox(locale_text, initialState,
     
    222224                        QuadStateCheckBox.State.UNSET });
    223225            } else {
     226                def = false;
    224227                // the objects have different values, or one or more objects have something
    225228                // else than true/false. we display a quad-state check box
     
    238241        @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    239242            // if the user hasn't changed anything, don't create a command.
    240             if (check.getState() == initialState) return;
     243            if (check.getState() == initialState && !def) return;
    241244
    242245            // otherwise change things according to the selected value.
     
    590593        if (p == null)
    591594            return;
    592              
     595
    593596        int answer = 1;
    594597        if (p.getComponentCount() != 0) {
     
    600603                    title = tr("Selection unsuitable!");
    601604            }
    602            
     605
    603606            class PresetDialog extends ExtendedDialog {
    604607                public PresetDialog(Component content, String title, boolean disableApply) {
     
    614617                }
    615618            }
    616            
     619
    617620            answer = new PresetDialog(p, title, (sel.size() == 0)).getValue();
    618621        }
     
    624627        Main.ds.setSelected(Main.ds.getSelected()); // force update
    625628    }
    626    
     629
    627630    /**
    628631     * True whenever the original selection given into createSelection was empty
    629632     */
    630633    private boolean originalSelectionEmpty = false;
    631    
     634
    632635    /**
    633636     * Removes all unsuitable OsmPrimitives from the given list
Note: See TracChangeset for help on using the changeset viewer.