IResource dfile = ResourcesPlugin.getWorkspace().getRoot().getFile(path); dfile.create(blahblahblah, true, new NullProgressMonitor()); // obviously you don't need this, it's just an example dfile.refreshLocal(IResource.DEPTH_ZERO, null);
public void refreshFile(File f) throws Exception { String path = toLocal(f); IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember(path); if (r != null) { r.refreshLocal(IResource.DEPTH_INFINITE, null); } }
public void refreshFile(File f) throws Exception { String path = toLocal(f); IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember(path); if (r != null) { r.refreshLocal(IResource.DEPTH_INFINITE, null); } }
public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(PackagesMessages.DragAdapter_refreshing, roots.size()); MultiStatus status= createMultiStatus(); Iterator iter= roots.iterator(); while (iter.hasNext()) { IResource r= (IResource)iter.next(); try { r.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { status.add(e.getStatus()); } } if (!status.isOK()) { throw new CoreException(status); } } finally { monitor.done(); } } };
/** * Refreshes the resource hierarchy with its children. In case of failure * adds an appropriate status to the resource tree's status. */ private void safeRefresh(IResource resource) { try { resource.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException ce) { IStatus status = new ResourceStatus(IStatus.ERROR, IResourceStatus.FAILED_DELETE_LOCAL, resource.getFullPath(), Messages.refresh_refreshErr, ce); failed(status); } }
/** * Refreshes the resource hierarchy with its children. In case of failure * adds an appropriate status to the resource tree's status. */ private void safeRefresh(IResource resource) { try { resource.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException ce) { IStatus status = new ResourceStatus(IStatus.ERROR, IResourceStatus.FAILED_DELETE_LOCAL, resource.getFullPath(), Messages.refresh_refreshErr, ce); failed(status); } }
/** * Refreshes the resource hierarchy with its children. In case of failure * adds an appropriate status to the resource tree's status. */ private void safeRefresh(IResource resource) { try { resource.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); } catch (CoreException ce) { IStatus status = new ResourceStatus(IStatus.ERROR, IResourceStatus.FAILED_DELETE_LOCAL, resource.getFullPath(), Messages.refresh_refreshErr, ce); failed(status); } }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
@Override public Change perform(IProgressMonitor pm) throws CoreException { IResource created= fResourceDescription.createResource(pm); created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1)); return new DeleteResourceChange(created.getFullPath(), true); }
public Change perform(IProgressMonitor pm) throws CoreException { IResource created= fResourceDescription.createResource(pm); created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1)); if (created instanceof IFile) { return new DeleteFileChange((IFile) created, false); } else if (created instanceof IFolder) { return new DeleteFolderChange((IFolder) created, false); } else { return null; // should not happen } }
@Override public Change perform(IProgressMonitor pm) throws CoreException { IResource created= fResourceDescription.createResource(pm); created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1)); return new DeleteResourceChange(created.getFullPath(), true); }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
@Override public Change perform(IProgressMonitor pm) throws CoreException { if (fResourceState.verifyExistence(true)) { String message= Messages.format(RefactoringCoreMessages.UndoDeleteResourceChange_already_exists, BasicElementLabels.getResourceName(fResourceState.getName())); throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), message)); } IResource created= fResourceState.createResource(pm); created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1)); DeleteResourceChange change= new DeleteResourceChange(created.getFullPath(), true, false); change.setValidationMethod(ResourceChange.VALIDATE_NOT_READ_ONLY | ResourceChange.VALIDATE_NOT_DIRTY); return change; }
protected void copyResource(IResource source, IResource destination) throws CoreException { IPath destPath = destination.getFullPath(); try { source.copy(destPath, IResource.FORCE | IResource.DERIVED, null); } catch (CoreException e) { // handle the case when the source resource is deleted source.refreshLocal(0, null); if (!source.exists()) return; // source resource was deleted so skip it throw e; } Util.setReadOnly(destination, false); // just in case the original was read only }
@Override public Change perform(IProgressMonitor pm) throws CoreException { if (fResourceState.verifyExistence(true)) { String message= Messages.format(RefactoringCoreMessages.UndoDeleteResourceChange_already_exists, BasicElementLabels.getResourceName(fResourceState.getName())); throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), message)); } IResource created= fResourceState.createResource(pm); created.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(pm, 1)); DeleteResourceChange change= new DeleteResourceChange(created.getFullPath(), true, false); change.setValidationMethod(ResourceChange.VALIDATE_NOT_READ_ONLY | ResourceChange.VALIDATE_NOT_DIRTY); return change; }
private ICompilationUnit createCompilationUnit(ICompilationUnit unit) { try { unit.getResource().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor()); if (unit.getResource().exists()) { IJavaElement parent = unit.getParent(); if (parent instanceof IPackageFragment) { IPackageFragment pkg = (IPackageFragment) parent; unit = pkg.createCompilationUnit(unit.getElementName(), unit.getSource(), true, new NullProgressMonitor()); } } } catch (CoreException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return unit; }
@Override public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException { IStatus status= Resources.checkInSync(fResource); if (!status.isOK()) { boolean autoRefresh= Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false, null); if (autoRefresh) { fResource.refreshLocal(IResource.DEPTH_INFINITE, pm); status= Resources.checkInSync(fResource); } } return RefactoringStatus.create(status); }