Package mars.venus
Class Editor
java.lang.Object
mars.venus.Editor
Manage the file being edited.
Currently only manages one file at a time, but can be expanded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
static int
static int
static int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
close()
Perform "close" operation on current tab's file.boolean
closeAll()
Close all currently open files.boolean
Called by several of the Action objects when there is potential loss of editing changes.Get name of current directory for Open operation.Get name of current directory for Save or Save As operation.Generates a default file namevoid
newFile()
Perform "new" operation to create an empty tab.boolean
open()
Open file in a new tab.boolean
save()
Perform "save" operation on current tab's file.boolean
saveAll()
Perform save operation on all open files (tabs).boolean
saveAs()
Perform "save as" operation on current tab's file.void
setEditTabbedPane(EditTabbedPane editTabbedPane)
Set associated EditTabbedPane.void
Places name of file currently being edited into its edit tab and the application's title bar.
-
Field Details
-
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 Details
-
Editor
Create editor.- Parameters:
ui
- the GUI that owns this editor
-
-
Method Details
-
setEditTabbedPane
Set associated EditTabbedPane. This is container for any/all open files.- Parameters:
editTabbedPane
- an existing editTabbedPane object
-
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
Get name of current directory for Save or Save As operation.- Returns:
- String containing directory pathname. Returns null if there is no EditTabbedPane. Returns directory MARS was launched from if no Save or Save As operations have been performed.
-
getNextDefaultFilename
Generates a default file name- Returns:
- returns string mipsN.asm, where N is 1,2,3,...
-
setTitle
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 filename
- Name of file (last component of path)status
- Edit status of file. See FileStatus static constants.
-
newFile
public void newFile()Perform "new" operation to create an empty tab. -
close
public boolean close()Perform "close" operation on current tab's file.- Returns:
- true if succeeded, else false.
-
closeAll
public boolean closeAll()Close all currently open files.- Returns:
- true if succeeded, else false.
-
save
public boolean save()Perform "save" operation on current tab's file.- Returns:
- true if succeeded, else false.
-
saveAs
public boolean saveAs()Perform "save as" operation on current tab's file.- Returns:
- true if succeeded, else false.
-
saveAll
public boolean saveAll()Perform save operation on all open files (tabs).- Returns:
- true if succeeded, else false.
-
open
public boolean open()Open file in a new tab.- Returns:
- true if succeeded, else false.
-
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:
- Whether the caller can proceed (edits were saved or discarded) or the user selected Cancel
-