-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement item mode changed events (#6672)
- Loading branch information
1 parent
789015c
commit 1b12dbc
Showing
8 changed files
with
539 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
.../src/main/java/com/vaadin/flow/component/dashboard/DashboardItemMoveModeChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.dashboard; | ||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.ComponentEventListener; | ||
import com.vaadin.flow.component.DomEvent; | ||
import com.vaadin.flow.component.EventData; | ||
|
||
/** | ||
* Widget or section move mode state changed event of {@link Dashboard}. | ||
* | ||
* @author Vaadin Ltd. | ||
* @see Dashboard#addItemMoveModeChangedListener(ComponentEventListener) | ||
*/ | ||
@DomEvent("dashboard-item-move-mode-changed") | ||
public class DashboardItemMoveModeChangedEvent | ||
extends ComponentEvent<Dashboard> { | ||
|
||
private final Component item; | ||
|
||
private final boolean moveMode; | ||
|
||
/** | ||
* Creates a dashboard item move mode changed event. | ||
* | ||
* @param source | ||
* Dashboard that contains the item of which the move mode state | ||
* has changed | ||
* @param fromClient | ||
* {@code true} if the event originated from the client side, | ||
* {@code false} otherwise | ||
* @param itemNodeId | ||
* The node ID of the item of which the move mode state has | ||
* changed | ||
* @param moveMode | ||
* Whether the item is in move mode | ||
*/ | ||
public DashboardItemMoveModeChangedEvent(Dashboard source, | ||
boolean fromClient, | ||
@EventData("event.detail.item.nodeid") int itemNodeId, | ||
@EventData("event.detail.value") boolean moveMode) { | ||
super(source, fromClient); | ||
this.item = source.getItem(itemNodeId); | ||
this.moveMode = moveMode; | ||
} | ||
|
||
/** | ||
* Returns the item of which the move mode state has changed | ||
* | ||
* @return the item of which the move mode state has changed | ||
*/ | ||
public Component getItem() { | ||
return item; | ||
} | ||
|
||
/** | ||
* Returns whether the item is in move mode | ||
* | ||
* @return whether the item is in move mode | ||
*/ | ||
public boolean isMoveMode() { | ||
return moveMode; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...rc/main/java/com/vaadin/flow/component/dashboard/DashboardItemResizeModeChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.dashboard; | ||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.ComponentEventListener; | ||
import com.vaadin.flow.component.DomEvent; | ||
import com.vaadin.flow.component.EventData; | ||
|
||
/** | ||
* Widget resize mode state changed event of {@link Dashboard}. | ||
* | ||
* @author Vaadin Ltd. | ||
* @see Dashboard#addItemResizeModeChangedListener(ComponentEventListener) | ||
*/ | ||
@DomEvent("dashboard-item-resize-mode-changed") | ||
public class DashboardItemResizeModeChangedEvent | ||
extends ComponentEvent<Dashboard> { | ||
|
||
private final Component item; | ||
|
||
private final boolean resizeMode; | ||
|
||
/** | ||
* Creates a dashboard item resize mode changed event. | ||
* | ||
* @param source | ||
* Dashboard that contains the item of which the resize mode | ||
* state has changed | ||
* @param fromClient | ||
* {@code true} if the event originated from the client side, | ||
* {@code false} otherwise | ||
* @param itemNodeId | ||
* The node ID of the item of which the resize mode state has | ||
* changed | ||
* @param resizeMode | ||
* Whether the item is in resize mode | ||
*/ | ||
public DashboardItemResizeModeChangedEvent(Dashboard source, | ||
boolean fromClient, | ||
@EventData("event.detail.item.nodeid") int itemNodeId, | ||
@EventData("event.detail.value") boolean resizeMode) { | ||
super(source, fromClient); | ||
this.item = source.getWidgets().stream().filter( | ||
widget -> itemNodeId == widget.getElement().getNode().getId()) | ||
.findAny().orElseThrow(); | ||
this.resizeMode = resizeMode; | ||
} | ||
|
||
/** | ||
* Returns the item of which the resize mode state has changed; | ||
* | ||
* @return the item of which the resize mode state has changed | ||
*/ | ||
public Component getItem() { | ||
return item; | ||
} | ||
|
||
/** | ||
* Returns whether the item is in resize mode | ||
* | ||
* @return whether the item is in resize mode | ||
*/ | ||
public boolean isResizeMode() { | ||
return resizeMode; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
.../src/main/java/com/vaadin/flow/component/dashboard/DashboardItemSelectedChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright 2000-2024 Vaadin Ltd. | ||
* | ||
* This program is available under Vaadin Commercial License and Service Terms. | ||
* | ||
* See {@literal <https://vaadin.com/commercial-license-and-service-terms>} for the full | ||
* license. | ||
*/ | ||
package com.vaadin.flow.component.dashboard; | ||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.flow.component.ComponentEvent; | ||
import com.vaadin.flow.component.ComponentEventListener; | ||
import com.vaadin.flow.component.DomEvent; | ||
import com.vaadin.flow.component.EventData; | ||
|
||
/** | ||
* Widget or section selected state changed event of {@link Dashboard}. | ||
* | ||
* @author Vaadin Ltd. | ||
* @see Dashboard#addItemSelectedChangedListener(ComponentEventListener) | ||
*/ | ||
@DomEvent("dashboard-item-selected-changed") | ||
public class DashboardItemSelectedChangedEvent | ||
extends ComponentEvent<Dashboard> { | ||
|
||
private final Component item; | ||
|
||
private final boolean selected; | ||
|
||
/** | ||
* Creates a dashboard item selected changed event. | ||
* | ||
* @param source | ||
* Dashboard that contains the item of which the selected state | ||
* has changed | ||
* @param fromClient | ||
* {@code true} if the event originated from the client side, | ||
* {@code false} otherwise | ||
* @param itemNodeId | ||
* The node ID of the item of which the selected state has | ||
* changed | ||
* @param selected | ||
* Whether the item is selected | ||
*/ | ||
public DashboardItemSelectedChangedEvent(Dashboard source, | ||
boolean fromClient, | ||
@EventData("event.detail.item.nodeid") int itemNodeId, | ||
@EventData("event.detail.value") boolean selected) { | ||
super(source, fromClient); | ||
this.item = source.getItem(itemNodeId); | ||
this.selected = selected; | ||
} | ||
|
||
/** | ||
* Returns the item of which the selected state has changed | ||
* | ||
* @return the item of which the selected state has changed | ||
*/ | ||
public Component getItem() { | ||
return item; | ||
} | ||
|
||
/** | ||
* Returns whether the item is selected | ||
* | ||
* @return whether the item is selected | ||
*/ | ||
public boolean isSelected() { | ||
return selected; | ||
} | ||
} |
Oops, something went wrong.