Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Messages
public static String addComponentFailed;
public static String automatedActions;
public static String commands;
public static String collapseTooltip;
public static String configure;
public static String delayTooltip0;
public static String delayTooltip1;
Expand All @@ -30,6 +31,7 @@ public class Messages
public static String disabledCommonEnableDate;
public static String disabledVaryingEnableDate;
public static String displays;
public static String editingModeTooltip;
public static String enableAlarmFailed;
public static String enableAlarms;
public static String guidance;
Expand All @@ -43,6 +45,8 @@ public class Messages
public static String promptTitle;
public static String removeComponentFailed;
public static String renameItemFailed;
public static String showAlarmsTooltip;
public static String showDisabledTooltip;
public static String totalPVs;
public static String unacknowledgeFailed;
public static String withEnableDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import java.util.logging.Level;
import java.util.stream.Collectors;


import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.FXCollections;
import javafx.scene.control.ToggleButton;
import org.phoebus.applications.alarm.AlarmSystem;
import org.phoebus.applications.alarm.client.AlarmClient;
import org.phoebus.applications.alarm.client.AlarmClientLeaf;
Expand All @@ -33,6 +36,7 @@
import org.phoebus.applications.alarm.model.BasicState;
import org.phoebus.applications.alarm.ui.AlarmContextMenuHelper;
import org.phoebus.applications.alarm.ui.AlarmUI;
import org.phoebus.applications.alarm.ui.Messages;
import org.phoebus.applications.alarm.ui.config.ItemConfigDialog;
import org.phoebus.framework.selection.Selection;
import org.phoebus.framework.selection.SelectionService;
Expand Down Expand Up @@ -140,6 +144,8 @@
items.remove(changing);
});

private final SimpleBooleanProperty is_editing_mode = new SimpleBooleanProperty(false);

Check warning on line 147 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeView.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "is_editing_mode" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaGCG9FYy_uu_AHL1K8E&open=AaGCG9FYy_uu_AHL1K8E&pullRequest=3991

// Javadoc for TreeItem shows example for overriding isLeaf() and getChildren()
// to dynamically create TreeItem as TreeView requests information.
//
Expand Down Expand Up @@ -176,7 +182,7 @@
tree_view.setCellFactory(view -> new AlarmTreeViewCell());
tree_view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

setTop(createToolbar());
setTop(createToolbar(model));
setCenter(tree_view);

createContextMenu();
Expand Down Expand Up @@ -234,11 +240,21 @@
});
}

private ToolBar createToolbar()
private ToolBar createToolbar(final AlarmClient model)
{
final ToggleButton editing_mode = new ToggleButton("",

Check warning on line 245 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/AlarmTreeView.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=ControlSystemStudio_phoebus&issues=AaF9-mWv24SirPMUdu_r&open=AaF9-mWv24SirPMUdu_r&pullRequest=3991
ImageCache.getImageView(AlarmUI.class, "/icons/alarm_edit.png"));
editing_mode.setTooltip(new Tooltip(Messages.editingModeTooltip));
is_editing_mode.bind(editing_mode.selectedProperty());
if (AlarmUI.mayConfigure(model)) {
editing_mode.setSelected(true);
} else {
editing_mode.setDisable(true);
}

final Button collapse = new Button("",
ImageCache.getImageView(AlarmUI.class, "/icons/collapse.png"));
collapse.setTooltip(new Tooltip("Collapse alarm tree"));
collapse.setTooltip(new Tooltip(Messages.collapseTooltip));
collapse.setOnAction(event ->
{
for (TreeItem<AlarmTreeItem<?>> sub : tree_view.getRoot().getChildren())
Expand All @@ -247,15 +263,15 @@

final Button show_alarms = new Button("",
ImageCache.getImageView(AlarmUI.class, "/icons/expand_alarms.png"));
show_alarms.setTooltip(new Tooltip("Expand alarm tree to show active alarms"));
show_alarms.setTooltip(new Tooltip(Messages.showAlarmsTooltip));
show_alarms.setOnAction(event -> expandAlarms(tree_view.getRoot()));

final Button show_disabled = new Button("",
ImageCache.getImageView(AlarmUI.class, "/icons/expand_disabled.png"));
show_disabled.setTooltip(new Tooltip("Expand alarm tree to show disabled PVs"));
show_disabled.setTooltip(new Tooltip(Messages.showDisabledTooltip));
show_disabled.setOnAction(event -> expandDisabledPVs(tree_view.getRoot()));

return new ToolBar(no_server, changing, ToolbarHelper.createSpring(), collapse, show_alarms, show_disabled);
return new ToolBar(no_server, changing, ToolbarHelper.createSpring(), editing_mode, collapse, show_alarms, show_disabled);
}

ToolBar getToolbar()
Expand Down Expand Up @@ -344,8 +360,7 @@
items.remove(no_server);
if (! alive)
// Place left of spring, collapse, expand_alarms,
// i.e. right of potential AlarmConfigSelector
items.add(items.size()-3, no_server);
items.add(items.size()-4, no_server);
}

// AlarmClientModelListener
Expand Down Expand Up @@ -593,7 +608,7 @@
if (menu_items.size() > 0)
menu_items.add(new SeparatorMenuItem());

if (AlarmUI.mayConfigure(model))
if (AlarmUI.mayConfigure(model) && is_editing_mode.get())
{
if (selection.size() <= 0)
// Add first item to empty config
Expand All @@ -614,16 +629,18 @@

menu_items.add(new MoveTreeItemAction(tree_view, model, item));
}
if (selection.size() >= 1)
{
menu_items.add(new EnableComponentAction(tree_view, model, selection));
menu_items.add(new DisableAction(tree_view, model, selection));
menu_items.add(new RemoveComponentAction(tree_view, model, selection));
}

}
if (selection.size() >= 1)
{
menu_items.add(new EnableComponentAction(tree_view, model, selection));
menu_items.add(new DisableAction(tree_view, model, selection));
if (AlarmUI.mayConfigure(model) && is_editing_mode.get())
menu_items.add(new RemoveComponentAction(tree_view, model, selection));
}

menu_items.add(new SeparatorMenuItem());

menu_items.add(new PrintAction(tree_view));
menu_items.add(new SaveSnapshotAction(DockPane.getActiveDockPane()));

Expand Down Expand Up @@ -657,9 +674,10 @@
{
tree_view.setOnMouseClicked(event ->
{
if (!AlarmUI.mayConfigure(model) ||
event.getClickCount() != 2 ||
tree_view.getSelectionModel().getSelectedItems().size() != 1)
if (!AlarmUI.mayConfigure(model)
|| !is_editing_mode.get()
|| event.getClickCount() != 2
|| tree_view.getSelectionModel().getSelectedItems().size() != 1)
return;

final AlarmTreeItem<?> item = tree_view.getSelectionModel().getSelectedItems().get(0).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ automatedActions=Automated Actions:
behavior=Behavior:
behaviorTooltip=Enable alarms? See also 'Enabling Filter'
commands=Commands:
collapseTooltip=Collapse alarm tree
configure=Configure
dateTimePickerTooltip=Select a date until which the alarm should be disabled
delay=Delay
Expand All @@ -47,6 +48,7 @@ disableUntil=Disable until:
disabledCommonEnableDate=Disabled until {0}: {1}
disabledVaryingEnableDate=Disabled (varying enable date): {0}
displays=Displays:
editingModeTooltip=Toggle editing mode
enabled=Enabled
enablingFilter=Enabling Filter:
enablingFilterTooltip=Optional expression for enabling the alarm
Expand All @@ -73,6 +75,8 @@ relativeDateLabel=Relative Date:
relativeDateTooltip=Select a predefined duration for disabling the alarm
removeComponentFailed=Failed to remove component
renameItemFailed=Failed to rename item
showAlarmsTooltip=Expand alarm tree to show active alarms
showDisabledTooltip=Expand alarm tree to show disabled PVs
timer=Timer
title=Title
tooltipAddTableItem=Add a new table item
Expand Down
2 changes: 1 addition & 1 deletion phoebus-product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
</dependency>
<dependency>
<groupId>org.phoebus</groupId>
<artifactId>app-alarm-freetts-annunciator</artifactId>
<artifactId>app-alarm-audio-annunciator</artifactId>
<version>7.0.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
Expand Down
Loading