1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 import com.sun.star.uno.Type;
24 import javax.swing.tree.TreeNode;
25 
26 
27 public class SwingUnoNode extends HideableMutableTreeNode implements XUnoNode{
28     private UnoNode m_oUnoNode;
29 
30     /** Creates a new instance of SwingUnoNode */
SwingUnoNode(Object _oUnoObject)31     public SwingUnoNode(Object _oUnoObject) {
32         super();
33         m_oUnoNode = new UnoNode(_oUnoObject);
34     }
35 
36 
SwingUnoNode(Object _oUnoObject, Type _aType)37     public SwingUnoNode(Object _oUnoObject, Type _aType) {
38         super();
39         m_oUnoNode = new UnoNode(_oUnoObject, _aType);
40         if (_aType != null){
41             this.setLabel(_aType.getTypeName());
42         }
43     }
44 
45 
getUnoObject()46     public Object getUnoObject(){
47         return m_oUnoNode.getUnoObject();
48     }
49 
setVisible(String _sFilter)50     public void setVisible(String _sFilter){
51         boolean bisVisible = isFilterApplicable(_sFilter);
52         super.setVisible(bisVisible);
53     }
54 
isFilterApplicable(String _sFilter)55     public boolean isFilterApplicable(String _sFilter) {
56         return m_oUnoNode.isFilterApplicable(_sFilter, getName());
57     }
58 
setParameterObjects(Object[] _oParamObjects)59     public void setParameterObjects(Object[] _oParamObjects) {
60         m_oUnoNode.setParameterObjects(_oParamObjects);
61     }
62 
openIdlDescription(String _SDKPath)63     public void openIdlDescription(String _SDKPath) {
64         m_oUnoNode.openIdlDescription(_SDKPath, getClassName(), getAnchor());
65     }
66 
getParameterObjects()67     public Object[] getParameterObjects() {
68         return m_oUnoNode.getParameterObjects();
69     }
70 
getClassName()71     public String getClassName(){
72         String sClassName = m_oUnoNode.getClassName();
73         if (sClassName.equals("")){
74             TreeNode oTreeNode = getParent();
75             if (oTreeNode != null){
76                if (oTreeNode instanceof XUnoNode){
77                    SwingUnoNode oUnoNode = (SwingUnoNode) oTreeNode;
78                    sClassName = oUnoNode.getClassName();
79                }
80             }
81         }
82         return sClassName;
83     }
84 
getAnchor()85     public String getAnchor() {
86         return m_oUnoNode.getAnchor();
87     }
88 
89 
setFoldable(boolean _bIsFoldable)90     public void setFoldable(boolean _bIsFoldable){
91         if (_bIsFoldable){
92             addDummyNode();
93         }
94         else{
95             removeDummyNode();
96         }
97     }
98 
99 
getParentNode()100     public XUnoNode getParentNode(){
101         return (SwingUnoNode) super.getParent();
102     }
103 
104 
addChildNode(XUnoNode _xUnoNode)105     public void addChildNode(XUnoNode _xUnoNode) {
106         super.add((SwingUnoNode) _xUnoNode);
107     }
108 
setLabel(String _sLabel)109     public void  setLabel(String _sLabel){
110         super.setUserObject(_sLabel);
111         this.m_oUnoNode.setLabel(_sLabel);
112     }
113 
getLabel()114     public String getLabel(){
115         return (String) super.getUserObject();
116     }
117 
118 
getChildCount()119     public int getChildCount(){
120         return super.getChildCount();
121     }
122 
123 
getChild(int _i)124     public XUnoNode getChild(int _i){
125         return (SwingUnoNode) super.getChildAt(_i);
126     }
127 
getNodeType()128     public int getNodeType(){
129         return m_oUnoNode.getNodeType();
130     }
131 
setNodeType(int _nNodeType)132     public void setNodeType(int _nNodeType){
133         m_oUnoNode.setNodeType(_nNodeType);
134     }
135 
136 
getName()137     public String getName(){
138         return getClassName();
139     }
140 
141 
getUnoType()142     public Type getUnoType(){
143         return m_oUnoNode.getUnoType();
144     }
145 }
146