Skip to content
Draft
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 @@ -52,9 +52,9 @@ public AlarmClientLeaf(final String parent_path, final String name)
* a detached copy is used to send the request.
* @return {@link AlarmClientLeaf} with same configuration, but no parent
*/
public AlarmClientLeaf createDetachedCopy()
public AlarmClientLeaf createDetachedCopy(final String newName)
{
final AlarmClientLeaf pv = new AlarmClientLeaf(null, getName());
final AlarmClientLeaf pv = new AlarmClientLeaf(null, newName);
pv.setDescription(getDescription());
pv.setEnabled(getEnabled());
pv.setLatching(isLatching());
Expand All @@ -69,6 +69,14 @@ public AlarmClientLeaf createDetachedCopy()
return pv;
}

/** When requesting a configuration update,
* a detached copy is used to send the request.
* @return {@link AlarmClientLeaf} with same configuration, but no parent
*/
public AlarmClientLeaf createDetachedCopy() {
return createDetachedCopy(getName());
}

/** @return Return description */
@Override
public String getDescription()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*******************************************************************************/
package org.phoebus.applications.alarm.client;

import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;

import org.phoebus.applications.alarm.model.AlarmTreeItemWithState;
Expand All @@ -27,4 +28,17 @@ public AlarmClientNode(final String parent_path, final String name)
super(parent_path, name, new CopyOnWriteArrayList<>());
state = new BasicState(SeverityLevel.OK);
}

/** @return {@link AlarmClientNode} with same configuration, but no parent or children */
public AlarmClientNode createDetachedCopy()
{
final AlarmClientNode node = new AlarmClientNode(null, getName());

node.setGuidance(new ArrayList<>(getGuidance()));
node.setDisplays(new ArrayList<>(getDisplays()));
node.setCommands(new ArrayList<>(getCommands()));
node.setActions(new ArrayList<>(getActions()));

return node;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,24 @@ public class Messages
public static String displays;
public static String enableAlarmFailed;
public static String enableAlarms;
public static String enterNameForDuplicate;
public static String guidance;
public static String headerAlreadyDisabled;
public static String headerAlreadyEnabled;
public static String headerConfirmDisable;
public static String headerConfirmDisableWithEnableDate;
public static String headerConfirmEnable;
public static String indefinitely;
public static String itemAlreadyExists;
public static String MenuPath;
public static String moveItemFailed;
public static String nameCannotBeEmpty;
public static String pasteItem;
public static String pasteItemFailed;
public static String promptTitle;
public static String renameItem;
public static String renameDialogLabel;
public static String renameDialogTitle;
public static String removeComponentFailed;
public static String renameItemFailed;
public static String totalPVs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@
*/
private final AtomicReference<List<String>> item_changes = new AtomicReference<>();

/** Set of items that have updated, with iteration order based on when they updated */
private final Set<String> items_to_update = new LinkedHashSet<>();
/** Set of items that have updated, with iteration order based on when they updated
*
* SYNC on access
*/
private final Set<String> item_paths_to_update = new LinkedHashSet<>();

Check warning on line 82 in app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/area/AlarmAreaView.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

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

/** Throttle [5Hz] used for updates of existing items */
private final UpdateThrottle update_throttle = new UpdateThrottle(200, TimeUnit.MILLISECONDS, this::updateItems);
Expand Down Expand Up @@ -165,9 +168,9 @@
if (null == item_name)
return;

synchronized (items_to_update)
synchronized (item_paths_to_update)
{
items_to_update.add(item_name);
item_paths_to_update.add(item_name);
}
update_throttle.trigger();
}
Expand All @@ -178,10 +181,10 @@
final List<String> changed_items = item_changes.getAndSet(null);

final String[] update_array;
synchronized (items_to_update)
synchronized (item_paths_to_update)
{
update_array = items_to_update.toArray(new String[items_to_update.size()]);
items_to_update.clear();
update_array = item_paths_to_update.toArray(new String[item_paths_to_update.size()]);
item_paths_to_update.clear();
}
Platform.runLater(() ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

import org.phoebus.applications.alarm.client.AlarmClient;
import org.phoebus.applications.alarm.client.AlarmClientLeaf;
import org.phoebus.applications.alarm.client.AlarmClientNode;
import org.phoebus.applications.alarm.model.AlarmTreeItem;
import org.phoebus.applications.alarm.model.AlarmTreePath;
import org.phoebus.applications.alarm.ui.Messages;
import org.phoebus.ui.dialog.DialogHelper;

import javafx.scene.control.TextInputDialog;
import javafx.scene.control.TreeView;
import org.phoebus.util.time.TimestampFormats;

/** @author Evan Smith
Expand Down Expand Up @@ -56,27 +54,26 @@ public static void rebuildTree(AlarmClient model, AlarmTreeItem<?> parent, Strin
}
}

/** Prompt the screen with a dialog box.
* @param title Title string of the dialog box.
* @param header Header string of the dialog box.
* @param default_text Default text contents of dialog box.
* @param node Node where the dialog box will be located.
* @return String The entered string or null if the entry was empty.
/** Moves the provided item and all its children to a new path.
*
* @param model AlarmClient used to communicate to the AlarmServer
* @param item AlarmTreeItem to move
* @param path Path that the parents' children will now be located at.
* @param removeOldItem Whether the old item should be removed once it is moved
*/
public static String prompt(String title, String header, final String default_text, final TreeView<AlarmTreeItem<?>> node)
{
// Prompt for new name
final TextInputDialog prompt = new TextInputDialog(default_text);
DialogHelper.positionDialog(prompt, node, -200, -100);
prompt.setTitle(title);
prompt.setHeaderText(header);
prompt.getDialogPane().setPrefWidth(500);
prompt.setResizable(true);
final String input = prompt.showAndWait().orElse("");
if (input.isEmpty())
return null;
return input;
}
public static void moveItem(AlarmClient model, AlarmTreeItem<?> item, String newPath, boolean removeOldItem) throws Exception
{
// Add the new item
model.sendItemConfigurationUpdate(newPath, item);
// ...and rebuild all its children
if (item instanceof AlarmClientNode) {
rebuildTree(model, item, newPath);
}
// Remove the item and all its children
if (removeOldItem) {
model.removeComponent(item);
}
}

/** Validate the passed path string by checking if the path name is valid.
*
Expand Down
Loading
Loading