From e04cae03b78ad8a19a146ab67c8df450e3b476a8 Mon Sep 17 00:00:00 2001 From: Yvan Lussaud Date: Fri, 15 Sep 2023 14:43:38 +0200 Subject: [PATCH] Fixed version check message when ignore version check is set to true. --- .../genconf/editor/command/AbstractGenerationHandler.java | 7 +++++-- .../genconf/editor/wizard/GenerationFileNamesPage.java | 7 +++++-- .../wrongM2DocVersionIgnoreVersionCheck.genconf | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/command/AbstractGenerationHandler.java b/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/command/AbstractGenerationHandler.java index d4e655cfe..75a7e44c7 100644 --- a/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/command/AbstractGenerationHandler.java +++ b/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/command/AbstractGenerationHandler.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.Map; import java.util.concurrent.RunnableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -205,15 +206,17 @@ protected static boolean checkM2DocVersion(final Shell shell, final String dialo throws DocumentGenerationException, IOException { boolean res = true; + final Map options = GenconfUtils.getOptions(gen); final ResourceSet resourceSetForModel = M2DocUtils.createResourceSetForModels(new ArrayList(), gen, - new ResourceSetImpl(), GenconfUtils.getOptions(gen)); + new ResourceSetImpl(), options); final String templateFilePath = gen.getTemplateFileName(); if (templateFilePath != null && !templateFilePath.isEmpty()) { final URI templateURI = GenconfUtils.getResolvedURI(gen, URI.createURI(templateFilePath, false)); final TemplateCustomProperties properties = POIServices.getInstance() .getTemplateCustomProperties(resourceSetForModel.getURIConverter(), templateURI); - if (!M2DocUtils.VERSION.equals(properties.getM2DocVersion())) { + final boolean ignoreVersionCheck = Boolean.valueOf(options.get(M2DocUtils.IGNORE_VERSION_CHECK_OPTION)); + if (!ignoreVersionCheck && !M2DocUtils.VERSION.equals(properties.getM2DocVersion())) { RunnableFuture runnable = new ConfirmRunnable(dialogTitle, properties, shell); Display.getDefault().syncExec(runnable); try { diff --git a/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/wizard/GenerationFileNamesPage.java b/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/wizard/GenerationFileNamesPage.java index 4c79edd22..a819d8a0d 100644 --- a/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/wizard/GenerationFileNamesPage.java +++ b/plugins/org.obeonetwork.m2doc.genconf.editor/src/org/obeonetwork/m2doc/genconf/editor/wizard/GenerationFileNamesPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 Obeo. + * Copyright (c) 2018, 2023 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.eclipse.acceleo.query.runtime.IQueryEnvironment; import org.eclipse.acceleo.query.runtime.Query; @@ -565,7 +566,9 @@ protected void doExecute() { if (res != null) { setPageComplete(true); - if (!M2DocUtils.VERSION.equals(res.getM2DocVersion())) { + final Map options = GenconfUtils.getOptions(generation); + final boolean ignoreVersionCheck = Boolean.valueOf(options.get(M2DocUtils.IGNORE_VERSION_CHECK_OPTION)); + if (!ignoreVersionCheck && !M2DocUtils.VERSION.equals(res.getM2DocVersion())) { setMessage("M2Doc version mismatch: template version is " + res.getM2DocVersion() + " and current M2Doc version is " + M2DocUtils.VERSION, IMessageProvider.WARNING); } else { diff --git a/tests/org.obeonetwork.m2doc.tests/resources/static/wrongM2DocVersionIgnoreVersionCheck/wrongM2DocVersionIgnoreVersionCheck.genconf b/tests/org.obeonetwork.m2doc.tests/resources/static/wrongM2DocVersionIgnoreVersionCheck/wrongM2DocVersionIgnoreVersionCheck.genconf index 2d81e2282..084891ea4 100644 --- a/tests/org.obeonetwork.m2doc.tests/resources/static/wrongM2DocVersionIgnoreVersionCheck/wrongM2DocVersionIgnoreVersionCheck.genconf +++ b/tests/org.obeonetwork.m2doc.tests/resources/static/wrongM2DocVersionIgnoreVersionCheck/wrongM2DocVersionIgnoreVersionCheck.genconf @@ -1,4 +1,4 @@ - +