Package org.eclipse.ui.ide.undo
Class UpdateMarkersOperation
java.lang.Object
org.eclipse.core.commands.operations.AbstractOperation
org.eclipse.ui.ide.undo.AbstractWorkspaceOperation
org.eclipse.ui.ide.undo.UpdateMarkersOperation
- All Implemented Interfaces:
IAdvancedUndoableOperation,IAdvancedUndoableOperation2,IUndoableOperation
An UpdateMarkersOperation represents an undoable operation for updating one
or more markers in the workspace with one or more sets of attributes. Clients
may call the public API from a background thread.
This class is intended to be instantiated and used by clients. It is not
intended to be subclassed by clients.
- Since:
- 3.3
-
Field Summary
Fields inherited from class org.eclipse.ui.ide.undo.AbstractWorkspaceOperation
EXECUTE, quietCompute, REDO, resources, UNDO -
Constructor Summary
ConstructorsConstructorDescriptionUpdateMarkersOperation(IMarker[] markers, Map attributes, String name, boolean mergeAttributes) Create an undoable operation that updates many markers to have the same set of attributes.UpdateMarkersOperation(IMarker marker, Map attributes, String name, boolean mergeAttributes) Create an undoable operation that can update the specified marker with the specified attributes. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAppend any descriptive text to the specified string buffer to be shown in the receiver'sAbstractWorkspaceOperation.toString()text.computeExecutionStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of executing the receiver.computeRedoableStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of redoing the receiver.computeUndoableStatus(IProgressMonitor monitor) Return a status indicating the projected outcome of undoing the receiver.protected voidcreateMarkers(int work, IProgressMonitor monitor) Create markers from any currently known marker descriptions.protected voiddeleteMarkers(int work, IProgressMonitor monitor) Delete any currently known markers and save their information in marker descriptions so that they can be restored.protected voiddoExecute(IProgressMonitor monitor, IAdaptable info) Perform the specific work involved in executing this operation.protected voiddoUndo(IProgressMonitor monitor, IAdaptable info) Perform the specific work involved in undoing this operation.protected IStatusReturn a status indicating the projected outcome of redoing the marker operation.protected IStatusReturn a status indicating the projected outcome of undoing the marker operation.protected ISchedulingRuleReturn a scheduling rule appropriate for executing this operation.protected IStatusCompute the status for creating any known markers.protected IStatusCompute the status for deleting any known markers.IMarker[]Return the array of markers that has been updated or created.protected IStatusCompute the status for updating any known markers.protected ISchedulingRuleReturn a scheduling rule appropriate for undoing this operation.protected booleanReturn whether the markers known by this operation currently exist.protected voidsetMarkerDescriptions(IMarkerSnapshot[] descriptions) Set the marker descriptions that describe markers that can be created.protected voidupdateMarkers(int work, IProgressMonitor monitor, boolean mergeAttributes) Update the currently known markers with the corresponding array of marker descriptions.Methods inherited from class org.eclipse.ui.ide.undo.AbstractWorkspaceOperation
aboutToNotify, canExecute, canRedo, canUndo, execute, getAffectedObjects, getErrorStatus, getRedoSchedulingRule, getShell, getWarningStatus, getWorkspace, getWorkspaceRuleFactory, isValid, markInvalid, redo, resourcesExist, resourcesIncludesProjects, runInBackground, setModelProviderIds, setQuietCompute, setTargetResources, toString, undo, updateResourceChangeDescriptionFactoryMethods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, dispose, getContexts, getLabel, hasContext, removeContext, setLabel
-
Constructor Details
-
UpdateMarkersOperation
Create an undoable operation that can update the specified marker with the specified attributes.- Parameters:
marker- the marker to be updatedattributes- the map of attributes to be assigned to the marker. This map does not replace the attribute map of the marker, but instead, each attribute in the map is added or updated with the current value in the map. In other wordsname- the name used to describe this operationmergeAttributes-trueif the specified map of attributes for the marker is to be merged with the attributes already specified for the marker, orfalseif the specified map of attributes is to be considered a complete replacement of all attributes of the marker
-
UpdateMarkersOperation
public UpdateMarkersOperation(IMarker[] markers, Map attributes, String name, boolean mergeAttributes) Create an undoable operation that updates many markers to have the same set of attributes.- Parameters:
markers- the markers to be updatedattributes- the map of attributes to be assigned to each markername- the name used to describe this operationmergeAttributes-trueif the specified map of attributes for each marker is to be merged with the attributes already specified for that marker, orfalseif the specified map of attributes is to be considered a complete replacement of all attributes for each marker
-
-
Method Details
-
doExecute
Description copied from class:AbstractWorkspaceOperationPerform the specific work involved in executing this operation.- Specified by:
doExecutein classAbstractWorkspaceOperation- Parameters:
monitor- the progress monitor to use for the operationinfo- the IAdaptable (ornull) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is notnull, it contains an adapter for the org.eclipse.swt.widgets.Shell.class- Throws:
CoreException- propagates any CoreExceptions thrown from the resources API
-
doUndo
Description copied from class:AbstractWorkspaceOperationPerform the specific work involved in undoing this operation.- Specified by:
doUndoin classAbstractWorkspaceOperation- Parameters:
monitor- the progress monitor to use for the operationinfo- the IAdaptable (ornull) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is notnull, it contains an adapter for the org.eclipse.swt.widgets.Shell.class- Throws:
CoreException- propagates any CoreExceptions thrown from the resources API
-
getBasicUndoStatus
Return a status indicating the projected outcome of undoing the marker operation. The receiver is not responsible for remembering the result of this computation.- Returns:
- the status indicating whether the operation can be undone
-
getBasicRedoStatus
Return a status indicating the projected outcome of redoing the marker operation. The receiver is not responsible for remembering the result of this computation.- Returns:
- the status indicating whether the operation can be undone
-
deleteMarkers
Delete any currently known markers and save their information in marker descriptions so that they can be restored.- Parameters:
work- the number of work ticks to be used by the deletemonitor- the progress monitor to use for the delete- Throws:
CoreException- propagates any CoreExceptions thrown from the resources API
-
createMarkers
Create markers from any currently known marker descriptions.- Parameters:
work- the number of work ticks to be used by the createmonitor- the progress monitor to use for the create- Throws:
CoreException- propagates any CoreExceptions thrown from the resources API
-
updateMarkers
protected void updateMarkers(int work, IProgressMonitor monitor, boolean mergeAttributes) throws CoreException Update the currently known markers with the corresponding array of marker descriptions.- Parameters:
work- the number of work ticks to be used by the updatemonitor- the progress monitor to use for the updatemergeAttributes- a boolean specifying whether the attributes are merged or considered to be a replacement of the previous attributes.- Throws:
CoreException- propagates any CoreExceptions thrown from the resources API
-
setMarkerDescriptions
Set the marker descriptions that describe markers that can be created.- Parameters:
descriptions- the descriptions of markers that can be created.
-
getMarkers
Return the array of markers that has been updated or created.- Returns:
- the array of markers that have been updated or created, or
nullif no markers have been created or updated.
-
markersExist
protected boolean markersExist()Return whether the markers known by this operation currently exist.- Returns:
trueif there are existing markers andfalseif there are no known markers or any one of them does not exist
-
computeExecutionStatus
Description copied from class:AbstractWorkspaceOperationReturn a status indicating the projected outcome of executing the receiver. This method is not called by the operation history, but instead is used by clients (such as implementers ofIOperationApprover2) who wish to perform advanced validation of an operation before attempting to execute it. If an ERROR status is returned, the operation will not proceed and the user notified if deemed necessary by the caller. The validity flag on the operation should be marked as invalid. If an OK status is returned, the operation will proceed. The caller must interpret any other returned status severity, and may choose to prompt the user as to how to proceed. If there are multiple conditions that result in an ambiguous status severity, it is best for the implementor of this method to consult the user as to how to proceed for each one, and return an OK or ERROR status that accurately reflects the user's wishes, or to return a multi-status that accurately describes all of the issues at hand, so that the caller may potentially consult the user. (Note that the user should not be consulted at all if a client has calledAbstractWorkspaceOperation.setQuietCompute(boolean)with a value oftrue.) This implementation computes the validity of execution by computing the resource delta that would be generated on execution, and checking whether any registered model providers are affected by the operation.- Specified by:
computeExecutionStatusin interfaceIAdvancedUndoableOperation2- Overrides:
computeExecutionStatusin classAbstractWorkspaceOperation- Parameters:
monitor- the progress monitor to be used for computing the status- Returns:
- the status indicating the projected outcome of executing the receiver
- See Also:
-
computeUndoableStatus
Description copied from class:AbstractWorkspaceOperationReturn a status indicating the projected outcome of undoing the receiver. This method is not called by the operation history, but instead is used by clients (such as implementers ofIOperationApprover2) who wish to perform advanced validation of an operation before attempting to undo it. If an ERROR status is returned, the undo will not proceed and the user notified if deemed necessary by the caller. The validity flag on the operation should be marked as invalid. If an OK status is returned, the undo will proceed. The caller must interpret any other returned status severity, and may choose to prompt the user as to how to proceed. If there are multiple conditions that result in an ambiguous status severity, it is best for the implementor of this method to consult the user as to how to proceed for each one, and return an OK or ERROR status that accurately reflects the user's wishes, or to return a multi-status that accurately describes all of the issues at hand, so that the caller may potentially consult the user. (Note that the user should not be consulted at all if a client has calledAbstractWorkspaceOperation.setQuietCompute(boolean)with a value oftrue.) This implementation computes the validity of undo by computing the resource delta that would be generated on undo, and checking whether any registered model providers are affected by the operation.- Specified by:
computeUndoableStatusin interfaceIAdvancedUndoableOperation- Overrides:
computeUndoableStatusin classAbstractWorkspaceOperation- Parameters:
monitor- the progress monitor to be used for computing the status- Returns:
- the status indicating the projected outcome of undoing the receiver
- See Also:
-
computeRedoableStatus
Description copied from class:AbstractWorkspaceOperationReturn a status indicating the projected outcome of redoing the receiver. This method is not called by the operation history, but instead is used by clients (such as implementers ofIOperationApprover2) who wish to perform advanced validation of an operation before attempting to redo it. If an ERROR status is returned, the redo will not proceed and the user notified if deemed necessary by the caller. The validity flag on the operation should be marked as invalid. If an OK status is returned, the redo will proceed. The caller must interpret any other returned status severity, and may choose to prompt the user as to how to proceed. If there are multiple conditions that result in an ambiguous status severity, it is best for the implementor of this method to consult the user as to how to proceed for each one, and return an OK or ERROR status that accurately reflects the user's wishes, or to return a multi-status that accurately describes all of the issues at hand, so that the caller may potentially consult the user. (Note that the user should not be consulted at all if a client has calledAbstractWorkspaceOperation.setQuietCompute(boolean)with a value oftrue.) This implementation computes the validity of redo by computing the resource delta that would be generated on redo, and checking whether any registered model providers are affected by the operation.- Specified by:
computeRedoableStatusin interfaceIAdvancedUndoableOperation- Overrides:
computeRedoableStatusin classAbstractWorkspaceOperation- Parameters:
monitor- the progress monitor to be used for computing the status- Returns:
- the status indicating the projected outcome of redoing the receiver
- See Also:
-
getMarkerDeletionStatus
Compute the status for deleting any known markers. A status severity ofOKindicates that the delete is likely to be successful. A status severity ofERRORindicates that the operation is no longer valid. Other status severities are open to interpretation by the caller.- Returns:
- the status indicating the projected outcome of deleting the markers.
-
getMarkerCreationStatus
Compute the status for creating any known markers. A status severity ofOKindicates that the create is likely to be successful. A status severity ofERRORindicates that the operation is no longer valid. Other status severities are open to interpretation by the caller.- Returns:
- the status indicating the projected outcome of creating the markers.
-
getMarkerUpdateStatus
Compute the status for updating any known markers. A status severity ofOKindicates that the update is likely to be successful. A status severity ofERRORindicates that the operation is no longer valid. Other status severities are open to interpretation by the caller.- Returns:
- the status indicating the projected outcome of updating the markers.
-
getExecuteSchedulingRule
Description copied from class:AbstractWorkspaceOperationReturn a scheduling rule appropriate for executing this operation. The default implementation is to return a rule that locks out the entire workspace. Subclasses are encouraged to provide more specific rules that affect only their resources.- Overrides:
getExecuteSchedulingRulein classAbstractWorkspaceOperation- Returns:
- the scheduling rule to use when executing this operation, or
nullif there are no scheduling restrictions for this operation. - See Also:
-
getUndoSchedulingRule
Description copied from class:AbstractWorkspaceOperationReturn a scheduling rule appropriate for undoing this operation. The default implementation is to return a rule that locks out the entire workspace. Subclasses are encouraged to provide more specific rules that affect only their resources.- Overrides:
getUndoSchedulingRulein classAbstractWorkspaceOperation- Returns:
- the scheduling rule to use when undoing this operation, or
nullif there are no scheduling restrictions for this operation. - See Also:
-
appendDescriptiveText
Description copied from class:AbstractWorkspaceOperationAppend any descriptive text to the specified string buffer to be shown in the receiver'sAbstractWorkspaceOperation.toString()text.Note that this method is not intend to be subclassed by clients.
- Overrides:
appendDescriptiveTextin classAbstractWorkspaceOperation- Parameters:
text- the StringBuffer on which to append the text
-