2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.deleteConfigurator
;
11 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
12 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.graphics
.Image
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Control
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
19 import eu
.etaxonomy
.cdm
.api
.service
.config
.DeleteConfiguratorBase
;
20 import eu
.etaxonomy
.cdm
.api
.service
.config
.MediaDeletionConfigurator
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.NameDeletionConfigurator
;
22 import eu
.etaxonomy
.cdm
.api
.service
.config
.SpecimenDeleteConfigurator
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.SynonymDeletionConfigurator
;
24 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
25 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonNodeDeletionConfigurator
;
28 * Abstract subclass of MessageDialog providing the functionality to configure
29 * a {@link DeleteConfiguratorBase}
34 public class DeleteConfiguratorDialog
extends MessageDialog
{
36 private final DeleteConfiguratorBase configurator
;
37 private final boolean fromBulkEditor
;
39 public DeleteConfiguratorDialog(DeleteConfiguratorBase configurator
, Shell parentShell
, String dialogTitle
,
40 Image dialogTitleImage
, String dialogMessage
, int dialogImageType
, String
[] dialogButtonLabels
, int defaultIndex
, boolean fromBulkEditor
) {
41 super(parentShell
, dialogTitle
, dialogTitleImage
, dialogMessage
, dialogImageType
, dialogButtonLabels
, defaultIndex
);
42 this.configurator
= configurator
;
43 this.fromBulkEditor
= fromBulkEditor
;
46 public DeleteConfiguratorDialog(DeleteConfiguratorBase configurator
, Shell parentShell
, String dialogTitle
,
47 Image dialogTitleImage
, String dialogMessage
, int dialogImageType
, String
[] dialogButtonLabels
, int defaultIndex
) {
48 super(parentShell
, dialogTitle
, dialogTitleImage
, dialogMessage
, dialogImageType
, dialogButtonLabels
, defaultIndex
);
49 this.configurator
= configurator
;
50 this.fromBulkEditor
= false;
54 protected Control
createCustomArea(Composite parent
) {
55 DeleteConfiguratorComposite composite
= new DeleteConfiguratorComposite(parent
, NONE
);
56 if(configurator
instanceof TaxonDeletionConfigurator
){
57 composite
.addConfiguratorComposite(new DeleteTaxonConfiguratorComposite((TaxonDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
58 }else if (configurator
instanceof SynonymDeletionConfigurator
){
59 composite
.addConfiguratorComposite(new DeleteTaxonBaseConfiguratorComposite((SynonymDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
60 }else if(configurator
instanceof SpecimenDeleteConfigurator
){
61 composite
.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
62 } else if(configurator
instanceof TaxonNodeDeletionConfigurator
){
63 composite
.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
64 } else if(configurator
instanceof NameDeletionConfigurator
){
65 composite
.addConfiguratorComposite(new DeleteNameConfiguratorComposite((NameDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
66 } else if(configurator
instanceof MediaDeletionConfigurator
){
68 composite
.addConfiguratorComposite(new DeleteMediaConfiguratorComposite((MediaDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
, fromBulkEditor
));
70 composite
.addConfiguratorComposite(new DeleteMediaConfiguratorComposite((MediaDeletionConfigurator
) configurator
, composite
.getSectionConfigure(), SWT
.NONE
));
78 public static boolean openConfirmWithConfigurator(DeleteConfiguratorBase configurator
, Shell parent
, String title
, String message
) {
79 DeleteConfiguratorDialog dialog
= new DeleteConfiguratorDialog(configurator
, parent
, title
, getDefaultImage(), message
, QUESTION
, getButtonLabels(QUESTION
), 0);
80 return dialog
.open() == 0;
84 protected boolean isResizable() {
89 protected static String
[] getButtonLabels(int kind
) {
90 String
[] dialogButtonLabels
;
95 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
};
99 dialogButtonLabels
= new String
[] { IDialogConstants
.OK_LABEL
,
100 IDialogConstants
.CANCEL_LABEL
};
104 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
105 IDialogConstants
.NO_LABEL
};
108 case QUESTION_WITH_CANCEL
: {
109 dialogButtonLabels
= new String
[] { IDialogConstants
.YES_LABEL
,
110 IDialogConstants
.NO_LABEL
,
111 IDialogConstants
.CANCEL_LABEL
};
115 throw new IllegalArgumentException(
116 "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
119 return dialogButtonLabels
;