Project

General

Profile

Download (2.38 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2019 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.newWizard;
10

    
11
import org.eclipse.jface.dialogs.IDialogConstants;
12
import org.eclipse.jface.wizard.IWizard;
13
import org.eclipse.jface.wizard.WizardDialog;
14
import org.eclipse.swt.SWTException;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.events.SelectionListener;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Shell;
20

    
21
/**
22
 * @author k.luther
23
 * @since 23.01.2019
24
 */
25
public class NewTaxonNodeWizardDialog extends WizardDialog {
26

    
27
    private Button finishAndOpen;
28
    private IWizard newTaxonNodeWizard;
29

    
30
    public NewTaxonNodeWizardDialog(Shell parentShell, IWizard newWizard) {
31
        super(parentShell, newWizard);
32
        newTaxonNodeWizard = newWizard;
33
    }
34

    
35
    @Override
36
    protected void createButtonsForButtonBar(Composite parent) {
37
        finishAndOpen = createButton(parent, IDialogConstants.FINISH_ID,"Finish and Open", false);
38

    
39
        finishAndOpen.addSelectionListener(new SelectionListener() {
40
            @Override
41
            public void widgetSelected(SelectionEvent e) {
42
                ((NewTaxonNodeWizard)newTaxonNodeWizard).setOpenInEditor(true);
43
                try{
44
                    finishPressed();
45
                }catch(SWTException exception){
46
                    if ("Widget is disposed".equals(exception.getMessage())){
47
                        return;
48
                    }
49
                }
50
            }
51
            @Override
52
            public void widgetDefaultSelected(SelectionEvent e) {
53

    
54
            }
55
        });
56
        super.createButtonsForButtonBar(parent);
57
    }
58

    
59
    @Override
60
    public void updateButtons() {
61
        try{
62
            boolean canFinish = newTaxonNodeWizard.canFinish();
63

    
64
            finishAndOpen.setEnabled(canFinish);
65

    
66
            super.updateButtons();
67
         // finishAndOpen is default unless it is disabled and next is enabled
68
            if (canFinish) {
69
                getShell().setDefaultButton(finishAndOpen);
70
            }
71
        }catch (SWTException e){
72
            if ("Widget is disposed".equals(e.getMessage())){
73
                return;
74
            }
75
        }
76
    }
77

    
78
}
(22-22/28)