All Packages  Class Hierarchy  This Package  Previous  Next  

Class wingsoft.editor.Main

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Frame
                                   |
                                   +----wingsoft.editor.Main

public class Main
extends Frame
implements EditorConst, Constants
The Main class is used to construct WingEditor's main window. Just like most of editors, the editor window in WingEditor consists of 5 parts, * Menu Bar * Button Bar * Scrolling Window * Status Bar * Footer


Constructor Index

 o Main(String)
Construct an editor window and load the file into the window.
 o Main(String, Dimension)
Construct an editor window with specified size and load the file into the window.
 o Main(String, int)
Construct an editor window and load the file into the window.
 o Main(String, int, Dimension)
Construct an editor window with specified size and load the file into the window.
 o Main(String, int[])
Construct an editor window with standard size and load the file into the window.
 o Main(String, int[], Dimension)
Construct an editor window with specified size and load the file into the window.

Method Index

 o appendMenu(Menu)
Append a menu to the existing menu bar.
 o appendMenu(Menu[])
Append a set of menus to the existing menu bar.
 o appendMenuItem(MenuItem, int)
Append a user-defined MenuItem to an existing Menu.
 o appendMenuItems(MenuItem[], int)
Append a set of user-defined MenuItems to an existing Menu.
 o bufferChanged()
Whether the buffer has been modified.
 o closeMain()
Close this window, if the buffer is not saved yet, save the buffer.
 o getClipBoard()
Get the clip board.
 o getCurrentLocation()
Get the current line where the cursor appears.
 o getEditor(String, boolean)
This method is to get a Editor Window with the file.
 o getFileName()
Get the name of the file under editing.
 o getSelectedString()
Get the selected String.
 o getTextAtLine(int)
Get the string at a specific line.
 o gotoLocation(int)
Move the cursor to the line.
 o handleEvent(Event)
Standard handleEvent.
 o layoutMain()
Layout the Editor Window.
 o loadFile(String)
Load the file into the current window.
 o postFooter(String)
Post a note at this window's footer
 o quitMain()
Quit this window, if the buffer is not saved yet, it will be discarded.
 o replaceString(String, String)
Replace string1 with string2.
 o saveFile(String)
Save the buffer to the file.
 o setClipBoard(String)
Set the clip board.
 o setColorLine(int)
Set a mark at the specified line.
 o setUserButtonBar(UserButton[])
Create a customerized button bar.
 o setUserButtonBar(UserButton[], boolean)
Create a customerized button bar.

Constructors

 o Main
 public Main(String file)
Construct an editor window and load the file into the window. The cursor will stop at the first line of the file.

Parameters:
file - the file to be loaded, null for new file
 o Main
 public Main(String file,
             Dimension size)
Construct an editor window with specified size and load the file into the window. The cursor will stop at the first line of the file.

Parameters:
file - the file to be loaded initially, null for new file
size - the window size
 o Main
 public Main(String file,
             int offMenu[])
Construct an editor window with standard size and load the file into the window. The cursor will stop at the first line of the file. Turn off some menus specified by offMenu on the menu bar.

Parameters:
file - the file to be loaded initially, null for new file
offMenu - the menus being turned off, the menu number should be less than the EditorConst.TOTAL_MENU.
 o Main
 public Main(String file,
             int offMenu[],
             Dimension size)
Construct an editor window with specified size and load the file into the window. The cursor will stop at the first line of the file. Turn off some menus specified by offMenu on the menu bar.

Parameters:
file - the file to be loaded initially, null for new file
offMenu - the menus being turned off, the menu number should be less than the EditorConst.TOTAL_MENU.
size - the window size
 o Main
 public Main(String file,
             int line)
Construct an editor window and load the file into the window. The cursor will stop at the line of the file.

Parameters:
file - the file to be loaded
line - the line the cursor will appear
 o Main
 public Main(String file,
             int line,
             Dimension size)
Construct an editor window with specified size and load the file into the window. The cursor will stop at the line of the file.

Parameters:
file - the file to be loaded
line - the line the cursor will appear
size - the window size

Methods

 o layoutMain
 public void layoutMain()
Layout the Editor Window. This method should be called after UserButtonBar is set, and userMenus or userMenuItems are set.

 o appendMenu
 public void appendMenu(Menu userMenu)
Append a menu to the existing menu bar.

Parameters:
userMenu - the user-defined menu
 o appendMenu
 public void appendMenu(Menu userMenus[])
Append a set of menus to the existing menu bar.

Parameters:
userMenus - the user-defined menus
 o appendMenuItem
 public void appendMenuItem(MenuItem userMenuItem,
                            int menuNumber)
Append a user-defined MenuItem to an existing Menu. The MenuNumber should be in the range between 0 and EditorConst.TOTAL_MENU.

Parameters:
userMenuItem - the user-defined menu item
MenuNumber - the existing menu
 o appendMenuItems
 public void appendMenuItems(MenuItem userMenuItems[],
                             int menuNumber)
Append a set of user-defined MenuItems to an existing Menu. The MenuNumber should be in the range between 0 and EditorConst.TOTAL_MENU.

Parameters:
userMenuItems - the user-defined menu items
MenuNumber - the existing menu
 o getEditor
 protected Main getEditor(String file,
                          boolean must)
This method is to get a Editor Window with the file. If the Editor Window exists, return the Editor Window, otherwise, if must is true, create an Editor Window with the file loaded, else return null

Parameters:
file - the file
must - marks whether an editor window will be created if the window does not exist.
 o getFileName
 public String getFileName()
Get the name of the file under editing.

 o saveFile
 public void saveFile(String file)
Save the buffer to the file.

Parameters:
file - the file to save to
 o gotoLocation
 public void gotoLocation(int line)
Move the cursor to the line.

Parameters:
line - the line number
 o getCurrentLocation
 public int getCurrentLocation()
Get the current line where the cursor appears.

 o setColorLine
 public void setColorLine(int line)
Set a mark at the specified line.

Parameters:
line - the line number
 o getSelectedString
 public String getSelectedString()
Get the selected String.

 o getClipBoard
 public String getClipBoard()
Get the clip board.

 o setClipBoard
 public void setClipBoard(String string)
Set the clip board.

Parameters:
string - the string to put on clip board.
 o replaceString
 public void replaceString(String string1,
                           String string2)
Replace string1 with string2.

Parameters:
string1 - the old string
string2 - the new string
 o getTextAtLine
 public String getTextAtLine(int line)
Get the string at a specific line.

Parameters:
line - the line
 o loadFile
 public void loadFile(String file)
Load the file into the current window.

Parameters:
file - the file
 o setUserButtonBar
 public void setUserButtonBar(UserButton buttons[],
                              boolean replace)
Create a customerized button bar.

Parameters:
buttons - the user-defined button that implement UserButton interface.
replace - true to replace the existing button bar, false to append to existing button bar.
 o setUserButtonBar
 public void setUserButtonBar(UserButton buttons[])
Create a customerized button bar.

Parameters:
buttons - the user-defined button that implement UserButton interface.
 o handleEvent
 public boolean handleEvent(Event event)
Standard handleEvent.

Overrides:
handleEvent in class Component
 o postFooter
 public synchronized void postFooter(String s)
Post a note at this window's footer

 o bufferChanged
 public boolean bufferChanged()
Whether the buffer has been modified.

 o closeMain
 public void closeMain()
Close this window, if the buffer is not saved yet, save the buffer.

 o quitMain
 public void quitMain()
Quit this window, if the buffer is not saved yet, it will be discarded.


All Packages  Class Hierarchy  This Package  Previous  Next