From 7b89c5dba40b8264f02b4d0991eccb50ee98bbf2 Mon Sep 17 00:00:00 2001 From: Nicolas Peransin Date: Mon, 18 May 2026 17:10:15 +0200 Subject: [PATCH] [3] Do not disable scrollable widgets when not editable Not editable widget must not be disabled. Disable widget cannot be scrolled. User should be able to read and copy the content. Actions must still be driven by "is Enabled Expression". https://github.com/eclipse-eef/org.eclipse.eef/issues/3 Change-Id: I46b47a1ade5b3472191e619f07aa1c4db93adaa9 Signed-off-by: Nicolas Peransin --- .../pages/releasenotes.html | 11 ++++++-- .../pages/releasenotes.textile | 6 +++- .../api/controllers/IEEFListController.java | 10 +++++++ .../controllers/EEFListController.java | 28 +++++++++++++++++++ ...FExtMultipleReferenceLifecycleManager.java | 27 ++++++++++++++++++ .../widgets/EEFListLifecycleManager.java | 6 ++-- .../widgets/EEFTextLifecycleManager.java | 3 +- 7 files changed, 84 insertions(+), 7 deletions(-) diff --git a/doc/org.eclipse.eef.documentation/pages/releasenotes.html b/doc/org.eclipse.eef.documentation/pages/releasenotes.html index 754590daf..04d8b264e 100644 --- a/doc/org.eclipse.eef.documentation/pages/releasenotes.html +++ b/doc/org.eclipse.eef.documentation/pages/releasenotes.html @@ -2,8 +2,6 @@ - releasenotes -

Release Notes for Eclipse EEF

@@ -11,6 +9,9 @@

Release Notes for Eclipse EEF

  • Release Notes for Eclipse EEF
      +
    1. + Changes in EEF 2.1.7 +
    2. Changes in EEF 2.1.1
    3. @@ -60,6 +61,10 @@

      Release Notes for Eclipse EEF

    This document contains the release notes for recent major releases of EEF.

    +

    Changes in EEF 2.1.7

    +
      +
    • Modified When disabled, content of lists, text areas and field are still readable. Widgets are scrollable and selectable even if they cannot be edited and actions are disabled.
    • +

    Changes in EEF 2.1.1

    • Modified Add the workbench part and the selection to the tab descriptor filter extension point.
    • @@ -157,7 +162,7 @@

      Developer-Visible Changes

      Changes in EEF 1.7.2

      Specifier-Visible Changes

        -
      • Modified The dynamic mappings will take into account all the «if» blocks with a valid predicate expression and not only the first one.
      • +
      • Modified The dynamic mappings will take into account all the «if» blocks with a valid predicate expression and not only the first one.
      • Modified Fixed an issue with the enablement of the widget actions of the reference widget.

      Changes in EEF 1.7.1

      diff --git a/doc/org.eclipse.eef.documentation/pages/releasenotes.textile b/doc/org.eclipse.eef.documentation/pages/releasenotes.textile index 1f1120bb0..991edc216 100644 --- a/doc/org.eclipse.eef.documentation/pages/releasenotes.textile +++ b/doc/org.eclipse.eef.documentation/pages/releasenotes.textile @@ -4,6 +4,10 @@ h2. Release Notes for Eclipse EEF This document contains the release notes for recent major releases of EEF. +h3(#eef2.1.7). Changes in EEF 2.1.7 + +* Modified When disabled, content of lists, text areas and field are still readable. Widgets are scrollable and selectable even if they cannot be edited and actions are disabled. + h3(#eef2.1.1). Changes in EEF 2.1.1 * Modified Add the workbench part and the selection to the tab descriptor filter extension point. @@ -89,7 +93,7 @@ h3(#eef1.7.2). Changes in EEF 1.7.2 h4. Specifier-Visible Changes -* Modified The dynamic mappings will take into account all the "if" blocks with a valid predicate expression and not only the first one. +* Modified The dynamic mappings will take into account all the «if» blocks with a valid predicate expression and not only the first one. * Modified Fixed an issue with the enablement of the widget actions of the reference widget. diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFListController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFListController.java index b5575ab51..754df7bd7 100644 --- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFListController.java +++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/api/controllers/IEEFListController.java @@ -23,6 +23,16 @@ * @author mbats */ public interface IEEFListController extends IEEFOnClickController { + + /** + * Sets the enablement of action on selection. + * + * @param isEnabled + * true when the widget should have its default behavior, false when the widget + * should be in a read only mode. + */ + void setEnabled(boolean isEnabled); + /** * Register a consumer which will be called with the new value of the text when it will change. * diff --git a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFListController.java b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFListController.java index f90a482c2..0673a3802 100644 --- a/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFListController.java +++ b/plugins/org.eclipse.eef.core/src/org/eclipse/eef/core/internal/controllers/EEFListController.java @@ -47,6 +47,11 @@ public class EEFListController extends AbstractEEFOnClickController implements I */ private Consumer newValueConsumer; + /** + * Enable flag to drive on-click. + */ + private boolean enabled = true; + /** * The constructor. * @@ -130,6 +135,29 @@ public IStatus action(final EEFWidgetAction action, final List elements) }); } + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.core.api.controllers.IEEFListController#setEnabled(boolean) + */ + @Override + public void setEnabled(boolean isEnabled) { + this.enabled = isEnabled; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.eef.core.api.controllers.AbstractEEFOnClickController#onClick(java.lang.Object, + * java.lang.String) + */ + @Override + public void onClick(Object element, String onClickEventKind) { + if (enabled) { + super.onClick(element, onClickEventKind); + } + } + /** * {@inheritDoc} * diff --git a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java index 2498e1b91..9ff7ba737 100644 --- a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtMultipleReferenceLifecycleManager.java @@ -43,6 +43,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; @@ -94,6 +95,11 @@ public class EEFExtMultipleReferenceLifecycleManager extends AbstractEEFExtRefer */ protected ButtonSelectionListener downButtonListener; + /** + * The default background color of the text field. + */ + private Color defaultBackgroundColor; + /** * The constructor. * @@ -124,6 +130,7 @@ public EEFExtMultipleReferenceLifecycleManager(EEFExtReferenceDescription descri @Override protected void createMainControl(Composite parent, IEEFFormContainer formContainer) { this.widgetFactory = formContainer.getWidgetFactory(); + defaultBackgroundColor = parent.getBackground(); Composite referenceComposite = this.widgetFactory.createFlatFormComposite(parent); GridLayout referenceGridLayout = new GridLayout(2, false); @@ -394,6 +401,10 @@ public void refresh() { protected void setEnabled(boolean isEnabled) { super.setEnabled(isEnabled); + if (this.tableViewer != null && this.tableViewer.getTable() != null && !this.tableViewer.getTable().isDisposed()) { + // Background color is handled like List widget + this.tableViewer.getTable().setBackground(this.getBackgroundColor(isEnabled)); + } if (this.upButton != null && !this.upButton.isDisposed()) { this.upButton.setEnabled(isEnabled); } @@ -402,6 +413,22 @@ protected void setEnabled(boolean isEnabled) { } } + /** + * Get the background color according to the current valid style. + * + * @param isEnabled + * true if the widget is enabled, false otherwise + * + * @return The background color to use in the text field. + */ + private Color getBackgroundColor(boolean isEnabled) { + Color color = defaultBackgroundColor; + if (!isEnabled) { + color = widgetFactory.getColors().getInactiveBackground(); + } + return color; + } + /** * {@inheritDoc} * diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java index 154a332de..458b8e14c 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFListLifecycleManager.java @@ -93,7 +93,7 @@ public class EEFListLifecycleManager extends AbstractEEFWidgetLifecycleManager { /** * The listener used to run the onClick expression when the user will click on the table. */ - private SelectionListener tableSelectionListener; + private EEFTableSelectionListener tableSelectionListener; /** * The constructor. @@ -178,6 +178,7 @@ private void createListWidget(Composite parent) { final int clientWidth = scrolledComposite.getClientArea().width; this.tableViewer.getTable().setSize(clientWidth, Math.max(TABLE_MINIMAL_HEIGHT, widgetHeight)); + tableViewer.getTable().setBackground(defaultBackgroundColor); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setAlwaysShowScrollBars(true); @@ -278,7 +279,8 @@ private void setListValue(Object value) { protected void setEnabled(boolean isEnabled) { if (this.tableViewer != null && this.tableViewer.getTable() != null && !this.tableViewer.getTable().isDisposed()) { this.tableViewer.getTable().setBackground(this.getBackgroundColor(isEnabled)); - this.tableViewer.getTable().setEnabled(isEnabled); + // tableViewer is not disabled so user can scroll. + controller.setEnabled(isEnabled); } this.actionButtons.stream().filter(actionButton -> !actionButton.getButton().isDisposed()) .forEach(actionButton -> actionButton.setEnabled(isEnabled)); diff --git a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java index c7e8bb1f4..90b40bb2f 100644 --- a/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java +++ b/plugins/org.eclipse.eef.ide.ui/src/org/eclipse/eef/ide/ui/internal/widgets/EEFTextLifecycleManager.java @@ -570,7 +570,8 @@ private String computeTextFromModel() { protected void setEnabled(boolean isEnabled) { if (!this.text.isDisposed()) { this.text.setEditable(isEnabled); - this.text.setEnabled(isEnabled); + // text must not be disabled. + // User need to scroll for text area or copy content. this.text.setBackground(this.getBackgroundColor(isEnabled)); this.text.setForeground(this.getForegroundColor(isEnabled)); }