Bug 526223 - Choices of values are not removed in the Pane Based Selection Wizard
Summary: Choices of values are not removed in the Pane Based Selection Wizard
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows NT
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-10-18 09:53 EDT by Amine Kechaou CLA
Modified: 2020-10-23 08:34 EDT (History)
2 users (show)

See Also:


Attachments
Here we see that the choice of values list still contains Class1 although it was added to the selected values list (11.08 KB, image/png)
2017-10-18 09:53 EDT, Amine Kechaou CLA
no flags Details
Reproduction case (6.07 KB, application/zip)
2017-10-19 04:54 EDT, Maxime Porhel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Amine Kechaou CLA 2017-10-18 09:53:18 EDT
Created attachment 271071 [details]
Here we see that the choice of values list still contains Class1 although it was added to the selected values list

When adding an EObject via double click or the add buton in the Pane Based Selection Wizard, this EObject is not removed from the choice of values list, as it is the case for example in the FeatureEditorDialog. 

The method of concern here is createAddButtonListener in the class EObjectPaneBasedSelectionWizardPage
Comment 1 Maxime Porhel CLA 2017-10-19 04:54:12 EDT
Created attachment 271089 [details]
Reproduction case

Reproduction scenario using the attached sample (taken from Sirius junit tests)
 - Open the paneBasedSelectionTest.aird session
 - Open the PaneBasedSelectionTestDiagram
 - Select one of the tools
 - Click on the diagram background
 - Use the add/remove buttons, the left pane should be dynamically updated when the user adds or removes elements using the add/remove buttons
Comment 2 Maxime Porhel CLA 2017-10-19 04:55:01 EDT
Hi Amine, 


Thanks for the bug report, 
Note that it has not be added to a future release yet.
Comment 3 Vincent Richard CLA 2020-10-23 08:34:16 EDT
Hi,

Please find below a fix suggestion. (For your information, I work around this by injecting the missing behavior using introspection but I really don't feel great about it ;)

diff --git a/plugins/org.eclipse.sirius.common.ui/src/org/eclipse/sirius/common/ui/tools/api/selection/page/EObjectPaneBasedSelectionWizardPage.java b/plugins/org.eclipse.sirius.common.ui/src/org/eclipse/sirius/common/ui/tools/api/selection/page/EObjectPaneBasedSelectionWizardPage.java
index 8869d94..ab04342 100644
--- a/plugins/org.eclipse.sirius.common.ui/src/org/eclipse/sirius/common/ui/tools/api/selection/page/EObjectPaneBasedSelectionWizardPage.java
+++ b/plugins/org.eclipse.sirius.common.ui/src/org/eclipse/sirius/common/ui/tools/api/selection/page/EObjectPaneBasedSelectionWizardPage.java
@@ -41,6 +41,8 @@
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.sirius.common.tools.api.util.TreeItemWrapper;
 import org.eclipse.sirius.common.ui.tools.api.navigator.GroupingContentProvider;
 import org.eclipse.sirius.common.ui.tools.api.util.TreeItemWrapperContentProvider;
@@ -184,7 +186,7 @@
         createButtonListeners();
 
         myViewerfilter.setTreeViewer(treeViewer);
-
+        
         /* expand before compute prefix => see trac #1323 */
         expandTreeViewer(treeViewer);
 
@@ -234,6 +236,7 @@
                         }
                         tableViewer.refresh();
                         tableViewer.setSelection(new StructuredSelection(tableSelection));
+                        treeViewer.refresh();
                     }
                 }
             });
@@ -260,6 +263,8 @@
                     }
                     tableViewer.refresh();
                     tableViewer.setSelection(null);
+                    elementsToSelectText.setText(""); //$NON-NLS-1$
+                    initRootPrefix();
                 }
             });
         }
@@ -382,6 +387,18 @@
         viewer.setContentProvider(contentProvider);
         viewer.setLabelProvider(new EObjectSelectionLabelProvider());
         viewer.addFilter(this.myViewerfilter);
+        viewer.addFilter(new ViewerFilter() {
+            
+            @Override
+            public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if(element instanceof TreeItemWrapper && ((TreeItemWrapper) element).getWrappedObject() instanceof EObject) {
+                    EObject eObject = (EObject) ((TreeItemWrapper) element).getWrappedObject();
+                    return !selectedEObjects.contains(eObject);
+                }
+                return true;
+            }
+        });
+        
         return viewer;
     }