Skip to content

Commit 7317c47

Browse files
committed
Fix bug for Variable that contains dot in the name and add a tooltip on
description cell
1 parent 59b4d77 commit 7317c47

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

app/pvtable/src/main/java/org/phoebus/applications/pvtable/model/PVTableItem.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class PVTableItem
5252

5353
/** Value of the PV's description */
5454
private volatile String desc_value = "";
55+
private volatile String desc_name = "";
5556

5657
/** Saved (snapshot) value */
5758
private volatile Optional<SavedValue> saved = Optional.empty();
@@ -77,6 +78,9 @@ public class PVTableItem
7778

7879
/** Listener to description PV */
7980
private volatile Disposable desc_flow;
81+
82+
private static final String DESC_FIELD = "DESC";
83+
private static final String DOT = ".";
8084

8185
/** Initialize
8286
*
@@ -148,12 +152,23 @@ private void createPVs(final String name)
148152
name.startsWith("loc:")))
149153
{
150154
// Determine DESC field.
151-
// If name already includes a field,
152-
// replace it with DESC field.
153-
final int sep = name.lastIndexOf('.');
154-
final String desc_name = sep >= 0
155-
? name.substring(0, sep) + ".DESC"
156-
: name + ".DESC";
155+
//Bug when a pv name contains a . caracters
156+
desc_name = name + DOT + DESC_FIELD;
157+
if(!name.endsWith(DOT + DESC_FIELD) && name.contains(DOT)) {
158+
// If name already includes a field
159+
// It can be a EPICS fields such as .VAL .EGU ...
160+
// EPICS fields are always in Upper Case
161+
// EPICS fields are 4 characters length max
162+
final int sep = name.lastIndexOf('.');
163+
String fieldVal = name.substring(sep + 1);
164+
//System.out.println("fieldVal=" + fieldVal);
165+
//Test if it in uppercase and max length 4
166+
boolean isEpicsField = fieldVal.toUpperCase().equals(fieldVal) && fieldVal.length() < 5;
167+
if(isEpicsField) {
168+
desc_name = name.replace(fieldVal, DESC_FIELD);
169+
}
170+
}
171+
157172
try
158173
{
159174
final PV new_desc_pv = PVPool.getPV(desc_name);
@@ -244,6 +259,11 @@ public String getDescription()
244259
{
245260
return desc_value;
246261
}
262+
263+
/** @return description pv name **/
264+
public String getDescriptionName() {
265+
return desc_name;
266+
}
247267

248268
/** @return Enum options for current value, <code>null</code> if not enumerated */
249269
public String[] getValueOptions()

app/pvtable/src/main/java/org/phoebus/applications/pvtable/ui/PVTable.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383
import javafx.scene.paint.Color;
8484
import javafx.util.converter.DefaultStringConverter;
8585

86-
import static org.phoebus.ui.application.PhoebusApplication.logger;
87-
8886

8987
/** PV Table and its toolbar
9088
* @author Kay Kasemir
@@ -164,6 +162,24 @@ protected void updateItem(final Boolean selected, final boolean empty)
164162
}
165163
}
166164
}
165+
166+
private static class DescriptionTableCell extends TableCell<TableItemProxy, String>
167+
{
168+
@Override
169+
protected void updateItem(final String item, final boolean empty)
170+
{
171+
super.updateItem(item, empty);
172+
setText(item);
173+
final int row = getIndex();
174+
final List<TableItemProxy> items = getTableView().getItems();
175+
if (! empty && row >= 0 && row < items.size()) {
176+
final TableItemProxy itemCell = items.get(row);
177+
if(itemCell != null && itemCell.getItem() != null) {
178+
setTooltip(new Tooltip(itemCell.getItem().getDescriptionName()));
179+
}
180+
}
181+
}
182+
}
167183

168184
/** Table cell for 'name' column, colors comments */
169185
private static class PVNameTableCell extends TextFieldTableCell<TableItemProxy, String>
@@ -784,6 +800,7 @@ private void createTableColumns()
784800
{
785801
col = new TableColumn<>(Messages.Description);
786802
col.setCellValueFactory(cell -> cell.getValue().desc_value);
803+
col.setCellFactory(column -> new DescriptionTableCell());
787804
table.getColumns().add(col);
788805
}
789806

0 commit comments

Comments
 (0)