1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.conflict.tags;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.BorderLayout;
|
---|
7 | import java.awt.GridBagConstraints;
|
---|
8 | import java.awt.GridBagLayout;
|
---|
9 |
|
---|
10 | import javax.swing.BorderFactory;
|
---|
11 | import javax.swing.JCheckBox;
|
---|
12 | import javax.swing.JLabel;
|
---|
13 | import javax.swing.JPanel;
|
---|
14 | import javax.swing.JScrollPane;
|
---|
15 | import javax.swing.event.ChangeEvent;
|
---|
16 | import javax.swing.event.ChangeListener;
|
---|
17 |
|
---|
18 | import 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 | */
|
---|
26 | public 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 |
|
---|
33 | protected JPanel buildInfoPanel() {
|
---|
34 | JPanel pnl = new JPanel();
|
---|
35 | pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
36 | pnl.setLayout(new GridBagLayout());
|
---|
37 | GridBagConstraints gc = new GridBagConstraints();
|
---|
38 | gc.fill = GridBagConstraints.BOTH;
|
---|
39 | gc.weighty = 1.0;
|
---|
40 | gc.weightx = 1.0;
|
---|
41 | gc.anchor = GridBagConstraints.LINE_START;
|
---|
42 | pnl.add(new JLabel(tr("<html>Please select the values to keep for the following tags.</html>")), gc);
|
---|
43 |
|
---|
44 | gc.gridy = 1;
|
---|
45 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
46 | gc.weighty = 0.0;
|
---|
47 | pnl.add(cbShowTagsWithConflictsOnly = new JCheckBox(tr("Show tags with conflicts only")), gc);
|
---|
48 | cbShowTagsWithConflictsOnly.addChangeListener(
|
---|
49 | new ChangeListener() {
|
---|
50 | public void stateChanged(ChangeEvent e) {
|
---|
51 | model.setShowTagsWithConflictsOnly(cbShowTagsWithConflictsOnly.isSelected());
|
---|
52 | }
|
---|
53 | }
|
---|
54 | );
|
---|
55 | cbShowTagsWithConflictsOnly.setSelected(
|
---|
56 | Main.pref.getBoolean(getClass().getName() + ".showTagsWithConflictsOnly", false)
|
---|
57 | );
|
---|
58 | return pnl;
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Remembers the current settings in the global preferences
|
---|
63 | *
|
---|
64 | */
|
---|
65 | public void rememberPreferences() {
|
---|
66 | Main.pref.put(getClass().getName() + ".showTagsWithConflictsOnly", cbShowTagsWithConflictsOnly.isSelected());
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected void build() {
|
---|
70 | setLayout(new BorderLayout());
|
---|
71 | add(buildInfoPanel(), BorderLayout.NORTH);
|
---|
72 | add(new JScrollPane(new TagConflictResolverTable(model)), BorderLayout.CENTER);
|
---|
73 | }
|
---|
74 |
|
---|
75 | public TagConflictResolver() {
|
---|
76 | this.model = new TagConflictResolverModel();
|
---|
77 | build();
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Replies the model used by this dialog
|
---|
82 | *
|
---|
83 | * @return the model
|
---|
84 | */
|
---|
85 | public TagConflictResolverModel getModel() {
|
---|
86 | return model;
|
---|
87 | }
|
---|
88 | }
|
---|