Java Code Examples for org.eclipse.jdt.core.IPackageFragment#exists()

The following examples show how to use org.eclipse.jdt.core.IPackageFragment#exists() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenamePackageChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void renamePackage(IPackageFragment pack, IProgressMonitor pm, IPath newPath, String newName) throws JavaModelException, CoreException {
	if (! pack.exists())
		return; // happens if empty parent with single subpackage is renamed, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199045
	pack.rename(newName, false, pm);
	if (fCompilationUnitStamps != null) {
		IPackageFragment newPack= (IPackageFragment) JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getFolder(newPath));
		if (newPack.exists()) {
			ICompilationUnit[] units= newPack.getCompilationUnits();
			for (int i= 0; i < units.length; i++) {
				IResource resource= units[i].getResource();
				if (resource != null) {
					Long stamp= fCompilationUnitStamps.get(resource);
					if (stamp != null) {
						resource.revertModificationStamp(stamp.longValue());
					}
				}
			}
		}
	}
}
 
Example 2
Source File: JavaElementResourceMapping.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<ResourceTraversal>();
	IContainer container= (IContainer)pack.getResource();
	
	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
		if (pack.exists()) { // folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167
			Object[] nonJavaResources= pack.getNonJavaResources();
			for (int i= 0; i < nonJavaResources.length; i++) {
				Object resource= nonJavaResources[i];
				if (resource instanceof IFolder) {
					res.add(new ResourceTraversal(new IResource[] { (IResource)resource }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}

	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example 3
Source File: PackagesViewHierarchicalContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IPackageFragment[] findNextLevelChildrenByElementName(IPackageFragmentRoot parent, IPackageFragment fragment) {
	List<IPackageFragment> list= new ArrayList<IPackageFragment>();
	try {

		IJavaElement[] children= parent.getChildren();
		String fragmentname= fragment.getElementName();
		for (int i= 0; i < children.length; i++) {
			IJavaElement element= children[i];
			if (element instanceof IPackageFragment) {
				IPackageFragment frag= (IPackageFragment) element;

				String name= element.getElementName();
				if (name.length() > fragmentname.length() && name.charAt(fragmentname.length()) == '.' && frag.exists() && !IPackageFragment.DEFAULT_PACKAGE_NAME.equals(fragmentname) && name.startsWith(fragmentname) && !name.equals(fragmentname)) {
					String tail= name.substring(fragmentname.length() + 1);
					if (!IPackageFragment.DEFAULT_PACKAGE_NAME.equals(tail) && tail.indexOf('.') == -1) {
						list.add(frag);
					}
				}
			}
		}

	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}
	return list.toArray(new IPackageFragment[list.size()]);
}
 
Example 4
Source File: JavaElementResourceMapping.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException {
	ArrayList<ResourceTraversal> res= new ArrayList<>();
	IContainer container= (IContainer)pack.getResource();

	if (container != null) {
		res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
		if (pack.exists()) { // folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167
			Object[] nonJavaResources= pack.getNonJavaResources();
			for (int i= 0; i < nonJavaResources.length; i++) {
				Object resource= nonJavaResources[i];
				if (resource instanceof IFolder) {
					res.add(new ResourceTraversal(new IResource[] { (IResource)resource }, IResource.DEPTH_INFINITE, 0));
				}
			}
		}
	}

	return res.toArray(new ResourceTraversal[res.size()]);
}
 
Example 5
Source File: MoveCompilationUnitChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IPackageFragment[] createDestination(IPackageFragmentRoot root, IPackageFragment destination, IProgressMonitor pm) throws JavaModelException {
	String packageName= destination.getElementName();
	String[] split= packageName.split("\\."); //$NON-NLS-1$

	ArrayList<IPackageFragment> created= new ArrayList<IPackageFragment>();

	StringBuffer name= new StringBuffer();
	name.append(split[0]);
	for (int i= 0; i < split.length; i++) {
		IPackageFragment fragment= root.getPackageFragment(name.toString());
		if (!fragment.exists()) {
			created.add(fragment);
		}

		if (fragment.equals(destination)) {
			root.createPackageFragment(name.toString(), true, pm);
			return created.toArray(new IPackageFragment[created.size()]);
		}

		name.append("."); //$NON-NLS-1$
		name.append(split[i + 1]);
	}

	return null;
}
 
Example 6
Source File: PackagesViewHierarchicalContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private Object getHierarchicalParent(IPackageFragment fragment) {
	IJavaElement parent= fragment.getParent();

	if ((parent instanceof IPackageFragmentRoot) && parent.exists()) {
		IPackageFragmentRoot root= (IPackageFragmentRoot) parent;
		if (root.isArchive() || root.isExternal() || !fragment.exists()) {
			return findNextLevelParentByElementName(fragment);
		} else {
			IResource resource= fragment.getResource();
			if ((resource != null) && (resource instanceof IFolder)) {
				IFolder folder= (IFolder) resource;
				IResource res= folder.getParent();

				IJavaElement el= JavaCore.create(res);
				if (el != null) {
					return el;
				} else {
					return res;
				}
			}
		}
	}
	return parent;
}
 
Example 7
Source File: NLSHintHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static IStorage getResourceBundle(IPackageFragmentRoot root, String packageName, String resourceName) throws JavaModelException {
	IPackageFragment packageFragment= root.getPackageFragment(packageName);
	if (packageFragment.exists()) {
		Object[] resources= packageFragment.isDefaultPackage() ? root.getNonJavaResources() : packageFragment.getNonJavaResources();
		for (int j= 0; j < resources.length; j++) {
			Object object= resources[j];
			if (JavaModelUtil.isOpenableStorage(object)) {
				IStorage storage= (IStorage)object;
				if (storage.getName().equals(resourceName)) {
					return storage;
				}
			}
		}
	}
	return null;
}
 
Example 8
Source File: NLSHintHelper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static IPackageFragment getResourceBundlePackage(IJavaProject javaProject, String packageName, String resourceName) throws JavaModelException {
	IPackageFragmentRoot[] allRoots= javaProject.getAllPackageFragmentRoots();
	for (int i= 0; i < allRoots.length; i++) {
		IPackageFragmentRoot root= allRoots[i];
		if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
			IPackageFragment packageFragment= root.getPackageFragment(packageName);
			if (packageFragment.exists()) {
				Object[] resources= packageFragment.isDefaultPackage() ? root.getNonJavaResources() : packageFragment.getNonJavaResources();
				for (int j= 0; j < resources.length; j++) {
					Object object= resources[j];
					if (object instanceof IFile) {
						IFile file= (IFile) object;
						if (file.getName().equals(resourceName)) {
							return packageFragment;
						}
					}
				}
			}
		}
	}
	return null;
}
 
Example 9
Source File: ProjectAwareUniqueClassNameValidator.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private SourceTraversal doCheckUniqueInProjectSource(String packageName, String typeName, JvmDeclaredType type,
		List<IPackageFragmentRoot> sourceFolders) throws JavaModelException {
	IndexManager indexManager = JavaModelManager.getIndexManager();
	for (IPackageFragmentRoot sourceFolder : sourceFolders) {
		if (indexManager.awaitingJobsCount() > 0) {
			if (!isDerived(sourceFolder.getResource())) {
				IPackageFragment packageFragment = sourceFolder.getPackageFragment(packageName);
				if (packageFragment.exists()) {
					for (ICompilationUnit unit : packageFragment.getCompilationUnits()) {
						if (!isDerived(unit.getResource())) {
							IType javaType = unit.getType(typeName);
							if (javaType.exists()) {
								addIssue(type, unit.getElementName());
								return SourceTraversal.DUPLICATE;
							}
						}
					}
				}
			}
		} else {
			return SourceTraversal.INTERRUPT;
		}
	}
	return SourceTraversal.UNIQUE;
}
 
Example 10
Source File: PackageExplorerContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public Object getHierarchicalPackageParent(IPackageFragment child) {
	String name= child.getElementName();
	IPackageFragmentRoot parent= (IPackageFragmentRoot) child.getParent();
	int index= name.lastIndexOf('.');
	if (index != -1) {
		String realParentName= name.substring(0, index);
		IPackageFragment element= parent.getPackageFragment(realParentName);
		if (element.exists()) {
			try {
				if (fFoldPackages && isEmpty(element) && findSinglePackageChild(element, parent.getChildren()) != null) {
					return getHierarchicalPackageParent(element);
				}
			} catch (JavaModelException e) {
				// ignore
			}
			return element;
		} else { // bug 65240
			IResource resource= element.getResource();
			if (resource != null) {
				return resource;
			}
		}
	}
	if (parent.getResource() instanceof IProject) {
		return parent.getJavaProject();
	}
	return parent;
}
 
Example 11
Source File: RenamePackageProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isPackageNameOkInRoot(String newName, IPackageFragmentRoot root) throws CoreException {
	IPackageFragment pack= root.getPackageFragment(newName);
	if (! pack.exists())
		return true;
	else if (pack.containsJavaResources())
		return false;
	else if (pack.getNonJavaResources().length != 0)
		return false;
	else
		return true;
}
 
Example 12
Source File: PackageBrowseAdapter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
static boolean canAddPackage(IPackageFragment p) throws JavaModelException{
	if (! p.exists())
		return false;
	if (p.isReadOnly())
		return false;
	if (! p.isStructureKnown())
		return false;
	return true;
}
 
Example 13
Source File: PackagesViewHierarchicalContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private LogicalPackage createLogicalPackage(IPackageFragment pkgFragment) {
	if(!fInputIsProject)
		return null;

	List<IPackageFragment> fragments= new ArrayList<IPackageFragment>();
	try {
		IPackageFragmentRoot[] roots= pkgFragment.getJavaProject().getPackageFragmentRoots();
		for (int i= 0; i < roots.length; i++) {
			IPackageFragmentRoot root= roots[i];
			IPackageFragment fragment= root.getPackageFragment(pkgFragment.getElementName());
			if(fragment.exists() && !fragment.equals(pkgFragment))
				fragments.add(fragment);
		}
		if(!fragments.isEmpty()) {
			LogicalPackage logicalPackage= new LogicalPackage(pkgFragment);
			fMapToLogicalPackage.put(getKey(pkgFragment), logicalPackage);
			Iterator<IPackageFragment> iter= fragments.iterator();
			while(iter.hasNext()){
				IPackageFragment f= iter.next();
				if(logicalPackage.belongs(f)){
					logicalPackage.add(f);
					fMapToLogicalPackage.put(getKey(f), logicalPackage);
				}
			}

			return logicalPackage;
		}

	} catch (JavaModelException e) {
		JavaPlugin.log(e);
	}

	return null;
}
 
Example 14
Source File: PackagesViewHierarchicalContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private Object findNextLevelParentByElementName(IPackageFragment child) {
	String name= child.getElementName();

	int index= name.lastIndexOf('.');
	if (index != -1) {
		String realParentName= name.substring(0, index);
		IPackageFragment element= ((IPackageFragmentRoot) child.getParent()).getPackageFragment(realParentName);
		if (element.exists()) {
			return element;
		}
	}
	return child.getParent();
}
 
Example 15
Source File: CleanUpAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void collectCompilationUnits(Object element, Collection<IJavaElement> result) {
	try {
		if (element instanceof IJavaElement) {
			IJavaElement elem= (IJavaElement)element;
			if (elem.exists()) {
				switch (elem.getElementType()) {
					case IJavaElement.TYPE:
						if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
							result.add(elem.getParent());
						}
						break;
					case IJavaElement.COMPILATION_UNIT:
						result.add(elem);
						break;
					case IJavaElement.IMPORT_CONTAINER:
						result.add(elem.getParent());
						break;
					case IJavaElement.PACKAGE_FRAGMENT:
						collectCompilationUnits((IPackageFragment)elem, result);
						break;
					case IJavaElement.PACKAGE_FRAGMENT_ROOT:
						collectCompilationUnits((IPackageFragmentRoot)elem, result);
						break;
					case IJavaElement.JAVA_PROJECT:
						IPackageFragmentRoot[] roots= ((IJavaProject)elem).getPackageFragmentRoots();
						for (int k= 0; k < roots.length; k++) {
							collectCompilationUnits(roots[k], result);
						}
						break;
				}
			}
		} else if (element instanceof LogicalPackage) {
			IPackageFragment[] packageFragments= ((LogicalPackage)element).getFragments();
			for (int k= 0; k < packageFragments.length; k++) {
				IPackageFragment pack= packageFragments[k];
				if (pack.exists()) {
					collectCompilationUnits(pack, result);
				}
			}
		} else if (element instanceof IWorkingSet) {
			IWorkingSet workingSet= (IWorkingSet) element;
			IAdaptable[] elements= workingSet.getElements();
			for (int j= 0; j < elements.length; j++) {
				collectCompilationUnits(elements[j], result);
			}
		}
	} catch (JavaModelException e) {
		if (JavaModelUtil.isExceptionToBeLogged(e))
			JavaPlugin.log(e);
	}
}
 
Example 16
Source File: FileEventHandler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
private static WorkspaceEdit computePackageRenameEdit(FileRenameEvent[] renameEvents, SourcePath[] sourcePaths, IProgressMonitor monitor) {
	WorkspaceEdit[] root = new WorkspaceEdit[1];
	SubMonitor submonitor = SubMonitor.convert(monitor, "Computing package rename updates...", 100 * renameEvents.length);
	for (FileRenameEvent event : renameEvents) {
		IPath oldLocation = ResourceUtils.filePathFromURI(event.oldUri);
		IPath newLocation = ResourceUtils.filePathFromURI(event.newUri);
		for (SourcePath sourcePath : sourcePaths) {
			IPath sourceLocation = Path.fromOSString(sourcePath.path);
			IPath sourceEntry = Path.fromOSString(sourcePath.classpathEntry);
			if (sourceLocation.isPrefixOf(oldLocation)) {
				SubMonitor renameMonitor = submonitor.split(100);
				try {
					IJavaProject javaProject = ProjectUtils.getJavaProject(sourcePath.projectName);
					if (javaProject == null) {
						break;
					}

					IPackageFragmentRoot packageRoot = javaProject.findPackageFragmentRoot(sourceEntry);
					if (packageRoot == null) {
						break;
					}

					String oldPackageName = String.join(".", oldLocation.makeRelativeTo(sourceLocation).segments());
					String newPackageName = String.join(".", newLocation.makeRelativeTo(sourceLocation).segments());
					IPackageFragment oldPackageFragment = packageRoot.getPackageFragment(oldPackageName);
					if (oldPackageFragment != null && !oldPackageFragment.isDefaultPackage() && oldPackageFragment.getResource() != null) {
						oldPackageFragment.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
						if (oldPackageFragment.exists()) {
							ResourcesPlugin.getWorkspace().run((pm) -> {
								WorkspaceEdit edit = getRenameEdit(oldPackageFragment, newPackageName, pm);
								root[0] = ChangeUtil.mergeChanges(root[0], edit, true);
							}, oldPackageFragment.getSchedulingRule(), IResource.NONE, renameMonitor);
						}
					}
				} catch (CoreException e) {
					JavaLanguageServerPlugin.logException("Failed to compute the package rename update", e);
				} finally {
					renameMonitor.done();
				}

				break;
			}
		}
	}

	submonitor.done();
	return ChangeUtil.hasChanges(root[0]) ? root[0] : null;
}
 
Example 17
Source File: NewPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Validates the package name and returns the status of the validation.
 * 
 * @param packName the package name
 * 
 * @return the status of the validation
 */
private IStatus getPackageStatus(String packName) {
	StatusInfo status= new StatusInfo();
	if (packName.length() > 0) {
		IStatus val= validatePackageName(packName);
		if (val.getSeverity() == IStatus.ERROR) {
			status.setError(Messages.format(NewWizardMessages.NewPackageWizardPage_error_InvalidPackageName, val.getMessage()));
			return status;
		} else if (val.getSeverity() == IStatus.WARNING) {
			status.setWarning(Messages.format(NewWizardMessages.NewPackageWizardPage_warning_DiscouragedPackageName, val.getMessage()));
		}
	} 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()) {
				// it's ok for the package to exist as long we want to create package level documentation
				// and the package level documentation doesn't exist
				if (!isCreatePackageDocumentation() || packageDocumentationAlreadyExists(pack)) {
					if (pack.containsJavaResources() || !pack.hasSubpackages()) {
						status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageExists);
					} else {
						status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageNotShown);
					}
				}
			} else {
				IResource resource= pack.getResource();
				if (resource != null && !ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
					status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageNameFiltered);
					return status;
				}
				URI location= pack.getResource().getLocationURI();
				if (location != null) {
					IFileStore store= EFS.getStore(location);
					if (store.fetchInfo().exists()) {
						status.setError(NewWizardMessages.NewPackageWizardPage_error_PackageExistsDifferentCase);
					}
				}
			}
		} catch (CoreException e) {
			JavaPlugin.log(e);
		}
	}
	return status;
}
 
Example 18
Source File: MoveCompilationUnitChange.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Override
Change doPerformReorg(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	String name;
	String newName= getNewName();
	if (newName == null) {
		name= getCu().getElementName();
	} else {
		name= newName;
	}

	// get current modification stamp
	long currentStamp= IResource.NULL_STAMP;
	IResource resource= getCu().getResource();
	if (resource != null) {
		currentStamp= resource.getModificationStamp();
	}

	IPackageFragment destination= getDestinationPackage();
	fUndoable= !destination.exists() || !destination.getCompilationUnit(name).exists();

	IPackageFragment[] createdPackages= null;
	if (!destination.exists()) {
		IPackageFragmentRoot packageFragmentRoot= (IPackageFragmentRoot) destination.getParent();
		createdPackages= createDestination(packageFragmentRoot, destination, pm);
	}

	// perform the move and restore modification stamp
	getCu().move(destination, null, newName, true, pm);
	if (fStampToRestore != IResource.NULL_STAMP) {
		ICompilationUnit moved= destination.getCompilationUnit(name);
		IResource movedResource= moved.getResource();
		if (movedResource != null) {
			movedResource.revertModificationStamp(fStampToRestore);
		}
	}

	if (fDeletePackages != null) {
		for (int i= fDeletePackages.length - 1; i >= 0; i--) {
			fDeletePackages[i].delete(true, pm);
		}
	}

	if (fUndoable) {
		return new MoveCompilationUnitChange(destination, getCu().getElementName(), getOldPackage(), currentStamp, createdPackages);
	} else {
		return null;
	}
}
 
Example 19
Source File: MoveCompilationUnitChange.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
Change doPerformReorg(IProgressMonitor pm) throws CoreException, OperationCanceledException {
	String name;
	String newName= getNewName();
	if (newName == null)
		name= getCu().getElementName();
	else
		name= newName;

	// get current modification stamp
	long currentStamp= IResource.NULL_STAMP;
	IResource resource= getCu().getResource();
	if (resource != null) {
		currentStamp= resource.getModificationStamp();
	}

	IPackageFragment destination= getDestinationPackage();
	fUndoable= !destination.exists() || !destination.getCompilationUnit(name).exists();

	IPackageFragment[] createdPackages= null;
	if (!destination.exists()) {
		IPackageFragmentRoot packageFragmentRoot= (IPackageFragmentRoot) destination.getParent();
		createdPackages= createDestination(packageFragmentRoot, destination, pm);
	}

	// perform the move and restore modification stamp
	getCu().move(destination, null, newName, true, pm);
	if (fStampToRestore != IResource.NULL_STAMP) {
		ICompilationUnit moved= destination.getCompilationUnit(name);
		IResource movedResource= moved.getResource();
		if (movedResource != null) {
			movedResource.revertModificationStamp(fStampToRestore);
		}
	}

	if (fDeletePackages != null) {
		for (int i= fDeletePackages.length - 1; i >= 0; i--) {
			fDeletePackages[i].delete(true, pm);
		}
	}

	if (fUndoable) {
		return new MoveCompilationUnitChange(destination, getCu().getElementName(), getOldPackage(), currentStamp, createdPackages);
	} else {
		return null;
	}
}
 
Example 20
Source File: NLSAccessorConfigurationDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void validatePropertyPackage() {

		IPackageFragmentRoot root= fResourceBundlePackage.getSelectedFragmentRoot();
		if ((root == null) || !root.exists()) {
			setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_root_invalid);
			return;
		}

		IPackageFragment fragment= fResourceBundlePackage.getSelected();
		if ((fragment == null) || !fragment.exists()) {
			setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_property_package_invalid);
			return;
		}

		String pkgName= fragment.getElementName();

		IStatus status= JavaConventionsUtil.validatePackageName(pkgName, root);
		if ((pkgName.length() > 0) && (status.getSeverity() == IStatus.ERROR)) {
			setInvalid(IDX_BUNDLE_PACKAGE, status.getMessage());
			return;
		}

		IPath pkgPath= new Path(pkgName.replace('.', IPath.SEPARATOR)).makeRelative();

		IJavaProject project= fRefactoring.getCu().getJavaProject();
		try {
			IJavaElement element= project.findElement(pkgPath);
			if (element == null || !element.exists()) {
				setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_must_exist);
				return;
			}
			IPackageFragment fPkgFragment= (IPackageFragment) element;
			if (!PackageBrowseAdapter.canAddPackage(fPkgFragment)) {
				setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package);
				return;
			}
			if (!PackageBrowseAdapter.canAddPackageRoot((IPackageFragmentRoot) fPkgFragment.getParent())) {
				setInvalid(IDX_BUNDLE_PACKAGE, NLSUIMessages.NLSAccessorConfigurationDialog_incorrect_package);
				return;
			}
		} catch (JavaModelException e) {
			setInvalid(IDX_BUNDLE_PACKAGE, e.getStatus().getMessage());
			return;
		}

		setValid(IDX_BUNDLE_PACKAGE);
	}