Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class DefaultScheduleModel

  1. Object
  2. AbstractScheduleModel
  3. DefaultScheduleModel

ImplementsScheduleModel

A schedule held in memory, which accepts every edit.

Override updateItem, createItem or removeItem to validate a change or to send it somewhere before it is accepted.

Constructors

public DefaultScheduleModel()

Methods

public DefaultScheduleModel addResource(ScheduleResource r)
public DefaultScheduleModel removeResource(ScheduleResource r)
public DefaultScheduleModel addItem(ScheduleItem item)
public DefaultScheduleModel addItems(List<ScheduleItem> all)Adds several items and fires one change.
public DefaultScheduleModel clearItems()Removes every item and keeps the resources.
public List<ScheduleItem> getAllItems()
public ScheduleItem getItem(String id)
public DefaultScheduleModel setCreationEnabled(boolean v)Whether dragging on empty space makes an item.
public boolean isCreationEnabled()
public DefaultScheduleModel setDefaultDuration(long millis)The length of an item created by a tap, where there is no range.
public List<ScheduleResource> getResources()The resources, in the order they are shown.
public void getItems(long from, long to, List<ScheduleItem> out)Adds every item with any part inside [from, to) to out.
public boolean updateItem(ScheduleItem item, long start, long end, String resourceId)Moves or resizes an item, and gives it to another resource when resourceId differs from the one it has.
public ScheduleItem createItem(long start, long end, String resourceId)Creates an item for a range the user dragged out on empty space.
public boolean removeItem(ScheduleItem item)Removes an item.

Inherited methods

Constructor details

DefaultScheduleModel

public DefaultScheduleModel()

Method details

addResource

public DefaultScheduleModel addResource(ScheduleResource r)

removeResource

public DefaultScheduleModel removeResource(ScheduleResource r)

addItem

public DefaultScheduleModel addItem(ScheduleItem item)

addItems

public DefaultScheduleModel addItems(List<ScheduleItem> all)
Adds several items and fires one change.

clearItems

public DefaultScheduleModel clearItems()
Removes every item and keeps the resources.

getAllItems

public List<ScheduleItem> getAllItems()

getItem

public ScheduleItem getItem(String id)

setCreationEnabled

public DefaultScheduleModel setCreationEnabled(boolean v)
Whether dragging on empty space makes an item. On by default.

isCreationEnabled

public boolean isCreationEnabled()

setDefaultDuration

public DefaultScheduleModel setDefaultDuration(long millis)
The length of an item created by a tap, where there is no range.

getResources

public List<ScheduleResource> getResources()
The resources, in the order they are shown. Empty for a schedule that is one person’s.

getItems

public void getItems(long from, long to, List<ScheduleItem> out)
Adds every item with any part inside [from, to) to out.

updateItem

public boolean updateItem(ScheduleItem item, long start, long end, String resourceId)
Moves or resizes an item, and gives it to another resource when resourceId differs from the one it has.

Returns

false when the model refuses the change; the view puts the item back

createItem

public ScheduleItem createItem(long start, long end, String resourceId)
Creates an item for a range the user dragged out on empty space.

Returns

the new item, or null when the model does not create items this way

removeItem

public boolean removeItem(ScheduleItem item)
Removes an item.

Returns

false when the model refuses