1 11 12 package org.eclipse.ui.ide.undo; 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IAdaptable; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.IStatus; 20 import org.eclipse.core.runtime.jobs.ISchedulingRule; 21 22 32 abstract class AbstractCreateResourcesOperation extends 33 AbstractResourcesOperation { 34 35 43 AbstractCreateResourcesOperation( 44 ResourceDescription[] resourceDescriptions, String label) { 45 super(resourceDescriptions, label); 46 } 47 48 57 protected void doExecute(IProgressMonitor monitor, IAdaptable uiInfo) 58 throws CoreException { 59 recreate(monitor, uiInfo); 60 } 61 62 70 protected void doUndo(IProgressMonitor monitor, IAdaptable uiInfo) 71 throws CoreException { 72 delete(monitor, uiInfo, false); } 74 75 83 protected boolean updateResourceChangeDescriptionFactory( 84 IResourceChangeDescriptionFactory factory, int operation) { 85 boolean modified = false; 86 if (operation == UNDO) { 87 for (int i = 0; i < resources.length; i++) { 88 IResource resource = resources[i]; 89 factory.delete(resource); 90 modified = true; 91 } 92 } else { 93 for (int i = 0; i < resourceDescriptions.length; i++) { 94 IResource resource = resourceDescriptions[i] 95 .createResourceHandle(); 96 factory.create(resource); 97 modified = true; 98 } 99 } 100 return modified; 101 } 102 103 108 protected ISchedulingRule getExecuteSchedulingRule() { 109 return super.computeCreateSchedulingRule(); 110 } 111 112 117 protected ISchedulingRule getUndoSchedulingRule() { 118 return super.computeDeleteSchedulingRule(); 119 } 120 121 128 public IStatus computeExecutionStatus(IProgressMonitor monitor) { 129 IStatus status = super.computeExecutionStatus(monitor); 130 if (status.isOK()) { 131 status = computeCreateStatus(true); 132 } 133 return status; 134 } 135 136 143 public IStatus computeUndoableStatus(IProgressMonitor monitor) { 144 IStatus status = super.computeUndoableStatus(monitor); 145 if (status.isOK()) { 146 status = computeDeleteStatus(); 147 } 148 return status; 149 } 150 151 158 public IStatus computeRedoableStatus(IProgressMonitor monitor) { 159 IStatus status = super.computeRedoableStatus(monitor); 160 if (status.isOK()) { 161 status = computeCreateStatus(true); 162 } 163 return status; 164 } 165 } 166 | Popular Tags |