Project

General

Profile

Download (2.64 KB) Statistics
| Branch: | Tag: | Revision:
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.navigation.key.polytomous.handler;
11

    
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.operations.AbstractOperation;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.ui.handlers.HandlerUtil;
21

    
22
import eu.etaxonomy.taxeditor.model.MessagingUtils;
23
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewLabels;
24
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RemotingPolytomousKeyDeleteOperation;
25
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
26
import eu.etaxonomy.taxeditor.util.OperationsUtil;
27

    
28
/**
29
 * @author cmathew
30
 * @date 25 Jun 2015
31
 *
32
 */
33
public class RemotingPolytomousKeyDeleteHandler extends RemotingCdmHandler {
34

    
35
    List<UUID> keysToDelete;
36
    /**
37
     * @param label
38
     */
39
    public RemotingPolytomousKeyDeleteHandler() {
40
        super(PolytomousKeyViewLabels.DELETE_POLYTOMOUS_KEY_LABEL);
41
    }
42

    
43
    /* (non-Javadoc)
44
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
45
     */
46
    @Override
47
    public IStatus allowOperations(ExecutionEvent event) {
48
        IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
49

    
50
        keysToDelete = OperationsUtil.convertToUuidList(selection.toList());
51

    
52
        if(keysToDelete.isEmpty()){
53
           return Status.CANCEL_STATUS;
54
        }
55

    
56
        boolean confirmation = MessagingUtils.confirmDialog("Confirm deletaion", "Do you want to delete the selected key" + (keysToDelete.size() == 1 ? "" : "s") + "?");
57

    
58
        if(!confirmation) {
59
            return Status.CANCEL_STATUS;
60
        }
61
        return Status.OK_STATUS;
62
    }
63

    
64
    /* (non-Javadoc)
65
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
66
     */
67
    @Override
68
    public AbstractOperation prepareOperation(ExecutionEvent event) {
69
        return new RemotingPolytomousKeyDeleteOperation(event.getTrigger(),
70
                false,
71
                keysToDelete);
72
    }
73

    
74
    /* (non-Javadoc)
75
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
76
     */
77
    @Override
78
    public void onComplete() {
79
        // TODO Auto-generated method stub
80

    
81
    }
82

    
83
}
(6-6/6)