stewchicken
stewchicken

Reputation: 531

How to save Eclipse project programticaly

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

Answers (1)

greg-449
greg-449

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

Related Questions