User: juha    
  Date: 01/02/18 12:27:39

  Modified:    src/org/jboss/admin/monitor/tree BeanTreeNode.java
                        ApplicationTreeModel.java
  Added:       src/org/jboss/admin/monitor/tree BeanCacheTreeNode.java
                        ApplicationTreeCellRenderer.java
  Log:
  Cell renderer for the app tree.
  Bean cache leaf for the bean nodes.
  
  Revision  Changes    Path
  1.2       +19 -0     admin/src/org/jboss/admin/monitor/tree/BeanTreeNode.java
  
  Index: BeanTreeNode.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/tree/BeanTreeNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanTreeNode.java 2000/12/17 20:11:25     1.1
  +++ BeanTreeNode.java 2001/02/18 20:27:38     1.2
  @@ -88,6 +88,25 @@
           return node;
       }
   
  +    public BeanCacheTreeNode addBeanCache() {
  +        BeanCacheTreeNode node = new BeanCacheTreeNode("Bean Cache");
  +        
  +        return addBeanCache(node);
  +    }
  +    
  +    public BeanCacheTreeNode addBeanCache(BeanCacheTreeNode node) {
  +        
  +        if (children.contains(node))
  +            return (BeanCacheTreeNode)children.get(children.indexOf(node));
  +            
  +        // insert cache as first node
  +        insert(node, 0);
  +        
  +        ((RootNode)getRoot()).getTreeModel().nodeStructureChanged(this);
  +        
  +        return node;
  +    }
  +    
   /*
    *************************************************************************
    *
  
  
  
  1.2       +15 -3     admin/src/org/jboss/admin/monitor/tree/ApplicationTreeModel.java
  
  Index: ApplicationTreeModel.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/tree/ApplicationTreeModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ApplicationTreeModel.java 2000/12/17 20:11:25     1.1
  +++ ApplicationTreeModel.java 2001/02/18 20:27:38     1.2
  @@ -10,7 +10,8 @@
   import javax.swing.event.TreeModelListener;
   
   // non-standard class dependencies
  -import org.jboss.admin.InvocationEntry;
  +import org.jboss.admin.dataholder.InvocationEntry;
  +import org.jboss.admin.dataholder.BeanCacheEntry;
   import org.jboss.admin.monitor.graph.InvocationTimeGraphModel;
   
   
  @@ -61,7 +62,7 @@
        * adds a new invocation entry to this model
        * will grab the relevant info from TxEntry
        */
  -    public void addInvocationEntry(InvocationEntry entry) {
  +    public void addEntry(InvocationEntry entry) {
           
           String applicationName = entry.getApplication();
           String beanName        = entry.getBean();
  @@ -76,8 +77,19 @@
           // Add the invocation entry to the graph model associated with 
           // the method tree node as well.
           InvocationTimeGraphModel graphModel = methodNode.getGraphModel();
  -        graphModel.appendInvocationEntry(entry);
  +        graphModel.appendInvocationEntry(entry);        
  +    }
  +    
  +    public void addEntry(BeanCacheEntry entry) {
  +        
  +        String applicationName = entry.getApplication();
  +        String beanName        = entry.getBean();
           
  +        RootNode root = (RootNode)getRoot();
  +        
  +        ApplicationTreeNode appNode = root.addApplication(applicationName);
  +        BeanTreeNode beanNode       = appNode.addBean(beanName);
  +        BeanCacheTreeNode cacheNode = beanNode.addBeanCache();
       }
       
   }
  
  
  
  1.1                  admin/src/org/jboss/admin/monitor/tree/BeanCacheTreeNode.java
  
  Index: BeanCacheTreeNode.java
  ===================================================================
  package org.jboss.admin.monitor.tree;
  
  // standard imports
  import javax.swing.tree.DefaultMutableTreeNode;
  import java.util.Vector;
  
  // non-standard class dependencies
  //import org.jboss.admin.monitor.graph.InvocationTimeGraphModel;
  
  
  /**
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   */
  public class BeanCacheTreeNode extends DefaultMutableTreeNode {
  
      // superclass implements Serializable, Cloneable
  
      private final static boolean ALLOW_CHILDREN = false;
  
      /*
       * each node contains a reference to the graph model that visualizes
       * the data received as TxEntries from metrics invocation layer
       *
       * initialized in the constructor
       */
      //private InvocationTimeGraphModel graphModel  =  null;
      
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */
   
      /*
       * constructs a node with method as user object
       * no children allowed
       */
      public BeanCacheTreeNode(String name) {
          super(name, ALLOW_CHILDREN);
  
          // superclass creates children collection lazily but I want it
          // to be around right after construction to avoid making NPE checks
          children = new Vector();
          
          // initialize the graph model for this node
          //graphModel = new InvocationTimeGraphModel();
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */
   
      /*
       * each method node contains a reference to a graph model that represents
       * the data from the metrics invocation layer
       */     
      //public InvocationTimeGraphModel getGraphModel() {
      //   return graphModel; 
      //}
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */
   
      public int hashCode() {
          return getUserObject().hashCode();
      }
      
      public boolean equals(Object obj) {
       
          if (obj == null)
              return false;
              
          if (this == obj)
              return true;
              
          if (getClass().equals(obj.getClass())) {
              DefaultMutableTreeNode node = (DefaultMutableTreeNode)obj;
              
              if (node.getUserObject().equals(this.getUserObject()))
                  return true;
          }
          
          return false;
      }
  }
  
  
  
  
  1.1                  
admin/src/org/jboss/admin/monitor/tree/ApplicationTreeCellRenderer.java
  
  Index: ApplicationTreeCellRenderer.java
  ===================================================================
  /*
   * Class ApplicationTreeCellRenderer
   * Copyright (C) 2001  Juha Lindfors
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
   * License as published by the Free Software Foundation; either
   * version 2 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Library General Public License for more details.
   *
   * You should have received a copy of the GNU Library General Public
   * License along with this library; if not, write to the
   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   * Boston, MA  02111-1307, USA.
   *
   * This package and its source code is available at www.jboss.org
   * $Id: ApplicationTreeCellRenderer.java,v 1.1 2001/02/18 20:27:38 juha Exp $
   */     
  package org.jboss.admin.monitor.tree;
  
  // standard imports
  import java.net.URL;
  import java.awt.Component;
  import javax.swing.ImageIcon;
  import javax.swing.JTree;
  import javax.swing.tree.DefaultTreeCellRenderer;
  
  // non-standard class dependencies
  import org.jboss.admin.monitor.MonitorResourceConstants;
  
  
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   * @version $Revision: 1.1 $
   */     
  public class ApplicationTreeCellRenderer extends    DefaultTreeCellRenderer
                                           implements MonitorResourceConstants {
  
      private transient ImageIcon ejbIcon         = null;
      private transient ImageIcon cacheIcon       = null;
      private transient ImageIcon applicationIcon = null;
      private transient ImageIcon methodIcon      = null;
      private transient ImageIcon serverIcon      = null;
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */ 
      
      public ApplicationTreeCellRenderer() {
          
          URL url = getClass().getResource(BEAN_ICON_16);
          if (url != null)
              ejbIcon = new ImageIcon(url);
          
          url = getClass().getResource(CACHE_ICON_16);
          if (url != null)
              cacheIcon = new ImageIcon(url);
          
          url = getClass().getResource(JAR_ICON_16);
          if (url != null)
              applicationIcon = new ImageIcon(url);
          
          url = getClass().getResource(METHOD_ICON_16);
          if (url != null)
              methodIcon = new ImageIcon(url);
              
          url = getClass().getResource(SERVER_ICON_16);
          if (url != null)
              serverIcon = new ImageIcon(url);
      }
      
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */     
  
      public Component getTreeCellRendererComponent(JTree tree, Object value,
              boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  
          super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, 
hasFocus);    
          
          if (value instanceof BeanTreeNode)
              setIcon(ejbIcon);
          else if (value instanceof BeanCacheTreeNode)
              setIcon(cacheIcon);
          else if (value instanceof MethodTreeNode)
              setIcon(methodIcon);
          else if (value instanceof ApplicationTreeNode)
              setIcon(applicationIcon);
          else if (value instanceof RootNode)
              setIcon(serverIcon);
         
          return this;
      }
  }
  
  
  

Reply via email to