mars.venus
Class Editor

java.lang.Object
  |
  +--mars.venus.Editor

public class Editor
extends java.lang.Object

Manage the file being edited. Currently only manages one file at a time, but can be expanded.


Constructor Summary
Editor(VenusUI ui)
          Create editor.
 
Method Summary
 boolean editsSavedOrAbandoned()
          Called by several of the Action objects when there is potential loss of editing changes.
 java.lang.String getNextDefaultFilename()
          Generates a default file name
 boolean save()
          Pops up a dialog box to do "Save" operation.
 boolean saveAs()
          Pops up a dialog box to do "Save As" operation.
 void setFrameTitle()
          Places name of file currently being edited into the title bar of the editing window.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Editor

public Editor(VenusUI ui)
Create editor.

Parameters:
ui - the GUI that owns this editor
Method Detail

getNextDefaultFilename

public java.lang.String getNextDefaultFilename()
Generates a default file name

Returns:
returns string mipsN.asm, where N is 1,2,3,...

setFrameTitle

public void setFrameTitle()
Places name of file currently being edited into the title bar of the editing window. If the contents of the editing window have been modified since the New, Open, Save or SaveAs operation, the client is responsible for calling this method to display an asterisk (*) next to the file name in the title bar. And responsible for calling it again after Save or SaveAs to repaint the filename without the asterisk.


save

public boolean save()
Pops up a dialog box to do "Save" operation.

Returns:
true if the file was actually saved.

saveAs

public boolean saveAs()
Pops up a dialog box to do "Save As" operation. If necessary an additional overwrite dialog is performed.

Returns:
true if the file was actually saved.

editsSavedOrAbandoned

public boolean editsSavedOrAbandoned()
Called by several of the Action objects when there is potential loss of editing changes. Specifically: if there is a current file open for editing and its modify flag is true, then give user a dialog box with choice to save, discard edits, or cancel and carry out the decision. This applies to File->New, File->Open, File->Close, and File->Exit.

Returns:
false means user selected Cancel so caller should do that. Return of true means caller can proceed (edits were saved or discarded).