// Path: src/main/java/de/konnekting/suite/events/EventDeviceRemoved.java
// public class EventDeviceRemoved {
// 
//     private final DeviceConfigContainer device;
// 
//     public EventDeviceRemoved(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDevice() {
//         return device;
//     }
//     
// }
// 
// 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/events/EventConsoleMessage.java
// public class EventConsoleMessage {
//     private final String message;
// 
//     public EventConsoleMessage(String message) {
//         this.message = message;
//     }
// 
//     public EventConsoleMessage(String message, Throwable ex) {
//         StringWriter sw = new StringWriter();
//         PrintWriter pw = new PrintWriter(sw);
//         ex.printStackTrace(pw);
//         this.message = message +"\n"+sw.toString();
//     }
// 
//     public String getMessage() {
//         return message;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventDeviceAdded.java
// public class EventDeviceAdded {
//     private final DeviceConfigContainer device;
// 
//     public EventDeviceAdded(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventDeviceListRefresh.java
// public class EventDeviceListRefresh {
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventProjectOpened.java
// public class EventProjectOpened {
//     private final File projectFolder;
// 
//     public EventProjectOpened(File projectFolder) {
//         this.projectFolder = projectFolder;
//     }
// 
//     public File getProjectFolder() {
//         return projectFolder;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/StickyDeviceSelected.java
// public class StickyDeviceSelected {
//     private final DeviceConfigContainer device;
// 
//     public StickyDeviceSelected(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public StickyDeviceSelected() {
//         device=null;
//     }
// 
//     /**
//      * Returns the selected device, null if no device is selected
//      * @return 
//      */
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
import de.konnekting.suite.events.EventDeviceRemoved;
import de.konnekting.deviceconfig.DeviceConfigContainer;
import de.konnekting.suite.events.EventAddDevice;
import de.konnekting.suite.events.EventConsoleMessage;
import de.root1.rooteventbus.RootEventBus;
import de.konnekting.suite.events.EventDeviceAdded;
import de.konnekting.suite.events.EventDeviceListRefresh;
import de.konnekting.suite.events.EventProjectOpened;
import de.konnekting.suite.events.StickyDeviceSelected;
import java.io.File;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBException;
/*
 * 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 DeviceList extends javax.swing.JPanel {

  private final java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("de/konnekting/suite/i18n/language"); // NOI18N
  private final Logger log = LoggerFactory.getLogger(getClass());

  private final RootEventBus eventBus = RootEventBus.getDefault();
  private File projectFolder;
  private int oldSelectedIndex = -1;

  /**
   * Creates new form DeviceList
   */
  public DeviceList() {
    initComponents();
    eventBus.register(this);

  }

  private String getLangString(String key, Object... values) {
    String completeKey = getClass().getSimpleName() + "." + key;
    try {
// Path: src/main/java/de/konnekting/suite/events/EventDeviceRemoved.java
// public class EventDeviceRemoved {
// 
//     private final DeviceConfigContainer device;
// 
//     public EventDeviceRemoved(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDevice() {
//         return device;
//     }
//     
// }
// 
// 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/events/EventConsoleMessage.java
// public class EventConsoleMessage {
//     private final String message;
// 
//     public EventConsoleMessage(String message) {
//         this.message = message;
//     }
// 
//     public EventConsoleMessage(String message, Throwable ex) {
//         StringWriter sw = new StringWriter();
//         PrintWriter pw = new PrintWriter(sw);
//         ex.printStackTrace(pw);
//         this.message = message +"\n"+sw.toString();
//     }
// 
//     public String getMessage() {
//         return message;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventDeviceAdded.java
// public class EventDeviceAdded {
//     private final DeviceConfigContainer device;
// 
//     public EventDeviceAdded(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventDeviceListRefresh.java
// public class EventDeviceListRefresh {
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/EventProjectOpened.java
// public class EventProjectOpened {
//     private final File projectFolder;
// 
//     public EventProjectOpened(File projectFolder) {
//         this.projectFolder = projectFolder;
//     }
// 
//     public File getProjectFolder() {
//         return projectFolder;
//     }
//     
// }
// 
// Path: src/main/java/de/konnekting/suite/events/StickyDeviceSelected.java
// public class StickyDeviceSelected {
//     private final DeviceConfigContainer device;
// 
//     public StickyDeviceSelected(DeviceConfigContainer device) {
//         this.device = device;
//     }
// 
//     public StickyDeviceSelected() {
//         device=null;
//     }
// 
//     /**
//      * Returns the selected device, null if no device is selected
//      * @return 
//      */
//     public DeviceConfigContainer getDeviceConfig() {
//         return device;
//     }
//     
// }


// Path: src/main/java/de/konnekting/suite/DeviceList.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
import de.konnekting.suite.events.EventDeviceRemoved;
import de.konnekting.deviceconfig.DeviceConfigContainer;
import de.konnekting.suite.events.EventAddDevice;
import de.konnekting.suite.events.EventConsoleMessage;
import de.root1.rooteventbus.RootEventBus;
import de.konnekting.suite.events.EventDeviceAdded;
import de.konnekting.suite.events.EventDeviceListRefresh;
import de.konnekting.suite.events.EventProjectOpened;
import de.konnekting.suite.events.StickyDeviceSelected;
import java.io.File;
import javax.swing.JOptionPane;
import javax.xml.bind.JAXBException;

/*
 * 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 DeviceList extends javax.swing.JPanel {

  private final java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("de/konnekting/suite/i18n/language"); // NOI18N
  private final Logger log = LoggerFactory.getLogger(getClass());

  private final RootEventBus eventBus = RootEventBus.getDefault();
  private File projectFolder;
  private int oldSelectedIndex = -1;

  /**
   * Creates new form DeviceList
   */
  public DeviceList() {
    initComponents();
    eventBus.register(this);

  }

  private String getLangString(String key, Object... values) {
    String completeKey = getClass().getSimpleName() + "." + key;
    try {
      String s = bundle.getString(completeKey);