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 intSEL_DESELECTDirection directive to deselect allstatic intSEL_FIRSTDirection directive to move selection to the first recordstatic intSEL_LASTDirection directive to move selection to the last recordstatic intSEL_NEXTDirection directive to move selection to the next recordstatic intSEL_PREVIOUSDirection directive to move selection to the previous recordstatic intSIGNAL_BLANKSignal directive that components should render themselves blankstatic intSIGNAL_DELETESignal directive that delete should occur (on current selection)static intSIGNAL_DESTROYSignal directive that the program WILL terminatestatic intSIGNAL_DIRTYSignal directive that there is dirty (unsaved) datastatic intSIGNAL_ERRORSignal directive that an error has occured in the BCstatic intSIGNAL_INITIATE_TERMINATESignal directive that the program wants to terminatestatic intSIGNAL_NEWSignal directive that a new record should be addedstatic intSIGNAL_SAVESignal directive that data should be savedstatic intSIGNAL_TERMINATESignal 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 BooleancanSetSelection()protected voiddeleteSelectedRows()Called by handleSignal(int signal, Object payload) on SIGNAL_DELETEDataRowgetAttributesRecord()BusinessComponentgetBC()DataRowgetDataRowForWrite()Called by write()intgetDebugLevel()ResultSetgetRS()List<String>getSelection()protected voidhandleSignal(int signal, Object payload)This BC binder will handle the different signals after all bound components have had their chancevoidonSetData()Invokes the onSetData() of all bound componentsvoidonSetSelection()Invokes the onSetSelection() of all bound componentsvoidregister(IBCBound component)Registers a component with this binder and sets the component's binder to this onevoidretrieve()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.voidsendSignal(int signal)Send signal without a payload to all bound componentsvoidsendSignal(int signal, Object payload)Send signal with a payload to all bound componentsvoidsetDebugLevel(int debugLevel)set the debug level of operations done by the BCBindervoidsetSelection(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.voidsetSelection(String rowKey)Sets selection to the given row key, after asking all bound components if it is okvoidsetSelection(ArrayList<String> sel)Sets one or more selections, after asking all bound components if it is okprotected voidterminate()protected voidupdateSelection()Checks if the items in the selection are still present in the result set and removes them from the selection if not.protected voidwrite()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 ExceptionPerforms 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 ExceptionCalled 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
-
-