1 11 package org.eclipse.ui.internal.ide.actions; 12 13 import org.eclipse.core.resources.IWorkspace; 14 import org.eclipse.core.resources.IWorkspaceDescription; 15 import org.eclipse.core.resources.ResourcesPlugin; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.jface.action.Action; 18 import org.eclipse.jface.dialogs.ErrorDialog; 19 import org.eclipse.ui.IWorkbenchWindow; 20 import org.eclipse.ui.actions.ActionFactory; 21 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 22 23 26 public class ToggleAutoBuildAction extends Action implements 27 ActionFactory.IWorkbenchAction { 28 private IWorkbenchWindow window; 29 30 34 public ToggleAutoBuildAction(IWorkbenchWindow window) { 35 super(IDEWorkbenchMessages.Workbench_buildAutomatically); 36 this.window = window; 37 setChecked(ResourcesPlugin.getWorkspace().isAutoBuilding()); 38 } 39 40 43 public void dispose() { 44 } 46 47 50 public void run() { 51 IWorkspace workspace = ResourcesPlugin.getWorkspace(); 52 IWorkspaceDescription description = workspace.getDescription(); 53 description.setAutoBuilding(!description.isAutoBuilding()); 54 try { 55 workspace.setDescription(description); 56 } catch (CoreException e) { 57 ErrorDialog.openError(window.getShell(), null, null, e.getStatus()); 58 } 59 } 60 } 61 | Popular Tags |