Package com.inmethod.grid.treegrid

Examples of com.inmethod.grid.treegrid.TreeGrid$TreeStateListener


    columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4"));
    columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5"));
    columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6"));
   
    TreeModel model = TreeModelFactory.createTreeModel();
    TreeGrid grid = new TreeGrid("grid", model, columns);
   
    grid.setContentHeight(23, SizeUnit.EM);
   
    // expand the root node
    grid.getTreeState().expandAll();
   
    add(grid);
  }
View Full Code Here


    );
    columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5"));
    columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6"));

    TreeModel model = TreeModelFactory.createTreeModel();
    TreeGrid grid = new TreeGrid("grid", model, columns);

    // expand the root node
    grid.getTreeState().expandNode((TreeNode) model.getRoot());
    grid.setContentHeight(23, SizeUnit.EM);

    add(grid);
  }
View Full Code Here

    columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4"));
    columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5"));
    columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6"));
   
    TreeModel model = TreeModelFactory.createTreeModel();
    final TreeGrid grid = new TreeGrid("grid", model, columns) {
      private static final long serialVersionUID = 1L;

      @Override
      public void onItemSelectionChanged(IModel item, boolean newValue) {
        super.onItemSelectionChanged(item, newValue);
       
        // refresh the selection label when an item gets selected/deselected.
        AjaxRequestTarget target = AjaxRequestTarget.get();
        target.addComponent(selectionLabel);
      }
    };
   
    grid.setAllowSelectMultiple(true);
    grid.setClickRowToSelect(true);
    grid.setContentHeight(23, SizeUnit.EM);
   
    // expand the root node
    grid.getTreeState().expandNode((TreeNode) model.getRoot());
   
    add(grid);
   
    IModel selectedItemsModel = new Model() {
      private static final long serialVersionUID = 1L;
View Full Code Here

    columns.add(new EditablePropertyColumn(new Model("Property 4"), "userObject.property4"));
    columns.add(new EditablePropertyColumn(new Model("Property 5"), "userObject.property5"));
    columns.add(new EditablePropertyColumn(new Model("Property 6"), "userObject.property6"));   
   
    TreeModel model = TreeModelFactory.createTreeModel();
    TreeGrid grid = new TreeGrid("grid", model, columns);
   
    grid.setContentHeight(23, SizeUnit.EM);
    grid.setAllowSelectMultiple(true);
    grid.setClickRowToSelect(true);
    grid.setClickRowToDeselect(false);
    grid.setSelectToEdit(true);
   
    // expand the root node
    grid.getTreeState().expandNode((TreeNode) model.getRoot());
   
    add(grid);
  }
View Full Code Here

    columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4"));
    columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5"));
    columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6"));
   
    TreeModel model = TreeModelFactory.createTreeModel();
    TreeGrid grid = new TreeGrid("grid", model, columns);
   
    // expand the root node
    grid.getTreeState().expandNode((TreeNode) model.getRoot());
   
    add(grid);
  }
View Full Code Here

      tag.put("disabled", "disabled");

    } else if (getGrid() instanceof TreeGrid       
        && ((TreeGrid) getGrid()).isAutoSelectChildren()) {
     
      TreeGrid grid = (TreeGrid) getGrid();
      Object parent = grid.getTree().getParentNode(model.getObject());
      if (parent != null && grid.getTreeState().isNodeSelected(parent)) {
        tag.put("disabled", "disabled");
      }
    }
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    private void init() {
        treeModel = new MenuTreeModel(getModelObject().getRoot());

        final TreeGrid tg;
        add(tg = new TreeGrid("treeGrid", treeModel, newColumns()) {
            @Override
            protected void onItemSelectionChanged(IModel item, boolean newValue) {
                super.onItemSelectionChanged(item, newValue);

                //if (newValue == false)
                setItemEdit(item, newValue);

                selectionChanged(AjaxRequestTarget.get());
                // update();
            }

            @Override
            public void setItemEdit(IModel rowModel, boolean edit) {
                if (edit == true) {
                    selectItem(rowModel, true);
                }

                super.setItemEdit(rowModel, edit);
            }
        });

        tree = tg.getTree();
        tg.setClickRowToSelect(true);
        tg.setClickRowToDeselect(true);
        tg.setSelectToEdit(false);
        tree.setRootLess(true);
        tg.setContentHeight(34, SizeUnit.EM);

        tree.getTreeState().expandAll();
        tree.getTreeState().setAllowSelectMultiple(false);
        // tree.getTreeState().selectNode(treeModel.getRoot(), true);

        links = new WebMarkupContainer("links");
        links.setOutputMarkupId(true);

        links.add(new AjaxLink("addTopLevel") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuTreeNode parent = (MenuTreeNode) treeModel.getRoot();
                ChildEntry entry = new ChildEntry(parent.getEntry());
                entry.setTitle(getString("newEntry"));
                parent.getEntry().getChildren().add(entry);
                MenuTreeNode node = new MenuTreeNode(entry);
                treeModel.nodeInserted(tree, parent, node);
                tree.getTreeState().selectNode(node, true);
                tree.updateTree();
            }
        });

        links.add(new AjaxLink("add") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                ChildEntry entry = new ChildEntry(getSelected().getEntry());
                entry.setTitle(getString("newEntry"));
                getSelected().getEntry().getChildren().add(entry);
                MenuTreeNode node = new MenuTreeNode(entry);
                treeModel.nodeInserted(tree, getSelected(), node);
                tree.getTreeState().selectNode(node, true);
                tree.updateTree();
            }

            @Override
            public boolean isEnabled() {
                return !getSelected().equals(treeModel.getRoot());
            }
        });

        links.add(new AjaxLink("remove") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuTreeNode selected = getSelected();
                MenuTreeNode parent = (MenuTreeNode) tree.getParentNode(selected);

                boolean editing = tg.isItemEdited(new Model<MenuTreeNode>(selected));
                int index = parent.getChildren().indexOf(selected);
                treeModel.nodeDeleted(tree, selected);
                parent.getEntry().getChildren().remove(selected.getEntry());

                if (index > parent.getChildren().size() - 1) {
                    --index;
                }

                MenuTreeNode newSelected = (MenuTreeNode) ((index >= 0) ? parent.getChildren().get(index) : parent);
                if (newSelected.equals(treeModel.getRoot()) == false) {
                    tree.getTreeState().selectNode(newSelected, true);
                    tg.setItemEdit(new Model<MenuTreeNode>(newSelected), editing);
                }
                tree.updateTree();
            }

            @Override
            public boolean isEnabled() {
                return getSelected() != treeModel.getRoot();
            }
        });

        links.add(new AjaxLink("moveUp") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuTreeNode selected = getSelected();
                int index = getIndex(selected);
                if (index > 0) {
                    boolean editing = tg.isItemEdited(new Model<MenuTreeNode>(selected));

                    MenuTreeNode parent = (MenuTreeNode) tree.getParentNode(selected);
                    treeModel.nodeDeleted(tree, selected);
                    parent.getEntry().getChildren().remove(selected.getEntry());
                    parent.getEntry().getChildren().add(index - 1, (ChildEntry) selected.getEntry());
                    treeModel.nodeInserted(tree, parent, selected);


                    tree.getTreeState().selectNode(selected, true);
                    tg.setItemEdit(new Model<MenuTreeNode>(selected), editing);

                    tree.updateTree();
                }
                target.addComponent(links);
            }

            @Override
            public boolean isEnabled() {
                return getIndex(getSelected()) > 0;
            }
        });

        links.add(new AjaxLink("moveDown") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                MenuTreeNode selected = getSelected();
                MenuTreeNode parent = (MenuTreeNode) tree.getParentNode(selected);
                int index = getIndex(selected);
                if (index < parent.getChildren().size() - 1) {
                    boolean editing = tg.isItemEdited(new Model<MenuTreeNode>(selected));
                    treeModel.nodeDeleted(tree, selected);
                    parent.getEntry().getChildren().remove(selected.getEntry());
                    parent.getEntry().getChildren().add(index + 1, (ChildEntry) selected.getEntry());
                    treeModel.nodeInserted(tree, parent, selected);

                    tree.getTreeState().selectNode(selected, true);
                    tg.setItemEdit(new Model<MenuTreeNode>(selected), editing);

                    tree.updateTree();
                }
                target.addComponent(links);
            }
View Full Code Here

TOP

Related Classes of com.inmethod.grid.treegrid.TreeGrid$TreeStateListener

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.