1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************/
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir import com.sun.star.lib.uno.helper.WeakBase;
37*cdf0e10cSrcweir import com.sun.star.uno.Any;
38*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter;
39*cdf0e10cSrcweir import com.sun.star.lang.XServiceInfo;
40*cdf0e10cSrcweir import com.sun.star.uno.TypeClass;
41*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
42*cdf0e10cSrcweir import com.sun.star.uno.Type;
43*cdf0e10cSrcweir import com.sun.star.uno.XComponentContext;
44*cdf0e10cSrcweir import com.sun.star.beans.XIntrospectionAccess;
45*cdf0e10cSrcweir import com.sun.star.beans.Property;
46*cdf0e10cSrcweir import com.sun.star.beans.PropertyValue;
47*cdf0e10cSrcweir import com.sun.star.beans.XPropertySet;
48*cdf0e10cSrcweir import com.sun.star.reflection.XIdlMethod;
49*cdf0e10cSrcweir import javax.swing.tree.ExpandVetoException;
50*cdf0e10cSrcweir import org.openoffice.XInstanceInspector;
51*cdf0e10cSrcweir import javax.swing.tree.TreePath;
52*cdf0e10cSrcweir import javax.swing.event.TreeWillExpandListener;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     public class InspectorPane extends WeakBase implements XInstanceInspector{  //, XServiceInfo
55*cdf0e10cSrcweir         private XIdlMethod[] xIdlMethods;
56*cdf0e10cSrcweir         private Property[] aProperties;
57*cdf0e10cSrcweir         private boolean bIncludeContent = false;
58*cdf0e10cSrcweir         private XComponentContext m_xComponentContext;
59*cdf0e10cSrcweir         private XDialogProvider m_xDialogProvider;
60*cdf0e10cSrcweir         private Introspector m_oIntrospector = null;
61*cdf0e10cSrcweir         private SourceCodeGenerator m_oSourceCodeGenerator;
62*cdf0e10cSrcweir         private XTreeControlProvider m_xTreeControlProvider;
63*cdf0e10cSrcweir         private String sTitle = "";
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir         /** The constructor of the inner class has a XMultiServiceFactory parameter.
67*cdf0e10cSrcweir          * @param xMultiServiceFactory XMultiServiceFactory
68*cdf0e10cSrcweir          */
69*cdf0e10cSrcweir         public InspectorPane(XComponentContext _xComponentContext, XDialogProvider _xDialogProvider, XTreeControlProvider _xTreeControlProvider, int _nLanguage) {
70*cdf0e10cSrcweir             m_xComponentContext = _xComponentContext;
71*cdf0e10cSrcweir             m_xTreeControlProvider = _xTreeControlProvider;
72*cdf0e10cSrcweir             m_xDialogProvider = _xDialogProvider;
73*cdf0e10cSrcweir             m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
74*cdf0e10cSrcweir             m_oSourceCodeGenerator = new SourceCodeGenerator(_nLanguage);
75*cdf0e10cSrcweir             _xTreeControlProvider.addInspectorPane(this);
76*cdf0e10cSrcweir         }
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir         private void setMaximumOfProgressBar(Object _oUnoObject){
80*cdf0e10cSrcweir             int nMaxValue = 0;
81*cdf0e10cSrcweir             xIdlMethods = m_oIntrospector.getMethods(_oUnoObject);
82*cdf0e10cSrcweir             aProperties = m_oIntrospector.getProperties(_oUnoObject);
83*cdf0e10cSrcweir         }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir         /** Inspect the given object for methods, properties, interfaces, and
87*cdf0e10cSrcweir          * services.
88*cdf0e10cSrcweir          * @param a The object to inspect
89*cdf0e10cSrcweir          * @throws RuntimeException If
90*cdf0e10cSrcweir          */
91*cdf0e10cSrcweir         public void inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException {
92*cdf0e10cSrcweir         try {
93*cdf0e10cSrcweir             Object oContainer = m_xTreeControlProvider.inspect(_oUserDefinedObject, _sTitle);
94*cdf0e10cSrcweir             m_xDialogProvider.addInspectorPage(getTitle(), oContainer);
95*cdf0e10cSrcweir         }
96*cdf0e10cSrcweir         catch( Exception exception ) {
97*cdf0e10cSrcweir             exception.printStackTrace(System.out);
98*cdf0e10cSrcweir         }}
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         public void setTitle(String _sTitle){
102*cdf0e10cSrcweir             if (_sTitle != null){
103*cdf0e10cSrcweir                 if (_sTitle.length() > 0){
104*cdf0e10cSrcweir                     sTitle = _sTitle;
105*cdf0e10cSrcweir                 }
106*cdf0e10cSrcweir             }
107*cdf0e10cSrcweir         }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         public String getTitle(){
111*cdf0e10cSrcweir             return sTitle;
112*cdf0e10cSrcweir         }
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         private Type[] getTypes(Object _oUnoObject){
117*cdf0e10cSrcweir             Type[] aTypes = null;
118*cdf0e10cSrcweir             if (m_oIntrospector.isArray(_oUnoObject)){
119*cdf0e10cSrcweir                 aTypes = (Type[])_oUnoObject;
120*cdf0e10cSrcweir             }
121*cdf0e10cSrcweir             else{
122*cdf0e10cSrcweir                 aTypes = m_oIntrospector.getInterfaces(_oUnoObject);
123*cdf0e10cSrcweir             }
124*cdf0e10cSrcweir             return aTypes;
125*cdf0e10cSrcweir         }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         private Object invoke(XUnoMethodNode _oUnoMethodNode){
129*cdf0e10cSrcweir         try{
130*cdf0e10cSrcweir             String sParamValueDescription = "";
131*cdf0e10cSrcweir             Object oUnoReturnObject = _oUnoMethodNode.invoke();
132*cdf0e10cSrcweir             boolean bHasParameters = _oUnoMethodNode.hasParameters();
133*cdf0e10cSrcweir             boolean bIsPrimitive = _oUnoMethodNode.isPrimitive();
134*cdf0e10cSrcweir                 if (bHasParameters){
135*cdf0e10cSrcweir                     sParamValueDescription = " (" + m_oSourceCodeGenerator.getMethodParameterValueDescription(_oUnoMethodNode, _oUnoMethodNode.getLastParameterObjects(), true) + ")";
136*cdf0e10cSrcweir                 }
137*cdf0e10cSrcweir             if (oUnoReturnObject != null ){
138*cdf0e10cSrcweir                 String sNodeDescription = "";
139*cdf0e10cSrcweir                 XUnoNode oUnoNode = null;
140*cdf0e10cSrcweir                 if (_oUnoMethodNode.getXIdlMethod().getReturnType().getTypeClass().getValue() == TypeClass.VOID_value){
141*cdf0e10cSrcweir                     sNodeDescription += _oUnoMethodNode.getXIdlMethod().getReturnType().getName() + " " + _oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription;
142*cdf0e10cSrcweir                     _oUnoMethodNode.setLabel(sNodeDescription);
143*cdf0e10cSrcweir                     m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
144*cdf0e10cSrcweir                 }
145*cdf0e10cSrcweir                 else if (bHasParameters || !bIsPrimitive){
146*cdf0e10cSrcweir                     if (bIsPrimitive){
147*cdf0e10cSrcweir                         sNodeDescription += m_oSourceCodeGenerator.getStringValueOfObject(oUnoReturnObject, _oUnoMethodNode.getTypeClass());
148*cdf0e10cSrcweir                     }
149*cdf0e10cSrcweir                     else{
150*cdf0e10cSrcweir                         Any aReturnObject = Any.complete(oUnoReturnObject);
151*cdf0e10cSrcweir                         String sShortClassName = m_oIntrospector.getShortClassName(aReturnObject.getType().getTypeName());
152*cdf0e10cSrcweir                         sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName);
153*cdf0e10cSrcweir                     }
154*cdf0e10cSrcweir                     if (m_oIntrospector.isArray(oUnoReturnObject)){
155*cdf0e10cSrcweir                         if (m_oIntrospector.isUnoTypeObject(oUnoReturnObject)){
156*cdf0e10cSrcweir                             oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoMethodNode.getUnoObject());
157*cdf0e10cSrcweir                         }
158*cdf0e10cSrcweir                         else if(m_oIntrospector.isUnoPropertyTypeObject(oUnoReturnObject)){
159*cdf0e10cSrcweir                             oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject);
160*cdf0e10cSrcweir                         }
161*cdf0e10cSrcweir                         else if(m_oIntrospector.isUnoPropertyValueTypeObject(oUnoReturnObject)){
162*cdf0e10cSrcweir                             oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION, oUnoReturnObject);
163*cdf0e10cSrcweir                         }
164*cdf0e10cSrcweir                     }
165*cdf0e10cSrcweir                     if (oUnoNode == null){
166*cdf0e10cSrcweir                         if (bHasParameters){
167*cdf0e10cSrcweir                             sNodeDescription += sParamValueDescription;
168*cdf0e10cSrcweir                         }
169*cdf0e10cSrcweir                         oUnoNode = addUnoNode(null, oUnoReturnObject, sNodeDescription);
170*cdf0e10cSrcweir                         if (bHasParameters){
171*cdf0e10cSrcweir                             oUnoNode.setParameterObjects(_oUnoMethodNode.getLastParameterObjects());
172*cdf0e10cSrcweir                         }
173*cdf0e10cSrcweir                     }
174*cdf0e10cSrcweir                     if (oUnoNode != null){
175*cdf0e10cSrcweir                         oUnoNode.setFoldable(!bIsPrimitive);
176*cdf0e10cSrcweir                         _oUnoMethodNode.setFoldable(false);
177*cdf0e10cSrcweir                         _oUnoMethodNode.addChildNode(oUnoNode);
178*cdf0e10cSrcweir                         m_xTreeControlProvider.nodeInserted(_oUnoMethodNode, oUnoNode, _oUnoMethodNode.getChildCount()-1);
179*cdf0e10cSrcweir                     }
180*cdf0e10cSrcweir                 }
181*cdf0e10cSrcweir                 else{
182*cdf0e10cSrcweir                     if (bIsPrimitive){
183*cdf0e10cSrcweir                         sNodeDescription  = _oUnoMethodNode.getStandardMethodDescription() + "=" + UnoMethodNode.getDisplayValueOfPrimitiveType(oUnoReturnObject);
184*cdf0e10cSrcweir                         _oUnoMethodNode.setLabel(sNodeDescription);
185*cdf0e10cSrcweir                         m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
186*cdf0e10cSrcweir                     }
187*cdf0e10cSrcweir                 }
188*cdf0e10cSrcweir             }
189*cdf0e10cSrcweir             // ReturnObject of method node == null..
190*cdf0e10cSrcweir             else{
191*cdf0e10cSrcweir                 if (!bHasParameters){
192*cdf0e10cSrcweir                     _oUnoMethodNode.setLabel(_oUnoMethodNode.getLabel() + " = null");
193*cdf0e10cSrcweir                 }
194*cdf0e10cSrcweir                 else{
195*cdf0e10cSrcweir                     _oUnoMethodNode.setLabel(_oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription + " = null");
196*cdf0e10cSrcweir                 }
197*cdf0e10cSrcweir                 m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
198*cdf0e10cSrcweir             }
199*cdf0e10cSrcweir             return oUnoReturnObject;
200*cdf0e10cSrcweir         }catch(Exception exception ) {
201*cdf0e10cSrcweir             return null;
202*cdf0e10cSrcweir         }}
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir         public void invokeSelectedMethodNode(){
206*cdf0e10cSrcweir             XTreePathProvider xTreePathProvider = m_xTreeControlProvider.getSelectedPath();
207*cdf0e10cSrcweir             XUnoNode oUnoNode = xTreePathProvider.getLastPathComponent();
208*cdf0e10cSrcweir             if (oUnoNode instanceof XUnoMethodNode){
209*cdf0e10cSrcweir                 invoke((XUnoMethodNode) oUnoNode);
210*cdf0e10cSrcweir                 m_xTreeControlProvider.expandPath(xTreePathProvider);
211*cdf0e10cSrcweir             }
212*cdf0e10cSrcweir         }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir         public void addSourceCodeOfSelectedNode(){
216*cdf0e10cSrcweir             XTreePathProvider oTreePathProvider = m_xTreeControlProvider.getSelectedPath();
217*cdf0e10cSrcweir             XUnoNode oUnoNode = oTreePathProvider.getLastPathComponent();
218*cdf0e10cSrcweir             if (oUnoNode instanceof XUnoMethodNode){
219*cdf0e10cSrcweir                 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
220*cdf0e10cSrcweir                 if (!oUnoMethodNode.isInvoked() && oUnoMethodNode.isInvokable()){
221*cdf0e10cSrcweir                     invoke(oUnoMethodNode);
222*cdf0e10cSrcweir                 }
223*cdf0e10cSrcweir             }
224*cdf0e10cSrcweir             String sSourceCode = m_oSourceCodeGenerator.addSourceCodeOfUnoObject(oTreePathProvider, true, true, true);
225*cdf0e10cSrcweir             m_xTreeControlProvider.setSourceCode(sSourceCode);
226*cdf0e10cSrcweir         }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir         public void convertCompleteSourceCode(int _nLanguage){
230*cdf0e10cSrcweir             String sSourceCode = m_oSourceCodeGenerator.convertAllUnoObjects(_nLanguage);
231*cdf0e10cSrcweir             m_xTreeControlProvider.setSourceCode(sSourceCode);
232*cdf0e10cSrcweir         }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir         protected XUnoNode getSelectedNode(){
235*cdf0e10cSrcweir             return m_xTreeControlProvider.getSelectedNode();
236*cdf0e10cSrcweir         }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir         //  add the object to the hashtable for a possible access in the tree
240*cdf0e10cSrcweir         private  XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){
241*cdf0e10cSrcweir             return m_xTreeControlProvider.addUnoFacetteNode( _oParentNode, _sNodeDescription, _oUnoObject);
242*cdf0e10cSrcweir         }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         private XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){
246*cdf0e10cSrcweir             return m_xTreeControlProvider.addMethodNode(_objectElement, _xIdlMethod);
247*cdf0e10cSrcweir         }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir         public void addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){
252*cdf0e10cSrcweir             if (this.m_oIntrospector.isValid(_xIdlMethods)){
253*cdf0e10cSrcweir                 for ( int n = 0; n < _xIdlMethods.length; n++ ) {
254*cdf0e10cSrcweir                     XIdlMethod xIdlMethod = _xIdlMethods[n];
255*cdf0e10cSrcweir                     if (!xIdlMethod.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
256*cdf0e10cSrcweir                         XUnoMethodNode oChildNode = addMethodNode(_oUnoParentObject, xIdlMethod);
257*cdf0e10cSrcweir                         if (oChildNode != null){
258*cdf0e10cSrcweir                             _oGrandParentNode.addChildNode(oChildNode);
259*cdf0e10cSrcweir                         }
260*cdf0e10cSrcweir                     }
261*cdf0e10cSrcweir                 }
262*cdf0e10cSrcweir             }
263*cdf0e10cSrcweir         }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir         private void addFacetteNodesToTreeNode(XUnoNode _oParentNode, Object _oUnoObject){
267*cdf0e10cSrcweir             if (m_oIntrospector.hasMethods(_oUnoObject)){
268*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SMETHODDESCRIPTION, _oUnoObject);
269*cdf0e10cSrcweir             }
270*cdf0e10cSrcweir             if (m_oIntrospector.hasProperties(_oUnoObject)){
271*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SPROPERTYDESCRIPTION, _oUnoObject);
272*cdf0e10cSrcweir             }
273*cdf0e10cSrcweir             if (m_oIntrospector.hasInterfaces(_oUnoObject)){
274*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoObject);
275*cdf0e10cSrcweir             }
276*cdf0e10cSrcweir             if (m_oIntrospector.isContainer(_oUnoObject)){
277*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SCONTAINERDESCRIPTION, _oUnoObject);
278*cdf0e10cSrcweir             }
279*cdf0e10cSrcweir             if (m_oIntrospector.hasSupportedServices(_oUnoObject)){
280*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SSERVICEDESCRIPTION, _oUnoObject);
281*cdf0e10cSrcweir             }
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         private void addInterfacesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, Type[] _aTypes) {
286*cdf0e10cSrcweir         try {
287*cdf0e10cSrcweir             if (_oUnoParentObject != null){
288*cdf0e10cSrcweir                 for ( int m = 0; m < _aTypes.length; m++ ) {
289*cdf0e10cSrcweir                     addUnoNode(_oGrandParentNode, _oUnoParentObject, _aTypes[m]);
290*cdf0e10cSrcweir                 }
291*cdf0e10cSrcweir             }
292*cdf0e10cSrcweir         }
293*cdf0e10cSrcweir         catch( Exception exception ) {
294*cdf0e10cSrcweir             exception.printStackTrace(System.out);
295*cdf0e10cSrcweir         }}
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir         //  add all services for the given object to the tree under the node parent
299*cdf0e10cSrcweir         private void addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) {
300*cdf0e10cSrcweir         try{
301*cdf0e10cSrcweir             XServiceInfo xServiceInfo = ( XServiceInfo ) UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject );
302*cdf0e10cSrcweir             if ( xServiceInfo != null ){
303*cdf0e10cSrcweir                 String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames();
304*cdf0e10cSrcweir                 for ( int m = 0; m < sSupportedServiceNames.length; m++ ) {
305*cdf0e10cSrcweir                     String sServiceName = sSupportedServiceNames[m];
306*cdf0e10cSrcweir                     if (sServiceName.length() > 0){
307*cdf0e10cSrcweir                         XUnoNode oUnoNode = addUnoNode(_oGrandParentNode, _oUnoObject, sSupportedServiceNames[m]);
308*cdf0e10cSrcweir                         oUnoNode.setNodeType(XUnoNode.nSERVICE);
309*cdf0e10cSrcweir                     }
310*cdf0e10cSrcweir                 }
311*cdf0e10cSrcweir             }
312*cdf0e10cSrcweir         }
313*cdf0e10cSrcweir         catch(Exception exception) {
314*cdf0e10cSrcweir             exception.printStackTrace(System.out);
315*cdf0e10cSrcweir         }}
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir         private void addPropertiesAndInterfacesOfService(XUnoNode _oUnoServiceNode){
319*cdf0e10cSrcweir             String sServiceName  = _oUnoServiceNode.getClassName();
320*cdf0e10cSrcweir             Object oUnoObject = _oUnoServiceNode.getUnoObject();
321*cdf0e10cSrcweir             addInterfacesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getInterfaces(oUnoObject, sServiceName));
322*cdf0e10cSrcweir             addPropertiesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject, sServiceName));
323*cdf0e10cSrcweir         }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     private void addPropertiesToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject,  Property[] _aProperties) {
327*cdf0e10cSrcweir     try {
328*cdf0e10cSrcweir         if (_aProperties.length > 0){
329*cdf0e10cSrcweir             for ( int n = 0; n < _aProperties.length; n++ ){
330*cdf0e10cSrcweir                 Property aProperty = _aProperties[n];
331*cdf0e10cSrcweir                 XIntrospectionAccess xIntrospectionAccess = m_oIntrospector.getXIntrospectionAccess(_oUnoParentObject);
332*cdf0e10cSrcweir                 XPropertySet xPropertySet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xIntrospectionAccess.queryAdapter(new Type( XPropertySet.class)));
333*cdf0e10cSrcweir                 if (xPropertySet != null) {
334*cdf0e10cSrcweir                     if (xPropertySet.getPropertySetInfo().hasPropertyByName(aProperty.Name)){
335*cdf0e10cSrcweir                         Object objectElement = xPropertySet.getPropertyValue(aProperty.Name);
336*cdf0e10cSrcweir                         if (objectElement != null) {
337*cdf0e10cSrcweir                             XUnoNode oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoParentObject, aProperty, objectElement);
338*cdf0e10cSrcweir                             if (oChildNode != null){
339*cdf0e10cSrcweir                                 _oParentNode.addChildNode(oChildNode);
340*cdf0e10cSrcweir                             }
341*cdf0e10cSrcweir                         }
342*cdf0e10cSrcweir                     }
343*cdf0e10cSrcweir                 }
344*cdf0e10cSrcweir             }
345*cdf0e10cSrcweir         }
346*cdf0e10cSrcweir     }
347*cdf0e10cSrcweir     catch(Exception exception) {
348*cdf0e10cSrcweir         exception.printStackTrace(System.out);
349*cdf0e10cSrcweir     }}
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     public void addContainerElementsToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject){
353*cdf0e10cSrcweir         Object[] oUnoContainerElements = m_oIntrospector.getUnoObjectsOfContainer(_oUnoParentObject);
354*cdf0e10cSrcweir         if (m_oIntrospector.isValid(oUnoContainerElements)){
355*cdf0e10cSrcweir             if (oUnoContainerElements.length > 0){
356*cdf0e10cSrcweir                 for (int i=0; i< oUnoContainerElements.length; i++){
357*cdf0e10cSrcweir                     XUnoNode oChildNode = addUnoNode(_oParentNode, oUnoContainerElements[i], UnoNode.getNodeDescription(oUnoContainerElements[i]));
358*cdf0e10cSrcweir                     m_xTreeControlProvider.nodeInserted(_oParentNode, oChildNode, _oParentNode.getChildCount()-1);
359*cdf0e10cSrcweir                 }
360*cdf0e10cSrcweir             }
361*cdf0e10cSrcweir         }
362*cdf0e10cSrcweir     }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, String _sLabel ){
366*cdf0e10cSrcweir         XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject);
367*cdf0e10cSrcweir         oUnoNode.setLabel(_sLabel);
368*cdf0e10cSrcweir         if (_oParentNode != null){
369*cdf0e10cSrcweir             _oParentNode.addChildNode(oUnoNode);
370*cdf0e10cSrcweir         }
371*cdf0e10cSrcweir         setNodeFoldable(oUnoNode, _oUnoObject);
372*cdf0e10cSrcweir         return oUnoNode;
373*cdf0e10cSrcweir     }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir     private void setNodeFoldable(XUnoNode _oUnoNode, Object _oUnoObject){
377*cdf0e10cSrcweir         if (_oUnoObject != null){
378*cdf0e10cSrcweir             if (!m_oIntrospector.isObjectPrimitive(_oUnoObject)){
379*cdf0e10cSrcweir                 _oUnoNode.setFoldable(true);
380*cdf0e10cSrcweir             }
381*cdf0e10cSrcweir         }
382*cdf0e10cSrcweir     }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, Type _aType){
386*cdf0e10cSrcweir         XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject, _aType);
387*cdf0e10cSrcweir         if (_oParentNode != null){
388*cdf0e10cSrcweir             _oParentNode.addChildNode(oUnoNode);
389*cdf0e10cSrcweir         }
390*cdf0e10cSrcweir         setNodeFoldable(oUnoNode, _oUnoObject);
391*cdf0e10cSrcweir         return oUnoNode;
392*cdf0e10cSrcweir     }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     private void addPropertySetInfoNodesToTreeNode(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
396*cdf0e10cSrcweir         if (_oUnoObject.getClass().isArray()){
397*cdf0e10cSrcweir             Object[] object = ( Object[] ) _oUnoObject;
398*cdf0e10cSrcweir             for ( int i = 0; i < object.length; i++ ) {
399*cdf0e10cSrcweir                 Property aProperty = (Property) object[i];
400*cdf0e10cSrcweir                 XUnoPropertyNode oUnoPropertyNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aProperty);
401*cdf0e10cSrcweir                 oUnoPropertyNode.setLabel(XUnoFacetteNode.SPROPERTYINFODESCRIPTION + " (" + aProperty.Name + ")");
402*cdf0e10cSrcweir                 oUnoPropertyNode.setFoldable(true);
403*cdf0e10cSrcweir                 _oUnoFacetteNode.addChildNode(oUnoPropertyNode);
404*cdf0e10cSrcweir             }
405*cdf0e10cSrcweir         }
406*cdf0e10cSrcweir     }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir     private void addPrimitiveValuesToTreeNode(XUnoNode _oUnoNode, Object _oUnoObject){
409*cdf0e10cSrcweir         if (_oUnoObject.getClass().isArray()){
410*cdf0e10cSrcweir             if (!_oUnoObject.getClass().getComponentType().isPrimitive()){
411*cdf0e10cSrcweir                 Object[] object = ( Object[] ) _oUnoObject;
412*cdf0e10cSrcweir                 for ( int i = 0; i < object.length; i++ ) {
413*cdf0e10cSrcweir                     if (m_oIntrospector.isObjectPrimitive(object[i])){
414*cdf0e10cSrcweir                         XUnoNode oChildNode = addUnoNode(_oUnoNode, null, UnoNode.getNodeDescription(object[i]));
415*cdf0e10cSrcweir                     }
416*cdf0e10cSrcweir                 }
417*cdf0e10cSrcweir             }
418*cdf0e10cSrcweir             else{
419*cdf0e10cSrcweir                 String[] sDisplayValues = UnoNode.getDisplayValuesofPrimitiveArray(_oUnoObject);
420*cdf0e10cSrcweir                 for ( int i = 0; i < sDisplayValues.length; i++ ) {
421*cdf0e10cSrcweir                     XUnoNode oUnoNode = addUnoNode(_oUnoNode, null, sDisplayValues[i]);
422*cdf0e10cSrcweir                 }
423*cdf0e10cSrcweir             }
424*cdf0e10cSrcweir         }
425*cdf0e10cSrcweir     }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     private void addPropertySetInfoSubNodes(XUnoPropertyNode _oUnoPropertyNode){
429*cdf0e10cSrcweir         Property aProperty = _oUnoPropertyNode.getProperty();
430*cdf0e10cSrcweir         _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithName(aProperty));
431*cdf0e10cSrcweir         _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithType(aProperty));
432*cdf0e10cSrcweir         _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithHandle(aProperty));
433*cdf0e10cSrcweir         _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithAttributesDescription(aProperty));
434*cdf0e10cSrcweir     }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir     private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
438*cdf0e10cSrcweir         if (m_oIntrospector.isUnoPropertyValueTypeObject(_oUnoObject)){
439*cdf0e10cSrcweir             Object[] object = ( Object[] ) _oUnoObject;
440*cdf0e10cSrcweir             for ( int i = 0; i < object.length; i++ ) {
441*cdf0e10cSrcweir                 String sObjectClassName = object[i].getClass().getName();
442*cdf0e10cSrcweir                 if (sObjectClassName.equals("com.sun.star.beans.PropertyValue")){
443*cdf0e10cSrcweir                     XUnoNode oChildNode = null;
444*cdf0e10cSrcweir                     PropertyValue aPropertyValue = (PropertyValue) object[i];
445*cdf0e10cSrcweir                     if (! m_oIntrospector.isObjectPrimitive(aPropertyValue.Value)){
446*cdf0e10cSrcweir                         oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aPropertyValue, _oUnoObject);
447*cdf0e10cSrcweir                     }
448*cdf0e10cSrcweir                     else{
449*cdf0e10cSrcweir                         oChildNode = addUnoNode(null, aPropertyValue.Value, UnoPropertyNode.getStandardPropertyValueDescription(aPropertyValue));
450*cdf0e10cSrcweir                     }
451*cdf0e10cSrcweir                     if (oChildNode != null){
452*cdf0e10cSrcweir                         _oUnoFacetteNode.addChildNode(oChildNode);
453*cdf0e10cSrcweir                     }
454*cdf0e10cSrcweir                 }
455*cdf0e10cSrcweir             }
456*cdf0e10cSrcweir         }
457*cdf0e10cSrcweir     }
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     public boolean expandNode(XUnoNode _oUnoNode, XTreePathProvider _xTreePathProvider){
461*cdf0e10cSrcweir         if ( _oUnoNode != null ) {
462*cdf0e10cSrcweir             _oUnoNode.setFoldable(false);
463*cdf0e10cSrcweir             if (m_xTreeControlProvider.isMethodNode(_oUnoNode)){
464*cdf0e10cSrcweir                 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) _oUnoNode;
465*cdf0e10cSrcweir                 if (!oUnoMethodNode.isInvoked()){
466*cdf0e10cSrcweir                     Object oUnoReturnObject = invoke((XUnoMethodNode) _oUnoNode);
467*cdf0e10cSrcweir                     if (oUnoReturnObject == null){
468*cdf0e10cSrcweir                         _oUnoNode.setFoldable(true);
469*cdf0e10cSrcweir                         return false;
470*cdf0e10cSrcweir                     }
471*cdf0e10cSrcweir                 }
472*cdf0e10cSrcweir             }
473*cdf0e10cSrcweir             else if (m_xTreeControlProvider.isPropertyNode(_oUnoNode)){
474*cdf0e10cSrcweir                 XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) _oUnoNode;
475*cdf0e10cSrcweir                 Object oUnoObject = oUnoPropertyNode.getUnoReturnObject();
476*cdf0e10cSrcweir                 if (oUnoPropertyNode.getPropertyNodeType() == XUnoPropertyNode.nPROPERTYSETINFOTYPE){
477*cdf0e10cSrcweir                     addPropertySetInfoSubNodes(oUnoPropertyNode);
478*cdf0e10cSrcweir                 }
479*cdf0e10cSrcweir                 else{
480*cdf0e10cSrcweir                     //TOOD this code is redundant!!!
481*cdf0e10cSrcweir                     if ( oUnoObject.getClass().isArray()){
482*cdf0e10cSrcweir                         // TOODO probably we should provid a possibility to insert also non-primitive nodes
483*cdf0e10cSrcweir                         addPrimitiveValuesToTreeNode(oUnoPropertyNode, oUnoObject);
484*cdf0e10cSrcweir                     }
485*cdf0e10cSrcweir                     else{
486*cdf0e10cSrcweir                         addFacetteNodesToTreeNode(oUnoPropertyNode, oUnoObject);
487*cdf0e10cSrcweir                     }
488*cdf0e10cSrcweir                 }
489*cdf0e10cSrcweir             }
490*cdf0e10cSrcweir             else if (m_xTreeControlProvider.isFacetteNode(_oUnoNode)){
491*cdf0e10cSrcweir                 XUnoFacetteNode oUnoFacetteNode = (XUnoFacetteNode) _oUnoNode;
492*cdf0e10cSrcweir                 Object oUnoObject = _oUnoNode.getUnoObject();
493*cdf0e10cSrcweir                 if (oUnoFacetteNode.isMethodNode()){
494*cdf0e10cSrcweir                     addMethodsToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getMethods(oUnoObject));
495*cdf0e10cSrcweir                 }
496*cdf0e10cSrcweir                 if (oUnoFacetteNode.isPropertyNode()){
497*cdf0e10cSrcweir                     String sNodeDescription = oUnoFacetteNode.getLabel();
498*cdf0e10cSrcweir                     // TODO: it's very dangerous to distinguishe the different UnoFacetteNodes only by the nodedescription
499*cdf0e10cSrcweir                     if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
500*cdf0e10cSrcweir                         addPropertySetInfoNodesToTreeNode(oUnoFacetteNode, oUnoObject);
501*cdf0e10cSrcweir                     }
502*cdf0e10cSrcweir                     else if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION)){
503*cdf0e10cSrcweir                         addPropertyValueSubNodes(oUnoFacetteNode, oUnoObject);
504*cdf0e10cSrcweir                     }
505*cdf0e10cSrcweir                     else{
506*cdf0e10cSrcweir                         addPropertiesToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject));
507*cdf0e10cSrcweir                     }
508*cdf0e10cSrcweir                 }
509*cdf0e10cSrcweir                 if (oUnoFacetteNode.isServiceNode()){
510*cdf0e10cSrcweir                     addServicesToTreeNode(oUnoFacetteNode, oUnoObject);
511*cdf0e10cSrcweir                 }
512*cdf0e10cSrcweir                 if (oUnoFacetteNode.isInterfaceNode()){
513*cdf0e10cSrcweir                     addInterfacesToTreeNode(oUnoFacetteNode, oUnoObject, getTypes(oUnoObject));
514*cdf0e10cSrcweir                 }
515*cdf0e10cSrcweir                 if (oUnoFacetteNode.isContainerNode()){
516*cdf0e10cSrcweir                     addContainerElementsToTreeNode(oUnoFacetteNode, oUnoObject);
517*cdf0e10cSrcweir                 }
518*cdf0e10cSrcweir             }
519*cdf0e10cSrcweir             else if (_oUnoNode.getNodeType() == XUnoNode.nSERVICE){
520*cdf0e10cSrcweir                 addPropertiesAndInterfacesOfService(_oUnoNode);
521*cdf0e10cSrcweir             }
522*cdf0e10cSrcweir             else if (_oUnoNode.getNodeType() == XUnoNode.nINTERFACE){
523*cdf0e10cSrcweir                 Type aType = _oUnoNode.getUnoType();
524*cdf0e10cSrcweir                 if (aType != null){
525*cdf0e10cSrcweir                     addMethodsToTreeNode(_oUnoNode, _oUnoNode.getUnoObject(), m_oIntrospector.getMethodsOfInterface(aType));
526*cdf0e10cSrcweir                 }
527*cdf0e10cSrcweir             }
528*cdf0e10cSrcweir             else if (_oUnoNode.getNodeType() == XUnoNode.nOTHERS){
529*cdf0e10cSrcweir                 Object oUnoObject = _oUnoNode.getUnoObject();
530*cdf0e10cSrcweir                 if ( oUnoObject.getClass().isArray()){
531*cdf0e10cSrcweir                     // TOODO probably we should provid a possibility to insert also non-primitive nodes
532*cdf0e10cSrcweir                      addPrimitiveValuesToTreeNode(_oUnoNode, oUnoObject);
533*cdf0e10cSrcweir                 }
534*cdf0e10cSrcweir                 else{
535*cdf0e10cSrcweir                     addFacetteNodesToTreeNode(_oUnoNode, oUnoObject);
536*cdf0e10cSrcweir                 }
537*cdf0e10cSrcweir             }
538*cdf0e10cSrcweir         }
539*cdf0e10cSrcweir         return true;
540*cdf0e10cSrcweir     }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir         public void applyFilter(XUnoFacetteNode _oUnoFacetteNode, String _sFilter){
545*cdf0e10cSrcweir             for (int i = 0; i < _oUnoFacetteNode.getChildCount(); i++){
546*cdf0e10cSrcweir                 XUnoNode oUnoNode = _oUnoFacetteNode.getChild(i);
547*cdf0e10cSrcweir                 boolean bIsVisible = oUnoNode.isFilterApplicable(_sFilter);
548*cdf0e10cSrcweir                 m_xTreeControlProvider.setNodeVisible(oUnoNode, bIsVisible);
549*cdf0e10cSrcweir             }
550*cdf0e10cSrcweir             _oUnoFacetteNode.setFilter(_sFilter);
551*cdf0e10cSrcweir         }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir         /** In opposition to 'getUnoObjectOfTreeNode' this method inspects the passed node if it represents a Uno object
555*cdf0e10cSrcweir          *  If not it returns null
556*cdf0e10cSrcweir          *
557*cdf0e10cSrcweir          */
558*cdf0e10cSrcweir         private Object getUnoObjectOfExplicitTreeNode(XTreePathProvider _xTreePathProvider){
559*cdf0e10cSrcweir             XUnoNode oUnoNode = _xTreePathProvider.getLastPathComponent();
560*cdf0e10cSrcweir             if (oUnoNode != null){
561*cdf0e10cSrcweir                 return oUnoNode.getUnoObject();
562*cdf0e10cSrcweir             }
563*cdf0e10cSrcweir             return null;
564*cdf0e10cSrcweir         }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir         public String getFilter(XUnoNode _oUnoNode){
568*cdf0e10cSrcweir             String sFilter = "";
569*cdf0e10cSrcweir             if (_oUnoNode != null){
570*cdf0e10cSrcweir                 XUnoNode oUnoNode = _oUnoNode;
571*cdf0e10cSrcweir                 boolean bleaveLoop = false;
572*cdf0e10cSrcweir                 do{
573*cdf0e10cSrcweir                     if (m_xTreeControlProvider.isFacetteNode(oUnoNode)){
574*cdf0e10cSrcweir                         sFilter = ((XUnoFacetteNode) oUnoNode).getFilter();
575*cdf0e10cSrcweir                         bleaveLoop = true;
576*cdf0e10cSrcweir                     }
577*cdf0e10cSrcweir                     else{
578*cdf0e10cSrcweir                         if (oUnoNode.getParentNode() != null){
579*cdf0e10cSrcweir                             oUnoNode = oUnoNode.getParentNode();
580*cdf0e10cSrcweir                         }
581*cdf0e10cSrcweir                         else{
582*cdf0e10cSrcweir                             bleaveLoop = true;
583*cdf0e10cSrcweir                         }
584*cdf0e10cSrcweir                     }
585*cdf0e10cSrcweir                 } while(!bleaveLoop);
586*cdf0e10cSrcweir             }
587*cdf0e10cSrcweir             return sFilter;
588*cdf0e10cSrcweir         }
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir         /** In opposition to 'getUnoObjectOfexplictTreeNode' this method inspects the passed node if it represents a Uno object
592*cdf0e10cSrcweir          *  if not it keeps checking all ancestors until it finds a Uno representation
593*cdf0e10cSrcweir          */
594*cdf0e10cSrcweir         private Object getUnoObjectOfTreeNode(XTreePathProvider _xTreePathProvider){
595*cdf0e10cSrcweir             XTreePathProvider xTreePathProvider = _xTreePathProvider;
596*cdf0e10cSrcweir             HideableMutableTreeNode oNode = null;
597*cdf0e10cSrcweir             Object oUnoObject = null;
598*cdf0e10cSrcweir             while (xTreePathProvider != null){
599*cdf0e10cSrcweir                 oUnoObject = getUnoObjectOfExplicitTreeNode(xTreePathProvider);
600*cdf0e10cSrcweir                 if (oUnoObject != null){
601*cdf0e10cSrcweir                     if (oUnoObject instanceof String){
602*cdf0e10cSrcweir                     }
603*cdf0e10cSrcweir                     else{
604*cdf0e10cSrcweir                         if (!m_oIntrospector.isUnoTypeObject(oUnoObject)){
605*cdf0e10cSrcweir                             return oUnoObject;
606*cdf0e10cSrcweir                         }
607*cdf0e10cSrcweir                     }
608*cdf0e10cSrcweir                 }
609*cdf0e10cSrcweir                 xTreePathProvider = xTreePathProvider.getParentPath();
610*cdf0e10cSrcweir             }
611*cdf0e10cSrcweir             return null;
612*cdf0e10cSrcweir         }
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir         public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{
616*cdf0e10cSrcweir             XUnoNode oUnoNode = getSelectedNode();
617*cdf0e10cSrcweir             boolean bdoEnableInvoke = oUnoNode instanceof XUnoMethodNode;
618*cdf0e10cSrcweir //            boolean bdoEnableSourceCodeGeneration = true;
619*cdf0e10cSrcweir             if (bdoEnableInvoke){
620*cdf0e10cSrcweir                 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
621*cdf0e10cSrcweir                 bdoEnableInvoke = oUnoMethodNode.isInvokable();
622*cdf0e10cSrcweir //                bdoEnableSourceCodeGeneration = bdoEnableInvoke;
623*cdf0e10cSrcweir             }
624*cdf0e10cSrcweir             m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SINVOKE, bdoEnableInvoke);
625*cdf0e10cSrcweir //            m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SADDTOSOURCECODE, bdoEnableSourceCodeGeneration);
626*cdf0e10cSrcweir             m_xDialogProvider.showPopUpMenu(_invoker, x, y);
627*cdf0e10cSrcweir         }
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir