001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.dialogs.relation.actions; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.awt.event.ActionEvent; 007 008import org.openstreetmap.josm.spi.preferences.Config; 009import org.openstreetmap.josm.tools.ImageProvider; 010import org.openstreetmap.josm.tools.Utils; 011 012/** 013 * Apply the updates and close the dialog. 014 */ 015public class OKAction extends SavingAction { 016 private static final long serialVersionUID = 1L; 017 018 /** 019 * Constructs a new {@code OKAction}. 020 * @param editorAccess An interface to access the relation editor contents. 021 */ 022 public OKAction(IRelationEditorActionAccess editorAccess) { 023 super(editorAccess); 024 putValue(SHORT_DESCRIPTION, tr("Apply the updates and close the dialog")); 025 new ImageProvider("ok").getResource().attachImageIcon(this); 026 putValue(NAME, tr("OK")); 027 setEnabled(true); 028 } 029 030 @Override 031 public void actionPerformed(ActionEvent e) { 032 Config.getPref().put("relation.editor.generic.lastrole", Utils.strip(tfRole.getText())); 033 editorAccess.getMemberTable().stopHighlighting(); 034 if (!applyChanges()) 035 return; 036 hideEditor(); 037 } 038}