Skip to content

Commit

Permalink
Merge branch 'feature/cellRange' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Jul 18, 2019
2 parents 77c5d89 + 1213bff commit d25d5a9
Show file tree
Hide file tree
Showing 14 changed files with 770 additions and 19 deletions.
133 changes: 133 additions & 0 deletions BBjGridExWidget.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ use ::BBjGridExWidget/BBjGridExWidgetColumns.bbj::BBjGridExWidgetColumnsManager
use ::BBjGridExWidget/BBjGridExWidgetRenderers.bbj::BBjGridExWidgetRendererImageRenderer
use ::BBjGridExWidget/BBjGridExWidgetClientJsonFactory.bbj::BBjGridExWidgetClientJsonFactory
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientRowModel
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClienAddRangeSelectionModel
use ::BBjGridExWidget/BBjGridExWidgetClientEvents.bbj::BBjGridExWidgetClientEventsRowSelection
use ::BBjGridExWidget/BBjGridExWidgetClientEvents.bbj::BBjGridExWidgetClientEventsContextMenu
use ::BBjGridExWidget/BBjGridExWidgetClientEvents.bbj::BBjGridExWidgetClientEventsCell
use ::BBjGridExWidget/BBjGridExWidgetClientEvents.bbj::BBjGridExWidgetClientEventsRowEditing
use ::BBjGridExWidget/BBjGridExWidgetClientEvents.bbj::BBjGridExWidgetClientEventsRangeSelection
rem /**
rem * The Grid Core Class.This class works as a columns manager and api provider.
rem * It contains a big number of methods and properties to configure the column from A..Z.
Expand Down Expand Up @@ -744,6 +746,20 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
rem */
field public BBjString Theme! = "balham"
rem /**
rem * Set to true to enable Range Selection
rem *
rem * <br><b><small>#Enterprise</small></b>
rem * <br><b><small>#Configuration</small></b>
rem */
field public BBjNumber EnableRangeSelection! = null()
rem /**
rem * Enable / diable one range selection even if ctrl key is held down
rem *
rem * <br><b><small>#Enterprise</small></b>
rem * <br><b><small>#Configuration</small></b>
rem */
field public BBjNumber SuppressMultiRangeSelection! = null()
rem /**
rem * The grid languages manager
rem */
field protected BBjGridExWidgetLanguageManager LanguageManager! = new BBjGridExWidgetLanguageManager()
Expand Down Expand Up @@ -882,6 +898,14 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
methodret 5008
methodend
rem /**
rem * Constant value to define range selection event
rem *
rem * @return BBjNumber
rem */
method public static BBjNumber ON_GRID_RANGE_SELECTION_CHANGED()
methodret 5009
methodend
rem /**
rem * Alias for <i>ON_GRID_STATE_CHANGE()</i>
rem *
rem * @see ON_GRID_STATE_CHANGE()
Expand Down Expand Up @@ -1351,6 +1375,9 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
case "gw.cellDoubleClicked"
#onCellEvent(detail$,#ON_GRID_CELL_DOUBLE_CLICK())
break
case "gw.rangeSelection"
#onRangeSelectionChange(detail$)
break
case "gw.cellEditingStarted"
#onCellEvent(detail$,#ON_GRID_CELL_EDITING_STARTED())
break
Expand Down Expand Up @@ -2059,10 +2086,13 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
options!.addProperty("accentedSort",#getAccentedSort().booleanValue(), err=*next)
options!.addProperty("suppressMaintainUnsortedOrder",#getSuppressMaintainUnsortedOrder().booleanValue(), err=*next)
rem Selection options
rem ===========================
options!.addProperty("rowSelection",iff(#getMultipleSelection() = 1 , "multiple" ,"single"), err=*next)
options!.addProperty("rowMultiSelectWithClick",#getRowMultiSelectWithClick().booleanValue() , err=*next)
options!.addProperty("rowDeselection",#getRowDeselection().booleanValue())
options!.addProperty("suppressRowClickSelection",#getSuppressRowClickSelection().booleanValue())
options!.addProperty("enableRangeSelection",#getEnableRangeSelection().booleanValue(), err=*next)
options!.addProperty("suppressMultiRangeSelection",#getSuppressMultiRangeSelection().booleanValue(), err=*next)
rem Editing Options
rem ===========================
options!.addProperty("singleClickEdit",#getSingleClickEdit().booleanValue(), err=*next)
Expand Down Expand Up @@ -2984,6 +3014,100 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
methodret rows!
methodend
rem /**
rem * The method will return a vector of the selected ranges including columns and rows
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @return BBjVector
rem */
method public BBjVector getRangeSelections()
rem an array to save the parsed range selections
rangeSelectionVector! = new BBjVector()
rem get the range selections from the client
rem the client will return an array of objects where each object is a range
rangeSelections! = #executeScript("gw_getRangeSelections('" + #GRIDID$ + "')")

if (rangeSelections! = "[]") then
goto getSelectionRangeErr
FI
rem iterate throw the ranges array and parse the range objects
parser! = new JsonParser()
ranges! = parser!.parse(rangeSelections!).getAsJsonArray()
rangesIterator! = ranges!.iterator()
while (rangesIterator!.hasNext())
model! = #getClientJsonFactory().getRangeSelection(rangesIterator!.next().getAsJsonObject())
rangeSelectionVector!.addItem(model!)
wend

getSelectionRangeErr:
methodret rangeSelectionVector!
methodend
rem /**
rem * Add new range selection
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjGridExWidgetClienAddRangeSelectionModel model! the add selection model
rem *
rem * @return BBjGridExWidgetClienAddRangeSelectionModel
rem */
method public BBjGridExWidgetClienAddRangeSelectionModel addRangeSelection(BBjGridExWidgetClienAddRangeSelectionModel model!)
#executeScript("gw_addCellRange('" + #GRIDID$ + "'," + model!.getAsJsonObject().toString() + ")")
methodret model!
methodend
rem /**
rem * Add new range selection
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjString columns! columns as comma seperated string (ex: CDNUMBER , COST)
rem * @param BBjString start! start row id or index
rem * @param BBjString end! end row id or index
rem *
rem * @return BBjGridExWidgetClienAddRangeSelectionModel
rem */
method public BBjGridExWidgetClienAddRangeSelectionModel addRangeSelection(BBjString columns! , BBjString start! , BBjString end!)
model! = new BBjGridExWidgetClienAddRangeSelectionModel()
model!.setColumns(columns!)
model!.setStart(start!)
model!.setEnd(end!)
methodret #addRangeSelection(model!)
methodend
rem /**
rem * Add new range selection
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjString columns! columns as comma seperated string (ex: CDNUMBER , COST)
rem * @param BBjNumber start! start row id or index
rem * @param BBjNumber end! end row id or index
rem *
rem * @return BBjGridExWidgetClienAddRangeSelectionModel
rem */
method public BBjGridExWidgetClienAddRangeSelectionModel addRangeSelection(BBjString columns! , BBjNumber start! , BBjNumber end!)
methodret #addRangeSelection(columns! , str(start!),str(end!))
methodend
rem /**
rem * Add new range selection
rem *
rem * <br><b><small>#API</small></b>
rem *
rem * @param BBjString columns! columns as comma seperated string (ex: CDNUMBER , COST)
rem *
rem * @return BBjGridExWidgetClienAddRangeSelectionModel
rem */
method public BBjGridExWidgetClienAddRangeSelectionModel addRangeSelection(BBjString columns!)
methodret #addRangeSelection(columns!,null() , null())
methodend
rem /**
rem * Clears the selected range.
rem *
rem * <br><b><small>#API</small></b>
rem */
method public void clearRangeSelection()
#executeScript("gw_clearRangeSelection('" + #GRIDID$ + "')")
methodend
rem /**
rem * Show loading overlay
rem *
rem * <br><b><small>#API</small></b>
Expand Down Expand Up @@ -3053,6 +3177,15 @@ class public BBjGridExWidget extends BBjWidget implements BBjGridExWidgetColumns
#fireEvent(type!, event!)
methodend
rem /**
rem * Handle Range Selections Event
rem *
rem * @see BBjGridExWidgetClientEventsRangeSelection
rem */
method private void onRangeSelectionChange(BBjString detail$)
event! = new BBjGridExWidgetClientEventsRangeSelection()
#fireEvent(#ON_GRID_RANGE_SELECTION_CHANGED(),event!)
methodend
rem /**
rem * On rows selections event
rem *
rem * Parse the json details coming from the client and fires new BBjGridExWidgetSelectRowEvent
Expand Down
10 changes: 9 additions & 1 deletion BBjGridExWidgetClientEvents.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class public BBjGridExWidgetClientEventsCell extends BBjGridExWidgetClientEvents
field public BBjString OldValue!

classend

rem /**
rem * Cell Editing / Clicking Event
rem *
Expand All @@ -88,4 +87,13 @@ class public BBjGridExWidgetClientEventsRowEditing
rem * The Row being edited
rem */
field public BBjGridExWidgetClientRowModel Row!

classend
REM /**
REM * Cells range selection event
REM *
REM * @author Hyyan Abo Fakher
REM */
class public BBjGridExWidgetClientEventsRangeSelection

classend
28 changes: 28 additions & 0 deletions BBjGridExWidgetClientJsonFactory.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientRowModel
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientColumnModel
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientCellModel
use ::BBjGridExWidget/BBjGridExWidgetClientModels.bbj::BBjGridExWidgetClientRangeSelectionModel
use com.google.gson.JsonObject
use com.google.gson.JsonParser
REM /**
Expand Down Expand Up @@ -113,5 +114,32 @@ class public BBjGridExWidgetClientJsonFactory
parsedCell! = parser!.parse(json!).getAsJsonObject()
methodret #getCell(parsedCell!)
methodend
rem /**
rem * Map a JSON object to BBjGridExWidgetClientRangeSelectionModel
rem *
rem * @param JsonObject json! Json object
rem *
rem * @return BBjGridExWidgetClientRangeSelectionModel
rem */
method public BBjGridExWidgetClientRangeSelectionModel getRangeSelection(JsonObject json!)
rem a model which describes the range object
rangeModel! = new BBjGridExWidgetClientRangeSelectionModel()
rem loop over the range columns and create a column model for each one
columns! = json!.get("columns").getAsJsonArray()
columnsIterator! = columns!.iterator()
while(columnsIterator!.hasNext())
rem create a column model and add it to the range
rangeModel!.getColumns().add(#getColumn(columnsIterator!.next().getAsString()))
wend
rem loop over the range rows and create a row model for each one
rows! = json!.get("rows").getAsJsonArray()
rowsIterator! = rows!.iterator()
while(rowsIterator!.hasNext())
rem create a row model and add it to the range
rangeModel!.getRows().add(#getRow(rowsIterator!.next().getAsJsonObject()))
wend

methodret rangeModel!
methodend

classend
76 changes: 74 additions & 2 deletions BBjGridExWidgetClientModels.bbj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
use ::BBjGridExWidget/BBjGridExWidget.bbj::BBjGridExWidget
use com.google.gson.Gson
use com.google.gson.JsonParser
use com.google.gson.JsonObject
use com.basiscomponents.db.DataRow
use java.util.ArrayList
use java.util.Arrays
REM /**
REM * A client model for rows
REM *
Expand Down Expand Up @@ -156,7 +159,7 @@ class public BBjGridExWidgetClientColumnModel
rem * @return BBjNumber column's type
rem */
method public BBjNumber getType()
methodret #getWidget().getRS().getColumnType(#getName())
methodret #getWidget().getRS().getColumnType(#getIndex())
methodend
rem /**
rem * Get the column type
Expand All @@ -179,11 +182,12 @@ class public BBjGridExWidgetClientColumnModel
rem /**
rem * Convert column to string
rem *
rem * @return BBjstring The column
rem * @return BBjstring The column
rem */
method public BBjString toString()
methodret #getName()
methodend

classend
REM /**
REM * A model for the client cell
Expand All @@ -204,4 +208,72 @@ class public BBjGridExWidgetClientCellModel
rem */
field public BBjString Value!

classend
REM /**
REM * This model is used when range selections are read from the client
REM *
REM * @author Hyyan Abo Fakher
REM */
class public BBjGridExWidgetClientRangeSelectionModel
rem /**
rem * An array of column objects where every object is instance of BBjGridExWidgetClientColumnModel
rem */
field public BBjVector Columns! = new BBjVector()
rem /**
rem * An array of rows objects where every object is instance of BBjGridExWidgetClientRowModel
rem */
field public BBjVector Rows! = new BBjVector()

classend
rem /**
rem * The model is used to compose a range selection model in order to be applied on the client.
rem *
rem * Ranges are normally bounded by a start and end row. However it is also possible to define a range unbounded
rem * by rows (ie to contain all rows). For an unbounded range, do not provided start or end row positions.
rem *
REM * @author Hyyan Abo Fakher
rem */
class public BBjGridExWidgetClienAddRangeSelectionModel
rem /**
rem * A list of column ids to use . Note that none existing columns will be ignored silently
rem */
field public ArrayList Columns! = new ArrayList()
rem /**
rem * Start row id or index
rem */
field public BBjString Start! = null()
rem /**
rem * End row id or index
rem */
field public BBjString End! = null()
rem /**
rem * Add columns as comma seperated string
rem *
rem * @param BBjString columns! columns as comma seperated string (ex: CDNUMBER , COST)
rem */
method public void setColumns(BBjString columns!)
arrayList! = new ArrayList()
list! = Arrays.asList(columns!.split(","))
it! = list!.iterator()
WHILE (it!.hasNext())
arrayList!.add(cvs(it!.next(),128))
WEND

#setColumns(arrayList!)
methodend
rem /**
rem * Convert the model to JSON object
rem *
rem * @return JsonObject
rem */
method public JsonObject getAsJsonObject()
declare JsonObject json!

json! = new JsonObject()
json!.addProperty("columns" , iff(#getColumns().size() <> 0 ,new Gson().toJson(#getColumns()), listIsEmpty!) , err=*next)
json!.addProperty("start" , #getStart(), err=*next)
json!.addProperty("end" , #getEnd(), err=*next)
methodret json!
methodend

classend

0 comments on commit d25d5a9

Please sign in to comment.