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