Java Code Examples for org.eclipse.core.resources.IResource.getFileExtension()

The following are Jave code examples for showing how to use getFileExtension() of the org.eclipse.core.resources.IResource class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: visuflow-plugin   File: JimpleBuilder.java   View Source Code Vote up 6 votes
public boolean visit(IResourceDelta delta) throws CoreException {
	IResource resource = delta.getResource();
	if (resource.getFileExtension() != null){
	switch (delta.getKind()) {
	case IResourceDelta.ADDED:
		if(resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	case IResourceDelta.REMOVED:
		if(resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	case IResourceDelta.CHANGED:
		if( resource.getFileExtension().equals("java")){
			executeBuild = true;
			return false;
		}
		break;
	}
	}
	return true;
}
 
Example 2
Project: gw4e.project   File: ResourceManagerTest.java   View Source Code Vote up 5 votes
@Test
public void testCreateFileDeleteIfExistsStringStringStringIProgressMonitor() throws Exception {
	IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true);
	IFile impl = (IFile) ResourceManager
			.getResource(project.getProject().getFullPath().append("src/test/java/SimpleImpl.java").toString());
	int[] count = new int[1];

	count[0] = 0;
	IResourceVisitor visitor = new IResourceVisitor() {
		@Override
		public boolean visit(IResource resource) throws CoreException {
			if (resource.getFileExtension() != null && resource.getFileExtension().equalsIgnoreCase("java")) {
				count[0] = count[0] + 1;
			}
			return true;
		}
	};
	impl.getParent().accept(visitor);
	assertTrue(count[0] == 1);

	ResourceManager.createFileDeleteIfExists(impl.getParent().getFullPath().toString(), "SimpleImpl.java", "",
			new NullProgressMonitor());
	String s = IOHelper.getContent(impl);
	assertTrue(s.length() == 0);

	count[0] = 0;
	impl.getParent().accept(visitor);
	assertTrue(count[0] == 2);
}
 
Example 3
Project: gemoc-studio   File: FileFinderVisitor.java   View Source Code Vote up 5 votes
@Override
public boolean visit(IResource resource) throws CoreException {
	boolean mustVisitChild = true;
	if(resource instanceof IFile){
		String resourceExtension = resource.getFileExtension();
		if(resourceExtension == null){
			resourceExtension = "";
		}
		if(_searchedFileExtensions.contains(resourceExtension)){
			_files.add((IFile) resource);
		}
		mustVisitChild = false;
	}
	return mustVisitChild;
}
 
Example 4
Project: xmontiarc   File: DesignerHelper.java   View Source Code Vote up 5 votes
private static List<String> loadModels(IContainer container) throws CoreException {
	List<String> files = new ArrayList<String>();
	IResource[] members = container.members();
	for (IResource member : members) {
		if (member instanceof IContainer) {
			files.addAll(loadModels((IContainer) member));
		} else if (member instanceof IFile) {
			if (member.getFileExtension() != null && member.getFileExtension().equals("xmontiarc")) {
				String path = member.getFullPath().toOSString();
				files.add(path);
			}
		}
	}
	return files;
}