Changeset 8760 in josm for trunk/src/org


Ignore:
Timestamp:
2015-09-14T22:44:28+02:00 (5 years ago)
Author:
simon04
Message:

fix #11686 - Error by uploading changeset with too long tag

Changeset tags table: limit key/value length to allowed maximum of API

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
5 edited

Legend:

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

    r8510 r8760  
    2626        setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    2727        model = new TagEditorModel();
    28         TagTable tblTags = new TagTable(model);
     28        TagTable tblTags = new TagTable(model, 0);
    2929        tblTags.setEnabled(false);
    3030        add(new JScrollPane(tblTags), BorderLayout.CENTER);
  • trunk/src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java

    r8510 r8760  
    2222
    2323    /** checkbox for selecting whether an atomic upload is to be used  */
    24     private final TagEditorPanel pnlTagEditor = new TagEditorPanel(null);
     24    private final TagEditorPanel pnlTagEditor = new TagEditorPanel(null, null, Changeset.MAX_CHANGESET_TAG_LENGTH);
    2525    /** the model for the changeset comment */
    2626    private final transient ChangesetCommentModel changesetCommentModel;
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagCellEditor.java

    r8510 r8760  
    3030    /**
    3131     * constructor
     32     * @param maxCharacters maximum number of characters allowed, 0 for unlimited
    3233     */
    33     public TagCellEditor() {
     34    public TagCellEditor(final int maxCharacters) {
    3435        editor = new AutoCompletingTextField(0, false);
     36        if (maxCharacters > 0) {
     37            editor.setMaxChars(maxCharacters);
     38        }
    3539        editor.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    3640    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java

    r8510 r8760  
    3636    private TagEditorModel model;
    3737    /** the tag table */
    38     private TagTable tagTable;
     38    private final TagTable tagTable;
    3939
    4040    private PresetListPanel presetListPanel;
     
    4848    protected JPanel buildTagTableEditorPanel() {
    4949        JPanel pnl = new JPanel();
    50         tagTable = new TagTable(model);
    5150        pnl.setLayout(new BorderLayout());
    5251        pnl.add(new JScrollPane(tagTable), BorderLayout.CENTER);
     
    142141     */
    143142    public TagEditorPanel(PresetHandler presetHandler) {
    144         this(null, presetHandler);
     143        this(null, presetHandler, 0);
    145144    }
    146145
     
    150149     *
    151150     * @param model the tag editor model
    152      */
    153     public TagEditorPanel(TagEditorModel model, PresetHandler presetHandler) {
     151     * @param maxCharacters maximum number of characters allowed, 0 for unlimited
     152     */
     153    public TagEditorPanel(TagEditorModel model, PresetHandler presetHandler, final int maxCharacters) {
    154154        this.model = model;
    155155        this.presetHandler = presetHandler;
     
    157157            this.model = new TagEditorModel();
    158158        }
     159        this.tagTable = new TagTable(this.model, maxCharacters);
    159160        build();
    160161    }
  • trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java

    r8540 r8760  
    393393    /**
    394394     * initialize the table
    395      */
    396     protected final void init() {
     395     * @param maxCharacters maximum number of characters allowed for keys and values, 0 for unlimited
     396     */
     397    protected final void init(final int maxCharacters) {
    397398        setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    398399        setRowSelectionAllowed(true);
     
    426427        // create the table cell editor and set it to key and value columns
    427428        //
    428         TagCellEditor tmpEditor = new TagCellEditor();
     429        TagCellEditor tmpEditor = new TagCellEditor(maxCharacters);
    429430        setRowHeight(tmpEditor.getEditor().getPreferredSize().height);
    430431        setTagCellEditor(tmpEditor);
     
    435436     *
    436437     * @param model the tag editor model
    437      */
    438     public TagTable(TagEditorModel model) {
     438     * @param maxCharacters maximum number of characters allowed for keys and values, 0 for unlimited
     439     */
     440    public TagTable(TagEditorModel model, final int maxCharacters) {
    439441        super(model, new TagTableColumnModel(model.getColumnSelectionModel()), model.getRowSelectionModel());
    440442        this.model = model;
    441         init();
     443        init(maxCharacters);
    442444    }
    443445
Note: See TracChangeset for help on using the changeset viewer.