0
votes

I'm refactoring my GWT App with the framework Editor.

I'm stuck with a view that contains a CellTree widget. I don't see how to wrap my CustomTreeViewModel with the editor Framework. Maybe I need to subclass the CellTree class?

Precision :
Here is my data structure in the CellTree :
rootLevel is null
ZoneProxy :

ZoneProxy parent;
List<ZoneProxy> childs;
List<PointProxy> points;

So I can have this :

|_ Zone 1
|  |_Zone 1.1
|  |_Zone 1.2
|     |_Point 1
|     |_Point 2
|_ Zone 2
.
.
.

I get the CellTree working without the EditorFramework, using two hashMaps :

private Map<ZoneProxy,ListDataProvider<ZoneProxy>> treeListDataZones;
private Map<ZoneProxy,ListDataProvider<PointProxy>> treeListDataPoints;

When a user clicks on a a Point in the tree, I have a right panel that should show the details of the point clicked.

I get the CellTree fills datas with the EditorFramework, but I make the CustomTreeViewModel of the CellTree implementing LeafValueEditor. I don't see how to go deeper with Editors. (I don't know wich Sub Editors I have to create with my data structure)

I think I'm missing something with the EditorFramework, I gonna read the Google DevGuide again.

I don't find any examples using Celltree with the Framework Editor. If someone has a good example, it will help me a lot. :)

Thanks

1
I found an adapter that adapts ListDataProvider to a ListEditor. I will see if it works, here is the link of the adapters : Adapter Link - Pintouch
I m trying to use a CompositeEditor build like this : CompositeEditor<List<ZoneProxy>,List<PointProxy>,ListEditor<PointProxy,PointContentEditor>>. Is it a good idea? I gonna check the ListEditor code, it's a CompositeEditor<T,T,C>. But mine is Composite<T,List<U>,ListEditor<U,C>>... It's gonna be complex. :s - Pintouch

1 Answers

0
votes

Hope it will help you. Here is the sample code with some modification in actual code from Here. Double click on text item to edit it.

import com.google.gwt.cell.client.EditTextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.TreeViewModel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GWTTestProject implements EntryPoint {
    /**
     * This is the entry point method.
     */
    public void onModuleLoad() {

        // Create a model for the tree.
        TreeViewModel model = new CustomTreeModel();

        /*
         * Create the tree using the model. We specify the default value of the
         * hidden root node as "Item 1".
         */
        CellTree tree = new CellTree(model, "Item 1");

        // Add the tree to the root layout panel.
        RootLayoutPanel.get().add(tree);

    }

    /**
     * The model that defines the nodes in the tree.
     */
    private static class CustomTreeModel implements TreeViewModel {

      /**
       * Get the {@link NodeInfo} that provides the children of the specified
       * value.
       */
      public <T> NodeInfo<?> getNodeInfo(T value) {
        /*
         * Create some data in a data provider. Use the parent value as a prefix
         * for the next level.
         */
        ListDataProvider<String> dataProvider = new ListDataProvider<String>();
        for (int i = 0; i < 2; i++) {
          dataProvider.getList().add(value + "." + String.valueOf(i));
        }

        EditTextCell textCell=new EditTextCell();
        // Return a node info that pairs the data with a cell.
        return new DefaultNodeInfo<String>(dataProvider, textCell);
      }

      /**
       * Check if the specified value represents a leaf node. Leaf nodes cannot be
       * opened.
       */
      public boolean isLeaf(Object value) {
        // The maximum length of a value is ten characters.
        return value.toString().length() > 10;
      }
    }

}