Class ThreatAnalysisService

java.lang.Object
be.kuleuven.cs.distrinet.sparta.analysis.service.ThreatAnalysisService
All Implemented Interfaces:
org.eclipse.ui.IPropertyListener

public class ThreatAnalysisService extends Object implements org.eclipse.ui.IPropertyListener
Analysis service for listening to changes to the model.
  • Method Details

    • getInstance

      public static ThreatAnalysisService 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

      public org.eclipse.core.runtime.IStatus load(Resource resource)
      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 user Job with progress reporting. Its result is published on the UI thread, which builds the realm-bound databinding graph, starts the RiskChangeTracker, attaches editorToAttach and 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 analyse
      editorToAttach - editor whose property changes refresh the views, attached once the load succeeded; or null
      Returns:
      Status.OK_STATUS once 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

      public void sub(AnalysisListener l)
    • unSub

      public void unSub(AnalysisListener l)
    • propertyChanged

      public void propertyChanged(Object source, int propId)
      Specified by:
      propertyChanged in interface org.eclipse.ui.IPropertyListener
    • getResource

      public Resource getResource()
    • hasResults

      public boolean hasResults()
      Returns:
      true while analysis results are available, i.e. between a successful load(Resource) and the next clear(). 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

      public void sub(PatternParseListener l)
    • unSub

      public void unSub(PatternParseListener l)