mars.venus
Class Editor

java.lang.Object
  extended by mars.venus.Editor

public class Editor
extends Object

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


Field Summary
static int MAX_BLINK_RATE
           
static int MAX_TAB_SIZE
           
static int MIN_BLINK_RATE
           
static int MIN_TAB_SIZE
           
 
Constructor Summary
Editor(VenusUI ui)
          Create editor.
 
Method Summary
 boolean close()
           
 boolean closeAll()
           
 boolean editsSavedOrAbandoned()
          Called by several of the Action objects when there is potential loss of editing changes.
 String getCurrentOpenDirectory()
          Get name of current directory for Open operation.
 String getCurrentSaveDirectory()
          Get name of current directory for Save or Save As operation.
 String getNextDefaultFilename()
          Generates a default file name
 void newFile()
           
 boolean open()
           
 boolean save()
           
 boolean saveAll()
           
 boolean saveAs()
           
 void setEditTabbedPane(EditTabbedPane editTabbedPane)
          Set associated EditTabbedPane.
 void setTitle(String path, String name, int status)
          Places name of file currently being edited into its edit tab and the application's title bar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_TAB_SIZE

public static final int MIN_TAB_SIZE
See Also:
Constant Field Values

MAX_TAB_SIZE

public static final int MAX_TAB_SIZE
See Also:
Constant Field Values

MIN_BLINK_RATE

public static final int MIN_BLINK_RATE
See Also:
Constant Field Values

MAX_BLINK_RATE

public static final int MAX_BLINK_RATE
See Also:
Constant Field Values
Constructor Detail

Editor

public Editor(VenusUI ui)
Create editor.

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

setEditTabbedPane

public void setEditTabbedPane(EditTabbedPane editTabbedPane)
Set associated EditTabbedPane. This is container for any/all open files.

Parameters:
editTabbedPane - an existing editTabbedPane object

getCurrentOpenDirectory

public String getCurrentOpenDirectory()
Get name of current directory for Open operation.

Returns:
String containing directory pathname. Returns null if there is no EditTabbedPane. Returns default, directory MARS is launched from, if no Opens have been performed.

getCurrentSaveDirectory

public String getCurrentSaveDirectory()
Get name of current directory for Save or Save As operation.

Returns:
String containing directory pathname. Returns null if there is no EditTabbedPane. Returns default, directory MARS is launched from, if no Save or Save As operations have been performed.

getNextDefaultFilename

public String getNextDefaultFilename()
Generates a default file name

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

setTitle

public void setTitle(String path,
                     String name,
                     int status)
Places name of file currently being edited into its edit tab and the application's title bar. The edit tab will contain only the filename, the title bar will contain full pathname. If file has been modified since created, opened or saved, as indicated by value of the status parameter, the name and path will be followed with an '*'. If newly-created file has not yet been saved, the title bar will show (temporary) file name but not path.

Parameters:
path - Full pathname for file
name - Name of file (last component of path)
status - Edit status of file. See FileStatus static constants.

newFile

public void newFile()

close

public boolean close()

closeAll

public boolean closeAll()

save

public boolean save()

saveAs

public boolean saveAs()

saveAll

public boolean saveAll()

open

public boolean open()

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).