Package org.vaadin.tltv.gantt
Class Gantt
java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.tltv.gantt.Gantt
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
@Tag("gantt-element")
@NpmPackage(value="tltv-gantt-element",version="1.0.30") @NpmPackage(value="tltv-timeline-element",version="1.0.20") @NpmPackage(value="date-fns",version="4.1.0") @NpmPackage(value="date-fns-tz",version="3.0.0")
@JsModule("tltv-gantt-element/dist/src/gantt-element.js")
@CssImport(value="gantt-grid.css",
themeFor="vaadin-grid")
public class Gantt
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasSize
Gantt is a component that shows Gantt chart which is by definition
a bar chart that illustrates a project schedule. It's a list of steps where
individual step can be divided in multiple substeps. Steps are movable and
resizable by mouse/touch devices and API gives control to
insert/update/remove steps programmatically. Steps are shown on a timeline
which has Day, Week and Hour resolutions. Resolution, date range, language
and timezone can be changed with the public API.
Gantt component uses 'tltv-gantt-element' and 'tltv'timeline.element' web components.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddDataChangeListener(com.vaadin.flow.component.ComponentEventListener<GanttDataChangeEvent> listener) com.vaadin.flow.shared.RegistrationaddGanttClickListener(com.vaadin.flow.component.ComponentEventListener<GanttClickEvent> listener) voidAdd step component based on the given step descriptor.voidAdd new step component based on the given step descriptor.com.vaadin.flow.shared.RegistrationaddStepClickListener(com.vaadin.flow.component.ComponentEventListener<StepClickEvent> listener) com.vaadin.flow.shared.RegistrationaddStepMoveListener(com.vaadin.flow.component.ComponentEventListener<StepMoveEvent> listener) com.vaadin.flow.shared.RegistrationaddStepResizeListener(com.vaadin.flow.component.ComponentEventListener<StepResizeEvent> listener) voidaddSteps(Collection<Step> steps) Add new step components based on the given collection of step descriptors.voidAdd new step components based on the given stream of step descriptors.voidAdd new step components based on the given varargs of step descriptors.voidaddSubStep(SubStep subStep) Add new sub step component based on the given sub step descriptor.com.vaadin.flow.component.grid.Grid<Step> buildCaptionGrid(String header) Builds a newGridinstance with a single column that renders text based on the step caption.com.vaadin.flow.component.treegrid.TreeGrid<Step> buildCaptionTreeGrid(String header) Builds a newTreeGridinstance with a single column that renders text based on the step caption.booleanReturns true if given UID matches with any existing step including sub step.booleanReturns true if givenGanttStep's UID matches with any existing step including sub step.booleanReturns true if givenStep's UID matches with any existing step excluding sub step.booleanReturns true if givenSubStep's UID matches with any existing sub step.protected <T extends GanttStep>
TensureUID(T step) Ensures that given step has UID.voidexpand(Collection<Step> items) Expands all child steps directed by the caption TreeGrid's hierarchical data source.voidexpand(Collection<Step> items, boolean expandWholeSubTree) Expands all child steps directed by the caption TreeGrid's hierarchical data source.voidExpands all child steps directed by the caption TreeGrid's hierarchical data source.voidExpands all child steps directed by the caption TreeGrid's hierarchical data source.getAnyStep(String uid) ReturnsGanttStepbyuid.com.vaadin.flow.component.grid.Grid<Step> Get captionGridinstance or null if it's not set.com.vaadin.flow.component.treegrid.TreeGrid<Step> Get captionTreeGridinstance or null if it's not set.Get end date of the timeline based on the web component'sendattribute.Get end datetime of the timeline based on the web component'sendattribute.ReturnsStepElementstream of all steps including sub steps.Return active locale based on the language tag in the web component.Get current timeline resolution.Get start date of the timeline based on the web component'sstartattribute.Get start datetime of the timeline based on the web component'sstartattribute.ReturnsStepby the UID or null if it doesn't exist.getStepElement(String uid) ReturnsStepElementbyuid.ReturnsStepElementstream excluding sub-steps.getSteps()ReturnsStepstream excluding sub-steps.Returns a list ofStepobjects excluding sub-steps.getSubStep(String uid) ReturnsSubStepby the UID or null if it doesn't exist.ReturnsStepElementstream of all sub-steps.getSubStepElements(String forStepUid) ReturnsStepElementstream for the given step UID.ReturnsSubStepstream of all sub-steps.Get currently activeTimeZonebased on the zone in the web component.protected voidhandleTreeDataAdd(com.vaadin.flow.data.provider.hierarchy.TreeData<Step> treeData, Step step) protected voidhandleTreeDataMove(com.vaadin.flow.data.provider.hierarchy.TreeData<Step> treeData, Step step) intReturns a zero based index of the given UID for a step or sub step.intReturns a zero based index of the givenStep.booleanGet month row visibility flag for the timeline based on the web component'smonthRowVisibleproperty.booleanGet boolean value of the web component'smovableStepsattribute.booleanGet boolean value of the web component'smovableStepsBetweenRowsattribute.booleanGet boolean value of the web component'sresizableStepsattribute.booleanGet value of twelve hour clock boolean flag based on the web component'stwelveHourClockattribute.booleanGet year row visibility flag for the timeline based on the web component'syearRowVisibleproperty.voidMoves given step or sub step.voidMove given existing step to the given index.voidmoveSubStep(int toIndex, SubStep subStep) Move given existing substep to the given index.voidRefresh target step element if it exists.booleanremoveAnyStep(String uid) Removes Step or sub step if it exists, based on the given UID.booleanremoveAnyStep(GanttStep step) Removes Step or sub step if it exists, based on its UID.voidRemove captionGridinstance if it exists.booleanremoveStep(Step step) Removes given Step if it exists, based on its UID.voidremoveSteps(Collection<Step> steps) Removes all given steps if they exists, based on their UIDs.voidremoveSteps(Stream<Step> steps) Removes all given steps looped through the given Stream if they exists, based on their UIDs.voidremoveSteps(Step... steps) Removes all given steps if they exists, based on their UIDs.voidsetEndDate(LocalDate endDate) Set end date of the timeline.voidsetEndDateTime(LocalDateTime endDateTime) Set end date and time of the timeline.voidvoidSetLocale.voidsetMonthRowVisible(boolean visible) voidsetMovableSteps(boolean enabled) voidsetMovableStepsBetweenRows(boolean enabled) voidsetResizableSteps(boolean enabled) voidsetResolution(Resolution resolution) Set new timeline resolution.voidsetStartDate(LocalDate startDate) Set start date of the timeline.voidsetStartDateTime(LocalDateTime startDateTime) Set start date and time of the timeline.voidsetTimeZone(TimeZone timeZone) SetTimeZone.voidsetTwelveHourClock(boolean enabled) Set value of twelve hour clock boolean flag to the web component'stwelveHourClockattribute.voidSetup component with default settings.voidvoidsetYearRowVisible(boolean visible) voidupdateSubStepsByMovedOwner(String stepUid) Updates sub step start and end dates for moved owner step.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
Gantt
public Gantt()Default contructor with default settings. Sets locale to matchComponent.getLocale().
-
-
Method Details
-
setupDefaults
public void setupDefaults()Setup component with default settings. -
setResolution
Set new timeline resolution. Allowed resolutions areResolution.Hour,Resolution.DayandResolution.Week.- Parameters:
resolution-Resolutionenum. Not null.
-
getResolution
Get current timeline resolution. Default isResolution.Day.- Returns:
Resolutionenum
-
setLocale
SetLocale. Setting locate updates locale of the web component by language tag. It also updates month names, week day names and first day of week based on theLocale.- Parameters:
locale- NewLocale. Should not be null.
-
getLocale
Return active locale based on the language tag in the web component. This may not be in sync with the application locale if it's changed withsetLocale(Locale)or if application locale is changed after constructor is called. Default constructor calls it once with application's locale read withComponent.getLocale().- Overrides:
getLocalein classcom.vaadin.flow.component.Component- Returns:
- Active
Locale
-
setTimeZone
SetTimeZone.- Parameters:
timeZone- NewTimeZone. Should not be null.
-
getTimeZone
Get currently activeTimeZonebased on the zone in the web component. Default is "Europe/London".- Returns:
- Active
TimeZone
-
setStartDate
Set start date of the timeline. Call this only withResolution.DayandResolution.Week.- Parameters:
startDate- Inclusive. Not null.invalid reference
LocaDate
-
setStartDateTime
Set start date and time of the timeline. Call this only withResolution.Hour.- Parameters:
startDate- Inclusive. Not null.invalid reference
LocaDateTime
-
getStartDate
Get start date of the timeline based on the web component'sstartattribute.- Returns:
- Inclusive
invalid reference
LocaDate
-
getStartDateTime
Get start datetime of the timeline based on the web component'sstartattribute.- Returns:
- Inclusive
invalid reference
LocaDateTime
-
setEndDate
Set end date of the timeline. Call this only withResolution.DayandResolution.Week.- Parameters:
endDate- Inclusive. Not null.invalid reference
LocaDate
-
setEndDateTime
Set end date and time of the timeline. Call this only withResolution.Hour.- Parameters:
endDateTime- Inclusive. Not null.invalid reference
LocaDateTime
-
getEndDate
Get end date of the timeline based on the web component'sendattribute.- Returns:
- Inclusive
invalid reference
LocaDate
-
getEndDateTime
Get end datetime of the timeline based on the web component'sendattribute.- Returns:
- Inclusive
invalid reference
LocaDateTime
-
isTwelveHourClock
public boolean isTwelveHourClock()Get value of twelve hour clock boolean flag based on the web component'stwelveHourClockattribute.falsedefaults to 24 hour clock. Affects time formatting in the timeline.- Returns:
truewhentwelveHourClockis enabled and false otherwise
-
setTwelveHourClock
public void setTwelveHourClock(boolean enabled) Set value of twelve hour clock boolean flag to the web component'stwelveHourClockattribute.- Parameters:
enabled-truewhentwelveHourClockis enabled and false otherwise
-
setYearRowVisible
public void setYearRowVisible(boolean visible) -
isYearRowVisible
public boolean isYearRowVisible()Get year row visibility flag for the timeline based on the web component'syearRowVisibleproperty. Default istrue. -
setMonthRowVisible
public void setMonthRowVisible(boolean visible) -
isMonthRowVisible
public boolean isMonthRowVisible()Get month row visibility flag for the timeline based on the web component'smonthRowVisibleproperty. Default istrue. -
setMovableSteps
public void setMovableSteps(boolean enabled) -
isMovableSteps
public boolean isMovableSteps()Get boolean value of the web component'smovableStepsattribute. Attribute controls if steps are movable by user interactions using mouse or touch device. Default istrue. -
setResizableSteps
public void setResizableSteps(boolean enabled) -
isResizableSteps
public boolean isResizableSteps()Get boolean value of the web component'sresizableStepsattribute. Attribute controls if steps are resizable by user interactions using mouse or touch device. Default istrue. -
setMovableStepsBetweenRows
public void setMovableStepsBetweenRows(boolean enabled) -
isMovableStepsBetweenRows
public boolean isMovableStepsBetweenRows()Get boolean value of the web component'smovableStepsBetweenRowsattribute. Attribute controls if steps are movable between rows by user interactions using mouse or touch device. Default istrue. IfisMovableSteps()isfalse, then steps are not movable between rows either even if set totrue. -
addSteps
Add new step components based on the given collection of step descriptors. New components are appended at the end.- Parameters:
steps- a collection of step descriptor objects for the new components.
-
addSteps
Add new step components based on the given varargs of step descriptors. New components are appended at the end.- Parameters:
steps- a varargs of step descriptor objects for the new components.
-
addSteps
Add new step components based on the given stream of step descriptors. New components are appended at the end.- Parameters:
steps- a stream of step descriptor objects for the new components.
-
addStep
Add new step component based on the given step descriptor. New component is appended at the end.- Parameters:
step- a step descriptor object for the new component
-
addSubStep
Add new sub step component based on the given sub step descriptor. New components are appended at the end of the owner step component layout.- Parameters:
subStep- a sub step descriptor object for the new component
-
addStep
Add step component based on the given step descriptor. New component is moved to the given index, moving previous component one index forward. If step already exists based on its UID, then it will be moved. SeemoveStep(int, GanttStep).- Parameters:
index- zero based index for new positionstep- a step descriptor object for the new or existing component
-
moveStep
Moves given step or sub step. Same asmoveStep(int, Step)ormoveSubStep(int, SubStep)depending on which type of a component is being moved based on the UID for the givenGanttStep.- Parameters:
toIndex- Target zero based index where to move the stepanyStep- step or sub step descriptor of the moved step
-
moveStep
Move given existing step to the given index. Index is based on the state at the moment when method is called. Moved step component is removed and discarded and new step component takes the new position. Existing substep components are moved to the new step component. Context menus and tooltips are recreated for the new step component.- Parameters:
toIndex- Target zero based index where to move the stepstep- step descriptor of the moved step
-
moveSubStep
Move given existing substep to the given index. Index is based on the state at the moment when method is called. Moved substep component is removed and discarded and new substep component takes the new position as a new children inside the step component at the new index.SubStep.getOwner()is changed to the new owner, and step dates are adjusted to include the substep inside it. Other substep component are not touched. Context menus and tooltips are recreated for the new substep component.- Parameters:
toIndex- Target zero based index where to move the substepsubStep- substep descriptor of the moved substep
-
removeSteps
Removes all given steps if they exists, based on their UIDs.- Parameters:
steps- collection of steps, null does nothing
-
removeSteps
Removes all given steps if they exists, based on their UIDs.- Parameters:
steps- a varargs of steps, null does nothing
-
removeSteps
Removes all given steps looped through the given Stream if they exists, based on their UIDs.- Parameters:
steps- Stream of steps, null does nothing
-
removeAnyStep
Removes Step or sub step if it exists, based on the given UID.- Parameters:
uid- Target UID for step or sub step to remove- Returns:
- boolean true if step or sub step was removed, false otherwise
-
removeAnyStep
Removes Step or sub step if it exists, based on its UID.- Parameters:
step- Target step or sub step to remove- Returns:
- boolean true if step or sub step was removed, false otherwise
-
removeStep
Removes given Step if it exists, based on its UID.- Parameters:
step- Target step to remove- Returns:
- boolean true if step was removed, false otherwise
-
getStepElement
ReturnsStepElementbyuid. Includes sub-steps. -
getStepElementOptional
-
getStepElements
ReturnsStepElementstream excluding sub-steps. -
getSteps
ReturnsStepstream excluding sub-steps. -
getStepsList
Returns a list ofStepobjects excluding sub-steps. -
getFlatStepElements
ReturnsStepElementstream of all steps including sub steps. -
getSubStepElements
ReturnsStepElementstream for the given step UID.- Parameters:
forStepUid- Target step UID- Returns:
StepElementStream
-
getSubStepElements
ReturnsStepElementstream of all sub-steps. -
getSubSteps
ReturnsSubStepstream of all sub-steps. -
contains
Returns true if given UID matches with any existing step including sub step.- Parameters:
targetUid- Target UID- Returns:
- boolean true if UID exists
-
contains
Returns true if givenGanttStep's UID matches with any existing step including sub step.- Parameters:
targetStep- Target step or sub step- Returns:
- boolean true if UID exists
-
contains
Returns true if givenStep's UID matches with any existing step excluding sub step.- Parameters:
targetStep- Target step- Returns:
- boolean true if step with the UID exists
-
contains
Returns true if givenSubStep's UID matches with any existing sub step.- Parameters:
targetSubStep- Target sub step- Returns:
- boolean true if sub step with the UID exists
-
indexOf
Returns a zero based index of the givenStep.- Parameters:
step- TargetStep- Returns:
- zero based index
-
indexOf
Returns a zero based index of the given UID for a step or sub step. For sub steps index is based on the owner step.- Parameters:
stepUid- Target UID- Returns:
- zero based index
-
getSubStep
ReturnsSubStepby the UID or null if it doesn't exist.- Parameters:
uid- Target UID- Returns:
SubStepor null
-
getStep
ReturnsStepby the UID or null if it doesn't exist.- Parameters:
uid- Target UID- Returns:
Stepor null
-
getAnyStep
ReturnsGanttStepbyuid. Including sub-steps. -
updateSubStepsByMovedOwner
Updates sub step start and end dates for moved owner step.- Parameters:
stepUid- Target owner step UID
-
refresh
Refresh target step element if it exists.- Parameters:
uid- Target step UID
-
ensureUID
Ensures that given step has UID. If not, then generates one. -
setWidth
- Specified by:
setWidthin interfacecom.vaadin.flow.component.HasSize
-
setHeight
- Specified by:
setHeightin interfacecom.vaadin.flow.component.HasSize
-
addGanttClickListener
public com.vaadin.flow.shared.Registration addGanttClickListener(com.vaadin.flow.component.ComponentEventListener<GanttClickEvent> listener) -
addStepClickListener
public com.vaadin.flow.shared.Registration addStepClickListener(com.vaadin.flow.component.ComponentEventListener<StepClickEvent> listener) -
addStepMoveListener
public com.vaadin.flow.shared.Registration addStepMoveListener(com.vaadin.flow.component.ComponentEventListener<StepMoveEvent> listener) -
addStepResizeListener
public com.vaadin.flow.shared.Registration addStepResizeListener(com.vaadin.flow.component.ComponentEventListener<StepResizeEvent> listener) -
addDataChangeListener
public com.vaadin.flow.shared.Registration addDataChangeListener(com.vaadin.flow.component.ComponentEventListener<GanttDataChangeEvent> listener) -
buildCaptionGrid
Builds a newGridinstance with a single column that renders text based on the step caption.Gridwill be kept in sync with the Gantt steps. Instance is available then withgetCaptionGrid(). This does not attach component to any layout.- Parameters:
header- Header of the column- Returns:
- A new
Gridinstance
-
buildCaptionTreeGrid
Builds a newTreeGridinstance with a single column that renders text based on the step caption.TreeGridwill be kept in sync with the Gantt steps. Instance is available then withgetCaptionGrid(). This does not attach component to any layout.- Parameters:
header- Header of the column- Returns:
- A new
TreeGridinstance
-
handleTreeDataAdd
-
handleTreeDataMove
-
expand
Expands all child steps directed by the caption TreeGrid's hierarchical data source. -
expand
Expands all child steps directed by the caption TreeGrid's hierarchical data source. -
expand
Expands all child steps directed by the caption TreeGrid's hierarchical data source. -
expand
Expands all child steps directed by the caption TreeGrid's hierarchical data source. -
removeCaptionGrid
public void removeCaptionGrid()Remove captionGridinstance if it exists. Grid will not be kept in sync with the Gantt after calling this. This does not detach component from the layout. Synchronized Grid can be created withbuildCaptionGrid(String)orbuildCaptionTreeGrid(String). -
getCaptionGrid
Get captionGridinstance or null if it's not set. SeebuildCaptionGrid(String)andbuildCaptionTreeGrid(String).- Returns:
Gridinstance or null
-
getCaptionTreeGrid
Get captionTreeGridinstance or null if it's not set. SeebuildCaptionTreeGrid(String).- Returns:
Gridinstance or null
-