1 package org.simantics.modeling.ui.actions;
3 import java.util.Collection;
5 import org.eclipse.core.commands.AbstractHandler;
6 import org.eclipse.core.commands.ExecutionEvent;
7 import org.eclipse.core.commands.ExecutionException;
8 import org.eclipse.jface.viewers.ISelection;
9 import org.eclipse.jface.viewers.IStructuredSelection;
10 import org.eclipse.ui.handlers.HandlerUtil;
11 import org.simantics.db.Resource;
12 import org.simantics.db.layer0.SelectionHints;
13 import org.simantics.db.layer0.adapter.ActionFactory;
14 import org.simantics.utils.ui.ISelectionUtils;
17 * This class exists as a org.eclipse.ui.handler extension point counterpart for
18 * AssignSymbolGroup ActionFactory due to lack of multi-selection support in the
19 * modeled {@link ActionFactory} contributions.
21 * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>
23 public class AssignSymbolGroupsHandler extends AbstractHandler {
26 public Object execute(ExecutionEvent event) throws ExecutionException {
27 ISelection s = HandlerUtil.getCurrentSelection(event);
28 if (!(s instanceof IStructuredSelection))
31 Collection<Resource> res = ISelectionUtils.getPossibleKeys(s, SelectionHints.KEY_MAIN, Resource.class);
33 new AssignSymbolGroup().assignGroups(res);