tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / odk / examples / java / Inspector / UnoTreeRenderer.java
blob81e62a6d19d4b733b19644d8221dcdccf32c2366
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * the BSD license.
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
35 import java.awt.Component;
36 import java.awt.Graphics;
37 import javax.swing.Icon;
38 import javax.swing.ImageIcon;
39 import javax.swing.JTree;
40 import javax.swing.tree.DefaultMutableTreeNode;
41 import javax.swing.tree.DefaultTreeCellRenderer;
45 public class UnoTreeRenderer extends DefaultTreeCellRenderer{
46 private Icon m_oMethodIcon;
47 private Icon m_oPropertyIcon;
48 private Icon m_oContainerIcon;
49 private Icon m_oContentIcon;
50 private Icon m_oServiceIcon;
51 private Icon m_oInterfaceIcon;
52 private Icon m_oPropertyValueIcon;
53 private boolean bSelected;
54 private int nWidth = 0;
57 /** Creates a new instance of UnoTreeRenderer */
58 public UnoTreeRenderer(){
59 super();
60 try {
62 final ClassLoader loader = ClassLoader.getSystemClassLoader();
63 m_oMethodIcon = new ImageIcon(loader.getResource("images/methods_16.png"));
64 m_oPropertyIcon = new ImageIcon("images/properties_16.png");
65 m_oPropertyValueIcon = new ImageIcon("images/properties_16.png");
66 m_oContainerIcon = new ImageIcon("images/containers_16.png");
67 m_oServiceIcon = new ImageIcon("images/services_16.png");
68 m_oInterfaceIcon = new ImageIcon("images/interfaces_16.png");
69 m_oContentIcon = new ImageIcon("images/content_16.png");
70 } catch (RuntimeException e) {
71 System.out.println("Sorry, could not locate resources, treecell icons will not be displayed.");
76 @Override
77 public synchronized Component getTreeCellRendererComponent(JTree tree,Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus){
78 try{
79 bSelected = sel;
80 DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
81 Component rc = super.getTreeCellRendererComponent( tree, value, sel,expanded, leaf, row,hasFocus);
82 String sLabelText = (String)node.getUserObject();
83 if (sLabelText != null){
84 if (sLabelText.equals(XUnoFacetteNode.SCONTAINERDESCRIPTION)){
85 } else if (sLabelText.equals(XUnoFacetteNode.SCONTENTDESCRIPTION)){
86 } else if (sLabelText.equals(XUnoFacetteNode.SINTERFACEDESCRIPTION)){
87 } else if (sLabelText.equals(XUnoFacetteNode.SMETHODDESCRIPTION)){
88 } else if (sLabelText.equals(XUnoFacetteNode.SPROPERTYDESCRIPTION)){
89 } else if (sLabelText.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
90 } else if (sLabelText.equals(XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION)){
91 } else if (sLabelText.equals(XUnoFacetteNode.SSERVICEDESCRIPTION)){
92 } else{
93 setText(sLabelText);
94 rc.validate();
96 setSize(getPreferredSize());
97 rc.validate();
98 doLayout();
100 } catch (RuntimeException e) {
101 System.out.println("Sorry, icon for treecell could not be displayed.");
103 return this;
108 @Override
109 public void paintComponent(Graphics g) {
110 int x;
111 if(getIcon() == null) {
112 x = 0;
113 } else {
114 x = getIcon().getIconWidth() + getIconTextGap();
116 g.setColor(getForeground());
117 super.paintComponent(g);
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */