source: josm/trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolver.java @ 12841

Last change on this file since 12841 was 12841, checked in by bastiK, 5 weeks ago

see #15229 - fix deprecations caused by [12840]

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.conflict.tags;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.BorderLayout;
7import java.awt.GridBagConstraints;
8import java.awt.GridBagLayout;
9
10import javax.swing.BorderFactory;
11import javax.swing.JCheckBox;
12import javax.swing.JLabel;
13import javax.swing.JPanel;
14import javax.swing.JScrollPane;
15
16import org.openstreetmap.josm.Main;
17
18/**
19 * This is a UI widget for resolving tag conflicts, i.e. differences of the tag values
20 * of multiple {@link org.openstreetmap.josm.data.osm.OsmPrimitive}s.
21 * @since 2008
22 */
23public class TagConflictResolver extends JPanel {
24
25    /** the model for the tag conflict resolver */
26    private final TagConflictResolverModel model;
27    /** selects whether only tags with conflicts are displayed */
28    private final JCheckBox cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only"));
29    private final JCheckBox cbShowTagsWithMultiValuesOnly = new JCheckBox(tr("Show tags with multiple values only"));
30
31    /**
32     * Constructs a new {@code TagConflictResolver}.
33     * @param model tag conflict resolver model
34     * @since 11772
35     */
36    public TagConflictResolver(TagConflictResolverModel model) {
37        this.model = model;
38        build();
39    }
40
41    protected JPanel buildInfoPanel() {
42        JPanel pnl = new JPanel(new GridBagLayout());
43        pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
44        GridBagConstraints gc = new GridBagConstraints();
45        gc.fill = GridBagConstraints.BOTH;
46        gc.weighty = 1.0;
47        gc.weightx = 1.0;
48        gc.anchor = GridBagConstraints.LINE_START;
49        gc.gridwidth = 2;
50        pnl.add(new JLabel(tr("<html>Please select the values to keep for the following tags.</html>")), gc);
51
52        gc.gridwidth = 1;
53        gc.gridy = 1;
54        gc.fill = GridBagConstraints.HORIZONTAL;
55        gc.weighty = 0.0;
56        pnl.add(cbShowTagsWithConflictsOnly, gc);
57        pnl.add(cbShowTagsWithMultiValuesOnly, gc);
58        cbShowTagsWithConflictsOnly.addChangeListener(e -> {
59                model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected());
60                cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected());
61        });
62        cbShowTagsWithConflictsOnly.setSelected(
63                Main.pref.getBoolean(getClass().getName() + ".showTagsWithConflictsOnly", false)
64        );
65        cbShowTagsWithMultiValuesOnly.addChangeListener(
66                e -> model.setShowTagsWithMultiValuesOnly(cbShowTagsWithMultiValuesOnly.isSelected())
67        );
68        cbShowTagsWithMultiValuesOnly.setSelected(
69                Main.pref.getBoolean(getClass().getName() + ".showTagsWithMultiValuesOnly", false)
70        );
71        cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected());
72        return pnl;
73    }
74
75    /**
76     * Remembers the current settings in the global preferences
77     *
78     */
79    public void rememberPreferences() {
80        Main.pref.putBoolean(getClass().getName() + ".showTagsWithConflictsOnly", cbShowTagsWithConflictsOnly.isSelected());
81        Main.pref.putBoolean(getClass().getName() + ".showTagsWithMultiValuesOnly", cbShowTagsWithMultiValuesOnly.isSelected());
82    }
83
84    protected final void build() {
85        setLayout(new BorderLayout());
86        add(buildInfoPanel(), BorderLayout.NORTH);
87        add(new JScrollPane(new TagConflictResolverTable(model)), BorderLayout.CENTER);
88    }
89
90    /**
91     * Replies the model used by this dialog
92     *
93     * @return the model
94     */
95    public TagConflictResolverModel getModel() {
96        return model;
97    }
98}
Note: See TracBrowser for help on using the repository browser.