Changeset 17371 in josm for trunk


Ignore:
Timestamp:
2020-11-28T10:15:15+01:00 (3 months ago)
Author:
GerdP
Message:

fix #18533: changeset manager: tags tab: width of column (almost) not changeable

  • use ReadOnlyTableModel as in PropertiesDialog to allow resizing of column width
  • don't allow reordering of column headers in Changeset dialogs (because content doesn't match header if allowed)
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManager.java

    r17333 r17371  
    280280        tblChangesets.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "removeFromCache");
    281281        tblChangesets.getActionMap().put("removeFromCache", actRemoveFromCacheAction);
     282        tblChangesets.getTableHeader().setReorderingAllowed(false);
    282283
    283284        tblChangesets.setTransferHandler(new TransferHandler() {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r16826 r17371  
    126126        tblContent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(historyAction.getShortcut().getKeyStroke(), "historyAction");
    127127        tblContent.getActionMap().put("historyAction", historyAction);
     128        tblContent.getTableHeader().setReorderingAllowed(false);
    128129        pnl.add(new JScrollPane(tblContent), BorderLayout.CENTER);
    129130        return pnl;
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionPanel.java

    r17370 r17371  
    118118        table = new JTable(model, new ChangesetDiscussionTableColumnModel());
    119119        table.setRowSorter(new ChangesetDiscussionTableRowSorter(model));
     120        table.getTableHeader().setReorderingAllowed(false);
    120121
    121122        table.getColumnModel().getColumn(2).addPropertyChangeListener(evt -> {
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetTagsPanel.java

    r9059 r17371  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.dialogs.changeset;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
    35
    46import java.awt.BorderLayout;
    57import java.beans.PropertyChangeEvent;
    68import java.beans.PropertyChangeListener;
     9import java.util.Map;
    710
    811import javax.swing.BorderFactory;
    912import javax.swing.JPanel;
    1013import javax.swing.JScrollPane;
     14import javax.swing.JTable;
    1115
    1216import org.openstreetmap.josm.data.osm.Changeset;
    13 import org.openstreetmap.josm.gui.tagging.TagEditorModel;
    14 import org.openstreetmap.josm.gui.tagging.TagTable;
     17import org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog.ReadOnlyTableModel;
    1518
    1619/**
     
    2023public class ChangesetTagsPanel extends JPanel implements PropertyChangeListener {
    2124
    22     private TagEditorModel model;
     25    private ReadOnlyTableModel model;
    2326
    2427    protected void build() {
    2528        setLayout(new BorderLayout());
    2629        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    27         model = new TagEditorModel();
    28         TagTable tblTags = new TagTable(model, 0);
    29         tblTags.setEnabled(false);
     30        model = new ReadOnlyTableModel();
     31        model.setColumnIdentifiers(new String[]{tr("Key"), tr("Value")});
     32        JTable tblTags = new JTable(model);
     33        tblTags.setAutoCreateRowSorter(true);
     34        tblTags.getTableHeader().setReorderingAllowed(false);
    3035        add(new JScrollPane(tblTags), BorderLayout.CENTER);
    3136    }
     
    4550        if (!evt.getPropertyName().equals(ChangesetCacheManagerModel.CHANGESET_IN_DETAIL_VIEW_PROP))
    4651            return;
     52        model.setRowCount(0);
    4753        Changeset cs = (Changeset) evt.getNewValue();
    48         if (cs == null) {
    49             model.clear();
    50         } else {
    51             model.initFromPrimitive(cs);
     54        if (cs != null) {
     55            for (Map.Entry<String, String> tag : cs.getKeys().entrySet()) {
     56                model.addRow(new String[] {tag.getKey(), tag.getValue()});
     57            }
    5258        }
    5359    }
Note: See TracChangeset for help on using the changeset viewer.