Commit f99ef124 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Add ugly buttons for switching class tree logic.

parent a8742699
Loading
Loading
Loading
Loading
+45 −2
Original line number Diff line number Diff line
@@ -15,8 +15,51 @@ Ext.define('Docs.view.cls.Tree', {
     */

    initComponent: function() {
        var tree = new Docs.view.cls.InheritanceLogic({classes: this.data, showPrivateClasses: true});
        this.root = tree.create();
        this.setLogic(Docs.view.cls.PackageLogic);

        this.buttons = [
            {
                xtype: 'button',
                text: 'By package',
                toggleGroup: 'logic',
                pressed: true,
                allowDepress: false,
                handler: function() {
                    this.setLogic(Docs.view.cls.PackageLogic);
                },
                scope: this
            },
            {
                xtype: 'button',
                text: 'By inheritance',
                toggleGroup: 'logic',
                allowDepress: false,
                handler: function() {
                    this.setLogic(Docs.view.cls.InheritanceLogic);
                },
                scope: this
            }
        ];

        this.callParent();
    },

    setLogic: function(logic) {
        var tree = new logic({classes: this.data, showPrivateClasses: true});
        if (this.root) {
            // remember the current selection
            var selected = this.getSelectionModel().getLastSelected();
            // create new treestructure
            var root = tree.create();
            this.setRootNode(root);
            this.initNodeLinks();
            // expand first child
            this.getRootNode().getChildAt(0).expand();
            // re-establish the previous selection
            selected && this.selectUrl(selected.raw.url);
        }
        else {
            this.root = tree.create();
        }
    }
});