/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * The Contents of this file are made available subject to the terms of * the BSD license. * * Copyright 2000, 2010 Oracle and/or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Sun Microsystems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*************************************************************************/
/** The constructor of the inner class has a XMultiServiceFactory parameter.
*/ public InspectorPane(XComponentContext _xComponentContext, XDialogProvider _xDialogProvider, XTreeControlProvider _xTreeControlProvider, int _nLanguage) {
m_xComponentContext = _xComponentContext;
m_xTreeControlProvider = _xTreeControlProvider;
m_xDialogProvider = _xDialogProvider;
m_oIntrospector = Introspector.getIntrospector(m_xComponentContext);
m_oSourceCodeGenerator = new SourceCodeGenerator(_nLanguage);
_xTreeControlProvider.addInspectorPane(this);
}
/** Inspect the given object for methods, properties, interfaces, and * services. * @param _oUserDefinedObject The object to inspect * @throws RuntimeException If
*/ publicvoid inspect(java.lang.Object _oUserDefinedObject, String _sTitle) throws com.sun.star.uno.RuntimeException { try {
Object oContainer = m_xTreeControlProvider.inspect(_oUserDefinedObject, _sTitle);
m_xDialogProvider.addInspectorPage(getTitle(), oContainer);
} catch( Exception exception ) {
exception.printStackTrace(System.err);
}}
publicvoid setTitle(String _sTitle){ if (_sTitle != null){ if (_sTitle.length() > 0){
sTitle = _sTitle;
}
}
}
// add the object to the hashtable for a possible access in the tree private XUnoFacetteNode addUnoFacetteNode(XUnoNode _oParentNode, String _sNodeDescription, Object _oUnoObject){ return m_xTreeControlProvider.addUnoFacetteNode( _oParentNode, _sNodeDescription, _oUnoObject);
}
privatevoid addMethodsToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, XIdlMethod[] _xIdlMethods){ if (Introspector.isValid(_xIdlMethods)){ for ( int n = 0; n < _xIdlMethods.length; n++ ) {
XIdlMethod xIdlMethod = _xIdlMethods[n]; if (!xIdlMethod.getDeclaringClass().getName().equals("com.sun.star.uno.XInterface")){
XUnoMethodNode oChildNode = addMethodNode(_oUnoParentObject, xIdlMethod); if (oChildNode != null){
_oGrandParentNode.addChildNode(oChildNode);
}
}
}
}
}
privatevoid addFacetteNodesToTreeNode(XUnoNode _oParentNode, Object _oUnoObject){ if (m_oIntrospector.hasMethods(_oUnoObject)){
addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SMETHODDESCRIPTION, _oUnoObject);
} if (m_oIntrospector.hasProperties(_oUnoObject)){
addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SPROPERTYDESCRIPTION, _oUnoObject);
} if (m_oIntrospector.hasInterfaces(_oUnoObject)){
addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SINTERFACEDESCRIPTION, _oUnoObject);
} if (m_oIntrospector.isContainer(_oUnoObject)){
addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SCONTAINERDESCRIPTION, _oUnoObject);
} if (m_oIntrospector.hasSupportedServices(_oUnoObject)){
addUnoFacetteNode(_oParentNode, XUnoFacetteNode.SSERVICEDESCRIPTION, _oUnoObject);
}
}
privatevoid addInterfacesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoParentObject, Type[] _aTypes) { try { if (_oUnoParentObject != null){ for ( int m = 0; m < _aTypes.length; m++ ) {
addUnoNode(_oGrandParentNode, _oUnoParentObject, _aTypes[m]);
}
}
} catch( Exception exception ) {
exception.printStackTrace(System.err);
}}
// add all services for the given object to the tree under the node parent privatevoid addServicesToTreeNode(XUnoNode _oGrandParentNode, Object _oUnoObject) { try{
XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, _oUnoObject ); if ( xServiceInfo != null ){
String[] sSupportedServiceNames = xServiceInfo.getSupportedServiceNames(); for ( int m = 0; m < sSupportedServiceNames.length; m++ ) {
String sServiceName = sSupportedServiceNames[m]; if (sServiceName.length() > 0){
XUnoNode oUnoNode = addUnoNode(_oGrandParentNode, _oUnoObject, sSupportedServiceNames[m]);
oUnoNode.setNodeType(XUnoNode.nSERVICE);
}
}
}
} catch(Exception exception) {
exception.printStackTrace(System.err);
}}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.