List of usage examples for org.eclipse.jdt.core IPackageFragmentRoot getJavaProject
IJavaProject getJavaProject();
null
if this element is not contained in any Java project (for instance, the IJavaModel
is not contained in any Java project). From source file:org.summer.dsl.xbase.ui.validation.XbaseUIValidator.java
License:Open Source License
@Nullable protected IClasspathEntry getResolvedClasspathEntry(IJavaProject javaProject, @NonNull IPackageFragmentRoot root) throws JavaModelException { IClasspathEntry result = null;/*from ww w . ja va 2 s. c om*/ JavaProject castedProject = (JavaProject) javaProject; castedProject.getResolvedClasspath(); // force the resolved entry cache to be populated @SuppressWarnings("rawtypes") Map rootPathToResolvedEntries = castedProject.getPerProjectInfo().rootPathToResolvedEntries; if (rootPathToResolvedEntries != null) { result = (IClasspathEntry) rootPathToResolvedEntries.get(root.getPath()); if (result == null) result = (IClasspathEntry) rootPathToResolvedEntries.get(root.getJavaProject().getPath()); } return result; }
From source file:sharpen.ui.popup.actions.ConvertPackageAction.java
License:Open Source License
protected void safeRun() throws Throwable { IPackageFragmentRoot root = (IPackageFragmentRoot) _selection.getFirstElement(); List<ICompilationUnit> units = new ArrayList<ICompilationUnit>(); JavaModelUtility.collectCompilationUnits(units, root); scheduleConversionJob("C# Conversion of package '" + root.getPath() + "'", units, root.getJavaProject()); }
From source file:x10dt.ui.wizards.NewX10PackageWizardPage.java
License:Open Source License
private IStatus packageChanged() { StatusInfo status = new StatusInfo(); String packName = getPackageText(); if (packName.length() > 0) { IStatus val = JavaConventions.validatePackageName(packName); if (val.getSeverity() == IStatus.ERROR) { status.setError(MessageFormat .format(NewWizardMessages.NewPackageWizardPage_error_InvalidPackageName, val.getMessage())); return status; } else if (val.getSeverity() == IStatus.WARNING) { status.setWarning(MessageFormat.format( NewWizardMessages.NewPackageWizardPage_warning_DiscouragedPackageName, val.getMessage())); }//from w ww .j av a 2 s . c o m } else { status.setError(NewWizardMessages.NewPackageWizardPage_error_EnterName); return status; } IPackageFragmentRoot root = getPackageFragmentRoot(); if (root != null && root.getJavaProject().exists()) { IPackageFragment pack = root.getPackageFragment(packName); 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 = pack.getPath(); if (outputPath.isPrefixOf(packagePath)) { status.setError(NewWizardMessages.NewPackageWizardPage_error_IsOutputFolder); return status; } } if (pack.exists()) { if (pack.containsJavaResources() || !pack.hasSubpackages()) { status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageExists); } else { status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageNotShown); } } // 11/14/2007 RMF disabled to avoid dependency on EFS for now else { URI location = URIUtils.getExpectedURI(pack.getResource().getLocationURI()); if (location != null) { IFileStore store = EFS.getStore(location); if (store.fetchInfo().exists()) { status.setError( NewWizardMessages.NewPackageWizardPage_error_PackageExistsDifferentCase); } } } } catch (CoreException e) { X10DTCorePlugin.getInstance().logException(e.getMessage(), e); } } return status; }