2015-02-17 03:05:32 +00:00
|
|
|
define(function(require, exports, module) {
|
2015-02-17 04:11:06 +00:00
|
|
|
main.consumes = ["Tree", "layout", "ui"];
|
2015-02-17 03:05:32 +00:00
|
|
|
main.provides = ["Datagrid"];
|
|
|
|
return main;
|
|
|
|
|
|
|
|
function main(options, imports, register) {
|
|
|
|
var Tree = imports.Tree;
|
2015-02-17 04:11:06 +00:00
|
|
|
var layout = imports.layout;
|
|
|
|
var ui = imports.ui;
|
2015-02-17 03:05:32 +00:00
|
|
|
|
|
|
|
var TreeModel = require("ace_tree/data_provider");
|
|
|
|
|
|
|
|
/***** Constructors *****/
|
|
|
|
|
|
|
|
function Datagrid(options, forPlugin, baseclass) {
|
|
|
|
if (!options) throw new Error("options are required");
|
|
|
|
|
|
|
|
if (!options.baseName)
|
|
|
|
options.baseName = "tree";
|
|
|
|
if (!options.theme)
|
|
|
|
options.theme = "blackdg";
|
|
|
|
|
|
|
|
var model = new TreeModel();
|
|
|
|
model.columns = options.columns;
|
|
|
|
options.model = model;
|
|
|
|
|
2015-02-17 04:11:06 +00:00
|
|
|
var plugin = new Tree(options, forPlugin, true);
|
2015-02-17 03:05:32 +00:00
|
|
|
// var emit = plugin.getEmitter();
|
|
|
|
if (baseclass) plugin.baseclass();
|
|
|
|
|
2015-02-18 06:07:10 +00:00
|
|
|
var acetree = plugin.acetree;
|
|
|
|
|
|
|
|
if (!options.rowHeight) {
|
|
|
|
layout.on("eachTheme", function(e){
|
|
|
|
var cls = "." + plugin.theme + " .row";
|
|
|
|
var height = parseInt(ui.getStyleRule(cls, "height"), 10) || 23;
|
|
|
|
// model.rowHeightInner = height - 1;
|
|
|
|
model.rowHeight = height;
|
|
|
|
|
|
|
|
if (e.changed) plugin.resize(true);
|
|
|
|
});
|
|
|
|
}
|
2015-02-17 04:11:06 +00:00
|
|
|
|
2015-02-17 03:05:32 +00:00
|
|
|
/**
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* Creates a new Datagrid instance.
|
|
|
|
* @param {Object} options
|
|
|
|
* @param {Array} options.columns
|
|
|
|
* @param {Plugin} plugin The plugin responsible for creating this datagrid.
|
|
|
|
*/
|
|
|
|
plugin.freezePublicAPI({
|
|
|
|
// Properties
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2015-02-18 06:07:10 +00:00
|
|
|
get columns(){ throw new Error("Columns can only be set.") },
|
|
|
|
set columns(c){
|
|
|
|
if (!acetree) return;
|
|
|
|
|
|
|
|
model.columns = c;
|
|
|
|
acetree.renderer.setDataProvider(model);
|
|
|
|
}
|
2015-02-17 03:05:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
register(null, {
|
|
|
|
Datagrid: Datagrid
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|