use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class RenamePackageTest method test1.
//-------
@Test
public void test1() throws Exception {
fIsPreDeltaTest = true;
RenamePackageProcessor proc = helper2(new String[] { "r" }, new String[][] { { "A" } }, "p1");
IJavaElementMapper jm = (IJavaElementMapper) proc.getAdapter(IJavaElementMapper.class);
IResourceMapper rm = (IResourceMapper) proc.getAdapter(IResourceMapper.class);
IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
IJavaProject project = getRoot().getJavaProject();
IFile _project = project.getProject().getFile(".project");
checkMappingUnchanged(jm, rm, new Object[] { project, _project, getRoot(), getPackageP(), getRoot().getPackageFragment("inexistent"), getRoot().getPackageFragment("r.inexistent"), getRoot().getPackageFragment("p1.inexistent") });
IPackageFragment r = getRoot().getPackageFragment("p1");
ICompilationUnit r_A = r.getCompilationUnit("A.java");
IType r_A_A = r_A.getType("A");
IField r_A_A_a = r_A_A.getField("a");
IPackageFragment p1 = getRoot().getPackageFragment("p1");
ICompilationUnit p1_A = p1.getCompilationUnit("A.java");
IType p1_A_A = p1_A.getType("A");
IField p1_A_A_a = p1_A_A.getField("a");
checkMappingChanged(jm, rm, new Object[][] { { r, p1 }, { r_A, p1_A }, { r_A_A, p1_A_A }, { r_A_A_a, p1_A_A_a } });
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class RenamePackageTest method helperProjectsPrgTest.
/**
* 2 Projects with a root each: Project RenamePack2 (root: srcTest) requires project RenamePack1
* (root: srcPrg).
*
* @param packageNames package names per root
* @param newPackageName the new package name for packageNames[0][0]
* @param cuNames cu names per package
* @throws Exception if one of the resources cannot be created
*/
private void helperProjectsPrgTest(String[][] packageNames, String newPackageName, String[][][] cuNames) throws Exception {
IJavaProject projectPrg = null;
IJavaProject projectTest = null;
try {
projectPrg = JavaProjectHelper.createJavaProject("RenamePack1", "bin");
assertNotNull(JavaProjectHelper.addRTJar(projectPrg));
IPackageFragmentRoot srcPrg = JavaProjectHelper.addSourceContainer(projectPrg, "srcPrg");
Map optionsPrg = projectPrg.getOptions(false);
JavaProjectHelper.set15CompilerOptions(optionsPrg);
projectPrg.setOptions(optionsPrg);
projectTest = JavaProjectHelper.createJavaProject("RenamePack2", "bin");
assertNotNull(JavaProjectHelper.addRTJar(projectTest));
IPackageFragmentRoot srcTest = JavaProjectHelper.addSourceContainer(projectTest, "srcTest");
Map optionsTest = projectTest.getOptions(false);
JavaProjectHelper.set15CompilerOptions(optionsTest);
projectTest.setOptions(optionsTest);
JavaProjectHelper.addRequiredProject(projectTest, projectPrg);
helperMultiProjects(new IPackageFragmentRoot[] { srcPrg, srcTest }, packageNames, newPackageName, cuNames);
} finally {
JavaProjectHelper.delete(projectPrg);
JavaProjectHelper.delete(projectTest);
}
}
use of org.eclipse.jdt.core.IJavaProject in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getSrcRootLocation.
/**
* Get the path of .JAVA/src
*
* @throws Exception
*/
protected IPath getSrcRootLocation() throws Exception {
ITalendProcessJavaProject talendProcessJavaProject = RepositoryPlugin.getDefault().getRunProcessService().getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
//$NON-NLS-1$
return new Path("");
}
IProject project = talendProcessJavaProject.getProject();
IJavaProject javaProject = talendProcessJavaProject.getJavaProject();
IPackageFragmentRoot[] pp = javaProject.getAllPackageFragmentRoots();
IPackageFragmentRoot src = null;
for (IPackageFragmentRoot root : pp) {
if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
src = root;
break;
}
}
IPath root = project.getParent().getLocation();
root = root.append(src.getPath());
return root;
}
use of org.eclipse.jdt.core.IJavaProject in project tdi-studio-se by Talend.
the class TalendProcessJavaProjectTest method testGetJavaProject.
/**
* Test method for {@link org.talend.designer.runprocess.java.TalendProcessJavaProject#getJavaProject()}.
*/
@Test
public void testGetJavaProject() {
IJavaProject javaProject = talendJavaProject.getJavaProject();
Assert.assertNotNull(javaProject);
Assert.assertTrue(javaProject.exists());
Assert.assertTrue(javaProject.isOpen());
Assert.assertNotNull(javaProject.getProject());
}
use of org.eclipse.jdt.core.IJavaProject in project tdi-studio-se by Talend.
the class AddPackageDialog method getPackageFragments.
/**
* Gets the package fragments.
*
* @param javaModel The java model
* @return The package fragments
*/
private Object[] getPackageFragments(IJavaModel javaModel) {
Set<String> packageElements = new HashSet<String>();
IJavaProject[] projects;
try {
projects = javaModel.getJavaProjects();
} catch (JavaModelException e) {
Activator.log(IStatus.ERROR, Messages.getJavaModelFailedMsg, e);
return new Object[0];
}
for (IJavaProject project : projects) {
if (EXTERNAL_PLUGIN_LIBRARIES.equals(project.getResource().getName())) {
continue;
}
IPackageFragmentRoot[] packageFragmentRoots;
try {
packageFragmentRoots = project.getPackageFragmentRoots();
} catch (JavaModelException e) {
continue;
}
for (IPackageFragmentRoot packageFragment : packageFragmentRoots) {
try {
addPackage(packageElements, packageFragment);
} catch (JavaModelException e) {
// do nothing
}
}
}
for (Object packageName : filteringPackages) {
packageElements.remove(packageName);
}
return packageElements.toArray(new String[0]);
}
Aggregations