843ff14fbe8ddc9a69cc850e454dc833f7e28e19
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / DeleteConfiguratorDialog.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.ui.dialog;
11
12 import org.eclipse.jface.dialogs.IDialogConstants;
13 import org.eclipse.jface.dialogs.MessageDialog;
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.Listener;
18 import org.eclipse.swt.widgets.Shell;
19
20 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
21
22 /**
23 * Abstract subclass of MessageDialog providing the functionality to configure
24 * a {@link DeleteConfiguratorBase}
25 * @author pplitzner
26 * @date Jan 28, 2015
27 *
28 */
29 public abstract class DeleteConfiguratorDialog extends MessageDialog implements Listener{
30
31 public DeleteConfiguratorDialog(Shell parentShell, String dialogTitle,
32 Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) {
33 super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
34 }
35
36 /* (non-Javadoc)
37 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
38 */
39 @Override
40 protected Control createDialogArea(Composite parent) {
41 Composite composite = (Composite) super.createDialogArea(parent);
42
43 createCheckBoxes(composite);
44
45 return composite;
46 }
47
48 protected abstract void createCheckBoxes(Composite parent);
49
50 /**
51 * @param kind
52 * @return
53 */
54 static String[] getButtonLabels(int kind) {
55 String[] dialogButtonLabels;
56 switch (kind) {
57 case ERROR:
58 case INFORMATION:
59 case WARNING: {
60 dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
61 break;
62 }
63 case CONFIRM: {
64 dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL,
65 IDialogConstants.CANCEL_LABEL };
66 break;
67 }
68 case QUESTION: {
69 dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
70 IDialogConstants.NO_LABEL };
71 break;
72 }
73 case QUESTION_WITH_CANCEL: {
74 dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
75 IDialogConstants.NO_LABEL,
76 IDialogConstants.CANCEL_LABEL };
77 break;
78 }
79 default: {
80 throw new IllegalArgumentException(
81 "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
82 }
83 }
84 return dialogButtonLabels;
85 }
86 }