Skip to content

Commit b5dedbf

Browse files
committed
added confirmation dialog
1 parent 7649012 commit b5dedbf

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

modules/ViewerController/src/main/java/org/janelia/workstation/controller/action/DeleteHortaWorkspaceAction.java

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,50 @@ public void performAction() {
7878
return;
7979
}
8080

81-
if (domainObject instanceof TmWorkspace) {
82-
TmWorkspace workspace = (TmWorkspace) this.domainObject;
83-
84-
BackgroundWorker deleter = new BackgroundWorker() {
85-
@Override
86-
public String getName() {
87-
return "Deleting TmWorkspaces";
88-
}
89-
90-
@Override
91-
protected void doStuff() {
92-
TiledMicroscopeDomainMgr domainMgr = TiledMicroscopeDomainMgr.getDomainMgr();
93-
List<Long> workspaceIds = new ArrayList<>();
94-
workspaceIds.add(workspace.getId());
95-
domainMgr.removeWorkspaces(workspaceIds);
96-
}
97-
98-
@Override
99-
protected void hadSuccess() {
100-
JOptionPane.showMessageDialog(
101-
null,
102-
"Selected workspaces deleted successfully.",
103-
"Success", JOptionPane.INFORMATION_MESSAGE);
104-
};
81+
int confirmation = JOptionPane.showConfirmDialog(null,
82+
"Are you sure you want to delete the selected workspaces?",
83+
"Confirm Deletion", JOptionPane.YES_NO_OPTION);
84+
85+
if (confirmation == JOptionPane.YES_OPTION) {
86+
87+
if (domainObject instanceof TmWorkspace) {
88+
TmWorkspace workspace = (TmWorkspace) this.domainObject;
89+
90+
BackgroundWorker deleter = new BackgroundWorker() {
91+
@Override
92+
public String getName() {
93+
return "Deleting TmWorkspaces";
94+
}
95+
96+
@Override
97+
protected void doStuff() {
98+
TiledMicroscopeDomainMgr domainMgr = TiledMicroscopeDomainMgr.getDomainMgr();
99+
List<Long> workspaceIds = new ArrayList<>();
100+
workspaceIds.add(workspace.getId());
101+
domainMgr.removeWorkspaces(workspaceIds);
102+
}
105103

106-
@Override
107-
protected void hadError(Throwable error) {
108-
log.error("Error deleting workspaces", error);
109-
JOptionPane.showMessageDialog(
110-
null,
111-
"Failed to delete workspaces: " + error.getMessage(), "Error",
112-
JOptionPane.ERROR_MESSAGE);
113-
}
114-
};
115-
deleter.executeWithEvents();
104+
@Override
105+
protected void hadSuccess() {
106+
JOptionPane.showMessageDialog(
107+
null,
108+
"Selected workspaces deleted successfully.",
109+
"Success", JOptionPane.INFORMATION_MESSAGE);
110+
}
111+
112+
;
113+
114+
@Override
115+
protected void hadError(Throwable error) {
116+
log.error("Error deleting workspaces", error);
117+
JOptionPane.showMessageDialog(
118+
null,
119+
"Failed to delete workspaces: " + error.getMessage(), "Error",
120+
JOptionPane.ERROR_MESSAGE);
121+
}
122+
};
123+
deleter.executeWithEvents();
124+
}
116125
}
117126
}
118127
}

0 commit comments

Comments
 (0)