Class Problem

java.lang.Object
com.amalgamasimulation.validation.Problem

public class Problem extends Object
One problem found by a check: its severity, the model object, the text for the user, and the tab of the property panel.

Usually Checks creates the problem. It takes the severity and the tab from its own settings (Checks.warnings(), Checks.onTab(String)) and the text from the message of the check. Code can also create a problem directly and then pass it to Checks.report(Problem) or ValidationResult.add(Problem).

An application can extend this class to give extra data to the UI. For example, a subclass keeps the scenario graph, and the UI uses it to show the unreachable nodes. Only the constructor sets the fields of this class, and they do not change later.

AbstractProblemsPart uses the fields as follows:

  • the severity selects the group: errors or warnings;
  • the object sets the group by object type, and a double click selects this object in the tree, in the table and in the property panel;
  • the tab: after a double click, the property panel opens the tab with this title.

If the object is null, the part shows the problem directly under its severity, without a group, and a double click does nothing. If the tab is null, or the property panel has no tab with this title, the panel keeps the current tab.

The class does not override equals and hashCode: two problems with equal fields are different objects.

  • Constructor Details

    • Problem

      public Problem(Problem.Severity severity, org.eclipse.emf.ecore.EObject object, String message, String tab)
      Creates a problem.
      Parameters:
      severity - the severity of the problem, not null
      object - the model object of the problem; null if the problem is about the whole scenario and not about one object
      message - the text for the user in the current language; usually it contains the label of the field
      tab - the title of the property panel tab where the user can fix the problem; null if the tab must not change
  • Method Details

    • getSeverity

      public Problem.Severity getSeverity()
      Returns the severity of the problem.
      Returns:
      the severity, not null
    • getObject

      public org.eclipse.emf.ecore.EObject getObject()
      Returns the model object of the problem.
      Returns:
      the object, or null
    • getMessage

      public String getMessage()
      Returns the text of the problem for the user.
      Returns:
      the text in the language that was current when the problem was created
    • getTab

      public String getTab()
      Returns the title of the property panel tab.
      Returns:
      the title, or null
    • toString

      public String toString()
      Returns the text of the problem, the same as getMessage().
      Overrides:
      toString in class Object
      Returns:
      the text of the problem