Package org.netbeans.modules.openoffice.wizard

Examples of org.netbeans.modules.openoffice.wizard.IDLInterface


       
        if ( interfacepickupPanel.display() ) {
            OOIDLParser ooidlparser = new OOIDLParser(
            interfacepickupPanel.getInterfaceFile() );
           
            IDLInterface iDLInterface = ooidlparser.createIDLInterface();
           
            if( iDLInterface == null ) {
                // Message that the IDL does not contain a Interface
                TopManager.getDefault().notify(
                new NotifyDescriptor.Message(
                "The IDL file you have choosen, does not contain an "
                + "Interface. Please pick up an other one." ) );
            }
            else {
                if ( ooservicedata.addIDLInterface( iDLInterface ) ) {
                    defaultlistmodel.addElement(
                    iDLInterface.getIDLName().getFullName() );
                }
            }
        }
    }//GEN-LAST:event_jButtonAddInterfaceActionPerformed
View Full Code Here


   
    private void jcomboboxInterfacesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcomboboxInterfacesActionPerformed
        int intSelectedIndex = jcomboboxInterfaces.getSelectedIndex();
        if ( intSelectedIndex != -1 ) {
            // Get interface.
            IDLInterface interfacedescriptionToDisplay
            = ( IDLInterface ) vectorInterfaces.elementAt(
            intSelectedIndex );
           
            vectorMethods = interfacedescriptionToDisplay.getVectorMethods();
           
            jcomboboxMethods.removeAllItems();
           
            for ( int intMethodCounter = 0;
            intMethodCounter < vectorMethods.size();
View Full Code Here

        // Set default descriptions for every interface.
        for ( int intIndexInterface = 0;
        intIndexInterface < vectorInterfaces.size();
        intIndexInterface++ ) {
            // Get the interface.
            IDLInterface idlinterface = ( IDLInterface )
            vectorInterfaces.elementAt( intIndexInterface );
           
            // Get the method vector.
            vectorMethods = idlinterface.getVectorMethods();
           
            // Set default descriptions for every method.
            for ( int intIndexMethod = 0;
            intIndexMethod < vectorMethods.size();
            intIndexMethod++ ) {
                // Get the method.
                IDLMethod idlmethod =
                ( IDLMethod ) vectorMethods.elementAt( intIndexMethod );
               
                // Set the default display function name.
                idlmethod.setDisplayFunctionName(
                idlmethod.getMethodElement().getName().getName() );
               
                // Set the default function desription.
                idlmethod.setFunctionDescription( "Without description." );
               
                // Set the default category.
                idlmethod.setCategory( "Add-in" );
               
                // Get the method element.
                MethodElement methodelement = idlmethod.getMethodElement();
               
                // Get the parameters from the method.
                MethodParameter[] methodparameter =
                methodelement.getParameters();
               
                // Create an array for the parameter description.
                IDLParameter[] idlparameter =
                new IDLParameter[ methodparameter.length ];
               
                // Set default descriptions for every parameter.
                for ( int intIndexParameter = 0;
                intIndexParameter < methodparameter.length;
                intIndexParameter++ ) {
                    // Create a new parameter.
                    idlparameter[ intIndexParameter ] = new IDLParameter();
                   
                    // Set default display parameter name.
                    idlparameter[ intIndexParameter ].setDisplayArgumentName(
                    methodparameter[ intIndexParameter ].getName() );
                   
                    // Set default display parameter description.
                    idlparameter[ intIndexParameter ].setArgumentDescription(
                    "Without description." );
                }
               
                // Set parameter description.
                idlmethod.setArgumentDescription( idlparameter );
            }
           
            // Fill in the interface combo box.
            jcomboboxInterfaces.addItem(
            idlinterface.getIdentifierName().getName() );
        }
       
        if ( vectorInterfaces.size() > 0 ) {
            // Enable text fields and combo box.
            jcomboboxCategory.enable();
View Full Code Here

        typeParameterCategoryName );
       
        for ( int intInterfaceCounter = 0;
        intInterfaceCounter < vectorInterfaces.size();
        intInterfaceCounter++ ) {
            IDLInterface interfacedescription = ( IDLInterface )
            vectorInterfaces.elementAt( intInterfaceCounter );
            for ( int intMethodCounter = 0;
            intMethodCounter < interfacedescription.getVectorMethods().size();
            intMethodCounter++ ) {
                try {
                    IDLMethod methoddescription = ( IDLMethod )
                    interfacedescription.getVectorMethods().elementAt( intMethodCounter );
                   
                    FieldElement fieldelement = new FieldElement();
                   
                    fieldelement.setName( Identifier.create( "short" +
                    methoddescription.getMethodElement().getName().getName().toUpperCase() ) );
View Full Code Here

        return( stringIDLContent );
    }
   
    public IDLInterface createIDLInterface() {
        String QualifierString = "";
        IDLInterface bIDLInterface = new IDLInterface();
        StringTokenizer st1 = new StringTokenizer(stringIDLContent,"{");
       
        // here we should get n tokens
        // n-2 tokens are standing for the names of a modul
        // the token with the index n-1 could contain the interface description if an interface is defined in the current
        // IDL file
        // the token with the index n contains the rest of the IDL file, in case of an interface we will find the
        // descriptions of the methods in this token
       
        int  tokens = st1.countTokens();
        for(int i=0; i< tokens-2; i++) {
            // creating the name package in which the interface is located
            QualifierString = QualifierString + st1.nextToken().trim().substring(7)+".";
        }
       
        // I have to store the next token into a variable, because it could be a description of an
        // interface. If the token does not start with the key word interface,
        // then the IDL file doe not contain an interface and wie have to return a null pointer
       
        String Description_of_Inter = st1.nextToken();
       
        // test if the IDL file contains an interface
       
       
        if (!Description_of_Inter.trim().startsWith("interface")) return null;
       
        StringTokenizer st2 = new StringTokenizer(Description_of_Inter,":");
       
        // st2 contains two or more tokens
        // - first token - keyword interface and the name of the interface
        // - second and following tokens - parts of the names of all the interfaces form which the interface has inherited his behavior
        // - the program should not touch those tokens, because the content makes no sense
       
        // only the name will be copyed into the Qulifierstring
        QualifierString = QualifierString + st2.nextToken().trim().substring(10);
       
        bIDLInterface.setName(Identifier.create(QualifierString));
       
        // split the rest of the IDL file into pieces
        StringTokenizer st3 = new StringTokenizer(st1.nextToken(),"}");
       
        // st3 should countain at least m = n-1 tokens(n-1 comes from the st1), because we have the closing bracets for the module and the interfaces
        // in the first token we will find the body of the interface which contains the definition of methodes and attributes
       
        // split the  body of the interface into lines
        StringTokenizer st4 = new StringTokenizer(st3.nextToken(),";");
       
        // each token of static st4 should contain a line of the interface description
        // the means the token can consast out of a method descripption and a comment od
        // out of an attribute definition and a comment or only a methode descripotion or
        // only an attribute description
        // The comment belongs to the line before, and will appear at the start of the next line
        // the Token with the index n is an empty string
       
        // that means - the first step we have to do is to remove the comments at the end of the line
        // and store the lines into an array
       
        tokens = st4.countTokens();
       
        aTokens = new String[tokens-1];
        for(int z=0; z < tokens-1; z++) {
            aTokens[z] = st4.nextToken();
           
        }
       
       
        // the next step is to run through every element of the array and check if it is a Methode
        // if the line ends with ); - than the line contains a methode defenition
       
        for(int j=0; j < aTokens.length ; j++) {
           
            //we will parse methods only
            if  (aTokens[j].endsWith(")")) {
                String s5;
               
                MethodElement aMethodeElement = new MethodElement();
               
                // at first we have to take care of the exception
                if  (aTokens[j].indexOf("raises") != -1) {
                    s5 = aTokens[j].substring(0,aTokens[j].indexOf("raises")-2);
                    String s5b = aTokens[j].substring(aTokens[j].indexOf("raises") + 6);
                   
                    //if s5b not 0 - then we have to deal with the exceptions
                    if (s5b.length() != 0 ) {
                        String s6 = s5b.trim().substring(1);
                        s6 = s6.substring(0,s6.length()-1);
                        StringTokenizer stt6 = new StringTokenizer(s6,",");
                        int btokens =  stt6.countTokens();
                        Identifier[] aExceptions = new Identifier[btokens];
                        for(int a=0; a <  btokens;a++) {
                            aExceptions[a] = Identifier.create(OOTools.replaceSubStrings(stt6.nextToken().trim(),"::", "."));
                        }
                        try {
                            aMethodeElement.setExceptions(aExceptions);
                        }catch (Exception e){
                            System.out.println( e );
                        }
                    }
                } else  s5 = aTokens[j].substring(0,aTokens[j].length()-1);
               
                // s5 contains only the methode without an exception
                // it is possible the the line starts with a comment
                // which was inserted at the end of the line before
               
                StringTokenizer st5 = new StringTokenizer(s5,"(");
               
                // if we have a methode with has no parameter - st5 will contain only one token
                // it does no matter if the method raises a eception or not.
                // that means we have to test the token count
                // we have to care about the parameters only if the count is 2
               
                StringTokenizer st6 = new StringTokenizer(st5.nextToken().trim()," ");
               
               
                // after we have created st6 - n tokens
                // n should be the name of the function
                // n - 1 is definitely the return type of the function
                // n - 2 could be a modifier or the keyword oneway or simply a
                // word of a comment
                // n-3 to 0 all stuff we do not need
               
               
                int ctokens = st6.countTokens();
               
                String returnType = null;
               
                try {
                    if (ctokens > 3)
                    { for(int b=0; b < ctokens-3;b++) {
                          st6.nextToken();
                      }
                    }
                    if (ctokens>=3) {
                        // this could be the modifier
                        String ModifierString = st6.nextToken();
                        if ((ModifierString=="public") || (ModifierString=="protected") || (ModifierString=="private")) {
                            if (ModifierString=="public") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC);
                            if (ModifierString=="protected") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PROTECTED);
                            if (ModifierString=="private") aMethodeElement.setModifiers(java.lang.reflect.Modifier.PRIVATE);
                        }else{aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC); }
                       
                    }
                    if (ctokens==2) aMethodeElement.setModifiers(java.lang.reflect.Modifier.PUBLIC);
                    returnType = st6.nextToken();
                    aMethodeElement.setName(Identifier.create(st6.nextToken()));
                    String sss = this.mapParameterTypes(returnType);
                    aMethodeElement.setReturn(Type.parse(this.mapParameterTypes(returnType)));
                   
                   
                }catch (Exception e){
                    System.out.println( e );
                };
               
                // test how many tokens are left over in st5
                if (st5.countTokens()== 1) {
                    // due to the fact that st5 still contains one token, we have to take care of the parameters
                    st6 = new StringTokenizer(st5.nextToken(),",");
                    tokens = st6.countTokens();
                   
                    org.openide.src.MethodParameter[] aMethodeParameters = new org.openide.src.MethodParameter[tokens];
                    for(int k=0; k < tokens;k++)
                    {  String aTypeString;
                       StringTokenizer st7 = new StringTokenizer(st6.nextToken().trim()," ");
                       // now we have the certain parameter
                       String Direction = st7.nextToken();
                      
                       if (Direction.indexOf("out")!= -1) aTypeString = "sequence<" + st7.nextToken()+">";
                       else   aTypeString = st7.nextToken();
                       String bString = st7.nextToken();
                       aMethodeParameters[k] = new org.openide.src.MethodParameter(bString, Type.parse(this.mapParameterTypes(aTypeString)), false);
                    }
                    try {
                        aMethodeElement.setParameters(aMethodeParameters);
                    } catch (Exception e){
                        System.out.println( e );
                    }
                }
                try {
                    // Define an empty return command.
                    String stringReturnCommand = "";
                   
                    // Test if return type is not void.
                    if ( !returnType.equals( "void" ) ) {
                        // Get the Java type of the method.
                        String stringJavaType = this.mapParameterTypes(
                        returnType );
                       
                        if ( ( stringJavaType.equals( "short" )
                        || ( stringJavaType.equals( "int" ) )
                        || ( stringJavaType.equals( "long" ) )
                        || ( stringJavaType.equals( "float" ) )
                        || ( stringJavaType.equals( "double" ) )
                        || ( stringJavaType.equals( "char" ) )
                        || ( stringJavaType.equals( "byte" ) ) ) ) {
                            stringReturnCommand = "\nreturn 0;\n";
                        }
                        else if ( stringJavaType.equals( "boolean" ) ) {
                            stringReturnCommand = "\nreturn false;\n";
                        }
                        else {
                            stringReturnCommand = "\nreturn null;\n";
                        }
                    }
                   
                    aMethodeElement.setBody(
                    "\n\n\n// ToDo: Please insert your implementation code "
                    + "here.\n\n" + stringReturnCommand );
                    IDLMethod aIDLMethod = new IDLMethod();
                    aIDLMethod.setMethod(aMethodeElement);
                    bIDLInterface.addIDLMethod(aIDLMethod);
                } catch (Exception e){
                    System.out.println( e );
                }
               
            }
View Full Code Here

        // Add all Java interfaces to the content list.
        for ( int intIndexInterfaces = 0;
        intIndexInterfaces < vectorInterfaces.size();
        intIndexInterfaces++ ) {
            // Get the interface.
            IDLInterface idlinterface = ( IDLInterface )
            vectorInterfaces.elementAt( intIndexInterfaces );
           
            // Get the interface name.
            String stringInterfaceName =
            idlinterface.getIdentifierName().getName();
           
            // Get the package.
            String stringPackage =
            idlinterface.getIdentifierName().getQualifier();
           
//            // Get index of first package separator.
//            int intIndexFirstPackageSeparator = stringPackage.indexOf( '.' );
//           
//            // Declare root package string.
View Full Code Here

        String stringInterfaceTypes = "";
       
        for ( int intIndexInterfaces = 0;
        intIndexInterfaces < vectorInterfaces.size();
        intIndexInterfaces++ ) {
            IDLInterface idlinterface =
            ( IDLInterface ) vectorInterfaces.elementAt( intIndexInterfaces );
           
            String stringIDLFullName =
            idlinterface.getIDLName().getFullName().replace( '.', '/' );
           
            String stringIDLName =
            idlinterface.getIDLName().getName();
           
            stringIDLFiles += "${OutputDirectory}/" + stringIDLFullName + ".idl ";
            stringURDFiles += "${OutputDirectory}/" + stringIDLName + ".urd ";
           
            // Get the full interface name.
            String stringFullName = idlinterface.getIDLName().getFullName();
           
            // Show message.
            //            TopManager.getDefault().notify(
            //            new NotifyDescriptor.Message(
            //            stringFullName ) );
View Full Code Here

TOP

Related Classes of org.netbeans.modules.openoffice.wizard.IDLInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.