Esempio n. 1
0
    private void addJamSession() {
      TreePath[] paths = contactsTree.getSelectionPaths();
      if (paths == null) {
        return;
      }

      ArrayList<String> participants = new ArrayList<String>();

      for (TreePath path : paths) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
        Object userObject = node.getUserObject();
        if (!(userObject instanceof JamUser)) {
          // Just expand / collapse
          return;
        }
        JamUser user = (JamUser) userObject;
        String userId = user.getId();
        participants.add(userId);
      }

      String sessionName;

      if (participants.size() == 1) {
        sessionName = participants.get(0);
      } else {
        sessionName = CommonDialog.getString(this, "Enter name for this jam session:");
        if (sessionName == null) {
          return;
        }
      }

      addJamSession(sessionName, participants);
    }