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.events.SelectionEvent;
|
15
|
import org.eclipse.swt.events.SelectionListener;
|
16
|
import org.eclipse.swt.widgets.Button;
|
17
|
import org.eclipse.swt.widgets.Composite;
|
18
|
import org.eclipse.swt.widgets.Shell;
|
19
|
|
20
|
/**
|
21
|
* @author k.luther
|
22
|
* @since 23.01.2019
|
23
|
*
|
24
|
*/
|
25
|
public class NewTaxonNodeWizardDialog extends WizardDialog {
|
26
|
|
27
|
private Button finishAndOpen;
|
28
|
private IWizard newTaxonNodeWizard;
|
29
|
/**
|
30
|
* @param parentShell
|
31
|
* @param newWizard
|
32
|
*/
|
33
|
public NewTaxonNodeWizardDialog(Shell parentShell, IWizard newWizard) {
|
34
|
super(parentShell, newWizard);
|
35
|
newTaxonNodeWizard = newWizard;
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
protected void createButtonsForButtonBar(Composite parent) {
|
40
|
finishAndOpen = createButton(parent, IDialogConstants.FINISH_ID,"Finish and Open", false);
|
41
|
|
42
|
finishAndOpen.addSelectionListener(new SelectionListener() {
|
43
|
/*
|
44
|
* @see SelectionListener.widgetSelected (SelectionEvent)
|
45
|
*/
|
46
|
@Override
|
47
|
public void widgetSelected(SelectionEvent e) {
|
48
|
((NewTaxonNodeWizard)newTaxonNodeWizard).setOpenInEditor(true);
|
49
|
finishPressed();
|
50
|
}
|
51
|
/*
|
52
|
* @see SelectionListener.widgetDefaultSelected(SelectionEvent)
|
53
|
*/
|
54
|
@Override
|
55
|
public void widgetDefaultSelected(SelectionEvent e) {
|
56
|
|
57
|
}
|
58
|
});
|
59
|
super.createButtonsForButtonBar(parent);
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public void updateButtons() {
|
64
|
|
65
|
boolean canFinish = newTaxonNodeWizard.canFinish();
|
66
|
|
67
|
finishAndOpen.setEnabled(canFinish);
|
68
|
|
69
|
super.updateButtons();
|
70
|
// finishAndOpen is default unless it is disabled and next is enabled
|
71
|
if (canFinish) {
|
72
|
getShell().setDefaultButton(finishAndOpen);
|
73
|
}
|
74
|
}
|
75
|
|
76
|
}
|