Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
johnspackman committed Oct 31, 2024
1 parent 308fecf commit 9dfeae5
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 10 deletions.
10 changes: 8 additions & 2 deletions source/class/qxl/datagrid/binding/Bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ qx.Class.define("qxl.datagrid.binding.Bindings", {
*
* @param {qx.data.Object} model The model to add the binding to
* @param {String} bindingId Id of binding
* @param {String?"binding"} bindingType The type of the binding. Either "binding" or "listener". Defaults to binding. Set to "binding " if this is a binding to a property, or "listener" if it's for a listener added with "addListener".
* @param {String?"binding"} bindingType The type of the binding. Either "binding", "listener", or "callback".
* Defaults to binding. Set to "binding" if this is a binding to a property, or "listener" if it's
* for a listener added with "addListener".
*/
construct(model, bindingId, bindingType) {
super();
Expand Down Expand Up @@ -72,18 +74,22 @@ qx.Class.define("qxl.datagrid.binding.Bindings", {
*
* @param {qx.core.Object} model the object with a binding
* @param {*} bindingId the binding ID to release
* @param {String?} bindingType The type of the binding. Either "binding" or "listener". Defaults to auto detect.
* @param {String?} bindingType The type of the binding. Either "binding", "listener", or "callback". Defaults to auto detect.
*/
add(model, bindingId, bindingType) {
if (bindingType === undefined) {
if (typeof bindingId == "string") {
bindingType = "listener";
} else if (typeof bindingId == "function") {
bindingType = "callback";
} else {
bindingType = "binding";
}
} else if (qx.core.Environment.get("qx.debug")) {
if (bindingType === "listener") {
this.assertTrue(typeof bindingId == "string", "Invalid binding type " + bindingType + " for bindingId " + bindingId);
} else if (bindingType === "callback") {
this.assertTrue(typeof bindingId == "function", "Invalid binding type " + bindingType + " for bindingId " + bindingId);
} else {
this.assertTrue(typeof bindingId != "string", "Invalid binding type " + bindingType + " for bindingId " + bindingId);
}
Expand Down
18 changes: 17 additions & 1 deletion source/class/qxl/datagrid/column/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ qx.Class.define("qxl.datagrid.column.Column", {
let path = this.getPath();
let bindings = new qxl.datagrid.binding.Bindings(model);
if (path) {
if (model) {
if (path == ".") {
widget.setValue(model);
bindings.add(model, () => widget.setValue(null));
} else if (model) {
let bindingId = model.bind(path, widget, "value", this.getBindingOptions()(widget, model));
bindings.add(model, bindingId);
}
Expand Down Expand Up @@ -323,6 +326,19 @@ qx.Class.define("qxl.datagrid.column.Column", {
});
},

/**
* Called to allow the column to update the state of the widget based on the model;
* this is typically used by the expansion column to show the correct icon for
* expanding/collapsing
*
* @param {qx.ui.core.Widget} widget
* @param {qx.core.Object} model
* @param {qxl.datagrid.ui.factory.IWidgetFactory} factory
*/
updateState(widget, model, factory) {
// Nothing to do
},

/**
* Apply for `width` property
*/
Expand Down
13 changes: 12 additions & 1 deletion source/class/qxl/datagrid/column/tree/ExpansionColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionColumn", {
return new qxl.datagrid.column.tree.ExpansionWidget();
},

/**
* @Override
*/
updateState(widget, model, factory) {
let state = factory.getDataSource().getNodeStateFor(model);
if (state == null) {
return;
}
widget.setIndentationLevel(state.level);
widget.setState(state.state);
},

/**
* @Override
*/
bindWidget(widget, model, factory) {
let bindings = super.bindWidget(widget, model);
let state = factory.getDataSource().getNodeStateFor(model);
if (state == null) {
debugger;
return bindings;
}
widget.setIndentationLevel(state.level);
Expand Down
12 changes: 7 additions & 5 deletions source/class/qxl/datagrid/column/tree/ExpansionWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionWidget", {
construct() {
super();
this._setLayout(new qxl.datagrid.column.tree.ExpansionLayout());
this._add(this.getChildControl("expander"));
let expander = this.getChildControl("expander");
this._add(expander);
this._add(this.getChildControl("icon"));
this._add(this.getChildControl("label"));

this.addListener("tap", evt => {
expander.addListener("tap", evt => {
let state = this.getState();
if (state == "open") {
this.setState("closed");
} else if (state == "closed") {
this.setState("open");
}
evt.preventDefault();
evt.stopPropagation();
});
},

Expand Down Expand Up @@ -182,7 +185,7 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionWidget", {

let expander = this.getChildControl("expander");
if (!icon) {
expander.setVisibility("hidden");
expander.setVisibility("excluded");
} else {
expander.set({
source: icon,
Expand All @@ -198,8 +201,7 @@ qx.Class.define("qxl.datagrid.column.tree.ExpansionWidget", {
switch (id) {
case "expander":
var expander = new qx.ui.basic.Image().set({
visibility: "hidden",
anonymous: true
visibility: "hidden"
});
return expander;

Expand Down
4 changes: 3 additions & 1 deletion source/class/qxl/datagrid/ui/WidgetPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ qx.Class.define("qxl.datagrid.ui.WidgetPane", {
this.setDataSource(dataSource);
}
this._setLayout(new qxl.datagrid.ui.layout.Fixed());
this.addListener("tap", this.__onTap, this, true);
this.addListener("tap", this.__onTap, this);
},

properties: {
Expand Down Expand Up @@ -200,6 +200,8 @@ qx.Class.define("qxl.datagrid.ui.WidgetPane", {
this._add(child);
qx.ui.core.queue.Layout.add(child);
this.__widgetFactory.bindWidget(child, model);
} else {
this.__widgetFactory.updateState(child, model);
}

const callbackArguments = [model, child, currentRelativePosition, currentAbsolutePosition];
Expand Down
8 changes: 8 additions & 0 deletions source/class/qxl/datagrid/ui/factory/AbstractWidgetFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ qx.Class.define("qxl.datagrid.ui.factory.AbstractWidgetFactory", {
widget.dispose();
},

/**
* @override
*/
updateState(widget, model) {
let bindingData = widget.getUserData("qxl.datagrid.factory.AbstractWidgetFactory.bindingData");
bindingData.column.updateState(widget, model, this);
},

/**
* Called to create a widget
*
Expand Down
10 changes: 10 additions & 0 deletions source/class/qxl/datagrid/ui/factory/IWidgetFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ qx.Interface.define("qxl.datagrid.ui.factory.IWidgetFactory", {
*/
unbindWidget(widget) {},

/**
* Called to allow the column to update the state of the widget based on the model;
* this is typically used by the expansion column to show the correct icon for
* expanding/collapsing
*
* @param {qx.ui.core.Widget} widget
* @param {qx.core.Object} model
*/
updateState(widget, model) {},

/**
* Obtains the model which is bound to the widget
*
Expand Down

0 comments on commit 9dfeae5

Please sign in to comment.