001    package org.shiftone.jrat.provider.tree.ui;
002    
003    import org.shiftone.jrat.core.spi.ViewBuilder;
004    import org.shiftone.jrat.provider.tree.TreeNode;
005    import org.shiftone.jrat.util.Assert;
006    
007    import javax.swing.*;
008    import java.io.ObjectInputStream;
009    import java.util.Properties;
010    import java.util.Set;
011    
012    /**
013     * @author jeff@shiftone.org (Jeff Drost)
014     */
015    public class TraceViewBuilder implements ViewBuilder { //, Externalizable {
016    
017        private static final long serialVersionUID = 1;
018        private TreeNode root;
019        private Set allMethodKeys;
020        private long sessionStartMs;
021        private long sessionEndMs;
022        private Properties systemProperties;
023        private String hostName;
024        private String hostAddress;
025    
026        public TraceViewBuilder() {
027        }
028    
029        public TraceViewBuilder(TreeNode root, Set allMethodKeys,
030                                long sessionStartMs, long sessionEndMs,
031                                Properties systemProperties,
032                                String hostName, String hostAddress) {
033    
034            Assert.assertNotNull(root);
035            Assert.assertNotNull(allMethodKeys);
036            Assert.assertNotNull(systemProperties);
037            Assert.assertNotNull(hostName);
038            Assert.assertNotNull(hostAddress);
039    
040            this.root = root;
041            this.allMethodKeys = allMethodKeys;
042            this.sessionStartMs = sessionStartMs;
043            this.sessionEndMs = sessionEndMs;
044            this.systemProperties = systemProperties;
045            this.hostName = hostName;
046            this.hostAddress = hostAddress;
047        }
048    
049        public JComponent buildView(ObjectInputStream input) throws Exception {
050    
051            return new TraceViewPanel(
052                    new TraceTreeNode(root),
053                    allMethodKeys,
054                    sessionStartMs, sessionEndMs,
055                    systemProperties,
056                    hostName, hostAddress);
057        }
058    
059    //
060    //    public void writeExternal(ObjectOutput out) throws IOException {
061    //        root.writeExternal(out);
062    //    }
063    //
064    //    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
065    //        root = new TreeNode();
066    //        root.readExternal(in);
067    //    }
068    }