registry.unregisterPlacemark(placemark, PlacemarkType.USER);
}//GEN-LAST:event_removeButtonActionPerformed
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
// Fetch the list of known USER Placemark names
PlacemarkRegistry registry = PlacemarkRegistryFactory.getInstance();
Set<Placemark> placemarkSet =
registry.getAllPlacemarks(PlacemarkType.USER);
// When the Edit..... button is pressed find the Placemark selected
// and display a dialog with the values filled in.
int row = placemarksTable.getSelectedRow();
if (row == -1) {
return;
}
Placemark placemark = placemarksTableModel.getPlacemark(row);
// Display a dialog with the values in the Placemark. And if we wish
// to update the values, then re-add the placemark. (Re-adding the
// placemark should have the effect of updating its values.
AddEditPlacemarkJDialog dialog = new AddEditPlacemarkJDialog(
this, true, placemark, placemarkSet);
dialog.setTitle(BUNDLE.getString("Edit_Placemark"));
dialog.setLocationRelativeTo(this);
dialog.pack();
dialog.setVisible(true);
if (dialog.getReturnStatus() == AddEditPlacemarkJDialog.RET_OK) {
// First remove the old placemark.
String oldName = placemark.getName();
try {
PlacemarkUtils.removeUserPlacemark(oldName);
} catch (Exception excp) {
LOGGER.log(Level.WARNING, "Unable to remove " + oldName +
" from " + " user's placemarks", excp);
return;
}
// Tell the client-side registry of placemarks that a new one has
// been added
registry.unregisterPlacemark(placemark, PlacemarkType.USER);
// Create a new placemark with the new information.
String name = dialog.getPlacemarkName();
String url = dialog.getServerURL();
float x = dialog.getLocationX();
float y = dialog.getLocationY();
float z = dialog.getLocationZ();
float angle = dialog.getLookAtAngle();
ColorRGBA backColor = dialog.getBackgroundColor();
ColorRGBA textColor = dialog.getTextColor();
String imageURL = dialog.getImageURL();
String message = dialog.getMessage();
Placemark newPlacemark = new Placemark(name, url, x, y, z, angle, backColor, textColor,
imageURL, message);
try {
PlacemarkUtils.addUserPlacemark(newPlacemark);
} catch (Exception excp) {
LOGGER.log(Level.WARNING, "Unable to add " + name + " to " +
" user's placemarks", excp);
return;
}
// Tell the client-side registry of placemarks that a new one has
// been added
registry.registerPlacemark(newPlacemark, PlacemarkType.USER);
}
}//GEN-LAST:event_editButtonActionPerformed