Package com.smartgwt.client.widgets.tree

Examples of com.smartgwt.client.widgets.tree.TreeGrid


    private void restartTreeGridThemes() {
        //restart the tree and the treegrid
        treeThemesGrid.clear();
        Tree tree2 = createTree();
        tree2.setData(nodesThemes);
        TreeGrid treeGrid2 = createTreeGridThemes(tree2);
        treeThemesGrid = treeGrid2;
        treeThemesGrid.getData().openAll();
        treeThemesGrid.setWidth100();
        treeThemesGrid.setHeight100();
View Full Code Here


        editLabel.setContents("[Form for edits can be dispalyed here]");
        editTab.setPane(editLabel);

        tabSet.setTabs(viewTab, editTab);

        TreeGrid treeGrid = new TreeGrid();
        treeGrid.setWidth("30%");
        treeGrid.setShowConnectors(true);
        treeGrid.setShowResizeBar(true);

        Tree data = new Tree();
        data.setModelType(TreeModelType.CHILDREN);
        data.setRoot(new TreeNode("root",
                new TreeNode("File"),
                new TreeNode("Edit"),
                new TreeNode("Search"),
                new TreeNode("Project"),
                new TreeNode("Tools"),
                new TreeNode("Window"),
                new TreeNode("Favourites")));

        treeGrid.setData(data);
       
        TreeGridField field = new TreeGridField("Navigation");
        field.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                return record.getAttribute("name");
            }
        });
        treeGrid.setFields(field);

        HLayout navLayout = new HLayout();
        navLayout.setMembers(treeGrid, listGrid);

        SectionStack sectionStack = new SectionStack();       
View Full Code Here

            return DESCRIPTION;
        }
    }

    public Canvas getViewPanel() {
        final TreeGrid employeeTree = new TreeGrid();
        employeeTree.setLoadDataOnDemand(false);       
        employeeTree.setWidth(500);
        employeeTree.setHeight(400);
        employeeTree.setDataSource(EmployeeXmlDS.getInstance());
        employeeTree.setAutoFetchData(true);
        employeeTree.setShowConnectors(true);      
        employeeTree.setNodeIcon("icons/16/person.png");
        employeeTree.setFolderIcon("icons/16/person.png");
        employeeTree.setShowOpenIcons(false);
        employeeTree.setShowDropIcons(false);
        employeeTree.setClosedIconSuffix("");    
        employeeTree.setBaseStyle("noBorderCell");
        employeeTree.setFields(new TreeGridField("Name"));

        employeeTree.addDataArrivedHandler(new DataArrivedHandler() {
            public void onDataArrived(DataArrivedEvent event) {
                employeeTree.getData().openAll();
            }
        });
       
        return employeeTree;
    }
View Full Code Here

    public Canvas getViewPanel() {

        DataSource employeeDS = EmployeeXmlDS.getInstance();

        final TreeGrid treeGrid = new TreeGrid();
        treeGrid.setLoadDataOnDemand(false);
        treeGrid.setWidth(500);
        treeGrid.setHeight(400);
        treeGrid.setDataSource(employeeDS);
        treeGrid.setNodeIcon("icons/16/person.png");
        treeGrid.setFolderIcon("icons/16/person.png");
        treeGrid.setShowOpenIcons(false);
        treeGrid.setShowDropIcons(false);
        treeGrid.setClosedIconSuffix("");
        treeGrid.setAutoFetchData(true);


        TreeGridField field = new TreeGridField();
        field.setName("Name");
        field.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                return record.getAttribute("Job") + ": " + value;
            }
        });

        treeGrid.setFields(field);

        treeGrid.addDataArrivedHandler(new DataArrivedHandler() {
            public void onDataArrived(DataArrivedEvent event) {
                treeGrid.getData().openAll();
            }
        });

        return treeGrid;
    }
View Full Code Here

    public Canvas getViewPanel() {

        EmployeeXmlDS employeesDS = EmployeeXmlDS.getInstance();

        TreeGrid treeGrid = new TreeGrid();
        treeGrid.setCanEdit(true);
        treeGrid.setLoadDataOnDemand(false);
        treeGrid.setWidth(500);
        treeGrid.setHeight(400);
        treeGrid.setDataSource(employeesDS);
        treeGrid.setNodeIcon("icons/16/person.png");
        treeGrid.setFolderIcon("icons/16/person.png");
        treeGrid.setShowOpenIcons(false);
        treeGrid.setShowDropIcons(false);
        treeGrid.setClosedIconSuffix("");
        treeGrid.setAutoFetchData(true);

        TreeGridField nameField = new TreeGridField("Name");
        TreeGridField jobField = new TreeGridField("Job");
        TreeGridField salaryField = new TreeGridField("Salary");
        salaryField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if(value != null) {
                    NumberFormat nf = NumberFormat.getFormat("#,##0");
                    try {
                        return "$" + nf.format(((Number)value).longValue());
                    } catch (Exception e) {
                        return value.toString();
                    }
                } else {
                    return null;
                }
            }
        });

        treeGrid.setFields(nameField, jobField, salaryField);
        return treeGrid;
    }
View Full Code Here

        layout.setWidth(650);
        layout.setAutoHeight();

        EmployeeXmlDS employeesDS = EmployeeXmlDS.getInstance();

        final TreeGrid treeGrid = new TreeGrid();
        treeGrid.setCanEdit(true);
        treeGrid.setLoadDataOnDemand(false);
        treeGrid.setWidth100();
        treeGrid.setHeight(400);
        treeGrid.setDataSource(employeesDS);
        treeGrid.setNodeIcon("icons/16/person.png");
        treeGrid.setFolderIcon("icons/16/person.png");
        treeGrid.setShowOpenIcons(false);
        treeGrid.setShowDropIcons(false);
        treeGrid.setClosedIconSuffix("");
        treeGrid.setAutoFetchData(true);

        TreeGridField nameField = new TreeGridField("Name");
        TreeGridField jobField = new TreeGridField("Job");
        TreeGridField salaryField = new TreeGridField("Salary");
        salaryField.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                if (value != null) {
                    NumberFormat nf = NumberFormat.getFormat("#,##0");
                    try {
                        return "$" + nf.format(((Number) value).longValue());
                    } catch (Exception e) {
                        return value.toString();
                    }
                } else {
                    return null;
                }
            }
        });

        treeGrid.setFields(nameField, jobField, salaryField);

        //create another grid to display the preference name and viewState string
        final ListGrid preferecesGrid = new ListGrid();
        preferecesGrid.setHeight(300);
        preferecesGrid.setWrapCells(true);
        preferecesGrid.setFixedRecordHeights(false);
        preferecesGrid.setCanEdit(true);
        preferecesGrid.setEmptyMessage("No Saved Preferences");
        preferecesGrid.setSelectionType(SelectionStyle.SINGLE);
        preferecesGrid.setCanRemoveRecords(true);
        final ListGridField name = new ListGridField("name", "Preference");
        ListGridField viewState = new ListGridField("viewState", "View State String");
        viewState.setEditorType(new TextAreaItem());
        viewState.setCellFormatter(new CellFormatter() {
            @Override
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                //prettier display
                return ((String) value).replace("\\r", "");
            }
        });
        preferecesGrid.setFields(name, viewState);
        preferecesGrid.setAutoFetchData(true);

        //create a "preferences" DataSource to bind to SelectItem and Preferences ListGrid
        final DataSource preferencesDS = new DataSource();
        DataSourceIntegerField pkField = new DataSourceIntegerField("pk");
        pkField.setHidden(true);
        pkField.setPrimaryKey(true);

        DataSourceTextField preferenceField = new DataSourceTextField("name", "Name");
        DataSourceTextField stateField = new DataSourceTextField("viewState", "View State");
        preferencesDS.setFields(pkField, preferenceField, stateField);
        preferencesDS.setClientOnly(true);
        preferecesGrid.setDataSource(preferencesDS);

        ToolStripButton formulaButton = new ToolStripButton("Formula Builder", "crystal/oo/sc_insertformula.png");
        formulaButton.setAutoFit(true);
        formulaButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                treeGrid.addFormulaField();
            }
        });

        ToolStripButton summaryBuilder = new ToolStripButton("Summary Builder", "crystal/16/apps/tooloptions.png");
        summaryBuilder.setAutoFit(true);
        summaryBuilder.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                treeGrid.addSummaryField();
            }
        });

        final SelectItem preferenceSelectItem = new SelectItem("name");
        preferenceSelectItem.setTitle("Preference");
        ListGrid pickListProperties = new ListGrid();
        pickListProperties.setEmptyMessage("No Saved Preferences");
        preferenceSelectItem.setPickListProperties(pickListProperties);
        preferenceSelectItem.setOptionDataSource(preferencesDS);

        //apply the selected preference from the SelectItem
        preferenceSelectItem.addChangedHandler(new ChangedHandler() {
            @Override
            public void onChanged(ChangedEvent event) {
                String preferenceName = (String) preferenceSelectItem.getValue();
                Criteria criteria = new Criteria("name", preferenceName);
                preferencesDS.fetchData(criteria, new DSCallback() {
                    @Override
                    public void execute(DSResponse response, Object rawData, DSRequest request) {
                        Record[] data = response.getData();
                        if (data.length != 0) {
                            PreferenceRecord record = (PreferenceRecord) data[0];
                            treeGrid.setViewState(record.getViewState());
                        }
                    }
                });
            }
        });
        preferenceSelectItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
            @Override
            public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                String preferenceName = (String) preferenceSelectItem.getValue();
                Criteria criteria = new Criteria("name", preferenceName);
                preferencesDS.fetchData(criteria, new DSCallback() {
                    @Override
                    public void execute(DSResponse response, Object rawData, DSRequest request) {
                        Record[] data = response.getData();
                        if (data.length != 0) {
                            PreferenceRecord record = (PreferenceRecord) data[0];
                            treeGrid.setViewState(record.getViewState());
                        }
                    }
                });
            }
        });

        ToolStripButton savePreference = new ToolStripButton("Save Preference", "silk/database_gear.png");
        savePreference.setAutoFit(true);
        savePreference.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                SC.askforValue("Enter Preference name :", new ValueCallback() {
                    @Override
                    public void execute(String value) {
                        if (value != null && !value.equals("")) {
                            String viewState = treeGrid.getViewState();
                            PreferenceRecord record = new PreferenceRecord(PK_COUNTER++, value, viewState);
                            preferecesGrid.addData(record);
                            preferenceSelectItem.setValue(value);
                        }
                    }
                });
            }
        });

        //toolstrip to attach to the country grid
        ToolStrip countryGridToolStrip = new ToolStrip();
        countryGridToolStrip.setWidth100();
        countryGridToolStrip.addFill();
        countryGridToolStrip.addButton(formulaButton);
        countryGridToolStrip.addButton(summaryBuilder);
        countryGridToolStrip.addSeparator();
        countryGridToolStrip.addButton(savePreference);
        countryGridToolStrip.addSeparator();
        countryGridToolStrip.addFormItem(preferenceSelectItem);

        VLayout countryGridLayout = new VLayout(0);
        countryGridLayout.setWidth(650);
        countryGridLayout.addMember(countryGridToolStrip);
        countryGridLayout.addMember(treeGrid);
        layout.addMember(countryGridLayout);

        VLayout preferencesGridLayout = new VLayout(0);
        preferencesGridLayout.setWidth(650);
        preferencesGridLayout.addMember(preferecesGrid);

        //toolstrip to attach to the preferences grid
        ToolStrip preferencesToolStrip = new ToolStrip();
        preferencesToolStrip.setWidth100();
        preferencesToolStrip.addFill();

        ToolStripButton restoreButton = new ToolStripButton("Restore State", "silk/database_gear.png");
        restoreButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Record record = preferecesGrid.getSelectedRecord();
                if (record != null) {
                    String viewState = record.getAttribute("viewState");
                    treeGrid.setViewState(viewState);
                }
            }
        });
        preferencesToolStrip.addButton(restoreButton);
        preferencesGridLayout.addMember(preferencesToolStrip);

        layout.addMember(preferencesGridLayout);

        layout.addDrawHandler(new DrawHandler() {
            @Override
            public void onDraw(DrawEvent event) {
                preferecesGrid.addData(new PreferenceRecord(PK_COUNTER++, "Default", treeGrid.getViewState()));
            }
        });

        return layout;
    }
View Full Code Here

        ListGridField unitCostField = new ListGridField("unitCost");
        ListGridField categoryField = new ListGridField("category");
        itemListGrid.setFields(itemIdField, itemNameField, unitCostField, categoryField);


        TreeGrid categoryTree = new TreeGrid();
        categoryTree.setWidth(250);
        categoryTree.setHeight(224);
        categoryTree.setDataSource(supplyCategoryXmlDS);
        categoryTree.setLoadDataOnDemand(true);
        categoryTree.setAutoFetchData(true);
        categoryTree.addRecordDoubleClickHandler(new RecordDoubleClickHandler() {
            @Override
            public void onRecordDoubleClick(RecordDoubleClickEvent event) {
                final String categoryName = event.getRecord().getAttribute("categoryName");
                Criteria criteria = new Criteria("category", categoryName);
                itemListGrid.filterData(criteria);
View Full Code Here

  public Canvas getViewPanel() {
    TreeGridField fieldName = new TreeGridField("Name", 150);
    TreeGridField fieldJob = new TreeGridField("Job", 150);
    TreeGridField fieldSalary = new TreeGridField("Salary");

    TreeGrid employeeTree = new TreeGrid();
    employeeTree.setWidth(500);
    employeeTree.setHeight(250);
    employeeTree.setDataSource(EmployeeXmlDS.getInstance());
    employeeTree.setNodeIcon("icons/16/person.png");
    employeeTree.setFolderIcon("icons/16/person.png");
    employeeTree.setAutoFetchData(true);
    employeeTree.setLoadDataOnDemand(false);
    employeeTree.setCanEdit(true);
    employeeTree.setCanReorderRecords(true);
    employeeTree.setCanAcceptDroppedRecords(true);
    employeeTree.setShowDropIcons(false);
    employeeTree.setShowOpenIcons(false);
    employeeTree.setClosedIconSuffix("");
    employeeTree.setFields(fieldName, fieldJob, fieldSalary);
   
    final ListGrid employeeGrid = new ListGrid();
    employeeGrid.setWidth(500);
    employeeGrid.setHeight(250);
        employeeGrid.setEmptyMessage("Select an Employee from the PickTree Item above.");
View Full Code Here

            return DESCRIPTION;
        }
    }

    public Canvas getViewPanel() {
        TreeGrid treeGrid = new TreeGrid();
        treeGrid.setWidth(300);
        treeGrid.setHeight(400);

        TreeGridField field = new TreeGridField("Name", "Tree from local data");
        field.setCanSort(false);

        treeGrid.setFields(field);

        Tree tree = new Tree();
        tree.setModelType(TreeModelType.PARENT);
        //tree.setRootValue("1");
        tree.setNameProperty("Name");
        tree.setIdField("EmployeeId");
        tree.setParentIdField("ReportsTo");
        tree.setShowRoot(true);

        EmployeeTreeNode root = new EmployeeTreeNode("4", "1", "Charles Madigen");
        EmployeeTreeNode node2 = new EmployeeTreeNode("188", "4", "Rogine Leger");
        EmployeeTreeNode node3 = new EmployeeTreeNode("189", "4", "Gene Porter");
        EmployeeTreeNode node4 = new EmployeeTreeNode("265", "189", "Olivier Doucet");
        EmployeeTreeNode node5 = new EmployeeTreeNode("264", "189", "Cheryl Pearson");
        tree.setData(new TreeNode[]{root, node2, node3, node4, node5});

        tree.setRoot(root);

        treeGrid.setData(tree);

        return treeGrid;
    }
View Full Code Here

            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                return record.getAttributeAsString("Job") + ": " + value;
            }
        });
       
        TreeGrid employeeTreeGrid = new TreeGrid();
        employeeTreeGrid.setWidth(500);
        employeeTreeGrid.setHeight(400);
        employeeTreeGrid.setNodeIcon("icons/16/person.png");
        employeeTreeGrid.setFolderIcon("icons/16/person.png");
        employeeTreeGrid.setAutoFetchData(true);
        employeeTreeGrid.setCanReorderRecords(true);
        employeeTreeGrid.setCanAcceptDroppedRecords(true);
        employeeTreeGrid.setShowOpenIcons(false);
        employeeTreeGrid.setDropIconSuffix("into");
        employeeTreeGrid.setClosedIconSuffix("");
        employeeTreeGrid.setData(employeeTree);
        employeeTreeGrid.setFields(formattedField);
       
        return employeeTreeGrid;
    }
View Full Code Here

TOP

Related Classes of com.smartgwt.client.widgets.tree.TreeGrid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.