Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IPackageFragmentRoot


        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)) {
              continue;
            }
            external.add(location);
          }
          sourceContainers.add(new PackageFragmentRootSourceContainer(root));
          traceBuffer.append("     RootSourceContainer created for : " + root.getPath().toPortableString() + "\n");
        }
      }     
    }
   
    // Last add DefaultSourceContainer, classes in jar files added to classpath will be visible
View Full Code Here


      }
    } else {
      status.setWarning("The use of the default package is discouraged.");
    }

    IPackageFragmentRoot root = getPackageFragmentRoot();
    if (root != null) {
      if (root.getJavaProject().exists() && packName.length() > 0) {
        try {
          IPath rootPath = root.getPath();
          IPath outputPath = root.getJavaProject().getOutputLocation();
          if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
            // if the bin folder is inside of our root, don't allow
            // to name a package
            // like the bin folder
            IPath packagePath = rootPath.append(packName.replace('.', '/'));
            if (outputPath.isPrefixOf(packagePath)) {
              status.setError("Package clashes with project output folder.");
              return status;
            }
          }
        } catch (JavaModelException e) {
          JavaPlugin.log(e);
          // let pass
        }
      }

      fPackageFragment = root.getPackageFragment(packName);
    } else {
      status.setError(""); //$NON-NLS-1$
    }
    return status;
  }
View Full Code Here

  /**
   * @return Package selected by the user in a separate dialog
   */
  protected IPackageFragment choosePackage() {
    IPackageFragmentRoot froot = getPackageFragmentRoot();
    IJavaElement[] packages = null;
    try {
      if (froot != null && froot.exists()) {
        packages = froot.getChildren();
      }
    } catch (JavaModelException e) {
      JavaPlugin.log(e);
    }
    if (packages == null) {
View Full Code Here

    monitor.beginTask("Creating aspect...", 10);

    ICompilationUnit createdWorkingCopy = null;
    try {
      // Step 1: Process package fragment.
      IPackageFragmentRoot root = getPackageFragmentRoot();
      IPackageFragment pack = getPackageFragment();
      if (pack == null) {
        pack = root.getPackageFragment(""); //$NON-NLS-1$
      }
      if (!pack.exists()) {
        String packName = pack.getElementName();
        pack = root.createPackageFragment(packName, true, null);
      }
      monitor.worked(1);

      // Step 2: Create aspect if not already existent.
      boolean needsCommit = false;
View Full Code Here

        LayoutUtil.setWidthHint(text, convertWidthInCharsToPixels(40));
    }

    protected IStatus updateTargetClass() {
        StatusInfo status = new StatusInfo();
        IPackageFragmentRoot root = getMainPage().getPackageFragmentRoot();
        fTargetClassDialogField.enableButton(root != null);

        fTargetClass = null;

        String targetClassName = getTargetClassName();
        if (targetClassName.length() == 0) {
            // accept the empty field (stands for java.lang.Object)
            return status;
        }
        IStatus val = JavaConventions.validateJavaTypeName(targetClassName);
        if (val.getSeverity() == IStatus.ERROR) {
            status.setError("Target class name is not valid.");
            return status;
        }
        if (root != null) {
            try {
                IType type = resolveClassName(root.getJavaProject(), targetClassName);
                if (type == null) {
                    status.setWarning("Target class does not exist in current project.");
                    return status;
                }
                fTargetClass = type;
View Full Code Here

        }
        return status;
    }

    protected IType chooseTargetClass() {
        IPackageFragmentRoot root = getMainPage().getPackageFragmentRoot();
        if (root == null) { return null; }

        IJavaElement[] elements = new IJavaElement[] { root.getJavaProject() };
        IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);

        SelectionDialog dialog;
    try {
      dialog = JavaUI.createTypeDialog(
View Full Code Here

        source.append(" target");
    }

    protected IStatus updateTargetException() {
        StatusInfo status = new StatusInfo();
        IPackageFragmentRoot root = getMainPage().getPackageFragmentRoot();
        fTargetExceptionDialogField.enableButton(root != null);

        fTargetException = null;

        String targetClassName = getTargetExceptionName();
        if (targetClassName.length() == 0) {
            // accept the empty field (stands for java.lang.Object)
            return status;
        }
        IStatus val = JavaConventions.validateJavaTypeName(targetClassName);
        if (val.getSeverity() == IStatus.ERROR) {
            status.setError("Target exception name is not valid.");
            return status;
        }
        if (root != null) {
            try {
                IType type = resolveClassName(root.getJavaProject(), targetClassName);
                if (type == null) {
                    status.setWarning("Target exception does not exist in current project.");
                    return status;
                }
                // TODO Check if exception is subclass of Throwable
View Full Code Here

        return status;

    }

    protected IType chooseTargetException() {
        IPackageFragmentRoot root = getMainPage().getPackageFragmentRoot();
        if (root == null) {
            return null;
        }

        IJavaElement[] elements = new IJavaElement[] { root.getJavaProject()};
        IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
        // TODO Filter for subclasses of Throwable
       
        SelectionDialog dialog;
    try {
View Full Code Here

     */
    protected char[] findSource(IType type, IBinaryType info, IClassFile cf,
        BitSet decompilerFlags) {

        IPackageFragment pkgFrag = type.getPackageFragment();
        IPackageFragmentRoot root = (IPackageFragmentRoot) pkgFrag.getParent();
        String pkg = type.getPackageFragment().getElementName().replace(
            '.', '/');

        String classFile = new String(info.getFileName());
        int p = classFile.lastIndexOf('/');
        classFile = classFile.substring(p + 1);

        StringBuffer source = new StringBuffer();
        String location = null;
        String className = pkg + "/" + classFile;
        if (root.isArchive()) {
            location = getArchivePath(root);
            DecompiledClass decompiledClass = decompileFromArchive(
                source, location, className, decompilerFlags);
            classToDecompiled.put(cf, decompiledClass);
        } else {
            try {
                location = root.getUnderlyingResource().getLocation()
                    .toOSString()
                    + "/" + className;
                DecompiledClass decompiledClass = decompile(
                    source, location, decompilerFlags);
                classToDecompiled.put(cf, decompiledClass);
View Full Code Here

        public void run() {
            if (editor == null) {
                return;
            }
            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)){
                        editor.setSourceAttachmentPossible(false);
                        attachAction.setEnabled(false);
                        BytecodeOutlinePlugin
                            .error("Unable to configure source attachment:\n"
                                + "classpath entry '" + containerPath +
                                        "'\nis either read-only "
                                + "or source attachment is not supported...", null);
                        return;
                    }
                    entry = JavaModelUtil.findEntryInContainer(container, root
                        .getPath());
                }

                Shell shell = Display.getDefault().getActiveShell();
                IClasspathEntry cpe = BuildPathDialogAccess
View Full Code Here

TOP

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

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.