Skip to content

Commit

Permalink
#107 Add the posibility to display the "ReqIF.Text" attribute of
Browse files Browse the repository at this point in the history
Requirement elements in Capella Richtext editor

Resolves #107

Change-Id: Ie75a86317b6ddcc53da7047839e4a1be99de06c7
Signed-off-by: Tu Ton <minhtutonthat@gmail.com>
  • Loading branch information
minhtutonthat authored and pdulth committed Jan 12, 2021
1 parent fcfd6cc commit 64042ee
Show file tree
Hide file tree
Showing 33 changed files with 16,712 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pipeline {
script {
def capellaURL = capella.getDownloadURL("${CAPELLA_BRANCH}", 'linux', '')

sh "curl -k -o capella.zip ${capellaURL}"
sh "unzip -q capella.zip"
sh "curl -k -o capella.tar.gz ${capellaURL}"
sh "tar xvzf capella.tar.gz"

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.polarsys.capella.core.sirius.analysis,
org.polarsys.capella.core.data.business.queries,
org.eclipse.sirius.common,
org.polarsys.capella.vp.requirements.ui.commands
org.polarsys.capella.vp.requirements.ui.commands,
org.polarsys.kitalpha.vp.requirements.model.helpers
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.polarsys.kitalpha.vp.requirements.Requirements.Requirement;
import org.polarsys.kitalpha.vp.requirements.Requirements.RequirementsFactory;
import org.polarsys.kitalpha.vp.requirements.Requirements.RequirementsPackage;
import org.polarsys.kitalpha.vp.requirements.model.helpers.LabelHelper;

/**
* <!-- begin-user-doc --> This class is an implementation of the Sirius
Expand Down Expand Up @@ -359,7 +360,7 @@ public String getRequirementContent(Requirement requirement) {
.get(ReqVPCustomDataHelper.CUSTOM_DATA_KEY_FOR_REQ_VP_QUERIES_CONTENT_LENGTH);
}

return evaluateExpression(session, requirement, expression, maxLength);
return LabelHelper.transformHTMLToText(evaluateExpression(session, requirement, expression, maxLength));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ <h2>Diff/Merge Dialog</h2>
</p>
</ul>

<b>Display ReqIF Text content in Capella Richtext editor</b>
<p>
Requirement's ReqIf.Text field when imported into Capella model can be displayed in Capella Richtext editor in the property view as shown in the below image.</div>
</p>
<img src="../../images/ReqIFText.png" alt="ReqIF Text" title="ReqIF Text">
<p>
For imported images, users can choose one of three strategies: import to an absolute path, import to a relative path or embed image in Base64 format. Here below are the advantages and inconveniences for each approach.
</p>
<img src="../../images/ImageImportStrategy.png" alt="Image import strategies" title="Image import strategies">
<ul>
<li>Absolute path: This is the recommended mode. However, images cannot be loaded if the image folder location is not known to Capella. Thus, users must make sure that the image folder is accessible (e.g. folder in a shared drive)</li>
<li>Relative path: The image folder is included in Capella project. However, due to some limitations, this mode does not work well with connected models in collaborative mode.</li>
<li>Embed in Base64: The image is directly embedded in Capella model. This can significantly increase the size of the model.</li>
</ul>
<p>Notice that between imports, if the image importing strategy is changed, the tool will consider that the text has been changed and thus, show the difference. If you do not want to see these differences, make sure to use the same image importing strategy in interative imports.</p>
<h2>Iterativity</h2>
<p>After an import, a new file .bridgetraces is created aside the .capella file. This file is used to allow successive imports. It shall not be deleted.</p>

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ http://www.eclipse.org/legal/epl-2.0
/images/type.png - org.polarsys.capella.vp.requirements.doc
/images/viewpointmanager.png - org.polarsys.capella.vp.requirements.doc
/images/migration1.png - org.polarsys.capella.vp.requirements.doc
/images/migration2.png - org.polarsys.capella.vp.requirements.doc
/images/migration2.png - org.polarsys.capella.vp.requirements.doc
/images/ReqIFText.png - org.polarsys.capella.vp.requirements.doc
/images/ImageImportStrategy.png - org.polarsys.capella.vp.requirements.doc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ Require-Bundle: org.eclipse.core.runtime,
org.polarsys.capella.vp.requirements.model.helpers,
org.eclipse.jface,
org.eclipse.ui.ide,
org.eclipse.swt
org.eclipse.swt,
org.polarsys.capella.core.preferences,
org.apache.commons.io,
org.polarsys.kitalpha.vp.requirements.model.helpers
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.polarsys.capella.vp.requirements.importer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
package org.polarsys.capella.vp.requirements.importer.transposer.activities;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
Expand All @@ -26,6 +33,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.diffmerge.api.scopes.IEditableModelScope;
import org.eclipse.emf.diffmerge.bridge.api.IBridgeTrace;
import org.eclipse.emf.diffmerge.bridge.api.incremental.IIncrementalBridgeExecution;
Expand All @@ -42,6 +50,8 @@
import org.polarsys.capella.common.ef.ExecutionManager;
import org.polarsys.capella.common.ef.command.AbstractReadWriteCommand;
import org.polarsys.capella.common.helpers.TransactionHelper;
import org.polarsys.capella.common.tools.report.config.registry.ReportManagerRegistry;
import org.polarsys.capella.common.tools.report.util.IReportManagerDefaultComponents;
import org.polarsys.capella.core.data.cs.BlockArchitecture;
import org.polarsys.capella.core.model.handler.helpers.HoldingResourceHelper;
import org.polarsys.capella.core.transition.common.activities.AbstractActivity;
Expand All @@ -50,6 +60,7 @@
import org.polarsys.kitalpha.cadence.core.api.parameter.ActivityParameters;
import org.polarsys.kitalpha.transposer.api.ITransposerWorkflow;
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext;
import org.polarsys.kitalpha.vp.requirements.Requirements.Requirement;

/**
* This class managers the merge of requirements into the model and the save of the associated resources.
Expand All @@ -67,6 +78,8 @@ public class TransposerTransformation extends AbstractActivity {
* There must be a cleaner way to achieve this. But for the moment this will do.
*/
final boolean[] mergeOperationCanceled = { false };
private static final Logger LOGGER = ReportManagerRegistry.getInstance()
.subscribe(IReportManagerDefaultComponents.DEFAULT);

/**
* The UI job that manages the transformation.
Expand Down Expand Up @@ -173,6 +186,7 @@ protected IStatus mergeAndSave(ActivityParameters activityParams, IProgressMonit
Resource traceResource = (Resource) context.get(IRequirementsImporterBridgeConstants.TRACE_RESOURCE);

saveAndCleanResources(executionManager, modelResource, traceResource, subMonitor.split(1));
importReferencedImages(blockArchitecture, context);
}
}

Expand All @@ -182,6 +196,40 @@ protected IStatus mergeAndSave(ActivityParameters activityParams, IProgressMonit
return Status.OK_STATUS;
}

/**
* Copy referenced images
* @param targetElement
* @param context
*/
protected void importReferencedImages(EObject targetElement, IContext context) {
TreeIterator<EObject> eAllContents = targetElement.eAllContents();
while (eAllContents.hasNext()) {
EObject eObj = eAllContents.next();
if (eObj instanceof Requirement) {
Requirement requirement = (Requirement) eObj;
importReferencedImagesOfRequirement(requirement, context);
}
}
}

protected void importReferencedImagesOfRequirement(Requirement requirement, IContext context) {
Map<String, List<List<Path>>> reqID2Images = (Map<String, List<List<Path>>>) context
.get(IRequirementsImporterBridgeConstants.IMAGES_TO_COPY);
if (reqID2Images.containsKey(requirement.getReqIFIdentifier())) {
List<List<Path>> imagesToCopy = reqID2Images.get(requirement.getReqIFIdentifier());
if (!imagesToCopy.isEmpty()) {
for (List<Path> srcPath2TargetPath : imagesToCopy) {
try {
Files.copy(srcPath2TargetPath.get(0), srcPath2TargetPath.get(1), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
LOGGER.log(Level.ERROR, MessageFormat.format("Cannot find or cannot copy {0}", srcPath2TargetPath.get(0)),
e);
}
}
}
}
}

/**
* Displays the Diff Merge Window, and merges the Requirements on user feedback. The code is executed in a
* transaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ public class IRequirementsImporterBridgeConstants {
public static final String BRIDGE_EXECUTION = "BRIDGE_EXECUTION";
public static final String REQIF_MODEL_FILE_EXTENSION = "reqif";
public static final String REQIF_MODEL_CONTAINS_MODULE = "ReqIF model must have at least a module";
public static final String IMAGES_TO_COPY = "Images to copy";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright (c) 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.vp.requirements.importer.transposer.bridge;

public enum ImageImportStrategy {
ABS_PATH, REL_PATH, EMBEDDED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2020 THALES GLOBAL SERVICES.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.vp.requirements.importer.transposer.bridge;

public class ImageImporter {
private ImageImportStrategy imgImportStrategy;
private String absPath;
private String relPath;

public ImageImportStrategy getImgImportStrategy() {
return imgImportStrategy;
}

public void setImgImportStrategy(ImageImportStrategy imgImportStrategy) {
this.imgImportStrategy = imgImportStrategy;
}

public String getAbsPath() {
return absPath;
}
public void setAbsPath(String absPath) {
this.absPath = absPath;
}
public String getRelPath() {
return relPath;
}
public void setRelPath(String relPath) {
this.relPath = relPath;
}

}

0 comments on commit 64042ee

Please sign in to comment.