Reputation: 531
I need to save project file programmatically before closing it, how can I achieve it? any hints will be more than welcome!
manually save means when the user modifies the project, usually, they have to click File->Save
List<IProject> projectList = new LinkedList<IProject>();
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = workspaceRoot.getProjects();
for(int i = 0; i < projects.length; i++) {
IProject project = projects[i];
if(project.isOpen()) {
project.close(new org.eclipse.core.runtime.NullProgressMonitor());
}
}
Upvotes: 0
Views: 122
Reputation: 111142
You can save all editors for files in a project using:
IDE.saveAllEditors(new IResource [] {project}, confirm);
where confirm
is true
if you want a confirmation prompt, false
otherwise.
IDE
is org.eclipse.ui.ide.IDE
Upvotes: 1