1 /*************************************************************************
3 * $RCSfile: InspectorPane.java,v $
7 * last change: $Author: rt $ $Date: 2007-04-04 09:18:30 $
9 * The Contents of this file are made available subject to the terms of
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
42 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
43 import com
.sun
.star
.uno
.Any
;
44 import com
.sun
.star
.uno
.AnyConverter
;
45 import com
.sun
.star
.lang
.XServiceInfo
;
46 import com
.sun
.star
.uno
.TypeClass
;
47 import com
.sun
.star
.uno
.UnoRuntime
;
48 import com
.sun
.star
.uno
.Type
;
49 import com
.sun
.star
.uno
.XComponentContext
;
50 import com
.sun
.star
.beans
.XIntrospectionAccess
;
51 import com
.sun
.star
.beans
.Property
;
52 import com
.sun
.star
.beans
.PropertyValue
;
53 import com
.sun
.star
.beans
.XPropertySet
;
54 import com
.sun
.star
.reflection
.XIdlMethod
;
55 import javax
.swing
.tree
.ExpandVetoException
;
56 import org
.openoffice
.XInstanceInspector
;
57 import javax
.swing
.tree
.TreePath
;
58 import javax
.swing
.event
.TreeWillExpandListener
;
60 public class InspectorPane
extends WeakBase
implements XInstanceInspector
{ //, XServiceInfo
61 private XIdlMethod
[] xIdlMethods
;
62 private Property
[] aProperties
;
63 private boolean bIncludeContent
= false;
64 private XComponentContext m_xComponentContext
;
65 private XDialogProvider m_xDialogProvider
;
66 private Introspector m_oIntrospector
= null;
67 private SourceCodeGenerator m_oSourceCodeGenerator
;
68 private XTreeControlProvider m_xTreeControlProvider
;
69 private String sTitle
= "";
72 /** The constructor of the inner class has a XMultiServiceFactory parameter.
73 * @param xMultiServiceFactory XMultiServiceFactory
75 public InspectorPane(XComponentContext _xComponentContext
, XDialogProvider _xDialogProvider
, XTreeControlProvider _xTreeControlProvider
, int _nLanguage
) {
76 m_xComponentContext
= _xComponentContext
;
77 m_xTreeControlProvider
= _xTreeControlProvider
;
78 m_xDialogProvider
= _xDialogProvider
;
79 m_oIntrospector
= Introspector
.getIntrospector(m_xComponentContext
);
80 m_oSourceCodeGenerator
= new SourceCodeGenerator(_nLanguage
);
81 _xTreeControlProvider
.addInspectorPane(this);
85 private void setMaximumOfProgressBar(Object _oUnoObject
){
87 xIdlMethods
= m_oIntrospector
.getMethods(_oUnoObject
);
88 aProperties
= m_oIntrospector
.getProperties(_oUnoObject
);
92 /** Inspect the given object for methods, properties, interfaces, and
94 * @param a The object to inspect
95 * @throws RuntimeException If
97 public void inspect(java
.lang
.Object _oUserDefinedObject
, String _sTitle
) throws com
.sun
.star
.uno
.RuntimeException
{
99 Object oContainer
= m_xTreeControlProvider
.inspect(_oUserDefinedObject
, _sTitle
);
100 m_xDialogProvider
.addInspectorPage(getTitle(), oContainer
);
102 catch( Exception exception
) {
103 exception
.printStackTrace(System
.out
);
107 public void setTitle(String _sTitle
){
108 if (_sTitle
!= null){
109 if (_sTitle
.length() > 0){
116 public String
getTitle(){
122 private Type
[] getTypes(Object _oUnoObject
){
123 Type
[] aTypes
= null;
124 if (m_oIntrospector
.isArray(_oUnoObject
)){
125 aTypes
= (Type
[])_oUnoObject
;
128 aTypes
= m_oIntrospector
.getInterfaces(_oUnoObject
);
134 private Object
invoke(XUnoMethodNode _oUnoMethodNode
){
136 String sParamValueDescription
= "";
137 Object oUnoReturnObject
= _oUnoMethodNode
.invoke();
138 boolean bHasParameters
= _oUnoMethodNode
.hasParameters();
139 boolean bIsPrimitive
= _oUnoMethodNode
.isPrimitive();
141 sParamValueDescription
= " (" + m_oSourceCodeGenerator
.getMethodParameterValueDescription(_oUnoMethodNode
, _oUnoMethodNode
.getLastParameterObjects(), true) + ")";
143 if (oUnoReturnObject
!= null ){
144 String sNodeDescription
= "";
145 XUnoNode oUnoNode
= null;
146 if (_oUnoMethodNode
.getXIdlMethod().getReturnType().getTypeClass().getValue() == TypeClass
.VOID_value
){
147 sNodeDescription
+= _oUnoMethodNode
.getXIdlMethod().getReturnType().getName() + " " + _oUnoMethodNode
.getXIdlMethod().getName() + sParamValueDescription
;
148 _oUnoMethodNode
.setLabel(sNodeDescription
);
149 m_xTreeControlProvider
.nodeChanged(_oUnoMethodNode
);
151 else if (bHasParameters
|| !bIsPrimitive
){
153 sNodeDescription
+= m_oSourceCodeGenerator
.getStringValueOfObject(oUnoReturnObject
, _oUnoMethodNode
.getTypeClass());
156 Any aReturnObject
= Any
.complete(oUnoReturnObject
);
157 String sShortClassName
= m_oIntrospector
.getShortClassName(aReturnObject
.getType().getTypeName());
158 sNodeDescription
+= m_oSourceCodeGenerator
.getVariableNameforUnoObject(sShortClassName
);
160 if (m_oIntrospector
.isArray(oUnoReturnObject
)){
161 if (m_oIntrospector
.isUnoTypeObject(oUnoReturnObject
)){
162 oUnoNode
= addUnoFacetteNode(_oUnoMethodNode
, XUnoFacetteNode
.SINTERFACEDESCRIPTION
, _oUnoMethodNode
.getUnoObject());
164 else if(m_oIntrospector
.isUnoPropertyTypeObject(oUnoReturnObject
)){
165 oUnoNode
= addUnoFacetteNode(_oUnoMethodNode
, XUnoFacetteNode
.SPROPERTYINFODESCRIPTION
, oUnoReturnObject
);
167 else if(m_oIntrospector
.isUnoPropertyValueTypeObject(oUnoReturnObject
)){
168 oUnoNode
= addUnoFacetteNode(_oUnoMethodNode
, XUnoFacetteNode
.SPROPERTYVALUEDESCRIPTION
, oUnoReturnObject
);
171 if (oUnoNode
== null){
173 sNodeDescription
+= sParamValueDescription
;
175 oUnoNode
= addUnoNode(null, oUnoReturnObject
, sNodeDescription
);
177 oUnoNode
.setParameterObjects(_oUnoMethodNode
.getLastParameterObjects());
180 if (oUnoNode
!= null){
181 oUnoNode
.setFoldable(!bIsPrimitive
);
182 _oUnoMethodNode
.setFoldable(false);
183 _oUnoMethodNode
.addChildNode(oUnoNode
);
184 m_xTreeControlProvider
.nodeInserted(_oUnoMethodNode
, oUnoNode
, _oUnoMethodNode
.getChildCount()-1);
189 sNodeDescription
= _oUnoMethodNode
.getStandardMethodDescription() + "=" + UnoMethodNode
.getDisplayValueOfPrimitiveType(oUnoReturnObject
);
190 _oUnoMethodNode
.setLabel(sNodeDescription
);
191 m_xTreeControlProvider
.nodeChanged(_oUnoMethodNode
);
195 // ReturnObject of method node == null..
197 if (!bHasParameters
){
198 _oUnoMethodNode
.setLabel(_oUnoMethodNode
.getLabel() + " = null");
201 _oUnoMethodNode
.setLabel(_oUnoMethodNode
.getXIdlMethod().getName() + sParamValueDescription
+ " = null");
203 m_xTreeControlProvider
.nodeChanged(_oUnoMethodNode
);
205 return oUnoReturnObject
;
206 }catch(Exception exception
) {
211 public void invokeSelectedMethodNode(){
212 XTreePathProvider xTreePathProvider
= m_xTreeControlProvider
.getSelectedPath();
213 XUnoNode oUnoNode
= xTreePathProvider
.getLastPathComponent();
214 if (oUnoNode
instanceof XUnoMethodNode
){
215 invoke((XUnoMethodNode
) oUnoNode
);
216 m_xTreeControlProvider
.expandPath(xTreePathProvider
);
221 public void addSourceCodeOfSelectedNode(){
222 XTreePathProvider oTreePathProvider
= m_xTreeControlProvider
.getSelectedPath();
223 XUnoNode oUnoNode
= oTreePathProvider
.getLastPathComponent();
224 if (oUnoNode
instanceof XUnoMethodNode
){
225 XUnoMethodNode oUnoMethodNode
= (XUnoMethodNode
) oUnoNode
;
226 if (!oUnoMethodNode
.isInvoked() && oUnoMethodNode
.isInvokable()){
227 invoke(oUnoMethodNode
);
230 String sSourceCode
= m_oSourceCodeGenerator
.addSourceCodeOfUnoObject(oTreePathProvider
, true, true, true);
231 m_xTreeControlProvider
.setSourceCode(sSourceCode
);
235 public void convertCompleteSourceCode(int _nLanguage
){
236 String sSourceCode
= m_oSourceCodeGenerator
.convertAllUnoObjects(_nLanguage
);
237 m_xTreeControlProvider
.setSourceCode(sSourceCode
);
240 protected XUnoNode
getSelectedNode(){
241 return m_xTreeControlProvider
.getSelectedNode();
245 // add the object to the hashtable for a possible access in the tree
246 private XUnoFacetteNode
addUnoFacetteNode(XUnoNode _oParentNode
, String _sNodeDescription
, Object _oUnoObject
){
247 return m_xTreeControlProvider
.addUnoFacetteNode( _oParentNode
, _sNodeDescription
, _oUnoObject
);
251 private XUnoMethodNode
addMethodNode(Object _objectElement
, XIdlMethod _xIdlMethod
){
252 return m_xTreeControlProvider
.addMethodNode(_objectElement
, _xIdlMethod
);
257 public void addMethodsToTreeNode(XUnoNode _oGrandParentNode
, Object _oUnoParentObject
, XIdlMethod
[] _xIdlMethods
){
258 if (this.m_oIntrospector
.isValid(_xIdlMethods
)){
259 for ( int n
= 0; n
< _xIdlMethods
.length
; n
++ ) {
260 XIdlMethod xIdlMethod
= _xIdlMethods
[n
];
261 if (!xIdlMethod
.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
262 XUnoMethodNode oChildNode
= addMethodNode(_oUnoParentObject
, xIdlMethod
);
263 if (oChildNode
!= null){
264 _oGrandParentNode
.addChildNode(oChildNode
);
272 private void addFacetteNodesToTreeNode(XUnoNode _oParentNode
, Object _oUnoObject
){
273 if (m_oIntrospector
.hasMethods(_oUnoObject
)){
274 XUnoFacetteNode oUnoFacetteNode
= addUnoFacetteNode(_oParentNode
, XUnoFacetteNode
.SMETHODDESCRIPTION
, _oUnoObject
);
276 if (m_oIntrospector
.hasProperties(_oUnoObject
)){
277 XUnoFacetteNode oUnoFacetteNode
= addUnoFacetteNode(_oParentNode
, XUnoFacetteNode
.SPROPERTYDESCRIPTION
, _oUnoObject
);
279 if (m_oIntrospector
.hasInterfaces(_oUnoObject
)){
280 XUnoFacetteNode oUnoFacetteNode
= addUnoFacetteNode(_oParentNode
, XUnoFacetteNode
.SINTERFACEDESCRIPTION
, _oUnoObject
);
282 if (m_oIntrospector
.isContainer(_oUnoObject
)){
283 XUnoFacetteNode oUnoFacetteNode
= addUnoFacetteNode(_oParentNode
, XUnoFacetteNode
.SCONTAINERDESCRIPTION
, _oUnoObject
);
285 if (m_oIntrospector
.hasSupportedServices(_oUnoObject
)){
286 XUnoFacetteNode oUnoFacetteNode
= addUnoFacetteNode(_oParentNode
, XUnoFacetteNode
.SSERVICEDESCRIPTION
, _oUnoObject
);
291 private void addInterfacesToTreeNode(XUnoNode _oGrandParentNode
, Object _oUnoParentObject
, Type
[] _aTypes
) {
293 if (_oUnoParentObject
!= null){
294 for ( int m
= 0; m
< _aTypes
.length
; m
++ ) {
295 addUnoNode(_oGrandParentNode
, _oUnoParentObject
, _aTypes
[m
]);
299 catch( Exception exception
) {
300 exception
.printStackTrace(System
.out
);
304 // add all services for the given object to the tree under the node parent
305 private void addServicesToTreeNode(XUnoNode _oGrandParentNode
, Object _oUnoObject
) {
307 XServiceInfo xServiceInfo
= ( XServiceInfo
) UnoRuntime
.queryInterface( XServiceInfo
.class, _oUnoObject
);
308 if ( xServiceInfo
!= null ){
309 String
[] sSupportedServiceNames
= xServiceInfo
.getSupportedServiceNames();
310 for ( int m
= 0; m
< sSupportedServiceNames
.length
; m
++ ) {
311 String sServiceName
= sSupportedServiceNames
[m
];
312 if (sServiceName
.length() > 0){
313 XUnoNode oUnoNode
= addUnoNode(_oGrandParentNode
, _oUnoObject
, sSupportedServiceNames
[m
]);
314 oUnoNode
.setNodeType(XUnoNode
.nSERVICE
);
319 catch(Exception exception
) {
320 exception
.printStackTrace(System
.out
);
324 private void addPropertiesAndInterfacesOfService(XUnoNode _oUnoServiceNode
){
325 String sServiceName
= _oUnoServiceNode
.getClassName();
326 Object oUnoObject
= _oUnoServiceNode
.getUnoObject();
327 addInterfacesToTreeNode(_oUnoServiceNode
, oUnoObject
, m_oIntrospector
.getInterfaces(oUnoObject
, sServiceName
));
328 addPropertiesToTreeNode(_oUnoServiceNode
, oUnoObject
, m_oIntrospector
.getProperties(oUnoObject
, sServiceName
));
332 private void addPropertiesToTreeNode(XUnoNode _oParentNode
, Object _oUnoParentObject
, Property
[] _aProperties
) {
334 if (_aProperties
.length
> 0){
335 for ( int n
= 0; n
< _aProperties
.length
; n
++ ){
336 Property aProperty
= _aProperties
[n
];
337 XIntrospectionAccess xIntrospectionAccess
= m_oIntrospector
.getXIntrospectionAccess(_oUnoParentObject
);
338 XPropertySet xPropertySet
= ( XPropertySet
) UnoRuntime
.queryInterface( XPropertySet
.class, xIntrospectionAccess
.queryAdapter(new Type( XPropertySet
.class)));
339 if (xPropertySet
!= null) {
340 if (xPropertySet
.getPropertySetInfo().hasPropertyByName(aProperty
.Name
)){
341 Object objectElement
= xPropertySet
.getPropertyValue(aProperty
.Name
);
342 if (objectElement
!= null) {
343 XUnoNode oChildNode
= m_xTreeControlProvider
.addUnoPropertyNode(_oUnoParentObject
, aProperty
, objectElement
);
344 if (oChildNode
!= null){
345 _oParentNode
.addChildNode(oChildNode
);
353 catch(Exception exception
) {
354 exception
.printStackTrace(System
.out
);
358 public void addContainerElementsToTreeNode(XUnoNode _oParentNode
, Object _oUnoParentObject
){
359 Object
[] oUnoContainerElements
= m_oIntrospector
.getUnoObjectsOfContainer(_oUnoParentObject
);
360 if (m_oIntrospector
.isValid(oUnoContainerElements
)){
361 if (oUnoContainerElements
.length
> 0){
362 for (int i
=0; i
< oUnoContainerElements
.length
; i
++){
363 XUnoNode oChildNode
= addUnoNode(_oParentNode
, oUnoContainerElements
[i
], UnoNode
.getNodeDescription(oUnoContainerElements
[i
]));
364 m_xTreeControlProvider
.nodeInserted(_oParentNode
, oChildNode
, _oParentNode
.getChildCount()-1);
371 private XUnoNode
addUnoNode(XUnoNode _oParentNode
, Object _oUnoObject
, String _sLabel
){
372 XUnoNode oUnoNode
= this.m_xTreeControlProvider
.addUnoNode(_oUnoObject
);
373 oUnoNode
.setLabel(_sLabel
);
374 if (_oParentNode
!= null){
375 _oParentNode
.addChildNode(oUnoNode
);
377 setNodeFoldable(oUnoNode
, _oUnoObject
);
382 private void setNodeFoldable(XUnoNode _oUnoNode
, Object _oUnoObject
){
383 if (_oUnoObject
!= null){
384 if (!m_oIntrospector
.isObjectPrimitive(_oUnoObject
)){
385 _oUnoNode
.setFoldable(true);
391 private XUnoNode
addUnoNode(XUnoNode _oParentNode
, Object _oUnoObject
, Type _aType
){
392 XUnoNode oUnoNode
= this.m_xTreeControlProvider
.addUnoNode(_oUnoObject
, _aType
);
393 if (_oParentNode
!= null){
394 _oParentNode
.addChildNode(oUnoNode
);
396 setNodeFoldable(oUnoNode
, _oUnoObject
);
401 private void addPropertySetInfoNodesToTreeNode(XUnoFacetteNode _oUnoFacetteNode
, Object _oUnoObject
){
402 if (_oUnoObject
.getClass().isArray()){
403 Object
[] object
= ( Object
[] ) _oUnoObject
;
404 for ( int i
= 0; i
< object
.length
; i
++ ) {
405 Property aProperty
= (Property
) object
[i
];
406 XUnoPropertyNode oUnoPropertyNode
= m_xTreeControlProvider
.addUnoPropertyNode(_oUnoObject
, aProperty
);
407 oUnoPropertyNode
.setLabel(XUnoFacetteNode
.SPROPERTYINFODESCRIPTION
+ " (" + aProperty
.Name
+ ")");
408 oUnoPropertyNode
.setFoldable(true);
409 _oUnoFacetteNode
.addChildNode(oUnoPropertyNode
);
414 private void addPrimitiveValuesToTreeNode(XUnoNode _oUnoNode
, Object _oUnoObject
){
415 if (_oUnoObject
.getClass().isArray()){
416 if (!_oUnoObject
.getClass().getComponentType().isPrimitive()){
417 Object
[] object
= ( Object
[] ) _oUnoObject
;
418 for ( int i
= 0; i
< object
.length
; i
++ ) {
419 if (m_oIntrospector
.isObjectPrimitive(object
[i
])){
420 XUnoNode oChildNode
= addUnoNode(_oUnoNode
, null, UnoNode
.getNodeDescription(object
[i
]));
425 String
[] sDisplayValues
= UnoNode
.getDisplayValuesofPrimitiveArray(_oUnoObject
);
426 for ( int i
= 0; i
< sDisplayValues
.length
; i
++ ) {
427 XUnoNode oUnoNode
= addUnoNode(_oUnoNode
, null, sDisplayValues
[i
]);
434 private void addPropertySetInfoSubNodes(XUnoPropertyNode _oUnoPropertyNode
){
435 Property aProperty
= _oUnoPropertyNode
.getProperty();
436 _oUnoPropertyNode
.addChildNode(m_xTreeControlProvider
.addUnoPropertyNodeWithName(aProperty
));
437 _oUnoPropertyNode
.addChildNode(m_xTreeControlProvider
.addUnoPropertyNodeWithType(aProperty
));
438 _oUnoPropertyNode
.addChildNode(m_xTreeControlProvider
.addUnoPropertyNodeWithHandle(aProperty
));
439 _oUnoPropertyNode
.addChildNode(m_xTreeControlProvider
.addUnoPropertyNodeWithAttributesDescription(aProperty
));
443 private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode
, Object _oUnoObject
){
444 if (m_oIntrospector
.isUnoPropertyValueTypeObject(_oUnoObject
)){
445 Object
[] object
= ( Object
[] ) _oUnoObject
;
446 for ( int i
= 0; i
< object
.length
; i
++ ) {
447 String sObjectClassName
= object
[i
].getClass().getName();
448 if (sObjectClassName
.equals("com.sun.star.beans.PropertyValue")){
449 XUnoNode oChildNode
= null;
450 PropertyValue aPropertyValue
= (PropertyValue
) object
[i
];
451 if (! m_oIntrospector
.isObjectPrimitive(aPropertyValue
.Value
)){
452 oChildNode
= m_xTreeControlProvider
.addUnoPropertyNode(_oUnoObject
, aPropertyValue
, _oUnoObject
);
455 oChildNode
= addUnoNode(null, aPropertyValue
.Value
, UnoPropertyNode
.getStandardPropertyValueDescription(aPropertyValue
));
457 if (oChildNode
!= null){
458 _oUnoFacetteNode
.addChildNode(oChildNode
);
466 public boolean expandNode(XUnoNode _oUnoNode
, XTreePathProvider _xTreePathProvider
){
467 if ( _oUnoNode
!= null ) {
468 _oUnoNode
.setFoldable(false);
469 if (m_xTreeControlProvider
.isMethodNode(_oUnoNode
)){
470 XUnoMethodNode oUnoMethodNode
= (XUnoMethodNode
) _oUnoNode
;
471 if (!oUnoMethodNode
.isInvoked()){
472 Object oUnoReturnObject
= invoke((XUnoMethodNode
) _oUnoNode
);
473 if (oUnoReturnObject
== null){
474 _oUnoNode
.setFoldable(true);
479 else if (m_xTreeControlProvider
.isPropertyNode(_oUnoNode
)){
480 XUnoPropertyNode oUnoPropertyNode
= (XUnoPropertyNode
) _oUnoNode
;
481 Object oUnoObject
= oUnoPropertyNode
.getUnoReturnObject();
482 if (oUnoPropertyNode
.getPropertyNodeType() == XUnoPropertyNode
.nPROPERTYSETINFOTYPE
){
483 addPropertySetInfoSubNodes(oUnoPropertyNode
);
486 //TOOD this code is redundant!!!
487 if ( oUnoObject
.getClass().isArray()){
488 // TOODO probably we should provid a possibility to insert also non-primitive nodes
489 addPrimitiveValuesToTreeNode(oUnoPropertyNode
, oUnoObject
);
492 addFacetteNodesToTreeNode(oUnoPropertyNode
, oUnoObject
);
496 else if (m_xTreeControlProvider
.isFacetteNode(_oUnoNode
)){
497 XUnoFacetteNode oUnoFacetteNode
= (XUnoFacetteNode
) _oUnoNode
;
498 Object oUnoObject
= _oUnoNode
.getUnoObject();
499 if (oUnoFacetteNode
.isMethodNode()){
500 addMethodsToTreeNode(oUnoFacetteNode
, oUnoObject
, m_oIntrospector
.getMethods(oUnoObject
));
502 if (oUnoFacetteNode
.isPropertyNode()){
503 String sNodeDescription
= oUnoFacetteNode
.getLabel();
504 // TODO: it's very dangerous to distinguishe the different UnoFacetteNodes only by the nodedescription
505 if (sNodeDescription
.startsWith(XUnoFacetteNode
.SPROPERTYINFODESCRIPTION
)){
506 addPropertySetInfoNodesToTreeNode(oUnoFacetteNode
, oUnoObject
);
508 else if (sNodeDescription
.startsWith(XUnoFacetteNode
.SPROPERTYVALUEDESCRIPTION
)){
509 addPropertyValueSubNodes(oUnoFacetteNode
, oUnoObject
);
512 addPropertiesToTreeNode(oUnoFacetteNode
, oUnoObject
, m_oIntrospector
.getProperties(oUnoObject
));
515 if (oUnoFacetteNode
.isServiceNode()){
516 addServicesToTreeNode(oUnoFacetteNode
, oUnoObject
);
518 if (oUnoFacetteNode
.isInterfaceNode()){
519 addInterfacesToTreeNode(oUnoFacetteNode
, oUnoObject
, getTypes(oUnoObject
));
521 if (oUnoFacetteNode
.isContainerNode()){
522 addContainerElementsToTreeNode(oUnoFacetteNode
, oUnoObject
);
525 else if (_oUnoNode
.getNodeType() == XUnoNode
.nSERVICE
){
526 addPropertiesAndInterfacesOfService(_oUnoNode
);
528 else if (_oUnoNode
.getNodeType() == XUnoNode
.nINTERFACE
){
529 Type aType
= _oUnoNode
.getUnoType();
531 addMethodsToTreeNode(_oUnoNode
, _oUnoNode
.getUnoObject(), m_oIntrospector
.getMethodsOfInterface(aType
));
534 else if (_oUnoNode
.getNodeType() == XUnoNode
.nOTHERS
){
535 Object oUnoObject
= _oUnoNode
.getUnoObject();
536 if ( oUnoObject
.getClass().isArray()){
537 // TOODO probably we should provid a possibility to insert also non-primitive nodes
538 addPrimitiveValuesToTreeNode(_oUnoNode
, oUnoObject
);
541 addFacetteNodesToTreeNode(_oUnoNode
, oUnoObject
);
550 public void applyFilter(XUnoFacetteNode _oUnoFacetteNode
, String _sFilter
){
551 for (int i
= 0; i
< _oUnoFacetteNode
.getChildCount(); i
++){
552 XUnoNode oUnoNode
= _oUnoFacetteNode
.getChild(i
);
553 boolean bIsVisible
= oUnoNode
.isFilterApplicable(_sFilter
);
554 m_xTreeControlProvider
.setNodeVisible(oUnoNode
, bIsVisible
);
556 _oUnoFacetteNode
.setFilter(_sFilter
);
560 /** In opposition to 'getUnoObjectOfTreeNode' this method inspects the passed node if it represents a Uno object
561 * If not it returns null
564 private Object
getUnoObjectOfExplicitTreeNode(XTreePathProvider _xTreePathProvider
){
565 XUnoNode oUnoNode
= _xTreePathProvider
.getLastPathComponent();
566 if (oUnoNode
!= null){
567 return oUnoNode
.getUnoObject();
573 public String
getFilter(XUnoNode _oUnoNode
){
575 if (_oUnoNode
!= null){
576 XUnoNode oUnoNode
= _oUnoNode
;
577 boolean bleaveLoop
= false;
579 if (m_xTreeControlProvider
.isFacetteNode(oUnoNode
)){
580 sFilter
= ((XUnoFacetteNode
) oUnoNode
).getFilter();
584 if (oUnoNode
.getParentNode() != null){
585 oUnoNode
= oUnoNode
.getParentNode();
591 } while(!bleaveLoop
);
597 /** In opposition to 'getUnoObjectOfexplictTreeNode' this method inspects the passed node if it represents a Uno object
598 * if not it keeps checking all ancestors until it finds a Uno representation
600 private Object
getUnoObjectOfTreeNode(XTreePathProvider _xTreePathProvider
){
601 XTreePathProvider xTreePathProvider
= _xTreePathProvider
;
602 HideableMutableTreeNode oNode
= null;
603 Object oUnoObject
= null;
604 while (xTreePathProvider
!= null){
605 oUnoObject
= getUnoObjectOfExplicitTreeNode(xTreePathProvider
);
606 if (oUnoObject
!= null){
607 if (oUnoObject
instanceof String
){
610 if (!m_oIntrospector
.isUnoTypeObject(oUnoObject
)){
615 xTreePathProvider
= xTreePathProvider
.getParentPath();
621 public void showPopUpMenu(Object _invoker
, int x
, int y
) throws ClassCastException
{
622 XUnoNode oUnoNode
= getSelectedNode();
623 boolean bdoEnableInvoke
= oUnoNode
instanceof XUnoMethodNode
;
624 // boolean bdoEnableSourceCodeGeneration = true;
625 if (bdoEnableInvoke
){
626 XUnoMethodNode oUnoMethodNode
= (XUnoMethodNode
) oUnoNode
;
627 bdoEnableInvoke
= oUnoMethodNode
.isInvokable();
628 // bdoEnableSourceCodeGeneration = bdoEnableInvoke;
630 m_xDialogProvider
.enablePopupMenuItem(XDialogProvider
.SINVOKE
, bdoEnableInvoke
);
631 // m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SADDTOSOURCECODE, bdoEnableSourceCodeGeneration);
632 m_xDialogProvider
.showPopUpMenu(_invoker
, x
, y
);