Example usage for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE

List of usage examples for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE.

Prototype

int CPE_SOURCE

To view the source code for org.eclipse.jdt.core IClasspathEntry CPE_SOURCE.

Click Source Link

Document

Entry kind constant describing a classpath entry identifying a folder containing package fragments with source code to be compiled.

Usage

From source file:com.redhat.ceylon.eclipse.code.wizard.CreateMultipleResourceFoldersDialog.java

License:Open Source License

@Override
public int open() {
    Class<?>[] acceptedClasses = new Class<?>[] { IProject.class, IFolder.class };
    List<IResource> existingContainers = getExistingContainers(fExistingElements);

    IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    ArrayList<IProject> rejectedElements = new ArrayList<IProject>(allProjects.length);
    IProject currProject = fJavaProject.getProject();
    for (int i = 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(currProject)) {
            rejectedElements.add(allProjects[i]);
        }// www. j av  a  2 s. com
    }
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements.toArray()) {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IFolder && ((IFolder) element).isVirtual()) {
                return false;
            }
            return super.select(viewer, parentElement, element);
        }
    };

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new FakeFolderBaseWorkbenchContentProvider();

    String title = type + " Folder Selection";
    String message = "&Select the folder:";

    MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp) {
        @Override
        protected Control createDialogArea(Composite parent) {
            Control result = super.createDialogArea(parent);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
                    IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
            return result;
        }

        @Override
        protected Object createFolder(final IContainer container) {
            final Object[] result = new Object[1];
            final CPListElement newElement = new CPListElement(fJavaProject, IClasspathEntry.CPE_SOURCE);
            final AddResourceFolderWizard wizard = newResourceFolderWizard(newElement, fExistingElements,
                    fOutputLocation, container);
            AbstractOpenWizardAction action = new AbstractOpenWizardAction() {
                @Override
                protected INewWizard createWizard() throws CoreException {
                    return wizard;
                }
            };
            action.addPropertyChangeListener(new IPropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getProperty().equals(IAction.RESULT)) {
                        if (event.getNewValue().equals(Boolean.TRUE)) {
                            result[0] = addFakeFolder(fJavaProject.getProject(), newElement);
                        } else {
                            wizard.cancel();
                        }
                    }
                }
            });
            action.run();
            return result[0];
        }
    };
    dialog.setExisting(existingContainers.toArray());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(fJavaProject.getProject().getParent());
    dialog.setInitialFocus(fJavaProject.getProject());

    if (dialog.open() == Window.OK) {
        Object[] elements = dialog.getResult();
        for (int i = 0; i < elements.length; i++) {
            IResource res = (IResource) elements[i];
            fInsertedElements
                    .add(new CPListElement(fJavaProject, IClasspathEntry.CPE_SOURCE, res.getFullPath(), res));
        }

        if (fExistingElements.length == 1) {
            CPListElement existingElement = fExistingElements[0];
            if (existingElement.getResource() instanceof IProject) {
                if (!removeProjectFromBP(existingElement)) {
                    ArrayList<CPListElement> added = new ArrayList<CPListElement>(fInsertedElements);
                    HashSet<CPListElement> updatedEclusionPatterns = new HashSet<CPListElement>();
                    addExlusionPatterns(added, updatedEclusionPatterns);
                    fModifiedElements.addAll(updatedEclusionPatterns);
                }
            }
        } else {
            ArrayList<CPListElement> added = new ArrayList<CPListElement>(fInsertedElements);
            HashSet<CPListElement> updatedEclusionPatterns = new HashSet<CPListElement>();
            addExlusionPatterns(added, updatedEclusionPatterns);
            fModifiedElements.addAll(updatedEclusionPatterns);
        }
        return Window.OK;
    } else {
        return Window.CANCEL;
    }
}

From source file:com.redhat.ceylon.eclipse.code.wizard.SourceContainerWorkbookPage.java

License:Open Source License

private void updateFoldersList() {
    if (fSWTControl == null || fSWTControl.isDisposed()) {
        return;/*from  ww w  .  j a v  a2  s  . com*/
    }

    ArrayList<CPListElement> folders = new ArrayList<CPListElement>();

    boolean useFolderOutputs = false;
    List<CPListElement> cpelements = fClassPathList.getElements();
    for (int i = 0; i < cpelements.size(); i++) {
        CPListElement cpe = cpelements.get(i);
        if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
            folders.add(cpe);
            boolean hasOutputFolder = cpe.getAttribute(CPListElement.OUTPUT) != null;
            if (hasOutputFolder) {
                useFolderOutputs = true;
            }

        }
    }
    fFoldersList.setElements(folders);
    fUseFolderOutputs.setSelection(useFolderOutputs);

    for (int i = 0; i < folders.size(); i++) {
        CPListElement cpe = folders.get(i);
        IPath[] ePatterns = (IPath[]) cpe.getAttribute(CPListElement.EXCLUSION);
        IPath[] iPatterns = (IPath[]) cpe.getAttribute(CPListElement.INCLUSION);
        boolean hasOutputFolder = cpe.getAttribute(CPListElement.OUTPUT) != null;
        if (ePatterns.length > 0 || iPatterns.length > 0 || hasOutputFolder) {
            fFoldersList.expandElement(cpe, 3);
        }
    }
}

From source file:com.redhat.ceylon.eclipse.code.wizard.SourceContainerWorkbookPage.java

License:Open Source License

protected void sourcePageCustomButtonPressed(DialogField field, int index) {
    if (field == fFoldersList) {
        if (index == IDX_ADD) {
            IProject project = fCurrJProject.getProject();
            if (project.isAccessible() && hasFolders(project)) {
                List<CPListElement> existingElements = fFoldersList.getElements();
                CPListElement[] existing = existingElements.toArray(new CPListElement[existingElements.size()]);
                CreateMultipleSourceFoldersDialog dialog = new CreateMultipleSourceFoldersDialog(fCurrJProject,
                        existing, fJavaOutputLocationField.getText(), getShell());
                if (dialog.open() == Window.OK) {
                    refresh(dialog.getInsertedElements(), dialog.getRemovedElements(),
                            dialog.getModifiedElements(), dialog.getOutputLocation());
                }//from   www . j  av a2s  .  c  o  m
            } else {
                CPListElement newElement = new CPListElement(fCurrJProject, IClasspathEntry.CPE_SOURCE);
                AddSourceFolderWizard wizard = newSourceFolderWizard(newElement, fFoldersList.getElements(),
                        fJavaOutputLocationField.getText(), true);
                OpenBuildPathWizardAction action = new OpenBuildPathWizardAction(wizard);
                action.run();
            }
        } else if (index == IDX_ADD_LINK) {
            CPListElement newElement = new CPListElement(fCurrJProject, IClasspathEntry.CPE_SOURCE);
            AddSourceFolderWizard wizard = newLinkedSourceFolderWizard(newElement, fFoldersList.getElements(),
                    fJavaOutputLocationField.getText(), true);
            OpenBuildPathWizardAction action = new OpenBuildPathWizardAction(wizard);
            action.run();
        } else if (index == IDX_EDIT || index == IDX_TOGGLE) {
            editEntry();
        } else if (index == IDX_REMOVE) {
            removeEntry();
        }
    }
}

From source file:com.redhat.ceylon.eclipse.code.wizard.SourceContainerWorkbookPage.java

License:Open Source License

private void removeEntry() {
    List<Object> selElements = fFoldersList.getSelectedElements();
    for (int i = selElements.size() - 1; i >= 0; i--) {
        Object elem = selElements.get(i);
        if (elem instanceof CPListElementAttribute) {
            CPListElementAttribute attrib = (CPListElementAttribute) elem;
            String key = attrib.getKey();
            if (attrib.isBuiltIn()) {
                Object value = null;
                if (key.equals(CPListElement.EXCLUSION) || key.equals(CPListElement.INCLUSION)) {
                    value = new Path[0];
                }//from  www  . ja va 2  s  .  com
                attrib.getParent().setAttribute(key, value);
            } else {
                removeCustomAttribute(attrib);
            }
            selElements.remove(i);
        }
    }
    if (selElements.isEmpty()) {
        fFoldersList.refresh();
        fClassPathList.dialogFieldChanged(); // validate
    } else {
        for (Iterator<Object> iter = selElements.iterator(); iter.hasNext();) {
            CPListElement element = (CPListElement) iter.next();
            if (element.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                List<CPListElement> list = ClasspathModifier.removeFilters(element.getPath(), fCurrJProject,
                        fFoldersList.getElements());
                for (Iterator<CPListElement> iterator = list.iterator(); iterator.hasNext();) {
                    CPListElement modified = iterator.next();
                    fFoldersList.refresh(modified);
                    fFoldersList.expandElement(modified, 3);
                }
            }
        }
        fFoldersList.removeElements(selElements);
    }
}

From source file:com.redhat.ceylon.eclipse.core.model.JDTModuleManager.java

License:Open Source License

@Override
protected JDTModule createModule(List<String> moduleName, String version) {
    JDTModule module = null;/*w w w.j a va2s  .co m*/
    String moduleNameString = Util.getName(moduleName);
    List<IPackageFragmentRoot> roots = new ArrayList<IPackageFragmentRoot>();
    if (javaProject != null) {
        try {
            if (moduleNameString.equals(Module.DEFAULT_MODULE_NAME)) {
                // Add the list of source package fragment roots
                for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
                    if (root.exists() && javaProject.isOnClasspath(root)) {
                        IClasspathEntry entry = root.getResolvedClasspathEntry();
                        if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && !root.isExternal()) {
                            roots.add(root);
                        }
                    }
                }
            } else {
                for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
                    if (root.exists() && javaProject.isOnClasspath(root)) {
                        if (JDKUtils.isJDKModule(moduleNameString)) {
                            // find the first package that exists in this root
                            for (String pkg : JDKUtils.getJDKPackagesByModule(moduleNameString)) {
                                if (root.getPackageFragment(pkg).exists()) {
                                    roots.add(root);
                                    break;
                                }
                            }
                        } else if (JDKUtils.isOracleJDKModule(moduleNameString)) {
                            // find the first package that exists in this root
                            for (String pkg : JDKUtils.getOracleJDKPackagesByModule(moduleNameString)) {
                                if (root.getPackageFragment(pkg).exists()) {
                                    roots.add(root);
                                    break;
                                }
                            }
                        } else if (!(root instanceof JarPackageFragmentRoot)
                                && !CeylonBuilder.isInCeylonClassesOutputFolder(root.getPath())) {
                            String packageToSearch = moduleNameString;
                            if (root.getPackageFragment(packageToSearch).exists()) {
                                roots.add(root);
                            }
                        }
                    }
                }
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }
    }

    module = new JDTModule(this, roots);
    module.setName(moduleName);
    module.setVersion(version);
    setupIfJDKModule(module);
    return module;
}

From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTModuleManager.java

License:Open Source License

@Override
protected Module createModule(List<String> moduleName, String version) {
    JDTModule module = null;// w  ww . j  a  va2 s  .  com
    String moduleNameString = Util.getName(moduleName);
    List<IPackageFragmentRoot> roots = new ArrayList<IPackageFragmentRoot>();
    try {
        if (moduleNameString.equals(Module.DEFAULT_MODULE_NAME)) {
            // Add the list of source package fragment roots
            for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
                IClasspathEntry entry = root.getResolvedClasspathEntry();
                if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && !root.isExternal()) {
                    roots.add(root);
                }
            }
        } else {
            for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
                if (JDKUtils.isJDKModule(moduleNameString)) {
                    // find the first package that exists in this root
                    for (String pkg : JDKUtils.getJDKPackagesByModule(moduleNameString)) {
                        if (root.getPackageFragment(pkg).exists()) {
                            roots.add(root);
                            break;
                        }
                    }
                } else if (JDKUtils.isOracleJDKModule(moduleNameString)) {
                    // find the first package that exists in this root
                    for (String pkg : JDKUtils.getOracleJDKPackagesByModule(moduleNameString)) {
                        if (root.getPackageFragment(pkg).exists()) {
                            roots.add(root);
                            break;
                        }
                    }
                } else if (!(root instanceof JarPackageFragmentRoot)) {
                    String packageToSearch = moduleNameString;
                    if (root.getPackageFragment(packageToSearch).exists()) {
                        roots.add(root);
                    }
                }
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }

    module = new JDTModule(this, roots);
    module.setName(moduleName);
    module.setVersion(version);
    setupIfJDKModule(module);
    return module;
}

From source file:com.siteview.mde.internal.core.builders.BuildErrorReporter.java

License:Open Source License

/**
 * Matches the javacSource, javacTarget, javacWarnings, javacErrors and jre.compilation.prile entries in build.properties with the 
 * project specific Java Compiler properties and reports the errors found.
 * //  w  ww. j  av a 2  s  .c  o m
 * @param javacSourceEntry
 * @param javacTargetEntry
 * @param jreCompilationProfileEntry
 * @param javacWarningsEntries
 * @param javacErrorsEntries 
 * @param libraryNames list of library names (javacWarnings/javacErrors require an entry for each source library)
 */
private void validateExecutionEnvironment(IBuildEntry javacSourceEntry, IBuildEntry javacTargetEntry,
        IBuildEntry jreCompilationProfileEntry, ArrayList javacWarningsEntries, ArrayList javacErrorsEntries,
        List libraryNames) {
    // if there is no source to compile, don't worry about compiler settings
    IJavaProject project = JavaCore.create(fProject);
    if (project.exists()) {
        IClasspathEntry[] classpath = null;
        try {
            classpath = project.getRawClasspath();
        } catch (JavaModelException e) {
            MDECore.log(e);
            return;
        }
        boolean source = false;
        for (int i = 0; i < classpath.length; i++) {
            IClasspathEntry cpe = classpath[i];
            if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                source = true;
            }
        }
        if (!source) {
            return;
        }

        String projectComplianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, false);

        if (projectComplianceLevel != null) {

            IMonitorModelBase model = MonitorRegistry.findModel(fProject);
            String[] execEnvs = null;
            if (model != null) {
                BundleDescription bundleDesc = model.getBundleDescription();
                if (bundleDesc != null) {
                    execEnvs = bundleDesc.getExecutionEnvironments();
                }
            }

            if (execEnvs == null || execEnvs.length == 0) {
                return;
            }

            //PDE Build uses top most entry to build the plug-in
            String execEnv = execEnvs[0];

            String projectSourceCompatibility = project.getOption(JavaCore.COMPILER_SOURCE, true);
            String projectClassCompatibility = project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM,
                    true);
            if (projectComplianceLevel
                    .equals(findMatchingEE(projectSourceCompatibility, projectClassCompatibility, false))
                    && execEnv.equals(
                            findMatchingEE(projectSourceCompatibility, projectClassCompatibility, true))) {
                return; //The project compliance settings matches the BREE
            }

            Map defaultComplianceOptions = new HashMap();
            JavaCore.setComplianceOptions(projectComplianceLevel, defaultComplianceOptions);

            //project compliance does not match the BREE
            String projectJavaCompatibility = findMatchingEE(projectSourceCompatibility,
                    projectClassCompatibility, true);
            String message = null;
            if (projectJavaCompatibility != null) {
                if (jreCompilationProfileEntry == null) {
                    message = NLS.bind(
                            MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                            PROPERTY_JRE_COMPILATION_PROFILE,
                            MDECoreMessages.BuildErrorReporter_CompilercomplianceLevel);
                    prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message,
                            MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                            MDEMarkerFactory.CAT_EE);
                } else {
                    if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) {
                        message = NLS.bind(
                                MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                PROPERTY_JRE_COMPILATION_PROFILE,
                                MDECoreMessages.BuildErrorReporter_CompilercomplianceLevel);
                        prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message,
                                MDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE);
                    }
                }
            } else {
                // Check source level setting
                if (projectSourceCompatibility.equals(defaultComplianceOptions.get(JavaCore.COMPILER_SOURCE))) {
                    if (javacSourceEntry != null) {
                        message = NLS.bind(
                                MDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault,
                                PROPERTY_JAVAC_SOURCE, MDECoreMessages.BuildErrorReporter_SourceCompatibility);
                        prepareError(PROPERTY_JAVAC_SOURCE, null, message, MDEMarkerFactory.B_REMOVAL,
                                fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE);
                    }
                } else {
                    if (javacSourceEntry == null) {
                        message = NLS.bind(
                                MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                                PROPERTY_JAVAC_SOURCE, MDECoreMessages.BuildErrorReporter_SourceCompatibility);
                        prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message,
                                MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                MDEMarkerFactory.CAT_EE);
                    } else {
                        if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) {
                            message = NLS.bind(
                                    MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                    PROPERTY_JAVAC_SOURCE,
                                    MDECoreMessages.BuildErrorReporter_SourceCompatibility);
                            prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message,
                                    MDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity,
                                    MDEMarkerFactory.CAT_EE);
                        }
                    }
                }

                // Check target level setting
                if (projectClassCompatibility
                        .equals(defaultComplianceOptions.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))) {
                    if (javacTargetEntry != null) {
                        message = NLS.bind(
                                MDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault,
                                PROPERTY_JAVAC_TARGET,
                                MDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                        prepareError(PROPERTY_JAVAC_TARGET, null, message, MDEMarkerFactory.B_REMOVAL,
                                fJavaComplianceSeverity, MDEMarkerFactory.CAT_EE);
                    }
                } else {
                    if (javacTargetEntry == null) {
                        message = NLS.bind(
                                MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                                PROPERTY_JAVAC_TARGET,
                                MDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                        prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message,
                                MDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                MDEMarkerFactory.CAT_EE);
                    } else {
                        if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) {
                            message = NLS.bind(
                                    MDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                    PROPERTY_JAVAC_TARGET,
                                    MDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                            prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message,
                                    MDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity,
                                    MDEMarkerFactory.CAT_EE);
                        }
                    }
                }
            }

            boolean warnForJavacWarnings = message != null || javacSourceEntry != null
                    || javacTargetEntry != null || jreCompilationProfileEntry != null;
            if (warnForJavacWarnings == false) {
                return;
            }

            checkJavaComplianceSettings(projectComplianceLevel, javacWarningsEntries, javacErrorsEntries,
                    libraryNames);
        }
    }
}

From source file:com.siteview.mde.internal.core.builders.BuildErrorReporter.java

License:Open Source License

private void validateMissingLibraries(ArrayList sourceEntryKeys, IClasspathEntry[] cpes) {
    boolean srcFolderExists = false;
    // no need to flag anything if the project contains no source folders.
    for (int j = 0; j < cpes.length; j++) {
        if (cpes[j].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
            srcFolderExists = true;//  ww  w .  j av  a2  s  . c o  m
            break;
        }
    }
    if (!srcFolderExists)
        return;

    IMonitorModelBase model = MonitorRegistry.findModel(fProject);
    if (model == null)
        return;
    if (model instanceof IBundlePluginModelBase && !(model instanceof IBundleFragmentModel)) {
        IBundleModel bm = ((IBundlePluginModelBase) model).getBundleModel();
        IManifestHeader mh = bm.getBundle().getManifestHeader(Constants.BUNDLE_CLASSPATH);
        if ((mh == null || mh.getValue() == null)) {
            if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) {
                prepareError(DEF_SOURCE_ENTRY, null, MDECoreMessages.BuildErrorReporter_sourceMissing,
                        MDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, MDEMarkerFactory.CAT_OTHER);
            }
        }
    }
    IMonitorLibrary[] libraries = model.getMonitorBase().getLibraries();
    for (int i = 0; i < libraries.length; i++) {
        String libname = libraries[i].getName();
        if (libname.equals(".")) { //$NON-NLS-1$
            if (!sourceEntryKeys.contains(DEF_SOURCE_ENTRY)) {
                prepareError(DEF_SOURCE_ENTRY, null, MDECoreMessages.BuildErrorReporter_sourceMissing,
                        MDEMarkerFactory.NO_RESOLUTION, fSrcLibSeverity, MDEMarkerFactory.CAT_OTHER);
                continue;
            }
        } else if (fProject.findMember(libname) != null) {
            // non "." library entries that exist in the workspace
            // don't have to be referenced in the build properties
            continue;
        }
        String sourceEntryKey = PROPERTY_SOURCE_PREFIX + libname;
        if (!sourceEntryKeys.contains(sourceEntryKey)
                && !containedInFragment(model.getBundleDescription(), libname))
            prepareError(sourceEntryKey, null,
                    NLS.bind(MDECoreMessages.BuildErrorReporter_missingEntry, sourceEntryKey),
                    MDEMarkerFactory.B_ADDITION, MDEMarkerFactory.CAT_OTHER);
    }
}

From source file:com.siteview.mde.internal.core.builders.BuildErrorReporter.java

License:Open Source License

private void validateSourceFoldersInSrcIncludes(IBuildEntry includes) {
    if (includes == null)
        return;//from w  ww  .  j  ava  2  s. c  o  m

    List sourceFolderList = new ArrayList(0);
    try {
        IJavaProject javaProject = JavaCore.create(fProject);
        if (javaProject.exists()) {
            IClasspathEntry[] classPathEntries = javaProject.getResolvedClasspath(true);

            for (int index = 0; index < classPathEntries.length; index++) {
                if (classPathEntries[index].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                    sourceFolderList.add(classPathEntries[index].getPath());
                }
            }
        }
    } catch (JavaModelException e) { //do nothing
    }

    List reservedTokens = Arrays.asList(RESERVED_NAMES);

    String[] tokens = includes.getTokens();
    for (int i = 0; i < tokens.length; i++) {
        IResource res = fProject.findMember(tokens[i]);
        if (res == null)
            continue;
        String errorMessage = null;
        if (sourceFolderList.contains(res.getFullPath())) {
            errorMessage = MDECoreMessages.BuildErrorReporter_srcIncludesSourceFolder;
        } else if (tokens[i].startsWith(".") //$NON-NLS-1$
                || reservedTokens.contains(res.getName().toString().toLowerCase())) {
            errorMessage = NLS.bind(MDECoreMessages.BuildErrorReporter_srcIncludesSourceFolder1, res.getName());
        }

        if (errorMessage != null) {
            prepareError(includes.getName(), tokens[i], errorMessage, MDEMarkerFactory.B_REMOVAL,
                    fSrcInclSeverity, MDEMarkerFactory.CAT_OTHER);
        }
    }

}

From source file:com.siteview.mde.internal.core.builders.MDEBuilderHelper.java

License:Open Source License

public static String[] getUnlistedClasspaths(ArrayList sourceEntries, IProject project,
        IClasspathEntry[] cpes) {//from w ww .j  a  v a2s .  c  o  m
    String[] unlisted = new String[cpes.length];
    int index = 0;
    for (int i = 0; i < cpes.length; i++) {
        if (cpes[i].getEntryKind() != IClasspathEntry.CPE_SOURCE)
            continue;
        IPath path = cpes[i].getPath();
        boolean found = false;
        for (int j = 0; j < sourceEntries.size(); j++) {
            IBuildEntry be = (IBuildEntry) sourceEntries.get(j);
            String[] tokens = be.getTokens();
            for (int k = 0; k < tokens.length; k++) {
                IResource res = project.findMember(tokens[k]);
                if (res == null)
                    continue;
                IPath ipath = res.getFullPath();
                if (ipath.equals(path))
                    found = true;
            }
        }
        if (!found)
            unlisted[index++] = path.removeFirstSegments(1).addTrailingSeparator().toString();
    }
    return unlisted;
}