Skip to content

Package: UserAction

UserAction

nameinstructionbranchcomplexitylinemethod
of(Callback)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
of(Callback, Collection)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
of(Callback, Object)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

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.core.role;
27:
28: import jakarta.annotation.Nonnull;
29: import java.util.Collection;
30: import java.util.Collections;
31: import java.util.List;
32: import it.tidalwave.util.As;
33: import it.tidalwave.util.Callback;
34: import it.tidalwave.util.Parameters;
35: import it.tidalwave.ui.core.BoundProperty;
36: import it.tidalwave.ui.core.role.impl.DefaultUserAction;
37: // import javafx.beans.property.BooleanProperty;
38:
39: /***************************************************************************************************************************************************************
40: *
41: * @since 2.0-ALPHA-1
42: * @author Fabrizio Giudici
43: *
44: **************************************************************************************************************************************************************/
45: public interface UserAction extends As
46: {
47: public static final Class<UserAction> _UserAction_ = UserAction.class;
48:
49: /***********************************************************************************************************************************************************
50: *
51: **********************************************************************************************************************************************************/
52: public void actionPerformed();
53:
54: /***********************************************************************************************************************************************************
55: * Returns the property describing the enabled status of this action.
56: *
57: * @return the enabled property
58: **********************************************************************************************************************************************************/
59: @Nonnull
60: public BoundProperty<Boolean> enabled(); // TODO: rename to enabledProperty()
61:
62: /***********************************************************************************************************************************************************
63: * Creates a new instance out of a callback and a collection of roles.
64: *
65: * @param callback the callback
66: * @param roles the roles (or role factories)
67: * @return the new instance
68: * @since 3.2-ALPHA-1 (replaces {@code new UserActionSupport()}
69: * @since 3.2-ALPHA-3 (refactored)
70: **********************************************************************************************************************************************************/
71: @Nonnull
72: public static UserAction of (@Nonnull final Callback callback, @Nonnull final Collection<Object> roles)
73: {
74: return new DefaultUserAction(callback, roles);
75: }
76:
77: /***********************************************************************************************************************************************************
78: * Creates a new instance out of a callback and a role (typically a {@link Displayable}).
79: *
80: * @param callback the callback
81: * @param role the role (or role factory)
82: * @return the new instance
83: * @since 3.2-ALPHA-3
84: **********************************************************************************************************************************************************/
85: @Nonnull
86: public static UserAction of (@Nonnull final Callback callback, @Nonnull final Object role)
87: {
88: Parameters.mustNotBeArrayOrCollection(role, "role");
89: return of(callback, List.of(role));
90: }
91:
92: /***********************************************************************************************************************************************************
93: * Creates a new instance out of a callback.
94: *
95: * @param callback the callback
96: * @return the new instance
97: * @since 3.2-ALPHA-3
98: **********************************************************************************************************************************************************/
99: @Nonnull
100: public static UserAction of (@Nonnull final Callback callback)
101: {
102: return of(callback, Collections.emptyList());
103: }
104: }