ref #7095 Fix multiple add buttons when switching between views
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 25 Jan 2018 16:05:30 +0000 (17:05 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 25 Jan 2018 18:11:20 +0000 (19:11 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java

index f4b93c29041da1ddf200793b7eed8820eb128183..a8dc5748d04fd8a21f680699e8cef1f44a5b4fd5 100644 (file)
@@ -379,6 +379,36 @@ ICdmEntitySessionEnabled{
         });
 
         buttonPanel = new Composite(parent, SWT.NONE);
+
+        buttonPanel.setLayout(new RowLayout());
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
+
+        /**
+         * Add description button
+         */
+        Button btnAddDescription = new Button(buttonPanel, SWT.PUSH);
+        btnAddDescription.setImage(ImageResources.getImage(ImageResources.ADD_ICON));
+        btnAddDescription.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                SpecimenSelectionDialog dialog = new SpecimenSelectionDialog(natTable.getShell(), CharacterMatrix.this);
+                if(dialog.open()==Window.OK){
+                    Collection<SpecimenOrObservationBase> specimens = dialog.getSpecimen();
+                    boolean hasAdded = false;
+                    for (SpecimenOrObservationBase specimen : specimens) {
+                        SpecimenDescription description = getDescriptionForWorkingSet(specimen);
+                        if(!workingSet.getDescriptions().contains(description)){
+                            CharacterMatrix.this.descriptions.add(new RowWrapper(description));
+                            workingSet.addDescription(description);
+                            hasAdded = true;
+                        }
+                    }
+                    if(hasAdded){
+                        setDirty();
+                    }
+                }
+            }
+        });
     }
 
     private void toggleTreeFlat(boolean isTree) {
@@ -389,6 +419,8 @@ ICdmEntitySessionEnabled{
         btnExpandAll.setEnabled(isTree);
         natTable.doCommand(new StructuralRefreshCommand());
         natTable.doCommand(new VisualRefreshCommand());
+        parent.layout();
+
     }
 
     public void init(UUID workingSetUuid, boolean treeView) {
@@ -660,41 +692,10 @@ ICdmEntitySessionEnabled{
 
         GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
 
-
         wsLabel.setText(workingSet.getLabel());
         wsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
         wsLabel.getParent().layout();
 
-        buttonPanel.setLayout(new RowLayout());
-        GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
-
-        /**
-         * Add description button
-         */
-        Button btnAddDescription = new Button(buttonPanel, SWT.PUSH);
-        btnAddDescription.setImage(ImageResources.getImage(ImageResources.ADD_ICON));
-        btnAddDescription.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                SpecimenSelectionDialog dialog = new SpecimenSelectionDialog(natTable.getShell(), CharacterMatrix.this);
-                if(dialog.open()==Window.OK){
-                    Collection<SpecimenOrObservationBase> specimens = dialog.getSpecimen();
-                    boolean hasAdded = false;
-                    for (SpecimenOrObservationBase specimen : specimens) {
-                        SpecimenDescription description = getDescriptionForWorkingSet(specimen);
-                        if(!workingSet.getDescriptions().contains(description)){
-                            CharacterMatrix.this.descriptions.add(new RowWrapper(description));
-                            workingSet.addDescription(description);
-                            hasAdded = true;
-                        }
-                    }
-                    if(hasAdded){
-                        setDirty();
-                    }
-                }
-            }
-        });
-
         parent.layout();
     }