Skip to content

Commit

Permalink
Fixed version check message when ignore version check is set to true.
Browse files Browse the repository at this point in the history
  • Loading branch information
ylussaud committed Sep 15, 2023
1 parent 0d993a9 commit e04cae0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -205,15 +206,17 @@ protected static boolean checkM2DocVersion(final Shell shell, final String dialo
throws DocumentGenerationException, IOException {
boolean res = true;

final Map<String, String> options = GenconfUtils.getOptions(gen);
final ResourceSet resourceSetForModel = M2DocUtils.createResourceSetForModels(new ArrayList<Exception>(), 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<Boolean> runnable = new ConfirmRunnable(dialogTitle, properties, shell);
Display.getDefault().syncExec(runnable);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -565,7 +566,9 @@ protected void doExecute() {

if (res != null) {
setPageComplete(true);
if (!M2DocUtils.VERSION.equals(res.getM2DocVersion())) {
final Map<String, String> 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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<genconf:Generation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genconf="http://www.obeonetwork.org/m2doc/genconf/1.0" name="wrongM2DocVersion" templateFileName="wrongM2DocVersion-template.docx" resultFileName="wrongM2DocVersion-actual-generation.docx" validationFileName="wrongM2DocVersion-actual-validation.docx">
<genconf:Generation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:genconf="http://www.obeonetwork.org/m2doc/genconf/1.0" name="wrongM2DocVersion" templateFileName="wrongM2DocVersionIgnoreVersionCheck-template.docx" resultFileName="wrongM2DocVersionIgnoreVersionCheck-actual-generation.docx" validationFileName="wrongM2DocVersionIgnoreVersionCheck-actual-validation.docx">
<options name="IgnoreVersionCheck" value="true"/>
</genconf:Generation>

0 comments on commit e04cae0

Please sign in to comment.