|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2017-2020 Oak Ridge National Laboratory. |
| 2 | + * Copyright (c) 2017-2025 Oak Ridge National Laboratory. |
3 | 3 | * All rights reserved. This program and the accompanying materials |
4 | 4 | * are made available under the terms of the Eclipse Public License v1.0 |
5 | 5 | * which accompanies this distribution, and is available at |
6 | 6 | * http://www.eclipse.org/legal/epl-v10.html |
7 | 7 | *******************************************************************************/ |
8 | 8 | package org.csstudio.display.builder.runtime.app; |
9 | 9 |
|
| 10 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propConfirmDialog; |
| 11 | +import static org.csstudio.display.builder.model.properties.CommonWidgetProperties.propPassword; |
| 12 | + |
10 | 13 | import javafx.collections.ObservableList; |
11 | 14 | import javafx.scene.Node; |
12 | 15 | import javafx.scene.Parent; |
@@ -127,12 +130,20 @@ private void fillMenu(Runnable setFocus, final Widget widget) { |
127 | 130 | } |
128 | 131 |
|
129 | 132 | // Widget actions |
130 | | - for (ActionInfo info : widget.propActions().getValue().getActions()) { |
131 | | - List<MenuItem> actionMenuItems = info.getContextMenuItems(RuntimeUtil.getExecutor(), widget); |
132 | | - if (actionMenuItems != null) { |
133 | | - items.addAll(actionMenuItems); |
| 133 | + // Skip if widget requires password or confirmation dialog, |
| 134 | + // because in here we would invoke actions without those constraints |
| 135 | + final Optional<WidgetProperty<String>> pass = widget.checkProperty(propPassword); |
| 136 | + final Optional<WidgetProperty<Boolean>> prompt = widget.checkProperty(propConfirmDialog); |
| 137 | + final boolean need_dialog = (pass.isPresent() && !pass.get().getValue().isBlank()) || |
| 138 | + (prompt.isPresent() && prompt.get().getValue()); |
| 139 | + |
| 140 | + if (! need_dialog) |
| 141 | + for (ActionInfo info : widget.propActions().getValue().getActions()) { |
| 142 | + List<MenuItem> actionMenuItems = info.getContextMenuItems(RuntimeUtil.getExecutor(), widget); |
| 143 | + if (actionMenuItems != null) { |
| 144 | + items.addAll(actionMenuItems); |
| 145 | + } |
134 | 146 | } |
135 | | - } |
136 | 147 |
|
137 | 148 | // Actions of the widget runtime |
138 | 149 | final WidgetRuntime<Widget> runtime = RuntimeUtil.getRuntime(widget); |
|
0 commit comments