org.eclipse.ocl.examples.impactanalyzer.editor
Class RevalidateAction
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.emf.edit.ui.action.ValidateAction
org.eclipse.ocl.examples.impactanalyzer.editor.RevalidateAction
- All Implemented Interfaces:
- org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelectionChangedListener
public class RevalidateAction
- extends org.eclipse.emf.edit.ui.action.ValidateAction
Validates a specific constraint on one or more of the context elements that are instance of the constaint's context class or a
subclass thereof.
There are Diagnostic
objects maintained as errors
and warnings
of an EMF resource, and IMarker
objects managed by IResource
s and stored persistently in the
workspace, representing validation errors. MarkerHelper
and its subclasses can turn Diagnostic
objects into
IMarker
s which form the basis for the problem view display. A MarkerHelper
is used to create markers
from Diagnostic
objects. Specializations of MarkerHelper
can annotate the markers with additional
information stored, e.g., in Diagnostic.getData()
and storing them in attributes
of the marker. By default, this process is triggered in the updateProblemIndication
method of a generated EMF
sample editor, where first all markers for the entire ResourceSet
(this seems too broad a scope) are deleted and then
created again based on the Diagnostic
s returned from Resource.getErrors()
and Resource.getWarnings()
for the resources contained by the editing domain's resource set.
EMF resources, upon loading, don't perform any constraint validation. Therefore, their errors and warnings list turns out empty
by default. Filling those has to happen by explicitly performing a ValidateAction
on selected resources or individual
elements. Only then will a Diagnostician
be used to fetch the EValidator
from the validator registry with which
a validation is performed on a single EObject
. Such a validation run will produce Diagnostic
objects which the
ValidateAction
then converts into IMarker
s again. Note that these Diagnostic
objects are not
entered into the errors/warnings of the Resource
on which the validation happened.
When a change Notification
triggers this revalidation action, the constraint is re-evaluated on the context objects
determined by the OCL Impact Analysis
. For any constraint which now evaluates to true
, any
existing Diagnostic
needs to be removed. FOr any constraint evaluating to false
a Diagnostic
object needs to be created, and an IMarker
needs to be created and displayed in the problem view.
During re-validation, the resources of other objects on which to evaluate the constraint may be loaded into the surrounding
editing domain's resource set. Markers are managed by a MarkerManager
which persistently stores markers in the
workspace, keyed by the resources to which they belong.
- Author:
- Axel Uhl (D043530)
Nested classes/interfaces inherited from class org.eclipse.emf.edit.ui.action.ValidateAction |
org.eclipse.emf.edit.ui.action.ValidateAction.EclipseResourcesUtil |
Fields inherited from class org.eclipse.emf.edit.ui.action.ValidateAction |
domain, eclipseResourcesUtil, selectedObjects, selectionProvider |
Fields inherited from interface org.eclipse.jface.action.IAction |
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT |
Method Summary |
protected java.lang.String |
composeMessage(org.eclipse.emf.common.util.Diagnostic diagnostic,
org.eclipse.emf.common.util.Diagnostic parentDiagnostic)
|
protected void |
createMarkers(org.eclipse.core.resources.IResource resource,
org.eclipse.emf.common.util.Diagnostic diagnostic,
org.eclipse.emf.common.util.Diagnostic parentDiagnostic)
|
void |
run()
|
Methods inherited from class org.eclipse.emf.edit.ui.action.ValidateAction |
createDiagnostician, handleDiagnostic, selectionChanged, setActiveWorkbenchPart, updateSelection, validate |
Methods inherited from class org.eclipse.jface.action.Action |
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, runWithEvent, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText |
Methods inherited from class org.eclipse.jface.action.AbstractAction |
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener |
Methods inherited from class org.eclipse.core.commands.common.EventManager |
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.jface.action.IAction |
addPropertyChangeListener, removePropertyChangeListener |
RevalidateAction
public RevalidateAction(java.lang.String constraintName,
java.util.Collection<org.eclipse.emf.ecore.EObject> contextObjects,
OCLExpression invariant,
OCLFactory oclFactory,
OppositeEndFinder oppositeEndFinder)
run
public void run()
- Specified by:
run
in interface org.eclipse.jface.action.IAction
- Overrides:
run
in class org.eclipse.emf.edit.ui.action.ValidateAction
composeMessage
protected java.lang.String composeMessage(org.eclipse.emf.common.util.Diagnostic diagnostic,
org.eclipse.emf.common.util.Diagnostic parentDiagnostic)
createMarkers
protected void createMarkers(org.eclipse.core.resources.IResource resource,
org.eclipse.emf.common.util.Diagnostic diagnostic,
org.eclipse.emf.common.util.Diagnostic parentDiagnostic)
throws org.eclipse.core.runtime.CoreException
- Throws:
org.eclipse.core.runtime.CoreException