Compiere 3.1

org.compiere.model
Class GridTab

java.lang.Object
  extended by org.compiere.model.GridTab
All Implemented Interfaces:
Serializable, EventListener, DataStatusListener, Evaluatee

public class GridTab
extends Object
implements DataStatusListener, Evaluatee, Serializable

Tab Model. - a combination of AD_Tab (the display attributes) and AD_Table information.

The Tab owns also it's Table model and listens to data changes to update the Field values.

The Tab maintains the bound property: CurrentRow

  Event Hierarchies:
      - dataChanged (from MTable)
          - setCurrentRow
              - Update all Field Values

      - setValue
          - Update Field Value
          - Callout
  

Version:
$Id: GridTab.java,v 1.10 2006/10/02 05:18:39 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Field Summary
protected  CLogger log
          Logger
protected  EventListenerList m_listenerList
          A list of event listeners for this component.
static String PROPERTY
          Property Change Type
 
Constructor Summary
GridTab(GridTabVO vo, int onlyCurrentDays)
          Create Tab (Model) from Value Object.
 
Method Summary
 void addDataStatusListener(DataStatusListener l)
           
 void addPropertyChangeListener(PropertyChangeListener l)
           
 boolean canHaveAttachment()
          Can this tab have Attachments?.
 boolean dataDelete()
          Delete current Row
 void dataIgnore()
          Ignore data changes
 boolean dataNew(boolean copy)
          Create (copy) new Row and process Callouts
 void dataRefresh()
          Refresh current row data
 void dataRefresh(int row)
          Refresh row data
 void dataRefreshAll()
          Refresh all data
 boolean dataSave(boolean manualCmd)
          Uncoditionally Save data
 void dataStatusChanged(DataStatusEvent e)
          Data Status Listener from MTable
protected  void dispose()
          Dispose - clean up resources
 void enableEvents()
          Enable Events - enable data events of tabs (add listeners)
 int findColumn(String columnName)
          Find Column
protected  void fireDataStatusEEvent(String AD_Message, String info, boolean isError)
          Create and fire Data Status Error Event
protected  void fireDataStatusEEvent(ValueNamePair errorLog)
          Create and fire Data Status Error Event (from Error Log)
 String get_ValueAsString(String variableName)
          Get Variable Value (Evaluatee)
 int getAD_AttachmentID()
          Get Attachment_ID for current record.
 int getAD_Client_ID()
          Get Current Table AD_Client_ID
 int getAD_ColumnSortOrder_ID()
          Get Order column for sort tab
 int getAD_ColumnSortYesNo_ID()
          Get Yes/No column for sort tab
 int getAD_Process_ID()
          Get Process ID
 int getAD_Tab_ID()
          Get Tab ID
 int getAD_Table_ID()
          Get Table ID
 int getAD_Window_ID()
          Get Window ID
 int getCM_ChatID()
          Get Chat_ID for this record.
 String getCommitWarning()
          Get Commit Warning
 int getCurrentRow()
          Get Current Row
 ArrayList<GridField> getDependantFields(String columnName)
          Get dependents fields of columnName
 ArrayList<String> getDependentOn()
          Get a list of variables, this tab is dependent on
 String getDescription()
          Get Description of Tab
 String getDisplayLogic()
          Get Display Logic
 GridField getField(int index)
          Get Field by index
 GridField getField(String columnName)
          Get Field by DB column name
 int getFieldCount()
          Get Column/Field Count
 GridField[] getFields()
          Get all Fields
 String getHelp()
          Get Help of Tab
 Icon getIcon()
          Get Tab Icon
 int getIncluded_Tab_ID()
          Get Included Tab ID
 String getKeyColumnName()
          Return the name of the key column - may be ""
 int getKeyID(int row)
          Get Key ID of row
 String getLinkColumnName()
          Return Name of link column
protected  GridTable getMTable()
          Return Table Model
 String getName()
          Get Name of Tab
 int getOnlyCurrentDays()
          Get Only Current Days
 ArrayList<String> getParentColumnNames()
          Return Parent ArrayList
 Query getQuery()
          Get Query
 int getRecord_ID()
          Get Current Table Key ID
 int getRowCount()
          Get RowCount
 GridTable getTableModel()
          Get TableModel.
 String getTableName()
          Get TableName
 int getTabLevel()
          Get Tab Level
 int getTabNo()
          Get TabNo
 String getTrxInfo()
          Transaction support.
 Object getValue(GridField field)
          Get Value of Field
 Object getValue(int row, String columnName)
          Get Value of Field in row
 Object getValue(String columnName)
          Get Value of Field with columnName
 String getWhereClause()
          Get Tab Where Clause
 String getWhereExtended()
          Get extended Where Clause (parent link)
 int getWindowNo()
          Get WindowNo
 boolean hasAttachment()
          Returns true, if current row has an Attachment
 boolean hasChat()
          Returns true, if current row has a Chat
 boolean hasDependants(String columnName)
          Has this field dependents ?
protected  boolean initTab(boolean async)
          Initialize Tab with record from AD_Tab_v
 boolean isAlwaysUpdateField()
          Tab contains Always Update Field
 boolean isCurrent()
          Is the tab current?.
 boolean isDetail()
          Returns true if this is a detail record
 boolean isDisplayed(boolean initialSetup)
          Is the Tab Visible.
 boolean isHighVolume()
          Is High Volume?
 boolean isIncluded()
          Is Tab Incluced in other Tab
 boolean isInsertRecord()
          Can we Insert Records?
 boolean isLocked()
          Record Is Locked
 boolean isOpen()
          Is the tab/table currently open
 boolean isPrinted()
          Is Printed (Document can be printed)
 boolean isProcessed()
          Is Processed
 boolean isQueryActive()
          Is Query Active
 boolean isQueryNewRecord()
          Is Query New Record
 boolean isReadOnly()
          Is Read Only?
 boolean isSingleRow()
          Is Single Row
 boolean isSortTab()
          Is Sort Tab
 boolean isTreeTab()
          Has Tree
 void loadAttachments()
          Load Attachments for this table
 void loadChats()
          Load Chats for this table
 void loadLocks()
          Load Locks for Table and User
 void lock(Ctx ctx, int Record_ID, boolean lock)
          Lock Record
 int navigate(int targetRow)
          Navigate absolute - goto Row - (zero based)
 int navigateCurrent()
          Navigate to current now (reload)
 int navigateRelative(int rowChange)
          Navigate relatively - i.e. plus/minus from current position
 boolean needSave(boolean rowChange, boolean onlyRealChange)
          Do we need to Save?
 String processFieldChange(GridField changedField)
          Process Field Change - evaluate Dependencies and process Callouts.
 void query(int onlyCurrentDays)
          Assemble whereClause and query MTable and position to row 0.
 boolean query(int onlyCurrentDays, int maxRows, boolean created)
          Assemble whereClause and query MTable and position to row 0.
 void removeDataStatusListener(DataStatusListener l)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void setIncluded(boolean isIncluded)
          Is Tab Incluced in other Tab
 void setLinkColumnName(String linkColumnName)
          Set Name of link column.
 void setQuery(Query query)
          Set Query
 void setSingleRow(boolean isSingleRow)
          Set Single Row.
 String setValue(GridField field, Object value)
          Set New Value & call Callout
 String setValue(String columnName, Object value)
          Set New Value & call Callout
 String toString()
          toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY

public static final String PROPERTY
Property Change Type

See Also:
Constant Field Values

m_listenerList

protected EventListenerList m_listenerList
A list of event listeners for this component.


log

protected CLogger log
Logger

Constructor Detail

GridTab

public GridTab(GridTabVO vo,
               int onlyCurrentDays)
Create Tab (Model) from Value Object.

MTab provides a property listener for changed rows and a DataStatusListener for communicating changes of the underlying data

Parameters:
vo - Value Object
onlyCurrentDays - only current days
Method Detail

initTab

protected boolean initTab(boolean async)
Initialize Tab with record from AD_Tab_v

Parameters:
async - async
Returns:
true, if correctly initialized (ignored)

dispose

protected void dispose()
Dispose - clean up resources


getDependentOn

public ArrayList<String> getDependentOn()
Get a list of variables, this tab is dependent on. - for display purposes

Returns:
ArrayList

getDisplayLogic

public String getDisplayLogic()
Get Display Logic

Returns:
display logic

getTableModel

public GridTable getTableModel()
Get TableModel. Do not directly communicate with the table model, but through the methods of this class

Returns:
Table Model

getIcon

public Icon getIcon()
Get Tab Icon

Returns:
Icon

hasDependants

public boolean hasDependants(String columnName)
Has this field dependents ?

Parameters:
columnName - column name
Returns:
true if column has dependent

getDependantFields

public ArrayList<GridField> getDependantFields(String columnName)
Get dependents fields of columnName

Parameters:
columnName - column name
Returns:
ArrayList with GridFields dependent on columnName

setQuery

public void setQuery(Query query)
Set Query

Parameters:
query - query

getQuery

public Query getQuery()
Get Query

Returns:
query

isQueryActive

public boolean isQueryActive()
Is Query Active

Returns:
true if query active

isQueryNewRecord

public boolean isQueryNewRecord()
Is Query New Record

Returns:
true if query active

enableEvents

public void enableEvents()
Enable Events - enable data events of tabs (add listeners)


query

public void query(int onlyCurrentDays)
Assemble whereClause and query MTable and position to row 0.
                Scenarios:
                - Never opened                                  (full query)
                - query changed                                 (full query)
                - Detail link value changed             (full query)
                - otherwise                                     (refreshAll)
  

Parameters:
onlyCurrentDays - only current rows

query

public boolean query(int onlyCurrentDays,
                     int maxRows,
                     boolean created)
Assemble whereClause and query MTable and position to row 0.
                Scenarios:
                - Never opened                                  (full query)
                - query changed                                 (full query)
                - Detail link value changed             (full query)
                - otherwise                                     (refreshAll)
  

Parameters:
onlyCurrentDays - if only current row, how many days back
maxRows - maximum rows or 0 for all
created - query based on created if true otherwise updated
Returns:
true if queried successfully

dataRefreshAll

public void dataRefreshAll()
Refresh all data


dataRefresh

public void dataRefresh()
Refresh current row data


dataRefresh

public void dataRefresh(int row)
Refresh row data

Parameters:
row - index

dataSave

public boolean dataSave(boolean manualCmd)
Uncoditionally Save data

Parameters:
manualCmd - if true, no vetoable PropertyChange will be fired for save confirmation from MTable
Returns:
true if save complete (or nor required)

needSave

public boolean needSave(boolean rowChange,
                        boolean onlyRealChange)
Do we need to Save?

Parameters:
rowChange - row change
onlyRealChange - if true the value of a field was actually changed (e.g. for new records, which have not been changed) - default false
Returns:
true it needs to be saved

dataIgnore

public void dataIgnore()
Ignore data changes


dataNew

public boolean dataNew(boolean copy)
Create (copy) new Row and process Callouts

Parameters:
copy - copy
Returns:
true if copied/new

dataDelete

public boolean dataDelete()
Delete current Row

Returns:
true if deleted

getName

public String getName()
Get Name of Tab

Returns:
name

getDescription

public String getDescription()
Get Description of Tab

Returns:
description

getHelp

public String getHelp()
Get Help of Tab

Returns:
help

getTabLevel

public int getTabLevel()
Get Tab Level

Returns:
tab level

getCommitWarning

public String getCommitWarning()
Get Commit Warning

Returns:
commit warning

getMTable

protected GridTable getMTable()
Return Table Model

Returns:
MTable

getKeyColumnName

public String getKeyColumnName()
Return the name of the key column - may be ""

Returns:
key column name

getLinkColumnName

public String getLinkColumnName()
Return Name of link column

Returns:
link column name

setLinkColumnName

public void setLinkColumnName(String linkColumnName)
Set Name of link column. Set from MWindow.loadTabData Used in MTab.isCurreny, (.setCurrentRow) .query - APanel.cmd_report and MField.isEditable and .isDefault via context

Parameters:
linkColumnName - name of column - or sets name to AD_Column_ID, if exists

isCurrent

public boolean isCurrent()
Is the tab current?.
        Yes     - Table must be open
                        - Query String is the same
                        - Not Detail
                        - Old link column value is same as current one
  

Returns:
true if current

isOpen

public boolean isOpen()
Is the tab/table currently open

Returns:
true if open

isIncluded

public boolean isIncluded()
Is Tab Incluced in other Tab

Returns:
true if included

setIncluded

public void setIncluded(boolean isIncluded)
Is Tab Incluced in other Tab

Parameters:
isIncluded - true if included

getOnlyCurrentDays

public int getOnlyCurrentDays()
Get Only Current Days

Returns:
history days

getParentColumnNames

public ArrayList<String> getParentColumnNames()
Return Parent ArrayList

Returns:
parent column names

isDetail

public boolean isDetail()
Returns true if this is a detail record

Returns:
true if not parent tab

isPrinted

public boolean isPrinted()
Is Printed (Document can be printed)

Returns:
true if printing

getWindowNo

public int getWindowNo()
Get WindowNo

Returns:
window no

getTabNo

public int getTabNo()
Get TabNo

Returns:
tab no

getAD_Process_ID

public int getAD_Process_ID()
Get Process ID

Returns:
Process ID

isHighVolume

public boolean isHighVolume()
Is High Volume?

Returns:
true if high volume table

isReadOnly

public boolean isReadOnly()
Is Read Only?

Returns:
true if read only

isAlwaysUpdateField

public boolean isAlwaysUpdateField()
Tab contains Always Update Field

Returns:
true if field with always updateable

isInsertRecord

public boolean isInsertRecord()
Can we Insert Records?

Returns:
true not read only and allowed

isDisplayed

public boolean isDisplayed(boolean initialSetup)
Is the Tab Visible. Called when constructing the window.

Parameters:
initialSetup - return false only if not to be displayed
Returns:
true, if displayed

get_ValueAsString

public String get_ValueAsString(String variableName)
Get Variable Value (Evaluatee)

Specified by:
get_ValueAsString in interface Evaluatee
Parameters:
variableName - name
Returns:
value

isSingleRow

public boolean isSingleRow()
Is Single Row

Returns:
true if single row

setSingleRow

public void setSingleRow(boolean isSingleRow)
Set Single Row. Temporary store of current value

Parameters:
isSingleRow - toggle

isTreeTab

public boolean isTreeTab()
Has Tree

Returns:
true if tree exists

getAD_Tab_ID

public int getAD_Tab_ID()
Get Tab ID

Returns:
Tab ID

getAD_Table_ID

public int getAD_Table_ID()
Get Table ID

Returns:
Table ID

getAD_Window_ID

public int getAD_Window_ID()
Get Window ID

Returns:
Window ID

getIncluded_Tab_ID

public int getIncluded_Tab_ID()
Get Included Tab ID

Returns:
Included_Tab_ID

getTableName

public String getTableName()
Get TableName

Returns:
Table Name

getWhereClause

public String getWhereClause()
Get Tab Where Clause

Returns:
where clause

isSortTab

public boolean isSortTab()
Is Sort Tab

Returns:
true if sort tab

getAD_ColumnSortOrder_ID

public int getAD_ColumnSortOrder_ID()
Get Order column for sort tab

Returns:
AD_Column_ID

getAD_ColumnSortYesNo_ID

public int getAD_ColumnSortYesNo_ID()
Get Yes/No column for sort tab

Returns:
AD_Column_ID

getWhereExtended

public String getWhereExtended()
Get extended Where Clause (parent link)

Returns:
parent link

getTrxInfo

public String getTrxInfo()
Transaction support. Depending on Table returns transaction info

Returns:
info

loadAttachments

public void loadAttachments()
Load Attachments for this table


canHaveAttachment

public boolean canHaveAttachment()
Can this tab have Attachments?.

It can have an attachment if it has a key column ending with _ID. The key column is empty, if there is no single identifying key.

Returns:
true if record can have attachment

hasAttachment

public boolean hasAttachment()
Returns true, if current row has an Attachment

Returns:
true if record has attchment

getAD_AttachmentID

public int getAD_AttachmentID()
Get Attachment_ID for current record.

Returns:
ID or 0, if not found

loadChats

public void loadChats()
Load Chats for this table


hasChat

public boolean hasChat()
Returns true, if current row has a Chat

Returns:
true if record has chat

getCM_ChatID

public int getCM_ChatID()
Get Chat_ID for this record.

Returns:
ID or 0, if not found

loadLocks

public void loadLocks()
Load Locks for Table and User


isLocked

public boolean isLocked()
Record Is Locked

Returns:
true if locked

lock

public void lock(Ctx ctx,
                 int Record_ID,
                 boolean lock)
Lock Record

Parameters:
ctx - context
Record_ID - id
lock - true if lock, otherwise unlock

dataStatusChanged

public void dataStatusChanged(DataStatusEvent e)
Data Status Listener from MTable. - get raw info and add current row information - update the current row - redistribute (fire) Data Status event

Specified by:
dataStatusChanged in interface DataStatusListener
Parameters:
e - event

fireDataStatusEEvent

protected void fireDataStatusEEvent(String AD_Message,
                                    String info,
                                    boolean isError)
Create and fire Data Status Error Event

Parameters:
AD_Message - message
info - info
isError - if not true, it is a Warning

fireDataStatusEEvent

protected void fireDataStatusEEvent(ValueNamePair errorLog)
Create and fire Data Status Error Event (from Error Log)

Parameters:
errorLog - log

getCurrentRow

public int getCurrentRow()
Get Current Row

Returns:
current row

getRecord_ID

public int getRecord_ID()
Get Current Table Key ID

Returns:
Record_ID

getKeyID

public int getKeyID(int row)
Get Key ID of row

Parameters:
row - row number
Returns:
The Key ID of the row or -1 if not found

getAD_Client_ID

public int getAD_Client_ID()
Get Current Table AD_Client_ID

Returns:
AD_Client_ID or -1 if not found

navigate

public int navigate(int targetRow)
Navigate absolute - goto Row - (zero based). - does nothing, if in current row - saves old row if required

Parameters:
targetRow - target row
Returns:
current row

navigateRelative

public int navigateRelative(int rowChange)
Navigate relatively - i.e. plus/minus from current position

Parameters:
rowChange - row change
Returns:
current row

navigateCurrent

public int navigateCurrent()
Navigate to current now (reload)

Returns:
current row

getRowCount

public int getRowCount()
Get RowCount

Returns:
row count

getFieldCount

public int getFieldCount()
Get Column/Field Count

Returns:
field count

getField

public GridField getField(int index)
Get Field by index

Parameters:
index - index
Returns:
MField

findColumn

public int findColumn(String columnName)
Find Column

Parameters:
columnName - column
Returns:
index of column/field

getField

public GridField getField(String columnName)
Get Field by DB column name

Parameters:
columnName - column name
Returns:
MField

getFields

public GridField[] getFields()
Get all Fields

Returns:
MFields

setValue

public String setValue(String columnName,
                       Object value)
Set New Value & call Callout

Parameters:
columnName - database column name
value - value
Returns:
error message or ""

setValue

public String setValue(GridField field,
                       Object value)
Set New Value & call Callout

Parameters:
field - field
value - value
Returns:
error message or ""

isProcessed

public boolean isProcessed()
Is Processed

Returns:
true if current record is processed

processFieldChange

public String processFieldChange(GridField changedField)
Process Field Change - evaluate Dependencies and process Callouts. called from MTab.setValue or GridController.dataStatusChanged

Parameters:
changedField - changed field
Returns:
error message or ""

getValue

public Object getValue(String columnName)
Get Value of Field with columnName

Parameters:
columnName - column name
Returns:
value

getValue

public Object getValue(GridField field)
Get Value of Field

Parameters:
field - field
Returns:
value

getValue

public Object getValue(int row,
                       String columnName)
Get Value of Field in row

Parameters:
row - row
columnName - column name
Returns:
value

toString

public String toString()
toString

Overrides:
toString in class Object
Returns:
String representation

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Parameters:
l - listener

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Parameters:
l - listener

removeDataStatusListener

public void removeDataStatusListener(DataStatusListener l)
Parameters:
l - listener

addDataStatusListener

public void addDataStatusListener(DataStatusListener l)
Parameters:
l - listener

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.