Skip to content

Commit c3afdb3

Browse files
committed
fix: allow to clean variable (write "" into PV)
1 parent 91b164d commit c3afdb3

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

app/display/model/src/main/java/org/csstudio/display/builder/model/widgets/AutoCompleteWidget.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,31 @@ public Widget createWidget() {
6666
* 'items' property: list of items (string properties) for auto-completion
6767
*/
6868
public static final WidgetPropertyDescriptor<String> propItems =
69-
newPVNamePropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "testitems",
70-
"AutoComplete Item");
69+
newPVNamePropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "testitems", "Suggestions");
7170

7271
/**
7372
* 'max_suggestions' property: maximum number of suggestions to display
7473
*/
7574
private static final WidgetPropertyDescriptor<Integer> propMaxSuggestions =
76-
newIntegerPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "max_suggestions",
77-
"Max Suggestions");
75+
newIntegerPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "max_suggestions", "Max Suggestions");
7876

7977
/**
8078
* 'min_chars' property: minimum characters to trigger autocomplete
8179
*/
8280
private static final WidgetPropertyDescriptor<Integer> propMinCharacters =
83-
newIntegerPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "min_characters",
84-
"Min Characters");
81+
newIntegerPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "min_characters", "Min Characters");
8582

8683
/**
8784
* 'case_sensitive' property: whether matching is case sensitive
8885
*/
8986
private static final WidgetPropertyDescriptor<Boolean> propCaseSensitive =
90-
newBooleanPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "case_sensitive",
91-
"Case Sensitive");
87+
newBooleanPropertyDescriptor(WidgetPropertyCategory.BEHAVIOR, "case_sensitive", "Case Sensitive");
9288

9389
/**
9490
* 'placeholder' property: placeholder text when empty
9591
*/
9692
private static final WidgetPropertyDescriptor<String> propPlaceholder =
97-
newStringPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "placeholder",
98-
"Placeholder Text");
93+
newStringPropertyDescriptor(WidgetPropertyCategory.DISPLAY, "placeholder", "Placeholder Text");
9994

10095
/**
10196
* 'filter_mode' property: how to filter suggestions (starts_with, contains, fuzzy)

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/AutoCompleteRepresentation.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
*******************************************************************************/
88
package org.csstudio.display.builder.representation.javafx.widgets;
99

10+
import static org.csstudio.display.builder.representation.ToolkitRepresentation.logger;
11+
1012
import java.text.MessageFormat;
1113
import java.util.Arrays;
1214
import java.util.Collections;
1315
import java.util.List;
16+
import java.util.logging.Level;
1417

1518
import javafx.scene.input.KeyCode;
1619
import javafx.scene.input.KeyEvent;
@@ -263,7 +266,7 @@ private void setupTextFieldEventHandlers(TextField textField) {
263266
suggestionsPopup.hide();
264267
}
265268
String text = textField.getText();
266-
if (text != null && !text.trim().isEmpty()) {
269+
if (text != null) {
267270
confirmValue(text);
268271
}
269272
});
@@ -452,8 +455,7 @@ private void confirmValue(final String value) {
452455
Object mappedValue;
453456

454457
if (currentPvValue instanceof VEnum) {
455-
mappedValue = FormatOptionHandler.parse(currentPvValue, value,
456-
FormatOption.DEFAULT);
458+
mappedValue = FormatOptionHandler.parse(currentPvValue, value, FormatOption.DEFAULT);
457459
} else {
458460
try {
459461
if (value.contains(".")) {
@@ -462,15 +464,15 @@ private void confirmValue(final String value) {
462464
mappedValue = Integer.parseInt(value);
463465
}
464466
} catch (NumberFormatException e) {
467+
// This will handle String PVs, which are expected to be most likely
465468
VType convertedValue = VType.toVType(value);
466469
mappedValue = (convertedValue != null) ? convertedValue : value;
467470
}
468471
}
469472

470473
toolkit.fireWrite(model_widget, mappedValue);
471474
} catch (Exception e) {
472-
System.err.println("Error writing to PV: " + e.getMessage());
473-
e.printStackTrace();
475+
logger.log(Level.WARNING, "Error writing to PV", e);
474476
}
475477
}
476478

0 commit comments

Comments
 (0)