Class ThreatAnalysisService
- All Implemented Interfaces:
org.eclipse.ui.IPropertyListener
-
Method Summary
Modifier and TypeMethodDescriptionvoidattachEditor(org.eclipse.ui.IWorkbenchPart editor) Registers this service as property listener on the given editor, detaching it from any previously tracked editor first so the singleton never stays subscribed to more than one editor at a time.voidclear()static ThreatAnalysisServicebooleanorg.eclipse.core.runtime.IStatusload(Resource, IWorkbenchPart)without an editor to attach.org.eclipse.core.runtime.IStatusLoad and analyse the given model resource, replacing any previous analysis.org.eclipse.core.databinding.observable.list.AbstractObservableList<? extends ObservableThreat> Map<ThreatPatternMatchMetadata, org.eclipse.viatra.query.patternlanguage.emf.util.PatternParsingResults> voidvoidpropertyChanged(Object source, int propId) voidvoidvoidvoid
-
Method Details
-
getInstance
-
attachEditor
public void attachEditor(org.eclipse.ui.IWorkbenchPart editor) Registers this service as property listener on the given editor, detaching it from any previously tracked editor first so the singleton never stays subscribed to more than one editor at a time. -
clear
public void clear() -
load
load(Resource, IWorkbenchPart)without an editor to attach. -
load
public org.eclipse.core.runtime.IStatus load(Resource resource, org.eclipse.ui.IWorkbenchPart editorToAttach) Load and analyse the given model resource, replacing any previous analysis. Must be called on the UI thread.The previous analysis is torn down synchronously (
clear()). The expensive part (cross-reference scan, engine and matcher construction, pattern parsing) then runs in a background userJobwith progress reporting. Its result is published on the UI thread, which builds the realm-bound databinding graph, starts theRiskChangeTracker, attacheseditorToAttachand notifies the listeners. A load superseded by a newer load or clear before it completes is cancelled and its engine discarded.Failures reach the user: a model that cannot be analysed at all is refused here with an error status for the caller to show; a failure in the background job becomes the job's error status, which the workbench shows and logs; a failure while publishing the result is reported through the
StatusManager.- Parameters:
resource- the model resource to analyseeditorToAttach- editor whose property changes refresh the views, attached once the load succeeded; ornull- Returns:
Status.OK_STATUSonce the load is scheduled; otherwise an error status (also logged) explaining why the model cannot be analysed
-
observableThreatList
public org.eclipse.core.databinding.observable.list.AbstractObservableList<? extends ObservableThreat> observableThreatList() -
sub
-
unSub
-
propertyChanged
- Specified by:
propertyChangedin interfaceorg.eclipse.ui.IPropertyListener
-
getResource
-
hasResults
public boolean hasResults()- Returns:
truewhile analysis results are available, i.e. between a successfulload(Resource)and the nextclear(). Before the first load, after a clear, or after a failed load there is nothing to export.
-
parseResults
public Map<ThreatPatternMatchMetadata,org.eclipse.viatra.query.patternlanguage.emf.util.PatternParsingResults> parseResults() -
patternsParsed
public void patternsParsed() -
sub
-
unSub
-