Have you tried EditTextCell? It shows readonly text, but turns into a Text Box when you click on it. Sounds like what you want.
Thanks, John LaBanca [email protected] On Sat, Nov 20, 2010 at 11:45 AM, dleins <[email protected]> wrote: > I've succeeded in displaying a dynamic Celltree from my database of > nodes, but cannot figure out how to make the displayed TextCells > clickable so that I may edit them, add additional children, etc. I > admit I am rather a novice using the new Cell Widgets. > > Here is the stripped down code. I have left out the code that > generates my arraylist of tree node (alNodes). Any help, thoughts or > suggestions would be greatly appreciated. A simple example that > popped a Window.alert when a TextCell was clicked would be more than > sufficient! Perhaps a ClickableTextCell would work? > > private class CustomTreeModel implements TreeViewModel { > > public <T> NodeInfo<?> getNodeInfo(T value) { > ListDataProvider<String> dataProvider = new > ListDataProvider<String>(); > > String type = ""; > Integer parent = 0; > Integer child = 0; > > // for the root of the tree > if (value == null) { > for (int i = 0; i < alNodes.size(); i++) { > if (alNodes.get(i).ruid == startnode > && alNodes.get(i).type == > "S") { > > dataProvider.getList().add(alNodes.get(i).title); > break; > } > } > } else { > // get the current node info from > alNodes ArrayList > for (int i = 0; i < alNodes.size(); i++) { > if > (alNodes.get(i).title.equals(value)) { > type = alNodes.get(i).type; > parent = > alNodes.get(i).ruid; > child = > alNodes.get(i).destSituation; > } > } > // Depending on the type of the > current node, find the child or children for the dataprovider for the > next level > if (type.equals("A")) { > for (int j = 0; j < alNodes.size(); j++) > { > if (alNodes.get(j).ruid == > child) { > > dataProvider.getList().add(alNodes.get(j).title); > break; // Note > that "A" type nodes will only have a single > child > } > } > } else { > for (int j = 0; j < alNodes.size(); > j++) { > if > (alNodes.get(j).parentSituation == parent) { > > dataProvider.getList().add(alNodes.get(j).title); > } > } > } > } > > return new DefaultNodeInfo<String>(dataProvider, new > TextCell()); > } > > public boolean isLeaf(Object value) { > String type = ""; > Integer parent = 0; > Integer child = 0; > for (int i = 0; i < alNodes.size(); i++) { > if (alNodes.get(i).title.equals(value)) { > type = alNodes.get(i).type; > parent = alNodes.get(i).ruid; > child = > alNodes.get(i).destSituation; > } > } > if (type.equals("A")) { > for (int j = 0; j < alNodes.size(); j++) { > if (alNodes.get(j).ruid == child) { > return false; > } > } > } else { > for (int j = 0; j < alNodes.size(); j++) { > if (alNodes.get(j).parentSituation > == parent) { > return false; > } > } > } > return true; > } > } > > public void onModuleLoad() { > > Button button = new Button("Start Simulation Editor"); > button.addClickHandler(new ClickHandler() { > public void onClick(ClickEvent event) { > TreeViewModel model = new CustomTreeModel(); > CellTree tree = new CellTree(model, null); > RootPanel.get().add(tree); > } > }); > RootPanel.get().add(button); > // There is code here that populates the alNodes ArrayList. It works > fine. > } > > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-web-toolkit%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
