/**
   * @method : void actionPerformed(ActionEvent e)
   *     <p>this method is called each time the user click on one of the buttons, or on the combobox
   */
  public void actionPerformed(ActionEvent e) {
    String s = e.getActionCommand();
    int command = Integer.parseInt(s);

    switch (command) {
      case AC_CHOSEN: // the item selected in the combobox is copied into the textfield, this allow
                      // the user to create a new synclist
        JComboBox<String> cb = (JComboBox<String>) e.getSource();
        String aSelection = (String) cb.getSelectedItem();
        theSyncListName.setText(aSelection);
        break;

      case AC_CANCEL: // quit without doing anything
        this.setVisible(false);
        theFrame.dispose();

        break;

      case AC_SAVE: // associated the selected synclist (or even create a new one) to the device
        String syncListName = theSyncListName.getText();
        Libelle aLibelle = SynclistNamesContainer.getSingleton().getLibelle(syncListName);
        if (aLibelle == null) { // so it is a new synclist, we create it
          aLibelle = SynclistNamesContainer.getSingleton().create(syncListName);
          Synclist p = SynclistContainer.getSingleton().getSynclist(aLibelle.getId());
          if (p == null) {
            p = new Synclist(aLibelle.getId());
            SynclistContainer.getSingleton().addSynclist(p);
          }
        }

        Synclist aSynclist = new Synclist(aLibelle.getId()); // mount point
        String aDirectory = theDirectory.getText();
        DeviceSyncList aDeviceSyncList = new DeviceSyncList(aDirectory, aSynclist.getId());

        theDevice.addDeviceSyncList(aDeviceSyncList);

        theSyncListPanel.setNewDevice(theDevice);

        this.setVisible(false);
        theFrame.dispose();

        break;

      default:
    }

    repaint();
  }
  /**
   * @method : void createMainPanel()
   *     <p>create all fields
   */
  private JPanel createMainPanel() {
    JPanel aPanel = new JPanel();
    BoxLayout l1 = new BoxLayout(aPanel, BoxLayout.PAGE_AXIS);
    aPanel.setLayout(l1);

    // the combobox of available synclists
    JComboBox<String> jC =
        new JComboBox<String>(SynclistNamesContainer.getSingleton().getLibelles());
    jC.setActionCommand(String.valueOf(AC_CHOSEN));
    jC.addActionListener(this);
    // jC.setMaximumSize(new Dimension(MAX_WIDTH, 20));
    aPanel.add(jC, BorderLayout.NORTH);

    aPanel.add(createSyncListName(), BorderLayout.CENTER); // the synclist name

    aPanel.add(createSyncDirectory(), BorderLayout.SOUTH); // the mount point

    return aPanel;
  }