|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.GUIBrain
This class contains the intellect the GUI class needs to provide services to the Control class. It also hides the GUI and Control from each other, serving as the middle-man for all their communication. It prepares all the data from CompileInfo, LoadInfo and RunInfo objects to GUI, so that it doesn't have to be aware of what's happening behind GUIBrain. Moreover, this class for its part doesn't take any position on how to show the data provided here on the screen. It may, however, tell GUI to disable or enable some elements or objects, such as buttons, menuitems or inputfields.
Field Summary | |
static int |
ANIMATED
|
private Animator |
animator
|
private java.util.Hashtable |
availableLanguages
This field contains the languages available, with the long, English names like "Finnish" or "English (GB)" as keys and the locales corresponding to the languages as values. |
private static short |
B91_NOT_RUNNING
|
private static short |
B91_PAUSED
|
private static short |
B91_RUNNING
|
private static short |
B91_WAIT_FOR_KBD
|
static int |
COMMENTED
|
private Control |
control
|
private java.io.File |
currentlyOpenedFile
|
private Settings |
currentSettings
This field namely stores the current settings and everytime a setting is changed, this is informed about it. |
private short |
currentState
Keeps track of the state of this program. |
static java.lang.String |
DEFAULT_STDIN_FILENAME
|
static java.lang.String |
DEFAULT_STDOUT_FILENAME
|
protected static boolean |
ENABLE_DATA_AREA_MARKUP
This variable sets whether the initial data area length (up to sp) should be marked by hiding the symbolic versions of lines down from it. |
private GUI |
gui
|
private static short |
INTERRUPTED_WITH_PAUSE
|
private static short |
INTERRUPTED_WITHOUT_PAUSE
|
private boolean |
interruptSent
This field is set when menuInterrupt is called, and all continuous loops which do many things and wait for input in between should check if this is sent before continuing to their next step. |
private static short |
K91_COMPILING
|
private static short |
K91_NOT_COMPILING
|
private static short |
K91_PAUSED
|
static int |
LINE_BY_LINE
|
private java.util.logging.Logger |
logger
This field contains our logger. |
static int |
MAX_KBD_VALUE
|
static int |
MIN_KBD_VALUE
|
private static short |
NONE
These fields are used to set the current state of program. |
private boolean |
noPauses
This field is set true, when continueTaskWithoutPauses is launched. |
static int |
PAUSED
|
private java.lang.String |
programPath
|
private java.io.File |
settingsFile
|
private boolean |
threadRunning
|
Constructor Summary | |
GUIBrain(GUI gui,
Animator animator)
This constructor sets up the GUIBrain instance. |
Method Summary | |
void |
continueTask()
Notifies all methods,that have called waitForContinueTask() to continue their operation. |
void |
continueTaskWithoutPauses()
Notifies all methods, that have called waitForContinueTask() to continue their operation plus informs them that waitForContinueTask() should no longer be called during current operation. |
boolean |
enterInput(java.lang.String input)
|
private void |
findAvailableLanguages()
This method determines the available languages. |
java.lang.String[] |
getAvailableLanguages()
Returns all available languages. |
private java.io.File |
getCurrentDefaultStdinFile()
This method returns the default stdin file, which is the one declared in currentSettings. |
private java.io.File |
getCurrentDefaultStdoutFile()
This method returns the default stdout file, which is the one declared in currentSettings. |
private void |
getCurrentSettings()
Makes sure that currentSettings contains at least the default values for each key, if they cannot be obtained from settingsFile. |
static java.lang.String |
getExtension(java.io.File f)
|
private void |
interruptCurrentTasks(boolean immediate)
Notifies all currents tasks to be interrupted once they are able to read the new value of interruptSent. |
private LoadInfo |
load()
This just loads the opened b91-program into Titokone's memory without updating GUI anyway. |
private void |
loadAndUpdateGUI()
Load the program into Titokone's memory and update's GUI to show the new memory contents and register values and such. |
void |
menuAbout()
|
void |
menuCompile()
This method corresponds to the menu option File -> Compile. |
void |
menuEraseMemory()
This method corresponds to the menu option File -> Erase memory. |
void |
menuExit()
This method corresponds to the menu option File -> Exit. |
void |
menuInterrupt(boolean immediate)
This method corresponds to a request to interrupt whatever we were doing once it becomes possible. |
void |
menuManual()
|
void |
menuOpenFile(java.io.File openedFile)
This method corresponds to the menu option File -> Open... |
void |
menuRun()
This method corresponds to the menu option File -> Run. |
void |
menuSetCompilingOption(int option,
boolean b)
This method |
void |
menuSetLanguage(java.io.File languageFile)
This method correspods as well to the menu option Option -> Set language. |
void |
menuSetLanguage(java.lang.String language)
This method corresponds to the menu option Option -> Set language. |
void |
menuSetMemorySize(int newSize)
This method corresponds to the menu option Option -> Set Memory Size. |
void |
menuSetRunningOption(int option,
boolean b)
|
void |
menuSetStdin(java.io.File stdinFile)
This method corresponds to the menu option Option -> Set Default Stdin File. |
void |
menuSetStdout(java.io.File stdoutFile,
boolean append)
This method corresponds to the menu option Option -> Set Default Stdout File. |
void |
refreshCompilingOptions()
This methods refreshes GUI so that it shows compiling options as they are declared currently. |
void |
refreshRunningOptions()
This methods refreshes GUI so that it shows running options as they are declared currently. |
private void |
saveSettings()
Saves currentSettings to settingsFile. |
void |
saveSource()
This method is used to save the source after it has been modified in the code window. |
private void |
setGUICommandsForCurrentState()
Sets GUI to correspond the current state of program, which means that some buttons should be enables while others not. |
void |
waitForContinueTask()
A method can call this, if it wants enter into pause mode and wait for someone to call continueTask() or continueTaskWithoutPauses() methods. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.Hashtable availableLanguages
private Control control
private Settings currentSettings
private Animator animator
private GUI gui
private java.lang.String programPath
private java.io.File settingsFile
private java.io.File currentlyOpenedFile
public static final int COMMENTED
public static final int LINE_BY_LINE
public static final int PAUSED
public static final int ANIMATED
private boolean interruptSent
private boolean noPauses
private boolean threadRunning
private short currentState
private static final short NONE
private static final short B91_NOT_RUNNING
private static final short B91_RUNNING
private static final short B91_PAUSED
private static final short B91_WAIT_FOR_KBD
private static final short K91_NOT_COMPILING
private static final short K91_COMPILING
private static final short K91_PAUSED
private static final short INTERRUPTED_WITHOUT_PAUSE
private static final short INTERRUPTED_WITH_PAUSE
private java.util.logging.Logger logger
public static java.lang.String DEFAULT_STDIN_FILENAME
public static java.lang.String DEFAULT_STDOUT_FILENAME
protected static boolean ENABLE_DATA_AREA_MARKUP
public static final int MIN_KBD_VALUE
public static final int MAX_KBD_VALUE
Constructor Detail |
public GUIBrain(GUI gui, Animator animator)
Method Detail |
public void menuOpenFile(java.io.File openedFile)
public boolean enterInput(java.lang.String input)
public void menuRun()
public void saveSource()
public void menuCompile()
public void menuEraseMemory()
public void menuExit()
public void menuSetLanguage(java.lang.String language)
language
- Name of the language. This should be one of those get
from getAvailableLanguages() method.public void menuSetLanguage(java.io.File languageFile)
languageFile
- The language file. This must be class-file that
extends ListResourceBundle.public void menuSetStdin(java.io.File stdinFile)
public void menuSetStdout(java.io.File stdoutFile, boolean append)
public void menuSetMemorySize(int newSize)
public void refreshRunningOptions()
public void menuSetRunningOption(int option, boolean b)
public void refreshCompilingOptions()
public void menuSetCompilingOption(int option, boolean b)
public void menuAbout()
public void menuManual()
public void menuInterrupt(boolean immediate)
immediate
- If this is true, then continueTask is being waited before
the previous job ends.
If this is false, then it stops immediately and next job
can start right after calling this.private void interruptCurrentTasks(boolean immediate)
immediate
- If this is true, then continueTask is being waited before
the previous job ends.
If this is false, then it stops immediately and next job
can start right after calling this.public void continueTask()
public void continueTaskWithoutPauses()
public void waitForContinueTask()
public java.lang.String[] getAvailableLanguages()
private void getCurrentSettings() throws java.io.IOException
java.io.IOException
private LoadInfo load()
private void loadAndUpdateGUI()
private void saveSettings()
private java.io.File getCurrentDefaultStdoutFile()
private java.io.File getCurrentDefaultStdinFile()
private void findAvailableLanguages()
public static java.lang.String getExtension(java.io.File f)
private void setGUICommandsForCurrentState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |