use of org.eclipse.core.resources.IContainer in project generator by mybatis.
the class ConfigurationComposite method getViewerFilter.
@Override
protected ViewerFilter getViewerFilter() {
return new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IContainer) {
return true;
}
if (element instanceof IFile) {
IFile file = (IFile) element;
ConfigVerifyer cv = new ConfigVerifyer(file);
return cv.isConfigurationFile();
}
return false;
}
};
}
use of org.eclipse.core.resources.IContainer in project che by eclipse.
the class JavaProjectHelper method addClassFolder.
/**
* Creates and adds a class folder to the class path.
* @param jproject The parent project
* @param containerName
* @param sourceAttachPath The source attachment path
* @param sourceAttachRoot The source attachment root path
* @return The handle of the created root
* @throws CoreException
*/
public static IPackageFragmentRoot addClassFolder(IJavaProject jproject, String containerName, IPath sourceAttachPath, IPath sourceAttachRoot) throws CoreException {
IProject project = jproject.getProject();
IContainer container = null;
if (containerName == null || containerName.length() == 0) {
container = project;
} else {
IFolder folder = project.getFolder(containerName);
if (!folder.exists()) {
CoreUtility.createFolder(folder, false, true, null);
}
container = folder;
}
IClasspathEntry cpe = JavaCore.newLibraryEntry(container.getFullPath(), sourceAttachPath, sourceAttachRoot);
addToClasspath(jproject, cpe);
return jproject.getPackageFragmentRoot(container);
}
use of org.eclipse.core.resources.IContainer in project che by eclipse.
the class JavaModelOperation method deleteEmptyPackageFragment.
/**
* Convenience method to delete an empty package fragment
*/
protected void deleteEmptyPackageFragment(IPackageFragment fragment, boolean forceFlag, IResource rootResource) throws JavaModelException {
IContainer resource = (IContainer) ((JavaElement) fragment).resource();
try {
resource.delete(forceFlag ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, getSubProgressMonitor(1));
setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
while (resource instanceof IFolder) {
// deleting a package: delete the parent if it is empty (e.g. deleting x.y where folder x doesn't have resources but y)
// without deleting the package fragment root
resource = resource.getParent();
if (!resource.equals(rootResource) && resource.members().length == 0) {
resource.delete(forceFlag ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY, getSubProgressMonitor(1));
setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
}
}
} catch (CoreException e) {
throw new JavaModelException(e);
}
}
use of org.eclipse.core.resources.IContainer in project che by eclipse.
the class JavaElementResourceMapping method getPackageFragmentTraversals.
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()]);
}
use of org.eclipse.core.resources.IContainer in project che by eclipse.
the class JavaElementResourceMapping method getRemotePackageFragmentTraversals.
private static ResourceTraversal[] getRemotePackageFragmentTraversals(IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) 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));
IResource[] remoteMembers = context.fetchRemoteMembers(container, monitor);
if (remoteMembers == null) {
remoteMembers = context.fetchMembers(container, monitor);
}
if (remoteMembers != null) {
for (int i = 0; i < remoteMembers.length; i++) {
IResource member = remoteMembers[i];
if (member instanceof IFolder && JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) {
res.add(new ResourceTraversal(new IResource[] { member }, IResource.DEPTH_INFINITE, 0));
}
}
}
}
return res.toArray(new ResourceTraversal[res.size()]);
}
Aggregations