1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import org.eclipse.core.commands.operations.IUndoableOperation; 19 import org.eclipse.core.resources.IMarker; 20 import org.eclipse.jface.viewers.ISelectionProvider; 21 import org.eclipse.jface.viewers.IStructuredSelection; 22 import org.eclipse.ui.ide.undo.UpdateMarkersOperation; 23 24 28 public class ActionMarkCompleted extends MarkerSelectionProviderAction { 29 30 35 public ActionMarkCompleted(ISelectionProvider provider) { 36 super(provider, MarkerMessages.markCompletedAction_title); 37 setEnabled(false); 38 } 39 40 45 public void run() { 46 IMarker[] markers = getSelectedMarkers(); 47 Map attrs = new HashMap (); 48 attrs.put(IMarker.DONE, Boolean.TRUE); 49 IUndoableOperation op = new UpdateMarkersOperation(markers, attrs, 50 getText(), true); 51 execute(op, getText(), null, null); 52 53 } 54 55 60 public void selectionChanged(IStructuredSelection selection) { 61 setEnabled(false); 62 if (selection == null || selection.isEmpty()) { 63 return; 64 } 65 for (Iterator iterator = selection.iterator(); iterator.hasNext();) { 66 Object obj = iterator.next(); 67 if (!(obj instanceof ConcreteMarker)) { 68 return; 69 } 70 IMarker marker = ((ConcreteMarker) obj).getMarker(); 71 if (!marker.getAttribute(IMarker.USER_EDITABLE, true)) { 72 return; 73 } 74 if (marker.getAttribute(IMarker.DONE, false)) { 75 return; 76 } 77 } 78 setEnabled(true); 79 } 80 } 81 | Popular Tags |