]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/ExpandFlagsHandler.java
(refs #7561) Allow extra parameters to the application of type alias
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / actions / ExpandFlagsHandler.java
1 package org.simantics.modeling.ui.actions;
2
3 import java.util.Arrays;
4 import java.util.HashSet;
5 import java.util.List;
6 import java.util.Set;
7
8 import org.eclipse.core.runtime.IProgressMonitor;
9 import org.simantics.db.Resource;
10 import org.simantics.db.WriteGraph;
11 import org.simantics.db.exception.DatabaseException;
12 import org.simantics.diagram.synchronization.runtime.DiagramSelectionUpdater;
13 import org.simantics.g2d.canvas.ICanvasContext;
14 import org.simantics.modeling.flags.ExpandFlags;
15
16 /**
17  * @author Hannu Niemistö
18  * @author Tuukka Lehtonen
19  */
20 public class ExpandFlagsHandler extends FlagOperationHandler {
21
22     @Override
23     protected void perform(IProgressMonitor monitor, WriteGraph graph, List<Resource> flags,
24             ICanvasContext canvasContext) throws DatabaseException {
25         monitor.beginTask("Expand Flags", IProgressMonitor.UNKNOWN);
26
27         Set<Resource> newSelection = new HashSet<Resource>();
28         for (Resource flag : flags) {
29             Resource[] result = ExpandFlags.expandFlag(graph, flag);
30             newSelection.addAll( Arrays.asList(result) );
31         }
32
33         // Make sure the diagram selection is set to the
34         // merged flag after the merge.
35         new DiagramSelectionUpdater( canvasContext )
36         .setNewSelection(0, newSelection)
37         .setOneshot(true)
38         .track();
39     }
40
41 }