ref #6566 Add generic "open part" handler to model fragment
[taxeditor.git] / eu.etaxonomy.taxeditor.workbench / src / main / java / eu / etaxonomy / taxeditor / workbench / OpenPartHandler.java
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.workbench.modeling.EPartService;
10 import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
11
12 public class OpenPartHandler {
13
14 @Execute
15 public void execute(ParameterizedCommand commandParameters, EPartService partService) {
16
17 if (null == commandParameters) {
18 return;
19 }
20 Map parameterMap = commandParameters.getParameterMap();
21 String partId = parameterMap.get(AppModelId.COMMANDPARAMETER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_COMMANDPARAMETER_PARTNAME).toString();
22 partService.showPart(partId, PartState.ACTIVATE);
23 }
24
25 @CanExecute
26 public boolean canExecute() {
27 return true;
28 }
29
30 }