Project

General

Profile

« Previous | Next » 

Revision 3586a882

Added by Patrick Plitzner almost 8 years ago

  • refactored delete configrator dialog
    • added dialog to derivate deletion

View differences:

.gitattributes
1410 1410
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/EnumComboElement.java -text
1411 1411
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java -text
1412 1412
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DefaultLanguageDialog.java -text
1413
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorComposite.java -text
1414
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorDialog.java -text
1415
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.java -text
1416 1413
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/LoginDialog.java -text
1417 1414
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/UriDialog.java -text
1415
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorComposite.java -text
1416
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java -text
1417
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteSpecimenConfiguratorComposite.java -text
1418
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.java -text
1418 1419
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java -text
1419 1420
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java -text
1420 1421
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/operation/DeleteDerivateOperation.java
27 27
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
28 28
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
29 29
import eu.etaxonomy.taxeditor.store.CdmStore;
30
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
30 31

  
31 32
/**
32 33
 *
......
66 67
                confirmationQuestion += " and its children";
67 68
            }
68 69
            confirmationQuestion += "?";
69
            if(!MessagingUtils.confirmDialog("Confirm deletion", confirmationQuestion)){
70
            if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfigurator, null, "Confirm Deletion", confirmationQuestion)){
70 71
                return Status.CANCEL_STATUS;
71 72
            }
72 73
            if(((ISaveablePart) getPostOperationEnabled()).isDirty()){
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
40 40
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
41 41
import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
42 42
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
43
import eu.etaxonomy.taxeditor.ui.dialog.DeleteConfiguratorDialog;
44
import eu.etaxonomy.taxeditor.ui.dialog.DeleteTaxonConfiguratorDialog;
43
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
45 44

  
46 45
/**
47 46
 * <p>DeleteTreeNodeHandler class.</p>
......
89 88
				ITaxonTreeNode taxonNode =treeNode;
90 89
				TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
91 90
				if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
92
					if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
91
					if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
93 92
						return null;
94 93
					}
95 94
				} else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
96
					if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
95
					if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
97 96
						return null;
98 97
					}
99 98
				} else {
100 99

  
101 100
					if (taxonNode.hasChildNodes()){
102
                        DeleteConfiguratorDialog dialog = new DeleteTaxonConfiguratorDialog(
101
                        DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
103 102
                                config,
104 103
                                HandlerUtil.getActiveShell(event),
105 104
                                "Confirm Deletion",
......
123 122

  
124 123
						}
125 124
					}else{
126
						if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
125
						if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
127 126
							return null;
128 127
						}
129 128
					}
......
148 147
			}
149 148
		} else{
150 149
			try{
151
				if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
150
				if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
152 151
					return null;
153 152
				}
154 153
				if (allEditorsClosed){
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF
32 32
 eu.etaxonomy.taxeditor.ui.bar,
33 33
 eu.etaxonomy.taxeditor.ui.combo,
34 34
 eu.etaxonomy.taxeditor.ui.dialog,
35
 eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator,
35 36
 eu.etaxonomy.taxeditor.ui.dialog.selection,
36 37
 eu.etaxonomy.taxeditor.ui.element,
37 38
 eu.etaxonomy.taxeditor.ui.group.grantedauthority,
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteConfiguratorComposite.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.core.databinding.DataBindingContext;
13
import org.eclipse.core.databinding.beans.PojoProperties;
14
import org.eclipse.core.databinding.observable.value.IObservableValue;
15
import org.eclipse.jface.databinding.swt.WidgetProperties;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.DisposeEvent;
18
import org.eclipse.swt.events.DisposeListener;
19
import org.eclipse.swt.layout.FillLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.forms.events.ExpansionEvent;
24
import org.eclipse.ui.forms.events.IExpansionListener;
25
import org.eclipse.ui.forms.widgets.FormToolkit;
26
import org.eclipse.ui.forms.widgets.Section;
27

  
28
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
29

  
30
/**
31
 * @author pplitzner
32
 * @date Feb 16, 2015
33
 *
34
 */
35
public class DeleteConfiguratorComposite extends Composite implements IExpansionListener{
36
    private final DataBindingContext m_bindingContext;
37

  
38
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
39
    private TaxonBaseDeletionConfigurator configurator = null;
40
    private final Button btnDeleteTaxonName;
41

  
42
    /**
43
     * Create the composite.
44
     * @param parent
45
     * @param style
46
     */
47
    public DeleteConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, final Composite parent, int style) {
48
        super(parent, SWT.NONE);
49
        this.configurator = configurator;
50

  
51
        addDisposeListener(new DisposeListener() {
52
            @Override
53
            public void widgetDisposed(DisposeEvent e) {
54
                toolkit.dispose();
55
            }
56
        });
57
        toolkit.paintBordersFor(this);
58
        setLayout(new FillLayout(SWT.HORIZONTAL));
59

  
60
        Section sctnConfigure = toolkit.createSection(this, Section.CLIENT_INDENT | Section.TWISTIE);
61
        sctnConfigure.addExpansionListener(this);
62
        sctnConfigure.setBackground(getBackground());
63
        toolkit.paintBordersFor(sctnConfigure);
64
        sctnConfigure.setText("Configure");
65

  
66
        btnDeleteTaxonName = new Button(sctnConfigure, SWT.CHECK);
67
        sctnConfigure.setClient(btnDeleteTaxonName);
68
        btnDeleteTaxonName.setText("Delete Taxon Name");
69
        m_bindingContext = initDataBindings();
70

  
71
    }
72
    protected DataBindingContext initDataBindings() {
73
        DataBindingContext bindingContext = new DataBindingContext();
74
        //
75
        IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName);
76
        IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator);
77
        bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
78
        //
79
        return bindingContext;
80
    }
81

  
82
    public Button getBtnDeleteTaxonName() {
83
        return btnDeleteTaxonName;
84
    }
85

  
86
    @Override
87
    public void expansionStateChanged(ExpansionEvent e) {
88
        getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
89
    }
90
    @Override
91
    public void expansionStateChanging(ExpansionEvent e) {
92
    }
93
}
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.Shell;
18

  
19
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
20

  
21
/**
22
 * Abstract subclass of MessageDialog providing the functionality to configure
23
 * a {@link DeleteConfiguratorBase}
24
 * @author pplitzner
25
 * @date Jan 28, 2015
26
 *
27
 */
28
public abstract class DeleteConfiguratorDialog extends MessageDialog{
29

  
30
    public DeleteConfiguratorDialog(Shell parentShell, String dialogTitle,
31
            Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex) {
32
        super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
33
    }
34

  
35
    /* (non-Javadoc)
36
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
37
     */
38
    @Override
39
    protected Control createDialogArea(Composite parent) {
40
        Composite composite = (Composite) super.createDialogArea(parent);
41

  
42
        return composite;
43
    }
44

  
45
    /**
46
     * @param kind
47
     * @return
48
     */
49
    static String[] getButtonLabels(int kind) {
50
        String[] dialogButtonLabels;
51
        switch (kind) {
52
        case ERROR:
53
        case INFORMATION:
54
        case WARNING: {
55
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
56
            break;
57
        }
58
        case CONFIRM: {
59
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL,
60
                    IDialogConstants.CANCEL_LABEL };
61
            break;
62
        }
63
        case QUESTION: {
64
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
65
                    IDialogConstants.NO_LABEL };
66
            break;
67
        }
68
        case QUESTION_WITH_CANCEL: {
69
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
70
                    IDialogConstants.NO_LABEL,
71
                    IDialogConstants.CANCEL_LABEL };
72
            break;
73
        }
74
        default: {
75
            throw new IllegalArgumentException(
76
                    "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
77
        }
78
        }
79
        return dialogButtonLabels;
80
    }
81
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/DeleteTaxonConfiguratorDialog.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.apache.log4j.Logger;
13
import org.eclipse.swt.graphics.Image;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.swt.widgets.Shell;
17

  
18
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
19

  
20
/**
21
 * @author pplitzner
22
 * @date Jan 28, 2015
23
 *
24
 */
25
public class DeleteTaxonConfiguratorDialog extends DeleteConfiguratorDialog {
26

  
27
    @SuppressWarnings("unused")
28
    private final Logger logger = Logger.getLogger(DeleteTaxonConfiguratorDialog.class);
29

  
30
    private final TaxonDeletionConfigurator configurator;
31

  
32
    /**
33
     * @param configurator
34
     * @param parentShell
35
     * @param dialogTitle
36
     * @param dialogTitleImage
37
     * @param dialogMessage
38
     * @param dialogImageType
39
     * @param dialogButtonLabels
40
     * @param defaultIndex
41
     */
42
    public DeleteTaxonConfiguratorDialog(TaxonDeletionConfigurator configurator, Shell parentShell, String dialogTitle,
43
            Image dialogTitleImage, String dialogMessage,int dialogImageType, String[] dialogButtonLabels, int defaultIndex) {
44
        super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
45
        this.configurator = configurator;
46
    }
47

  
48
    /* (non-Javadoc)
49
     * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
50
     */
51
    @Override
52
    protected Control createCustomArea(Composite parent) {
53
        DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(configurator, parent, NONE);
54
        return composite;
55
    }
56

  
57
    public static boolean openConfirmWithConfigurator(TaxonDeletionConfigurator configurator, Shell parent, String title, String message) {
58
        DeleteTaxonConfiguratorDialog dialog = new DeleteTaxonConfiguratorDialog(configurator, parent, title, getDefaultImage(), message, QUESTION, getButtonLabels(QUESTION), 0);
59
        return dialog.open() == 0;
60
    }
61

  
62
    /* (non-Javadoc)
63
     * @see org.eclipse.jface.dialogs.Dialog#isResizable()
64
     */
65
    @Override
66
    protected boolean isResizable() {
67
        return true;
68
    }
69

  
70
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorComposite.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.deleteConfigurator;
11

  
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.DisposeEvent;
14
import org.eclipse.swt.events.DisposeListener;
15
import org.eclipse.swt.layout.FillLayout;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Display;
18
import org.eclipse.ui.forms.events.ExpansionEvent;
19
import org.eclipse.ui.forms.events.IExpansionListener;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.ui.forms.widgets.Section;
22

  
23
/**
24
 * @author pplitzner
25
 * @date Feb 16, 2015
26
 *
27
 */
28
public class DeleteConfiguratorComposite extends Composite implements IExpansionListener{
29

  
30
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
31
    private final Section sctnConfigure;
32
    /**
33
     * Create the composite.
34
     * @param parent
35
     * @param style
36
     */
37
    public DeleteConfiguratorComposite(final Composite parent, int style) {
38
        super(parent, SWT.NONE);
39

  
40
        addDisposeListener(new DisposeListener() {
41
            @Override
42
            public void widgetDisposed(DisposeEvent e) {
43
                toolkit.dispose();
44
            }
45
        });
46
        toolkit.paintBordersFor(this);
47
        setLayout(new FillLayout(SWT.HORIZONTAL));
48

  
49
        sctnConfigure = toolkit.createSection(this, Section.CLIENT_INDENT | Section.TWISTIE);
50
        sctnConfigure.addExpansionListener(this);
51
        sctnConfigure.setBackground(getBackground());
52
        toolkit.paintBordersFor(sctnConfigure);
53
        sctnConfigure.setText("Configure");
54

  
55

  
56
    }
57

  
58

  
59
    public void addConfiguratorComposite(Composite configuratorComposite){
60
        toolkit.paintBordersFor(configuratorComposite);
61
        sctnConfigure.setClient(configuratorComposite);
62
    }
63

  
64
    @Override
65
    public void expansionStateChanged(ExpansionEvent e) {
66
        getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
67
    }
68
    @Override
69
    public void expansionStateChanging(ExpansionEvent e) {
70
    }
71
    public Section getSectionConfigure() {
72
        return sctnConfigure;
73
    }
74
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/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.deleteConfigurator;
11

  
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;
19

  
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

  
24
/**
25
 * Abstract subclass of MessageDialog providing the functionality to configure
26
 * a {@link DeleteConfiguratorBase}
27
 * @author pplitzner
28
 * @date Jan 28, 2015
29
 *
30
 */
31
public class DeleteConfiguratorDialog extends MessageDialog{
32

  
33
    private final DeleteConfiguratorBase configurator;
34

  
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;
39
    }
40

  
41
    /* (non-Javadoc)
42
     * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
43
     */
44
    @Override
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));
49
        }
50
        else if(configurator instanceof SpecimenDeleteConfigurator){
51
            composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
52
        }
53
        return composite;
54
    }
55

  
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;
59
    }
60

  
61
    /* (non-Javadoc)
62
     * @see org.eclipse.jface.dialogs.Dialog#isResizable()
63
     */
64
    @Override
65
    protected boolean isResizable() {
66
        return true;
67
    }
68

  
69

  
70
    /**
71
     * @param kind
72
     * @return
73
     */
74
    protected static String[] getButtonLabels(int kind) {
75
        String[] dialogButtonLabels;
76
        switch (kind) {
77
        case ERROR:
78
        case INFORMATION:
79
        case WARNING: {
80
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
81
            break;
82
        }
83
        case CONFIRM: {
84
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL,
85
                    IDialogConstants.CANCEL_LABEL };
86
            break;
87
        }
88
        case QUESTION: {
89
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
90
                    IDialogConstants.NO_LABEL };
91
            break;
92
        }
93
        case QUESTION_WITH_CANCEL: {
94
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
95
                    IDialogConstants.NO_LABEL,
96
                    IDialogConstants.CANCEL_LABEL };
97
            break;
98
        }
99
        default: {
100
            throw new IllegalArgumentException(
101
                    "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
102
        }
103
        }
104
        return dialogButtonLabels;
105
    }
106
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteSpecimenConfiguratorComposite.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.deleteConfigurator;
11

  
12
import org.eclipse.core.databinding.DataBindingContext;
13
import org.eclipse.core.databinding.beans.PojoProperties;
14
import org.eclipse.core.databinding.observable.value.IObservableValue;
15
import org.eclipse.jface.databinding.swt.WidgetProperties;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.DisposeEvent;
18
import org.eclipse.swt.events.DisposeListener;
19
import org.eclipse.swt.layout.RowLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.forms.widgets.FormToolkit;
24

  
25
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
26

  
27
/**
28
 * @author pplitzner
29
 * @date Feb 18, 2015
30
 *
31
 */
32
public class DeleteSpecimenConfiguratorComposite extends Composite {
33
    private final DataBindingContext m_bindingContext;
34

  
35
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36

  
37
    private final SpecimenDeleteConfigurator configurator;
38
    private final Button btnDeleteChildren;
39
    private final Button btnDeleteFromTypeDesignation;
40
    private final Button btnDeleteMolecularData;
41

  
42
    /**
43
     * Create the composite.
44
     * @param parent
45
     * @param style
46
     */
47
    public DeleteSpecimenConfiguratorComposite(SpecimenDeleteConfigurator configurator, Composite parent, int style) {
48
        super(parent, style);
49
        this.configurator = configurator;
50
        addDisposeListener(new DisposeListener() {
51
            @Override
52
            public void widgetDisposed(DisposeEvent e) {
53
                toolkit.dispose();
54
            }
55
        });
56
        toolkit.paintBordersFor(this);
57
        setLayout(new RowLayout(SWT.VERTICAL));
58

  
59
        btnDeleteChildren = new Button(this, SWT.CHECK);
60
        btnDeleteChildren.setText("Delete Children");
61

  
62
        btnDeleteFromTypeDesignation = new Button(this, SWT.CHECK);
63
        btnDeleteFromTypeDesignation.setText("Delete from type designation");
64

  
65
        btnDeleteMolecularData = new Button(this, SWT.CHECK);
66
        btnDeleteMolecularData.setText("Delete molecular data");
67
        m_bindingContext = initDataBindings();
68

  
69
    }
70

  
71
    protected DataBindingContext initDataBindings() {
72
        DataBindingContext bindingContext = new DataBindingContext();
73
        //
74
        IObservableValue observeSelectionBtnDeleteChildrenObserveWidget = WidgetProperties.selection().observe(btnDeleteChildren);
75
        IObservableValue deleteChildrenConfiguratorObserveValue = PojoProperties.value("deleteChildren").observe(configurator);
76
        bindingContext.bindValue(observeSelectionBtnDeleteChildrenObserveWidget, deleteChildrenConfiguratorObserveValue, null, null);
77
        //
78
        IObservableValue observeSelectionBtnDeleteFromTypeDesignationObserveWidget = WidgetProperties.selection().observe(btnDeleteFromTypeDesignation);
79
        IObservableValue deleteFromTypeDesignationConfiguratorObserveValue = PojoProperties.value("deleteFromTypeDesignation").observe(configurator);
80
        bindingContext.bindValue(observeSelectionBtnDeleteFromTypeDesignationObserveWidget, deleteFromTypeDesignationConfiguratorObserveValue, null, null);
81
        //
82
        IObservableValue observeSelectionBtnDeleteMolecularDataObserveWidget = WidgetProperties.selection().observe(btnDeleteMolecularData);
83
        IObservableValue deleteMolecularDataConfiguratorObserveValue = PojoProperties.value("deleteMolecularData").observe(configurator);
84
        bindingContext.bindValue(observeSelectionBtnDeleteMolecularDataObserveWidget, deleteMolecularDataConfiguratorObserveValue, null, null);
85
        //
86
        return bindingContext;
87
    }
88
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.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.deleteConfigurator;
11

  
12
import org.eclipse.core.databinding.DataBindingContext;
13
import org.eclipse.core.databinding.beans.PojoProperties;
14
import org.eclipse.core.databinding.observable.value.IObservableValue;
15
import org.eclipse.jface.databinding.swt.WidgetProperties;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.DisposeEvent;
18
import org.eclipse.swt.events.DisposeListener;
19
import org.eclipse.swt.layout.RowLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.ui.forms.widgets.FormToolkit;
24

  
25
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
26

  
27
/**
28
 * @author pplitzner
29
 * @date Feb 18, 2015
30
 *
31
 */
32
public class DeleteTaxonConfiguratorComposite extends Composite {
33
    private final DataBindingContext m_bindingContext;
34

  
35
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36
    private final TaxonBaseDeletionConfigurator configurator;
37
    private final Button btnDeleteTaxonName;
38

  
39
    /**
40
     * Create the composite.
41
     * @param parent
42
     * @param style
43
     */
44
    public DeleteTaxonConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, Composite parent, int style) {
45
        super(parent, style);
46
        this.configurator = configurator;
47
        addDisposeListener(new DisposeListener() {
48
            @Override
49
            public void widgetDisposed(DisposeEvent e) {
50
                toolkit.dispose();
51
            }
52
        });
53
        toolkit.paintBordersFor(this);
54
        setLayout(new RowLayout(SWT.VERTICAL));
55
        setBackground(getBackground());
56

  
57
        btnDeleteTaxonName = new Button(this, SWT.CHECK);
58
        btnDeleteTaxonName.setText("Delete taxon name");
59
        m_bindingContext = initDataBindings();
60

  
61
    }
62

  
63
    protected DataBindingContext initDataBindings() {
64
        DataBindingContext bindingContext = new DataBindingContext();
65
        //
66
        IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName);
67
        IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator);
68
        bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
69
        //
70
        return bindingContext;
71
    }
72
}

Also available in: Unified diff