3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.deleteConfigurator
;
12 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
13 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.graphics
.Image
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Control
;
18 import org
.eclipse
.swt
.widgets
.Shell
;
20 import eu
.etaxonomy
.cdm
.api
.service
.config
.DeleteConfiguratorBase
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.SpecimenDeleteConfigurator
;
22 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonBaseDeletionConfigurator
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonNodeDeletionConfigurator
;
26 * Abstract subclass of MessageDialog providing the functionality to configure
27 * a {@link DeleteConfiguratorBase}
32 public class DeleteConfiguratorDialog
extends MessageDialog
{
34 private final DeleteConfiguratorBase configurator
;
36 public DeleteConfiguratorDialog(DeleteConfiguratorBase configurator
, Shell parentShell
, String dialogTitle
,
37 Image dialogTitleImage
, String dialogMessage
, int dialogImageType
, String
[] dialogButtonLabels
, int defaultIndex
) {
38 super(parentShell
, dialogTitle
, dialogTitleImage
, dialogMessage
, dialogImageType
, dialogButtonLabels
, defaultIndex
);
39 this.configurator
= configurator
;
43 * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
46 protected Control
createCustomArea(Composite parent
) {
47 DeleteConfiguratorComposite composite
= new DeleteConfiguratorComposite(parent
, NONE
);
48 if(configurator
instanceof TaxonBaseDeletionConfigurator
){
49 composite
.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonBaseDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
51 else if(configurator
instanceof SpecimenDeleteConfigurator
){
52 composite
.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
53 } else if(configurator
instanceof TaxonNodeDeletionConfigurator
){
54 composite
.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
60 public static boolean openConfirmWithConfigurator(DeleteConfiguratorBase configurator
, Shell parent
, String title
, String message
) {
61 DeleteConfiguratorDialog dialog
= new DeleteConfiguratorDialog(configurator
, parent
, title
, getDefaultImage(), message
, QUESTION
, getButtonLabels(QUESTION
), 0);
62 return dialog
.open() == 0;
66 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
69 protected boolean isResizable() {
78 protected static String
[] getButtonLabels(int kind
) {
79 String
[] dialogButtonLabels
;
84 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
};
88 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
,
89 IDialogConstants
.CANCEL_LABEL
};
93 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
94 IDialogConstants
.NO_LABEL
};
97 case QUESTION_WITH_CANCEL
: {
98 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
99 IDialogConstants
.NO_LABEL
,
100 IDialogConstants
.CANCEL_LABEL
};
104 throw new IllegalArgumentException(
105 "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
108 return dialogButtonLabels
;