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
;
25 * Abstract subclass of MessageDialog providing the functionality to configure
26 * a {@link DeleteConfiguratorBase}
31 public class DeleteConfiguratorDialog
extends MessageDialog
{
33 private final DeleteConfiguratorBase configurator
;
35 public DeleteConfiguratorDialog(DeleteConfiguratorBase configurator
, Shell parentShell
, String dialogTitle
,
36 Image dialogTitleImage
, String dialogMessage
, int dialogImageType
, String
[] dialogButtonLabels
, int defaultIndex
) {
37 super(parentShell
, dialogTitle
, dialogTitleImage
, dialogMessage
, dialogImageType
, dialogButtonLabels
, defaultIndex
);
38 this.configurator
= configurator
;
42 * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
45 protected Control
createCustomArea(Composite parent
) {
46 DeleteConfiguratorComposite composite
= new DeleteConfiguratorComposite(parent
, NONE
);
47 if(configurator
instanceof TaxonBaseDeletionConfigurator
){
48 composite
.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonBaseDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
50 else if(configurator
instanceof SpecimenDeleteConfigurator
){
51 composite
.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
56 public static boolean openConfirmWithConfigurator(DeleteConfiguratorBase configurator
, Shell parent
, String title
, String message
) {
57 DeleteConfiguratorDialog dialog
= new DeleteConfiguratorDialog(configurator
, parent
, title
, getDefaultImage(), message
, QUESTION
, getButtonLabels(QUESTION
), 0);
58 return dialog
.open() == 0;
62 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
65 protected boolean isResizable() {
74 protected static String
[] getButtonLabels(int kind
) {
75 String
[] dialogButtonLabels
;
80 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
};
84 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
,
85 IDialogConstants
.CANCEL_LABEL
};
89 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
90 IDialogConstants
.NO_LABEL
};
93 case QUESTION_WITH_CANCEL
: {
94 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
95 IDialogConstants
.NO_LABEL
,
96 IDialogConstants
.CANCEL_LABEL
};
100 throw new IllegalArgumentException(
101 "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
104 return dialogButtonLabels
;