* Delete the resources associated to the selected nodes.
* Display an error message if there is no node selected or if
* the resource is not editable.
*/
protected void deleteSelectedResources() {
PropertyManager pm = PropertyManager.getPropertyManager();
TreePath path[] = removeDescendants(getSelectionPaths());
if (path == null) {
JOptionPane.showMessageDialog(this,
"No Resource selected",
"Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (path.length > 0) {
int result =
JOptionPane.showConfirmDialog(this,
"Delete selected resource(s)?",
"Delete Resource(s)",
JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.YES_OPTION) {
DefaultTreeModel model = (DefaultTreeModel) getModel();
for (int i = 0 ; i < path.length ; i++) {
RemoteResourceWrapper rrw =
getSelectedResourceWrapper(path[i]);
if (rrw == null)
continue;
try {
if (pm.isEditable(rrw)) {
deleteResource(rrw);
MutableTreeNode node = (MutableTreeNode)
path[i].getLastPathComponent();
model.removeNodeFromParent(node);
} else {