org.mockcentral.editor.nodes.problem
Class NodeProblemManager

java.lang.Object
  extended by org.mockcentral.editor.nodes.problem.NodeProblemManager

public class NodeProblemManager
extends java.lang.Object

Utility class used to manage a list of NodeProblem objects for a specific MockCentralNode instance.

Author:
David Hutchinson

Field Summary
protected  java.util.List<NodeProblem> newProblems
           
protected  java.util.List<NodeProblem> storedProblems
           
 
Constructor Summary
NodeProblemManager(MockCentralNode node)
          Creates a new instance.
 
Method Summary
 void addNewProblem(NodeProblem nodeProblem)
          Adds a new entry to the list storing problems encountered during validation of the MockCentralNode data.
 void clearDeletedNodeProblems(MockCentralNode deletedNode)
          Removes any and all NodeProblem objects within the stored list which specify the supplied MockCentralNode as the source.
protected  void doUpdate(NodeProblem problem, boolean add)
          Adds or removes a NodeProblem from the current list and propagates the changed upward through all enclosing instances.
 NodeProblem getIndexedNodeProblem(java.lang.String elementName, int elementIndex)
          Returns the NodeProblem associated with the given element name, at the given index, if any.
static java.lang.String getMaxSeverityLabel(MockCentralNode node)
          Returns a String describing the maximum severity of any/all NodeProblem instances associated with the supplied MockCentralNode.
 java.util.List<NodeProblem> getNodeProblems()
          Returns the stored list of problems.
static NodeProblem getSeverestNodeProblem(MockCentralNode node)
          Returns the severest NodeProblem for the supplied MockCentralNode, if any.
static java.lang.String getSeverityLabel(NodeProblem nodeProblem)
          Returns a String describing the severity of the supplied NodeProblem.
 boolean isModified()
          Returns the value for whether processing the updated list of problems modified the stored list.
 boolean processUpdatedNodeProblems(boolean updateUI)
          Processes the list used to store any problems encountered during validation of the MockCentralNode data.
 void resetNewProblems()
          Clears the list used to store any problems encountered during validation of the MockCentralNode data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

storedProblems

protected java.util.List<NodeProblem> storedProblems

newProblems

protected java.util.List<NodeProblem> newProblems
Constructor Detail

NodeProblemManager

public NodeProblemManager(MockCentralNode node)
Creates a new instance.

Parameters:
node - the MockCentralNode to be updated after changes, if any.
Method Detail

getSeverityLabel

public static java.lang.String getSeverityLabel(NodeProblem nodeProblem)
Returns a String describing the severity of the supplied NodeProblem. The result is based on looking up the preference for the severity for the problem's NodeProblemCategory using the MockCentralEditorPreferences class.

Parameters:
nodeProblem - the NodeProblem.
Returns:
a string describing the severity of the supplied NodeProblem.

getSeverestNodeProblem

public static NodeProblem getSeverestNodeProblem(MockCentralNode node)
Returns the severest NodeProblem for the supplied MockCentralNode, if any. The various severity levels for different NodeProblemCategory types are set as preferences by the user.

Parameters:
node - the MockCentralNode
Returns:
the severest NodeProblem for the supplied MockCentralNode, or null if there are no problems.

getMaxSeverityLabel

public static java.lang.String getMaxSeverityLabel(MockCentralNode node)
Returns a String describing the maximum severity of any/all NodeProblem instances associated with the supplied MockCentralNode.

Parameters:
node - the MockCentralNode.
Returns:
a String describing the maximum severity of any/all NodeProblem instances associated with the supplied MockCentralNode.

resetNewProblems

public void resetNewProblems()
Clears the list used to store any problems encountered during validation of the MockCentralNode data.


addNewProblem

public void addNewProblem(NodeProblem nodeProblem)
Adds a new entry to the list storing problems encountered during validation of the MockCentralNode data.

Parameters:
nodeProblem - the entry to add.

isModified

public boolean isModified()
Returns the value for whether processing the updated list of problems modified the stored list.

Returns:
the value for whether processing the updated list of problems modified the stored list.

processUpdatedNodeProblems

public boolean processUpdatedNodeProblems(boolean updateUI)
Processes the list used to store any problems encountered during validation of the MockCentralNode data. This will update the stored list of problems and fire any changes to the list to all registered listeners.


getNodeProblems

public java.util.List<NodeProblem> getNodeProblems()
Returns the stored list of problems.

Returns:
the stored list of problems.

getIndexedNodeProblem

public NodeProblem getIndexedNodeProblem(java.lang.String elementName,
                                         int elementIndex)
Returns the NodeProblem associated with the given element name, at the given index, if any.

Parameters:
elementName - the type name of the element ("methodParam", "expectedResult", etc).
elementIndex - the index of the element within its enclosing group (refererring to, for example, the 2nd parameter to a method, or the first constructor argument).
Returns:
the NodeProblem associated with the given element name, at the given index, if any.

doUpdate

protected void doUpdate(NodeProblem problem,
                        boolean add)
Adds or removes a NodeProblem from the current list and propagates the changed upward through all enclosing instances.

Parameters:
problem - the NodeProblem.
add - whether the update represents an addition or deletion.

clearDeletedNodeProblems

public void clearDeletedNodeProblems(MockCentralNode deletedNode)
Removes any and all NodeProblem objects within the stored list which specify the supplied MockCentralNode as the source. Propagates the change upward through all enclosing instances.

Parameters:
deletedNode - the MockCentralNode.