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

Last change on this file since 5832 was 5832, checked in by stoecker, 11 years ago

i18n update and javadoc fixes

  • Property svn:eol-style set to native
File size: 3.8 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 {@link org.openstreetmap.josm.data.osm.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 whether 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 gc.gridwidth = 2;
44 pnl.add(new JLabel(tr("<html>Please select the values to keep for the following tags.</html>")), gc);
45
46 gc.gridwidth = 1;
47 gc.gridy = 1;
48 gc.fill = GridBagConstraints.HORIZONTAL;
49 gc.weighty = 0.0;
50 pnl.add(cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only")), gc);
51 pnl.add(cbShowTagsWithMultiValuesOnly = new JCheckBox(tr("Show tags with multiple values only")), gc);
52 cbShowTagsWithConflictsOnly.addChangeListener(
53 new ChangeListener() {
54 public void stateChanged(ChangeEvent e) {
55 model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected());
56 cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected());
57 }
58 }
59 );
60 cbShowTagsWithConflictsOnly.setSelected(
61 Main.pref.getBoolean(getClass().getName() + ".showTagsWithConflictsOnly", false)
62 );
63 cbShowTagsWithMultiValuesOnly.addChangeListener(
64 new ChangeListener() {
65 public void stateChanged(ChangeEvent e) {
66 model.setShowTagsWithMultiValuesOnly(cbShowTagsWithMultiValuesOnly.isSelected());
67 }
68 }
69 );
70 cbShowTagsWithMultiValuesOnly.setSelected(
71 Main.pref.getBoolean(getClass().getName() + ".showTagsWithMultiValuesOnly", false)
72 );
73 cbShowTagsWithMultiValuesOnly.setEnabled(cbShowTagsWithConflictsOnly.isSelected());
74 return pnl;
75 }
76
77 /**
78 * Remembers the current settings in the global preferences
79 *
80 */
81 public void rememberPreferences() {
82 Main.pref.put(getClass().getName() + ".showTagsWithConflictsOnly", cbShowTagsWithConflictsOnly.isSelected());
83 Main.pref.put(getClass().getName() + ".showTagsWithMultiValuesOnly", cbShowTagsWithMultiValuesOnly.isSelected());
84 }
85
86 protected void build() {
87 setLayout(new BorderLayout());
88 add(buildInfoPanel(), BorderLayout.NORTH);
89 add(new JScrollPane(new TagConflictResolverTable(model)), BorderLayout.CENTER);
90 }
91
92 public TagConflictResolver() {
93 this.model = new TagConflictResolverModel();
94 build();
95 }
96
97 /**
98 * Replies the model used by this dialog
99 *
100 * @return the model
101 */
102 public TagConflictResolverModel getModel() {
103 return model;
104 }
105}
Note: See TracBrowser for help on using the repository browser.