001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.preferences.imagery; 003 004import static org.openstreetmap.josm.tools.I18n.tr; 005 006import java.awt.Component; 007import java.awt.Dimension; 008 009import org.openstreetmap.josm.gui.ExtendedDialog; 010import org.openstreetmap.josm.gui.preferences.imagery.AddImageryPanel.ContentValidationListener; 011 012/** 013 * Dialog shown to add a new imagery (WMS/TMS) source from imagery preferences. 014 * @since 5731 015 */ 016public class AddImageryDialog extends ExtendedDialog implements ContentValidationListener { 017 018 /** 019 * Constructs a new AddImageryDialog. 020 * @param parent The parent element that will be used for position and maximum size 021 * @param panel The content that will be displayed in the message dialog 022 */ 023 public AddImageryDialog(Component parent, AddImageryPanel panel) { 024 super(parent, tr("Add Imagery URL"), new String[] {tr("OK"), tr("Cancel")}); 025 setButtonIcons(new String[] {"ok", "cancel"}); 026 setCancelButton(2); 027 configureContextsensitiveHelp("/Dialog/AddImagery", true /* show help button */); 028 setContent(panel, false); 029 setMinimumSize(new Dimension(300, 400)); 030 panel.addContentValidationListener(this); 031 } 032 033 @Override 034 public void setupDialog() { 035 super.setupDialog(); 036 contentChanged(false); 037 } 038 039 @Override 040 public void contentChanged(boolean isValid) { 041 buttons.get(0).setEnabled(isValid); 042 } 043}