com.emitrom.touch4j.client.data.TreeStore.java Source code

Java tutorial

Introduction

Here is the source code for com.emitrom.touch4j.client.data.TreeStore.java

Source

/**
 Copyright (c) 2013 Emitrom LLC. All rights reserved.
 For licensing questions, please contact us at licensing@emitrom.com
    
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
    
 http://www.apache.org/licenses/LICENSE-2.0
    
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
package com.emitrom.touch4j.client.data;

import com.emitrom.touch4j.client.core.Ext;
import com.google.gwt.core.client.JavaScriptObject;

public class TreeStore extends Store {

    private TreeModel treeModel;

    protected TreeStore() {
    }

    public TreeStore(TreeModel data) {
        super(JavaScriptObject.createObject());
        assert data != null : "Model cannot be null";
        this.treeModel = data;

        modelRegistry++;
        modelName = model + modelRegistry;

        Ext.defineModel(modelName, data.getFields());

        create(modelName, data.getJsObj());

    }

    public native void setDefaultRootProperty(String value)/*-{
                                                           var jso = this.@com.emitrom.touch4j.client.core.JsObject::jsObj;
                                                           jso.setDefaultRootProperty(value);
                                                           }-*/;

    /**
     * @return the treeModel
     */
    public TreeModel getTreeModel() {
        return treeModel;
    }

    private native void create(String modelName, JavaScriptObject values) /*-{
                                                                          this.@com.emitrom.touch4j.client.core.JsObject::jsObj = new $wnd.Ext.data.TreeStore(
                                                                          {
                                                                          model : modelName,
                                                                          defaultRootProperty : 'items',
                                                                          root : values
                                                                          });
                                                                          }-*/;

}