001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.changeset; 003 004import java.awt.BorderLayout; 005import java.beans.PropertyChangeEvent; 006import java.beans.PropertyChangeListener; 007 008import javax.swing.BorderFactory; 009import javax.swing.JPanel; 010import javax.swing.JScrollPane; 011 012import org.openstreetmap.josm.data.osm.Changeset; 013import org.openstreetmap.josm.gui.tagging.TagEditorModel; 014import org.openstreetmap.josm.gui.tagging.TagTable; 015 016/** 017 * This panel displays the tags of the currently selected changeset in the {@link ChangesetCacheManager} 018 * 019 */ 020public class ChangesetTagsPanel extends JPanel implements PropertyChangeListener { 021 022 private TagEditorModel model; 023 024 protected void build() { 025 setLayout(new BorderLayout()); 026 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 027 model = new TagEditorModel(); 028 TagTable tblTags = new TagTable(model, 0); 029 tblTags.setEnabled(false); 030 add(new JScrollPane(tblTags), BorderLayout.CENTER); 031 } 032 033 /** 034 * Constructs a new {@code ChangesetTagsPanel}. 035 */ 036 public ChangesetTagsPanel() { 037 build(); 038 } 039 040 /* ---------------------------------------------------------------------------- */ 041 /* interface PropertyChangeListener */ 042 /* ---------------------------------------------------------------------------- */ 043 @Override 044 public void propertyChange(PropertyChangeEvent evt) { 045 if (!evt.getPropertyName().equals(ChangesetCacheManagerModel.CHANGESET_IN_DETAIL_VIEW_PROP)) 046 return; 047 Changeset cs = (Changeset) evt.getNewValue(); 048 if (cs == null) { 049 model.clear(); 050 } else { 051 model.initFromPrimitive(cs); 052 } 053 } 054}