X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Factions%2FMergeFlagsHandler.java;h=3671fa9bbb88298038be9ccc86f8128170a7b497;hb=HEAD;hp=a003c13283304746e62e31547b2db73527a1403f;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java index a003c1328..3671fa9bb 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/MergeFlagsHandler.java @@ -1,56 +1,59 @@ -package org.simantics.modeling.ui.actions; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.ui.PlatformUI; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; -import org.simantics.diagram.synchronization.runtime.DiagramSelectionUpdater; -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.modeling.flags.MergeFlags; - -/** - * @author Hannu Niemistö - * @author Tuukka Lehtonen - */ -public class MergeFlagsHandler extends FlagOperationHandler { - - protected void perform(IProgressMonitor monitor, WriteGraph graph, List flags, ICanvasContext canvasContext) throws DatabaseException { - monitor.beginTask("Merge Selected Flags", IProgressMonitor.UNKNOWN); - performMerge(graph, flags, canvasContext); - } - - public static void performMerge(WriteGraph graph, List flags, ICanvasContext canvasContext) throws DatabaseException { - final String text = MergeFlags.validateForMerge(graph, flags); - if(text != null) { - System.err.println(text); - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .getActiveEditor().getEditorSite().getActionBars().getStatusLineManager() - .setErrorMessage(text); - } - }); - } - else { - String result = MergeFlags.merge(graph, flags); - if(result != null && !result.isEmpty()) { - System.err.println(result); // Should not happen because of prevalidation - } else { - if (canvasContext != null) { - // Make sure the diagram selection is set to the - // merged flag after the merge. - new DiagramSelectionUpdater( canvasContext ) - .setNewSelection(0, Collections.singleton( flags.get(0) )) - .setOneshot(true) - .track(); - } - } - } - } - -} +package org.simantics.modeling.ui.actions; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.ui.PlatformUI; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; +import org.simantics.diagram.synchronization.runtime.DiagramSelectionUpdater; +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.modeling.flags.MergeFlags; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Hannu Niemistö + * @author Tuukka Lehtonen + */ +public class MergeFlagsHandler extends FlagOperationHandler { + + private static final Logger LOGGER = LoggerFactory.getLogger(MergeFlagsHandler.class); + protected void perform(IProgressMonitor monitor, WriteGraph graph, List flags, ICanvasContext canvasContext) throws DatabaseException { + monitor.beginTask(Messages.MergeFlagsHandler_MonitorMergeSelectedFlags, IProgressMonitor.UNKNOWN); + performMerge(graph, flags, canvasContext); + } + + public static void performMerge(WriteGraph graph, List flags, ICanvasContext canvasContext) throws DatabaseException { + final String text = MergeFlags.validateForMerge(graph, flags); + if(text != null) { + LOGGER.error(text); + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() + .getActiveEditor().getEditorSite().getActionBars().getStatusLineManager() + .setErrorMessage(text); + } + }); + } + else { + String result = MergeFlags.merge(graph, flags); + if(result != null && !result.isEmpty()) { + LOGGER.error(result); // Should not happen because of prevalidation + } else { + if (canvasContext != null) { + // Make sure the diagram selection is set to the + // merged flag after the merge. + new DiagramSelectionUpdater( canvasContext ) + .setNewSelection(0, Collections.singleton( flags.get(0) )) + .setOneshot(true) + .track(); + } + } + } + } + +}