Example usage for org.eclipse.jdt.core IJavaProject getRawClasspath

List of usage examples for org.eclipse.jdt.core IJavaProject getRawClasspath

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaProject getRawClasspath.

Prototype

IClasspathEntry[] getRawClasspath() throws JavaModelException;

Source Link

Document

Returns the raw classpath for the project, as a list of classpath entries.

Usage

From source file:com.microsoft.azure.hdinsight.projects.CreateProjectUtil.java

License:Open Source License

private static void createResourceStructForLocalRunScalaProject(IFolder sourceRootFolder, String rootPath,
        IProject project) throws CoreException {
    copyFileTo(Scala_Local_Run_Sample, rootPath);
    final IFolder dataFolder = sourceRootFolder.getParent().getFolder(new Path("data"));
    if (!dataFolder.exists()) {
        dataFolder.create(false, true, null);
    }//from  w  w w  . j av a2 s .c o m
    copyFileTo(Scala_Local_Run_Sample_Data, dataFolder.getLocation().toFile().getAbsolutePath());

    IJavaProject javaProject = JavaCore.create(project);
    IClasspathEntry[] entries = javaProject.getRawClasspath();

    IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
    System.arraycopy(entries, 0, newEntries, 0, entries.length);

    IPath dataPath = javaProject.getPath().append("data");
    IClasspathEntry dataEntry = JavaCore.newSourceEntry(dataPath, null);

    newEntries[entries.length] = JavaCore.newSourceEntry(dataEntry.getPath());
    javaProject.setRawClasspath(newEntries, null);
}

From source file:com.microsoft.azuretools.wasdkjava.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method creates Include in the project deployment assembly
 * check box./*w ww .  j a  va2s. com*/
 * @param container
 */
private void createDepCheckBox(Composite container) {
    boolean containerIdPresent = false;
    depCheck = new Button(container, SWT.CHECK);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalIndent = 10;
    gridData.verticalIndent = 10;
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = SWT.FILL;
    depCheck.setText(Messages.depChkBox);
    depCheck.setLayoutData(gridData);
    if (isEdit()) {
        // Edit library scenario
        try {
            IJavaProject proj1 = JavaCore.create(getSelectedProject());
            // Iterate over class path entries.
            for (int i = 0; i < proj1.getRawClasspath().length; i++) {
                /*
                 * check if class path contains
                 * our library's container Id
                 * If contains then it's not
                 * a case of immediate edit
                 */
                if (proj1.getRawClasspath()[i].toString().contains(Messages.containerID)) {
                    containerIdPresent = true;
                    for (int j = 0; j < proj1.getRawClasspath()[i].getExtraAttributes().length; j++) {
                        if (proj1.getRawClasspath()[i].getExtraAttributes()[j].getName()
                                .equalsIgnoreCase(Messages.jstDep)) {
                            depCheck.setSelection(true);
                            break;
                        }
                        depCheck.setSelection(false);
                    }
                    if (proj1.getRawClasspath()[i].getExtraAttributes().length == 0) {
                        depCheck.setSelection(false);
                    }
                }
            }
            /*
             * If contains then it's not a case of immediate edit
             * retrieve state of deployment assembly check box
             * which was saved when user clicks on Finish button.
             */
            if (!containerIdPresent) {
                depCheck.setSelection(Activator.geteploymentAssemblyState());
            }
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }

    } else {
        // Add library scenario
        depCheck.setSelection(true);
    }
}

From source file:com.microsoft.azuretools.wasdkjava.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method adds entries into .classpath file.
 *///from  w w w  .  j a  v a2  s.  c o m
private void configureClasspathEntries() {
    IJavaProject proj1 = JavaCore.create(getSelectedProject());
    IClasspathEntry[] entries;
    try {
        entries = proj1.getRawClasspath();
        IClasspathEntry[] newentries = new IClasspathEntry[entries.length];

        for (int i = 0; i < entries.length; i++) {
            if (entries[i].toString().contains(Messages.containerID)) {
                if (depCheck.getSelection()) {
                    IClasspathAttribute[] attr = new IClasspathAttribute[1];
                    attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
                    newentries[i] = JavaCore.newContainerEntry(entry, null, attr, true);
                } else {
                    newentries[i] = JavaCore.newContainerEntry(entry);
                }
            } else {
                newentries[i] = entries[i];
            }
        }
        proj1.setRawClasspath(newentries, null);
    } catch (Exception e) {
        Activator.getDefault().log(e.getMessage(), e);
    }
}

From source file:com.microsoft.sqljdbc4.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method creates Include in the project deployment assembly
 * check box.// ww w .j  a  v  a2 s .co m
 * @param container
 */
private void createDepCheckBox(Composite container) {
    boolean containerIdPresent = false;
    depCheck = new Button(container, SWT.CHECK);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalIndent = 10;
    gridData.verticalIndent = 10;
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = SWT.FILL;
    depCheck.setText(Messages.depChkBox);
    depCheck.setLayoutData(gridData);
    if (isEdit()) {
        // Edit library scenario
        try {
            IJavaProject proj1 = JavaCore.create(getSelectedProject());
            // Iterate over class path entries.
            for (int i = 0; i < proj1.getRawClasspath().length; i++) {
                /*
                 * check if class path contains
                 * our library's container Id
                 * If contains then it's not
                 * a case of immediate edit
                 */
                if (proj1.getRawClasspath()[i].toString().contains(Messages.sdkContainer)) {
                    containerIdPresent = true;
                    for (int j = 0; j < proj1.getRawClasspath()[i].getExtraAttributes().length; j++) {
                        if (proj1.getRawClasspath()[i].getExtraAttributes()[j].getName()
                                .equalsIgnoreCase(Messages.jstDep)) {
                            depCheck.setSelection(true);
                            break;
                        }
                        depCheck.setSelection(false);
                    }
                    if (proj1.getRawClasspath()[i].getExtraAttributes().length == 0) {
                        depCheck.setSelection(false);
                    }
                }
            }
            /*
             * If contains then it's not a case of immediate edit
             * retrieve state of deployment assembly check box
             * which was saved when user clicks on Finish button.
             */
            if (!containerIdPresent) {
                depCheck.setSelection(Activator.geteploymentAssemblyState());
            }
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }

    } else {
        // Add library scenario
        depCheck.setSelection(true);
    }
}

From source file:com.microsoft.sqljdbc4.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method adds entries into .classpath file.
 *///from  w w w.j a  v  a  2 s  . com
private void configureClasspathEntries() {
    IJavaProject proj1 = JavaCore.create(getSelectedProject());
    IClasspathEntry[] entries;
    try {
        entries = proj1.getRawClasspath();
        IClasspathEntry[] newentries = new IClasspathEntry[entries.length];

        for (int i = 0; i < entries.length; i++) {
            if (entries[i].toString().contains(Messages.sdkContainer)) {
                if (depCheck.getSelection()) {
                    IClasspathAttribute[] attr = new IClasspathAttribute[1];
                    attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
                    newentries[i] = JavaCore.newContainerEntry(entry, null, attr, true);

                } else {
                    newentries[i] = JavaCore.newContainerEntry(entry);
                }
            } else {
                newentries[i] = entries[i];
            }
        }
        proj1.setRawClasspath(newentries, null);
    } catch (Exception e) {
        Activator.getDefault().log(e.getMessage(), e);
    }
}

From source file:com.microsoftopentechnologies.acsfilter.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Draws controls for page./* www  .j  ava  2s.  c  o m*/
 *
 * @param parent.
 */
@Override
public void createControl(Composite parent) {
    boolean containerIdPresent = false;
    GridLayout gridLayout = new GridLayout();
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(gridLayout);
    container.setLayoutData(gridData);

    // display help contents
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
            "com.microsoftopentechnologies.acsfilter.ui." + "acs_config_dialog");

    gridLayout = new GridLayout();
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    gridLayout.numColumns = 2;
    Composite verContainer = new Composite(container, SWT.NONE);
    verContainer.setLayout(gridLayout);
    verContainer.setLayoutData(gridData);

    //Label for version
    Label lblVersion = new Label(verContainer, SWT.LEFT);
    gridData = new GridData();
    lblVersion.setText(Messages.lblVersion);
    lblVersion.setLayoutData(gridData);

    //Combo to hold the versions
    combo = new Combo(verContainer, SWT.READ_ONLY | SWT.LEFT);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalIndent = 10;
    gridData.horizontalAlignment = SWT.FILL;
    combo.setLayoutData(gridData);
    combo.addSelectionListener(new ComboSelectionListener());
    //get bundles for the sdk
    Bundle[] bundles = Platform.getBundles(Messages.sdkID, null);
    if (bundles == null || bundles.length == 0) {
        //if bundles is null set an error msg
        setErrorMessage(Messages.libNotAvail);
        finishVal = false;
    } else {
        try {
            //populate the combo box with available versions of sdk
            populateComboBox(bundles);
            Bundle bundle = bundles[combo.getSelectionIndex()];

            if (bundle == null) {
                finishVal = false;
                //if bundle is null set an error msg
                setErrorMessage(Messages.verNotAvail);
            } else {
                //locate sdk jar in bundle
                URL url = FileLocator.find(bundle, new Path(Messages.sdkJar), null);
                if (url == null) {
                    finishVal = false;
                    setErrorMessage(Messages.verNotAvail);
                } else {
                    //if jar is found then resolve url and get the location
                    url = FileLocator.resolve(url);
                    File loc = new File(url.getPath());
                    libLocation = loc.getAbsolutePath();
                }
            }
        } catch (Exception e) {
            //if exception is thrown set an error msg.
            setErrorMessage(Messages.verNotAvail);
            finishVal = false;
        }
    }
    //label for location
    lblLoc = new Label(verContainer, SWT.LEFT);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;

    lblLoc.setLayoutData(gridData);
    lblLoc.setText(Messages.lblLocation);
    //label to hold the sdk jar path
    location = new Label(verContainer, SWT.WRAP | SWT.LEFT);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalIndent = 10;
    gridData.widthHint = 400;
    gridData.horizontalAlignment = SWT.FILL;

    location.setLayoutData(gridData);
    location.setText(libLocation);

    createDepCheckBox(container);
    createACSComponent(container);
    createRealmComponent(container);
    createCertComponent(container);
    //Disabling the control if selected project is not dynamic web project.
    try {
        IProject proj = ACSFilterUtil.getSelectedProject();
        if (!(proj.hasNature(Messages.emfNtr) && proj.hasNature(Messages.mdlCrNtr)
                && proj.hasNature(Messages.fctNtr) && proj.hasNature(Messages.javaNtr)
                && proj.hasNature(Messages.jsNtr))) {
            setErrorMessage(Messages.acsInvProjMsg);
            disableAll();
            setPageComplete(false);
        } else {
            if (proj.hasNature(Messages.natMaven)) {
                xmlPath = Messages.webxmlPathMaven;
                depDirLoc = Messages.depDirLocMaven;
                certificateLocation = Messages.depDirLocMaven;
            } else {
                xmlPath = Messages.xmlPath;
                depDirLoc = Messages.depDirLoc;
                certificateLocation = Messages.depDirLoc;
            }
        }
    } catch (CoreException e) {
        finishVal = false;
        setErrorMessage(Messages.acsInvProjMsg);
    }

    if (isEdit()) {
        // Edit library scenario
        try {
            IJavaProject proj1 = JavaCore.create(ACSFilterUtil.getSelectedProject());
            // Iterate over class path entries.
            for (int i = 0; i < proj1.getRawClasspath().length; i++) {
                /*
                 * check if class path contains
                 * our library's container Id
                 * If contains then it's not
                 * a case of immediate edit
                 */
                if (proj1.getRawClasspath()[i].toString().contains(Messages.sdkContainer)) {
                    containerIdPresent = true;
                    for (int j = 0; j < proj1.getRawClasspath()[i].getExtraAttributes().length; j++) {
                        if (proj1.getRawClasspath()[i].getExtraAttributes()[j].getName()
                                .equalsIgnoreCase(Messages.jstDep)) {
                            depCheck.setSelection(true);
                            break;
                        }
                        depCheck.setSelection(false);
                    }
                    if (proj1.getRawClasspath()[i].getExtraAttributes().length == 0) {
                        depCheck.setSelection(false);
                    }
                }
            }
            /*
             * If contains then it's not a case of immediate edit
             * retrieve state of deployment assembly check box
             * which was saved when user clicks on Finish button.
             */
            if (!containerIdPresent) {
                depCheck.setSelection(Activator.geteploymentAssemblyState());
            }
            ACSFilterHandler editHandler = new ACSFilterHandler(
                    ACSFilterUtil.getSelectedProject().getFile(xmlPath).getLocation().toOSString());
            paramMap = editHandler.getAcsFilterParams();
            acsTxt.setText(paramMap.get(Messages.acsAttr));
            relTxt.setText(paramMap.get(Messages.relAttr));
            if (paramMap.get(Messages.certAttr) != null) {
                certTxt.setText(paramMap.get(Messages.certAttr));
                certInfoTxt.setText(getCertInfo(certTxt.getText()));
            } else {
                certInfoTxt.setText(getEmbeddedCertInfo());
                embedCertCheck.setSelection(true);
            }

            requiresHttpsCheck.setSelection(!Boolean.valueOf(paramMap.get(Messages.allowHTTPAttr)));
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }
    } else {
        // Add library scenario
        depCheck.setSelection(true);
    }
    setControl(container);
}

From source file:com.microsoftopentechnologies.acsfilter.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method adds ACS filter and filter mapping tags in web.xml
 * and saves input values given on ACS library page.
 * In case of edit, populates previously set values.
 *///from w w  w  .  j av a 2  s  . c om
private void configureDeployment() {
    //edit library
    if (isEdit()) {
        IJavaProject proj1 = JavaCore.create(ACSFilterUtil.getSelectedProject());
        IClasspathEntry[] entries;
        try {
            entries = proj1.getRawClasspath();
            IClasspathEntry[] newentries = new IClasspathEntry[entries.length];

            for (int i = 0; i < entries.length; i++) {
                if (entries[i].toString().contains(Messages.sdkContainer)) {
                    if (depCheck.getSelection()) {
                        IClasspathAttribute[] attr = new IClasspathAttribute[1];
                        attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
                        newentries[i] = JavaCore.newContainerEntry(entry, null, attr, true);
                    } else {
                        newentries[i] = JavaCore.newContainerEntry(entry);
                    }
                } else {
                    newentries[i] = entries[i];
                }
            }
            proj1.setRawClasspath(newentries, null);
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }
    }

    ACSFilterHandler handler = null;
    try {
        IProject proj = ACSFilterUtil.getSelectedProject();
        if (proj.getFile(xmlPath).exists()) {
            handler = new ACSFilterHandler(proj.getFile(xmlPath).getLocation().toOSString());
            handler.setAcsFilterParams(Messages.acsAttr, acsTxt.getText());
            handler.setAcsFilterParams(Messages.relAttr, relTxt.getText());
            if (!embedCertCheck.getSelection()) {
                handler.setAcsFilterParams(Messages.certAttr, certTxt.getText());
                if (getEmbeddedCertInfo() != null)
                    removeEmbedCert(ACSFilterUtil.getSelectedProject());
            } else {
                handler.removeParamsIfExists(Messages.certAttr);
                if (!certTxt.getText().isEmpty()) {
                    String srcLoc = ACSFilterUtil.getSelectedProject().getFolder(certificateLocation)
                            .getLocation().toOSString();
                    String certLoc = String.format("%s%s%s", srcLoc, File.separator, Messages.acsCertLoc);
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
            }
            handler.setAcsFilterParams(Messages.secretKeyAttr, generateKey());
            handler.setAcsFilterParams(Messages.allowHTTPAttr,
                    requiresHttpsCheck.getSelection() ? "false" : "true");
        } else {
            boolean choice = MessageDialog.openQuestion(this.getShell(), Messages.depDescTtl,
                    Messages.depDescMsg);
            if (choice) {
                String path = createWebXml(depDirLoc);
                //copy cert into WEB-INF/cert/_acs_signing.cer location if embed cert is selected 
                if (embedCertCheck.getSelection()) {
                    String srcLoc = ACSFilterUtil.getSelectedProject().getFolder(certificateLocation)
                            .getLocation().toOSString();
                    String certLoc = String.format("%s%s%s", srcLoc, File.separator, Messages.acsCertLoc);
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
                handler = new ACSFilterHandler(path);
                handler.setAcsFilterParams(Messages.acsAttr, acsTxt.getText());
                handler.setAcsFilterParams(Messages.relAttr, relTxt.getText());
                if (!embedCertCheck.getSelection()) { //Donot make entry if embed cert is selected
                    handler.setAcsFilterParams(Messages.certAttr, certTxt.getText());
                    if (getEmbeddedCertInfo() != null)
                        removeEmbedCert(ACSFilterUtil.getSelectedProject());
                }
                handler.setAcsFilterParams(Messages.secretKeyAttr, generateKey());
                handler.setAcsFilterParams(Messages.allowHTTPAttr,
                        requiresHttpsCheck.getSelection() ? "false" : "true");
            } else {
                finishVal = true;
                return;
            }
        }
    } catch (Exception e) {
        MessageDialog.openError(this.getShell(), Messages.acsErrTtl, Messages.acsErrMsg);
        finishVal = false;
        Activator.getDefault().log(e.getMessage(), e);
    }
    try {
        handler.save();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot root = workspace.getRoot();
        root.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (Exception e) {
        Activator.getDefault().log(e.getMessage(), e);
        MessageDialog.openError(this.getShell(), Messages.acsErrTtl, Messages.saveErrMsg);
        finishVal = false;
    }
}

From source file:com.microsoftopentechnologies.waqpidjava.ui.classpath.ClasspathContainerPage.java

License:Open Source License

/**
 * Method creates Include in the project deployment assembly
 * check box./*from  ww w.  java 2  s . com*/
 * @param container
 */
private void createDepCheckBox(Composite container) {
    boolean containerIdPresent = false;
    depCheck = new Button(container, SWT.CHECK);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalIndent = 10;
    gridData.verticalIndent = 10;
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = SWT.FILL;
    depCheck.setText(Messages.depChkBox);
    depCheck.setLayoutData(gridData);
    if (isEdit()) {
        // Edit library scenario
        try {
            IJavaProject proj1 = JavaCore.create(getSelectedProject());
            // Iterate over class path entries.
            for (int i = 0; i < proj1.getRawClasspath().length; i++) {
                /*
                 * check if class path contains
                 * our library's container Id
                 * If contains then it's not
                 * a case of immediate edit
                 */
                if (proj1.getRawClasspath()[i].toString().contains(Messages.containerID)) {
                    containerIdPresent = true;
                    for (int j = 0; j < proj1.getRawClasspath()[i].getExtraAttributes().length; j++) {
                        if (proj1.getRawClasspath()[i].getExtraAttributes()[j].getName()
                                .equalsIgnoreCase(Messages.jstDep)) {
                            depCheck.setSelection(true);
                            break;
                        }
                        depCheck.setSelection(false);
                    }
                    if (proj1.getRawClasspath()[i].getExtraAttributes().length == 0) {
                        depCheck.setSelection(false);
                    }
                }
            }
            /*
             * If contains then it's not a case of immediate edit
             * retrieve state of deployment assembly check box
             * which was saved when user clicks on Finish button.
             */
            if (!containerIdPresent) {
                depCheck.setSelection(Activator.geteploymentAssemblyState());
            }
        } catch (Exception e) {
            Activator.getDefault().log(e.getMessage(), e);
        }
    } else {
        // Add library scenario
        depCheck.setSelection(true);
    }
}

From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * This method adds a list of paths to all projects classpaths settings.
 * @param javaProjects List of projects that will have the classpath changed
 * @param libsPaths List of lib paths to be added to Projects' classpaths
 * @param monitor Monitor to track progress or null if it's not necessary.
 * @return IStatus The status of the operation. This method stops processing at the first error found.
 *//*from w  w  w  .  ja v a  2s .com*/
public static IStatus addLibsToProjects(List<IJavaProject> javaProjects, List<IPath> libsPaths,
        IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
    subMonitor.beginTask(UtilitiesNLS.ProjectUtils_AddLibsProgress_ConfiguringClassPaths,
            ((javaProjects.size() * 2) + libsPaths.size()) * 1000);
    IStatus status = Status.OK_STATUS;
    IClasspathEntry[] classPathEntries = new IClasspathEntry[libsPaths.size()];
    int i = 0;
    subMonitor.subTask(UtilitiesNLS.ProjectUtils_AddLibsProgress_PreparingPaths);
    for (IPath libPath : libsPaths) {
        IClasspathEntry classpathEntry = JavaCore.newLibraryEntry(libPath, null, null);
        classPathEntries[i] = classpathEntry;
        i++;
        subMonitor.worked(1000);
    }

    subMonitor.subTask(UtilitiesNLS.ProjectUtils_AddLibsProgress_ConfiguringProjects);
    for (IJavaProject javaProject : javaProjects) {
        IClasspathEntry[] rawClasspath;
        try {
            rawClasspath = javaProject.getRawClasspath();
            int length = rawClasspath.length;
            int newEntriesLength = classPathEntries.length;
            int newLenght = length + newEntriesLength;
            IClasspathEntry[] newClassPath = new IClasspathEntry[newLenght];

            System.arraycopy(rawClasspath, 0, newClassPath, 0, length); //Copy the existent classPath to the new array.
            System.arraycopy(classPathEntries, 0, newClassPath, length, newEntriesLength); //Copy the new entries to the new array
            subMonitor.worked(1000);
            javaProject.setRawClasspath(newClassPath, subMonitor.newChild(1000)); // Set the Project's classpath.
        } catch (JavaModelException e) {
            status = new Status(IStatus.ERROR, CommonPlugin.PLUGIN_ID,
                    UtilitiesNLS.ProjectUtils_AddLibsProgress_ErrorSettingClasspaths, e);
            break;
        }
    }
    subMonitor.done();
    return status;
}

From source file:com.motorola.studio.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Verifies if a given libPath is already available on the project classpath.
 * @param javaProject //from   w ww .  j  a  v  a2 s.c  om
 * @param libPath
 * @return true if present, false otherwise
 */
public static boolean isLibOnClasspath(IJavaProject javaProject, IPath libPath) {
    try {
        IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
        for (IClasspathEntry classpathEntry : rawClasspath) {
            if (classpathEntry.getPath().equals(libPath)) {
                return true;
            }
        }
    } catch (JavaModelException e) {
        return false;
    }
    return false;
}