6454 Added confirmation before deleting persona

This commit is contained in:
Ethan Roseman 2020-06-10 14:09:45 -04:00
parent b6f33e72f8
commit dd36f60f31
2 changed files with 31 additions and 17 deletions

View File

@ -21,17 +21,15 @@ CTL_PersonaDetailsTopComponent=Persona Details
OpenPersonasAction.displayName=Persona Manager OpenPersonasAction.displayName=Persona Manager
PersonaDetailsDialogCreateTitle=Create Persona PersonaDetailsDialogCreateTitle=Create Persona
PersonaDetailsDialogEditTitle=Edit Persona PersonaDetailsDialogEditTitle=Edit Persona
PersonaDetailsDialogViewTitle=View Persona
PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository PersonaDetailsPanel_CentralRepoErr_msg=Failure to write to Central Repository
PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure PersonaDetailsPanel_CentralRepoErr_Title=Central Repository failure
PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty PersonaDetailsPanel_EmptyName_msg=Persona name cannot be empty
PersonaDetailsPanel_EmptyName_Title=Empty persona name PersonaDetailsPanel_EmptyName_Title=Empty persona name
PersonaDetailsPanel_load_exception_msg=Failed to load persona PersonaDetailsPanel_load_exception_msg=Failed to load persona
PersonaDetailsPanel_load_exception_Title=Initialization failure PersonaDetailsPanel_load_exception_Title=Initialization failure
PersonaDetailsPanel_NameCreate=Create Persona PersonaDetailsPanel_NotEnoughAccounts_msg=A persona needs at least one account
PersonaDetailsPanel_NameEdit=Edit Persona PersonaDetailsPanel_NotEnoughAccounts_Title=Missing account
PersonaDetailsPanel_NameView=View Persona
PersonaDetailsPanel_NotEnoughAccounts_msg=Two or more accounts are necessary to create a persona
PersonaDetailsPanel_NotEnoughAccounts_Title=Not enough accounts
PersonaManagerTopComponent.createBtn.text=New Persona PersonaManagerTopComponent.createBtn.text=New Persona
PersonaManagerTopComponent.searchBtn.text=Search PersonaManagerTopComponent.searchBtn.text=Search
PersonaManagerTopComponent.resultsTable.columnModel.title1=Name PersonaManagerTopComponent.resultsTable.columnModel.title1=Name
@ -84,6 +82,11 @@ AddAccountDialog.confidenceLbl.text=Confidence:
AddAccountDialog.typeLbl.text=Type: AddAccountDialog.typeLbl.text=Type:
AddAccountDialog.identiferLbl.text=Identifier: AddAccountDialog.identiferLbl.text=Identifier:
AddAccountDialog.identifierTextField.text= AddAccountDialog.identifierTextField.text=
PersonaManagerTopComponent.deleteBtn.text=Delete Persona
PMTopComponent_delete_confirmation_msg=Are you sure you want to delete a persona?
PMTopComponent_delete_confirmation_Title=Are you sure?
PMTopComponent_delete_exception_msg=Failed to delete persona.
PMTopComponent_delete_exception_Title=Delete failure
PMTopComponent_Name=Persona Manager PMTopComponent_Name=Persona Manager
PMTopComponent_search_exception_msg=Failed to search personas PMTopComponent_search_exception_msg=Failed to search personas
PMTopComponent_search_exception_Title=Search failure PMTopComponent_search_exception_Title=Search failure

View File

@ -30,6 +30,8 @@ import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.windows.RetainLocation; import org.openide.windows.RetainLocation;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
@ -56,7 +58,9 @@ public final class PersonaManagerTopComponent extends TopComponent {
@Messages({ @Messages({
"PMTopComponent_Name=Persona Manager", "PMTopComponent_Name=Persona Manager",
"PMTopComponent_delete_exception_Title=Delete failure", "PMTopComponent_delete_exception_Title=Delete failure",
"PMTopComponent_delete_exception_msg=Failed to delete persona", "PMTopComponent_delete_exception_msg=Failed to delete persona.",
"PMTopComponent_delete_confirmation_Title=Are you sure?",
"PMTopComponent_delete_confirmation_msg=Are you sure you want to delete this persona?",
}) })
public PersonaManagerTopComponent() { public PersonaManagerTopComponent() {
initComponents(); initComponents();
@ -89,6 +93,12 @@ public final class PersonaManagerTopComponent extends TopComponent {
deleteBtn.addActionListener(new ActionListener() { deleteBtn.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
NotifyDescriptor confirm = new NotifyDescriptor.Confirmation(
Bundle.PMTopComponent_delete_confirmation_msg(),
Bundle.PMTopComponent_delete_confirmation_Title(),
NotifyDescriptor.YES_NO_OPTION);
DialogDisplayer.getDefault().notify(confirm);
if (confirm.getValue().equals(NotifyDescriptor.YES_OPTION)) {
try { try {
if (selectedPersona != null) { if (selectedPersona != null) {
selectedPersona.delete(); selectedPersona.delete();
@ -103,6 +113,7 @@ public final class PersonaManagerTopComponent extends TopComponent {
} }
executeSearch(); executeSearch();
} }
}
}); });
// Results table // Results table