Example usage for org.eclipse.jdt.internal.core JavaModelManager loadVariablesAndContainers

List of usage examples for org.eclipse.jdt.internal.core JavaModelManager loadVariablesAndContainers

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core JavaModelManager loadVariablesAndContainers.

Prototype

public void loadVariablesAndContainers() throws CoreException 

Source Link

Usage

From source file:es.bsc.servicess.ide.dialogs.JarFileDialog.java

License:Apache License

/** Method to update a dependency in the project
 * @param monitor Monitor to report the progress
 *//*from ww w . ja v a2  s . com*/
public void updateDeps(IProgressMonitor monitor) {
    try {
        /*
        IClasspathEntry ent = JavaCore.newLibraryEntry(new Path(path),
              null, null, true);
        if (ent != null) {*/
        IFile m_file = project.getProject().getFolder(ProjectMetadata.METADATA_FOLDER)
                .getFile(ProjectMetadata.METADATA_FILENAME);

        ProjectMetadata pr_meta = new ProjectMetadata(m_file.getRawLocation().toFile());
        if (libraryAdded) {
            log.debug("Library " + prev_jarLoc + " removed");
            pr_meta.removeDependency(prev_jarLoc);
        }
        if (!pr_meta.existsDependency(path, sType)) {
            pr_meta.addDependency(path, sType, imported);
            libraryAdded = true;
            log.debug("Library " + path + " Added");
        } else {
            log.debug("Library " + path + " already exists");
            libraryAdded = false;
        }
        pr_meta.toFile(m_file.getRawLocation().toFile());
        m_file.refreshLocal(1, monitor);
        JavaCore.getClasspathContainerInitializer("Dependencies")
                .initialize(new Path(ProjectMetadata.DEPENDENCY_ENTRYPATH), project);

        JavaModelManager manager = JavaModelManager.getJavaModelManager();
        manager.loadVariablesAndContainers();
        log.debug(" Updating ");
        project.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
        log.debug(" Dependency loaded");
        /*} else {
           ErrorDialog.openError(getShell(), "Error", "Updating libraries",
          new Status(IStatus.ERROR, Activator.PLUGIN_ID,
                "We can not create a library entry for " + path));
           path = null;
        }*/

    } catch (Exception e) {
        log.error("Exception found", e);
        ErrorDialog.openError(getShell(), "Error", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Exception when updating a dependency"));
        path = null;
    }
}

From source file:es.bsc.servicess.ide.wizards.coretypes.ExistingMethodSpecificTreatment.java

License:Apache License

public void updateDependency(String dir) {
    try {//w w  w .jav  a 2s  .c  o  m
        IClasspathEntry ent = JavaCore.newLibraryEntry(new Path(dir), null, null, true);
        if (ent != null) {
            IFile m_file = secondPage.getJavaProject().getProject().getFolder(ProjectMetadata.METADATA_FOLDER)
                    .getFile(ProjectMetadata.METADATA_FILENAME);
            ProjectMetadata pr_meta = new ProjectMetadata(m_file.getRawLocation().toFile());
            if (libraryAdded) {
                log.debug("Library " + prev_jarLoc + " removed");
                pr_meta.removeDependency(prev_jarLoc);
            }
            if (!pr_meta.existsDependency(dir, ProjectMetadata.JAR_DEP_TYPE)) {
                pr_meta.addDependency(dir, ProjectMetadata.JAR_DEP_TYPE);
                libraryAdded = true;
                log.debug("Library " + dir + " Added");
            } else {
                log.debug("Library " + dir + " already exists");
                libraryAdded = false;
            }
            pr_meta.toFile(m_file.getRawLocation().toFile());
            m_file.refreshLocal(1, null);
            JavaModelManager manager = JavaModelManager.getJavaModelManager();
            manager.loadVariablesAndContainers();
            log.debug(" Dependency loaded");
            libraryLocation.setText(dir);
            prev_jarLoc = dir;
        } else {
            MessageDialog.openError(shell, "Error updating libraries",
                    "We can not create a libray entry for " + dir);
        }

    } catch (Exception e) {
        MessageDialog.openError(shell, "Error updatin libraries", e.getMessage());
    }
}

From source file:es.bsc.servicess.ide.wizards.ServiceSsImportOrchestrationClassPage.java

License:Apache License

/** Method to update a dependency in the project
 * @param monitor Monitor to report the progress
 *///from ww w . ja  v a  2s  .  co  m
public void updateDeps(String prev_jarLoc, String path, String sType, IProgressMonitor monitor) {
    try {
        IFile m_file = project.getProject().getFolder(ProjectMetadata.METADATA_FOLDER)
                .getFile(ProjectMetadata.METADATA_FILENAME);

        ProjectMetadata pr_meta = new ProjectMetadata(m_file.getRawLocation().toFile());
        if (libraryAdded) {
            log.debug("Library " + prev_jarLoc + " removed");
            pr_meta.removeDependency(prev_jarLoc);
        }
        if (!pr_meta.existsDependency(path, sType)) {
            pr_meta.addDependency(path, sType);
            libraryAdded = true;
            log.debug("Library " + path + " Added");
        } else {
            log.debug("Library " + path + " already exists");
            libraryAdded = false;
        }
        pr_meta.toFile(m_file.getRawLocation().toFile());
        m_file.refreshLocal(1, monitor);
        JavaCore.getClasspathContainerInitializer("Dependencies")
                .initialize(new Path(ProjectMetadata.DEPENDENCY_ENTRYPATH), project);

        JavaModelManager manager = JavaModelManager.getJavaModelManager();
        manager.loadVariablesAndContainers();
        log.debug(" Updating ");
        project.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
        log.debug(" Dependency loaded");

    } catch (Exception e) {
        log.error("Exception found", e);
        ErrorDialog.openError(getShell(), "Error", e.getMessage(),
                new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Exception when updating a dependency"));
    }
}