From 955c42951c5cf84adde8c7138a49b88004219399 Mon Sep 17 00:00:00 2001 From: preecej Date: Tue, 2 Oct 2012 23:49:22 +0000 Subject: [PATCH] Close Action progress. Now just need to build Close action dialog and trigger Save action when requested. svn path=/; revision=386 --- .../ie/dcu/apps/ist/actions/CloseAction.java | 26 +++++++++++-------- .../apps/ist/dialogs/SaveReminderDialog.java | 26 ++++++++++++------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java b/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java index 6c3fe1a..433c88a 100644 --- a/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java +++ b/Annotation/src/ie/dcu/apps/ist/actions/CloseAction.java @@ -18,19 +18,23 @@ public class CloseAction extends AppAction { public void run() { // call Save Reminder dialog SaveReminderDialog dialog = new SaveReminderDialog(window.getShell()); - SaveReminderDialog.Result result = dialog.open(); + SaveReminderDialog.ResultChoice result = dialog.open(); if (result != null) { - /* check return choice in result here and fire appropriate action: - * - save now and then close file ("Save now") - * - do not save and then close file ("I've already saved my work") - * - cancel the close ("Do not close this file") - */ - /*if (confirmClose(window)) { - window.close(); - // TODO: not really; you'll close the file here after a confirmation from the user via the ConfirmSaved dialog - System.exit(0); - }*/ + // check return choice in result here and fire appropriate action: + switch (result) { + case SAVE: // save now and then close file ("Save now") + //TODO: trigger Save dialog to save the file + window.getView().resetView(); // clear current data and work + break; + case NOSAVE: // do not save and then close file ("I've already saved my work") + window.getView().resetView(); // clear current data and work + status("Closed"); + break; + case CANCEL: // cancel the close ("Do not close this file") + status("Close cancelled."); + break; + } } } diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java index ea70c94..5f2e16f 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/SaveReminderDialog.java @@ -1,25 +1,31 @@ package ie.dcu.apps.ist.dialogs; +import ie.dcu.apps.ist.dialogs.ExportDialog.Result; +import ie.dcu.apps.ist.export.imagemap.AreaShape; +import ie.dcu.apps.ist.export.imagemap.RolloverEffect; + +import java.io.File; + import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Shell; public class SaveReminderDialog extends Dialog { - // Default title - private static final String TITLE = "Save Reminder"; - public class Result {}; - public SaveReminderDialog(Shell shell) { super(shell); setText(TITLE); } - - public Result open() { - return null; + + public enum ResultChoice { + SAVE, NOSAVE, CANCEL } - //return MessageDialog.openConfirm( - // window.getShell(), "Save", - // "Have you remembered to save your work before closing this file?"); + // Default title + private static final String TITLE = "Save Reminder"; + + public ResultChoice open() { + //TODO: build dialog UI here + return ResultChoice.SAVE; + } } -- 2.34.1