Project

General

Profile

Download (2.01 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.handler;
10

    
11
import java.util.Collection;
12

    
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
17
import org.eclipse.swt.SWT;
18

    
19
import eu.etaxonomy.cdm.model.common.CdmBase;
20
import eu.etaxonomy.taxeditor.model.AbstractUtility;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
22
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24
import eu.etaxonomy.taxeditor.view.sessions.InspectSessionsDialog;
25

    
26
/**
27
 * @author cmathew
28
 * @date 18 Feb 2015
29
 *
30
 */
31
public class OpenInspectSessionsHandler extends AbstractHandler implements IHandler {
32

    
33

    
34
    /* (non-Javadoc)
35
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
36
     */
37
    /** {@inheritDoc} */
38
    @Override
39
    public Object execute(ExecutionEvent event) throws ExecutionException {
40

    
41
        Object principal = CdmStore.getCurrentAuthentiation().getPrincipal();
42

    
43
        ICdmEntitySession activeSession = CdmStore.getCurrentSessionManager().getActiveSession();
44

    
45
        if(activeSession == null) {
46
            MessagingUtils.warningDialog("No Active Session", this, "Active Session is null");
47
        } else {
48
            Collection<CdmBase> rootEntities = activeSession.getRootEntities();
49
            if(rootEntities == null || rootEntities.isEmpty()) {
50
                MessagingUtils.warningDialog("No Root Entities", this, "No root entities to inspect");
51
            } else {
52
                InspectSessionsDialog dialog = new InspectSessionsDialog(AbstractUtility.getShell(), SWT.NONE);
53
                dialog.open();
54
            }
55

    
56
        }
57

    
58
        return null;
59

    
60
    }
61
}
(5-5/11)