diff --git a/.classpath b/.classpath
new file mode 100644
index 00000000..9fb5df0c
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/BBjGridExWidget.bbj b/BBjGridExWidget.bbj
index 861649e6..73afab7a 100644
--- a/BBjGridExWidget.bbj
+++ b/BBjGridExWidget.bbj
@@ -571,6 +571,10 @@ class public BBjGridExWidget extends BBjWidget
node!.addProperty("filter","date")
break
+ case Types.BOOLEAN
+ node!.addProperty("filter","boolean")
+ break
+
case default
node!.addProperty("filter","agTextColumnFilter")
diff --git a/Demo/d.bbj b/Demo/d.bbj
new file mode 100644
index 00000000..1f714a76
--- /dev/null
+++ b/Demo/d.bbj
@@ -0,0 +1,71 @@
+REM /**
+REM * d.bbj
+REM * @author Hyyan-Basis
+REM *
+REM */
+use com.google.gson.JsonParser
+use com.google.gson.Gson
+use com.google.gson.JsonObject
+use java.util.HashMap
+use java.util.Iterator
+use java.lang.Integer
+use java.util.Collection
+use java.util.ArrayList
+
+class public Foo
+
+ field public BBjString firstname$
+ field public BBjString lastname$
+classend
+
+json$ = "[{firstname: ""Hyyan"",lastname:""AF""},{firstname:""Foo"",lastname:""Bar""}]"
+
+
+declare JsonParser parser!
+parser! = new JsonParser()
+
+array! = parser!.parse(json$).getAsJsonArray()
+
+it! = array!.iterator()
+while (it!.hasNext())
+ next! = it!.next()
+ print next!.getAsJsonObject().get("firstname").getAsBoolean()
+wend
+
+REM obj! = new JsonObject()
+REM obj!.addProperty("id", Integer.valueOf(5))
+REM
+REM declare ArrayList c!
+REM c! = new ArrayList()
+REM c!.add("5")
+REM c!.add(obj!)
+REM
+REM declare Gson g!
+REM
+REM g! = new Gson()
+REM print g!.toJson(c!)
+
+REM parse! = new JsonParser()
+REM obj! = new JsonObject()
+REM obj!.addProperty("id", Integer.valueOf(5))
+REM
+REM obj2! = new JsonObject()
+REM obj2!.addProperty("id2" , Integer.valueOf(2))
+REM
+REM obj!.add("foo",obj2!)
+REM
+REM it! = m!.entrySet().iterator()
+REM while (it!.hasNext())
+REM next! = it!.next()
+REM print next!.getKey() + " - " + str(next!.getValue()) + "\n"
+REM wend
+REM
+REM print m!.toString()
+
+
+
+
+REM ret! = parse!.parse("{id: '5'}").getAsJsonObject()
+REM print ret!.get("id").getAsDouble()
+REM print ret!.toString()
+REM print ret!.get("id").getAsInt()
\ No newline at end of file
diff --git a/js/BBjGridExWidget.js b/js/BBjGridExWidget.js
index 39336feb..e2d618fc 100644
--- a/js/BBjGridExWidget.js
+++ b/js/BBjGridExWidget.js
@@ -13,6 +13,10 @@ bbj_grid_supported_value_formatter = {
'agNumberColumnFilter': bbj_grid_widget_get_value_formatter_number
}
+bbj_grid_supported_value_renderer = {
+ 'boolean': bbj_grid_widget_get_value_renderer_boolean
+}
+
function bbj_grid_widget_post_event(ev) {
window.basisDispatchCustomEvent(ev, ev.payload);
}
@@ -185,7 +189,10 @@ function bbj_grid_widget_init(container, license, data, options) {
for (var i in options.columnDefs) {
options.columnDefs[i].cellStyle = bbj_grid_widget_cell_render;
- options.columnDefs[i].valueFormatter = bbj_grid_widget_get_value_formatter(
+ options.columnDefs[i].valueFormatter = bbj_grid_widget_format_value(
+ options.columnDefs[i].filter
+ );
+ options.columnDefs[i].cellRenderer = bbj_grid_widget_render_value(
options.columnDefs[i].filter
);
}
@@ -268,14 +275,17 @@ function bbj_grid_widget_set_state(state) {
$doc.bbj_grid_widget.columnApi.setColumnState(state);
}
-function bbj_grid_widget_get_value_formatter(filter) {
-
+function bbj_grid_widget_format_value(filter) {
return bbj_grid_supported_value_formatter && bbj_grid_supported_value_formatter.hasOwnProperty(filter) ?
bbj_grid_supported_value_formatter[filter] : null;
}
-function bbj_grid_widget_get_value_formatter_date(data) {
+function bbj_grid_widget_render_value(renderer) {
+ return bbj_grid_supported_value_renderer && bbj_grid_supported_value_renderer.hasOwnProperty(renderer) ?
+ bbj_grid_supported_value_renderer[renderer] : null;
+}
+function bbj_grid_widget_get_value_formatter_date(data) {
if (
($doc.bbj_grid_widget_meta && $doc.bbj_grid_widget_meta.hasOwnProperty(data.colDef.field)) &&
$doc.bbj_grid_widget_meta[data.colDef.field].hasOwnProperty('MASK')
@@ -300,6 +310,16 @@ function bbj_grid_widget_get_value_formatter_number(data) {
} else return data.value;
}
+function bbj_grid_widget_get_value_renderer_boolean(data) {
+
+ if (data.value) {
+ return '✔'
+ } else {
+ return '✘'
+ }
+
+}
+
function bbj_grid_widget_set_data(json, options) {
var container = $doc.getElementById('grid');
diff --git a/js/format.js b/js/format.js
deleted file mode 100644
index 218c6027..00000000
--- a/js/format.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * javascript-number-formatter
- * Lightweight & Fast JavaScript Number Formatter
- *
- * @preserve IntegraXor Web SCADA - JavaScript Number Formatter (http://www.integraxor.com/)
- * @author KPL
- * @maintainer Rob Garrison
- * @copyright 2017 ecava
- * @license MIT
- * @link http://mottie.github.com/javascript-number-formatter/
- * @version 1.1.11
- */
-/*jshint browser:true */
-/* global define, module */
-(function ( root, factory ) {
- if ( typeof define === 'function' && define.amd ) {
- define( [], factory );
- } else if ( typeof module === 'object' ) {
- module.exports = factory();
- } else {
- root.format = factory();
- }
-}( this, function () {
-
- return function ( mask, value ) {
- 'use strict';
- if ( !mask || isNaN( +value ) ) {
- return value; // return as it is.
- }
-
- var isNegative, result, decimal, group, posLeadZero, posTrailZero, posSeparator,
- part, szSep, integer,
-
- // find prefix/suffix
- len = mask.length,
- start = mask.search( /[0-9\-\+#]/ ),
- prefix = start > 0 ? mask.substring( 0, start ) : '',
- // reverse string: not an ideal method if there are surrogate pairs
- str = mask.split( '' ).reverse().join( '' ),
- end = str.search( /[0-9\-\+#]/ ),
- offset = len - end,
- substr = mask.substring( offset, offset + 1 ),
- indx = offset + ( ( substr === '.' || ( substr === ',' )) ? 1 : 0 ),
- suffix = end > 0 ? mask.substring( indx, len ) : '';
-
- // mask with prefix & suffix removed
- mask = mask.substring( start, indx );
-
- // convert any string to number according to formation sign.
- value = mask.charAt( 0 ) === '-' ? -value : +value;
- isNegative = value < 0 ? value = -value : 0; // process only abs(), and turn on flag.
-
- // search for separator for grp & decimal, anything not digit, not +/- sign, not #.
- result = mask.match( /[^\d\-\+#]/g );
- decimal = ( result && result[ result.length - 1 ] ) || '.'; // treat the right most symbol as decimal
- group = ( result && result[ 1 ] && result[ 0 ] ) || ','; // treat the left most symbol as group separator
-
- // split the decimal for the format string if any.
- mask = mask.split( decimal );
- // Fix the decimal first, toFixed will auto fill trailing zero.
- value = value.toFixed( mask[ 1 ] && mask[ 1 ].length );
- value = +( value ) + ''; // convert number to string to trim off *all* trailing decimal zero(es)
-
- // fill back any trailing zero according to format
- posTrailZero = mask[ 1 ] && mask[ 1 ].lastIndexOf( '0' ); // look for last zero in format
- part = value.split( '.' );
- // integer will get !part[1]
- if ( !part[ 1 ] || ( part[ 1 ] && part[ 1 ].length <= posTrailZero ) ) {
- value = ( +value ).toFixed( posTrailZero + 1 );
- }
- szSep = mask[ 0 ].split( group ); // look for separator
- mask[ 0 ] = szSep.join( '' ); // join back without separator for counting the pos of any leading 0.
-
- posLeadZero = mask[ 0 ] && mask[ 0 ].indexOf( '0' );
- if ( posLeadZero > -1 ) {
- while ( part[ 0 ].length < ( mask[ 0 ].length - posLeadZero ) ) {
- part[ 0 ] = '0' + part[ 0 ];
- }
- } else if ( +part[ 0 ] === 0 ) {
- part[ 0 ] = '';
- }
-
- value = value.split( '.' );
- value[ 0 ] = part[ 0 ];
-
- // process the first group separator from decimal (.) only, the rest ignore.
- // get the length of the last slice of split result.
- posSeparator = ( szSep[ 1 ] && szSep[ szSep.length - 1 ].length );
- if ( posSeparator ) {
- integer = value[ 0 ];
- str = '';
- offset = integer.length % posSeparator;
- len = integer.length;
- for ( indx = 0; indx < len; indx++ ) {
- str += integer.charAt( indx ); // ie6 only support charAt for sz.
- // -posSeparator so that won't trail separator on full length
- /*jshint -W018 */
- if ( !( ( indx - offset + 1 ) % posSeparator ) && indx < len - posSeparator ) {
- str += group;
- }
- }
- value[ 0 ] = str;
- }
- value[ 1 ] = ( mask[ 1 ] && value[ 1 ] ) ? decimal + value[ 1 ] : '';
-
- // remove negative sign if result is zero
- result = value.join( '' );
- if ( result === '0' || result === '' ) {
- // remove negative sign if result is zero
- isNegative = false;
- }
-
- // put back any negation, combine integer and fraction, and add back prefix & suffix
- return prefix + ( ( isNegative ? '-' : '' ) + result ) + suffix;
- };
-
-} ));
diff --git a/js/masks.js b/js/masks.js
deleted file mode 100644
index c69bff14..00000000
--- a/js/masks.js
+++ /dev/null
@@ -1,86 +0,0 @@
-function bbj_mask_date(date, format) {
-
- if (!date || !format) return null;
-
- date = new Date(date);
-
- var year = date.getYear();
- var fullYear = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hours24 = date.getHours();
- var hours12 = hours24 - 12;
- hours12 = hours12 <= 12 ? hours12 : hours24;
- hours12 = hours12 == 0 ? 12 : hours12;
- var minutes = date.getMinutes();
- var seconds = date.getSeconds();
-
- var translations = {
-
- // year
- "Yz": year,
- "Ys": fullYear,
- "Yl": fullYear,
- "Yp": String.fromCharCode(year),
- "Yd": fullYear,
- "Y": fullYear,
-
- // month
- "Mz": String(month).length == 1 ? "0" + month : month,
- "Ms": month,
- "Ml": month,
- "Mp": String.fromCharCode(month),
- "Md": month,
- "M": month,
-
- // day
- "Dz": String(day).length == 1 ? "0" + day : day,
- "Ds": day,
- "Dl": day,
- "Dp": String.fromCharCode(day),
- "Dd": day,
- "D": day,
-
- // hour 24
- "Hs": hours24,
- "Hl": hours24,
- "Hp": String.fromCharCode(hours24),
- "Hd": hours24,
- "H": hours24,
-
- // hour 12
- "hs": String(hours12).length == 1 ? "0" + hours12 : hours12,
- "hl": hours12,
- "hp": String.fromCharCode(hours12),
- "hd": hours12,
- "h": hours12,
-
- // minutes
- "ms": String(minutes).length == 1 ? "0" + minutes : minutes,
- "ml": minutes,
- "mp": String.fromCharCode(minutes),
- "md": minutes,
- "m": minutes,
-
- // seconds
- "ss": String(seconds).length == 1 ? "0" + seconds : seconds,
- "sl": seconds,
- "sp": String.fromCharCode(seconds),
- "sd": seconds,
- "s": seconds,
-
- 'pd': hours24 > 12 ? 'PM' : 'AM',
- 'p': hours24 > 12 ? 'PM' : 'AM',
- };
-
- var result = format;
- for (var k in translations) {
- result = result.replace(new RegExp('(%' + k + ')', 'g'), translations[k]);
- }
-
- return result;
-}
-
-function bbj_mask_number(number, mask) {
- return format(mask, number);
-}