// Proceed if delete was confirmed
if ( confirm == WebOptionPane.YES_OPTION )
{
// Retrieving index of deleted file node in parent node
final FileTreeNode parentNode = fileTree.getSelectedNode ().getParent ();
final int index = parentNode.indexOfFileChild ( file );
final int count = parentNode.getChildCount ();
// Removing file
FileUtils.deleteFile ( file );
fileTree.removeFile ( file );
// Restoring selection
fileTree.setSelectedNode ( count == 1 ? parentNode :
( index < count - 1 ? parentNode.getChildAt ( index ) : parentNode.getChildAt ( index - 1 ) ) );
}
}
} );
contolsToolbar.add ( remove, ToolbarLayout.END );