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

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

Introduction

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

Prototype

IProject getProject();

Source Link

Document

Returns the IProject on which this IJavaProject was created.

Usage

From source file:com.google.gwt.eclipse.core.runtime.GWTRuntimeTest.java

License:Open Source License

private void checkSdkDetectionUsingRawClasspathEntries(IPath installPath)
        throws CoreException, JavaModelException {
    GWTRuntime sdk = GWTRuntime.getFactory().newInstance(getName(), installPath);
    IJavaProject javaProject = JavaProjectUtilities.createJavaProject(getName());
    try {//from w ww .ja  va 2  s. com
        for (IClasspathEntry entry : sdk.getClasspathEntries()) {
            JavaProjectUtilities.addRawClassPathEntry(javaProject, entry);
        }

        GWTRuntime detectedSdk = GWTRuntime.findSdkFor(javaProject);
        assertNotNull(detectedSdk);
        assertTrue(detectedSdk.validate().isOK());
    } finally {
        javaProject.getProject().delete(true, null);
    }
}

From source file:com.google.gwt.eclipse.core.uibinder.model.UiXmlReferencedFieldIndex.java

License:Open Source License

public void clear(IJavaProject javaProject) {
    synchronized (this) {
        for (IPath uiXmlPath : referencedFields.keys()) {
            IResource uiXmlResource = ResourcesPlugin.getWorkspace().getRoot().findMember(uiXmlPath);
            if (uiXmlResource != null) {
                if (uiXmlResource.getProject().equals(javaProject.getProject())) {
                    remove(uiXmlPath);//from www . j ava  2  s  .  c  o m
                }
            }
        }
    }
}

From source file:com.google.gwt.eclipse.core.validators.java.JavaCompilationParticipant.java

License:Open Source License

@Override
public void cleanStarting(IJavaProject project) {
    // Cancel the current validation job.
    synchronized (this) {
        Job buildJob = validationJobs.get(project.getProject());
        if (buildJob != null) {
            buildJob.cancel();// ww w .j  a  v a2s .  c o m
        }
    }

    cleanBuildArtifacts(project.getProject());
}

From source file:com.google.gwt.eclipse.core.validators.java.JavaCompilationParticipant.java

License:Open Source License

@Override
public boolean isActive(IJavaProject project) {
    boolean active = project.exists() && GWTNature.isGWTProject(project.getProject());
    return active;
}

From source file:com.google.gwt.eclipse.core.validators.rpc.RemoteServiceUtilities.java

License:Open Source License

/**
 * Returns <code>true</code> if the type is or extends the RemoteService 
 * interface.//from  ww w .ja v a  2 s . c  om
 */
public static boolean isSyncInterface(IType type) throws JavaModelException {
    IJavaProject javaProject = type.getJavaProject();
    if (!GWTNature.isGWTProject(javaProject.getProject())) {
        return false;
    }

    ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
    IType remoteServiceInterface = javaProject.findType(REMOTE_SERVICE_QUALIFIED_NAME);
    return remoteServiceInterface != null && hierarchy.contains(remoteServiceInterface);
}

From source file:com.google.gwt.eclipse.core.wizards.NewEntryPointWizardPage.java

License:Open Source License

@Override
protected IStatus containerChanged() {
    IStatus status = super.containerChanged();

    if (!status.isOK()) {
        moduleField.setGWTProject(null);

        if (status.getSeverity() == IStatus.ERROR) {
            return status;
        }/*ww  w.  j  a  v  a  2s .c  om*/

        /*
         * TODO: Right now, we assume that all WARNING statuses that are set by
         * NewContainerWizardPage are actually error conditions for us. This is
         * true, but to verify this, one has to look at the code. Ideally, we
         * would have ultimate control over the status levels that are set by the
         * NewContainerWizardPage, but there is no way to do that without
         * overriding the containerChanged() method and doing a lot of
         * copy-pasting. Really, it is not so bad to upgrade WARNINGS to ERRORS;
         * we are just being more conservative.
         */
        if (status.getSeverity() == IStatus.WARNING) {
            return Util.newErrorStatus(status.getMessage());
        }
    }

    IJavaProject javaProject = getJavaProject();
    if (JavaProjectUtilities.isJavaProjectNonNullAndExists(javaProject)
            && GWTNature.isGWTProject(javaProject.getProject())) {
        moduleField.setGWTProject(javaProject);
    } else {
        moduleField.setGWTProject(null);
        status = Util.newErrorStatus("The source folder does not belong to a GWT Project.");
    }

    return status;
}

From source file:com.google.gwt.eclipse.core.wizards.NewHostPageWizardPage.java

License:Open Source License

private IJavaProject chooseProject() {
    IJavaProject[] projects;/*from ww w.jav a 2 s . c  o  m*/
    try {
        projects = JavaCore.create(Util.getWorkspaceRoot()).getJavaProjects();
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
        projects = new IJavaProject[0];
    }

    // Filter the list to only show GWT projects
    List<IJavaProject> gwtProjects = new ArrayList<IJavaProject>();
    for (IJavaProject project : projects) {
        if (GWTNature.isGWTProject(project.getProject())) {
            gwtProjects.add(project);
        }
    }

    // TODO: refactor this into utility function
    ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
    dialog.setTitle("Project Selection");
    dialog.setMessage("Choose a project for the new HTML page");
    dialog.setElements(gwtProjects.toArray(new IJavaProject[0]));
    dialog.setInitialSelections(new Object[] { getJavaProject() });
    dialog.setHelpAvailable(false);
    if (dialog.open() == Window.OK) {
        return (IJavaProject) dialog.getFirstResult();
    }
    return null;
}

From source file:com.google.gwt.eclipse.core.wizards.NewModuleWizardPage.java

License:Open Source License

private void addCommonGWTModulesAsDefaultInherits() {

    IJavaProject javaProject = getJavaProject();

    assert (JavaProjectUtilities.isJavaProjectNonNullAndExists(javaProject)
            && GWTNature.isGWTProject(javaProject.getProject()));

    // Look for com.google.gwt.user.User module, and add it as a
    // default in the inherits list if available.

    /*//from  w ww.j a va 2  s .  co m
     * TODO: If the project has many jars, this lookup could be slow, thus
     * causing a delay when the dialog is rendered the first time. Look into the
     * possibility of being able to ask a project's GWT Runtime about its
     * available modules, as opposed to calling ModuleUtils.findModule, which
     * iterates through all of the project's package fragment roots.
     */
    if (javaProject.getResource().isAccessible()) {
        IModule gwtUserModule = ModuleUtils.findModule(javaProject, "com.google.gwt.user.User", true);
        if (gwtUserModule != null) {
            addModuleIfNotAlreadyInList(gwtUserModule);
        }
    }
}

From source file:com.google.gwt.eclipse.oophm.views.hierarchical.LaunchConfigurationContent.java

License:Open Source License

private IProject getProject(LaunchConfiguration launchConfig) {
    if (launchConfig == null) {
        return null;
    }/*from   w  ww  . ja v  a 2s  .com*/

    ILaunch launch = launchConfig.getLaunch();
    if (launch == null) {
        return null;
    }

    ILaunchConfiguration lc = launch.getLaunchConfiguration();
    if (lc == null) {
        return null;
    }

    IJavaProject project;
    try {
        project = JavaRuntime.getJavaProject(lc);
    } catch (CoreException e) {
        return null;
    }
    if (project == null) {
        return null;
    }

    return project.getProject();
}

From source file:com.google.inject.tools.ideplugin.eclipse.EclipseJavaProject.java

License:Apache License

private String getProjectOutputLocation(IJavaProject project) throws JavaModelException {
    IResource resource = project.getResource();
    String resourceLocation = resource.getLocation().toOSString();
    String projectLocation = project.getOutputLocation().makeRelative().toOSString();
    return projectLocation.replaceFirst(project.getProject().getName(), resourceLocation);
}