From 309a06b39a26a846c72e081c52c878097f7926c9 Mon Sep 17 00:00:00 2001 From: kasemir Date: Fri, 21 Apr 2023 11:20:19 -0400 Subject: [PATCH 1/2] Alarm config action: Preserve PV names For "sevrpv:ThePVName", ThePVName with colons would not show properly in the dialog Fixes #2649 --- .../alarm/ui/tree/TitleDetailDelayTable.java | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java index 21d381fe64..8185325120 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Oak Ridge National Laboratory. + * Copyright (c) 2018-2023 Oak Ridge National Laboratory. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -215,36 +215,46 @@ private void createTable() } /** - * This function extract the command option from detail "option:info" + * This function extracts the option from detail "option:info" * * @param titleDetailDelay - * @return enum Option_d either mailto or cmd + * @return enum Option_d (mailto, cmd, sevrpv) */ - private Option_d getOptionFromDetail(TitleDetailDelay titleDetailDelay) { - Option_d option = null; - String detail = titleDetailDelay != null ? titleDetailDelay.detail : null; - String[] split = detail != null ? detail.split(":") : null; - String optionString = split != null && split.length > 0 ? split[0] : null; - try { - option = optionString != null ? Option_d.valueOf(optionString) : Option_d.mailto; - } catch (Exception e) { - option = Option_d.mailto; + private Option_d getOptionFromDetail(final TitleDetailDelay titleDetailDelay) + { + if (titleDetailDelay == null) + return null; + + final int sep = titleDetailDelay.detail.indexOf(':'); + if (sep < 0) + return Option_d.mailto; + + try + { + return Option_d.valueOf(titleDetailDelay.detail.substring(0, sep)); + } + catch (Exception e) + { + return Option_d.mailto; } - return option; } /** - * This function extract the info from detail "option:info" + * This function extracts the info from detail "option:info" * * @param titleDetailDelay - * @return information eg : mail or command + * @return information eg : mail, command, PV */ - private String getInfoFromDetail(TitleDetailDelay titleDetailDelay) { - String info = ""; - String detail = titleDetailDelay != null ? titleDetailDelay.detail : null; - String[] split = detail != null ? detail.split(":") : null; - info = split != null && split.length > 1 ? split[1] : ""; - return info; + private String getInfoFromDetail(final TitleDetailDelay titleDetailDelay) + { + if (titleDetailDelay == null) + return null; + + final int sep = titleDetailDelay.detail.indexOf(':'); + if (sep < 0) + return ""; + + return titleDetailDelay.detail.substring(sep+1); } /** From d3424df25abef31ba435909517b3f0eb7ecb99a4 Mon Sep 17 00:00:00 2001 From: kasemir Date: Fri, 21 Apr 2023 11:25:23 -0400 Subject: [PATCH 2/2] Tabs.. --- .../alarm/ui/tree/TitleDetailDelayTable.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java index 8185325120..da96a114e4 100644 --- a/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java +++ b/app/alarm/ui/src/main/java/org/phoebus/applications/alarm/ui/tree/TitleDetailDelayTable.java @@ -223,19 +223,19 @@ private void createTable() private Option_d getOptionFromDetail(final TitleDetailDelay titleDetailDelay) { if (titleDetailDelay == null) - return null; + return null; final int sep = titleDetailDelay.detail.indexOf(':'); if (sep < 0) - return Option_d.mailto; + return Option_d.mailto; try { - return Option_d.valueOf(titleDetailDelay.detail.substring(0, sep)); + return Option_d.valueOf(titleDetailDelay.detail.substring(0, sep)); } catch (Exception e) { - return Option_d.mailto; + return Option_d.mailto; } } @@ -248,11 +248,11 @@ private Option_d getOptionFromDetail(final TitleDetailDelay titleDetailDelay) private String getInfoFromDetail(final TitleDetailDelay titleDetailDelay) { if (titleDetailDelay == null) - return null; + return ""; final int sep = titleDetailDelay.detail.indexOf(':'); if (sep < 0) - return ""; + return ""; return titleDetailDelay.detail.substring(sep+1); }