本文整理汇总了Java中org.eclipse.jdt.internal.ui.util.CoreUtility.createFolder方法的典型用法代码示例。如果您正苦于以下问题:Java CoreUtility.createFolder方法的具体用法?Java CoreUtility.createFolder怎么用?Java CoreUtility.createFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.ui.util.CoreUtility
的用法示例。
在下文中一共展示了CoreUtility.createFolder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addClassFolder
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
/**
* 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);
}
示例2: addClassFolder
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
/**
* 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);
}
示例3: testPackageRenameWithResource3
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
@Test
@Ignore
public void testPackageRenameWithResource3() throws Exception {
// regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=108019
fIsPreDeltaTest = true;
fQualifiedNamesFilePatterns = "*.txt";
String textFileName = "Textfile.txt";
String textfileContent =
getFileContents(
getTestPath() + name.getMethodName() + TEST_INPUT_INFIX + "my/pack/" + textFileName);
IFolder myPackFolder =
getRoot().getJavaProject().getProject().getFolder("my").getFolder("pack");
CoreUtility.createFolder(myPackFolder, true, true, null);
IFile textfile = myPackFolder.getFile(textFileName);
textfile.create(new ByteArrayInputStream(textfileContent.getBytes()), true, null);
helper2(new String[] {"my.pack", "my"}, new String[][] {{}, {}}, "my");
InputStreamReader reader = new InputStreamReader(textfile.getContents(true));
StringBuffer newContent = new StringBuffer();
try {
int ch;
while ((ch = reader.read()) != -1) newContent.append((char) ch);
} finally {
reader.close();
}
String definedContent =
getFileContents(
getTestPath() + name.getMethodName() + TEST_OUTPUT_INFIX + "my/" + textFileName);
assertEqualLines("invalid updating", definedContent, newContent.toString());
}
示例4: createPackageFragmentRoot
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException {
final IJavaProject project = root.getJavaProject();
if (!project.exists()) createJavaProject(project.getProject());
final IFolder folder = project.getProject().getFolder(root.getElementName());
if (!folder.exists()) CoreUtility.createFolder(folder, true, true, new NullProgressMonitor());
final List<IClasspathEntry> list = Arrays.asList(project.getRawClasspath());
list.add(JavaCore.newSourceEntry(folder.getFullPath()));
project.setRawClasspath(
list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor());
}
示例5: createPackageFragmentRoot
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
private void createPackageFragmentRoot(IPackageFragmentRoot root) throws CoreException {
final IJavaProject project= root.getJavaProject();
if (!project.exists())
createJavaProject(project.getProject());
final IFolder folder= project.getProject().getFolder(root.getElementName());
if (!folder.exists())
CoreUtility.createFolder(folder, true, true, new NullProgressMonitor());
final List<IClasspathEntry> list= Arrays.asList(project.getRawClasspath());
list.add(JavaCore.newSourceEntry(folder.getFullPath()));
project.setRawClasspath(list.toArray(new IClasspathEntry[list.size()]), new NullProgressMonitor());
}
示例6: createPackageFragmentRoot
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
public void createPackageFragmentRoot(IProgressMonitor monitor) throws CoreException, InterruptedException {
if (monitor == null) {
monitor= new NullProgressMonitor();
}
monitor.beginTask(NewWizardMessages.NewSourceFolderWizardPage_operation, 3);
try {
IPath projPath= fCurrJProject.getProject().getFullPath();
if (fOutputLocation.equals(projPath) && !fNewOutputLocation.equals(projPath)) {
if (BuildPathsBlock.hasClassfiles(fCurrJProject.getProject())) {
if (BuildPathsBlock.getRemoveOldBinariesQuery(getShell()).doQuery(false, projPath)) {
BuildPathsBlock.removeOldClassfiles(fCurrJProject.getProject());
}
}
}
String relPath= fRootDialogField.getText();
IFolder folder= fCurrJProject.getProject().getFolder(relPath);
if (!folder.exists()) {
CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));
}
if (monitor.isCanceled()) {
throw new InterruptedException();
}
fCurrJProject.setRawClasspath(fNewEntries, fNewOutputLocation, new SubProgressMonitor(monitor, 2));
fCreatedRoot= fCurrJProject.getPackageFragmentRoot(folder);
} finally {
monitor.done();
}
}
示例7: createJavaProject
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
/**
* Creates a IJavaProject.
*
* @param projectName
* The name of the project
* @param binFolderName
* Name of the output folder
* @return Returns the Java project handle
* @throws CoreException
* Project creation failed
*/
public static IJavaProject createJavaProject(String projectName, String binFolderName) throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
if (!project.exists()) {
project.create(null);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!project.isOpen()) {
project.open(null);
}
IPath outputLocation;
if (binFolderName != null && binFolderName.length() > 0) {
IFolder binFolder = project.getFolder(binFolderName);
if (!binFolder.exists()) {
CoreUtility.createFolder(binFolder, false, true, null);
}
outputLocation = binFolder.getFullPath();
} else {
outputLocation = project.getFullPath();
}
if (!project.hasNature(JavaCore.NATURE_ID)) {
addNatureToProject(project, JavaCore.NATURE_ID, null);
}
IJavaProject jproject = JavaCore.create(project);
jproject.setOutputLocation(outputLocation, null);
jproject.setRawClasspath(new IClasspathEntry[0], null);
return jproject;
}
示例8: createJavaProject
import org.eclipse.jdt.internal.ui.util.CoreUtility; //导入方法依赖的package包/类
/**
* Creates a IJavaProject.
*
* @param projectName The name of the project
* @param binFolderName Name of the output folder
* @return Returns the Java project handle
* @throws CoreException Project creation failed
*/
public static IJavaProject createJavaProject(String projectName, String binFolderName)
throws CoreException {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
if (!project.exists()) {
project.create(null);
} else {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!project.isOpen()) {
project.open(null);
}
IPath outputLocation;
if (binFolderName != null && binFolderName.length() > 0) {
IFolder binFolder = project.getFolder(binFolderName);
if (!binFolder.exists()) {
CoreUtility.createFolder(binFolder, false, true, null);
}
outputLocation = binFolder.getFullPath();
} else {
outputLocation = project.getFullPath();
}
IFolder codenvyFolder = project.getFolder(".che");
if (!codenvyFolder.exists()) {
CoreUtility.createFolder(codenvyFolder, false, true, null);
}
// if (!project.hasNature(JavaCore.NATURE_ID)) {
// addNatureToProject(project, JavaCore.NATURE_ID, null);
// }
IJavaProject jproject = JavaCore.create(project);
// jproject.setOutputLocation(outputLocation, null);
jproject.setRawClasspath(new IClasspathEntry[0], null);
IFolder folder = project.getFolder(JavaProject.INNER_DIR);
CoreUtility.createFolder(folder, true, true, null);
return jproject;
}