]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/AssignSymbolGroupsHandler.java
Allow client-logic in component type interface property name editing
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / AssignSymbolGroupsHandler.java
1 package org.simantics.modeling.ui.actions;
2
3 import java.util.Collection;
4
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;
15
16 /**
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.
20  * 
21  * @author Tuukka Lehtonen <tuukka.lehtonen@semantum.fi>
22  */
23 public class AssignSymbolGroupsHandler extends AbstractHandler {
24
25         @Override
26         public Object execute(ExecutionEvent event) throws ExecutionException {
27                 ISelection s = HandlerUtil.getCurrentSelection(event);
28                 if (!(s instanceof IStructuredSelection))
29                         return null;
30
31                 Collection<Resource> res = ISelectionUtils.getPossibleKeys(s, SelectionHints.KEY_MAIN, Resource.class);
32                 if (!res.isEmpty())
33                         new AssignSymbolGroup().assignGroups(res);
34
35                 return null;
36         }
37
38 }