cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / handler / defaultHandler / e4 / DefaultOpenSetBaseHandler.java
1 /**
2 * Copyright (C) 2020 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.defaultHandler.e4;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 import javax.inject.Named;
15
16 import org.eclipse.e4.core.contexts.IEclipseContext;
17 import org.eclipse.e4.core.di.annotations.Execute;
18 import org.eclipse.e4.ui.model.application.MApplication;
19 import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
20 import org.eclipse.e4.ui.services.IServiceConstants;
21 import org.eclipse.e4.ui.workbench.modeling.EModelService;
22 import org.eclipse.e4.ui.workbench.modeling.EPartService;
23 import org.eclipse.jface.viewers.TreeSelection;
24 import org.eclipse.swt.widgets.Shell;
25
26 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
27
28 /**
29 * @author k.luther
30 * @since Feb 20, 2020
31 */
32 public abstract class DefaultOpenSetBaseHandler<S> extends DefaultOpenHandlerBaseE4<S> {
33
34 @Override
35 @Execute
36 public void execute(@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MHandledMenuItem menuItem,
37 EModelService modelService, EPartService partService, MApplication application,
38 IEclipseContext context) throws Exception {
39 this.context = context;
40 this.modelService = modelService;
41 this.application = application;
42
43 String commandId = menuItem.getCommand().getElementId();
44 Object transientData = menuItem.getTransientData().get(commandId+".uuid");
45 S list = null;
46 if(transientData instanceof TreeSelection){
47 list = (S) ((TreeSelection)transientData).toList();
48
49 }else if (transientData instanceof UuidAndTitleCache){
50 List<UuidAndTitleCache> uuidList = new ArrayList<>();
51 uuidList.add((UuidAndTitleCache)transientData);
52 list = (S)uuidList;
53 }
54 if (list != null){
55 open(list, shell, partService);
56 }
57
58 }
59 }