/**
   * Save the current editor content to the given entry and write to disk.
   *
   * @param entry entry object to save.
   * @throws IOException
   */
  public void saveEntry(final Entry entry) throws IOException {
    if (entry == null) return;
    entry.setName(nameField.getText());
    entry.setComment(commentField.getText());
    entry.setIcon(iconField.getText());
    entry.setExec(execField.getText());
    entry.setType(typeField.getText());
    entry.setCategories(categoryField.getText());
    entry.setTerminal(terminalBox.isSelected());
    entry.setStartupNotify(startupNotifyBox.isSelected());

    FileWriter writer = new FileWriter(entry.getFile());
    writer.write(entry.toContentString());
    writer.close();

    JOptionPane.showMessageDialog(null, entry.getFile().getName() + " has been saved!");
  }
  /**
   * _more_
   *
   * @param entry _more_
   * @param properties _more_
   * @return _more_
   * @throws Exception _more_
   */
  private RecordFile doMakeRecordFile(Entry entry, Hashtable properties) throws Exception {
    String recordFileClass = getProperty("record.file.class", (String) null);
    if (recordFileClass != null) {
      return doMakeRecordFile(entry, recordFileClass, properties);
    }
    String path = entry.getFile().toString();

    return (RecordFile) getRecordFileFactory().doMakeRecordFile(path, properties);
  }
 /**
  * Refresh the edit box with the data at entry. The current entry pointer is set to the selected
  * entry.
  *
  * @param e the entry to load.
  */
 public void loadEntry(final Entry e) {
   current = e;
   fileLabel.setText("Editing " + e.getFile().getName());
   nameField.setText(e.getName());
   commentField.setText(e.getComment());
   iconField.setText(e.getIcon());
   execField.setText(e.getExec());
   typeField.setText(e.getType());
   categoryField.setText(e.getCategories());
   terminalBox.setSelected(e.isTerminal());
   startupNotifyBox.setSelected(e.isStartupNotify());
 }
 /**
  * Delete the file component of the given entry.
  *
  * @param entry the entry to remove from disk.
  */
 public void deleteEntry(final Entry entry) {
   File f = entry.getFile();
   int result =
       JOptionPane.showConfirmDialog(
           null,
           "Delete the file " + f.getName() + "?",
           "Confirm Deletion!",
           JOptionPane.OK_CANCEL_OPTION);
   if (result == JOptionPane.YES_OPTION) {
     f.delete();
   }
 }
  /**
   * _more_
   *
   * @param entry _more_
   * @param className _more_
   * @param properties _more_
   * @return _more_
   * @throws Exception _more_
   */
  private RecordFile doMakeRecordFile(Entry entry, String className, Hashtable properties)
      throws Exception {
    Class c = Misc.findClass(className);
    Constructor ctor = Misc.findConstructor(c, new Class[] {String.class, Hashtable.class});
    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getFile().toString(), properties});
    }
    ctor = Misc.findConstructor(c, new Class[] {String.class});

    if (ctor != null) {
      return (RecordFile) ctor.newInstance(new Object[] {entry.getResource().getPath()});
    }

    throw new IllegalArgumentException("Could not find constructor for " + className);
  }
  /**
   * @param request _more_
   * @param entry _more_
   * @param map _more_
   * @return _more_
   */
  @Override
  public boolean addToMap(Request request, Entry entry, MapInfo map) {
    try {
      if (!entry.isFile()) {
        return true;
      }
      // TODO: stream through the shapes
      EsriShapefile shapefile = new EsriShapefile(entry.getFile().toString());
      List features = shapefile.getFeatures();
      int totalPoints = 0;
      int MAX_POINTS = 10000;
      for (int i = 0; i < features.size(); i++) {
        if (totalPoints > MAX_POINTS) {
          break;
        }
        EsriShapefile.EsriFeature gf = (EsriShapefile.EsriFeature) features.get(i);
        java.util.Iterator pi = gf.getGisParts();
        while (pi.hasNext()) {
          if (totalPoints > MAX_POINTS) {
            break;
          }
          GisPart gp = (GisPart) pi.next();
          double[] xx = gp.getX();
          double[] yy = gp.getY();
          List<double[]> points = new ArrayList<double[]>();
          for (int ptIdx = 0; ptIdx < xx.length; ptIdx++) {
            points.add(new double[] {yy[ptIdx], xx[ptIdx]});
          }
          totalPoints += points.size();
          if (points.size() > 1) {
            map.addLines("", points);
          } else if (points.size() == 1) {
            map.addMarker("id", points.get(0)[0], points.get(0)[1], null, "");
          }
        }
      }
    } catch (Exception exc) {
      throw new RuntimeException(exc);
    }

    return false;
  }
 /**
  * _more_
  *
  * @param request _more_
  * @param entry _more_
  * @param parent _more_
  * @param newEntry _more_
  * @throws Exception _more_
  */
 public void initializeEntryFromForm(Request request, Entry entry, Entry parent, boolean newEntry)
     throws Exception {
   if (!entry.isFile()) {
     return;
   }
   EsriShapefile shapefile = new EsriShapefile(entry.getFile().toString());
   Rectangle2D bounds = shapefile.getBoundingBox();
   double[][] lonlat = new double[][] {{bounds.getX()}, {bounds.getY() + bounds.getHeight()}};
   ProjFile projFile = shapefile.getProjFile();
   if (projFile != null) {
     lonlat = projFile.convertToLonLat(lonlat);
   }
   entry.setNorth(lonlat[IDX_LAT][0]);
   entry.setWest(lonlat[IDX_LON][0]);
   lonlat[IDX_LAT][0] = bounds.getY();
   lonlat[IDX_LON][0] = bounds.getX() + bounds.getWidth();
   if (projFile != null) {
     lonlat = projFile.convertToLonLat(lonlat);
   }
   entry.setSouth(lonlat[IDX_LAT][0]);
   entry.setEast(lonlat[IDX_LON][0]);
 }