@Override
 public void profileSelectionChanged(final Optional<MutableProfile> profile) {
   okButton.setEnabled(model.isSaveAllowed());
   deleteProfile.setEnabled(model.getSelectedProfile().isPresent());
   if (profile.isPresent()) {
     final int index = profilesModel.indexOf(profile.get());
     selectionModel.setLeadSelectionIndex(index);
   } else {
     selectionModel.setLeadSelectionIndex(-1);
   }
   addNickname.setEnabled(model.getSelectedProfile().isPresent());
   editNickname.setEnabled(model.getSelectedProfile().isPresent());
   addHighlight.setEnabled(model.getSelectedProfile().isPresent());
   editHighlight.setEnabled(model.getSelectedProfile().isPresent());
   name.setEnabled(model.getSelectedProfile().isPresent());
   name.setText(model.getSelectedProfileName().orElse(""));
   nicknames.setEnabled(model.getSelectedProfile().isPresent());
   nicknamesModel.clear();
   nicknamesModel.addAll(model.getSelectedProfileNicknames().orElse(Lists.newArrayList()));
   highlights.setEnabled(model.getSelectedProfile().isPresent());
   highlightsModel.clear();
   highlightsModel.addAll(model.getSelectedProfileHighlights().orElse(Lists.newArrayList()));
   realname.setEnabled(model.getSelectedProfile().isPresent());
   realname.setText(model.getSelectedProfileRealname().orElse(""));
   ident.setEnabled(model.getSelectedProfile().isPresent());
   ident.setText(model.getSelectedProfileIdent().orElse(""));
 }
 private void setupProfileNicknames(final ReorderableJList<String> nicknames) {
   nicknamesModel = nicknames.getModel();
   nicknamesModel.addAll(model.getSelectedProfileNicknames().orElse(Lists.newArrayList()));
   nicknames.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   nicknames.setEnabled(model.getSelectedProfileNicknames().isPresent());
   nicknames.addListSelectionListener(
       l ->
           model.setSelectedProfileSelectedNickname(
               Optional.ofNullable(nicknames.getSelectedValue())));
 }
 private void setupProfileHighlights(final ReorderableJList<String> highlights) {
   highlightsModel = highlights.getModel();
   highlightsModel.addAll(model.getSelectedProfileHighlights().orElse(Lists.newArrayList()));
   highlights.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   highlights.setEnabled(model.getSelectedProfileHighlights().isPresent());
   highlights.addListSelectionListener(
       l ->
           model.setSelectedProfileSelectedHighlight(
               Optional.ofNullable(highlights.getSelectedValue())));
 }
 private void setupProfileList(final JList<MutableProfile> profileList) {
   selectionModel = new VetoableListSelectionModel();
   profilesModel = (GenericListModel<MutableProfile>) profileList.getModel();
   profilesModel.addAll(model.getProfileList());
   profileList.setSelectionModel(selectionModel);
   selectionModel.addVetoableSelectionListener(
       e -> {
         if (!model.canSwitchProfiles()) {
           throw new PropertyVetoException("Cannot switch with invalid profile", e);
         }
       });
   profileList.addListSelectionListener(
       l -> {
         if (!selectionModel.isSelectionEmpty()) {
           model.setSelectedProfile(Optional.ofNullable(profileList.getSelectedValue()));
         }
       });
 }