1 11 12 package org.eclipse.ui.ide.undo; 13 14 import java.util.Map ; 15 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.core.runtime.CoreException; 18 import org.eclipse.core.runtime.IAdaptable; 19 import org.eclipse.core.runtime.IProgressMonitor; 20 import org.eclipse.core.runtime.IStatus; 21 import org.eclipse.core.runtime.NullProgressMonitor; 22 import org.eclipse.ui.internal.ide.undo.MarkerDescription; 23 import org.eclipse.ui.internal.ide.undo.UndoMessages; 24 25 36 public class CreateMarkersOperation extends AbstractMarkersOperation { 37 38 54 public CreateMarkersOperation(String type, Map attributes, 55 IResource resource, String name) { 56 super(null, new MarkerDescription[] { new MarkerDescription(type, 57 attributes, resource) }, null, name); 58 } 59 60 76 public CreateMarkersOperation(String [] types, Map [] attributes, 77 IResource[] resources, String name) { 78 super(null, null, null, name); 79 MarkerDescription[] markersToCreate = new MarkerDescription[attributes.length]; 80 for (int i = 0; i < markersToCreate.length; i++) { 81 markersToCreate[i] = new MarkerDescription(types[i], attributes[i], 82 resources[i]); 83 } 84 setMarkerDescriptions(markersToCreate); 85 } 86 87 103 public CreateMarkersOperation(String type, Map [] attributes, 104 IResource[] resources, String name) { 105 super(null, null, null, name); 106 MarkerDescription[] markersToCreate = new MarkerDescription[attributes.length]; 107 for (int i = 0; i < markersToCreate.length; i++) { 108 markersToCreate[i] = new MarkerDescription(type, attributes[i], 109 resources[i]); 110 } 111 setMarkerDescriptions(markersToCreate); 112 } 113 114 122 protected void doExecute(IProgressMonitor monitor, IAdaptable info) 123 throws CoreException { 124 if (monitor == null) { 125 monitor = new NullProgressMonitor(); 126 } 127 monitor.beginTask("", 100); monitor.setTaskName(UndoMessages.MarkerOperation_CreateProgress); 129 createMarkers(100, monitor); 130 monitor.done(); 131 } 132 133 141 protected void doUndo(IProgressMonitor monitor, IAdaptable info) 142 throws CoreException { 143 if (monitor == null) { 144 monitor = new NullProgressMonitor(); 145 } 146 monitor.beginTask("", 100); monitor.setTaskName(UndoMessages.MarkerOperation_DeleteProgress); 148 deleteMarkers(100, monitor); 149 monitor.done(); 150 } 151 152 159 protected IStatus getBasicUndoStatus() { 160 return getMarkerDeletionStatus(); 161 } 162 163 170 protected IStatus getBasicRedoStatus() { 171 return getMarkerCreationStatus(); 172 } 173 } 174 | Popular Tags |