-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#88 Copy images to the target project
Add a new Activity triggered after diff/merge to copy images contained in the source project to the target project. Change-Id: I0000000000000000000000000000000000000000 Signed-off-by: Arnaud Dieumegard <arnaud.dieumegard@obeo.fr>
- Loading branch information
1 parent
879d495
commit 50e2b60
Showing
8 changed files
with
171 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 45 additions & 43 deletions
88
plugins/org.polarsys.capella.transition.system2subsystem/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,45 @@ | ||
Manifest-Version: 1.0 | ||
Export-Package: org.polarsys.capella.transition.system2subsystem, | ||
org.polarsys.capella.transition.system2subsystem.activities, | ||
org.polarsys.capella.transition.system2subsystem.commands, | ||
org.polarsys.capella.transition.system2subsystem.constants, | ||
org.polarsys.capella.transition.system2subsystem.context, | ||
org.polarsys.capella.transition.system2subsystem.handlers.attachment, | ||
org.polarsys.capella.transition.system2subsystem.handlers.filter, | ||
org.polarsys.capella.transition.system2subsystem.handlers.scope, | ||
org.polarsys.capella.transition.system2subsystem.handlers.selection, | ||
org.polarsys.capella.transition.system2subsystem.handlers.session, | ||
org.polarsys.capella.transition.system2subsystem.handlers.traceability, | ||
org.polarsys.capella.transition.system2subsystem.handlers.traceability.config, | ||
org.polarsys.capella.transition.system2subsystem.launcher, | ||
org.polarsys.capella.transition.system2subsystem.policies.match, | ||
org.polarsys.capella.transition.system2subsystem.preferences, | ||
org.polarsys.capella.transition.system2subsystem.rules, | ||
org.polarsys.capella.transition.system2subsystem.rules.core, | ||
org.polarsys.capella.transition.system2subsystem.rules.cs, | ||
org.polarsys.capella.transition.system2subsystem.rules.fa, | ||
org.polarsys.capella.transition.system2subsystem.rules.information, | ||
org.polarsys.capella.transition.system2subsystem.rules.information.communication, | ||
org.polarsys.capella.transition.system2subsystem.rules.interaction, | ||
org.polarsys.capella.transition.system2subsystem.rules.pa, | ||
org.polarsys.capella.transition.system2subsystem.transposer | ||
Require-Bundle: org.eclipse.core.runtime, | ||
org.polarsys.capella.core.data.gen, | ||
org.polarsys.capella.core.model.helpers, | ||
org.polarsys.capella.core.transition.system;visibility:=reexport, | ||
org.polarsys.capella.core.transition.system.topdown, | ||
org.polarsys.capella.core.model.handler, | ||
org.polarsys.capella.common.libraries, | ||
org.polarsys.capella.common.transition | ||
Bundle-Vendor: %providerName | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-Version: 1.6.0.qualifier | ||
Bundle-Localization: plugin | ||
Bundle-Name: %pluginName | ||
Bundle-Activator: org.polarsys.capella.transition.system2subsystem.Activator | ||
Bundle-ManifestVersion: 2 | ||
Bundle-SymbolicName: org.polarsys.capella.transition.system2subsystem;singleton:=true | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
|
||
Manifest-Version: 1.0 | ||
Export-Package: org.polarsys.capella.transition.system2subsystem, | ||
org.polarsys.capella.transition.system2subsystem.activities, | ||
org.polarsys.capella.transition.system2subsystem.commands, | ||
org.polarsys.capella.transition.system2subsystem.constants, | ||
org.polarsys.capella.transition.system2subsystem.context, | ||
org.polarsys.capella.transition.system2subsystem.handlers.attachment, | ||
org.polarsys.capella.transition.system2subsystem.handlers.filter, | ||
org.polarsys.capella.transition.system2subsystem.handlers.scope, | ||
org.polarsys.capella.transition.system2subsystem.handlers.selection, | ||
org.polarsys.capella.transition.system2subsystem.handlers.session, | ||
org.polarsys.capella.transition.system2subsystem.handlers.traceability, | ||
org.polarsys.capella.transition.system2subsystem.handlers.traceability.config, | ||
org.polarsys.capella.transition.system2subsystem.launcher, | ||
org.polarsys.capella.transition.system2subsystem.policies.match, | ||
org.polarsys.capella.transition.system2subsystem.preferences, | ||
org.polarsys.capella.transition.system2subsystem.rules, | ||
org.polarsys.capella.transition.system2subsystem.rules.core, | ||
org.polarsys.capella.transition.system2subsystem.rules.cs, | ||
org.polarsys.capella.transition.system2subsystem.rules.fa, | ||
org.polarsys.capella.transition.system2subsystem.rules.information, | ||
org.polarsys.capella.transition.system2subsystem.rules.information.communication, | ||
org.polarsys.capella.transition.system2subsystem.rules.interaction, | ||
org.polarsys.capella.transition.system2subsystem.rules.pa, | ||
org.polarsys.capella.transition.system2subsystem.transposer | ||
Require-Bundle: org.eclipse.core.runtime, | ||
org.polarsys.capella.core.data.gen, | ||
org.polarsys.capella.core.model.helpers, | ||
org.polarsys.capella.core.transition.system;visibility:=reexport, | ||
org.polarsys.capella.core.transition.system.topdown, | ||
org.polarsys.capella.core.model.handler, | ||
org.polarsys.capella.common.libraries, | ||
org.polarsys.capella.common.transition, | ||
org.polarsys.kitalpha.ad.metadata, | ||
org.polarsys.capella.core.sirius.ui | ||
Bundle-Vendor: %providerName | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-Version: 1.6.0.qualifier | ||
Bundle-Localization: plugin | ||
Bundle-Name: %pluginName | ||
Bundle-Activator: org.polarsys.capella.transition.system2subsystem.Activator | ||
Bundle-ManifestVersion: 2 | ||
Bundle-SymbolicName: org.polarsys.capella.transition.system2subsystem;singleton:=true | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...m/src/org/polarsys/capella/transition/system2subsystem/activities/CopyImagesActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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.transition.system2subsystem.activities; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IResource; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.core.runtime.Status; | ||
import org.polarsys.capella.core.data.capellamodeller.Project; | ||
import org.polarsys.capella.core.sirius.ui.helper.ResourceHelper; | ||
import org.polarsys.capella.core.transition.common.activities.AbstractActivity; | ||
import org.polarsys.capella.core.transition.common.handlers.log.LogHelper; | ||
import org.polarsys.capella.core.transition.system.helpers.ContextHelper; | ||
import org.polarsys.capella.transition.system2subsystem.constants.Messages; | ||
import org.polarsys.kitalpha.cadence.core.api.parameter.ActivityParameters; | ||
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext; | ||
|
||
/** | ||
* This activity copies all images from the Transition Context Source Project into the Transition Context Target | ||
* Project. | ||
* | ||
* @author <a href="mailto:arnaud.dieumegard@obeo.fr">Arnaud Dieumegard</a> | ||
*/ | ||
public class CopyImagesActivity extends AbstractActivity { | ||
|
||
public static final String ID = "org.polarsys.capella.transition.system2subsystem.activities.CopyImagesActivity"; //$NON-NLS-1$ | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected IStatus _run(ActivityParameters activityParams_p) { | ||
|
||
IContext transformationContext = getContext(activityParams_p); | ||
Project sourceProject = ContextHelper.getSourceProject(transformationContext); | ||
Project targetProject = ContextHelper.getTargetProject(transformationContext); | ||
|
||
IProject sourceEclipseProject = ResourcesPlugin.getWorkspace().getRoot().getProject(sourceProject.getName()); | ||
IProject targetEclipseProject = ResourcesPlugin.getWorkspace().getRoot().getProject(targetProject.getName()); | ||
|
||
copyImagesToTargetProject(sourceEclipseProject, targetEclipseProject); | ||
|
||
return Status.OK_STATUS; | ||
} | ||
|
||
private void copyImagesToTargetProject(IProject sourceEclipseProject, IProject targetEclipseProject) { | ||
// Copy image | ||
try { | ||
for (IResource resource : ResourceHelper.collectImageFiles(sourceEclipseProject)) { | ||
// Prevent the copy of already existing resources | ||
if (!targetEclipseProject.exists(resource.getProjectRelativePath())) { | ||
// Calculate newPath with the same file name | ||
IPath newPath = targetEclipseProject.getFullPath(); | ||
newPath = newPath.addTrailingSeparator(); | ||
newPath = newPath.append(resource.getProjectRelativePath()); | ||
// Create folder hierarchy | ||
boolean mkdirs = targetEclipseProject.getLocation().addTrailingSeparator().append(resource.getProjectRelativePath()).removeLastSegments(1).toFile().mkdirs(); | ||
if (mkdirs) { | ||
targetEclipseProject.refreshLocal(newPath.segmentCount() - 1, null); | ||
} | ||
// Copy the file | ||
resource.copy(newPath, true, new NullProgressMonitor()); | ||
} | ||
} | ||
} catch (CoreException e) { | ||
LogHelper.getInstance().log(e.getMessage(), new Status(IStatus.ERROR, org.polarsys.capella.transition.system2subsystem.Activator.PLUGIN_ID, e.getMessage(), e), | ||
Messages.Activity_CopyImages); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public String getActivityIdentifier() { | ||
return ID; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters