Skip to contentPackage: MainPanelPresentation$Bindings
MainPanelPresentation$Bindings
Coverage
1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * SteelBlue: DCI User Interfaces
5: * http://tidalwave.it/projects/steelblue
6: *
7: * Copyright (C) 2015 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/steelblue-src
22: * git clone https://github.com/tidalwave-it/steelblue-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.ui.example.presentation;
27:
28: import jakarta.annotation.Nonnull;
29: import java.nio.file.Path;
30: import it.tidalwave.ui.core.UserNotificationWithFeedback;
31: import it.tidalwave.ui.core.BoundProperty;
32: import it.tidalwave.ui.core.role.PresentationModel;
33: import it.tidalwave.ui.core.role.UserAction;
34: import lombok.Builder;
35:
36: /***************************************************************************************************************************************************************
37: *
38: * This interface describes all the interactions with the presentation object.
39: *
40: * @stereotype Presentation
41: *
42: * @author Fabrizio Giudici
43: *
44: **************************************************************************************************************************************************************/
45: public interface MainPanelPresentation
46: {
47: /***********************************************************************************************************************************************************
48: * If the presentation contains form fields, it's a good practice to group them together within a single class
49: * which exposes {@link BoundProperty} instances.
50: **********************************************************************************************************************************************************/
51: // START SNIPPET: bindings
52: @Builder
53: public static class Bindings
54: {
55: @Nonnull
56: public final UserAction actionButton;
57:
58: @Nonnull
59: public final UserAction actionDialogOk;
60:
61: @Nonnull
62: public final UserAction actionDialogCancelOk;
63:
64: @Nonnull
65: public final UserAction actionPickFile;
66:
67: @Nonnull
68: public final UserAction actionPickDirectory;
69:
70: public final BoundProperty<String> textProperty = new BoundProperty<>("1");
71:
72: public final BoundProperty<Boolean> booleanProperty = new BoundProperty<>(true);
73: }
74: // END SNIPPET: bindings
75:
76: /***********************************************************************************************************************************************************
77: * A presentation always exposes a {@code bind()} method which is invoked by the control and binds callbacks
78: * and form fields. There is no requirement on the name and signature of the method.
79: * @param bindings the container of bindings
80: **********************************************************************************************************************************************************/
81: public void bind (@Nonnull Bindings bindings);
82:
83: /***********************************************************************************************************************************************************
84: * A presentation also exposes some {@code populateXYZ()} methods which are used to fill various parts of the UI
85: * with model. Data structures are modelled by {@link PresentationModel}s. There is no requirement on the name of the
86: * method.
87: * @param pmSimpleEntities the presentation model for SimpleEntity instances
88: * @param pmDciEntities the presentation model for SimpleDciEntity instances
89: * @param pmFileEntities the presentation model for FileEntity instances
90: **********************************************************************************************************************************************************/
91: public void populate (@Nonnull PresentationModel pmSimpleEntities,
92: @Nonnull PresentationModel pmDciEntities,
93: @Nonnull PresentationModel pmFileEntities);
94:
95: /***********************************************************************************************************************************************************
96: * When the control requires an interaction with the user in form of a dialog box with feedback (such as Ok/Cancel)
97: * a method must be exposed which accepts a {@link UserNotificationWithFeedback}. There is no requirement on the
98: * name of the method.
99: * @param notification the object managing the interaction
100: **********************************************************************************************************************************************************/
101: public void notify (@Nonnull UserNotificationWithFeedback notification);
102:
103: /***********************************************************************************************************************************************************
104: * Displays a notification in the presentation.
105: * @param message the text of the notification
106: **********************************************************************************************************************************************************/
107: public void notify (@Nonnull String message);
108:
109: /***********************************************************************************************************************************************************
110: * Asks the user to pick a file.
111: * @param selectedFile a property containing both the file to pre-select and later the piked file
112: * @param notification the object managing the interaction
113: **********************************************************************************************************************************************************/
114: public void pickFile (@Nonnull BoundProperty<Path> selectedFile,
115: @Nonnull UserNotificationWithFeedback notification);
116:
117: /***********************************************************************************************************************************************************
118: * Asks the user to pick a directory.
119: * @param selectedFolder a property containing both the directory to pre-select and later the picked folder
120: * @param notification the object managing the interaction
121: **********************************************************************************************************************************************************/
122: public void pickDirectory (@Nonnull BoundProperty<Path> selectedFolder,
123: @Nonnull UserNotificationWithFeedback notification);
124: }