Package com.basiscomponents.bc
Class BCBinder
- java.lang.Object
-
- com.basiscomponents.bc.BCBinder
-
public class BCBinder extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static int
SEL_DESELECT
Direction directive to deselect allstatic int
SEL_FIRST
Direction directive to move selection to the first recordstatic int
SEL_LAST
Direction directive to move selection to the last recordstatic int
SEL_NEXT
Direction directive to move selection to the next recordstatic int
SEL_PREVIOUS
Direction directive to move selection to the previous recordstatic int
SIGNAL_BLANK
Signal directive that components should render themselves blankstatic int
SIGNAL_DELETE
Signal directive that delete should occur (on current selection)static int
SIGNAL_DESTROY
Signal directive that the program WILL terminatestatic int
SIGNAL_DIRTY
Signal directive that there is dirty (unsaved) datastatic int
SIGNAL_ERROR
Signal directive that an error has occured in the BCstatic int
SIGNAL_INITIATE_TERMINATE
Signal directive that the program wants to terminatestatic int
SIGNAL_NEW
Signal directive that a new record should be addedstatic int
SIGNAL_SAVE
Signal directive that data should be savedstatic int
SIGNAL_TERMINATE
Signal directive that the program wants to terminate
-
Constructor Summary
Constructors Constructor Description BCBinder(BusinessComponent bc)
Sets the working business component and its attributes record
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
canSetSelection()
protected void
deleteSelectedRows()
Called by handleSignal(int signal, Object payload) on SIGNAL_DELETEDataRow
getAttributesRecord()
BusinessComponent
getBC()
DataRow
getDataRowForWrite()
Called by write()int
getDebugLevel()
ResultSet
getRS()
List<String>
getSelection()
protected void
handleSignal(int signal, Object payload)
This BC binder will handle the different signals after all bound components have had their chancevoid
onSetData()
Invokes the onSetData() of all bound componentsvoid
onSetSelection()
Invokes the onSetSelection() of all bound componentsvoid
register(IBCBound component)
Registers a component with this binder and sets the component's binder to this onevoid
retrieve()
Performs the retrieve of the bound BC, gets the corresponding attributes record that describes what's in the result set, creates indexes in the result set, checks keys in current selection list are in the result set, and invokes the onSetData() of all bound components so they can react.void
sendSignal(int signal)
Send signal without a payload to all bound componentsvoid
sendSignal(int signal, Object payload)
Send signal with a payload to all bound componentsvoid
setDebugLevel(int debugLevel)
set the debug level of operations done by the BCBindervoid
setSelection(int direction)
Moves row pointer in result set based on the passed direction and extracts the row's key, which is then used to set the selection, after asking all bound components if it is ok.void
setSelection(String rowKey)
Sets selection to the given row key, after asking all bound components if it is okvoid
setSelection(ArrayList<String> sel)
Sets one or more selections, after asking all bound components if it is okprotected void
terminate()
protected void
updateSelection()
Checks if the items in the selection are still present in the result set and removes them from the selection if not.protected void
write()
Called by handleSignal(int signal, Object payload) on SIGNAL_SAVE Writes data from components to the bc.
-
-
-
Field Detail
-
SEL_FIRST
public static final int SEL_FIRST
Direction directive to move selection to the first record- See Also:
- Constant Field Values
-
SEL_PREVIOUS
public static final int SEL_PREVIOUS
Direction directive to move selection to the previous record- See Also:
- Constant Field Values
-
SEL_NEXT
public static final int SEL_NEXT
Direction directive to move selection to the next record- See Also:
- Constant Field Values
-
SEL_LAST
public static final int SEL_LAST
Direction directive to move selection to the last record- See Also:
- Constant Field Values
-
SEL_DESELECT
public static final int SEL_DESELECT
Direction directive to deselect all- See Also:
- Constant Field Values
-
SIGNAL_SAVE
public static final int SIGNAL_SAVE
Signal directive that data should be saved- See Also:
- Constant Field Values
-
SIGNAL_NEW
public static final int SIGNAL_NEW
Signal directive that a new record should be added- See Also:
- Constant Field Values
-
SIGNAL_DELETE
public static final int SIGNAL_DELETE
Signal directive that delete should occur (on current selection)- See Also:
- Constant Field Values
-
SIGNAL_BLANK
public static final int SIGNAL_BLANK
Signal directive that components should render themselves blank- See Also:
- Constant Field Values
-
SIGNAL_DIRTY
public static final int SIGNAL_DIRTY
Signal directive that there is dirty (unsaved) data- See Also:
- Constant Field Values
-
SIGNAL_ERROR
public static final int SIGNAL_ERROR
Signal directive that an error has occured in the BC- See Also:
- Constant Field Values
-
SIGNAL_INITIATE_TERMINATE
public static final int SIGNAL_INITIATE_TERMINATE
Signal directive that the program wants to terminate- See Also:
- Constant Field Values
-
SIGNAL_TERMINATE
public static final int SIGNAL_TERMINATE
Signal directive that the program wants to terminate- See Also:
- Constant Field Values
-
SIGNAL_DESTROY
public static final int SIGNAL_DESTROY
Signal directive that the program WILL terminate- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BCBinder
public BCBinder(BusinessComponent bc)
Sets the working business component and its attributes record- Parameters:
bc
- Business Component
-
-
Method Detail
-
getDebugLevel
public int getDebugLevel()
- Returns:
- the debug level which is currently set
-
setDebugLevel
public void setDebugLevel(int debugLevel)
set the debug level of operations done by the BCBinder- Parameters:
debugLevel
- : 0=no debug, 1=moderate debug
-
getBC
public BusinessComponent getBC()
- Returns:
- bound BC
-
getRS
public ResultSet getRS()
- Returns:
- working result set
-
getAttributesRecord
public DataRow getAttributesRecord()
- Returns:
- DataRow containing all attributes
-
register
public void register(IBCBound component)
Registers a component with this binder and sets the component's binder to this one- Parameters:
component
-
-
retrieve
public void retrieve() throws Exception
Performs the retrieve of the bound BC, gets the corresponding attributes record that describes what's in the result set, creates indexes in the result set, checks keys in current selection list are in the result set, and invokes the onSetData() of all bound components so they can react.- Throws:
Exception
-
updateSelection
protected void updateSelection()
Checks if the items in the selection are still present in the result set and removes them from the selection if not.
-
onSetData
public void onSetData()
Invokes the onSetData() of all bound components
-
onSetSelection
public void onSetSelection()
Invokes the onSetSelection() of all bound components
-
setSelection
public void setSelection(ArrayList<String> sel)
Sets one or more selections, after asking all bound components if it is ok- Parameters:
sel
- a list of row keys for setting one or more selections (any empty list means to deselect all)
-
setSelection
public void setSelection(String rowKey)
Sets selection to the given row key, after asking all bound components if it is ok- Parameters:
rowKey
- the row key for setting the selection
-
setSelection
public void setSelection(int direction)
Moves row pointer in result set based on the passed direction and extracts the row's key, which is then used to set the selection, after asking all bound components if it is ok. If the direction is set to SEL_DESELECT, then an empty list is used to deselect all.- Parameters:
direction
- of movement in result set
-
canSetSelection
public Boolean canSetSelection()
- Returns:
- boolean whether the selection can be set
-
sendSignal
public void sendSignal(int signal)
Send signal without a payload to all bound components- Parameters:
signal
-
-
sendSignal
public void sendSignal(int signal, Object payload)
Send signal with a payload to all bound components- Parameters:
signal
-payload
-
-
handleSignal
protected void handleSignal(int signal, Object payload)
This BC binder will handle the different signals after all bound components have had their chance- Parameters:
signal
-payload
-- Throws:
Exception
-
terminate
protected void terminate()
-
getDataRowForWrite
public DataRow getDataRowForWrite() throws Exception
Called by write()- Returns:
- DataRow
- Throws:
Exception
-
write
protected void write() throws Exception
Called by handleSignal(int signal, Object payload) on SIGNAL_SAVE Writes data from components to the bc. components provide data with the getDataRowForWrite() method. after that, the new datarow is being integrated into the result set of the binder, either via addition or replacement.- Throws:
Exception
-
-