ex1
Class OprnTableModel

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byex1.OprnTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class OprnTableModel
extends javax.swing.table.AbstractTableModel

This the model for delivering data to the main operations table view. This handles loading the operations_defn.xml file and the operations_lang.xml file. The operations_defn.xml file contains the following information that is stored: - name of the parameter - type of the parameter, float, int, etc - default units for the value

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
OprnTableModel(java.lang.String cfgDir, java.lang.String dbMainDir)
          Create the table model for the main part of operations
 
Method Summary
 void addBlankOperation(java.lang.String name)
          This adds an empty operations file to the table.
 void addXmlFile(java.lang.String file)
          This adds an XML data file to the table model
 boolean changeProcess(int row, int procNum, int newProc)
          Changes the process type within a row to new process
 boolean checkOneOperation(int row, boolean display)
          This function checks the process order for one file.
 void checkProcesses(boolean display)
          Checks the process order for all files and marks any that are in error.
 void computeRowInfo(int tab)
          This function updates the row mapping info for one detail table.
 void computeRowMaps()
          This function causes all row mapping to be updated for all detail tables.
 void copyOperation(java.lang.String name, int row)
          This copies an existing operation and gives it a new name.
 boolean deleteOperation(int row)
          Delete the operation on the specified row.
 boolean deleteProcess(int row, int procNum)
          Delete process from a specific row.
 java.lang.String getActionName(int ind)
          Get the name of a specific action
 int getActionNameCount()
          Get the number of different process names
 java.lang.String getChangedFiles()
          Get a list of all the files that have been changed
 java.lang.String getChoice(int ch)
          Get the name of a specific choice.
 int getChoiceCount()
          Get number of choice entries for a cell
 java.lang.Class getColumnClass(int c)
          Class of data in column
 int getColumnCount()
          This returns the number of columns in the main operations panel view.
 java.lang.String getColumnName(int col)
          Get the name of the column of the main operations screen, very generic.
 int getColumnType(int col)
          This gets the column type in the main operations table.
 boolean getEdit()
          Get if any changes can be made.
 WepsDBFile getFile(int row)
          Get the file structure associated with a specific row.
 java.lang.String getFileName(int row)
          This gets the file name (short version for the operations record on a specified row.
 java.lang.String getFilePath(int row)
          Get the full path name of the file for a specific row.
 java.lang.String getFilePathOnly(int row)
          Get the path only part of the file for a specific row This is used to fill in the directory portion of the table
 java.lang.String getFullActionName(int ind)
          Get the full name of a specific action.
 int getLogicalRow(int tab, int row)
          This gets the row in the main operation table that a specific row in a detail table correspnds to.
 int getLogicalSub(int tab, int row)
          This gets the sub-index for a process in a detail table.
 DefnFileParser getParmInfo()
          Get structure holding all the parameters loaded
 int getRowCount()
          Number of rows in the main operations table which is the same as the number of files loaded.
 int getRowCount(int tab)
          Return the number of rows this view/process has.
 java.lang.Object getValueAt(int row, int col)
          Returns the name of a process at a particular position.
 java.lang.Object getValueAt(int tab, int row, int col)
          This gets the value of a cell for a detailed operations table - a specific tab and then the row+column within the tab.
 WepsDBFile getXmlFile(int row)
          This returns the structure holding all information about the file on a specific row.
 boolean insertProcess(int row, int procNum, int newProc, boolean before)
          Insert a new process int the operation.
 boolean isCellEditable(int row, int col)
           
 boolean isModified()
          This function checks if any of the files have been modified.
 boolean isModified(int row)
          Check if the file on a specific row has been modified
 boolean isReadOnly(int row)
          This checks if the file associated with a specific row is read-only
 void moveProcess(int row, int col, boolean isRight)
          This will shift/move an existing process in the process order
 boolean outOfOrder(int row)
          Checks if the processes for a specific row are out-of-order
 void renameOperation(java.lang.String name, int row)
          Renames an existing operation to a new name.
 void saveAll()
          This calls a save function for all files that have been modified.
 boolean saveFile(int row)
          Saves the file at the specified row
 void setAltUnits(boolean val)
          Sets whether alternate units will be used when retreiving or storing data.
 void setEdit(boolean val)
          Set if this is generally to allow changes
 void setValueAt(java.lang.Object o, int tab, int row, int col)
          Save the value of a cell for a detailed operations table.
 void setXmlFiles(java.util.ArrayList li)
          After sorting update the file list order by reseting the array.
 void sort(int col, int status)
          This sorts the rows based on the contents of a specific column.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OprnTableModel

public OprnTableModel(java.lang.String cfgDir,
                      java.lang.String dbMainDir)
Create the table model for the main part of operations

Parameters:
cfgDir - directory where mcrew config files are located
dbMainDir - directory where data files are located
Method Detail

getColumnCount

public int getColumnCount()
This returns the number of columns in the main operations panel view. The number of columns is the maximum of all loaded file process counts plus the NUM,NAME,DIRECTORY columns and one blank column.

Returns:
number of columns in main operations tale

getRowCount

public int getRowCount()
Number of rows in the main operations table which is the same as the number of files loaded.

Returns:
number of rows in main operations table

getRowCount

public int getRowCount(int tab)
Return the number of rows this view/process has. This may be different between the table tabs if a file has a process that appears more than once.

Parameters:
tab - index of sub/detail/process table to get row count for
Returns:
number of rows in this process table

setEdit

public void setEdit(boolean val)
Set if this is generally to allow changes

Parameters:
val - true if changes are allowed

getEdit

public boolean getEdit()
Get if any changes can be made.


computeRowMaps

public void computeRowMaps()
This function causes all row mapping to be updated for all detail tables. The row maps contain links between a detail row info and the operation it is realted to. For example row 12 in a detail might link to the operation on row 10 of the main table.


computeRowInfo

public void computeRowInfo(int tab)
This function updates the row mapping info for one detail table.


setAltUnits

public void setAltUnits(boolean val)
Sets whether alternate units will be used when retreiving or storing data.

Parameters:
val - true if alternate(english) units should be used.

getColumnName

public java.lang.String getColumnName(int col)
Get the name of the column of the main operations screen, very generic.

Parameters:
col - the column to get the name for
Returns:
the name used for the column

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Returns the name of a process at a particular position.

Parameters:
row - the row to get process name for
col - the column to get process name for
Returns:
the string representing the value

getValueAt

public java.lang.Object getValueAt(int tab,
                                   int row,
                                   int col)
This gets the value of a cell for a detailed operations table - a specific tab and then the row+column within the tab.

Parameters:
tab - the specific detail table to get value from
row - the row to get value from
col - the column to get value from

setValueAt

public void setValueAt(java.lang.Object o,
                       int tab,
                       int row,
                       int col)
Save the value of a cell for a detailed operations table.

Parameters:
o - value to store (a string)
tab - detail table from value came from
row - row in detail table value came from
col - column in detail table value came from

getLogicalRow

public int getLogicalRow(int tab,
                         int row)
This gets the row in the main operation table that a specific row in a detail table correspnds to.

Parameters:
tab - detail table index
row - row in detail table
Returns:
row in main operations table that has operation

getLogicalSub

public int getLogicalSub(int tab,
                         int row)
This gets the sub-index for a process in a detail table. If an operation has Several processes of the same type they are ordered as 0,1,2,etc based on the row of the detail table this returns the sub-index of the row (what index within a group of the same processes this row corresponds to)

Parameters:
tab - detail table index
row - row in detail table
Returns:
what index within a group of the same processes this row corresponds to

getColumnType

public int getColumnType(int col)
This gets the column type in the main operations table.

Parameters:
col - column to get type for
Returns:
type of data in this column

getColumnClass

public java.lang.Class getColumnClass(int c)
Class of data in column

Parameters:
c - column to inspect
Returns:
type of data (all are Strings)

isCellEditable

public boolean isCellEditable(int row,
                              int col)

getChoiceCount

public int getChoiceCount()
Get number of choice entries for a cell

Returns:
number of process types.

getChoice

public java.lang.String getChoice(int ch)
Get the name of a specific choice.

Parameters:
ch - index of choice array to return
Returns:
choice at index as a string

addXmlFile

public void addXmlFile(java.lang.String file)
This adds an XML data file to the table model

Parameters:
file - name of the operations file to add

getXmlFile

public WepsDBFile getXmlFile(int row)
This returns the structure holding all information about the file on a specific row.

Parameters:
row - row of operations table to get info about
Returns:
the structure holding all info about the file

setXmlFiles

public void setXmlFiles(java.util.ArrayList li)
After sorting update the file list order by reseting the array.

Parameters:
li - new list of ordered file info objects

getActionNameCount

public int getActionNameCount()
Get the number of different process names

Returns:
the number of process names

getActionName

public java.lang.String getActionName(int ind)
Get the name of a specific action

Parameters:
ind - what index to get the name for
Returns:
the process name at that index

getFullActionName

public java.lang.String getFullActionName(int ind)
Get the full name of a specific action. This has the process number on the fron

Parameters:
ind - what index to get the name for
Returns:
the full process name at that index

getParmInfo

public DefnFileParser getParmInfo()
Get structure holding all the parameters loaded

Returns:
the DefnFileParser structure which holds all parameters

getChangedFiles

public java.lang.String getChangedFiles()
Get a list of all the files that have been changed

Returns:
list of files seperated by newlines

isModified

public boolean isModified()
This function checks if any of the files have been modified.

Returns:
true if any file is changed, false if there have been no changes.

isModified

public boolean isModified(int row)
Check if the file on a specific row has been modified

Parameters:
row - row to check for a modified file
Returns:
true if the file on this row was modified.

saveAll

public void saveAll()
This calls a save function for all files that have been modified.


getFileName

public java.lang.String getFileName(int row)
This gets the file name (short version for the operations record on a specified row.

Parameters:
row - row to get filename from
Returns:
filename (short) corresponding to this row.

getFilePath

public java.lang.String getFilePath(int row)
Get the full path name of the file for a specific row.

Parameters:
row - row to get filename from
Returns:
full filename (directory + base + extension)

getFilePathOnly

public java.lang.String getFilePathOnly(int row)
Get the path only part of the file for a specific row This is used to fill in the directory portion of the table

Parameters:
row - row to get file path from
Returns:
path part of file relative to main db directory

addBlankOperation

public void addBlankOperation(java.lang.String name)
This adds an empty operations file to the table.

Parameters:
name - name of the new file.

copyOperation

public void copyOperation(java.lang.String name,
                          int row)
This copies an existing operation and gives it a new name.

Parameters:
name - name of new operation
row - base row that source is found on

renameOperation

public void renameOperation(java.lang.String name,
                            int row)
Renames an existing operation to a new name.

Parameters:
name - new name of operation
row - row that is being changed

deleteOperation

public boolean deleteOperation(int row)
Delete the operation on the specified row.

Parameters:
row - row to be deleted
Returns:
true if the operation was deleted successfully

deleteProcess

public boolean deleteProcess(int row,
                             int procNum)
Delete process from a specific row.

Parameters:
row - row number that delete will occur on
procNum - index of process within row that will be deleted.
Returns:
true if the process could be deleted.

changeProcess

public boolean changeProcess(int row,
                             int procNum,
                             int newProc)
Changes the process type within a row to new process

Parameters:
row - row that process belongs to
procNum - index of process that is to be changed
newProc - index of new process in processes array

insertProcess

public boolean insertProcess(int row,
                             int procNum,
                             int newProc,
                             boolean before)
Insert a new process int the operation.

Parameters:
row - row that process will be added to
procNum - index of process to be changed
newProc - type of new process to be added
before - true if new process is before existing, or false if after
Returns:
true if new process could be added

getFile

public WepsDBFile getFile(int row)
Get the file structure associated with a specific row.

Parameters:
row - row to get file info for
Returns:
structure holding all info about the file

saveFile

public boolean saveFile(int row)
Saves the file at the specified row

Parameters:
row - row to save file from
Returns:
true if file saved ok

moveProcess

public void moveProcess(int row,
                        int col,
                        boolean isRight)
This will shift/move an existing process in the process order

Parameters:
row - row that process belongs to
col - column of process to shift
isRight - true if data should be shofted right, false for left

checkProcesses

public void checkProcesses(boolean display)
Checks the process order for all files and marks any that are in error.

Parameters:
display - true if error messages are to be displayed

outOfOrder

public boolean outOfOrder(int row)
Checks if the processes for a specific row are out-of-order

Parameters:
row - row to check process order
Returns:
true if process order has an error, false if ok

checkOneOperation

public boolean checkOneOperation(int row,
                                 boolean display)
This function checks the process order for one file.

Parameters:
row - row of table to check
display - true if any errors are to be displayed
Returns:
true if order incorrect, false if ok

sort

public void sort(int col,
                 int status)
This sorts the rows based on the contents of a specific column.

Parameters:
col - column to sort
status - ascending, descending or nothing

isReadOnly

public boolean isReadOnly(int row)
This checks if the file associated with a specific row is read-only

Parameters:
row - row to check for read-only properties
Returns:
true if row is read-only, false if changes allowed.