net.sf.sdedit.diagram
Class FragmentManager

java.lang.Object
  extended by net.sf.sdedit.diagram.FragmentManager

public final class FragmentManager
extends Object

A FragmentManager is responsible for processing the fragments occurring in a diagram. During the process, the FragmentManager sets a fragment in three states, successively:

  1. open: sequence elements are added to the fragment
  2. closing: answers to included messages are still being added to the fragment
  3. finished: nothing is being added anymore

Author:
Markus Strauch

Constructor Summary
FragmentManager(Diagram diagram)
          Creates a new FragmentManager responsible for the fragments occurring in the given diagram.
 
Method Summary
 void addSequenceElement(SequenceElement elem)
          Adds the given sequence element to all open and closing fragments.
 void clearLabels()
          This method should be called when for all fragments corresponding to getFragmentLabels() there has been a Fragment object created.
 void clearSectionLabel()
          This method should be called when a new section has been just created.
 void finishFragments()
          Sets all the closing fragments into finished state.
 void finishFragmentsNotIncluding(Answer answer)
          Sets the closing fragments that do not include the message to which the given answer is the answer into finished state.
 LinkedList<String> getFragmentLabels()
          Returns the labels for the fragments for which we have already seen an open command (see DiagramDataProvider.openFragment()) but for which we have not yet created a Fragment representation.
 String getFragmentSectionLabel()
          When we have just seen the beginning of a new fragment section, this method returns its label, otherwise null.
 void openFragments()
          Creates Fragment objects for all pending fragment labels in getFragmentLabels() and adds them to the list of open fragments.
 boolean openFragmentsExist()
          Returns a flag indicating if there are fragments for which we have not seen a close command yet (see DiagramDataProvider.closeFragment()).
 boolean readFragments()
          This method uses the provider of the diagram data (see DiagramDataProvider, Diagram.getDataProvider() and takes some action if the provider says that a fragment is opened or closed, or if the beginning of a new section is specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FragmentManager

public FragmentManager(Diagram diagram)
Creates a new FragmentManager responsible for the fragments occurring in the given diagram.

Parameters:
diagram - the given diagram
Method Detail

getFragmentLabels

public LinkedList<String> getFragmentLabels()
Returns the labels for the fragments for which we have already seen an open command (see DiagramDataProvider.openFragment()) but for which we have not yet created a Fragment representation.

Returns:
the labels for the fragments for which we have already seen an open command, but for which there is not yet a Fragment object

getFragmentSectionLabel

public String getFragmentSectionLabel()
When we have just seen the beginning of a new fragment section, this method returns its label, otherwise null.

Returns:
the label of a new fragment section or null

clearLabels

public void clearLabels()
This method should be called when for all fragments corresponding to getFragmentLabels() there has been a Fragment object created. The list is cleared then.


clearSectionLabel

public void clearSectionLabel()
This method should be called when a new section has been just created.


readFragments

public boolean readFragments()
                      throws SyntaxError
This method uses the provider of the diagram data (see DiagramDataProvider, Diagram.getDataProvider() and takes some action if the provider says that a fragment is opened or closed, or if the beginning of a new section is specified.

Returns:
true if the diagram data provider currently specifies something that has to do with a fragment
Throws:
SyntaxError - if the fragment specification is syntactically wrong

openFragments

public void openFragments()
Creates Fragment objects for all pending fragment labels in getFragmentLabels() and adds them to the list of open fragments.


openFragmentsExist

public boolean openFragmentsExist()
Returns a flag indicating if there are fragments for which we have not seen a close command yet (see DiagramDataProvider.closeFragment()).

Returns:
a flag indicating if there are fragments for which we have not seen a close command

finishFragments

public void finishFragments()
Sets all the closing fragments into finished state.


finishFragmentsNotIncluding

public void finishFragmentsNotIncluding(Answer answer)
Sets the closing fragments that do not include the message to which the given answer is the answer into finished state.

Parameters:
answer - an answer

addSequenceElement

public void addSequenceElement(SequenceElement elem)
Adds the given sequence element to all open and closing fragments.

Parameters:
elem - a sequence element to be added to all open and closing fragments


Copyright © 2011. All Rights Reserved.