PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/sidekick/ExpansionModel.java

#
Java | 48 lines | 20 code | 6 blank | 22 comment | 0 complexity | 451bde5fa7a973d5fde5e1e35f960ce7 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. package sidekick;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. /**
  5. * An expansion model for trees. This essentially just wraps a list of
  6. * integers that represent the row numbers in the tree that should be
  7. * expanded. It is not necessary to use this model, but it is convenient
  8. * when creating the list of row numbers. The value returned by <code>
  9. * getModel</code> is suitable for setting in the <code>expansionModel</code>
  10. * field in SideKickParsedData.
  11. */
  12. public class ExpansionModel {
  13. private List<Integer> model = new ArrayList<Integer>();
  14. private int row = 0;
  15. /**
  16. * @return The expansion model, set this in SideKickParsedData.
  17. */
  18. public List<Integer> getModel() {
  19. return model;
  20. }
  21. /**
  22. * Call this for each row in the tree that should be visible and expanded.
  23. * This will add the current row number to the model and automatically
  24. * inc().
  25. */
  26. public void add() {
  27. model.add( row );
  28. inc();
  29. }
  30. /**
  31. * Call this for each row in the tree that should be visible.
  32. */
  33. public void inc() {
  34. ++row;
  35. }
  36. /**
  37. * @return The current row value.
  38. */
  39. public int getRow() {
  40. return row;
  41. }
  42. }