// Path: src/main/java/de/konnekting/suite/events/EventAddDevice.java
// public class EventAddDevice {
//     
//     private final DeviceConfigContainer device;
// 
//     public EventAddDevice(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }


import de.konnekting.deviceconfig.DeviceConfigContainer;
import de.konnekting.deviceconfig.exception.InvalidAddressFormatException;
import de.konnekting.suite.events.EventAddDevice;
import de.root1.rooteventbus.RootEventBus;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import javax.xml.bind.JAXBException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
/*
 * Copyright (C) 2016 Alexander Christian <alex(at)root1.de>. All rights reserved.
 * 
 * This file is part of KONNEKTING Suite.
 *
 *   KONNEKTING Suite is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   KONNEKTING Suite is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with KONNEKTING DeviceConfig.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.konnekting.suite;


/**
 *
 * @author achristian
 */
public class SaveDeviceAsDialog extends javax.swing.JDialog {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private DeviceConfigContainer device;
    private File configFile;

    private static final String CONFIG_EXTENSION = ".kconfig.xml";

    /**
     * Creates new form SaveDeviceAsDialog
     *
     * @param parent
     * @param projectDir
     * @param konnekt
     */
    private SaveDeviceAsDialog(java.awt.Frame parent, File projectDir, DeviceConfigContainer device) {
        super(parent, false);
        super.setModal(true);
        super.setLocationRelativeTo(parent);
        initComponents();

        try {
            this.device = device.makeConfigFile(projectDir);

            deviceInformationPanel.setDeviceConfig(this.device);

            if (device.hasConfiguration()) {
                deviceDescriptionTextField.setText("KOPIE VON " + device.getDescription());
// Path: src/main/java/de/konnekting/suite/events/EventAddDevice.java
// public class EventAddDevice {
//     
//     private final DeviceConfigContainer device;
// 
//     public EventAddDevice(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }


// Path: src/main/java/de/konnekting/suite/SaveDeviceAsDialog.java
import de.konnekting.deviceconfig.DeviceConfigContainer;
import de.konnekting.deviceconfig.exception.InvalidAddressFormatException;
import de.konnekting.suite.events.EventAddDevice;
import de.root1.rooteventbus.RootEventBus;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import javax.xml.bind.JAXBException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

/*
 * Copyright (C) 2016 Alexander Christian <alex(at)root1.de>. All rights reserved.
 * 
 * This file is part of KONNEKTING Suite.
 *
 *   KONNEKTING Suite is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   KONNEKTING Suite is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with KONNEKTING DeviceConfig.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.konnekting.suite;


/**
 *
 * @author achristian
 */
public class SaveDeviceAsDialog extends javax.swing.JDialog {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private DeviceConfigContainer device;
    private File configFile;

    private static final String CONFIG_EXTENSION = ".kconfig.xml";

    /**
     * Creates new form SaveDeviceAsDialog
     *
     * @param parent
     * @param projectDir
     * @param konnekt
     */
    private SaveDeviceAsDialog(java.awt.Frame parent, File projectDir, DeviceConfigContainer device) {
        super(parent, false);
        super.setModal(true);
        super.setLocationRelativeTo(parent);
        initComponents();

        try {
            this.device = device.makeConfigFile(projectDir);

            deviceInformationPanel.setDeviceConfig(this.device);

            if (device.hasConfiguration()) {
                deviceDescriptionTextField.setText("KOPIE VON " + device.getDescription());
            } else {