Skip to content

Commit 919ba14

Browse files
committed
Merge branch 'release/2.0.0'
2 parents ba8b160 + dc43a26 commit 919ba14

File tree

22 files changed

+627
-127
lines changed

22 files changed

+627
-127
lines changed

domino-ui-shared/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-ui-parent</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>2.0.0-RC5</version>
8+
<version>2.0.0</version>
99
</parent>
1010
<packaging>jar</packaging>
1111
<modelVersion>4.0.0</modelVersion>
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/*
2+
* Copyright © 2019 Dominokit
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.dominokit.domino.ui.style;
18+
19+
import elemental2.dom.Element;
20+
import java.util.function.Supplier;
21+
import org.dominokit.domino.ui.IsElement;
22+
23+
/**
24+
* A utility class to facilitate the conditional application or removal of CSS classes based on
25+
* boolean conditions. This class acts as a wrapper around the {@link CssClass} interface, with the
26+
* provision for conditional application or removal of styles.
27+
*
28+
* @see CssClass
29+
* @author [Your Name or Organization]
30+
*/
31+
public class ConditionalCssClass implements CssClass {
32+
33+
private CssClass cssClass;
34+
private Supplier<Boolean> condition;
35+
36+
/**
37+
* Creates an instance with a specified {@link CssClass} and a condition flag.
38+
*
39+
* @param cssClass The CSS class to be conditionally applied or removed.
40+
* @param condition Condition flag to determine if the class should be applied (true) or removed
41+
* (false).
42+
* @return A new instance of {@code ConditionalCssClass}.
43+
*/
44+
public static ConditionalCssClass of(CssClass cssClass, Supplier<Boolean> condition) {
45+
return new ConditionalCssClass(cssClass, condition);
46+
}
47+
48+
/**
49+
* Creates an instance with a specified {@link HasCssClass} and a condition flag. This method
50+
* extracts the {@link CssClass} from the provided {@link HasCssClass}.
51+
*
52+
* @param cssClass The object implementing {@link HasCssClass} whose CSS class will be extracted.
53+
* @param condition Condition flag to determine if the class should be applied (true) or removed
54+
* (false).
55+
* @return A new instance of {@code ConditionalCssClass}.
56+
*/
57+
public static ConditionalCssClass of(HasCssClass cssClass, Supplier<Boolean> condition) {
58+
return new ConditionalCssClass(cssClass.getCssClass(), condition);
59+
}
60+
61+
/**
62+
* Creates an instance with a specified CSS class string and a condition flag.
63+
*
64+
* @param cssClass The string representation of the CSS class to be conditionally applied or
65+
* removed.
66+
* @param condition Condition flag to determine if the class should be applied (true) or removed
67+
* (false).
68+
* @return A new instance of {@code ConditionalCssClass}.
69+
*/
70+
public static ConditionalCssClass of(String cssClass, Supplier<Boolean> condition) {
71+
return new ConditionalCssClass(() -> cssClass, condition);
72+
}
73+
74+
/**
75+
* Initializes the {@code ConditionalCssClass} with a provided {@link CssClass} and a condition
76+
* flag.
77+
*
78+
* @param cssClass The CSS class to be managed.
79+
* @param condition Condition flag to determine if the class should be applied (true) or removed
80+
* (false).
81+
*/
82+
public ConditionalCssClass(CssClass cssClass, Supplier<Boolean> condition) {
83+
this.cssClass = cssClass;
84+
this.condition = condition;
85+
}
86+
87+
/**
88+
* Applies or removes the CSS class on the provided element based on the condition flag.
89+
*
90+
* @param element The DOM element to which the CSS class will be applied or removed.
91+
*/
92+
@Override
93+
public void apply(Element element) {
94+
apply(element, condition);
95+
}
96+
97+
/**
98+
* Applies or removes the CSS class on the provided element based on the given condition flag.
99+
*
100+
* @param element The DOM element to which the CSS class will be applied or removed.
101+
* @param condition Condition flag to determine if the class should be applied (true) or removed
102+
* (false).
103+
*/
104+
public void apply(Element element, Supplier<Boolean> condition) {
105+
if (condition.get()) {
106+
cssClass.apply(element);
107+
} else {
108+
remove(element);
109+
}
110+
}
111+
112+
/**
113+
* Applies or removes the CSS class on the provided {@link IsElement} based on the specified
114+
* condition.
115+
*
116+
* @param element The UI element (implementing {@link IsElement}) on which the CSS class will be
117+
* conditionally applied or removed.
118+
* @param condition Condition flag to determine if the class should be applied (true) or removed
119+
* (false).
120+
*/
121+
public void apply(IsElement<?> element, Supplier<Boolean> condition) {
122+
apply(element.element(), condition);
123+
}
124+
125+
/**
126+
* Checks if the CSS class is applied to the specified DOM {@link Element}.
127+
*
128+
* @param element The DOM element to check.
129+
* @return {@code true} if the CSS class is applied to the element, {@code false} otherwise.
130+
*/
131+
@Override
132+
public boolean isAppliedTo(Element element) {
133+
return cssClass.isAppliedTo(element);
134+
}
135+
136+
/**
137+
* Checks if the CSS class is applied to the specified {@link IsElement}.
138+
*
139+
* @param element The UI element (implementing {@link IsElement}) to check.
140+
* @return {@code true} if the CSS class is applied to the element, {@code false} otherwise.
141+
*/
142+
@Override
143+
public boolean isAppliedTo(IsElement<?> element) {
144+
return cssClass.isAppliedTo(element);
145+
}
146+
147+
/**
148+
* Removes the CSS class from the specified DOM {@link Element}.
149+
*
150+
* @param element The DOM element from which the CSS class will be removed.
151+
*/
152+
@Override
153+
public void remove(Element element) {
154+
cssClass.remove(element);
155+
}
156+
157+
/**
158+
* Removes the CSS class from the specified {@link IsElement}.
159+
*
160+
* @param element The UI element (implementing {@link IsElement}) from which the CSS class will be
161+
* removed.
162+
*/
163+
@Override
164+
public void remove(IsElement<?> element) {
165+
cssClass.remove(element);
166+
}
167+
168+
/**
169+
* Retrieves the CSS class string associated with this instance.
170+
*
171+
* @return The string representation of the associated CSS class.
172+
*/
173+
@Override
174+
public String getCssClass() {
175+
return cssClass.getCssClass();
176+
}
177+
}

domino-ui-tools/mdi-icons-processor/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-ui-tools</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>2.0.0-RC5</version>
8+
<version>2.0.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

domino-ui-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-ui-parent</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>2.0.0-RC5</version>
8+
<version>2.0.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

domino-ui-webjar/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>domino-ui-parent</artifactId>
77
<groupId>org.dominokit</groupId>
8-
<version>2.0.0-RC5</version>
8+
<version>2.0.0</version>
99
</parent>
1010
<packaging>jar</packaging>
1111
<modelVersion>4.0.0</modelVersion>

domino-ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.dominokit</groupId>
88
<artifactId>domino-ui-parent</artifactId>
9-
<version>2.0.0-RC5</version>
9+
<version>2.0.0</version>
1010
</parent>
1111

1212
<artifactId>domino-ui</artifactId>

domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListDataStore.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,19 @@ public void addRecord(T record) {
553553
setData(newData);
554554
}
555555

556+
/**
557+
* Inserts a single record to the data store at the specified index, updating both the original
558+
* and filtered lists.
559+
*
560+
* @param index The insertion index.
561+
* @param record The record to be added.
562+
*/
563+
public void insertRecord(int index, T record) {
564+
original.add(index, record);
565+
List<T> newData = new ArrayList<>(original);
566+
setData(newData);
567+
}
568+
556569
/**
557570
* Removes a single record from the data store, updating both the original and filtered lists.
558571
*
@@ -566,6 +579,16 @@ public void removeRecord(T record) {
566579
}
567580
}
568581

582+
/**
583+
* Removes a single record from the data store from the specified index, updating both the
584+
* original and filtered lists.
585+
*
586+
* @param index The index of the record to be removed
587+
*/
588+
public void removeRecord(int index) {
589+
removeRecord(original.get(index));
590+
}
591+
569592
/**
570593
* Updates a single record in the data store by replacing it with a new record, updating both the
571594
* original and filtered lists.

domino-ui/src/main/java/org/dominokit/domino/ui/datatable/store/LocalListScrollingDataSource.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class LocalListScrollingDataSource<T> implements DataStore<T> {
4343
private final List<T> original;
4444
private List<T> filtered = new ArrayList<>();
4545
private final int pageSize;
46+
private int initialLoadedPages = 1;
4647
private int pageIndex = 0;
4748
private List<StoreDataChangeListener<T>> listeners = new ArrayList<>();
4849
private SearchFilter<T> searchFilter;
@@ -59,6 +60,18 @@ public LocalListScrollingDataSource(int pageSize) {
5960
this.pageSize = pageSize;
6061
}
6162

63+
/**
64+
* Creates a new instance of {@link LocalListScrollingDataSource} with the specified page size.
65+
*
66+
* @param pageSize The number of records to load per page.
67+
* @param initialLoadedPages The number of pages to load in the initial load - page index 0 -.
68+
*/
69+
public LocalListScrollingDataSource(int pageSize, int initialLoadedPages) {
70+
this.original = new ArrayList<>();
71+
this.pageSize = pageSize;
72+
this.initialLoadedPages = initialLoadedPages;
73+
}
74+
6275
/**
6376
* Creates a new instance of {@link LocalListScrollingDataSource} with the specified page size and
6477
* initial data.
@@ -72,6 +85,21 @@ public LocalListScrollingDataSource(List<T> data, int pageSize) {
7285
this.filtered.addAll(data);
7386
}
7487

88+
/**
89+
* Creates a new instance of {@link LocalListScrollingDataSource} with the specified page size and
90+
* initial data.
91+
*
92+
* @param data The initial data to populate the data source.
93+
* @param pageSize The number of records to load per page.
94+
* @param initialLoadedPages The number of pages to load in the initial load - page index 0 -.
95+
*/
96+
public LocalListScrollingDataSource(List<T> data, int pageSize, int initialLoadedPages) {
97+
this.original = data;
98+
this.pageSize = pageSize;
99+
this.initialLoadedPages = initialLoadedPages;
100+
this.filtered.addAll(data);
101+
}
102+
75103
/**
76104
* Retrieves a copy of records stored in the data store.
77105
*
@@ -162,7 +190,7 @@ public void load() {
162190

163191
private void fireUpdate(boolean append) {
164192
int fromIndex = pageSize * pageIndex;
165-
int toIndex = Math.min(fromIndex + pageSize, filtered.size());
193+
int toIndex = Math.min(getToIndex(fromIndex), filtered.size());
166194

167195
listeners.forEach(
168196
dataChangeListener ->
@@ -173,6 +201,15 @@ private void fireUpdate(boolean append) {
173201
filtered.size())));
174202
}
175203

204+
private int getToIndex(int fromIndex) {
205+
if (pageIndex == 0 && initialLoadedPages > 1) {
206+
int toIndex = fromIndex + (initialLoadedPages * pageSize);
207+
pageIndex = initialLoadedPages - 1;
208+
return toIndex;
209+
}
210+
return fromIndex + pageSize;
211+
}
212+
176213
/**
177214
* Handles various table-related events and delegates to specific event handling methods based on
178215
* the event type.

domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/AbstractDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private void doOpen() {
318318
getConfig().getZindexManager().onPopupOpen(this);
319319
element.removeCss(dui_hidden);
320320
updateFocus();
321-
triggerExpandListeners((T) this);
321+
triggerOpenListeners((T) this);
322322
this.open = true;
323323
}
324324

@@ -391,7 +391,7 @@ private void doClose() {
391391
}
392392
this.open = false;
393393
getConfig().getZindexManager().onPopupClose(this);
394-
triggerCollapseListeners((T) this);
394+
triggerCloseListeners((T) this);
395395
}
396396

397397
/**

domino-ui/src/main/java/org/dominokit/domino/ui/dialogs/AlertMessageDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public AlertMessageDialog() {
9999
setStretchHeight(DialogSize.VERY_SMALL);
100100
setAutoClose(false);
101101
contentHeader.get().addCss(dui_justify_around);
102-
addExpandListener(
102+
addOpenListener(
103103
(component) -> {
104104
if (alertIcon.isInitialized()) {
105105
Animation.create(getAlertIcon())

0 commit comments

Comments
 (0)