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: /** Shortcut for {@link it.tidalwave.util.As}. */
48: public static final Class<UserAction> _UserAction_ = UserAction.class;
49:
50: /***********************************************************************************************************************************************************
51: *
52: **********************************************************************************************************************************************************/
53: public void actionPerformed();
54:
55: /***********************************************************************************************************************************************************
56: * Returns the property describing the enabled status of this action.
57: *
58: * @return the enabled property
59: **********************************************************************************************************************************************************/
60: @Nonnull
61: public BoundProperty<Boolean> enabled(); // TODO: rename to enabledProperty()
62:
63: /***********************************************************************************************************************************************************
64: * Creates a new instance out of a callback and a collection of roles.
65: *
66: * @param callback the callback
67: * @param roles the roles (or role factories)
68: * @return the new instance
69: * @since 3.2-ALPHA-1 (replaces {@code new UserActionSupport()}
70: * @since 3.2-ALPHA-3 (refactored)
71: **********************************************************************************************************************************************************/
72: @Nonnull
73: public static UserAction of (@Nonnull final Callback callback, @Nonnull final Collection<Object> roles)
74: {
75: return new DefaultUserAction(callback, roles);
76: }
77:
78: /***********************************************************************************************************************************************************
79: * Creates a new instance out of a callback and a role (typically a {@link Displayable}).
80: *
81: * @param callback the callback
82: * @param role the role (or role factory)
83: * @return the new instance
84: * @since 3.2-ALPHA-3
85: **********************************************************************************************************************************************************/
86: @Nonnull
87: public static UserAction of (@Nonnull final Callback callback, @Nonnull final Object role)
88: {
89: Parameters.mustNotBeArrayOrCollection(role, "role");
90: return of(callback, List.of(role));
91: }
92:
93: /***********************************************************************************************************************************************************
94: * Creates a new instance out of a callback.
95: *
96: * @param callback the callback
97: * @return the new instance
98: * @since 3.2-ALPHA-3
99: **********************************************************************************************************************************************************/
100: @Nonnull
101: public static UserAction of (@Nonnull final Callback callback)
102: {
103: return of(callback, Collections.emptyList());
104: }
105: }