本文整理匯總了Java中org.eclipse.core.resources.IFile.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.delete方法的具體用法?Java IFile.delete怎麽用?Java IFile.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile
的用法示例。
在下文中一共展示了IFile.delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: cleanOutput
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void cleanOutput(IProject aProject, OutputConfiguration config, IProgressMonitor monitor)
throws CoreException {
IContainer container = getContainer(aProject, config.getOutputDirectory());
if (!container.exists()) {
return;
}
if (config.isCanClearOutputDirectory()) {
for (IResource resource : container.members()) {
resource.delete(IResource.KEEP_HISTORY, monitor);
}
} else if (config.isCleanUpDerivedResources()) {
List<IFile> resources = derivedResourceMarkers.findDerivedResources(container, null);
for (IFile iFile : resources) {
iFile.delete(IResource.KEEP_HISTORY, monitor);
}
}
}
示例2: generateTestImplementation
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Generate a test implementation if it does not exist
*
* @param implementationFolder
* @param implementationFragmentRoot
* @param targetPkg
* @param interfaceCompUnit
* @param monitor
* @throws CoreException
*/
public static IFile generateTestImplementation(TestResourceGeneration provider, IProgressMonitor monitor)
throws Exception {
IFile ifile = provider.toIFile();
if (ifile.exists()) {
JDTManager.rename(ifile, monitor);
ifile.delete(true, monitor);
}
if (ifile.exists())
return null;
NewExecutionContextClassWizardPageRunner execRunner = new NewExecutionContextClassWizardPageRunner(provider,
monitor);
Display.getDefault().syncExec(execRunner);
IPath path = execRunner.getType().getPath();
IFile createdFile = (IFile) ResourceManager.getResource(path.toString());
return createdFile;
}
示例3: createFileDeleteIfExists
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Create a file in a folder with the specified name and content
*
* @param fullpath
* @param filename
* @param content
* @throws CoreException
* @throws InterruptedException
*/
public static IFile createFileDeleteIfExists(String fullpath, String filename, String content,
IProgressMonitor monitor) throws CoreException, InterruptedException {
SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
subMonitor.setTaskName("Create file delete if it exists " + fullpath);
IFile newFile;
try {
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IContainer container = (IContainer) wroot.findMember(new Path(fullpath));
newFile = container.getFile(new Path(filename));
if (newFile.exists()) {
JDTManager.rename(newFile, new NullProgressMonitor());
newFile.delete(true, new NullProgressMonitor());
}
subMonitor.split(30);
byte[] source = content.getBytes(Charset.forName("UTF-8"));
newFile.create(new ByteArrayInputStream(source), true, new NullProgressMonitor());
subMonitor.split(70);
} finally {
subMonitor.done();
}
return newFile;
}
示例4: renameFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param container
* @param filename
* @throws CoreException
*/
public static void renameFile(IContainer container, String oldName, String newName) throws CoreException {
if (oldName.equals(newName))
return;
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
renameFile((IContainer) member, oldName, newName);
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (file.getName().equals(oldName)) {
IProgressMonitor monitor = new NullProgressMonitor();
IPath path = file.getFullPath().removeLastSegments(1).append(newName);
ResourceManager.logInfo(file.getProject().getName(),
"Renaming " + file.getFullPath() + " into " + path);
file.copy(path, true, monitor);
file.delete(true, monitor);
}
}
}
}
示例5: deleteCache
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param projectName
* @param container
* @param monitor
*/
private static void deleteCache(String cachename, IContainer container, IProgressMonitor monitor) {
try {
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
deleteCache(cachename, (IContainer) member, monitor);
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (cachename.equals(file.getName())) {
file.delete(true, monitor);
}
}
}
} catch (CoreException e) {
ResourceManager.logException(e);
}
}
示例6: delete
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void delete (IFile file) {
try {
file.delete(true, new NullProgressMonitor());
while (file.exists()) {
Thread.sleep(1000);
}
} catch (Exception e) {
}
}
示例7: write
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param factory
* @param file
* @throws IOException
*/
private static List<IPath> write(ContextFactory factory, SourceFile file, boolean erase, IProgressMonitor monitor)
throws IOException {
List<IPath> ret = new ArrayList<IPath>();
List<Context> contexts = factory.create(file.getInputPath());
for (Context context : contexts) {
try {
RuntimeModel model = context.getModel();
File outfile = file.getOutputPath().toFile();
if (erase) {
IFile ifileTodelete = ResourceManager.toIFile(outfile);
if (ifileTodelete.exists()) {
ifileTodelete.delete(true, monitor);
}
}
String source = new CodeGenerator().generate(file, model);
File f = file.getOutputPath().getParent().toFile();
IFolder ifolder = ResourceManager.toIFolder(f);
ResourceManager.ensureFolder((IFolder) ifolder);
IFile ifile = ResourceManager.createFileDeleteIfExists(file.getOutputPath().toFile(), source, monitor);
ret.add(ifile.getFullPath());
} catch (Throwable t) {
ResourceManager.logException(t);
}
}
return ret;
}
示例8: deleteFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* @param filename
* @throws CoreException
*/
public static void deleteFile(IContainer container, String filename) throws CoreException {
IResource[] members = container.members();
for (IResource member : members) {
if (member instanceof IContainer) {
deleteFile((IContainer) member, filename);
} else if (member instanceof IFile) {
IFile file = (IFile) member;
if (file.getName().equals(filename)) {
file.delete(true, new NullProgressMonitor());
}
}
}
}
示例9: testCreateFileIFileIProgressMonitor
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Test
public void testCreateFileIFileIProgressMonitor() throws Exception {
IJavaProject project = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, true, true);
IFile f = ResourceManager.getIFileFromQualifiedName(project.getProject().getName(), "SimpleImpl");
f.delete(true, new NullProgressMonitor());
assertFalse(f.exists());
ResourceManager.createFile(f, new NullProgressMonitor());
assertTrue(f.exists());
}
示例10: deleteFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void deleteFile(IFile f) {
try {
Log.log(Log.LOG_INFO, "Deleting file " + f.getName()); //$NON-NLS-1$
f.delete(true, null);
} catch (CoreException ex) {
Log.log(ex);
}
}
示例11: deleteFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private void deleteFile(IFile occieFile, String extension) {
IPath ecorePath = occieFile.getFullPath().removeFileExtension().addFileExtension(extension);
IFile ecoreFile = ResourcesPlugin.getWorkspace().getRoot().getFile(ecorePath);
if(ecoreFile.exists()) {
try {
ecoreFile.delete(true, null);
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
示例12: testReferenceDeleted
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
*
* 01. Class0
* 02. Class1.field0
* 03. Class0 -> Class1.field0
* 04. delete Class1
* 05. Class0 -> Class1 import and Class1.field0 should get error marker
* 06. recreate Class1 file
* 07. Class0 should have no error markers
*/
//@formatter:on
@Test
public void testReferenceDeleted() throws Exception {
logger.info("BuilderParticipantPluginUITest.testReferenceDeleted");
// create project and test files
final IProject project = createJSProject("testReferenceBrokenToOtherClassesMethod");
IFolder folder = configureProjectWithXtext(project);
IFolder moduleFolder = createFolder(folder, TestFiles.moduleFolder());
IFile file2 = createTestFile(moduleFolder, "Class1", TestFiles.class1());
assertMarkers("File2 should have no errors", file2, 0);
IFile file1 = createTestFile(moduleFolder, "Class0", TestFiles.class0());
assertMarkers("File1 should have no errors, one unused variable warning", file1, 1);
// open editors of test files
IWorkbenchPage page = getActivePage();
XtextEditor file1XtextEditor = openAndGetXtextEditor(file1, page);
List<?> errors = getEditorErrors(file1XtextEditor);
assertEquals("Editor of Class0 should have no errors", 0, errors.size());
XtextEditor file2XtextEditor = openAndGetXtextEditor(file2, page);
errors = getEditorErrors(file2XtextEditor);
assertEquals("Editor of Class1 should have no errors", 0, errors.size());
file2.delete(true, monitor());
moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor());
waitForAutoBuild();
waitForUpdateEditorJob();
// check if editor 1 contain error markers
errors = getEditorErrors(file1XtextEditor);
// Consequential errors are omitted, so there is no error reported for unknown field, as the receiver is of
// unknown type
assertEquals("Content of editor 1 should be broken, because now linking to missing resource", 3, errors.size());
file2 = createTestFile(folder, "Class1", TestFiles.class1());
assertMarkers("File2 should have no errors", file2, 0);
// editor 1 should not contain any error markers anymore
file2 = createTestFile(moduleFolder, "Class1", TestFiles.class1());
waitForAutoBuild();
waitForUpdateEditorJob();
errors = getEditorErrors(file1XtextEditor);
assertEquals(
"Content of editor 1 should be valid again, as Class1 in editor has got the field with name 'field0' again",
0, errors.size());
}
示例13: testSuperClassDeleted
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
*
* 01. Class0 uses Class1 in require statement and in isa function
* 02. Class1 is deleted
* 05. Class0 should get error marker at require statement and at isa function
* 06. recreate Class1 file
* 07. Class0 should have no error markers
*
*/
//@formatter:on
@Test
public void testSuperClassDeleted() throws Exception {
logger.info("BuilderParticipantPluginUITest.testSuperClassDeleted");
// create project and test files
final IProject project = createJSProject("testSuperClassDeleted");
IFolder folder = configureProjectWithXtext(project);
IFolder moduleFolder = createFolder(folder, InheritanceTestFiles.inheritanceModule());
IFile parentFile = createTestFile(moduleFolder, "Parent", InheritanceTestFiles.Parent());
assertMarkers("Parent file should have no errors", parentFile, 0);
IFile childFile = createTestFile(moduleFolder, "Child", InheritanceTestFiles.Child());
assertMarkers("Child file should have no errors", childFile, 0);
// open editors of test files
IWorkbenchPage page = getActivePage();
XtextEditor parentFileXtextEditor = openAndGetXtextEditor(parentFile, page);
List<?> errors = getEditorErrors(parentFileXtextEditor);
assertEquals("Editor of parent should have no errors", 0, errors.size());
XtextEditor childFileXtextEditor = openAndGetXtextEditor(childFile, page);
errors = getEditorErrors(childFileXtextEditor);
assertEquals("Editor of child should have no errors", 0, errors.size());
parentFileXtextEditor.close(true);
parentFile.delete(true, true, monitor());
moduleFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor());
waitForAutoBuild();
waitForUpdateEditorJob();
assertFalse("Parent.n4js doesn't exist anymore", moduleFolder.getFile(new Path("Parent" + F_EXT)).exists());
errors = getEditorErrors(childFileXtextEditor);
assertEquals("Editor of child should have error markers", 3, errors.size());
IFile recreatedParentFile = createTestFile(moduleFolder, "Parent", InheritanceTestFiles.Parent());
assertMarkers("File1 should have no errors", recreatedParentFile, 0);
waitForUpdateEditorJob();
errors = getEditorErrors(childFileXtextEditor);
assertEquals("Editor of child should have no errors", 0, errors.size());
}
示例14: process
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
@Override
public void process ( final String phase, final IFolder baseDir, final IProgressMonitor monitor, final Map<String, String> properties ) throws Exception
{
if ( phase != null && !"process".equals ( phase ) )
{
return;
}
final String name = makeName ();
final IFolder output = baseDir.getFolder ( new Path ( name ) );
output.create ( true, true, null );
final IFile exporterFile = output.getFile ( "exporter.xml" ); //$NON-NLS-1$
final IFile propFile = output.getFile ( "application.properties" ); //$NON-NLS-1$
final DocumentRoot root = ExporterFactory.eINSTANCE.createDocumentRoot ();
final ConfigurationType cfg = ExporterFactory.eINSTANCE.createConfigurationType ();
root.setConfiguration ( cfg );
final HiveType hive = ExporterFactory.eINSTANCE.createHiveType ();
cfg.getHive ().add ( hive );
hive.setRef ( getHiveId () );
final HiveConfigurationType hiveCfg = ExporterFactory.eINSTANCE.createHiveConfigurationType ();
hive.setConfiguration ( hiveCfg );
addConfiguration ( hiveCfg );
for ( final Endpoint ep : this.driver.getEndpoints () )
{
addEndpoint ( hive, ep );
}
// write exporter file
new ModelWriter ( root ).store ( URI.createPlatformResourceURI ( exporterFile.getFullPath ().toString (), true ) );
exporterFile.refreshLocal ( 1, monitor );
// write application properties
if ( propFile.exists () )
{
propFile.delete ( true, monitor );
}
final Properties p = new Properties ();
fillProperties ( p );
if ( !p.isEmpty () )
{
try (FileOutputStream fos = new FileOutputStream ( propFile.getRawLocation ().toOSString () ))
{
p.store ( fos, "Created by the Eclipse SCADA world generator" );
}
propFile.refreshLocal ( 1, monitor );
}
}
示例15: clearBuildPoliciesFile
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public void clearBuildPoliciesFile(IFile buildPolicyFile) throws IOException, CoreException, InterruptedException {
buildPolicyFile.delete(true, getNullMonitor());
bot.waitUntil(new BuildPoliciesFileDoesNotExistsCondition(buildPolicyFile));
BuildPolicyManager.createBuildPoliciesFile(buildPolicyFile, getNullMonitor());
bot.waitUntil(new BuildPoliciesFileExistsCondition(buildPolicyFile));
}