Use correct object
[LibreOffice.git] / odk / examples / java / Inspector / InspectorPane.java
blob6483958b76b3aa8c31861c5da07d2ab62b7c9889
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * the BSD license.
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
37 import org.openoffice.XInstanceInspector;
39 import com.sun.star.beans.Property;
40 import com.sun.star.beans.PropertyValue;
41 import com.sun.star.beans.XIntrospectionAccess;
42 import com.sun.star.beans.XPropertySet;
43 import com.sun.star.lang.XServiceInfo;
44 import com.sun.star.lib.uno.helper.WeakBase;
45 import com.sun.star.reflection.XIdlMethod;
46 import com.sun.star.uno.Any;
47 import com.sun.star.uno.AnyConverter;
48 import com.sun.star.uno.Type;
49 import com.sun.star.uno.TypeClass;
50 import com.sun.star.uno.UnoRuntime;
51 import com.sun.star.uno.XComponentContext;
53 public class InspectorPane extends WeakBase implements XInstanceInspector{ //, XServiceInfo
54 private XComponentContext m_xComponentContext;
55 private XDialogProvider m_xDialogProvider;
56 private Introspector m_oIntrospector = null;
57 private SourceCodeGenerator m_oSourceCodeGenerator;
58 private XTreeControlProvider m_xTreeControlProvider;
59 private String sTitle = "";
62 /** The constructor of the inner class has a XMultiServiceFactory parameter.
64 public InspectorPane(XComponentContext _xComponentContext, XDialogProvider _xDialogProvider, XTreeControlProvider _xTreeControlProvider, int _nLanguage) {
65 m_xComponentContext = _xComponentContext;
66 m_xTreeControlProvider = _xTreeControlProvider;
67 m_xDialogProvider = _xDialogProvider;
68 m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
69 m_oSourceCodeGenerator = new SourceCodeGenerator(_nLanguage);
70 _xTreeControlProvider.addInspectorPane(this);
73 /** Inspect the given object for methods, properties, interfaces, and
74 * services.
75 * @param _oUserDefinedObject The object to inspect
76 * @throws RuntimeException If
78 public void inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException {
79 try {
80 Object oContainer = m_xTreeControlProvider.inspect(_oUserDefinedObject, _sTitle);
81 m_xDialogProvider.addInspectorPage(getTitle(), oContainer);
83 catch( Exception exception ) {
84 exception.printStackTrace(System.err);
88 public void setTitle(String _sTitle){
89 if (_sTitle != null){
90 if (_sTitle.length() > 0){
91 sTitle = _sTitle;
97 public String getTitle(){
98 return sTitle;
103 private Type[] getTypes(Object _oUnoObject){
104 Type[] aTypes = null;
105 if (AnyConverter.isArray(_oUnoObject)){
106 aTypes = (Type[])_oUnoObject;
108 else{
109 aTypes = m_oIntrospector.getInterfaces(_oUnoObject);
111 return aTypes;
115 private Object invoke(XUnoMethodNode _oUnoMethodNode){
116 try{
117 String sParamValueDescription = "";
118 Object oUnoReturnObject = _oUnoMethodNode.invoke();
119 boolean bHasParameters = _oUnoMethodNode.hasParameters();
120 boolean bIsPrimitive = _oUnoMethodNode.isPrimitive();
121 if (bHasParameters){
122 sParamValueDescription = " (" + m_oSourceCodeGenerator.getMethodParameterValueDescription(_oUnoMethodNode, _oUnoMethodNode.getLastParameterObjects(), true) + ")";
124 if (oUnoReturnObject != null ){
125 String sNodeDescription = "";
126 XUnoNode oUnoNode = null;
127 if (_oUnoMethodNode.getXIdlMethod().getReturnType().getTypeClass().getValue() == TypeClass.VOID_value){
128 sNodeDescription += _oUnoMethodNode.getXIdlMethod().getReturnType().getName() + " " + _oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription;
129 _oUnoMethodNode.setLabel(sNodeDescription);
130 m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
132 else if (bHasParameters || !bIsPrimitive){
133 if (bIsPrimitive){
134 sNodeDescription += m_oSourceCodeGenerator.getStringValueOfObject(oUnoReturnObject, _oUnoMethodNode.getTypeClass());
136 else{
137 Any aReturnObject = Any.complete(oUnoReturnObject);
138 String sShortClassName = Introspector.getShortClassName(aReturnObject.getType().getTypeName());
139 sNodeDescription += m_oSourceCodeGenerator.getVariableNameforUnoObject(sShortClassName);
141 if (Introspector.isArray(oUnoReturnObject)){
142 if (Introspector.isUnoTypeObject(oUnoReturnObject)){
143 oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoMethodNode.getUnoObject());
145 else if(Introspector.isUnoPropertyTypeObject(oUnoReturnObject)){
146 oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYINFODESCRIPTION, oUnoReturnObject);
148 else if(Introspector.isUnoPropertyValueTypeObject(oUnoReturnObject)){
149 oUnoNode = addUnoFacetteNode(_oUnoMethodNode, XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION, oUnoReturnObject);
152 if (oUnoNode == null){
153 if (bHasParameters){
154 sNodeDescription += sParamValueDescription;
156 oUnoNode = addUnoNode(null, oUnoReturnObject, sNodeDescription);
157 if (bHasParameters){
158 oUnoNode.setParameterObjects(_oUnoMethodNode.getLastParameterObjects());
161 if (oUnoNode != null){
162 oUnoNode.setFoldable(!bIsPrimitive);
163 _oUnoMethodNode.setFoldable(false);
164 _oUnoMethodNode.addChildNode(oUnoNode);
165 m_xTreeControlProvider.nodeInserted(_oUnoMethodNode, oUnoNode, _oUnoMethodNode.getChildCount()-1);
168 else{
169 if (bIsPrimitive){
170 sNodeDescription = _oUnoMethodNode.getStandardMethodDescription() + "=" + UnoMethodNode.getDisplayValueOfPrimitiveType(oUnoReturnObject);
171 _oUnoMethodNode.setLabel(sNodeDescription);
172 m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
176 // ReturnObject of method node == null...
177 else{
178 if (!bHasParameters){
179 _oUnoMethodNode.setLabel(_oUnoMethodNode.getLabel() + " = null");
181 else{
182 _oUnoMethodNode.setLabel(_oUnoMethodNode.getXIdlMethod().getName() + sParamValueDescription + " = null");
184 m_xTreeControlProvider.nodeChanged(_oUnoMethodNode);
186 return oUnoReturnObject;
187 }catch(Exception exception ) {
188 return null;
192 public void invokeSelectedMethodNode(){
193 XTreePathProvider xTreePathProvider = m_xTreeControlProvider.getSelectedPath();
194 XUnoNode oUnoNode = xTreePathProvider.getLastPathComponent();
195 if (oUnoNode instanceof XUnoMethodNode){
196 invoke((XUnoMethodNode) oUnoNode);
197 m_xTreeControlProvider.expandPath(xTreePathProvider);
202 public void addSourceCodeOfSelectedNode(){
203 XTreePathProvider oTreePathProvider = m_xTreeControlProvider.getSelectedPath();
204 XUnoNode oUnoNode = oTreePathProvider.getLastPathComponent();
205 if (oUnoNode instanceof XUnoMethodNode){
206 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
207 if (!oUnoMethodNode.isInvoked() && oUnoMethodNode.isInvokable()){
208 invoke(oUnoMethodNode);
211 String sSourceCode = m_oSourceCodeGenerator.addSourceCodeOfUnoObject(oTreePathProvider, true, true);
212 m_xTreeControlProvider.setSourceCode(sSourceCode);
216 public void convertCompleteSourceCode(int _nLanguage){
217 String sSourceCode = m_oSourceCodeGenerator.convertAllUnoObjects(_nLanguage);
218 m_xTreeControlProvider.setSourceCode(sSourceCode);
221 protected XUnoNode getSelectedNode(){
222 return m_xTreeControlProvider.getSelectedNode();
226 // add the object to the hashtable for a possible access in the tree
227 private XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){
228 return m_xTreeControlProvider.addUnoFacetteNode( _oParentNode, _sNodeDescription, _oUnoObject);
232 private XUnoMethodNode addMethodNode(Object _objectElement, XIdlMethod _xIdlMethod){
233 return m_xTreeControlProvider.addMethodNode(_objectElement, _xIdlMethod);
238 private void addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){
239 if (Introspector.isValid(_xIdlMethods)){
240 for ( int n = 0; n < _xIdlMethods.length; n++ ) {
241 XIdlMethod xIdlMethod = _xIdlMethods[n];
242 if (!xIdlMethod.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
243 XUnoMethodNode oChildNode = addMethodNode(_oUnoParentObject, xIdlMethod);
244 if (oChildNode != null){
245 _oGrandParentNode.addChildNode(oChildNode);
253 private void addFacetteNodesToTreeNode(XUnoNode _oParentNode, Object _oUnoObject){
254 if (m_oIntrospector.hasMethods(_oUnoObject)){
255 addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SMETHODDESCRIPTION, _oUnoObject);
257 if (m_oIntrospector.hasProperties(_oUnoObject)){
258 addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SPROPERTYDESCRIPTION, _oUnoObject);
260 if (m_oIntrospector.hasInterfaces(_oUnoObject)){
261 addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoObject);
263 if (m_oIntrospector.isContainer(_oUnoObject)){
264 addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SCONTAINERDESCRIPTION, _oUnoObject);
266 if (m_oIntrospector.hasSupportedServices(_oUnoObject)){
267 addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SSERVICEDESCRIPTION, _oUnoObject);
272 private void addInterfacesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, Type[] _aTypes) {
273 try {
274 if (_oUnoParentObject != null){
275 for ( int m = 0; m < _aTypes.length; m++ ) {
276 addUnoNode(_oGrandParentNode, _oUnoParentObject, _aTypes[m]);
280 catch( Exception exception ) {
281 exception.printStackTrace(System.err);
285 // add all services for the given object to the tree under the node parent
286 private void addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) {
287 try{
288 XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject );
289 if ( xServiceInfo != null ){
290 String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames();
291 for ( int m = 0; m < sSupportedServiceNames.length; m++ ) {
292 String sServiceName = sSupportedServiceNames[m];
293 if (sServiceName.length() > 0){
294 XUnoNode oUnoNode = addUnoNode(_oGrandParentNode, _oUnoObject, sSupportedServiceNames[m]);
295 oUnoNode.setNodeType(XUnoNode.nSERVICE);
300 catch(Exception exception) {
301 exception.printStackTrace(System.err);
305 private void addPropertiesAndInterfacesOfService(XUnoNode _oUnoServiceNode){
306 String sServiceName = _oUnoServiceNode.getClassName();
307 Object oUnoObject = _oUnoServiceNode.getUnoObject();
308 addInterfacesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getInterfaces(oUnoObject, sServiceName));
309 addPropertiesToTreeNode(_oUnoServiceNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject, sServiceName));
313 private void addPropertiesToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject, Property[] _aProperties) {
314 try {
315 if (_aProperties.length > 0){
316 for ( int n = 0; n < _aProperties.length; n++ ){
317 Property aProperty = _aProperties[n];
318 XIntrospectionAccess xIntrospectionAccess = m_oIntrospector.getXIntrospectionAccess(_oUnoParentObject);
319 XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIntrospectionAccess.queryAdapter(new Type( XPropertySet.class)));
320 if (xPropertySet != null) {
321 if (xPropertySet.getPropertySetInfo().hasPropertyByName(aProperty.Name)){
322 Object objectElement = xPropertySet.getPropertyValue(aProperty.Name);
323 if (objectElement != null) {
324 XUnoNode oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoParentObject, aProperty, objectElement);
325 if (oChildNode != null){
326 _oParentNode.addChildNode(oChildNode);
334 catch(Exception exception) {
335 exception.printStackTrace(System.err);
339 private void addContainerElementsToTreeNode(XUnoNode _oParentNode, Object _oUnoParentObject){
340 Object[] oUnoContainerElements = m_oIntrospector.getUnoObjectsOfContainer(_oUnoParentObject);
341 if (Introspector.isValid(oUnoContainerElements)){
342 if (oUnoContainerElements.length > 0){
343 for (int i=0; i< oUnoContainerElements.length; i++){
344 XUnoNode oChildNode = addUnoNode(_oParentNode, oUnoContainerElements[i], UnoNode.getNodeDescription(oUnoContainerElements[i]));
345 m_xTreeControlProvider.nodeInserted(_oParentNode, oChildNode, _oParentNode.getChildCount()-1);
352 private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, String _sLabel ){
353 XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject);
354 oUnoNode.setLabel(_sLabel);
355 if (_oParentNode != null){
356 _oParentNode.addChildNode(oUnoNode);
358 setNodeFoldable(oUnoNode, _oUnoObject);
359 return oUnoNode;
363 private void setNodeFoldable(XUnoNode _oUnoNode, Object _oUnoObject){
364 if (_oUnoObject != null){
365 if (!Introspector.isObjectPrimitive(_oUnoObject)){
366 _oUnoNode.setFoldable(true);
372 private XUnoNode addUnoNode(XUnoNode _oParentNode, Object _oUnoObject, Type _aType){
373 XUnoNode oUnoNode = this.m_xTreeControlProvider.addUnoNode(_oUnoObject, _aType);
374 if (_oParentNode != null){
375 _oParentNode.addChildNode(oUnoNode);
377 setNodeFoldable(oUnoNode, _oUnoObject);
378 return oUnoNode;
382 private void addPropertySetInfoNodesToTreeNode(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
383 if (_oUnoObject.getClass().isArray()){
384 Object[] object = ( Object[] ) _oUnoObject;
385 for ( int i = 0; i < object.length; i++ ) {
386 Property aProperty = (Property) object[i];
387 XUnoPropertyNode oUnoPropertyNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aProperty);
388 oUnoPropertyNode.setLabel(XUnoFacetteNode.SPROPERTYINFODESCRIPTION + " (" + aProperty.Name + ")");
389 oUnoPropertyNode.setFoldable(true);
390 _oUnoFacetteNode.addChildNode(oUnoPropertyNode);
395 private void addPrimitiveValuesToTreeNode(XUnoNode _oUnoNode, Object _oUnoObject){
396 if (_oUnoObject.getClass().isArray()){
397 if (!_oUnoObject.getClass().getComponentType().isPrimitive()){
398 Object[] object = ( Object[] ) _oUnoObject;
399 for ( int i = 0; i < object.length; i++ ) {
400 if (Introspector.isObjectPrimitive(object[i])){
401 addUnoNode(_oUnoNode, null, UnoNode.getNodeDescription(object[i]));
405 else{
406 String[] sDisplayValues = UnoNode.getDisplayValuesofPrimitiveArray(_oUnoObject);
407 for ( int i = 0; i < sDisplayValues.length; i++ ) {
408 addUnoNode(_oUnoNode, null, sDisplayValues[i]);
415 private void addPropertySetInfoSubNodes(XUnoPropertyNode _oUnoPropertyNode){
416 Property aProperty = _oUnoPropertyNode.getProperty();
417 _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithName(aProperty));
418 _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithType(aProperty));
419 _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithHandle(aProperty));
420 _oUnoPropertyNode.addChildNode(m_xTreeControlProvider.addUnoPropertyNodeWithAttributesDescription(aProperty));
424 private void addPropertyValueSubNodes(XUnoFacetteNode _oUnoFacetteNode, Object _oUnoObject){
425 if (Introspector.isUnoPropertyValueTypeObject(_oUnoObject)){
426 Object[] object = ( Object[] ) _oUnoObject;
427 for ( int i = 0; i < object.length; i++ ) {
428 String sObjectClassName = object[i].getClass().getName();
429 if (sObjectClassName.equals("com.sun.star.beans.PropertyValue")){
430 XUnoNode oChildNode = null;
431 PropertyValue aPropertyValue = (PropertyValue) object[i];
432 if (! Introspector.isObjectPrimitive(aPropertyValue.Value)){
433 oChildNode = m_xTreeControlProvider.addUnoPropertyNode(_oUnoObject, aPropertyValue, _oUnoObject);
435 else{
436 oChildNode = addUnoNode(null, aPropertyValue.Value, UnoPropertyNode.getStandardPropertyValueDescription(aPropertyValue));
438 if (oChildNode != null){
439 _oUnoFacetteNode.addChildNode(oChildNode);
447 public boolean expandNode(XUnoNode _oUnoNode){
448 if ( _oUnoNode != null ) {
449 _oUnoNode.setFoldable(false);
450 if (m_xTreeControlProvider.isMethodNode(_oUnoNode)){
451 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) _oUnoNode;
452 if (!oUnoMethodNode.isInvoked()){
453 Object oUnoReturnObject = invoke((XUnoMethodNode) _oUnoNode);
454 if (oUnoReturnObject == null){
455 _oUnoNode.setFoldable(true);
456 return false;
460 else if (m_xTreeControlProvider.isPropertyNode(_oUnoNode)){
461 XUnoPropertyNode oUnoPropertyNode = (XUnoPropertyNode) _oUnoNode;
462 Object oUnoObject = oUnoPropertyNode.getUnoReturnObject();
463 if (oUnoPropertyNode.getPropertyNodeType() == XUnoPropertyNode.nPROPERTYSETINFOTYPE){
464 addPropertySetInfoSubNodes(oUnoPropertyNode);
466 else{
467 //TODO: this code is redundant!!!
468 if ( oUnoObject.getClass().isArray()){
469 // TODO: probably we should provide a possibility to insert also non-primitive nodes
470 addPrimitiveValuesToTreeNode(oUnoPropertyNode, oUnoObject);
472 else{
473 addFacetteNodesToTreeNode(oUnoPropertyNode, oUnoObject);
477 else if (m_xTreeControlProvider.isFacetteNode(_oUnoNode)){
478 XUnoFacetteNode oUnoFacetteNode = (XUnoFacetteNode) _oUnoNode;
479 Object oUnoObject = _oUnoNode.getUnoObject();
480 if (oUnoFacetteNode.isMethodNode()){
481 addMethodsToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getMethods(oUnoObject));
483 if (oUnoFacetteNode.isPropertyNode()){
484 String sNodeDescription = oUnoFacetteNode.getLabel();
485 // TODO: it's very dangerous to distinguish the different UnoFacetteNodes only by the node description
486 if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYINFODESCRIPTION)){
487 addPropertySetInfoNodesToTreeNode(oUnoFacetteNode, oUnoObject);
489 else if (sNodeDescription.startsWith(XUnoFacetteNode.SPROPERTYVALUEDESCRIPTION)){
490 addPropertyValueSubNodes(oUnoFacetteNode, oUnoObject);
492 else{
493 addPropertiesToTreeNode(oUnoFacetteNode, oUnoObject, m_oIntrospector.getProperties(oUnoObject));
496 if (oUnoFacetteNode.isServiceNode()){
497 addServicesToTreeNode(oUnoFacetteNode, oUnoObject);
499 if (oUnoFacetteNode.isInterfaceNode()){
500 addInterfacesToTreeNode(oUnoFacetteNode, oUnoObject, getTypes(oUnoObject));
502 if (oUnoFacetteNode.isContainerNode()){
503 addContainerElementsToTreeNode(oUnoFacetteNode, oUnoObject);
506 else if (_oUnoNode.getNodeType() == XUnoNode.nSERVICE){
507 addPropertiesAndInterfacesOfService(_oUnoNode);
509 else if (_oUnoNode.getNodeType() == XUnoNode.nINTERFACE){
510 Type aType = _oUnoNode.getUnoType();
511 if (aType != null){
512 addMethodsToTreeNode(_oUnoNode, _oUnoNode.getUnoObject(), m_oIntrospector.getMethodsOfInterface(aType));
515 else if (_oUnoNode.getNodeType() == XUnoNode.nOTHERS){
516 Object oUnoObject = _oUnoNode.getUnoObject();
517 if ( oUnoObject.getClass().isArray()){
518 // TODO: probably we should provide a possibility to insert also non-primitive nodes
519 addPrimitiveValuesToTreeNode(_oUnoNode, oUnoObject);
521 else{
522 addFacetteNodesToTreeNode(_oUnoNode, oUnoObject);
526 return true;
531 public void applyFilter(XUnoFacetteNode _oUnoFacetteNode, String _sFilter){
532 for (int i = 0; i < _oUnoFacetteNode.getChildCount(); i++){
533 XUnoNode oUnoNode = _oUnoFacetteNode.getChild(i);
534 boolean bIsVisible = oUnoNode.isFilterApplicable(_sFilter);
535 m_xTreeControlProvider.setNodeVisible(oUnoNode, bIsVisible);
537 _oUnoFacetteNode.setFilter(_sFilter);
541 public String getFilter(XUnoNode _oUnoNode){
542 String sFilter = "";
543 if (_oUnoNode != null){
544 XUnoNode oUnoNode = _oUnoNode;
545 boolean bleaveLoop = false;
547 if (m_xTreeControlProvider.isFacetteNode(oUnoNode)){
548 sFilter = ((XUnoFacetteNode) oUnoNode).getFilter();
549 bleaveLoop = true;
551 else{
552 if (oUnoNode.getParentNode() != null){
553 oUnoNode = oUnoNode.getParentNode();
555 else{
556 bleaveLoop = true;
559 } while(!bleaveLoop);
561 return sFilter;
565 public void showPopUpMenu(Object _invoker, int x, int y) throws ClassCastException{
566 XUnoNode oUnoNode = getSelectedNode();
567 boolean bdoEnableInvoke = oUnoNode instanceof XUnoMethodNode;
568 if (bdoEnableInvoke){
569 XUnoMethodNode oUnoMethodNode = (XUnoMethodNode) oUnoNode;
570 bdoEnableInvoke = oUnoMethodNode.isInvokable();
572 m_xDialogProvider.enablePopupMenuItem(XDialogProvider.SINVOKE, bdoEnableInvoke);
573 m_xDialogProvider.showPopUpMenu(_invoker, x, y);
577 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */