本文整理匯總了Java中org.eclipse.core.resources.IFolder.create方法的典型用法代碼示例。如果您正苦於以下問題:Java IFolder.create方法的具體用法?Java IFolder.create怎麽用?Java IFolder.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFolder
的用法示例。
在下文中一共展示了IFolder.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createManifest
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private void createManifest(String projectName, String string) throws CoreException, UnsupportedEncodingException {
IProject project = workspace.getProject(projectName);
IFile manifestFile = project.getFile(IN4JSProject.N4MF_MANIFEST);
@SuppressWarnings("resource")
StringInputStream content = new StringInputStream(string, Charsets.UTF_8.name());
manifestFile.create(content, false, null);
manifestFile.setCharset(Charsets.UTF_8.name(), null);
IFolder src = project.getFolder("src");
src.create(false, true, null);
IFolder sub = src.getFolder("sub");
sub.create(false, true, null);
IFolder leaf = sub.getFolder("leaf");
leaf.create(false, true, null);
src.getFile("A.js").create(new ByteArrayInputStream(new byte[0]), false, null);
src.getFile("B.js").create(new ByteArrayInputStream(new byte[0]), false, null);
sub.getFile("B.js").create(new ByteArrayInputStream(new byte[0]), false, null);
sub.getFile("C.js").create(new ByteArrayInputStream(new byte[0]), false, null);
leaf.getFile("D.js").create(new ByteArrayInputStream(new byte[0]), false, null);
}
示例2: createTestProject
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Creates a project with two files.
*/
@SuppressWarnings("resource")
@BeforeClass
public static void createTestProject() throws Exception {
staticProject = ProjectUtils.createJSProject(PROJECT_NAME);
IFolder path = staticProject.getFolder("src").getFolder("path");
path.create(true, true, null);
IFile libFile = path.getFile("Libs.n4js");
libFile.create(new StringInputStream(
"export public class MyFirstClass {} export public class MySecondClass {} class MyHiddenClass {}",
libFile.getCharset()), true, monitor());
IFile moreLibFile = path.getFile("MoreLibs.n4js");
moreLibFile.create(new StringInputStream(
"export public class MoreLibFirstClass {} export public class MoreLibSecondClass {}",
moreLibFile.getCharset()), true, monitor());
IFile testFile = path.getFile("Test.n4js");
testFile.create(new StringInputStream("", testFile.getCharset()), true, monitor());
addNature(staticProject, XtextProjectHelper.NATURE_ID);
ProjectUtils.waitForAutoBuild();
}
示例3: doFinish
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private void doFinish(IPath containerPath, String[] path, IProgressMonitor monitor) throws CoreException {
monitor.beginTask("Creating package " + String.join(".", path), path.length);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(containerPath);
if (!resource.exists() || !(resource instanceof IContainer)) {
throwCoreException("Container \"" + containerPath + "\" does not exist.");
}
IContainer container = (IContainer) resource;
for(int i = 0; i < path.length; i++) {
Path p = new Path(path[i]);
final IFolder folder = container.getFolder(p);
if(!folder.exists())
folder.create(true, false, monitor);
container = container.getFolder(p);
monitor.worked(1);
}
}
示例4: createSchema
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
static IFolder createSchema(String name, boolean open, IProject project) throws CoreException {
IFolder projectFolder = project.getFolder(DbObjType.SCHEMA.name());
if (!projectFolder.exists()) {
projectFolder.create(false, true, null);
}
IFolder schemaFolder = projectFolder.getFolder(name);
if (!schemaFolder.exists()) {
schemaFolder.create(false, true, null);
}
IFile file = projectFolder.getFile(name + POSTFIX);
if (!file.exists()) {
StringBuilder sb = new StringBuilder();
sb.append(MessageFormat.format(PATTERN, DbObjType.SCHEMA, name));
sb.append(MessageFormat.format(OWNER_TO, DbObjType.SCHEMA, name));
file.create(new ByteArrayInputStream(sb.toString().getBytes()), false, null);
}
if (open) {
openFileInEditor(file);
}
return schemaFolder;
}
示例5: processFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
public static void processFile ( final IContainer parent, final Definition definition, final Profile profile, final IProgressMonitor monitor ) throws Exception
{
monitor.beginTask ( makeJobLabel ( definition, profile ), 100 );
final IFolder output = parent.getFolder ( new Path ( "output" ) ); //$NON-NLS-1$
if ( output.exists () )
{
output.delete ( true, new SubProgressMonitor ( monitor, 9 ) );
}
output.create ( true, true, new SubProgressMonitor ( monitor, 1 ) );
final Builder builder = new Builder ( definition, profile );
final Recipe recipe = builder.build ();
try
{
final Map<String, Object> initialContent = new HashMap<String, Object> ();
initialContent.put ( "output", output ); //$NON-NLS-1$
recipe.execute ( initialContent, new SubProgressMonitor ( monitor, 90 ) );
}
finally
{
monitor.done ();
}
}
示例6: createFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param projectname
* @param destFolder
* @param filename
* @param content
* @throws CoreException
*/
public static IFile createFile(String projectname, String destFolder, String pkg, String filename, String content)
throws CoreException {
IProject project = getProject(projectname);
IFolder folder = project.getFolder(new Path(destFolder));
if (!folder.exists())
folder.create(true, true, null);
IFolder container = folder;
if (pkg != null) {
StringTokenizer st = new StringTokenizer(pkg, "/");
while (st.hasMoreTokens()) {
String dir = st.nextToken();
IFolder f = container.getFolder(new Path(dir));
if (!f.exists()) {
f.create(true, true, null);
}
container = f;
}
}
IFile newFile = container.getFile(new Path(filename));
newFile.create(new ByteArrayInputStream(content.getBytes()), true, null);
return newFile;
}
示例7: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
public static void createFolder(String path, IProject project, IProgressMonitor monitor) throws CoreException {
String[] strings = path.split("/");
IContainer currentContainer = project;
for ( String s : strings ) {
IFolder folder = currentContainer.getFolder( new Path(s) );
folder.create(true, true, monitor);
currentContainer = folder;
}
}
示例8: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/***/
protected IFolder createFolder(IFolder superFolder, String path) throws CoreException {
IFolder folder = superFolder.getFolder(path);
if (!folder.exists()) {
createParentFolder(folder);
folder.create(true, true, null);
}
return folder;
}
示例9: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* Create recursively folders in the project.
* Do nothing if folder already exists.
* @param project
* @param path
* @param monitor
* @return
* @throws CoreException
*/
public static IFolder createFolder(IProject project, IPath path, IProgressMonitor monitor) throws CoreException {
IFolder folder = project.getFolder(path);
if (!folder.exists()) {
if (path.segmentCount() > 1) {
IPath currentFolderPath = new Path("");
for (int i=0; i<path.segmentCount()-1; i++) {
currentFolderPath = currentFolderPath.append(path.segment(i));
createFolder(project, currentFolderPath, monitor);
}
}
folder.create(true, true, monitor);
}
return folder;
}
示例10: createArchive
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private void createArchive(String projectName) throws CoreException, IOException {
IProject project = workspace.getProject(projectName);
IFolder libFolder = project.getFolder(LIB_FOLDER_NAME);
libFolder.create(false, true, null);
IFile archiveFile = libFolder.getFile(host.archiveProjectId + ".nfar");
ByteArrayOutputStream byteArrayOutputSteam = new ByteArrayOutputStream();
final ZipOutputStream zipOutputStream = new ZipOutputStream(byteArrayOutputSteam);
zipOutputStream.putNextEntry(new ZipEntry("src/A.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/B.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/B.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/C.js"));
zipOutputStream.putNextEntry(new ZipEntry("src/sub/leaf/D.js"));
zipOutputStream.putNextEntry(new ZipEntry(IN4JSProject.N4MF_MANIFEST));
// this will close the stream
CharStreams.write("ProjectId: " + host.archiveProjectId + "\n" +
"ProjectType: library\n" +
"ProjectVersion: 0.0.1-SNAPSHOT\n" +
"VendorId: org.eclipse.n4js\n" +
"VendorName: \"Eclipse N4JS Project\"\n" +
"Libraries { \"" + LIB_FOLDER_NAME + "\"\n }\n" +
"Output: \"src-gen\"" +
"Sources {\n" +
" source { " +
" \"src\"\n" +
" }\n" +
"}\n", CharStreams.newWriterSupplier(new OutputSupplier<ZipOutputStream>() {
@Override
public ZipOutputStream getOutput() throws IOException {
return zipOutputStream;
}
}, Charsets.UTF_8));
archiveFile.create(new ByteArrayInputStream(byteArrayOutputSteam.toByteArray()), false, null);
host.setArchiveFileURI(URI.createPlatformResourceURI(archiveFile.getFullPath().toString(), true));
}
示例11: createTemprarySourceFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private IPath createTemprarySourceFolder(){
IPath tempSrcFolder=new Path(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
IFolder folder=BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject().getFolder(tempSrcFolder);
try {
if(!folder.exists()){
folder.create(true, true,null);
}
} catch (CoreException e) {
LOGGER.error("CoreException occurred while creating temporary source folder",e);
return null;
}
LOGGER.debug("Created temporary build path at "+PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER);
return folder.getFullPath();
}
示例12: fullBuild
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
protected void fullBuild(IProgressMonitor monitor) throws CoreException{
Visuflow.getDefault().getLogger().info("Build Start");
String targetFolder = "sootOutput";
IJavaProject project = JavaCore.create(getProject());
IResourceDelta delta = getDelta(project.getProject());
if (delta == null || !delta.getAffectedChildren()[0].getProjectRelativePath().toString().equals(targetFolder)) {
classpath = getSootCP(project);
String location = GlobalSettings.get("Target_Path");
IFolder folder = project.getProject().getFolder(targetFolder);
// at this point, no resources have been created
if (!folder.exists()) {
// Changed to force because of bug id vis-119
folder.create(IResource.FORCE, true, monitor);
} else {
for (IResource resource : folder.members()) {
resource.delete(IResource.FORCE, monitor);
}
}
classpath = location + classpath;
String[] sootString = new String[] { "-cp", classpath, "-exclude", "javax", "-allow-phantom-refs", "-no-bodies-for-excluded", "-process-dir",
location, "-src-prec", "only-class", "-w", "-output-format", "J", "-keep-line-number", "-output-dir",
folder.getLocation().toOSString()/* , "tag.ln","on" */ };
ICFGStructure icfg = new ICFGStructure();
JimpleModelAnalysis analysis = new JimpleModelAnalysis();
analysis.setSootString(sootString);
List<VFClass> jimpleClasses = new ArrayList<>();
try {
analysis.createICFG(icfg, jimpleClasses);
fillDataModel(icfg, jimpleClasses);
} catch(Exception e) {
logger.error("Couldn't execute analysis", e);
}
folder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
示例13: createProjectScriptFile
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
private IEditorInput createProjectScriptFile(String content, String filename) throws CoreException, IOException {
Log.log(Log.LOG_INFO, "Creating file " + filename); //$NON-NLS-1$
IProject iProject = proj.getProject();
IFolder folder = iProject.getFolder(PROJ_PATH.MIGRATION_DIR);
if (!folder.exists()){
folder.create(IResource.NONE, true, null);
}
IFile file = folder.getFile(filename + ".sql"); //$NON-NLS-1$
InputStream source = new ByteArrayInputStream(content.getBytes(proj.getProjectCharset()));
file.create(source, IResource.NONE, null);
return new FileEditorInput(iProject.getFile(file.getProjectRelativePath()));
}
示例14: createFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor)
throws CoreException {
if (!folder.exists()) {
IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent, force, local, new NullProgressMonitor());
}
folder.create(force, local, monitor);
}
}
示例15: ensureFolder
import org.eclipse.core.resources.IFolder; //導入方法依賴的package包/類
/**
* @param folder
* @throws CoreException
*/
public static void ensureFolder(IFolder folder) throws CoreException {
if (!folder.exists()) {
ensureFolder((IFolder) folder.getParent());
folder.create(false, false, null);
}
}