Revision 963170aa
Added by Katja Luther about 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenuE4.java | ||
---|---|---|
3 | 3 |
import java.util.List; |
4 | 4 |
import java.util.Map; |
5 | 5 |
import java.util.Map.Entry; |
6 |
import java.util.UUID; |
|
6 | 7 |
|
7 | 8 |
import javax.inject.Inject; |
8 | 9 |
import javax.inject.Named; |
... | ... | |
22 | 23 |
import org.eclipse.jface.viewers.IStructuredSelection; |
23 | 24 |
import org.eclipse.jface.viewers.TreeNode; |
24 | 25 |
|
26 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
27 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
|
25 | 28 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
26 | 29 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
27 | 30 |
|
... | ... | |
90 | 93 |
menu.setLabel(Messages.CdmViewerContextMenu_OPEN_IN); |
91 | 94 |
items.add(menu); |
92 | 95 |
// items.add(addCommand(uuid, command, String.format(Messages.CdmViewerContextMenu_OPEN, viewerName))); |
93 |
menu.getChildren().add(addCommand((IStructuredSelection)selectedObject, command, viewerName));
|
|
96 |
menu.getChildren().add(addCommand(selectedObject, command, viewerName)); |
|
94 | 97 |
} |
95 | 98 |
else if(enabledCommands.size()>1){ |
96 | 99 |
MMenu menu = MMenuFactory.INSTANCE.createMenu(); |
... | ... | |
99 | 102 |
for(Entry<Command, String> entry:enabledCommands.entrySet()){ |
100 | 103 |
String viewerName = entry.getValue(); |
101 | 104 |
Command command = entry.getKey(); |
102 |
menu.getChildren().add(addCommand((IStructuredSelection)selectedObject, command, viewerName)); |
|
105 |
if (selectedObject instanceof IStructuredSelection){ |
|
106 |
menu.getChildren().add(addCommand(selectedObject, command, viewerName)); |
|
107 |
}else if(selectedObject instanceof ICdmBase){ |
|
108 |
UUID uuid = ((ICdmBase) selectedObject).getUuid(); |
|
109 |
menu.getChildren().add(addCommand(uuid, command, viewerName)); |
|
110 |
}else if (selectedObject instanceof UuidAndTitleCache){ |
|
111 |
menu.getChildren().add(addCommand(selectedObject, command, viewerName)); |
|
112 |
} |
|
103 | 113 |
} |
104 | 114 |
} |
105 | 115 |
} |
106 | 116 |
|
107 |
public MHandledMenuItem addCommand(IStructuredSelection selection, Command command, String commandLabel) {
|
|
117 |
public MHandledMenuItem addCommand(Object selection, Command command, String commandLabel) {
|
|
108 | 118 |
MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem(); |
109 | 119 |
menuItem.setLabel(commandLabel); |
110 | 120 |
MCommand mCommand = MCommandsFactory.INSTANCE.createCommand(); |
Also available in: Unified diff
ref #8890: allow multiselect for open in dynamic menu