com.SoftWoehr.JTOpenContrib.MEU
Class MEUController

java.lang.Object
  |
  +--com.SoftWoehr.JTOpenContrib.MEU.MEUController
All Implemented Interfaces:
ServiceClient

public class MEUController
extends java.lang.Object
implements ServiceClient

Frame ontroller portion of MEU application; centralizes communications between visual components and non-visual entities. There is also a top-level application controller com.SoftWoehr.JTOpenContrib.MEU.MEU


Constructor Summary
MEUController(MEU m)
          Creates new MEUController
 
Method Summary
 void actionClose(java.awt.event.ActionEvent e)
          Close the current frame (warning on save changed)
 void actionSave(java.awt.event.ActionEvent e)
          Save current file member
 void actionScrollAhead(java.awt.event.ActionEvent e)
          Scroll ahead and display
 void actionScrollBack(java.awt.event.ActionEvent e)
          Scroll ahead and display
 void actionSplitJoin(java.awt.event.ActionEvent e)
          Split/Join a line
 void actionToggleFocus(java.awt.event.ActionEvent e)
          Flip focus between command line and text area
 void actionToggleInserting(java.awt.event.ActionEvent e)
          Clear changed and line commands and redisplay
 void beep()
          Beep
 void cleanup()
          Clean up connection stuff
 void clearRedisplaySavingCursor()
          Save cursor and do redisplay
 boolean closeRequested(MEUFrame f)
          An MEUFrame calls this when user tries to close frame.
 void doCommand(java.lang.String commandString)
          Execute a command issued at the editor command line
 void eventClearRedisplay(java.awt.event.KeyEvent e)
          Clear changed and line commands and redisplay
 void eventProcessChanged(java.awt.event.KeyEvent e)
          Process all changed rows
 boolean getAllFrom(com.ibm.as400.access.QSYSObjectPathName pathName)
          Insert records from a user-chosen file member File member must already exist! File must have same record format!
 int getCurPos()
          Get current text area cursor offset
 int getCurrentRowNumber()
          Return the record/row number the cursor is on.
 int getDisplayedRowNumber()
          Return the display row number the cursor is on.
 MEUFrame getFrame()
          Get the frame to which this controller is attached
 java.lang.String getIFSPath()
          Get IFS Path of our file member
 boolean getInserting()
          Return insert mode (true) or typeover (false)
 MEU getMEU()
          Get the top-level application controller
 int getNumberOfRows()
          Return total number of row records
 int getNumberOfRowsDisplayed()
          Return total number of row records
 int getOffsetInSRCDTA(int curpos)
          Returns offset of cursor in srcdta on current line.
 java.lang.String getSRCDTAcontents(int rownum)
          Return SRCDTA contents of a give row/recordnumber
 int getSRCDTAlength()
          Return record field length for SRCDTA
 boolean insertRow()
          Insert row below current row
 boolean isChanged()
          See if file member needs save
protected  void iWantToClose()
          Close, warning for save of changed
 void menuGetAll(java.awt.event.ActionEvent evt)
          Get a file member into the current file member by dialog.
 void menuInsertRow(java.awt.event.ActionEvent evt)
          Insert a new row after the current position.
 void menuNewFileMember(java.awt.event.ActionEvent evt)
          Open file open via dialog in response to a menu item
 void menuOpenFileMember(java.awt.event.ActionEvent evt)
          Open file open via dialog in response to a menu item
 void menuRemoveRow(java.awt.event.ActionEvent evt)
          Delete row at the current position.
 void menuSave(java.awt.event.ActionEvent evt)
          Process changed and save changes to server file member
 void menuSaveAs(java.awt.event.ActionEvent evt)
          Process changed and save under new name by dialog.
 void menuSaveLocal(java.awt.event.ActionEvent evt)
          Save the current buffer as a local text file by dialog.
 void menuSearch(java.awt.event.ActionEvent evt)
          Search for a string.
 void menuSetServer(java.awt.event.ActionEvent evt)
          Set server via a dialog in response to a menu item
 void newEditBuffer(java.lang.String lib, java.lang.String file, java.lang.String member)
          Create a new edit buffer.
 boolean newOnServer(com.ibm.as400.access.QSYSObjectPathName pathName)
          Save records to a user-chosen file member File member must already exist! File must have same record format!
protected  boolean offerGetAll()
          Offer to Save As on server.
 void offerNewFileMember()
          Offer to create a file member and do so if accepted
 void offerOpenFileMember()
          Offer to open a file member and do so if accepted
protected  boolean offerSaveAs()
          Offer to Save As on server.
 boolean offerSaveLocaltext()
          Offer the user to save text format locally.
 boolean offerSearch()
          Offer to open a file member and do so if accepted
 boolean openEditSession(java.lang.String ifsPath)
          Open an edit session if the user doesn't cancel a save/discard of the previous contents
 void processChangedSavingCursor()
          Save cursor and process changes
 void relinquish(ServiceRecord sr)
          Called by a Mgr, this function indicates that a service record supplied earlier by the MGr to the ServiceClient instance will no longer be valid after this call completes.
 boolean removeRow()
          Remove the row at current cursor in the display
 boolean removeRow(int displayRowNum)
          Remove a specific row/record by its visual display row number
 boolean requestShutdown(MEUFrame f)
          Iterate through frames requesting shutdown.
 int rowNumberToRecordNumber(int rownum)
          Convert a display row number to an absolute row/record number.
 boolean saveAsToServer(com.ibm.as400.access.QSYSObjectPathName pathName)
          Save records to a user-chosen file member.
 boolean saveToServer()
          If changed, write back to the server.
 boolean saveToServer(boolean forceWrite)
          Write back to the server if changed or forced True on success.
 void setCurPos(int pos)
          Set current cursort pos to wrapped cursor pos offered.
 void setDefaultServer()
          Look up the default and set the server accordingly.
 void setEditingEnabled(boolean enabled)
          Enable/disable text editing
 void setFrame(MEUFrame f)
          Set the frame we're associated with
 void setOffsetInSRCDTA(int offset)
          Move cursor on a line
 void setServer(java.lang.String server)
          Set the server (i.e., do setSystem) safely, dialoging where necessary.
 void textAreaFocus()
          Transfer the focus for the text area
 void toggleFocus()
          Flip focus between command line and text area
 boolean toggleInserting()
          Toggle the insert mode flag
 boolean writeLocaltext(java.io.File f)
          Write the member out to a local file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MEUController

public MEUController(MEU m)
Creates new MEUController
Method Detail

getMEU

public MEU getMEU()
Get the top-level application controller

setServer

public void setServer(java.lang.String server)
Set the server (i.e., do setSystem) safely, dialoging where necessary.

setDefaultServer

public void setDefaultServer()
Look up the default and set the server accordingly. Frame must be set first because set server changes title.

relinquish

public void relinquish(ServiceRecord sr)
Called by a Mgr, this function indicates that a service record supplied earlier by the MGr to the ServiceClient instance will no longer be valid after this call completes.
Specified by:
relinquish in interface ServiceClient
Parameters:
sr - The service record which the Mgr is indicating will no longer be valid after the relinquish completes.

getFrame

public MEUFrame getFrame()
Get the frame to which this controller is attached

setFrame

public void setFrame(MEUFrame f)
Set the frame we're associated with

getDisplayedRowNumber

public int getDisplayedRowNumber()
Return the display row number the cursor is on.

rowNumberToRecordNumber

public int rowNumberToRecordNumber(int rownum)
Convert a display row number to an absolute row/record number. -1 would equal "start of data" line and row == getNumberOfRecords === "end of data" line.

getCurrentRowNumber

public int getCurrentRowNumber()
Return the record/row number the cursor is on. -1 means the start-of-data line

getOffsetInSRCDTA

public int getOffsetInSRCDTA(int curpos)
Returns offset of cursor in srcdta on current line. Floored at zero, max is srcdta length.

setOffsetInSRCDTA

public void setOffsetInSRCDTA(int offset)
Move cursor on a line

getCurPos

public int getCurPos()
Get current text area cursor offset

setCurPos

public void setCurPos(int pos)
Set current cursort pos to wrapped cursor pos offered.

setEditingEnabled

public void setEditingEnabled(boolean enabled)
Enable/disable text editing

getInserting

public boolean getInserting()
Return insert mode (true) or typeover (false)

toggleInserting

public boolean toggleInserting()
Toggle the insert mode flag

toggleFocus

public void toggleFocus()
Flip focus between command line and text area

textAreaFocus

public void textAreaFocus()
Transfer the focus for the text area

getIFSPath

public java.lang.String getIFSPath()
Get IFS Path of our file member

isChanged

public boolean isChanged()
See if file member needs save

getNumberOfRows

public int getNumberOfRows()
Return total number of row records

getNumberOfRowsDisplayed

public int getNumberOfRowsDisplayed()
Return total number of row records

getSRCDTAlength

public int getSRCDTAlength()
Return record field length for SRCDTA

getSRCDTAcontents

public java.lang.String getSRCDTAcontents(int rownum)
Return SRCDTA contents of a give row/recordnumber

insertRow

public boolean insertRow()
Insert row below current row

removeRow

public boolean removeRow(int displayRowNum)
Remove a specific row/record by its visual display row number

removeRow

public boolean removeRow()
Remove the row at current cursor in the display

newEditBuffer

public void newEditBuffer(java.lang.String lib,
                          java.lang.String file,
                          java.lang.String member)
Create a new edit buffer. System must be instanced first

saveToServer

public boolean saveToServer()
If changed, write back to the server. True on success. Called from the menu Save selection and from doCommandSAVE

saveToServer

public boolean saveToServer(boolean forceWrite)
Write back to the server if changed or forced True on success. Force write if (boolean forceWrite). Called from the menu Save selection and from doCommandSAVE

saveAsToServer

public boolean saveAsToServer(com.ibm.as400.access.QSYSObjectPathName pathName)
Save records to a user-chosen file member.

newOnServer

public boolean newOnServer(com.ibm.as400.access.QSYSObjectPathName pathName)
Save records to a user-chosen file member File member must already exist! File must have same record format!

getAllFrom

public boolean getAllFrom(com.ibm.as400.access.QSYSObjectPathName pathName)
Insert records from a user-chosen file member File member must already exist! File must have same record format!

writeLocaltext

public boolean writeLocaltext(java.io.File f)
Write the member out to a local file

openEditSession

public boolean openEditSession(java.lang.String ifsPath)
Open an edit session if the user doesn't cancel a save/discard of the previous contents

offerNewFileMember

public void offerNewFileMember()
Offer to create a file member and do so if accepted

offerOpenFileMember

public void offerOpenFileMember()
Offer to open a file member and do so if accepted

offerSaveAs

protected boolean offerSaveAs()
Offer to Save As on server. Return true if successful.

offerGetAll

protected boolean offerGetAll()
Offer to Save As on server. Return true if successful.

offerSaveLocaltext

public boolean offerSaveLocaltext()
Offer the user to save text format locally. Return true if completed.

offerSearch

public boolean offerSearch()
Offer to open a file member and do so if accepted

clearRedisplaySavingCursor

public void clearRedisplaySavingCursor()
Save cursor and do redisplay

processChangedSavingCursor

public void processChangedSavingCursor()
Save cursor and process changes

menuNewFileMember

public void menuNewFileMember(java.awt.event.ActionEvent evt)
Open file open via dialog in response to a menu item

menuOpenFileMember

public void menuOpenFileMember(java.awt.event.ActionEvent evt)
Open file open via dialog in response to a menu item

menuSetServer

public void menuSetServer(java.awt.event.ActionEvent evt)
Set server via a dialog in response to a menu item

menuSave

public void menuSave(java.awt.event.ActionEvent evt)
Process changed and save changes to server file member

menuSaveAs

public void menuSaveAs(java.awt.event.ActionEvent evt)
Process changed and save under new name by dialog.

menuGetAll

public void menuGetAll(java.awt.event.ActionEvent evt)
Get a file member into the current file member by dialog.

menuSaveLocal

public void menuSaveLocal(java.awt.event.ActionEvent evt)
Save the current buffer as a local text file by dialog.

menuInsertRow

public void menuInsertRow(java.awt.event.ActionEvent evt)
Insert a new row after the current position.

menuRemoveRow

public void menuRemoveRow(java.awt.event.ActionEvent evt)
Delete row at the current position.

menuSearch

public void menuSearch(java.awt.event.ActionEvent evt)
Search for a string.

eventClearRedisplay

public void eventClearRedisplay(java.awt.event.KeyEvent e)
Clear changed and line commands and redisplay

eventProcessChanged

public void eventProcessChanged(java.awt.event.KeyEvent e)
Process all changed rows

actionToggleFocus

public void actionToggleFocus(java.awt.event.ActionEvent e)
Flip focus between command line and text area

actionScrollAhead

public void actionScrollAhead(java.awt.event.ActionEvent e)
Scroll ahead and display

actionScrollBack

public void actionScrollBack(java.awt.event.ActionEvent e)
Scroll ahead and display

actionSplitJoin

public void actionSplitJoin(java.awt.event.ActionEvent e)
Split/Join a line

actionToggleInserting

public void actionToggleInserting(java.awt.event.ActionEvent e)
Clear changed and line commands and redisplay

actionSave

public void actionSave(java.awt.event.ActionEvent e)
Save current file member

actionClose

public void actionClose(java.awt.event.ActionEvent e)
Close the current frame (warning on save changed)

doCommand

public void doCommand(java.lang.String commandString)
Execute a command issued at the editor command line

beep

public void beep()
Beep

iWantToClose

protected void iWantToClose()
Close, warning for save of changed

closeRequested

public boolean closeRequested(MEUFrame f)
An MEUFrame calls this when user tries to close frame. MEUController checks if anything needs saving (or if user decides to cancel). Then if all is still go, forwards close request to application controller (class MEU).

requestShutdown

public boolean requestShutdown(MEUFrame f)
Iterate through frames requesting shutdown. If all approve (true), i.e., if the user doesn't CANCEL on a "Save?" requester, go ahead and have each frame cleanup, dispose each frame, delete the heck out of them as well as one can, all this to make sure connection resources etc. are returned. Then System.exit(some result);

cleanup

public void cleanup()
Clean up connection stuff