1 /************************************************************************* 2 * 3 * The Contents of this file are made available subject to the terms of 4 * the BSD license. 5 * 6 * Copyright 2000, 2010 Oracle and/or its affiliates. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 31 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 *************************************************************************/ 34 import com.sun.star.uno.Type; 35 import javax.swing.tree.TreeNode; 36 37 38 public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{ 39 private UnoNode m_oUnoNode; 40 41 /** Creates a new instance of SwingUnoNode */ 42 public SwingUnoNode(Object _oUnoObject) { 43 super(); 44 m_oUnoNode = new UnoNode(_oUnoObject); 45 } 46 47 48 public SwingUnoNode(Object _oUnoObject, Type _aType) { 49 super(); 50 m_oUnoNode = new UnoNode(_oUnoObject, _aType); 51 if (_aType != null){ 52 this.setLabel(_aType.getTypeName()); 53 } 54 } 55 56 57 public Object getUnoObject(){ 58 return m_oUnoNode.getUnoObject(); 59 } 60 61 public void setVisible(String _sFilter){ 62 boolean bisVisible = isFilterApplicable(_sFilter); 63 super.setVisible(bisVisible); 64 } 65 66 public boolean isFilterApplicable(String _sFilter) { 67 return m_oUnoNode.isFilterApplicable(_sFilter, getName()); 68 } 69 70 public void setParameterObjects(Object[] _oParamObjects) { 71 m_oUnoNode.setParameterObjects(_oParamObjects); 72 } 73 74 public void openIdlDescription(String _SDKPath) { 75 m_oUnoNode.openIdlDescription(_SDKPath, getClassName(), getAnchor()); 76 } 77 78 public Object[] getParameterObjects() { 79 return m_oUnoNode.getParameterObjects(); 80 } 81 82 public String getClassName(){ 83 String sClassName = m_oUnoNode.getClassName(); 84 if (sClassName.equals("")){ 85 TreeNode oTreeNode = getParent(); 86 if (oTreeNode != null){ 87 if (oTreeNode instanceof XUnoNode){ 88 SwingUnoNode oUnoNode = (SwingUnoNode) oTreeNode; 89 sClassName = oUnoNode.getClassName(); 90 } 91 } 92 } 93 return sClassName; 94 } 95 96 public String getAnchor() { 97 return m_oUnoNode.getAnchor(); 98 } 99 100 101 public void setFoldable(boolean _bIsFoldable){ 102 if (_bIsFoldable){ 103 addDummyNode(); 104 } 105 else{ 106 removeDummyNode(); 107 } 108 } 109 110 111 public XUnoNode getParentNode(){ 112 return (SwingUnoNode) super.getParent(); 113 } 114 115 116 public void addChildNode(XUnoNode _xUnoNode) { 117 super.add((SwingUnoNode) _xUnoNode); 118 } 119 120 public void setLabel(String _sLabel){ 121 super.setUserObject(_sLabel); 122 this.m_oUnoNode.setLabel(_sLabel); 123 } 124 125 public String getLabel(){ 126 return (String) super.getUserObject(); 127 } 128 129 130 public int getChildCount(){ 131 return super.getChildCount(); 132 } 133 134 135 public XUnoNode getChild(int _i){ 136 return (SwingUnoNode) super.getChildAt(_i); 137 } 138 139 public int getNodeType(){ 140 return m_oUnoNode.getNodeType(); 141 } 142 143 public void setNodeType(int _nNodeType){ 144 m_oUnoNode.setNodeType(_nNodeType); 145 } 146 147 148 public String getName(){ 149 return getClassName(); 150 } 151 152 153 public Type getUnoType(){ 154 return m_oUnoNode.getUnoType(); 155 } 156 } 157