Пример #1
0
  /**
   * Methode : fillOutTheChoiceList() allows you to fill out the choice list for the user This
   * methode will search all the device linked with this SESAME.
   */
  public void fillOutTheChoiceList() {
    System.out.println("<--- BEGIN : fillOutTheChoiceList() --->");

    String[] all_device_id;

    // Make the deserialization of the table file which is the database of the device
    IdentifiantAndKeyTable table_id_key = null;
    boolean flag_extraction = false;
    File file = new File("identifiant_and_key_table.ser");
    try (FileInputStream fileIn = new FileInputStream(file);
        ObjectInputStream in = new ObjectInputStream(fileIn)) {
      table_id_key = (IdentifiantAndKeyTable) in.readObject();

      flag_extraction = true;

    } catch (IOException i) {
      flag_extraction = false;
      System.out.println("IOException : " + i.getMessage());
    } catch (ClassNotFoundException c) {
      System.out.println("DeviceLinkingData class not found");
      flag_extraction = false;
    }

    // Check if the deserialization is done succesffully
    if (flag_extraction) {
      all_device_id = table_id_key.getAllLinkedDeviceId();
      if (all_device_id.length > 0) {
        // Fit the device array list
        for (int i = 0; i < all_device_id.length; i++) {
          liste_peripherique.add(all_device_id[i], i);
        }
      } else {
        for (int i = 0; i < device_list.length; i++) {
          liste_peripherique.add(device_list[i], i);
        }
      }
    } else {
      for (int i = 0; i < device_list.length; i++) {
        liste_peripherique.add(device_list[i], i);
      }
    }
    System.out.println("<--- END : fillOutTheChoiceList() --->");
    // liste_peripherique.addListSelectionListener(this);
  }