Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaProject


    private Button _exportButton;

    @Override
    protected Control createContents(Composite parent) {
        if (getElement() instanceof IJavaProject) {
            IJavaProject javaProject = (IJavaProject) getElement();
            _selectedProject = javaProject.getProject();
        }
        else if (getElement() instanceof IProject) {
            _selectedProject = (IProject) getElement();
        }
View Full Code Here


      // - third DefaultSourceContainer (jar files added to classpath will be added to source path)

 
      // First add all projects source containers
      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Add JavaProjectSourceContainer for " + project.getProject().getName() + "\n");
        sourceContainers.add(new JavaProjectSourceContainer(project));
      }

      // Adding packageFragmentRoot source containers, so classes in jar files associated to a project will be seen
      Set<IPath> external = new HashSet<IPath>();

      for (int i = 0; i < javaProjects.length; i++) {
        IJavaProject project = javaProjects[i];
        traceBuffer.append("  -> Compute SourceContainers for " + project.getProject().getName() + " :\n");

        IPackageFragmentRoot[] roots = project.getPackageFragmentRoots();
        for (int ri = 0; ri < roots.length; ri++) {
          IPackageFragmentRoot root = roots[ri];         
          if (root.isExternal()) {
            IPath location = root.getPath();
            if (external.contains(location)) {
View Full Code Here

     * Show a dialog that lets the user select a project. This in turn provides
     * context for the main type, allowing the user to key a main type name, or
     * constraining the search for main types to the specified project.
     */
    protected void handleProjectButtonSelected() {
        IJavaProject project = chooseJavaProject();
        if (project == null) { return; }

        String projectName = project.getElementName();
        fProjText.setText(projectName);
    }
View Full Code Here

        ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
        dialog.setTitle("Project Selection");
        dialog.setMessage("Choose a project to constrain the search for main types:");
        dialog.setElements(projects);

        IJavaProject javaProject = getJavaProject();
        if (javaProject != null) {
            dialog.setInitialSelections(new Object[] { javaProject});
        }
        if (dialog.open() == ElementListSelectionDialog.OK) { return (IJavaProject) dialog.getFirstResult(); }
        return null;
View Full Code Here

    /**
     * Show a dialog that lists all main types.
     */
    protected void handleSearchButtonSelected() {
        IJavaProject javaProject = getJavaProject();
        IJavaSearchScope searchScope = null;
        if ((javaProject == null) || !javaProject.exists()) {
            searchScope = SearchEngine.createWorkspaceScope();
        } else {
            searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject}, false);
        }

        int constraints = IJavaElementSearchConstants.CONSIDER_BINARIES;
        MainMethodSearchEngine engine = new MainMethodSearchEngine();
        IType[] types = null;
        try {
            types = engine.searchMainMethods(getLaunchConfigurationDialog(), searchScope, constraints);
        } catch (InvocationTargetException e) {
            setErrorMessage(e.getMessage());
            return;
        } catch (InterruptedException e) {
            setErrorMessage(e.getMessage());
            return;
        }

      
        SelectionDialog dialog;
    try {
      dialog = JavaUI.createTypeDialog(
          getShell(),
          getLaunchConfigurationDialog(),
          SearchEngine.createJavaSearchScope(types),
          IJavaElementSearchConstants.CONSIDER_CLASSES,
          false,
          "**");
    } catch (JavaModelException e) {
      setErrorMessage(e.getMessage());
            return;
    }
       
        dialog.setTitle("Choose Main Type");
        dialog.setMessage("Choose Main Type");
        if (dialog.open() == Window.CANCEL) { return; }

        Object[] results = dialog.getResult();
        if ((results == null) || (results.length < 1)) { return; }
        IType type = (IType) results[0];
        if (type != null) {
            fMainText.setText(type.getFullyQualifiedName());
            javaProject = type.getJavaProject();
            fProjText.setText(javaProject.getElementName());
        }
    }
View Full Code Here

     * @param active Active or testing aspect manager instance?
     * @param txId transaction identifier, or null if non-transacted
     * @throws CoreException
     */
    public void insertAspect(IType aspect, String address, boolean active, String txId) throws CoreException {
        IJavaProject project = aspect.getJavaProject();

        IVMInstall vmInstall = getVMInstall(project);
        if (vmInstall == null) return;
        IVMRunner vmRunner = vmInstall.getVMRunner(ILaunchManager.RUN_MODE);
        if (vmRunner == null) return;
View Full Code Here

            }
            IPackageFragmentRoot root = editor.getPackageFragmentRoot(editor.getClassFile());
            try {
                IClasspathEntry entry = root.getRawClasspathEntry();
                IPath containerPath = null;
                IJavaProject javaProject = root.getJavaProject();
                if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                    containerPath = entry.getPath();
                    IClasspathContainer container = JavaCore
                        .getClasspathContainer(containerPath, javaProject);
                    if(!isSourceAttachmentPossible(containerPath, javaProject)){
View Full Code Here

     * @param javaElt
     * @return true, if corresponding java project has compiler setting to generate
     * bytecode for jdk 1.5 and above
     */
    public static boolean is50OrHigher(IJavaElement javaElt) {
        IJavaProject project = javaElt.getJavaProject();
        String option = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
        boolean result = JavaCore.VERSION_1_5.equals(option);
        if(result){
            return result;
        }
        // probably > 1.5?
View Full Code Here

        String dir = ""; //$NON-NLS-1$
        if (javaElement == null) {
            return dir;
        }

        IJavaProject project = javaElement.getJavaProject();

        if (project == null) {
            return dir;
        }
        // default bytecode location
        IPath path = project.getOutputLocation();

        IResource resource = javaElement.getUnderlyingResource();
        if (resource == null) {
            return dir;
        }
        // resolve multiple output locations here
        if (project.exists() && project.getProject().isOpen()) {
            IClasspathEntry entries[] = project.getRawClasspath();
            for (int i = 0; i < entries.length; i++) {
                IClasspathEntry classpathEntry = entries[i];
                if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    IPath outputPath = classpathEntry.getOutputLocation();
                    if (outputPath != null
                        && classpathEntry.getPath().isPrefixOf(
                            resource.getFullPath())) {
                        path = outputPath;
                        break;
                    }
                }
            }
        }

        if (path == null) {
            // check the default location if not already included
            IPath def = project.getOutputLocation();
            if (def != null && def.isPrefixOf(resource.getFullPath())){
                path = def;
            }
        }

        if(path == null){
            return dir;
        }

        IWorkspace workspace = ResourcesPlugin.getWorkspace();

        if (!project.getPath().equals(path)) {
            IFolder outputFolder = workspace.getRoot().getFolder(path);
            if (outputFolder != null) {
                // linked resources will be resolved here!
                IPath rawPath = outputFolder.getRawLocation();
                if (rawPath != null) {
                    path = rawPath;
                }
            }
        } else {
            path = project.getProject().getLocation();
        }

        // here we should resolve path variables,
        // probably existing at first place of path
        IPathVariableManager pathManager = workspace.getPathVariableManager();
View Full Code Here

        }
        return null;
    }

    private static boolean isOnClasspath(IJavaElement javaElement) {
        IJavaProject project = javaElement.getJavaProject();
        if (project != null) {
            boolean result = project.isOnClasspath(javaElement);
            return result;
        }
        return false;
    }
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.