Class DefaultKanbanModel

java.lang.Object
com.codename1.kanban.AbstractKanbanModel
com.codename1.kanban.DefaultKanbanModel
All Implemented Interfaces:
KanbanModel

public class DefaultKanbanModel extends AbstractKanbanModel

A board kept in memory that accepts every edit.

DefaultKanbanModel model = new DefaultKanbanModel();
model.addColumn(new KanbanColumn("todo", "To do"));
model.addColumn(new KanbanColumn("doing", "Doing").setWipLimit(3));
model.addColumn(new KanbanColumn("done", "Done"));
model.addCard("todo", new KanbanCard("c1", "Write the release notes"));

Override a mutator to refuse an edit, or to send it to a server and accept it.

  • Constructor Details

    • DefaultKanbanModel

      public DefaultKanbanModel()
  • Method Details

    • getColumns

      public List<KanbanColumn> getColumns()
      Description copied from interface: KanbanModel
      The columns, in order. Do not modify the list.
    • getLanes

      public List<KanbanLane> getLanes()
      Description copied from interface: KanbanModel
      The swimlanes, in order; empty for a board without lanes. Do not modify the list.
    • isEnforceWipLimits

      public boolean isEnforceWipLimits()
      True when a card that would take a column past its limit is refused.
    • setEnforceWipLimits

      public void setEnforceWipLimits(boolean enforceWipLimits)
      Makes moveCard and insertCard refuse a card that would take a column past its limit. Off by default, when a column over its limit is only drawn as such.
    • addColumn

      public KanbanColumn addColumn(KanbanColumn column)

      Adds a column after the others.

      Throws
      • IllegalArgumentException: when a column has that id already
    • removeColumn

      public boolean removeColumn(KanbanColumn column)
      Removes a column and the cards in it.
    • addLane

      public KanbanLane addLane(KanbanLane lane)
      Adds a swimlane after the others. A board has lanes once it has one; a card in no lane, or in one that is gone, shows in the first.
    • removeLane

      public boolean removeLane(KanbanLane lane)
      Removes a lane. Its cards stay, and show in the first lane left.
    • addCard

      public KanbanCard addCard(String columnId, KanbanCard card)

      Adds a card at the end of a column, in the lane the card names. Unlike insertCard, this is the application filling the model, and no limit refuses it.

      Throws
      • IllegalArgumentException: when there is no such column, or a card has that id already
    • clear

      public void clear()
      Removes every column, lane and card.
    • newCardId

      public String newCardId()
      An id no card of the model has, for a card the user adds.
    • getCards

      public List<KanbanCard> getCards(KanbanColumn column, KanbanLane lane)
      Description copied from interface: KanbanModel
      The cards of one cell, in order: those of a column that are in a lane. lane is null on a board without lanes, and then the answer is every card of the column. Do not modify the list.
    • getCardCount

      public int getCardCount(KanbanColumn column)
      Description copied from interface: KanbanModel
      The number of cards in a column, in all its lanes.
      Specified by:
      getCardCount in interface KanbanModel
      Overrides:
      getCardCount in class AbstractKanbanModel
    • getCard

      public KanbanCard getCard(String id)
      Description copied from interface: KanbanModel
      The card with an id, or null.
      Specified by:
      getCard in interface KanbanModel
      Overrides:
      getCard in class AbstractKanbanModel
    • canMoveCard

      public boolean canMoveCard(KanbanCard card, KanbanColumn column, KanbanLane lane)
      Description copied from interface: KanbanModel
      Whether moveCard would take the card into a column. A board asks while a card is dragged over a column, to show a refusal before the card is let go.
      Specified by:
      canMoveCard in interface KanbanModel
      Overrides:
      canMoveCard in class AbstractKanbanModel
    • insertCard

      public boolean insertCard(KanbanCard card, KanbanColumn column, KanbanLane lane, int index)
      Description copied from interface: KanbanModel
      Adds a card to a cell at an index among the cell's cards; an index past the end adds it last.
      Specified by:
      insertCard in interface KanbanModel
      Overrides:
      insertCard in class AbstractKanbanModel
    • removeCard

      public boolean removeCard(KanbanCard card)
      Description copied from interface: KanbanModel
      Removes a card.
      Specified by:
      removeCard in interface KanbanModel
      Overrides:
      removeCard in class AbstractKanbanModel
    • renameCard

      public boolean renameCard(KanbanCard card, String title)
      Description copied from interface: KanbanModel
      Gives a card another title.
      Specified by:
      renameCard in interface KanbanModel
      Overrides:
      renameCard in class AbstractKanbanModel
    • moveCard

      public boolean moveCard(KanbanCard card, KanbanColumn column, KanbanLane lane, int index)
      Description copied from interface: KanbanModel
      Moves a card to an index among the cards of a cell, which may be the cell it is in. The index counts the cell without the card. A null lane is the whole column: the index counts every lane's cards, and the card keeps the lane it names.
      Specified by:
      moveCard in interface KanbanModel
      Overrides:
      moveCard in class AbstractKanbanModel
    • moveColumn

      public boolean moveColumn(KanbanColumn column, int index)
      Description copied from interface: KanbanModel
      Moves a column to an index among the columns, counted without it.
      Specified by:
      moveColumn in interface KanbanModel
      Overrides:
      moveColumn in class AbstractKanbanModel
    • setCollapsed

      public boolean setCollapsed(KanbanColumn column, boolean collapsed)
      Description copied from interface: KanbanModel
      Folds or unfolds a column.
      Specified by:
      setCollapsed in interface KanbanModel
      Overrides:
      setCollapsed in class AbstractKanbanModel
    • setLaneCollapsed

      public boolean setLaneCollapsed(KanbanLane lane, boolean collapsed)
      Description copied from interface: KanbanModel
      Folds or unfolds a lane.
      Specified by:
      setLaneCollapsed in interface KanbanModel
      Overrides:
      setLaneCollapsed in class AbstractKanbanModel