/**
  * Respond to selections within the left list.
  *
  * @throws InvocationTargetException
  * @throws InterruptedException
  */
 private void respondToListClick() {
   this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   enableOrDisableActions();
   int idx = archetypeList.getSelectedIndex();
   if (idx == -1 || idx >= listData.size()) {
     // no selection
     if (archetypeControl == null) {
       return;
     }
     archetypeControl.removeNameChangeListener(this);
     rightPanel.removeAll();
     archetypeControl = null;
     rightPanel.add(selectLeftLabel);
     rightPanel.repaint();
     return;
   }
   if (archetypeControl == null) {
     archetypeControl = new ArchetypeControl(listData.get(idx));
     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
     rightPanel.removeAll();
     rightPanel.add(archetypeControl, BorderLayout.CENTER);
     rightPanel.repaint();
     rightPanel.revalidate();
     setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
     archetypeControl.addNameChangeListener(this);
   } else {
     archetypeControl.setArchetype(listData.get(idx));
     archetypeControl.repaint();
   }
   this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 }
  protected void doExportSelected() {
    Archetype selected = listData.get(archetypeList.getSelectedIndex());
    if (selected == null) {
      return;
    }
    // Set up the dialog
    JMemoryFileChooser chooser = new JMemoryFileChooser();
    chooser.setFileFilter(characterFileFilter);
    chooser.setSelectedFile(new File(selected.getName() + ".xml"));
    chooser.setDialogTitle("Export Archetype");
    chooser.setApproveButtonText("Export");

    // Call dialog
    if (chooser.showSaveDialog(FILEDIALOG_NAME, this) != JFileChooser.APPROVE_OPTION) {
      return;
    }
    File targetFile = chooser.getSelectedFile();
    // Save it
    try {
      performSave(selected, targetFile);
    } catch (IOException e) {
      JOptionPane.showMessageDialog(
          this, "An error occured during export.", "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
 private void enableOrDisableActions() {
   int idx = archetypeList.getSelectedIndex();
   if (archetypeList.getSelectedIndex() == -1) {
     deleteArchetypeAction.setEnabled(false);
     return;
   }
   if (StringUtils.equalsIgnoreCase("generic", listData.get(idx).getName())) {
     deleteArchetypeAction.setEnabled(false);
     return;
   }
   exportArchetypeAction.setEnabled(true);
   deleteArchetypeAction.setEnabled(true);
 }
 /** Delete selected archetype */
 private void deleteSelectedAchetype() {
   int idx = archetypeList.getSelectedIndex();
   if (idx == -1) {
     return;
   }
   StringBuilder msg = new StringBuilder(256);
   msg.append("Delete archetype \"");
   msg.append(listData.get(idx).getName());
   msg.append("\" ?");
   int ret =
       JOptionPane.showConfirmDialog(
           this, msg.toString(), "Confirm", JOptionPane.OK_CANCEL_OPTION);
   if (ret == JOptionPane.CANCEL_OPTION) {
     return;
   }
   listData.remove(idx);
   saveListAction.setEnabled(true);
 }