Project

General

Profile

Download (1.65 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
package eu.etaxonomy.taxeditor.workbench;
3

    
4
import java.util.Map;
5

    
6
import org.eclipse.core.commands.ParameterizedCommand;
7
import org.eclipse.e4.core.di.annotations.CanExecute;
8
import org.eclipse.e4.core.di.annotations.Execute;
9
import org.eclipse.e4.ui.model.application.MApplication;
10
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
11
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
12
import org.eclipse.e4.ui.workbench.modeling.EModelService;
13
import org.eclipse.e4.ui.workbench.modeling.EPartService;
14
import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
15

    
16
import eu.etaxonomy.taxeditor.workbench.part.IEditorAreaPart;
17

    
18
public class OpenPartHandler {
19

    
20
    @Execute
21
    public void execute(ParameterizedCommand commandParameters, EPartService partService, MApplication application, EModelService modelService) {
22

    
23
        if (null == commandParameters) {
24
            return;
25
        }
26
        Map parameterMap = commandParameters.getParameterMap();
27
        String partId = parameterMap.get(AppModelId.COMMANDPARAMETER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_COMMANDPARAMETER_PARTNAME).toString();
28
        MPart part = partService.createPart(partId);
29
        part = partService.showPart(part, PartState.ACTIVATE);
30
        if(part.getObject() instanceof IEditorAreaPart){
31
            MPartStack editorAreaPartStack = WorkbenchUtility.getEditorAreaPartStack(application, modelService);
32
            if(editorAreaPartStack!=null){
33
                editorAreaPartStack.getChildren().add(part);
34
            }
35
            part = partService.showPart(part, PartState.VISIBLE);
36
        }
37
    }
38

    
39
    @CanExecute
40
    public boolean canExecute() {
41
        return true;
42
    }
43

    
44
}
(5-5/8)