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 {
25 public static Object handleStatic(Collection<Resource> res) throws ExecutionException {
26 return executeImpl(res);
30 public Object execute(ExecutionEvent event) throws ExecutionException {
31 ISelection s = HandlerUtil.getCurrentSelection(event);
32 if (!(s instanceof IStructuredSelection))
35 Collection<Resource> res = ISelectionUtils.getPossibleKeys(s, SelectionHints.KEY_MAIN, Resource.class);
36 return executeImpl(res);
39 private static Object executeImpl(Collection<Resource> res) throws ExecutionException {
41 new AssignSymbolGroup().assignGroups(res);