Class MyMenu

java.lang.Object
  |
  +--MyMenu

public class MyMenu
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.ComponentListener

This class constructs the menu of the menu of the main window of the application. It implements the ActionListener interface in order to make the application able to respond to the actions from the menu


Inner Class Summary
(package private)  class MyMenu.MenuAction
          class necessary for those actions which are retrieved also on the toolbars.
 
Field Summary
(package private)  MainFrame application
          holds a referrence to the MainFrame class
(package private)  javax.swing.JCheckBoxMenuItem automaticCompar
          holds a referrence to the "Selective Save" option in the Settings menu
(package private)  javax.swing.JMenuItem change_char
          holds the reference to the "Replace characters" item in the Options sub-menu of the Settings menu
(package private)  javax.swing.JMenuItem change_frequency
          holds the referrence to the "Save every..." option in the Options sub-menu in the Settings menu
(package private)  javax.swing.JCheckBoxMenuItem checkali
          holds a referrence to the "Case-based translation" option in the Translations sub-menu from the View menu
(package private)  javax.swing.JCheckBoxMenuItem checkdeep
          holds a referrence to the "Deep Analysis" option in the Translations sub-menu from the View menu
(package private)  javax.swing.JCheckBoxMenuItem checkedit
          holds a referrence to the "Edit data" option in the Settings menu
(package private)  javax.swing.JCheckBoxMenuItem checkoriginal
          holds a referrence to the "Original translation" option in the Translations sub-menu from the View menu
(package private)  javax.swing.JCheckBoxMenuItem checkpre
          holds a referrence to the "Preselection" option in the Translations sub-menu from the View menu
(package private)  javax.swing.JCheckBoxMenuItem checksave
          holds a referrence to the "Autosave" option in the Settings menu
(package private)  javax.swing.JCheckBoxMenuItem checkstat
          holds a referrence to the "Statistical translation" option in the Translations sub-menu from the View menu
(package private)  javax.swing.JCheckBoxMenuItem checksyn
          holds a referrence to the "Dialog-based translation" option in the Translations sub-menu from the View menu
(package private)  MyMenu.MenuAction closeAction
          holds the reference to the close action related to the menu but also the toobarActions
(package private)  java.lang.String command
          used for identifying the command for the menu
(package private)  MyMenu.MenuAction dialogAct
          holds the reference to the action dealing with opening the Dialog Act, done from the menu and also from the toolbarWindows
(package private)  java.util.Vector doc_items
          contains the name of the opened documents.
(package private)  javax.swing.JMenuItem item_spec
          used for constructing the "no files" item in the Documents menu
(package private)  MyMenu.MenuAction judgements
          holds the reference to the action dealing with opening the Judgements Statistics Window, done from the menu and also from the toolbarWindows
(package private)  javax.swing.JMenu menu
          used for constructing the main menu components
(package private)  javax.swing.JMenuBar menubar
          holds the menubar
(package private)  MyMenu.MenuAction openAction
          holds the reference to the "open" action related to the menu but also the toobarActions
(package private)  javax.swing.JMenu options
          used for constructing the sub-menu "Options"
(package private)  MyMenu.MenuAction pattern
          holds the reference to the action dealing with opening the Pattern Window, done from the menu and also from the toolbarWindows
(package private)  MyMenu.MenuAction quitAction
          holds the reference to the quit action related to the menu but also the toobarActions
(package private)  MyMenu.MenuAction recognizedInput
          holds the reference to the action dealing with opening the Recognizer Panel, done from the menu and also from the toolbarWindows
(package private)  MyMenu.MenuAction reloadAction
          holds the reference to the reload action related to the menu but also the toobarActions
(package private)  MyMenu.MenuAction saveAction
          holds the reference to the "save" action related to the menu but also the toobarActions
(package private)  MyMenu.MenuAction saveAsAction
          holds the refference to the "save as" action related to the menu but also the toobarActions
(package private)  javax.swing.JToolBar toolbarActions
          holds the toolbar for the actions in the "File" menu, like Save, close, Open, etc as well as for the other windows related to the main appication: Translation Panel, Recognized Panel etc;
(package private)  MyMenu.MenuAction translations
          holds the reference to the action dealing with opening the Translation Statistics Window, done from the menu and also from the toolbarWindows
(package private)  MyMenu.MenuAction translationWindow
          holds the referrence to the action dealing with opening the Translation Window, done from the menu and also from the toolbarWindows
(package private)  UserInterface ui
          holds a reference to the UserInterface.
 
Constructor Summary
MyMenu(MainFrame application)
          The parameter is an instance of the MainFrame class, needed for getting access to the User interface
 
Method Summary
private  void ActionFromMenu()
          passes to the UserInterface the commands from the menu
 void actionPerformed(java.awt.event.ActionEvent e)
          starts a thread for the actions in the menu
 void addFile(java.lang.String s)
          adds a new menu item to the menu Documents whenever a new file is opened shows that this is the current document by seting the state of the current item to true and of the others to false if a new JCheckBoxMenuItem is created the name of this item is added to the Vector doc_items if the document is only reloaded it sets only the states to the corresponding values ui.newdocument is true if a new document is opened and false otherwise
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 void EnableMenu(boolean enable)
          Depending on the value of the boolean parameter the method enables or disables the operations to be done on a document as opening, closing, saving etc.
 javax.swing.JMenuBar getMenuBar()
          Returns the menubar field
 javax.swing.JToolBar getToolBarActions()
          Returns the first toolbar, concerning the actions in the File menu
 void removeFile(java.lang.String s)
          removes an item from the Document menu, whenever a document is close It also removes the name of the item from the doc_items Vector
 void setSavable(boolean save)
           
 void update()
          sets the items in the Document menu as not selected
 void updateInClose(java.lang.String s)
          updates the Document Menu by setting by opened the document opened before the one closed
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

menubar

javax.swing.JMenuBar menubar
holds the menubar
See Also:
getMenuBar()

toolbarActions

javax.swing.JToolBar toolbarActions
holds the toolbar for the actions in the "File" menu, like Save, close, Open, etc as well as for the other windows related to the main appication: Translation Panel, Recognized Panel etc;
See Also:
getToolBarActions()

menu

javax.swing.JMenu menu
used for constructing the main menu components
See Also:
MyMenu(MainFrame)

options

javax.swing.JMenu options
used for constructing the sub-menu "Options"
See Also:
MyMenu(MainFrame)

change_char

javax.swing.JMenuItem change_char
holds the reference to the "Replace characters" item in the Options sub-menu of the Settings menu

change_frequency

javax.swing.JMenuItem change_frequency
holds the referrence to the "Save every..." option in the Options sub-menu in the Settings menu

item_spec

javax.swing.JMenuItem item_spec
used for constructing the "no files" item in the Documents menu

saveAction

MyMenu.MenuAction saveAction
holds the reference to the "save" action related to the menu but also the toobarActions

openAction

MyMenu.MenuAction openAction
holds the reference to the "open" action related to the menu but also the toobarActions

saveAsAction

MyMenu.MenuAction saveAsAction
holds the refference to the "save as" action related to the menu but also the toobarActions

reloadAction

MyMenu.MenuAction reloadAction
holds the reference to the reload action related to the menu but also the toobarActions

closeAction

MyMenu.MenuAction closeAction
holds the reference to the close action related to the menu but also the toobarActions

quitAction

MyMenu.MenuAction quitAction
holds the reference to the quit action related to the menu but also the toobarActions

translationWindow

MyMenu.MenuAction translationWindow
holds the referrence to the action dealing with opening the Translation Window, done from the menu and also from the toolbarWindows

recognizedInput

MyMenu.MenuAction recognizedInput
holds the reference to the action dealing with opening the Recognizer Panel, done from the menu and also from the toolbarWindows

dialogAct

MyMenu.MenuAction dialogAct
holds the reference to the action dealing with opening the Dialog Act, done from the menu and also from the toolbarWindows

pattern

MyMenu.MenuAction pattern
holds the reference to the action dealing with opening the Pattern Window, done from the menu and also from the toolbarWindows

judgements

MyMenu.MenuAction judgements
holds the reference to the action dealing with opening the Judgements Statistics Window, done from the menu and also from the toolbarWindows

translations

MyMenu.MenuAction translations
holds the reference to the action dealing with opening the Translation Statistics Window, done from the menu and also from the toolbarWindows

checkedit

javax.swing.JCheckBoxMenuItem checkedit
holds a referrence to the "Edit data" option in the Settings menu

automaticCompar

javax.swing.JCheckBoxMenuItem automaticCompar
holds a referrence to the "Selective Save" option in the Settings menu

checksave

javax.swing.JCheckBoxMenuItem checksave
holds a referrence to the "Autosave" option in the Settings menu

checkoriginal

javax.swing.JCheckBoxMenuItem checkoriginal
holds a referrence to the "Original translation" option in the Translations sub-menu from the View menu

checkali

javax.swing.JCheckBoxMenuItem checkali
holds a referrence to the "Case-based translation" option in the Translations sub-menu from the View menu

checkstat

javax.swing.JCheckBoxMenuItem checkstat
holds a referrence to the "Statistical translation" option in the Translations sub-menu from the View menu

checksyn

javax.swing.JCheckBoxMenuItem checksyn
holds a referrence to the "Dialog-based translation" option in the Translations sub-menu from the View menu

checkdeep

javax.swing.JCheckBoxMenuItem checkdeep
holds a referrence to the "Deep Analysis" option in the Translations sub-menu from the View menu

checkpre

javax.swing.JCheckBoxMenuItem checkpre
holds a referrence to the "Preselection" option in the Translations sub-menu from the View menu

ui

UserInterface ui
holds a reference to the UserInterface. It is instantiated only in actionPerformed method and not in the constructor as the menu and the User Interface are created in the same object (MainFrame)
See Also:
actionPerformed(ActionEvent), MyMenu.MenuAction.actionPerformed(ActionEvent)

application

MainFrame application
holds a referrence to the MainFrame class
See Also:
MainFrame

doc_items

java.util.Vector doc_items
contains the name of the opened documents. It is used in the Document menu
See Also:
addFile(String), updateInClose(String), removeFile(String)

command

java.lang.String command
used for identifying the command for the menu
See Also:
MyMenu.MenuAction.actionPerformed(ActionEvent), actionPerformed(ActionEvent)
Constructor Detail

MyMenu

public MyMenu(MainFrame application)
The parameter is an instance of the MainFrame class, needed for getting access to the User interface
See Also:
MainFrame
Method Detail

getMenuBar

public javax.swing.JMenuBar getMenuBar()
Returns the menubar field
See Also:
MainFrame.MainFrame()

getToolBarActions

public javax.swing.JToolBar getToolBarActions()
Returns the first toolbar, concerning the actions in the File menu
See Also:
MainFrame.MainFrame()

EnableMenu

public void EnableMenu(boolean enable)
Depending on the value of the boolean parameter the method enables or disables the operations to be done on a document as opening, closing, saving etc.
Parameters:
enable - is false if no document is opened
enable - is true if at least one document is opened
See Also:
UserInterface.Close()

addFile

public void addFile(java.lang.String s)
adds a new menu item to the menu Documents whenever a new file is opened shows that this is the current document by seting the state of the current item to true and of the others to false if a new JCheckBoxMenuItem is created the name of this item is added to the Vector doc_items if the document is only reloaded it sets only the states to the corresponding values ui.newdocument is true if a new document is opened and false otherwise
Parameters:
s - the name of the file to be added
See Also:
UserInterface.Open(JComponent)

update

public void update()
sets the items in the Document menu as not selected

updateInClose

public void updateInClose(java.lang.String s)
updates the Document Menu by setting by opened the document opened before the one closed
Parameters:
s - the name of the previous opened document
See Also:
UserInterface.Close()

removeFile

public void removeFile(java.lang.String s)
removes an item from the Document menu, whenever a document is close It also removes the name of the item from the doc_items Vector
See Also:
UserInterface.Save()

setSavable

public void setSavable(boolean save)
Parameters:
save - gives information about the current status of the document (if it was saved or not) Depending on this it enables the Save option in the File menu
See Also:
Document, UserInterface

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
starts a thread for the actions in the menu
Specified by:
actionPerformed in interface java.awt.event.ActionListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

ActionFromMenu

private void ActionFromMenu()
passes to the UserInterface the commands from the menu
See Also:
UserInterface.EditData(boolean), UserInterface.setAutosave(boolean), UserInterface.setOutput(int), Document.fireChange(), TranslationPanel.ShowDialog()