1*db859879SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*db859879SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*db859879SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*db859879SAndrew Rist * distributed with this work for additional information 6*db859879SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*db859879SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*db859879SAndrew Rist * "License"); you may not use this file except in compliance 9*db859879SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*db859879SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*db859879SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*db859879SAndrew Rist * software distributed under the License is distributed on an 15*db859879SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*db859879SAndrew Rist * KIND, either express or implied. See the License for the 17*db859879SAndrew Rist * specific language governing permissions and limitations 18*db859879SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*db859879SAndrew Rist *************************************************************/ 21*db859879SAndrew Rist 22*db859879SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package com.sun.star.xml.security.uno; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import javax.swing.tree.DefaultTreeCellRenderer; 27cdf0e10cSrcweir import org.w3c.dom.Node; 28cdf0e10cSrcweir import javax.swing.ImageIcon; 29cdf0e10cSrcweir import java.awt.Component; 30cdf0e10cSrcweir import javax.swing.JTree; 31cdf0e10cSrcweir 32cdf0e10cSrcweir /* 33cdf0e10cSrcweir * a TreeCellRender which can show a graph on the current 34cdf0e10cSrcweir * tree node. 35cdf0e10cSrcweir */ 36cdf0e10cSrcweir class XMLTreeCellRanderer extends DefaultTreeCellRenderer 37cdf0e10cSrcweir { 38cdf0e10cSrcweir /* 39cdf0e10cSrcweir * the icon for the current Node 40cdf0e10cSrcweir */ 41cdf0e10cSrcweir private ImageIcon m_currentIcon; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /* 44cdf0e10cSrcweir * the current Node 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir private Node m_currentNode; 47cdf0e10cSrcweir 48cdf0e10cSrcweir XMLTreeCellRanderer(Node currentNode) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir m_currentNode = currentNode; 51cdf0e10cSrcweir m_currentIcon = new ImageIcon("current.gif"); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir public Component getTreeCellRendererComponent( 55cdf0e10cSrcweir JTree tree, 56cdf0e10cSrcweir Object value, 57cdf0e10cSrcweir boolean sel, 58cdf0e10cSrcweir boolean expanded, 59cdf0e10cSrcweir boolean leaf, 60cdf0e10cSrcweir int row, 61cdf0e10cSrcweir boolean hasFocus) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir super.getTreeCellRendererComponent( 64cdf0e10cSrcweir tree, value, sel, 65cdf0e10cSrcweir expanded, leaf, row, 66cdf0e10cSrcweir hasFocus); 67cdf0e10cSrcweir 68cdf0e10cSrcweir if (((AdapterNode)value).getNode() == m_currentNode) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir setIcon(m_currentIcon); 71cdf0e10cSrcweir setToolTipText("This is the current element."); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir else 74cdf0e10cSrcweir { 75cdf0e10cSrcweir setToolTipText(null); /* no tool tip */ 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir return this; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82