Branch libreoffice-5-0-4
[LibreOffice.git] / odk / examples / java / Inspector / SwingUnoNode.java
blobf0a421c85b86df6b1158e32ec2bb091df8827d56
1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * the BSD license.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * All rights reserved.
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.
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.
33 *************************************************************************/
34 import com.sun.star.uno.Type;
35 import javax.swing.tree.TreeNode;
38 public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{
39 private UnoNode m_oUnoNode;
41 /** Creates a new instance of SwingUnoNode */
42 public SwingUnoNode(Object _oUnoObject) {
43 super();
44 m_oUnoNode = new UnoNode(_oUnoObject);
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());
57 public Object getUnoObject(){
58 return m_oUnoNode.getUnoObject();
61 public void setVisible(String _sFilter){
62 boolean bisVisible = isFilterApplicable(_sFilter);
63 super.setVisible(bisVisible);
66 public boolean isFilterApplicable(String _sFilter) {
67 return m_oUnoNode.isFilterApplicable(_sFilter, getName());
70 public void setParameterObjects(Object[] _oParamObjects) {
71 m_oUnoNode.setParameterObjects(_oParamObjects);
74 public void openIdlDescription(String _SDKPath) {
75 m_oUnoNode.openIdlDescription(_SDKPath, getClassName());
78 public Object[] getParameterObjects() {
79 return m_oUnoNode.getParameterObjects();
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();
93 return sClassName;
96 public String getAnchor() {
97 return m_oUnoNode.getAnchor();
101 public void setFoldable(boolean _bIsFoldable){
102 if (_bIsFoldable){
103 addDummyNode();
105 else{
106 removeDummyNode();
111 public XUnoNode getParentNode(){
112 return (SwingUnoNode) super.getParent();
116 public void addChildNode(XUnoNode _xUnoNode) {
117 super.add((SwingUnoNode) _xUnoNode);
120 public void setLabel(String _sLabel){
121 super.setUserObject(_sLabel);
122 this.m_oUnoNode.setLabel(_sLabel);
125 public String getLabel(){
126 return (String) super.getUserObject();
130 @Override
131 public int getChildCount(){
132 return super.getChildCount();
136 public XUnoNode getChild(int _i){
137 return (SwingUnoNode) super.getChildAt(_i);
140 public int getNodeType(){
141 return m_oUnoNode.getNodeType();
144 public void setNodeType(int _nNodeType){
145 m_oUnoNode.setNodeType(_nNodeType);
149 public String getName(){
150 return getClassName();
154 public Type getUnoType(){
155 return m_oUnoNode.getUnoType();