From fcda7f6ef0ae065f88d3bc2aecb2e94aaac2d1d5 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 15 Feb 2022 13:19:33 +0100 Subject: [PATCH] klighd: added possibility to configure descriptions for synthesis options and show them in tooltips on hover. --- .../SynthesisOptionControlFactory.java | 15 +++++++++----- .../cau/cs/kieler/klighd/SynthesisOption.java | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java index c09a3070d..30c5fff6e 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java @@ -326,7 +326,8 @@ private SynthesisOptionControlFactory createCategorySynthesisOptionControlFactor // Create category container for diagram synthesis options Section categorySection = formToolkit.createSection(parent, Section.CLIENT_INDENT | Section.NO_TITLE_FOCUS_BOX | Section.TWISTIE); - + + categorySection.setToolTipText(option.getDescription()); if (option.getName() != null && !option.getName().isEmpty()) { categorySection.setText(option.getName()); } else { @@ -406,7 +407,7 @@ private void createCheckOptionControl(final SynthesisOption option, final ViewContext context) { final Button checkButton = formToolkit.createButton(parent, option.getName(), SWT.CHECK); - checkButton.setToolTipText(option.getName()); + checkButton.setToolTipText(option.getDescription()); controls.add(checkButton); // set initial value @@ -462,7 +463,8 @@ private void createChoiceOptionControl(final SynthesisOption option, final ViewC controls.add(valuesContainer); // add the radio group label ... - formToolkit.createLabel(valuesContainer, option.getName() + ":"); + Label label = formToolkit.createLabel(valuesContainer, option.getName() + ":"); + label.setToolTipText(option.getDescription()); // ... and a radio button for each possible value GridData vGd; @@ -472,7 +474,7 @@ private void createChoiceOptionControl(final SynthesisOption option, final ViewC // create the button ... final Button button = formToolkit.createButton(valuesContainer, value.toString(), SWT.RADIO); - button.setToolTipText(value.toString()); + button.setToolTipText(option.getDescription());; button.setLayoutData(vGd); final String us = option.getUpdateStrategy(); @@ -533,12 +535,13 @@ private void createRangeOptionControl(final SynthesisOption option, final ViewCo // add the label ... final Label label = formToolkit.createLabel(container, ""); + label.setToolTipText(option.getDescription()); // ... and the scaler for choosing the value final Scale scale = new Scale(container, SWT.NONE); // the following setting is needed on windows scale.setBackground(container.getBackground()); - scale.setToolTipText(option.getName()); + scale.setToolTipText(option.getDescription()); // configure its layout, esp. the minimal width and the 'grab additional space' final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); @@ -678,9 +681,11 @@ private void createTextOptionControl(final SynthesisOption option, final ViewCon // add the label ... final Label label = formToolkit.createLabel(container, ""); + label.setToolTipText(option.getDescription()); // ... and the text box for choosing the value final Text text = formToolkit.createText(container, (String) context.getOptionValue(option)); + text.setToolTipText(option.getDescription()); // configure its layout final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/SynthesisOption.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/SynthesisOption.java index 283d33656..3fc103a7c 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/SynthesisOption.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/SynthesisOption.java @@ -636,6 +636,8 @@ private enum TransformationOptionType { private String updateAction = null; /** The optional category option. */ private SynthesisOption category = null; + /** An optional description of this option. */ + private String description = null; /** * Constructor. @@ -883,6 +885,24 @@ public SynthesisOption setCategory(final SynthesisOption newCategory) { return this; } + /** + * @return the description of what this option does, or the option's name if not configured. + */ + public String getDescription() { + return description != null ? description : getName(); + } + + /** + * Sets the description of what this option does. + * @param newDescription + * the new description for this option, or null to unset this option. + * @return this {@link SynthesisOption} for convenience. + */ + public SynthesisOption setDescription(final String newDescription) { + this.description = newDescription; + return this; + } + /** * Creates a synthesis option id using the class and the name of the option. *