// File: ActionClose.java // Classes: ActionClose // Author: Kedar Patankar package edu.neu.ccs.demeter.tools.apstudio.graphedit; public class ActionClose extends Action { // executeit resets this and doIt sets it if any error/cancel occurs during its course of execution private boolean _userCancelled; public ActionClose(Editor e,Document d) { super(e,d);} public String name() { return "Close class dictionary File"; } public boolean executeIt() { _userCancelled=false; doIt(); return !_userCancelled; } public void doIt() { if(!_document.gcdNeedsSaving()) shutDown(); else { String title="Confirm File Close"; String message1="Save changes to class graph?"; String message2=_document.getDocName(); String buttonString="YNC"; AlarmDialog ad = new AlarmDialog(_editor,title,message1,message2,buttonString,"Y"); ad.setVisible(true); String choice = ad.getChoice(); if(choice.equals("YES")) { ActionSave act=new ActionSave(_editor,_document); if(act.executeIt()) shutDown(); else _userCancelled = true; } else if(choice.equals("CANCEL")) _userCancelled = true; else shutDown(); } } public void undoIt() { } private void shutDown() { _editor.detach(_document.getDocName(),_document); } } /* end class ActionClose */