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

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

Introduction

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

Prototype

boolean exists();

Source Link

Document

Returns whether this Java element exists in the model.

Usage

From source file:com.google.gdt.eclipse.designer.core.util.UtilsTest.java

License:Open Source License

/**
 * Test for {@link Utils#getJavaProject(String)}.
 *//*from  w  w  w. j a  va2s  .c o m*/
public void test_getJavaProject() throws Exception {
    {
        IJavaProject javaProject = Utils.getJavaProject("TestProject");
        assertNotNull(javaProject);
        assertTrue(javaProject.exists());
    }
    {
        IJavaProject javaProject = Utils.getJavaProject("NoSuchProject");
        assertNotNull(javaProject);
        assertFalse(javaProject.exists());
    }
}

From source file:com.google.gdt.eclipse.designer.core.util.UtilsTest.java

License:Open Source License

/**
 * Test for {@link Utils#isGWTProject(IJavaProject)} and {@link Utils#isGWTProject(IProject)}.
 *//*from   ww w.java  2s  .  co  m*/
public void test_isGWTProject_noSuchProject() throws Exception {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("noSuchProject");
    IJavaProject javaProject = JavaCore.create(project);
    assertFalse(project.exists());
    assertFalse(javaProject.exists());
    assertFalse(Utils.isGWTProject(javaProject));
}

From source file:com.google.gdt.eclipse.designer.util.resources.DefaultResourcesProvider.java

License:Open Source License

/**
 * Appends source {@link IPackageFragmentRoot}'s, because {@link DefaultResourcesProvider} should
 * provide access not only to the binary resources (i.e. just resources in classpath), but also to
 * the source resources.//from  w  w w . ja v  a  2s .c o  m
 */
private static void addSourceFolders(Set<IProject> visitedProjects, List<String> entries, IProject project)
        throws Exception {
    // may be not exists
    if (!project.exists()) {
        return;
    }
    // may be already visited
    if (visitedProjects.contains(project)) {
        return;
    }
    visitedProjects.add(project);
    // add source folders for IJavaProject
    {
        IJavaProject javaProject = JavaCore.create(project);
        if (javaProject.exists()) {
            for (IPackageFragmentRoot packageFragmentRoot : javaProject.getPackageFragmentRoots()) {
                if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
                    entries.add(packageFragmentRoot.getResource().getLocation().toPortableString());
                }
            }
        }
    }
    // process required projects
    for (IProject referencedProject : project.getReferencedProjects()) {
        addSourceFolders(visitedProjects, entries, referencedProject);
    }
}

From source file:com.google.gdt.eclipse.suite.launch.processors.LaunchConfigAffectingChangesListener.java

License:Open Source License

public void launchConfigurationAdded(ILaunchConfiguration configuration) {
    try {/*w  w  w.  j a v a 2s.  co m*/
        String id = configuration.getType().getIdentifier();
        if (id == null || !LaunchConfigurationUpdater.APPLICABLE_LAUNCH_CONFIGURATION_TYPE_IDS.contains(id)) {
            return;
        }
    } catch (CoreException e) {
        // Could not get the type
        GdtPlugin.getLogger().logWarning(e,
                "Not updating launch configuration after possible SDK/classpath change due to failure fetching its type");
        return;
    }

    try {
        IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
        if (javaProject == null || !javaProject.exists()) {
            return;
        }

        /*
         * Assumes that we have a lock on the launch configuration itself; this
         * should be called in response to saving a launch config working copy. We
         * need to do this synchronously, otherwise there's a chance that the
         * launch config could actually execute before the updaters have a chance
         * to run.
         */
        syncUpdate(Collections.singletonList(new LaunchConfigurationUpdater(configuration, javaProject)));
    } catch (CoreException e) {
        GdtPlugin.getLogger().logError(e, "Could not update newly added launch configuration");
    }
}

From source file:com.google.gdt.eclipse.suite.launch.processors.LaunchConfigAffectingChangesListener.java

License:Open Source License

public void resourceChanged(IResourceChangeEvent event) {
    IResourceDelta rootDelta = event.getDelta();
    if (rootDelta == null) {
        return;/*from  w  ww.j av  a 2s .com*/
    }

    for (IResourceDelta delta : rootDelta.getAffectedChildren()) {
        // The description includes natures (see IProjectDescription)
        if (delta.getFlags() == IResourceDelta.DESCRIPTION) {
            IResource resource = delta.getResource();
            if (resource.getType() != IResource.PROJECT) {
                continue;
            }

            IJavaProject javaProject = JavaCore.create((IProject) resource);
            if (!javaProject.exists()) {
                continue;
            }

            updateLaunchConfigs(javaProject);
        }
    }
}

From source file:com.google.gdt.eclipse.suite.launch.processors.LaunchConfigAffectingChangesListener.java

License:Open Source License

public void updateLaunchConfigurations(IProject project) {
    IJavaProject javaProject = JavaCore.create(project);
    if (javaProject.exists()) {
        updateLaunchConfigs(javaProject);
    }//  w w  w.j  a v a  2 s .c  om
}

From source file:com.google.gdt.eclipse.suite.launch.ui.tabs.WebAppMainTab.java

License:Open Source License

/**
 * Get the LaunchConfigurator./*from   www  . j a  v a  2  s .c o m*/
 *
 * @param configuration
 * @return the launch configurator.
 * @throws CoreException
 */
private LaunchConfigurationUpdater getLaunchConfigurator(ILaunchConfiguration configuration)
        throws CoreException {
    IJavaProject javaProject = getJavaProject();
    if (javaProject == null || !javaProject.exists()) {
        return null;
    }

    if (launchConfigurator == null) {
        launchConfigurator = new LaunchConfigurationUpdater(configuration, javaProject);
    }
    return launchConfigurator;
}

From source file:com.google.gdt.eclipse.suite.launch.ui.WebAppMainTab.java

License:Open Source License

public void doPerformApply(ILaunchConfigurationWorkingCopy configuration) {
    super.performApply(configuration);

    // Link the launch configuration to the project. This will cause the
    // launch config to be deleted automatically if the project is deleted.
    IProject project = getProjectNamed(getEnteredProjectName());
    if (project != null) {
        configuration.setMappedResources(new IResource[] { project });
    }/*from   w w w. jav  a2  s. c  om*/

    IJavaProject javaProject = getJavaProject();
    if (javaProject != null && javaProject.exists()) {
        try {
            new LaunchConfigurationUpdater(configuration, javaProject).update();
        } catch (CoreException e) {
            CorePluginLog.logError(e, "Could not update arguments to reflect main tab changes");
        }
    }
}

From source file:com.google.gdt.eclipse.suite.update.builders.UpdateTriggerCompilationParticipant.java

License:Open Source License

@Override
public boolean isActive(IJavaProject project) {
    if (!project.exists()) {
        return false;
    }/*w  ww  .j  a  v a2s. c o  m*/

    if (GWTNature.isGWTProject(project.getProject())) {
        GdtExtPlugin.getFeatureUpdateManager().checkForUpdates();
        return true;
    } else {
        return false;
    }
}

From source file:com.google.gwt.eclipse.core.launch.ui.GWTSettingsTab.java

License:Open Source License

private IProject getProject() throws CoreException {
    IJavaProject javaProject = getJavaProject();
    if (javaProject == null || !javaProject.exists()) {
        throw new CoreException(
                new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not get a valid Java project"));
    }/*from  w ww. j a va 2s  . c  o m*/

    return javaProject.getProject();
}