X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Ftypicals%2FSyncCurrentTypicalTemplateToInstances.java;h=954b8f5f1d5d72b090f88b54ce352de82f04f5bb;hb=0475b9e2a9331ef8f3dcd61567e5d071ae8ef561;hp=c4454831e94412de3990203ea899f64814bd9258;hpb=7684baeb8bc7963700676af20db6f4a860581e46;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/SyncCurrentTypicalTemplateToInstances.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/SyncCurrentTypicalTemplateToInstances.java index c4454831e..954b8f5f1 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/SyncCurrentTypicalTemplateToInstances.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/SyncCurrentTypicalTemplateToInstances.java @@ -1,59 +1,59 @@ -package org.simantics.modeling.ui.typicals; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; -import org.simantics.Simantics; -import org.simantics.db.Resource; -import org.simantics.db.Session; -import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances; -import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter; -import org.simantics.modeling.ui.property.TypicalPropertyTester; -import org.simantics.ui.workbench.IResourceEditorInput; -import org.simantics.utils.ui.ErrorLogger; - -/** - * @author Tuukka Lehtonen - */ -public class SyncCurrentTypicalTemplateToInstances extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - Shell shell = HandlerUtil.getActiveShell(event); - IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event); - IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); - Session session = Simantics.getSession(); - -// if (!MessageDialog -// .openConfirm(shell, -// "Synchronize Typical Template With Instances", -// "Are you sure you want to synchronize all instances of this typical template with the template?")) -// return null; - - try { - if (!TypicalPropertyTester.isTypicalMasterEditor(session, input.getResource())) { - MessageDialog.openInformation(shell, "Not Synchronizing", "Currently active editor is not a typical diagram template editor."); - return null; - } - - RuleChooserDialog.RuleResult result = RuleChooserDialog.choose(shell, "Synchronizing typical template to all its instances in the currently active model.", new Resource[] { input.getResource() }); - if(result == null) return null; - - session.markUndoPoint(); - SyncTypicalTemplatesToInstances req = new SyncTypicalTemplatesToInstances(result.selectedRules, input.getResource()).logging(result.logging); - session.syncRequest(req); - if (result.logging) { - for(Resource log : req.logs) - new OpenPlainTextDocumentAdapter().openEditor(log); - } - } catch (Exception e) { - ErrorLogger.defaultLogError(e); - } - return null; - } - -} +package org.simantics.modeling.ui.typicals; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.Simantics; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances; +import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter; +import org.simantics.modeling.ui.property.TypicalPropertyTester; +import org.simantics.ui.workbench.IResourceEditorInput; +import org.simantics.utils.ui.ErrorLogger; + +/** + * @author Tuukka Lehtonen + */ +public class SyncCurrentTypicalTemplateToInstances extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + Shell shell = HandlerUtil.getActiveShell(event); + IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event); + IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); + Session session = Simantics.getSession(); + +// if (!MessageDialog +// .openConfirm(shell, +// "Synchronize Typical Template With Instances", +// "Are you sure you want to synchronize all instances of this typical template with the template?")) +// return null; + + try { + if (!TypicalPropertyTester.isTypicalMasterEditor(session, input.getResource())) { + MessageDialog.openInformation(shell, "Not Synchronizing", "Currently active editor is not a typical diagram template editor."); + return null; + } + + RuleChooserDialog.RuleResult result = RuleChooserDialog.choose(shell, "Synchronizing typical template to all its instances in the currently active model.", new Resource[] { input.getResource() }); + if(result == null) return null; + + session.markUndoPoint(); + SyncTypicalTemplatesToInstances req = new SyncTypicalTemplatesToInstances(result.selectedRules, input.getResource()).logging(result.logging); + session.syncRequest(req); + if (result.logging) { + for(Resource log : req.logs) + new OpenPlainTextDocumentAdapter().openEditor(log); + } + } catch (Exception e) { + ErrorLogger.defaultLogError(e); + } + return null; + } + +}