Package aQute.bnd.properties

Examples of aQute.bnd.properties.Document


     * @throws CoreException
     */
    protected void processGeneratedProject(ProjectPaths projectPaths, BndEditModel bndModel, IJavaProject project, IProgressMonitor monitor) throws CoreException {
        SubMonitor progress = SubMonitor.convert(monitor, 3);

        Document document = new Document("");
        bndModel.saveChangesTo(document);
        progress.worked(1);

        ByteArrayInputStream bndInput;
        try {
            bndInput = new ByteArrayInputStream(document.get().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            return;
        }
        IFile bndBndFile = project.getProject().getFile(Project.BNDFILE);
        if (bndBndFile.exists()) {
View Full Code Here


        BndEditModel newBundleModel = new BndEditModel();

        // Load project file and model
        IFile projectFile = container.getProject().getFile(Project.BNDFILE);
        BndEditModel projectModel;
        final Document projectDocument;
        try {
            if (projectFile.exists()) {
                byte[] bytes = FileUtils.readFully(projectFile.getContents());
                projectDocument = new Document(new String(bytes, projectFile.getCharset()));
            } else {
                projectDocument = new Document("");
            }
            projectModel = new BndEditModel();
            projectModel.loadFrom(projectDocument);
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, e.getMessage(), e));
        }

        // Check if we need to enable sub-bundles on the project file
        boolean enableSubs;
        List<String> subBndFiles = projectModel.getSubBndFiles();
        List<String> availableHeaders = calculateProjectOnlyHeaders(projectModel.getAllPropertyNames());
        Collection<String> bundleSpecificHeaders = calculateBundleSpecificHeaders(availableHeaders);

        if (subBndFiles == null || subBndFiles.isEmpty()) {
            final EnableSubBundlesDialog subBundlesDialog = new EnableSubBundlesDialog(parentShell, availableHeaders, bundleSpecificHeaders);

            if (subBundlesDialog.open() != Window.OK) {
                monitor.setCanceled(true);
                return;
            }

            enableSubs = subBundlesDialog.isEnableSubBundles();
            bundleSpecificHeaders = subBundlesDialog.getSelectedProperties();
        } else {
            enableSubs = false;
        }

        // Enable subs and copy entries from project model to new bundle model
        if (enableSubs) {
            projectModel.setSubBndFiles(Arrays.asList(new String[] {
                "*.bnd"
            }));
            for (String propertyName : bundleSpecificHeaders) {
                Object value = projectModel.genericGet(propertyName);
                projectModel.genericSet(propertyName, null);
                newBundleModel.genericSet(propertyName, value);
            }

            // Save the project model
            projectModel.saveChangesTo(projectDocument);
            FileUtils.writeFully(projectDocument.get(), projectFile, false);
        }

        // Generate the new bundle model
        Document newBundleDocument = new Document("");
        newBundleModel.saveChangesTo(newBundleDocument);

        try {
            newBundleInputStream = new ByteArrayInputStream(newBundleDocument.get().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            newBundleInputStream = null;
        }
    }
View Full Code Here

     * @throws CoreException
     */
    protected void processGeneratedProject(ProjectPaths projectPaths, BndEditModel bndModel, IJavaProject project, IProgressMonitor monitor) throws CoreException {
        SubMonitor progress = SubMonitor.convert(monitor, 3);

        Document document = new Document("");
        bndModel.saveChangesTo(document);
        progress.worked(1);

        ByteArrayInputStream bndInput;
        try {
            bndInput = new ByteArrayInputStream(document.get().getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            return;
        }
        IFile bndBndFile = project.getProject().getFile(Project.BNDFILE);
        if (bndBndFile.exists()) {
View Full Code Here

                file = context.getProject().getPropertiesFile();
                properties = context.getProject().getProperties();
            }
            final IFile resource = (IFile) ReleaseUtils.toResource(file);

            final Document document;
            if (resource.exists()) {
                byte[] bytes = readFully(resource.getContents());
                document = new Document(new String(bytes, resource.getCharset()));
            } else {
                document = new Document(""); //$NON-NLS-1$
            }

            final BndEditModel model = new BndEditModel();
            model.loadFrom(document);

            String currentVersion = model.getBundleVersionString();
            String templateVersion = updateTemplateVersion(currentVersion, bundleVersion);
            model.setBundleVersion(templateVersion);
            properties.setProperty(Constants.BUNDLE_VERSION, templateVersion);

            final Document finalDoc = document;
            Runnable run = new Runnable() {
                public void run() {
                    model.saveChangesTo(finalDoc);

                    try {
                        writeFully(finalDoc.get(), resource, false);
                        resource.refreshLocal(IResource.DEPTH_ZERO, null);
                    } catch (CoreException e) {
                        throw new RuntimeException(e);
                    }
                }
View Full Code Here

        file = context.getProject().getPropertiesFile();
        properties = context.getProject().getProperties();
      }
      final IFile resource = (IFile) ReleaseUtils.toResource(file);

      final Document document;
      if (resource.exists()) {
        byte[] bytes = readFully(resource.getContents());
        document = new Document(new String(bytes, resource.getCharset()));
      } else {
        document = new Document(""); //$NON-NLS-1$
      }

      final BndEditModel model = new BndEditModel();
      model.loadFrom(document);

      String currentVersion = model.getBundleVersionString();
      String templateVersion = updateTemplateVersion(currentVersion, bundleVersion);
      model.setBundleVersion(templateVersion);
      properties.setProperty(Constants.BUNDLE_VERSION, templateVersion);

      final Document finalDoc = document;
      Runnable run = new Runnable() {
        public void run() {
          model.saveChangesTo(finalDoc);

          try {
            writeFully(finalDoc.get(), resource, false);
            resource.refreshLocal(IResource.DEPTH_ZERO, null);
          } catch (CoreException e) {
            throw new RuntimeException(e);
          }
        }
View Full Code Here

TOP

Related Classes of aQute.bnd.properties.Document

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.