Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaProject


    private class ActivatorClassProposalProvider extends CachingContentProposalProvider {
        @Override
        protected List<IContentProposal> doGenerateProposals(String contents, int position) {
            final String prefix = contents.substring(0, position);
            final IJavaProject javaProject = getJavaProject();
            if (javaProject == null)
                return Collections.emptyList();

            try {
                final List<IContentProposal> result = new ArrayList<IContentProposal>();

                final IRunnableWithProgress runnable = new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        try {
                            IType activatorType = javaProject.findType(BundleActivator.class.getName());
                            if (activatorType != null) {
                                ITypeHierarchy hierarchy = activatorType.newTypeHierarchy(javaProject, monitor);
                                for (IType subType : hierarchy.getAllSubtypes(activatorType)) {
                                    if (!Flags.isAbstract(subType.getFlags()) && subType.getElementName().toLowerCase().contains(prefix.toLowerCase())) {
                                        result.add(new JavaTypeContentProposal(subType));
View Full Code Here


        };
        IFormPage page = (IFormPage) getManagedForm().getContainer();
        IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();

        // Prepare the package lister from the Java project
        IJavaProject javaProject = getJavaProject();
        if (javaProject == null) {
            MessageDialog.openError(getSection().getShell(), "Error", "Cannot add packages: unable to find a Java project associated with the editor input.");
            return;
        }
        IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] {
View Full Code Here

    @Override
    public boolean performFinish() {
        boolean result = super.performFinish();
        if (result) {
            final IJavaProject javaProj = (IJavaProject) getCreatedElement();
            try {
                // Run using the progress bar from the wizard dialog
                getContainer().run(false, false, new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        try {
                            SubMonitor progress = SubMonitor.convert(monitor, 3);

                            // Generate the Bnd model
                            final BndEditModel bndModel = generateBndModel(progress.newChild(1));

                            // Make changes to the project
                            final IWorkspaceRunnable op = new IWorkspaceRunnable() {
                                @Override
                                public void run(IProgressMonitor monitor) throws CoreException {
                                    processGeneratedProject(ProjectPaths.get(pageOne.getProjectLayout()), bndModel, javaProj, monitor);
                                }
                            };
                            javaProj.getProject().getWorkspace().run(op, progress.newChild(2));
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                });
                result = true;
            } catch (InvocationTargetException e) {
                logger.logError("Could not initialise the project", e);
                ErrorDialog.openError(getShell(), "Error", "", new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error creating Bnd project descriptor file ({0}).", Project.BNDFILE), e.getTargetException()));
                result = false;
            } catch (InterruptedException e) {
                // Shouldn't happen
            }

            // Open the bnd.bnd file in the editor
            IFile bndFile = javaProj.getProject().getFile(Project.BNDFILE);
            try {
                IDE.openEditor(getWorkbench().getActiveWorkbenchWindow().getActivePage(), bndFile);
            } catch (PartInitException e) {
                ErrorDialog.openError(getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to open project descriptor file {0} in the editor.", bndFile.getFullPath().toString()), e));
            }
View Full Code Here

     * @param text to search for
     */
    protected void handleSearchPerformed(String text) {
        try {
            TextSearchQueryProvider queryProvider = TextSearchQueryProvider.getPreferred();
            IJavaProject currentJavaProject = theController.getCurrentProject();
            if (currentJavaProject == null) return;
           
            IResource currentProject = currentJavaProject.getResource();
            ISearchQuery query = queryProvider.createQuery(text, asArray(currentProject));
            NewSearchUI.runQueryInBackground(query);
            query.getSearchResult().addListener(resultListener);
        } catch (CoreException e) {
            Log.error(e);
View Full Code Here

   *
   * @param selection
   * @throws CoreException
   */
  private void selectionChanged(IStructuredSelection selection) throws CoreException {
    IJavaProject javaProject = null;
    Collection<ICompilationUnit> units = new HashSet<ICompilationUnit>();
    for (Object each: selection.toList()) {
      IJavaElement javaElement = Adaptables.adapt(each, IJavaElement.class);
      if (javaElement == null) continue;
      // we can't handle binaries as their project usually contains no sources and is not
      // visible in the navigation
      if (javaElement instanceof IMember){
          IMember member = (IMember) javaElement;
          if (member.isBinary()) return;
      }
     
      if (javaProject == null) {
        javaProject = javaElement.getJavaProject();
      }
      if (!javaProject.equals(javaElement.getJavaProject()) && javaElement.getJavaProject() != null) {
        multipleProjectsSelected();
        return;
      }
      if (javaElement instanceof ICompilationUnit) {
        units.add((ICompilationUnit) javaElement);
View Full Code Here

        final String[] natures = description.getNatureIds();
        final String[] newNatures = Arrays.copyOf(natures, natures.length + 1);
        newNatures[natures.length] = JavaCore.NATURE_ID;
        description.setNatureIds(newNatures);
        project.setDescription(description, null);
        final IJavaProject javaProject = JavaCore.create(project);
        @SuppressWarnings("rawtypes")
        final
        Map options = javaProject.getOptions(true);
        // Compliance level need to be 1.6
        JavaCore.setComplianceOptions(JavaCore.VERSION_1_6, options);
        javaProject.setOptions(options);
        javaProject.setRawClasspath(classPath, monitor);
        javaProject.setOutputLocation(javaProject.getPath().append("out"), monitor);
    }
View Full Code Here

        final String[] natures = description.getNatureIds();
        final String[] newNatures = Arrays.copyOf(natures, natures.length + 1);
        newNatures[natures.length] = JavaCore.NATURE_ID;
        description.setNatureIds(newNatures);
        project.setDescription(description, null);
        final IJavaProject javaProject = JavaCore.create(project);
        @SuppressWarnings("rawtypes")
        final Map options = javaProject.getOptions(true);
        // Compliance level need to be 1.6
        JavaCore.setComplianceOptions(JavaCore.VERSION_1_6, options);
        javaProject.setOptions(options);

        IClasspathEntry[] classPath = mangleClasspath(javaProject.getRawClasspath(), project,
                repoLink);
        javaProject.setRawClasspath(classPath, monitor);
        javaProject.setOutputLocation(javaProject.getPath().append("out"), monitor);
    }
View Full Code Here

   * longer require a framework for an application, as frameworks have been
   * replaced with buildpacks.
   */
  protected String getFramework(IProject project) {
    if (project != null) {
      IJavaProject javaProject = CloudFoundryProjectUtil.getJavaProject(project);
      if (javaProject != null) {
        if (CloudFoundryProjectUtil.hasNature(project, CloudFoundryConstants.GRAILS_NATURE)) {
          return CloudFoundryConstants.GRAILS;
        }

        // in case user has Grails projects without the nature
        // attached
        if (project.isAccessible() && project.getFolder("grails-app").exists() //$NON-NLS-1$
            && project.getFile("application.properties").exists()) { //$NON-NLS-1$
          return CloudFoundryConstants.GRAILS;
        }

        IClasspathEntry[] entries;
        boolean foundSpringLibrary = false;
        try {
          entries = javaProject.getRawClasspath();
          for (IClasspathEntry entry : entries) {
            if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
              if (isLiftLibrary(entry)) {
                return CloudFoundryConstants.LIFT;
              }
View Full Code Here

    if (projectName == null) {
      return null;
    }

    for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
      IJavaProject javaProject = JavaCore.create(project);
      if (javaProject != null && javaProject.isOpen() && ("".equals(projectName) || projectName.equals(javaProject.getElementName()))) { //$NON-NLS-1$
        entries.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject));
      }
    }

    IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( //
View Full Code Here

      }
    }

    if (packagedFile == null) {

      IJavaProject javaProject = CloudFoundryProjectUtil
          .getJavaProject(appModule);

      if (javaProject == null) {
        handleApplicationDeploymentFailure(Messages.JavaCloudFoundryArchiver_ERROR_NO_JAVA_PROJ_RESOLVED);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IJavaProject

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.