Hi Salva, After you change the model (i.e. a node), you have to call nodeChanged() method so that the view (i.e. ULCTableTree) will be notified to update itself a per the new model.
I hope this helps. Thanks and regards, Janak PS: Please post your queries to [EMAIL PROTECTED] instead of sending them directly to the person in charge of support. >-----Original Message----- >From: salva vilarrasa [mailto:[EMAIL PROTECTED] >Sent: Thursday, May 04, 2006 9:04 PM >To: Janak Mulani >Subject: Re: [ULC-developer] TableTree > > >Hi janak, >I set up the model of the TableTree from the text file. But i have >a little >problem, I got a class which implemets ITableTreeNode. This class >represents each node in the Table. I have created a method >setValues(String >a) which is used to initialize the values when this is not done >through the >constructor. Two constructors available nodes() and nodes(String a). If a >node is created using the nodes(String a) constructor, the value is >correctly displayed in the TableTree, but if a create a node using the >nodes() constructor and after i call setValues(String a) to set the value >for this node, the value is not displayed...I tried to repaint the >component >but no data appears in the TableTree. Have any idea? > > >----- Original Message ----- >From: "Janak Mulani" <[EMAIL PROTECTED]> >To: "salva vilarrasa" <[EMAIL PROTECTED]> >Cc: <[email protected]> >Sent: Friday, June 16, 2006 1:11 PM >Subject: RE: [ULC-developer] TableTree > > >> Hi Salva, >> >> There is a code sample for ULCTableTree in the ULCSet sample application. >> This should give you an idea about how to set up the model for a >> ULCTableTree. >> >> You can initialize your TableTreeModel from a text file when your >> application starts and set this model on ULCTableTree. ULCTableTree, like >> ULCTable & ULCTree, implements lazy loading of data on the client side - >> meaning that only those rows/nodes that become visible will be >uploaded to >> the client to the server. >> >> Now, if you don't want to initialize the model in one shot because it is >> too >> time consuming and it will slow down the app statrtup, then you can >> initialize part of the model initially. You can then use a >ULCPollingTimer >> to add the model piece by piece. >> >> Another option in Servlet context is to make the model an adpter to a >> collection. This collection can be initialized in a separate servlet and >> it >> is shared through the session with your ULC application. >> >> You can certainly add child nodes to a node when it is >double-clicked. See >> the snippet below. >> >> But fetching the model data from a web service on some view action will >> slow >> down your UI. You should do this only if the child node data is >dependent >> on >> some context. As far as possible you should keep the model initialized so >> that data is available to the view on demand. >> >> I hope this helps. >> >> Thanks and regards, >> >> Janak >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] Behalf Of salva vilarrasa >> Sent: Tuesday, May 16, 2006 5:39 PM >> To: [EMAIL PROTECTED] Com >> Subject: [ULC-developer] tabletree >> >> >> Hi all, >> I would like to build a TableTree setting the tree from a txt file, the >> problem is that i do not want to initialize the values of the table, >> because >> performance. Is it possible to get the values from a web service when a >> node >> is doubleclicked or opened? any clue about how to do it, cause i am >> struggling with TableTree's. Thanks. >> >> ---------- >> >> import com.ulcjava.base.application.AbstractApplication; >> import com.ulcjava.base.application.ULCBoxPane; >> import com.ulcjava.base.application.ULCFrame; >> import com.ulcjava.base.application.ULCScrollPane; >> import com.ulcjava.base.application.ULCTableTree; >> import com.ulcjava.base.application.event.ActionEvent; >> import com.ulcjava.base.application.event.IActionListener; >> import com.ulcjava.base.application.tabletree.DefaultTableTreeModel; >> import com.ulcjava.base.application.tabletree.ITableTreeModel; >> import com.ulcjava.base.application.tabletree.ITableTreeNode; >> import com.ulcjava.base.application.tree.TreePath; >> import com.ulcjava.base.development.DevelopmentRunner; >> import com.ulcjava.base.shared.internal.IllegalArgumentException; >> >> import java.io.Serializable; >> import java.util.ArrayList; >> import java.util.List; >> >> public class TableTreeDemo extends AbstractApplication { >> private static final String UNIX_ICON_PATH = "unix.gif"; >> private static final String IBM_ICON_PATH = "ibm.gif"; >> private static final String BSD_ICON_PATH = "bsd.gif"; >> private static final String SUN_ICON_PATH = "sun.gif"; >> private static final String SOLARIS_ICON_PATH = "sol.gif"; >> private static final String DEC_ICON_PATH = "dec.gif"; >> private static final String HP_ICON_PATH = "hp.gif"; >> >> public static class UnixTableTreeNode implements ITableTreeNode, >> Serializable { >> public static final int NAME_COLUMN = 0; >> public static final int COMPANY_COLUMN = 1; >> public static final int YEAR_COLUMN = 2; >> public static final int ICON_COLUMN = 3; >> >> private String fName; >> private String fCompany; >> private int fYear; >> private String fIconFilePath; >> >> private UnixTableTreeNode fParent; >> private List fChildren; >> >> public UnixTableTreeNode(String name, String company, int year, >> String iconFilePath) { >> fName = name; >> fCompany = company; >> fYear = year; >> fIconFilePath = iconFilePath; >> >> fChildren = new ArrayList(); >> } >> >> public void addChild(UnixTableTreeNode child) { >> fChildren.add(child); >> child.setParent(this); >> } >> >> public ITableTreeNode getChildAt(int index) { >> return (ITableTreeNode)fChildren.get(index); >> } >> >> public int getChildCount() { >> return fChildren.size(); >> } >> >> public ITableTreeNode getParent() { >> return fParent; >> } >> >> private void setParent(UnixTableTreeNode parent) { >> fParent = parent; >> } >> >> public Object getValueAt(int column) { >> switch (column) { >> case NAME_COLUMN: >> return fName; >> case COMPANY_COLUMN: >> return fCompany; >> case YEAR_COLUMN: >> return new Integer(fYear); >> case ICON_COLUMN: >> return fIconFilePath; >> default: >> throw new IllegalArgumentException("unknown >attribute: >> " >> + column); >> } >> } >> >> public boolean isLeaf() { >> return false; >> } >> >> public int getIndex(ITableTreeNode aChild) { >> return fChildren.indexOf(aChild); >> } >> } >> >> private static final int ROW_HEIGHT = 38; >> private ULCTableTree fTableTree; >> >> private final ULCTableTree buildTableTree() { >> ULCTableTree result = new ULCTableTree(); >> result.setModel(createTableTreeModel()); >> result.setRowHeight(ROW_HEIGHT); >> result.getColumn("Unix Version").setPreferredWidth(200); >> return result; >> } >> >> public ULCBoxPane getContent() { >> ULCScrollPane scrollPane = new ULCScrollPane(fTableTree); >> ULCBoxPane box = new ULCBoxPane(); >> box.add(ULCBoxPane.BOX_EXPAND_EXPAND, scrollPane); >> return box; >> } >> >> private ITableTreeModel createTableTreeModel() { >> UnixTableTreeNode multics = new UnixTableTreeNode("Multics", >> "AT&T", >> 1969, UNIX_ICON_PATH); >> UnixTableTreeNode unix = new UnixTableTreeNode("Unix", "AT&T", >> 1969, >> UNIX_ICON_PATH); >> UnixTableTreeNode unix1 = new UnixTableTreeNode("Version 1", >> "AT&T", >> 1971, UNIX_ICON_PATH); >> UnixTableTreeNode unix4 = new UnixTableTreeNode("Version 4", >> "AT&T", >> 1973, UNIX_ICON_PATH); >> UnixTableTreeNode unix6 = new UnixTableTreeNode("Version 6", >> "AT&T", >> 1975, UNIX_ICON_PATH); >> UnixTableTreeNode unix7 = new UnixTableTreeNode("Version 7", >> "AT&T", >> 1979, UNIX_ICON_PATH); >> UnixTableTreeNode systemIII = new UnixTableTreeNode("System III", >> "AT&T", 1982, UNIX_ICON_PATH); >> UnixTableTreeNode systemV = new UnixTableTreeNode("System V", >> "AT&T", 1983, UNIX_ICON_PATH); >> UnixTableTreeNode svr2 = new UnixTableTreeNode("SVR 2", "AT&T", >> 1984, UNIX_ICON_PATH); >> UnixTableTreeNode svr3 = new UnixTableTreeNode("SVR 3", "AT&T", >> 1987, UNIX_ICON_PATH); >> UnixTableTreeNode svr32 = new UnixTableTreeNode("SVR 3.2", "AT&T", >> 1988, UNIX_ICON_PATH); >> UnixTableTreeNode svr4 = new UnixTableTreeNode("SVR 4", "AT&T", >> 1989, UNIX_ICON_PATH); >> UnixTableTreeNode svr42 = new UnixTableTreeNode("SVR 4.2", "USL", >> 1992, UNIX_ICON_PATH); >> UnixTableTreeNode aix30 = new UnixTableTreeNode("AIX 3.0", "IBM", >> 1991, IBM_ICON_PATH); >> UnixTableTreeNode aix32 = new UnixTableTreeNode("AIX 3.2", "IBM", >> 1992, IBM_ICON_PATH); >> UnixTableTreeNode aix41 = new UnixTableTreeNode("AIX 4.1", "IBM", >> 1993, IBM_ICON_PATH); >> UnixTableTreeNode bsd41 = new UnixTableTreeNode("4.1BSD", >> "Berkeley", 1979, BSD_ICON_PATH); >> UnixTableTreeNode bsd42 = new UnixTableTreeNode("4.2BSD", >> "Berkeley", 1984, BSD_ICON_PATH); >> UnixTableTreeNode bsd43 = new UnixTableTreeNode("4.3BSD", >> "Berkeley", 1986, BSD_ICON_PATH); >> UnixTableTreeNode bsd44 = new UnixTableTreeNode("4.4BSD", >> "Berkeley", 1993, BSD_ICON_PATH); >> UnixTableTreeNode sunOS = new UnixTableTreeNode("SunOS", "Sun", >> 1980, SUN_ICON_PATH); >> UnixTableTreeNode sunOS40 = new UnixTableTreeNode("SunOS 4.0", >> "Sun", 1991, SUN_ICON_PATH); >> UnixTableTreeNode solaris1 = new UnixTableTreeNode("Solaris 1", >> "Sun", 1992, SOLARIS_ICON_PATH); >> UnixTableTreeNode solaris2 = new UnixTableTreeNode("Solaris 2", >> "Sun", 1993, SOLARIS_ICON_PATH); >> UnixTableTreeNode ultrix32 = new UnixTableTreeNode("Ultrix 3.2", >> "DEC", 1981, DEC_ICON_PATH); >> UnixTableTreeNode hpux = new UnixTableTreeNode("HP-UX", >"HP", 1981, >> HP_ICON_PATH); >> UnixTableTreeNode hpux7 = new UnixTableTreeNode("HP-UX 7", "HP", >> 1991, HP_ICON_PATH); >> >> UnixTableTreeNode root = multics; >> multics.addChild(unix); >> unix.addChild(unix1); >> unix1.addChild(unix4); >> unix4.addChild(unix6); >> unix6.addChild(unix7); >> unix7.addChild(systemIII); >> systemIII.addChild(systemV); >> systemV.addChild(svr2); >> svr2.addChild(svr3); >> svr3.addChild(svr32); >> svr32.addChild(svr4); >> svr4.addChild(svr42); >> >> svr4.addChild(aix30); >> aix30.addChild(aix32); >> aix32.addChild(aix41); >> >> unix7.addChild(bsd41); >> bsd41.addChild(bsd42); >> bsd42.addChild(bsd43); >> bsd43.addChild(bsd44); >> >> bsd42.addChild(sunOS); >> sunOS.addChild(sunOS40); >> sunOS40.addChild(solaris1); >> solaris1.addChild(solaris2); >> >> sunOS.addChild(ultrix32); >> >> bsd42.addChild(hpux); >> hpux.addChild(hpux7); >> >> return new DefaultTableTreeModel(root, new String[]{"Unix >Version", >> "Company", "Year", ""}); >> } >> >> >> >> public void start() { >> fTableTree = buildTableTree(); >> fTableTree.addActionListener(new IActionListener() { >> >> public void actionPerformed(ActionEvent event) { >> ULCTableTree src = (ULCTableTree)event.getSource(); >> TreePath path = src.getSelectedPath(); >> UnixTableTreeNode node = >> (UnixTableTreeNode)path.getLastPathComponent(); >> node.addChild(new UnixTableTreeNode("1", "1", 1, "1")); >> node.addChild(new UnixTableTreeNode("1", "1", 1, "1")); >> node.addChild(new UnixTableTreeNode("1", "1", 1, "1")); >> >> ((DefaultTableTreeModel)(fTableTree.getModel())).nodeStructur >> eChanged(node); >> } >> >> }); >> >> >> >> ULCFrame frame = new ULCFrame("TableTreeDemo"); >> frame.setSize(400,400); >> frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE); >> frame.add(getContent()); >> frame.setVisible(true); >> } >> >> public static void main(String[] args) { >> DevelopmentRunner.setApplicationClass(TableTreeDemo.class); >> DevelopmentRunner.run(); >> } >> } >> >> _______________________________________________ >> ULC-developer mailing list >> [email protected] >> http://lists.canoo.com/mailman/listinfo/ulc-developer >> _______________________________________________ ULC-developer mailing list [email protected] http://lists.canoo.com/mailman/listinfo/ulc-developer
