Revision 313b340d
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenHandlerBaseE4.java | ||
---|---|---|
8 | 8 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
9 | 9 |
import org.eclipse.e4.core.di.annotations.Execute; |
10 | 10 |
import org.eclipse.e4.ui.model.application.MApplication; |
11 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
11 | 12 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
12 | 13 |
import org.eclipse.e4.ui.services.IServiceConstants; |
13 | 14 |
import org.eclipse.e4.ui.workbench.modeling.EModelService; |
... | ... | |
40 | 41 |
} |
41 | 42 |
|
42 | 43 |
@CanExecute |
43 |
public boolean canExecute(MHandledMenuItem menuItem) { |
|
44 |
public boolean canExecute(MHandledMenuItem menuItem, |
|
45 |
@Named(IServiceConstants.ACTIVE_PART) MPart activePart) { |
|
44 | 46 |
boolean canExecute = false; |
47 |
|
|
48 |
//check if same part |
|
49 |
String partId = getPartId(); |
|
50 |
//check for correct entity |
|
45 | 51 |
String commandId = menuItem.getCommand().getElementId(); |
46 | 52 |
Object transientData = menuItem.getTransientData().get(commandId+".uuid"); |
47 | 53 |
if(transientData instanceof UUID){ |
48 | 54 |
T entity = getEntity((UUID) transientData); |
49 |
canExecute = canExecute(entity); |
|
55 |
canExecute = canExecute(entity) |
|
56 |
&& (partId!=null?!partId.equals(activePart.getElementId()):true); |
|
50 | 57 |
} |
51 | 58 |
menuItem.setVisible(canExecute); |
52 | 59 |
return canExecute; |
... | ... | |
58 | 65 |
|
59 | 66 |
protected abstract boolean canExecute(T entity); |
60 | 67 |
|
68 |
/** |
|
69 |
* Returns the part id for the part this handler opens.<br> |
|
70 |
*/ |
|
71 |
protected String getPartId(){ |
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
61 | 75 |
} |
Also available in: Unified diff
Hide option to "Open in" an element in the same part