+ private void askRouteNameAndPersist(Route committedRoute) {
+ String newName = askRouteName("Confirm Route", committedRoute.getName());
+ if (newName != null) {
+ committedRoute.setName(newName);
+ routeService.persistRoute(committedRoute);
+ } else {
+ routeService.discardRoute(committedRoute);
+ }
+ }
+
+ private boolean askDiscardUnpersistedRoute() {
+ MessageDialog dialog = new MessageDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Discard route",
+ null,
+ "Discard current unpersisted route?",
+ MessageDialog.INFORMATION,
+ 0,
+ new String[] { "OK", "Cancel" });
+ return dialog.open() == Window.OK;
+ }
+
+ private String askRouteName(String dialogTitle, String initialValue) {
+ InputDialog dialog = new InputDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ dialogTitle,
+ "Route name",
+ initialValue,
+ s -> s.trim().length() > 0 ? null : "Name must be non-empty");
+ if (dialog.open() == Window.OK) {
+ return dialog.getValue();
+ }
+ return null;
+ }
+