Skip to content

Commit e747201

Browse files
committed
CSSTUDIO-2954 Install the optional informative tooltip.
1 parent 2a4738c commit e747201

File tree

1 file changed

+53
-43
lines changed

1 file changed

+53
-43
lines changed

app/display/editor/src/main/java/org/csstudio/display/builder/editor/properties/PropertyPanelSection.java

Lines changed: 53 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -212,30 +212,30 @@ public static Node bindSimplePropertyField(
212212
if (widget instanceof DisplayModel) { // DisplayModel is not registered as a Widget that users can add
213213
String text = Messages.Display;
214214
Label label = new Label(text, ImageCache.getImageView(ModelPlugin.class, "/icons/display.png"));
215-
Tooltip.install(label, new Tooltip(text));
215+
Tooltip.install(label, new Tooltip(text + possiblyInformativeTooltip(property)));
216216
field = label;
217217
} else {
218218
final String type = widget.getType();
219219
try {
220220
final ImageView icon = new ImageView(WidgetIcons.getIcon(type));
221221
final String name = WidgetFactory.getInstance().getWidgetDescriptor(type).getName();
222222
Label label = new Label(name, icon);
223-
Tooltip.install(label, new Tooltip(name));
223+
Tooltip.install(label, new Tooltip(name + possiblyInformativeTooltip(property)));
224224
field = label;
225225
} catch (Exception ex) {
226226
// Even 'unknown' widgets should have an icon,
227227
// but fall back to just showing the type name
228-
String text = String.valueOf(property.getValue());
228+
String text = String.valueOf(property.getValue() + possiblyInformativeTooltip(property));
229229
Label label = new Label(text);
230-
Tooltip.install(label, new Tooltip(text));
230+
Tooltip.install(label, new Tooltip(text + possiblyInformativeTooltip(property)));
231231
field = label;
232232
}
233233
}
234234
} else {
235235
final TextField text = new TextField();
236236
text.setText(String.valueOf(property.getValue()));
237237
text.setDisable(true);
238-
Tooltip.install(text, new Tooltip(text.getText()));
238+
Tooltip.install(text, new Tooltip(text.getText() + possiblyInformativeTooltip(property)));
239239
field = text;
240240
}
241241
} else if (property instanceof ColorWidgetProperty) {
@@ -246,12 +246,12 @@ public static Node bindSimplePropertyField(
246246
Function<WidgetColor, Tooltip> widgetColorToTooltip = (widgetColor) ->
247247
{
248248
if (widgetColor instanceof NamedWidgetColor) {
249-
return new Tooltip(((NamedWidgetColor) widgetColor).getName());
249+
return new Tooltip(((NamedWidgetColor) widgetColor).getName() + possiblyInformativeTooltip(property));
250250
} else {
251251
if (widgetColor.getAlpha() == 255) {
252-
return new Tooltip("RGB(" + widgetColor.getRed() + "," + widgetColor.getGreen() + "," + widgetColor.getBlue() + ")");
252+
return new Tooltip("RGB(" + widgetColor.getRed() + "," + widgetColor.getGreen() + "," + widgetColor.getBlue() + ")" + possiblyInformativeTooltip(property));
253253
} else {
254-
return new Tooltip("RGB(" + widgetColor.getRed() + "," + widgetColor.getGreen() + "," + widgetColor.getBlue() + "," + widgetColor.getAlpha() + ")");
254+
return new Tooltip("RGB(" + widgetColor.getRed() + "," + widgetColor.getGreen() + "," + widgetColor.getBlue() + "," + widgetColor.getAlpha() + ")" + possiblyInformativeTooltip(property));
255255
}
256256
}
257257
};
@@ -268,8 +268,8 @@ public static Node bindSimplePropertyField(
268268
font_field.setMnemonicParsing(false);
269269
font_field.setMaxWidth(Double.MAX_VALUE);
270270

271-
Tooltip.install(font_field, new Tooltip(font_prop.getValue().toString()));
272-
font_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(font_field, new Tooltip(new_value.toString())));
271+
Tooltip.install(font_field, new Tooltip(font_prop.getValue().toString() + possiblyInformativeTooltip(property)));
272+
font_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(font_field, new Tooltip(new_value.toString() + possiblyInformativeTooltip(property))));
273273

274274
final WidgetFontPropertyBinding binding = new WidgetFontPropertyBinding(undo, font_field, font_prop, other);
275275
bindings.add(binding);
@@ -283,12 +283,12 @@ public static Node bindSimplePropertyField(
283283
combo.setMaxWidth(Double.MAX_VALUE);
284284
combo.setMaxHeight(Double.MAX_VALUE);
285285

286-
Tooltip.install(combo, new Tooltip(enum_prop.getValue().toString()));
287-
enum_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(combo, new Tooltip(new_value.toString())));
286+
Tooltip.install(combo, new Tooltip(enum_prop.getValue().toString() + possiblyInformativeTooltip(property)));
287+
enum_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(combo, new Tooltip(new_value.toString() + possiblyInformativeTooltip(property))));
288288

289289
final ToggleButton macroButton = new ToggleButton("", ImageCache.getImageView(DisplayEditor.class, "/icons/macro-edit.png"));
290290
macroButton.getStyleClass().add("macro_button");
291-
macroButton.setTooltip(new Tooltip(Messages.MacroEditButton));
291+
macroButton.setTooltip(new Tooltip(Messages.MacroEditButton + possiblyInformativeTooltip(property)));
292292
BorderPane.setMargin(macroButton, new Insets(0, 0, 0, 3));
293293
BorderPane.setAlignment(macroButton, Pos.CENTER);
294294

@@ -338,13 +338,13 @@ public static Node bindSimplePropertyField(
338338
StackPane.setAlignment(check, Pos.CENTER_LEFT);
339339
final ToggleButton macroButton = new ToggleButton("", ImageCache.getImageView(DisplayEditor.class, "/icons/macro-edit.png"));
340340
macroButton.getStyleClass().add("macro_button");
341-
macroButton.setTooltip(new Tooltip(Messages.MacroEditButton));
341+
macroButton.setTooltip(new Tooltip(Messages.MacroEditButton + possiblyInformativeTooltip(property)));
342342
BorderPane.setMargin(macroButton, new Insets(0, 0, 0, 3));
343343
BorderPane.setAlignment(macroButton, Pos.CENTER);
344344

345345
{
346-
Tooltip tooltipWhenSetToTrue = new Tooltip("True");
347-
Tooltip tooltipWhenSetToFalse = new Tooltip("False");
346+
Tooltip tooltipWhenSetToTrue = new Tooltip("True" + possiblyInformativeTooltip(property));
347+
Tooltip tooltipWhenSetToFalse = new Tooltip("False" + possiblyInformativeTooltip(property));
348348

349349
Consumer<Boolean> setToolTip = (bool) -> {
350350
if (bool) {
@@ -389,9 +389,9 @@ public static Node bindSimplePropertyField(
389389
{
390390
if (colorMap instanceof PredefinedColorMaps.Predefined) {
391391
PredefinedColorMaps.Predefined predefinedColorMap = (PredefinedColorMaps.Predefined) colorMap;
392-
return new Tooltip(predefinedColorMap.getDescription());
392+
return new Tooltip(predefinedColorMap.getDescription() + possiblyInformativeTooltip(property));
393393
} else {
394-
return new Tooltip("Color Map");
394+
return new Tooltip("Color Map" + possiblyInformativeTooltip(property));
395395
}
396396
};
397397

@@ -413,8 +413,8 @@ public static Node bindSimplePropertyField(
413413
bindings.add(binding);
414414
binding.bind();
415415

416-
Tooltip.install(combo, new Tooltip(widget_class_prop.getValue()));
417-
widget_class_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(combo, new Tooltip(new_value)));
416+
Tooltip.install(combo, new Tooltip(widget_class_prop.getValue() + possiblyInformativeTooltip(property)));
417+
widget_class_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(combo, new Tooltip(new_value + possiblyInformativeTooltip(property))));
418418

419419
field = combo;
420420
} else if (property instanceof FilenameWidgetProperty) {
@@ -437,9 +437,9 @@ public static Node bindSimplePropertyField(
437437
bindings.add(binding);
438438
binding.bind();
439439

440-
Tooltip.install(select_file, new Tooltip("Select File"));
441-
Tooltip.install(text, new Tooltip(file_prop.getValue()));
442-
file_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(new_value)));
440+
Tooltip.install(select_file, new Tooltip("Select File" + possiblyInformativeTooltip(property)));
441+
Tooltip.install(text, new Tooltip(file_prop.getValue() + possiblyInformativeTooltip(property)));
442+
file_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(new_value + possiblyInformativeTooltip(property))));
443443

444444
field = new HBox(text, select_file);
445445
HBox.setHgrow(text, Priority.ALWAYS);
@@ -480,9 +480,9 @@ public void bind() {
480480
});
481481

482482

483-
Tooltip.install(open_editor, new Tooltip("Open Editor"));
484-
Tooltip.install(text, new Tooltip(pv_prop.getValue()));
485-
pv_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(new_value)));
483+
Tooltip.install(open_editor, new Tooltip("Open Editor" + possiblyInformativeTooltip(property)));
484+
Tooltip.install(text, new Tooltip(pv_prop.getValue() + possiblyInformativeTooltip(property)));
485+
pv_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(new_value + possiblyInformativeTooltip(property))));
486486

487487
field = new HBox(text, open_editor);
488488
HBox.setHgrow(text, Priority.ALWAYS);
@@ -496,17 +496,17 @@ public void bind() {
496496
final MacroizedWidgetProperty<?> macro_prop = (MacroizedWidgetProperty<?>) property;
497497
final TextField text = new TextField();
498498
text.setPromptText(macro_prop.getDefaultValue().toString());
499-
text.setOnKeyReleased((event) -> Tooltip.install(text, new Tooltip(text.getText())));
499+
text.setOnKeyReleased((event) -> Tooltip.install(text, new Tooltip(text.getText() + possiblyInformativeTooltip(property))));
500500
final MacroizedWidgetPropertyBinding binding = new MacroizedWidgetPropertyBinding(undo, text, macro_prop, other);
501501
bindings.add(binding);
502502
binding.bind();
503503

504-
Tooltip.install(text, new Tooltip(text.getText()));
504+
Tooltip.install(text, new Tooltip(text.getText() + possiblyInformativeTooltip(property)));
505505

506506
if (CommonWidgetProperties.propText.getName().equals(property.getName()) ||
507507
CommonWidgetProperties.propTooltip.getName().equals(property.getName())) { // Allow editing multi-line text in dialog
508508
final Button open_editor = new Button("...");
509-
Tooltip.install(open_editor, new Tooltip("Open Editor"));
509+
Tooltip.install(open_editor, new Tooltip("Open Editor" + possiblyInformativeTooltip(property)));
510510
open_editor.setOnAction(event ->
511511
{
512512
final MultiLineInputDialog dialog = new MultiLineInputDialog(open_editor, macro_prop.getSpecification());
@@ -520,7 +520,7 @@ public void bind() {
520520
undo.execute(new SetMacroizedWidgetPropertyAction(other_prop, result.get()));
521521
}
522522
text.setText(result.get().replaceAll("\n", "\\\\n"));
523-
Tooltip.install(text, new Tooltip(result.get()));
523+
Tooltip.install(text, new Tooltip(result.get() + possiblyInformativeTooltip(property)));
524524
});
525525
field = new HBox(text, open_editor);
526526
HBox.setHgrow(text, Priority.ALWAYS);
@@ -540,8 +540,8 @@ public void bind() {
540540
bindings.add(binding);
541541
binding.bind();
542542

543-
Tooltip.install(points_field, new Tooltip(points_prop.getValue().size() + " Points"));
544-
points_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(points_field, new Tooltip(new_value.size() + " Points")));
543+
Tooltip.install(points_field, new Tooltip(points_prop.getValue().size() + " Points" + possiblyInformativeTooltip(property)));
544+
points_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(points_field, new Tooltip(new_value.size() + " Points" + possiblyInformativeTooltip(property))));
545545

546546
field = points_field;
547547
}
@@ -572,7 +572,7 @@ private void createPropertyUI(
572572
final Label label = new Label(property.getDescription());
573573
label.setMaxWidth(Double.MAX_VALUE);
574574
final String tooltip = property.getDescription() + " (" + property.getPath() + ")";
575-
label.setTooltip(new Tooltip(tooltip));
575+
label.setTooltip(new Tooltip(tooltip + possiblyInformativeTooltip(property)));
576576
// setGridLinesVisible(true); // For debugging the layout
577577

578578
Node field = bindSimplePropertyField(undo, bindings, property, other);
@@ -587,8 +587,8 @@ private void createPropertyUI(
587587
bindings.add(binding);
588588
binding.bind();
589589

590-
Tooltip.install(macros_field, new Tooltip(macros_field.getText()));
591-
macros_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(macros_field, new Tooltip(macros_field.getText())));
590+
Tooltip.install(macros_field, new Tooltip(macros_field.getText() + possiblyInformativeTooltip(property)));
591+
macros_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(macros_field, new Tooltip(macros_field.getText() + possiblyInformativeTooltip(property))));
592592

593593
field = macros_field;
594594
} else if (property instanceof ActionsWidgetProperty) {
@@ -600,8 +600,8 @@ private void createPropertyUI(
600600
bindings.add(binding);
601601
binding.bind();
602602

603-
Tooltip.install(actions_field, new Tooltip(actions_field.getText()));
604-
actions_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(actions_field, new Tooltip(actions_field.getText())));
603+
Tooltip.install(actions_field, new Tooltip(actions_field.getText() + possiblyInformativeTooltip(property)));
604+
actions_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(actions_field, new Tooltip(actions_field.getText() + possiblyInformativeTooltip(property))));
605605

606606
field = actions_field;
607607
} else if (property instanceof ScriptsWidgetProperty) {
@@ -613,8 +613,8 @@ private void createPropertyUI(
613613
bindings.add(binding);
614614
binding.bind();
615615

616-
Tooltip.install(scripts_field, new Tooltip(scripts_field.getText()));
617-
scripts_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(scripts_field, new Tooltip(scripts_field.getText())));
616+
Tooltip.install(scripts_field, new Tooltip(scripts_field.getText() + possiblyInformativeTooltip(property)));
617+
scripts_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(scripts_field, new Tooltip(scripts_field.getText() + possiblyInformativeTooltip(property))));
618618

619619
field = scripts_field;
620620
} else if (property instanceof RulesWidgetProperty) {
@@ -625,8 +625,8 @@ private void createPropertyUI(
625625
bindings.add(binding);
626626
binding.bind();
627627

628-
Tooltip.install(rules_field, new Tooltip(rules_field.getText()));
629-
rules_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(rules_field, new Tooltip(rules_field.getText())));
628+
Tooltip.install(rules_field, new Tooltip(rules_field.getText() + possiblyInformativeTooltip(property)));
629+
rules_prop.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(rules_field, new Tooltip(rules_field.getText() + possiblyInformativeTooltip(property))));
630630

631631
field = rules_field;
632632
} else if (property instanceof StructuredWidgetProperty) {
@@ -724,8 +724,8 @@ private void createPropertyUI(
724724
text.setText(String.valueOf(property.getValue()));
725725
text.setEditable(false);
726726

727-
Tooltip.install(text, new Tooltip(text.getText()));
728-
property.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(text.getText())));
727+
Tooltip.install(text, new Tooltip(text.getText() + possiblyInformativeTooltip(property)));
728+
property.addPropertyListener((listener, old_value, new_value) -> Tooltip.install(text, new Tooltip(text.getText() + possiblyInformativeTooltip(property))));
729729

730730
field = text;
731731
}
@@ -848,6 +848,16 @@ private void fillIndent(final int indentationLevel, final int row) {
848848
}
849849
}
850850

851+
private static String possiblyInformativeTooltip(WidgetProperty property) {
852+
Optional<String> informativeTooltip = property.getInformativeTooltip();
853+
if (informativeTooltip.isPresent()) {
854+
return "\n\n" + informativeTooltip.get();
855+
}
856+
else {
857+
return "";
858+
}
859+
}
860+
851861
/**
852862
* Clear the property UI
853863
* <P>Removes all property bindings and their UI

0 commit comments

Comments
 (0)