Project

General

Profile

« Previous | Next » 

Revision f04201c7

Added by Patrick Plitzner about 6 years ago

ref #7095 Fix multiple add buttons when switching between views

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
379 379
        });
380 380

  
381 381
        buttonPanel = new Composite(parent, SWT.NONE);
382

  
383
        buttonPanel.setLayout(new RowLayout());
384
        GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
385

  
386
        /**
387
         * Add description button
388
         */
389
        Button btnAddDescription = new Button(buttonPanel, SWT.PUSH);
390
        btnAddDescription.setImage(ImageResources.getImage(ImageResources.ADD_ICON));
391
        btnAddDescription.addSelectionListener(new SelectionAdapter() {
392
            @Override
393
            public void widgetSelected(SelectionEvent e) {
394
                SpecimenSelectionDialog dialog = new SpecimenSelectionDialog(natTable.getShell(), CharacterMatrix.this);
395
                if(dialog.open()==Window.OK){
396
                    Collection<SpecimenOrObservationBase> specimens = dialog.getSpecimen();
397
                    boolean hasAdded = false;
398
                    for (SpecimenOrObservationBase specimen : specimens) {
399
                        SpecimenDescription description = getDescriptionForWorkingSet(specimen);
400
                        if(!workingSet.getDescriptions().contains(description)){
401
                            CharacterMatrix.this.descriptions.add(new RowWrapper(description));
402
                            workingSet.addDescription(description);
403
                            hasAdded = true;
404
                        }
405
                    }
406
                    if(hasAdded){
407
                        setDirty();
408
                    }
409
                }
410
            }
411
        });
382 412
    }
383 413

  
384 414
    private void toggleTreeFlat(boolean isTree) {
......
389 419
        btnExpandAll.setEnabled(isTree);
390 420
        natTable.doCommand(new StructuralRefreshCommand());
391 421
        natTable.doCommand(new VisualRefreshCommand());
422
        parent.layout();
423

  
392 424
    }
393 425

  
394 426
    public void init(UUID workingSetUuid, boolean treeView) {
......
660 692

  
661 693
        GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
662 694

  
663

  
664 695
        wsLabel.setText(workingSet.getLabel());
665 696
        wsLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
666 697
        wsLabel.getParent().layout();
667 698

  
668
        buttonPanel.setLayout(new RowLayout());
669
        GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
670

  
671
        /**
672
         * Add description button
673
         */
674
        Button btnAddDescription = new Button(buttonPanel, SWT.PUSH);
675
        btnAddDescription.setImage(ImageResources.getImage(ImageResources.ADD_ICON));
676
        btnAddDescription.addSelectionListener(new SelectionAdapter() {
677
            @Override
678
            public void widgetSelected(SelectionEvent e) {
679
                SpecimenSelectionDialog dialog = new SpecimenSelectionDialog(natTable.getShell(), CharacterMatrix.this);
680
                if(dialog.open()==Window.OK){
681
                    Collection<SpecimenOrObservationBase> specimens = dialog.getSpecimen();
682
                    boolean hasAdded = false;
683
                    for (SpecimenOrObservationBase specimen : specimens) {
684
                        SpecimenDescription description = getDescriptionForWorkingSet(specimen);
685
                        if(!workingSet.getDescriptions().contains(description)){
686
                            CharacterMatrix.this.descriptions.add(new RowWrapper(description));
687
                            workingSet.addDescription(description);
688
                            hasAdded = true;
689
                        }
690
                    }
691
                    if(hasAdded){
692
                        setDirty();
693
                    }
694
                }
695
            }
696
        });
697

  
698 699
        parent.layout();
699 700
    }
700 701

  

Also available in: Unified diff