Project

General

Profile

Download (2.01 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.handler;
11

    
12
import java.util.Collection;
13

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

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

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

    
34

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

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

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

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

    
57
        }
58

    
59
        return null;
60

    
61
    }
62
}
(3-3/9)