From 75bdb3ed59221b1603becd3284ff02040ccb0e89 Mon Sep 17 00:00:00 2001 From: Elena Parovyshnaia Date: Fri, 16 Apr 2021 13:24:51 +0300 Subject: [PATCH 1/3] Bug 572906 improve DiagnosticDialog UX with colors - 'error code' column background is colored in one of four colors depending on severity and exception containment - 'type' column is added to explain the code in general Signed-off-by: eparovyshnaya --- .../dialogs/licensing/DiagnosticColors.java | 49 +++++++++++++++++++ .../dialogs/licensing/DiagnosticDialog.java | 22 +++++++-- .../dialogs/licensing/HereLabelProvider.java | 14 +++--- .../jface/dialogs/licensing/HereTable.java | 12 ++++- .../jface/i18n/DiagnosticDialogMessages.java | 3 +- .../i18n/DiagnosticDialogMessages.properties | 3 +- 6 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticColors.java diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticColors.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticColors.java new file mode 100644 index 000000000..e1bfaf51f --- /dev/null +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticColors.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.internal.jface.dialogs.licensing; + +import java.util.Arrays; + +import org.eclipse.swt.graphics.Color; + +final class DiagnosticColors { + + private final Color failure; + private final Color error; + private final Color warning; + private final Color info; + + DiagnosticColors() { + this.failure = new Color(222, 145, 145); + this.error = new Color(233, 175, 215); + this.warning = new Color(244, 228, 186); + this.info = new Color(178, 201, 166); + } + + Color get(boolean severe, boolean exception) { + if (severe && exception) { + return failure; + } else if (severe && !exception) { + return error; + } else if (!severe && exception) { + return warning; + } else { + return info; + } + } + + void dispose() { + Arrays.asList(failure, error, warning, info)// + .forEach(Color::dispose); + } +} diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticDialog.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticDialog.java index c0c51ac8e..2eb0730da 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticDialog.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/DiagnosticDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020 ArSysOp + * Copyright (c) 2020, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -21,17 +21,20 @@ import org.eclipse.passage.lic.internal.base.diagnostic.SumOfLists; import org.eclipse.passage.lic.internal.base.diagnostic.TroubleHasException; import org.eclipse.passage.lic.internal.jface.i18n.DiagnosticDialogMessages; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; public final class DiagnosticDialog extends NotificationDialog { private final Diagnostic diagnostic; + private final DiagnosticColors colors; private ButtonConfig error; public DiagnosticDialog(Shell shell, Diagnostic diagnostic) { super(shell); this.diagnostic = diagnostic; + this.colors = new DiagnosticColors(); } @Override @@ -39,7 +42,7 @@ protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(DiagnosticDialogMessages.DiagnosticDialog_title); shell.setImage(getDefaultImage()); - shell.setSize(850, 600); + shell.setSize(1250, 500); } @Override @@ -56,10 +59,12 @@ protected void initButtons() { @Override protected void buildUI(Composite parent) { - viewer = new HereTable(parent, Trouble.class) // - .withColumn(DiagnosticDialogMessages.DiagnosticDialog_column_details, 750, Trouble::details) + viewer = new HereTable(parent, Trouble.class, this::backdround) // + .withColumn(DiagnosticDialogMessages.DiagnosticDialog_column_details, 900, Trouble::details) .withColumn(DiagnosticDialogMessages.DiagnosticDialog_column_code, 50, trouble -> Integer.toString(trouble.code().code()))// + .withColumn(DiagnosticDialogMessages.DiagnosticDialog_column_type, 250, + trouble -> trouble.code().explanation())// .viewer(); } @@ -96,4 +101,13 @@ private Optional selectedTrouble() { return new FirstSelected(viewer.getSelection(), Trouble.class).get(); } + private Color backdround(Object element, int column) { + if (column != 1) { + return null; // framework driven null + } + boolean failure = ((Trouble) element).exception().isPresent(); + boolean severe = diagnostic.severe().contains(element); + return colors.get(severe, failure); + } + } diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereLabelProvider.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereLabelProvider.java index 22d9e7e64..a5ed94bb2 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereLabelProvider.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2020 ArSysOp + * Copyright (c) 2018, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -13,6 +13,7 @@ package org.eclipse.passage.lic.internal.jface.dialogs.licensing; import java.util.Map; +import java.util.function.BiFunction; import java.util.function.Function; import org.eclipse.jface.viewers.ILabelProviderListener; @@ -25,27 +26,27 @@ class HereLabelProvider implements ITableLabelProvider, ITableColorProvider { private final Map> texts; private final Class cls; + private final BiFunction background; - HereLabelProvider(Map> texts, Class cls) { + HereLabelProvider(Map> texts, Class cls, + BiFunction background) { this.texts = texts; this.cls = cls; + this.background = background; } @Override public Color getForeground(Object element, int column) { - // TODO Auto-generated method stub return null; } @Override public Color getBackground(Object element, int column) { - // TODO Auto-generated method stub - return null; + return background.apply(element, column); } @Override public Image getColumnImage(Object element, int column) { - // TODO Auto-generated method stub return null; } @@ -69,6 +70,5 @@ public void addListener(ILabelProviderListener listener) { @Override public void removeListener(ILabelProviderListener listener) { - // TODO Auto-generated method stub } } diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereTable.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereTable.java index 60f434218..a699f3909 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereTable.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/dialogs/licensing/HereTable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2020 ArSysOp + * Copyright (c) 2018, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -14,12 +14,14 @@ import java.util.HashMap; import java.util.Map; +import java.util.function.BiFunction; import java.util.function.Function; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; @@ -29,15 +31,21 @@ final class HereTable { private final TableViewer table; private final Class cls; private final Map> texts = new HashMap<>(); + private final BiFunction background; HereTable(Composite parent, Class cls) { + this(parent, cls, (element, index) -> null); // framework-driven null + } + + HereTable(Composite parent, Class cls, BiFunction background) { this.table = new TableViewer(parent); this.cls = cls; + this.background = background; } public TableViewer viewer() { table.setContentProvider(new ArrayContentProvider()); - table.setLabelProvider(new HereLabelProvider(texts, cls)); + table.setLabelProvider(new HereLabelProvider(texts, cls, background)); table.getTable().setHeaderVisible(true); table.getTable().setLinesVisible(true); table.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.java b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.java index f53630f9c..80aad8704 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.java +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020 ArSysOp + * Copyright (c) 2020, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -22,6 +22,7 @@ public class DiagnosticDialogMessages extends NLS { public static String DiagnosticDialog_action_view_failure_tooltip; public static String DiagnosticDialog_column_code; public static String DiagnosticDialog_column_details; + public static String DiagnosticDialog_column_type; public static String DiagnosticDialog_description; public static String DiagnosticDialog_error_title; public static String DiagnosticDialog_title; diff --git a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.properties b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.properties index 92643cb1a..f3f529fe9 100644 --- a/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.properties +++ b/bundles/org.eclipse.passage.lic.jface/src/org/eclipse/passage/lic/internal/jface/i18n/DiagnosticDialogMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2020 ArSysOp and others +# Copyright (c) 2020, 2021 ArSysOp and others # # This program and the accompanying materials are made available under the # terms of the Eclipse Public License 2.0 which is available at @@ -16,6 +16,7 @@ DiagnosticDialog_action_view_failure=&View Error... DiagnosticDialog_action_view_failure_tooltip=Selected report mention failure. View the exception. DiagnosticDialog_column_code=Code DiagnosticDialog_column_details=Error +DiagnosticDialog_column_type=Type DiagnosticDialog_description=Licensing engine experience difficulties during license coverage assessment. DiagnosticDialog_error_title=Error DiagnosticDialog_title=Licensing failure diagnostic From 7be1269d168da5bc770594a446dfb4627b14a8e4 Mon Sep 17 00:00:00 2001 From: Elena Parovyshnaia Date: Fri, 16 Apr 2021 13:54:25 +0300 Subject: [PATCH 2/3] Bug 572906 improve DiagnosticDialog UX with colors Bump service version for amended plugin Signed-off-by: eparovyshnaya --- bundles/org.eclipse.passage.lic.jface/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.passage.lic.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.jface/META-INF/MANIFEST.MF index afbb46bdb..fc9c76a1a 100644 --- a/bundles/org.eclipse.passage.lic.jface/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.jface/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Automatic-Module-Name: org.eclipse.passage.lic.base.ui Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.passage.lic.jface -Bundle-Version: 1.1.1.qualifier +Bundle-Version: 1.1.200.qualifier Bundle-Name: %Bundle-Name Bundle-Vendor: %Bundle-Vendor Bundle-Copyright: %Bundle-Copyright From bbc565b511deff74d197221f9727f602dc60f6a0 Mon Sep 17 00:00:00 2001 From: Elena Parovyshnaia Date: Fri, 16 Apr 2021 14:02:34 +0300 Subject: [PATCH 3/3] Bug 572906 improve DiagnosticDialog UX with colors Bump service version for affected feature Signed-off-by: eparovyshnaya --- features/org.eclipse.passage.lic.e4.ui.feature/feature.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/org.eclipse.passage.lic.e4.ui.feature/feature.xml b/features/org.eclipse.passage.lic.e4.ui.feature/feature.xml index a64172eda..346a369e2 100644 --- a/features/org.eclipse.passage.lic.e4.ui.feature/feature.xml +++ b/features/org.eclipse.passage.lic.e4.ui.feature/feature.xml @@ -14,7 +14,7 @@