1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.changeset;
|
---|
3 |
|
---|
4 | import java.awt.BorderLayout;
|
---|
5 | import java.beans.PropertyChangeEvent;
|
---|
6 | import java.beans.PropertyChangeListener;
|
---|
7 |
|
---|
8 | import javax.swing.BorderFactory;
|
---|
9 | import javax.swing.JPanel;
|
---|
10 | import javax.swing.JScrollPane;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.data.osm.Changeset;
|
---|
13 | import org.openstreetmap.josm.gui.tagging.TagEditorModel;
|
---|
14 | import org.openstreetmap.josm.gui.tagging.TagTable;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * This panel displays the tags of the currently selected changeset in the {@link ChangesetCacheManager}
|
---|
18 | *
|
---|
19 | */
|
---|
20 | public class ChangesetTagsPanel extends JPanel implements PropertyChangeListener{
|
---|
21 |
|
---|
22 | private TagEditorModel model;
|
---|
23 |
|
---|
24 | protected void build() {
|
---|
25 | setLayout(new BorderLayout());
|
---|
26 | setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
---|
27 | model = new TagEditorModel();
|
---|
28 | TagTable tblTags = new TagTable(model, 0);
|
---|
29 | tblTags.setEnabled(false);
|
---|
30 | add(new JScrollPane(tblTags), BorderLayout.CENTER);
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Constructs a new {@code ChangesetTagsPanel}.
|
---|
35 | */
|
---|
36 | public ChangesetTagsPanel() {
|
---|
37 | build();
|
---|
38 | }
|
---|
39 |
|
---|
40 | protected void init(Changeset cs) {
|
---|
41 | if (cs == null) {
|
---|
42 | model.clear();
|
---|
43 | return;
|
---|
44 | }
|
---|
45 | model.initFromTags(cs.getKeys());
|
---|
46 | }
|
---|
47 |
|
---|
48 | /* ---------------------------------------------------------------------------- */
|
---|
49 | /* interface PropertyChangeListener */
|
---|
50 | /* ---------------------------------------------------------------------------- */
|
---|
51 | @Override
|
---|
52 | public void propertyChange(PropertyChangeEvent evt) {
|
---|
53 | if (!evt.getPropertyName().equals(ChangesetCacheManagerModel.CHANGESET_IN_DETAIL_VIEW_PROP))
|
---|
54 | return;
|
---|
55 | Changeset cs = (Changeset) evt.getNewValue();
|
---|
56 | if (cs == null) {
|
---|
57 | model.clear();
|
---|
58 | } else {
|
---|
59 | model.initFromPrimitive(cs);
|
---|
60 | }
|
---|
61 | }
|
---|
62 | }
|
---|