use of org.eclipse.core.resources.IContainer in project linuxtools by eclipse.
the class SourcesFileHyperlink method open.
/**
* Tries to open the given file name looking for it in the current directory
* and in ../SOURCES.
*
* @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
*/
@Override
public void open() {
IContainer container = original.getParent();
IResource resourceToOpen = container.findMember(fileName);
if (resourceToOpen == null) {
IResource sourcesFolder = container.getParent().findMember(// $NON-NLS-1$
"SOURCES");
resourceToOpen = ((IFolder) sourcesFolder).getFile(fileName);
}
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
if (resourceToOpen.getType() == IResource.FILE) {
IDE.openEditor(page, (IFile) resourceToOpen);
}
} catch (PartInitException e) {
SpecfileLog.logError(e);
}
}
use of org.eclipse.core.resources.IContainer in project linuxtools by eclipse.
the class OpenGCAction method getDefaultBinary.
private String getDefaultBinary(IPath file) {
IFile c = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(file);
if (c != null) {
IProject project = c.getProject();
if (project != null && project.exists()) {
IContainer folder = c.getParent();
// $NON-NLS-1$
IFile infoFile = folder.getFile(new Path("AnalysisInfo.txt"));
try {
String defaultBinaryFromUserPref = getDefaultBinaryFromUserPref(project, infoFile);
if (defaultBinaryFromUserPref != null) {
return defaultBinaryFromUserPref;
}
} catch (IOException | CoreException ex) {
// do nothing here.
}
ICProject cproject = CoreModel.getDefault().create(project);
if (cproject != null) {
try {
IBinary[] b = cproject.getBinaryContainer().getBinaries();
if (b != null && b.length > 0 && b[0] != null) {
IResource r = b[0].getResource();
return r.getLocation().toOSString();
}
} catch (CModelException e) {
}
}
}
}
// $NON-NLS-1$
return "";
}
use of org.eclipse.core.resources.IContainer in project linuxtools by eclipse.
the class DownloadPrepareSourcesTest method checkPreparedSources.
/**
* Check if the source was prepared correctly based on project layout
*
* @param project The RPM project
* @param layout The layout of the RPM project (RPMBuild or FLAT)
* @throws CoreException
*/
public void checkPreparedSources(RPMProject project, RPMProjectLayout layout) throws CoreException {
IContainer buildFolder = project.getConfiguration().getBuildFolder();
IFolder helloBuildFolder = null;
assertNotNull(buildFolder);
switch(layout) {
case RPMBUILD:
assertNotNull(buildFolder.getParent().findMember("BUILD"));
assertEquals(buildFolder.members().length, 1);
// check if the file exists under BUILD folder
helloBuildFolder = buildFolder.getFolder(new Path("hello-2.8"));
assertTrue(helloBuildFolder.exists());
// there should be some stuff within hello-2.8/ folder
assertTrue(helloBuildFolder.members().length >= 1);
break;
case FLAT:
// 4 = "hello-2.8.tar.gz" + ".project" + "hello-2.8-1.fc19.src.rpm" + "hello.spec" + "hello-2.8/"
assertEquals(buildFolder.members().length, 5);
helloBuildFolder = buildFolder.getFolder(new Path("hello-2.8"));
assertTrue(helloBuildFolder.exists());
// there should be some stuff within hello-2.8/ folder
assertTrue(helloBuildFolder.members().length >= 1);
break;
}
}
use of org.eclipse.core.resources.IContainer in project linuxtools by eclipse.
the class RPMProjectTest method testBuildPrepHelloWorld.
@Test
@Ignore
public void testBuildPrepHelloWorld() throws Exception {
// Create a project for the test
IProject testProject = root.getProject("testBuildPrepHelloWorld");
RPMProject rpmProject = importSrpm(testProject);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
rpmProject.buildPrep(bos);
// Make sure we got everything in the build directory
IContainer builddir = rpmProject.getConfiguration().getBuildFolder();
IFolder helloworldFolder = builddir.getFolder(new Path("helloworld-2"));
assertTrue(helloworldFolder.exists());
// Clean up
testProject.delete(true, true, monitor);
}
use of org.eclipse.core.resources.IContainer in project linuxtools by eclipse.
the class RPMProject method getSpecFile.
/**
* Returns the .spec file of this project.
*
* @return The .spec file or null if one is not found.
*/
public IResource getSpecFile() {
IContainer specsFolder = getConfiguration().getSpecsFolder();
IResource file = null;
SpecfileVisitor specVisitor = new SpecfileVisitor();
try {
specsFolder.accept(specVisitor);
List<IResource> installedSpecs = specVisitor.getSpecFiles();
if (installedSpecs.size() > 0) {
file = installedSpecs.get(0);
}
} catch (CoreException e) {
// ignore, failed to find .spec file.
}
return file;
}
Aggregations