I would like to translate a java example of tree vaadin to clojure. I have 
to files in the same folder: planets.clj and core.clj. I am having problems 
and I need help. What I am doing wrong?
*
*
*;; In the file planets.clj:*
(ns project.planets)
(let [planets (doto (Object.)
              (Object. ["Venus"])
              (Object. ["Earth" "The Moon"])
              (Object. ["Mars" "Phobos" "Deimos"])
              )]

*;; In the file core.clj:*
(load "planets")
(defn -cjinit [][[] (ref {})])
(defn -init [this]
  (let [tree (doto (com.vaadin.ui.Tree. "The Planets and Major Moons")
               (loop [i 0]
                 (str planet planets[i] 0)
                 (.addItem planet)
                 (if (= planets[i].length 1)
                   (.setChildrenAllowed planet false))
                 (loop [j 1]
                   (str moon planets[i][j])
                   (.addItem monn)
                   (.setParent moon planet)
                   (.setChildrenAllowed moon false))
                 (.expandItemsRecursively planet)
                 (recur (inc i))))]
    (do (.addComponent main tree))))


*;; Java*
final Object[][] planets = new Object[][]{
  new Object[]{"Mercury"},
      new Object[]{"Venus"},
      new Object[]{"Earth", "The Moon"},
      new Object[]{"Mars", "Phobos", "Deimos"},
      new Object[]{"Jupiter", "Io", "Europa", "Ganymedes",
        "Callisto"},
      new Object[]{"Saturn",  "Titan", "Tethys", "Dione",
        "Rhea", "Iapetus"},
      new Object[]{"Uranus",  "Miranda", "Ariel", "Umbriel",
        "Titania", "Oberon"},
      new Object[]{"Neptune", "Triton", "Proteus", "Nereid",
        "Larissa"}};
Tree tree = new Tree("The Planets and Major Moons");
for (int i=0; i<planets.length; i++) {
  String planet = (String) (planets[i][0]);
  tree.addItem(planet);
  if (planets[i].length == 1) {
    tree.setChildrenAllowed(planet, false);
  } else {
    for (int j=1; j<planets[i].length; j++) {
      String moon = (String) planets[i][j];
      tree.addItem(moon);
      tree.setParent(moon, planet);
      tree.setChildrenAllowed(moon, false);
    }
    tree.expandItemsRecursively(planet);
  }
}
main.addComponent(tree);
*
*
*;; The final result must be something like this:*

<http://vaadin.com/download/current/docs/book/img/components/tree-example1.png>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to