1 package org.simantics.modeling.ui.actions;
3 import java.util.Arrays;
4 import java.util.HashSet;
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;
17 * @author Hannu Niemistö
18 * @author Tuukka Lehtonen
20 public class ExpandFlagsHandler extends FlagOperationHandler {
23 protected void perform(IProgressMonitor monitor, WriteGraph graph, List<Resource> flags,
24 ICanvasContext canvasContext) throws DatabaseException {
25 monitor.beginTask("Expand Flags", IProgressMonitor.UNKNOWN);
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) );
33 // Make sure the diagram selection is set to the
34 // merged flag after the merge.
35 new DiagramSelectionUpdater( canvasContext )
36 .setNewSelection(0, newSelection)