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

Last change on this file since 2779 was 2779, checked in by mjulius, 14 years ago

fixes #4253 - Combine way conflict dialog - check box for "Show tags with multiple values only"

File size: 3.7 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;
15import javax.swing.event.ChangeEvent;
16import javax.swing.event.ChangeListener;
17
18import org.openstreetmap.josm.Main;
19
20/**
21 * This is a UI widget for resolving tag conflicts, i.e. differences of the tag values
22 * of multiple {@see OsmPrimitive}s.
23 *
24 *
25 */
26public class TagConflictResolver extends JPanel {
27
28 /** the model for the tag conflict resolver */
29 private TagConflictResolverModel model;
30 /** selects wheter only tags with conflicts are displayed */
31 private JCheckBox cbShowTagsWithConflictsOnly;
32 private JCheckBox cbShowTagsWithMultiValuesOnly;
33
34 protected JPanel buildInfoPanel() {
35 JPanel pnl = new JPanel();
36 pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
37 pnl.setLayout(new GridBagLayout());
38 GridBagConstraints gc = new GridBagConstraints();
39 gc.fill = GridBagConstraints.BOTH;
40 gc.weighty = 1.0;
41 gc.weightx = 1.0;
42 gc.anchor = GridBagConstraints.LINE_START;
43 pnl.add(new JLabel(tr("<html>Please select the values to keep for the following tags.</html>")), gc);
44
45 gc.gridy = 1;
46 gc.fill = GridBagConstraints.HORIZONTAL;
47 gc.weighty = 0.0;
48 pnl.add(cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only")), gc);
49 cbShowTagsWithConflictsOnly.addChangeListener(
50 new ChangeListener() {
51 public void stateChanged(ChangeEvent e) {
52 model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected());
53 cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected());
54 }
55 }
56 );
57 cbShowTagsWithConflictsOnly.setSelected(
58 Main.pref.getBoolean(getClass().getName() + ".showTagsWithConflictsOnly", false)
59 );
60 pnl.add(cbShowTagsWithMultiValuesOnly = new JCheckBox(tr("Show tags with multiple values only")), gc);
61 cbShowTagsWithMultiValuesOnly.addChangeListener(
62 new ChangeListener() {
63 public void stateChanged(ChangeEvent e) {
64 model.setShowTagsWithMultiValuesOnly(cbShowTagsWithMultiValuesOnly.isSelected());
65 }
66 }
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.put(getClass().getName() + ".showTagsWithConflictsOnly", cbShowTagsWithConflictsOnly.isSelected());
81 Main.pref.put(getClass().getName() + ".showTagsWithMultiValuesOnly", cbShowTagsWithMultiValuesOnly.isSelected());
82 }
83
84 protected void build() {
85 setLayout(new BorderLayout());
86 add(buildInfoPanel(), BorderLayout.NORTH);
87 add(new JScrollPane(new TagConflictResolverTable(model)), BorderLayout.CENTER);
88 }
89
90 public TagConflictResolver() {
91 this.model = new TagConflictResolverModel();
92 build();
93 }
94
95 /**
96 * Replies the model used by this dialog
97 *
98 * @return the model
99 */
100 public TagConflictResolverModel getModel() {
101 return model;
102 }
103}
Note: See TracBrowser for help on using the repository browser.