Package org.openide.loaders

Examples of org.openide.loaders.DataObject


   
   
    public Set instantiate(TemplateWizard wiz) throws IOException/*, IllegalStateException*/ {
        String name = wiz.getTargetName();
        DataFolder targetFolder = wiz.getTargetFolder();
        DataObject template = wiz.getTemplate();
        DataObject result;
       
        if (name == null) {
            result = template.createFromTemplate(targetFolder);
        } else {
            result = template.createFromTemplate(targetFolder, name);
        }
       
        SourceCookie sourcecookie = (SourceCookie)result.getCookie(SourceCookie.class);
        if(sourcecookie == null) {
            //what should we do if the template does not contain a class
            return Collections.singleton(result);
        }
        //here we get the outer class
        ClassElement aclasselement[] = sourcecookie.getSource().getClasses();
        try {
           
            sourcecookie.getSource().addImports(myData.getImports());
            sourcecookie.getSource().removeClass(aclasselement[0]);
            sourcecookie.getSource().addClass(myData.getOuterClass());
           
            // Create a manifest.
            OOTools.writeManifest(
            targetFolder.getPrimaryFile().getFileSystem().getSystemName(),
            myData.getPackage()
            + ( ( myData.getPackage().equals( "" ) ) ? ( "" ) : ( "." ) )
            + myData.getClassName() );
           
            // Create Basic code for registering the service in the office.
            OOTools.writeBasicCode(
            targetFolder.getPrimaryFile().getFileSystem().getSystemName(),
            myData.getServiceName(),
            myData.getClassName() );
           
            //            TopManager.getDefault().notify(
            //            new NotifyDescriptor.Message(
            //            "Start creating the jar content..." ) );
           
            // Create jar content with necessary files.
            OOTools.createJarContent( myData,
            targetFolder.getPrimaryFile().getFileSystem().getSystemName(),
            targetFolder.getPrimaryFile().getFileSystem() );
           
            //            TopManager.getDefault().notify(
            //            new NotifyDescriptor.Message(
            //            "Finished creating the jar content." ) );
           
            // Create a ANT build file for the component.
            OOTools.writeANTFile( myData,
            targetFolder.getPrimaryFile().getFileSystem().getSystemName() );
        }
        catch(SourceException sourceexception) {
            result.delete();
            throw new IOException(sourceexception.getLocalizedMessage());
        }
        OpenCookie open = (OpenCookie) result.getCookie(OpenCookie.class);
        if (open != null) {
            open.open();
        }
        OOTools.installFiles(
        OOIDLGlobalSettings.getDefault().getSDKDirectory(),
View Full Code Here


            // Exit the method.
            return;
        }
       
        // Create an empty data object.
        DataObject dataobject = null;
       
        try {
            // Find the data object of the file object.
            dataobject = DataObject.find( fileobject );
        }
        catch( DataObjectNotFoundException dataobjectnotfoundexception ) {
            // Show message.
            TopManager.getDefault().notify(
            new NotifyDescriptor.Message(
            dataobjectnotfoundexception.toString() ) );
        }
       
        // Create an empty content member list for the jar content.
        ContentMemberList contentmemberlist = new ContentMemberList();
       
       
       
       
        //        // Get file object of the service implementation.
        //        FileObject fileobjectManifest = repository.find(
        //        ooservicedata.getOuterClass().getName().getQualifier(),
        //        "manifest",
        //        "mf" );
        //
        //        // Could the service implementation not be found?
        //        if ( fileobjectManifest == null ) {
        //            // Show message.
        //            TopManager.getDefault().notify(
        //            new NotifyDescriptor.Message(
        //            "Error: No file found. Package:" +
        //            ooservicedata.getOuterClass().getName().getQualifier()
        //            + ", Name:"
        //            + "manifest.mf" ) );
        //
        //            // Exit the method.
        //            return;
        //        }
        //
        //        // Create an empty data object.
        //        DataObject dataobjectManifest = null;
        //
        //        try {
        //            // Find the data object of the file object.
        //            dataobjectManifest = DataObject.find( fileobjectManifest );
        //        }
        //        catch( DataObjectNotFoundException dataobjectnotfoundexception ) {
        //            dataobjectnotfoundexception.printStackTrace();
        //        }
        //
        //        // Add the data object of the service implementation to the list.
        //        contentmemberlist.addMember( dataobjectManifest );
       
       
        // Create an empty manifest object.
        Manifest manifest = null;
       
        try {
            // Create the manifest with a given system file.
            //            TopManager.getDefault().notify(
            //            new NotifyDescriptor.Message(
            //            stringSystemDirectory
            ////            + File.separator + "META-INF"
            //            + File.separator + stringManifestFile ) );
           
            manifest = new Manifest( new FileInputStream(
            stringSystemDirectory
            //            + File.separator + "META-INF"
            + File.separator + "MANIFEST_" + ooservicedata.getClassName()
            + ".TXT" ) );
           
            //            Iterator iterator =
            //            manifest.getMainAttributes().values().iterator();
            //
            //            for ( int intIndexAttributes = 0;
            //            iterator.hasNext();
            //            intIndexAttributes++ ) {
            //                TopManager.getDefault().notify(
            //                new NotifyDescriptor.Message(
            //                "Attribute: " + iterator.next().toString() + "\n" ) );
            //            }
           
        }
        catch( FileNotFoundException filenotfoundexception ) {
            // Show message.
            TopManager.getDefault().notify(
            new NotifyDescriptor.Message(
            filenotfoundexception.toString() ) );
        }
        catch( IOException ioexception ) {
            // Show message.
            TopManager.getDefault().notify(
            new NotifyDescriptor.Message(
            ioexception.toString() ) );
        }
       
        // Get the vector containing the interfaces.
        Vector vectorInterfaces = ooservicedata.getIDLInterfaces();
       
        // 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.
//            String stringRootPackage = null;
//           
//            // Get root package.
//            if ( intIndexFirstPackageSeparator != -1 ) {
//                stringRootPackage = stringPackage.substring( 0,
//                intIndexFirstPackageSeparator );
//            }
//            else {
//                stringRootPackage = stringPackage;
//            }
////            String stringRootPackage = stringPackage.substring( 0,
////            intIndexFirstPackageSeparator );
           
            // Create an empty file object.
            FileObject fileobjectIDL = null;
           
            // Get directory.
//            fileobjectIDL = filesystemOutput.find( stringRootPackage, null, null );
            fileobjectIDL = filesystemOutput.find( stringPackage,
            stringInterfaceName, "idl" );
           
            //            // Get file object of the service implementation.
            //            fileobjectIDL = repository.find( stringPackage,
            //            stringInterfaceName, "java" );
           
            // Could the file object not be found?
            if ( fileobjectIDL == null ) {
                // Show message.
                TopManager.getDefault().notify(
                new NotifyDescriptor.Message(
//                "Error: No package found. Package:" + stringRootPackage ) );
                "Error: No file found. Package:" + stringPackage + ", Name:"
                + stringInterfaceName ) );
               
                continue;
            }
           
            // Create an empty data object.
            DataObject dataobjectIDL = null;
           
            try {
                // Find the data object of the file object.
                dataobjectIDL = DataObject.find( fileobjectIDL );
            }
View Full Code Here

            TopManager.getDefault().notify(d);
            return;
        }

        FileSystem fs = Repository.getDefault().getDefaultFileSystem();
        DataObject result = null;
        try {
            DataObject dObj = DataObject.find(fs.findResource(sourceFile));
            result = dObj.createFromTemplate(parent);
        }
        catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
View Full Code Here

        FileObject fo;

        try {
            TopComponent tc = TopComponent.getRegistry().getActivated();

            DataObject mainDataObj = tc.getLookup().lookup(DataObject.class);
            fo = mainDataObj.getPrimaryFile();
            Project proj = FileOwnerQuery.getOwner(fo);
    
            return proj;
        } catch (Exception e) {
        }
View Full Code Here

        if (d == null) return null;

        Line.Part lp = (Line.Part) getAttachedAnnotatable();
        if (lp != null) {
            Line line = lp.getLine ();
            DataObject dob = DataEditorSupport.findDataObject(line);
            EditorCookie ec = (EditorCookie) dob.getCookie(EditorCookie.class);

            if (ec != null) { // Only for editable dataobjects
                try {
                    doc = ec.openDocument ();                   
                    RequestProcessor.getDefault().post(this);                   
View Full Code Here

        for (int i = 0; i < fileList.size(); i++) {
            String src = fileList.get(i).toString();
            String name = WizardUtils.fileName(src, this.safeName);           
            FileObject file = subFolder.createData(name);
            WizardUtils.generateFile(file, libraryPath, name, src, this.safeName, this.moduleName);
            DataObject dObj = DataObject.find(file);
            OpenCookie oc = (OpenCookie) dObj.getCookie(OpenCookie.class);
            if (oc != null) {
                oc.open();
            }
        }
        //(final FileObject file, String ver, String type, String ext, Object params)
View Full Code Here

            if (url.startsWith("file:/")) {
                String fileName = url.substring(url.indexOf(":")+1, url.lastIndexOf(":"));
                String lineNumber = url.substring(url.lastIndexOf(":") + 1);
                File f = new File(fileName);
                FileObject fobj = FileUtil.toFileObject(f);
                DataObject dobj = null;
               
                try {
                    dobj = DataObject.find(fobj);
                } catch (DataObjectNotFoundException ex) {
                    ex.printStackTrace();
                }
                if (dobj != null) {
                    LineCookie lc = (LineCookie) dobj.getCookie(LineCookie.class);
                    if (lc != null) {
                        Line l = lc.getLineSet().getOriginal(Integer.parseInt(lineNumber));
                        l.show(Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
                    }
View Full Code Here

        for (int i = 0; i < fileList.size(); i++) {
            String src = fileList.get(i).toString();
            String name = WizardUtils.fileName(src, this.safeName);
            FileObject file = subFolder.createData(name);
            WizardUtils.generateFile(file, libraryPath, name, src, this.safeName, this.moduleName);
            DataObject dObj = DataObject.find(file);
            OpenCookie oc = (OpenCookie) dObj.getCookie(OpenCookie.class);
            if (oc != null) {
                oc.open();
            }
        }
        //(final FileObject file, String ver, String type, String ext, Object params)
View Full Code Here

      FileObject foTemplatesDir = FileUtil.toFileObject(templatesDir);
            DataFolder templatesDf = DataFolder.findFolder(foTemplatesDir);

      try {
        FileObject latteTemplate = FileUtil.getConfigFile("Templates/Nette Framework/LatteTemplate.latte");
        DataObject latteDTemplate = DataObject.find(latteTemplate);

        ActionRenderTemplateChecker artc = new ActionRenderTemplateChecker(presenterName, templatesDirectory);

        for (Object wholeAction : actions) {
          HashMap<String, Object> action = (HashMap<String, Object>) wholeAction;

          boolean generateTemplate = (Boolean) action.get("template");

          String actionName = (String) action.get("name");

          if (generateTemplate && !artc.existsActionTemplate(actionName)) {
            latteDTemplate.createFromTemplate(templatesDf, latteTemplatePrefix + EditorUtils.firstLetterSmall(actionName));
          }
        }
      } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
      }
View Full Code Here

        NettePreferences.setParentPresenter(PhpModule.inferPhpModule(), parentPresenter);
        NettePreferences.setGenerateStartup(PhpModule.inferPhpModule(), generateStartup);

        FileObject template = Templates.getTemplate(wizard);
        DataObject dTemplate = DataObject.find(template);
        DataObject dobj = dTemplate.createFromTemplate(df, targetName, hashMap);

    ActionRenderTemplatesGenerator atg = new ActionRenderTemplatesGenerator();
    atg.generate(actions, targetName, (String) wizard.getProperty("templatesDirectory"), (Boolean) wizard.getProperty("dottedNotation"));

        FileObject createdFile = dobj.getPrimaryFile();

        return Collections.singleton(createdFile);
    }
View Full Code Here

TOP

Related Classes of org.openide.loaders.DataObject

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.