diff options
author | Nicolas FAUVERGUE | 2019-04-14 07:12:08 +0000 |
---|---|---|
committer | Patrick Tessier | 2019-04-15 08:57:24 +0000 |
commit | 6157d8fbb1fe1e62e094c3d22b9339f9cd045781 (patch) | |
tree | 681b0f19baf9c644f6ef3ef3c0f6c7dc277fe1e6 /plugins | |
parent | d23d3677570137311a64c5775296305ba6fdc952 (diff) | |
download | org.eclipse.papyrus-6157d8fbb1fe1e62e094c3d22b9339f9cd045781.tar.gz org.eclipse.papyrus-6157d8fbb1fe1e62e094c3d22b9339f9cd045781.tar.xz org.eclipse.papyrus-6157d8fbb1fe1e62e094c3d22b9339f9cd045781.zip |
Bug 546239: [Toolsmiths][Validation] Plug-ins to validate profile
plug-in must be implemented
- Manage the internal classes and APi classes.
+ Create the interface for checkers
+ Add usecases files
Change-Id: Iadc7798659355c481a286da289c56ba6aa900a91
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins')
20 files changed, 708 insertions, 89 deletions
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/META-INF/MANIFEST.MF b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/META-INF/MANIFEST.MF index 1b2f2aeb13d..cb5f7cac22e 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/META-INF/MANIFEST.MF +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/META-INF/MANIFEST.MF @@ -7,6 +7,7 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)" Export-Package: org.eclipse.papyrus.toolsmiths.validation.common, + org.eclipse.papyrus.toolsmiths.validation.common.checkers, org.eclipse.papyrus.toolsmiths.validation.common.utils Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/RequirementsValidationCommon.usecases b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/RequirementsValidationCommon.usecases new file mode 100644 index 00000000000..b288b4676ff --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/RequirementsValidationCommon.usecases @@ -0,0 +1,23 @@ +# Requirements defined for the validation of Papyrus plug-ins (for profile, element types, architecture, ...) +# This file must be filled by developer when a task is done in the Common validator + +# General Technical Requirements +Requirement: ReqTechnical_Manage_Easily_Project_CommonValidation_001: The files of a project can be easily accessible +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementService.java + +Requirement: ReqTechnical_Manage_Easily_Markers_CommonValidation_002: The markers should be easy to create and delete for a specific type +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersService.java + +Requirement: ReqTechnical_Manage_Easily_Validation_CommonValidation_003: The concept of validation for a papyrus plug-in should be easy (one called method) +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/PluginValidationService.java + +Requirement: ReqTechnical_Checker_Creation_CommonValidation_004: The concept of checker must be implement to manage easily the validation +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/IPluginChecker.java + +Requirement: ReqTechnical_Validation_Checkers_CommonValidation_005: The validation should manage checkers to manage the validation +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/PluginValidationService.java + +Requirement: ReqTechnical_Validation_Dialog_CommonValidation_006: During the validation, a progress monitor must be opened with correct explanations +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/PluginValidationService.java +- org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/IPluginChecker.java + diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/IPluginChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/IPluginChecker.java new file mode 100644 index 00000000000..0689adb3f83 --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/checkers/IPluginChecker.java @@ -0,0 +1,33 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.common.checkers; + +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * This allows to define the plug-in checker concept for the validation of papyrus plug-ins. + */ +public interface IPluginChecker { + + /** + * This allows to validate. + * + * @param monitor + * The progress monitor. + */ + public void check(final IProgressMonitor monitor); + +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersManagementUtils.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/MarkersManagementUtils.java index 1409400e5b5..49a9f1d75ad 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersManagementUtils.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/MarkersManagementUtils.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.common.utils; +package org.eclipse.papyrus.toolsmiths.validation.common.internal.utils; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.papyrus.toolsmiths.validation.common.Activator; /** - * This allows to manage markers + * This allows to manage markers. */ public class MarkersManagementUtils { diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/PluginValidation.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/PluginValidation.java new file mode 100644 index 00000000000..323dccf65b0 --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/PluginValidation.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.common.internal.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; + +/** + * This allows to validate a papyrus plug-in. + */ +public class PluginValidation { + + /** + * The plug-in checkers to validate a papyrus plug-in. + */ + private List<IPluginChecker> pluginCheckers; + + /** + * Default constructor. + */ + public PluginValidation() { + this.pluginCheckers = new ArrayList<>(); + } + + /** + * Constructor. + * + * @param pluginCheckers + * The plug-in checkers. + */ + public PluginValidation(final List<IPluginChecker> pluginCheckers) { + this.pluginCheckers = new ArrayList<>(pluginCheckers); + } + + /** + * This allows to add a plug-in checker. + * + * @param pluginChecker + * The plug-in checker to add. + */ + public void addPluginChecker(final IPluginChecker pluginChecker) { + this.pluginCheckers.add(pluginChecker); + } + + /** + * This allows to remove a plug-in checker + * + * @param pluginChecker + * The plug-in checker to remove. + * @return Result of the remove : <code>true</code> if done successfully, <code>false</code> otherwise. + */ + public boolean removePluginChecker(final IPluginChecker pluginChecker) { + return this.pluginCheckers.remove(pluginChecker); + } + + /** + * This allows to validate a papyrus plug-in. + * + * @param monitor + * The progress monitor for the action (can be <code>null</code>). + */ + public void validate(final IProgressMonitor monitor) { + this.pluginCheckers.stream().forEach(checker -> checker.check(monitor)); + } +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java index cbd6f27b42e..78bbef97469 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/internal/utils/ProjectManagementUtils.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.common.utils; +package org.eclipse.papyrus.toolsmiths.validation.common.internal.utils; import java.util.Arrays; import java.util.Collection; diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersService.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersService.java new file mode 100644 index 00000000000..7692b97f84c --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/MarkersService.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.common.utils; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IResource; +import org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.MarkersManagementUtils; + +/** + * This allows to provide services about markers. + * In this case, we can provide methods to create and delete markers. + */ +public class MarkersService { + + /** + * This allows to create a marker for a resource. + * + * @param resource + * The resource where create the marker. + * @param type + * The type of the marker validation. + * @param message + * The message of the marker. + * @param severity + * The severity of the marker. + * @return The created marker or <code>null</code> if there is an error. + */ + public static IMarker createMarker(final IResource resource, final String type, final String message, final int severity) { + return MarkersManagementUtils.createMarker(resource, type, message, severity); + } + + /** + * This allows to delete markers of a resource. + * + * @param resource + * The resource. + * @param type + * The type of markers to delete. + */ + public static void deleteMarkers(final IResource resource, final String type) { + MarkersManagementUtils.deleteMarkers(resource, type); + } + +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/PluginValidationService.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/PluginValidationService.java new file mode 100644 index 00000000000..5eeaa7e1f22 --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/PluginValidationService.java @@ -0,0 +1,81 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.common.utils; + +import java.util.List; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.PluginValidation; + +/** + * This allows to validate a papyrus plug-in. + */ +public class PluginValidationService { + + /** + * The plug-in validation to validate a papyrus plug-in. + */ + private PluginValidation pluginValidation; + + /** + * Default constructor. + */ + public PluginValidationService() { + pluginValidation = new PluginValidation(); + } + + /** + * Constructor. + * + * @param pluginCheckers + * The plug-in checkers. + */ + public PluginValidationService(final List<IPluginChecker> pluginCheckers) { + pluginValidation = new PluginValidation(pluginCheckers); + } + + /** + * This allows to add a plug-in checker. + * + * @param pluginChecker + * The plug-in checker to add. + */ + public void addPluginChecker(final IPluginChecker pluginChecker) { + pluginValidation.addPluginChecker(pluginChecker); + } + + /** + * This allows to remove a plug-in checker + * + * @param pluginChecker + * The plug-in checker to remove. + * @return Result of the remove : <code>true</code> if done successfully, <code>false</code> otherwise. + */ + public boolean removePluginChecker(final IPluginChecker pluginChecker) { + return pluginValidation.removePluginChecker(pluginChecker); + } + + /** + * This allows to validate a papyrus plug-in. + * + * @param monitor + * The progress monitor for the action (can be <code>null</code>). + */ + public void validate(final IProgressMonitor monitor) { + pluginValidation.validate(monitor); + } +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementService.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementService.java new file mode 100644 index 00000000000..4e77d4f92a0 --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementService.java @@ -0,0 +1,144 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.common.utils; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.osgi.service.resolver.BundleSpecification; +import org.eclipse.papyrus.toolsmiths.validation.common.internal.utils.ProjectManagementUtils; +import org.eclipse.pde.core.build.IBuildModel; +import org.eclipse.pde.core.plugin.IPluginExtension; +import org.eclipse.pde.core.plugin.IPluginModelBase; + +/** + * This allows to provide services about project and files into project. + * For example, we can found methods to get the dependencies, the extensions, the build but to get IFiles too. + */ +public class ProjectManagementService { + + /** + * This allows to get the plugin model base from the project. + * This allows to manipulate the 'plugin.xml' and 'MANIFEST.MF' files content. + * + * @param project + * The current project. + * @return The {@link IPluginModelBase} representing the plug-in project content. + */ + public static IPluginModelBase getPluginModelBase(final IProject project) { + return ProjectManagementUtils.getPluginModelBase(project); + } + + /** + * This allows to get the list of extensions in the 'plugin.xml' file. + * + * @param project + * The current project. + * @return The list of extensions (can be empty). + */ + public static List<IPluginExtension> getPluginExtensions(final IProject project) { + return ProjectManagementUtils.getPluginExtensions(project); + } + + /** + * This allows to get the list of required plug-ins. + * + * @param project + * The current project. + * @return The list of required plug-ins (can be empty). + */ + public static List<BundleSpecification> getPluginDependencies(final IProject project) { + return ProjectManagementUtils.getPluginDependencies(project); + } + + /** + * This allows to get the build model of the project. + * + * @param project + * The current project. + * @return The build model representing the 'build.properties' file. + */ + public static IBuildModel getPluginBuild(final IProject project) { + return ProjectManagementUtils.getPluginBuild(project); + } + + /** + * This allows to check the file corresponding to the file name in parameter exists. + * + * @param container + * The container resource. + * @param foundFile + * The name of the found file. + * @param isExtensionCheck + * <code>true</code> if the found file is an extension to find, <code>false</code> otherwise. + * @return The corresponding file or <code>null</code>. + */ + public static boolean existFileFromProject(final IContainer container, final String foundFile, final boolean isExtensionCheck) { + return ProjectManagementUtils.existFileFromProject(container, foundFile, isExtensionCheck); + } + + /** + * This allows to get the files corresponding to the file name in parameter. + * + * @param container + * The container resource. + * @param foundFile + * The name of the found file. + * @param isExtensionCheck + * <code>true</code> if the found file is an extension to find, <code>false</code> otherwise. + * @return The corresponding file or <code>null</code>. + */ + public static Collection<IFile> getFilesFromProject(final IContainer container, final String foundFile, final boolean isExtensionCheck) { + return ProjectManagementUtils.getFilesFromProject(container, foundFile, isExtensionCheck); + } + + /** + * This allows to get the 'MANIFEST.MF' file. + * + * @param container + * The container. + * @return The found file 'MANIFEST.MF' or <code>null</code>. + */ + public static IFile getManifestFile(final IContainer container) { + return ProjectManagementUtils.getManifestFile(container); + } + + /** + * This allows to get the 'plugin.xml' file. + * + * @param container + * The container. + * @return The found file 'plugin.xml' or <code>null</code>. + */ + public static IFile getPluginXMLFile(final IContainer container) { + return ProjectManagementUtils.getPluginXMLFile(container); + } + + /** + * This allows to get the 'build.properties' file. + * + * @param container + * The container. + * @return The found file 'build.properties' or <code>null</code>. + */ + public static IFile getBuildFile(final IContainer container) { + return ProjectManagementUtils.getBuildFile(container); + } + +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/META-INF/MANIFEST.MF b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/META-INF/MANIFEST.MF index 87857f49d0c..c6e40be7006 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/META-INF/MANIFEST.MF +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/META-INF/MANIFEST.MF @@ -13,9 +13,7 @@ Require-Bundle: Export-Package: org.eclipse.papyrus.toolsmiths.validation.profile, org.eclipse.papyrus.toolsmiths.validation.profile.checkers, - org.eclipse.papyrus.toolsmiths.validation.profile.constants, - org.eclipse.papyrus.toolsmiths.validation.profile.handlers, - org.eclipse.papyrus.toolsmiths.validation.profile.testers + org.eclipse.papyrus.toolsmiths.validation.profile.constants Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-ClassPath: . diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/RequirementsProfileValidation.usecases b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/RequirementsProfileValidation.usecases new file mode 100644 index 00000000000..5a5d012f6ab --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/RequirementsProfileValidation.usecases @@ -0,0 +1,28 @@ +# Requirements defined for the validation of Papyrus profile plug-in +# This file must be filled by developer when a task is done in the validation of a profile plug-in + +# General Requirements +Requirement: Req_Validate_Menu_ProfileValidation_001: The profile validation must be done with a button 'Validate Profile plug-in' on plug-in, in the papyrus developer menu +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/handlers/ValidateProfilePluginHandler.java +- org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/testers/ValidateProfilePluginTester.java +- org.eclipse.papyrus.toolsmiths.validation.profile/plugin.xml + +Requirement: Req_Validation_Dialog_ProfileValidation_002: During the validation, a progress monitor must be opened with correct explanations +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/handlers/ValidateProfilePluginHandler.java + +# General Technical Requirements +Requirement: ReqTechnical_Extensions_Checker_ProfileValidation_001: A checker for the extensions must be implemented +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileExtensionsChecker.java + +Requirement: ReqTechnical_Definition_Profile_Checker_ProfileValidation_002: A checker for the definition profile must be implemented +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDefinitionChecker.java + +Requirement: ReqTechnical_Build_Checker_ProfileValidation_003: A checker for the build must be implemented +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileBuildChecker.java + +Requirement: ReqTechnical_Dependencies_Checker_ProfileValidation_004: A checker for the dependencies must be implemented +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDependenciesChecker.java + +Requirement: ReqTechnical_Profile_Plugin_Checker_ProfileValidation_005: A method to call the profile plug-in validation must be available +Code instruction: - org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginCheckerService.java +- org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfilePluginChecker.java diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/plugin.xml b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/plugin.xml index a997cd9a764..29300bcc47a 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/plugin.xml +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/plugin.xml @@ -46,7 +46,7 @@ <extension point="org.eclipse.ui.commands"> <command - defaultHandler="org.eclipse.papyrus.toolsmiths.validation.profile.handlers.ValidateProfilePluginHandler" + defaultHandler="org.eclipse.papyrus.toolsmiths.validation.profile.internal.handlers.ValidateProfilePluginHandler" id="org.eclipse.papyrus.toolsmiths.validation.profile.validateCommand" name="Validate Profile plug-in"> </command> @@ -54,7 +54,7 @@ <extension point="org.eclipse.core.expressions.propertyTesters"> <propertyTester - class="org.eclipse.papyrus.toolsmiths.validation.profile.testers.ValidateProfilePluginTester" + class="org.eclipse.papyrus.toolsmiths.validation.profile.internal.testers.ValidateProfilePluginTester" id="org.eclipse.papyrus.toolsmiths.validation.profile.canValidateProfilePlugin" namespace="org.eclipse.papyrus.toolsmiths.validation.profile" properties="canValidateProfilePlugin" diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginCheckerService.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginCheckerService.java new file mode 100644 index 00000000000..4135d75c45a --- /dev/null +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginCheckerService.java @@ -0,0 +1,35 @@ +/***************************************************************************** + * Copyright (c) 2019 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; + +import org.eclipse.core.resources.IProject; + +/** + * This allows to check a profile plug-in (extensions, builds, dependencies). + */ +public class ProfilePluginCheckerService { + + /** + * This allows to check the profile plug-in. + * + * @param project + * The current project to check. + */ + public static void checkProfilePlugin(final IProject project) { + ProfilePluginCheckerService.checkProfilePlugin(project); + } + +} diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileBuildChecker.java index b4d75717131..133935fdf56 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileBuildChecker.java @@ -13,13 +13,15 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersService; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementService; import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants; import org.eclipse.pde.core.build.IBuild; import org.eclipse.pde.core.build.IBuildEntry; @@ -28,20 +30,47 @@ import org.eclipse.pde.core.build.IBuildModel; /** * This class allows to check the 'build.properties' needed for the profile file. */ -public class ProfileBuildChecker { +public class ProfileBuildChecker implements IPluginChecker { /** - * This allows to check the build of the profile file. + * The current project resource. + */ + private final IProject project; + + /** + * The file of the UML profile. + */ + private final IFile profileFile; + + /** + * Constructor. * * @param project - * The current project to check. + * The current project resource. * @param profileFile - * The profile for which one to check. + * The file of the UML profile. + */ + public ProfileBuildChecker(final IProject project, final IFile profileFile) { + this.project = project; + this.profileFile = profileFile; + } + + + /** + * This allows to check the build of the profile file. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker#check(org.eclipse.core.runtime.IProgressMonitor) */ - public static void checkBuildFile(final IProject project, final IFile profileFile) { + @Override + public void check(final IProgressMonitor monitor) { + + if (null != monitor) { + monitor.subTask("Validate 'build.properties' file for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ + } // Get the build.properties entries from the project - final IBuildModel buildModel = ProjectManagementUtils.getPluginBuild(project); + final IBuildModel buildModel = ProjectManagementService.getPluginBuild(project); if (null != buildModel) { // Create the conditions: @@ -62,15 +91,19 @@ public class ProfileBuildChecker { // Create marker for UMLProfile extension point if needed if (!containsProfile) { - final IFile buildPropertiesFile = ProjectManagementUtils.getBuildFile(project); + final IFile buildPropertiesFile = ProjectManagementService.getBuildFile(project); - MarkersManagementUtils.createMarker( + MarkersService.createMarker( buildPropertiesFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "The build does not contains entry for file '" + profilePath + "'", //$NON-NLS-1$ //$NON-NLS-2$ IMarker.SEVERITY_ERROR); } } + + if (null != monitor) { + monitor.worked(1); + } } } diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileDefinitionChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDefinitionChecker.java index e42962a44a3..ee5c6a29265 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileDefinitionChecker.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDefinitionChecker.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers; import java.util.Collection; import java.util.HashSet; @@ -21,11 +21,12 @@ import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersService; import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants; import org.eclipse.papyrus.uml.tools.profile.definition.IPapyrusVersionConstants; import org.eclipse.papyrus.uml.tools.profile.definition.PapyrusDefinitionAnnotation; @@ -35,19 +36,43 @@ import org.eclipse.uml2.uml.util.UMLUtil; /** * This class allows to check profiles don't have any definition (because it's not working with static profile). */ -public class ProfileDefinitionChecker { +public class ProfileDefinitionChecker implements IPluginChecker { /** - * This allows to check that profiles does not have any definition. + * The file of the UML profile. + */ + private final IFile profileFile; + + /** + * The existing profiles in the UML file. + */ + private final Collection<Profile> existingProfiles; + + /** + * Constructor. * - * @param project - * The current project to check. * @param profileFile - * The profile for which one to check. + * The file of the UML profile. * @param existingProfiles * The existing profiles in the UML file. */ - public static void checkProfilesDefinition(final IProject project, final IFile profileFile, final Collection<Profile> existingProfiles) { + public ProfileDefinitionChecker(final IFile profileFile, final Collection<Profile> existingProfiles) { + this.profileFile = profileFile; + this.existingProfiles = existingProfiles; + } + + /** + * This allows to check that profiles does not have any definition. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker#check(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void check(final IProgressMonitor monitor) { + + if (null != monitor) { + monitor.subTask("Validate profiles definitions for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ + } // Create the conditions: // - Copy of existing profiles (that will be removed if there are found in uml generated package extension points) @@ -65,13 +90,17 @@ public class ProfileDefinitionChecker { // Create markers (one by missing profile) for uml generated package extension point if needed if (!profiles.isEmpty()) { for (final Profile profile : profiles) { - MarkersManagementUtils.createMarker( + MarkersService.createMarker( profileFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "The profile '" + profile.getName() + "' contain a definition but should not", //$NON-NLS-1$ //$NON-NLS-2$ IMarker.SEVERITY_ERROR); } } + + if (null != monitor) { + monitor.worked(1); + } } /** @@ -81,7 +110,7 @@ public class ProfileDefinitionChecker { * The profile to check. * @return <code>true</code> if a definition for the profile is found, <code>false</code> otherwise. */ - private static boolean hasProfileDefinition(final Profile profile) { + private boolean hasProfileDefinition(final Profile profile) { boolean result = false; final EAnnotation umlAnnotation = profile.getEAnnotation(UMLUtil.UML2_UML_PACKAGE_2_0_NS_URI); diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileDependenciesChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDependenciesChecker.java index f94de65ca8b..7316970190a 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileDependenciesChecker.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileDependenciesChecker.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers; import java.util.Collection; import java.util.HashSet; @@ -22,18 +22,20 @@ import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.impl.URIMappingRegistryImpl; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersService; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementService; import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants; /** * This class allows to check that the plug-in has the correct dependencies depending to the external profile references. */ -public class ProfileDependenciesChecker { +public class ProfileDependenciesChecker implements IPluginChecker { /** * The plug-ins to detect as warning instead of errors. @@ -46,17 +48,50 @@ public class ProfileDependenciesChecker { } }; + /** - * This allows to check that the plug-in has the correct dependencies depending to the external profile references. + * The current project resource. + */ + private final IProject project; + + /** + * The file of the UML profile. + */ + private final IFile profileFile; + + /** + * The EMF resource. + */ + private final Resource resource; + + /** + * Constructor. * * @param project - * The current project to check. + * The current project resource. * @param profileFile - * The file or the UML profile. + * The file of the UML profile. * @param resource * The EMF resource. */ - public static void checkDependencies(final IProject project, final IFile profileFile, final Resource resource) { + public ProfileDependenciesChecker(final IProject project, final IFile profileFile, final Resource resource) { + this.project = project; + this.profileFile = profileFile; + this.resource = resource; + } + + /** + * This allows to check that the plug-in has the correct dependencies depending to the external profile references. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker#check(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void check(final IProgressMonitor monitor) { + + if (null != monitor) { + monitor.subTask("Validate dependencies for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ + } // Get the external reference paths final Collection<URI> externalReferencesPaths = getExternalReferencesPaths(project, profileFile, resource); @@ -67,25 +102,29 @@ public class ProfileDependenciesChecker { // For each external reference, get its plug-in name and search its dependency in the plug-in final Collection<String> existingRequiredPlugins = new HashSet<>(); - ProjectManagementUtils.getPluginDependencies(project).stream().forEach(dependency -> existingRequiredPlugins.add(dependency.getName())); + ProjectManagementService.getPluginDependencies(project).stream().forEach(dependency -> existingRequiredPlugins.add(dependency.getName())); requiredPlugins.removeIf(requiredPlugin -> existingRequiredPlugins.contains(requiredPlugin)); // If requiredPlugins is not empty, that means, the dependency is not available in the profile plug-in // So, create the warning markers if (!requiredPlugins.isEmpty()) { - final IFile manifestFile = ProjectManagementUtils.getManifestFile(project); + final IFile manifestFile = ProjectManagementService.getManifestFile(project); requiredPlugins.stream().forEach(requiredPlugin -> { int severity = IMarker.SEVERITY_ERROR; if (WARNING_PLUGINS_EXCEPTION.contains(requiredPlugin)) { severity = IMarker.SEVERITY_WARNING; } - MarkersManagementUtils.createMarker(manifestFile, + MarkersService.createMarker(manifestFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "The plug-in '" + requiredPlugin + "' must be defined as required plug-in (for profile '" + profileFile.getName() + "').", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ severity); }); } + + if (null != monitor) { + monitor.worked(1); + } } /** @@ -99,7 +138,7 @@ public class ProfileDependenciesChecker { * The resource to get external references paths. * @return The external references paths. */ - public static Collection<URI> getExternalReferencesPaths(final IProject project, final IFile profileFile, final Resource resource) { + private Collection<URI> getExternalReferencesPaths(final IProject project, final IFile profileFile, final Resource resource) { final Collection<URI> externalReferencesPaths = new HashSet<>(); // First step, resolve all references @@ -116,7 +155,7 @@ public class ProfileDependenciesChecker { final URI correspondingURI = getCorrespondingURIFromPathmap(resourceURI); if (null == correspondingURI) { // If this case, the pathmap cannot be resolved, so create a marker - MarkersManagementUtils.createMarker(profileFile, + MarkersService.createMarker(profileFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "The pathmap '" + resourceURI.toString() + "' cannot be resolved.", //$NON-NLS-1$ //$NON-NLS-2$ IMarker.SEVERITY_ERROR); @@ -143,7 +182,7 @@ public class ProfileDependenciesChecker { * The resource to check. * @return <code>true</code> if we have to manage reference, <code>false</code> otherwise. */ - private static boolean isExternalReferenceToManage(final IProject project, final Resource resource) { + private boolean isExternalReferenceToManage(final IProject project, final Resource resource) { final String resourceURI = resource.getURI().toString(); // We don't have to manage references of files from the same plug-in @@ -163,7 +202,7 @@ public class ProfileDependenciesChecker { * The pathmap URI to search. * @return The corresponding URI to the pathmap. */ - private static URI getCorrespondingURIFromPathmap(final URI uri) { + private URI getCorrespondingURIFromPathmap(final URI uri) { URI copiedURI = URI.createURI(uri.toString()); URI foundCorrespondingURI = null; @@ -187,7 +226,7 @@ public class ProfileDependenciesChecker { * The initial URI. * @return The plug-in name from URI or <code>null</code> if any problem occurred. */ - private static String getPluginNameFromURI(final URI uri) { + private String getPluginNameFromURI(final URI uri) { String pluginName = null; // Take we correct segment (without authority) diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileExtensionsChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileExtensionsChecker.java index 3ba7026d3ed..9cf424f004a 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileExtensionsChecker.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfileExtensionsChecker.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers; import java.util.Collection; import java.util.HashSet; @@ -22,9 +22,11 @@ import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.ecore.xmi.XMIResource; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils; +import org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersService; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementService; import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants; import org.eclipse.pde.core.plugin.IPluginAttribute; import org.eclipse.pde.core.plugin.IPluginElement; @@ -35,19 +37,51 @@ import org.eclipse.uml2.uml.Profile; /** * This class allows to check the extensions of the 'plugin.xml' needed for the profiles. */ -public class ProfileExtensionsChecker { +public class ProfileExtensionsChecker implements IPluginChecker { /** - * This allows to check the extensions of the profile. + * The current project resource. + */ + private final IProject project; + + /** + * The file of the UML profile. + */ + private final IFile profileFile; + + /** + * The existing profiles in the UML file. + */ + private final Collection<Profile> existingProfiles; + + /** + * Constructor. * * @param project * The current project to check. * @param profileFile - * The profile for which one to check. + * The file of the UML profile. * @param existingProfiles - * The existing profiles in the file. + * The existing profiles in the UML file. */ - public static void checkPluginXMLFile(final IProject project, final IFile profileFile, final Collection<Profile> existingProfiles) { + public ProfileExtensionsChecker(final IProject project, final IFile profileFile, final Collection<Profile> existingProfiles) { + this.project = project; + this.profileFile = profileFile; + this.existingProfiles = existingProfiles; + } + + /** + * This allows to check the extensions of the profile. + * {@inheritDoc} + * + * @see org.eclipse.papyrus.toolsmiths.validation.common.checkers.IPluginChecker#check(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void check(final IProgressMonitor monitor) { + + if (null != monitor) { + monitor.subTask("Validate 'plugin.xml' file for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ + } // Create the conditions: // - Copy of existing profiles (that will be removed if there are found in uml generated package extension points) @@ -56,7 +90,7 @@ public class ProfileExtensionsChecker { boolean foundExtensionUMLProfile = false; // Get all the extensions of the plug-in to check - final Iterator<IPluginExtension> extensions = ProjectManagementUtils.getPluginExtensions(project).iterator(); + final Iterator<IPluginExtension> extensions = ProjectManagementService.getPluginExtensions(project).iterator(); while (extensions.hasNext()) { final IPluginExtension extension = extensions.next(); // Check if the UML profile extension point is managed (warning because this one can be managed outside of this plug-in) @@ -101,11 +135,11 @@ public class ProfileExtensionsChecker { // If there is a problem, get the plugin.xml file to mark the correct file for problems if (!foundExtensionUMLProfile || !profiles.isEmpty()) { - final IFile pluginXMLFile = ProjectManagementUtils.getPluginXMLFile(project); + final IFile pluginXMLFile = ProjectManagementService.getPluginXMLFile(project); // Create marker for UMLProfile extension point if needed if (!foundExtensionUMLProfile) { - MarkersManagementUtils.createMarker( + MarkersService.createMarker( pluginXMLFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "The extension point '" + ProfilePluginValidationConstants.UMLPROFILE_EXTENSION_POINT + "' should be created for profile '" + profileFile.getName() + "'", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -114,7 +148,7 @@ public class ProfileExtensionsChecker { // Create markers (one by missing profile) for uml generated package extension point if needed if (!profiles.isEmpty()) { for (final Profile profile : profiles) { - MarkersManagementUtils.createMarker( + MarkersService.createMarker( pluginXMLFile, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE, "There is no extension point '" + ProfilePluginValidationConstants.UML_GENERATED_PACKAGE_EXTENSION_POINT + "' for profile '" + profile.getName() + "'.", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -122,6 +156,10 @@ public class ProfileExtensionsChecker { } } } + + if (null != monitor) { + monitor.worked(1); + } } } diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfilePluginChecker.java index f32a2f51c3a..ae6a22faeee 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/checkers/ProfilePluginChecker.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.checkers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers; import java.lang.reflect.InvocationTargetException; import java.util.Collection; @@ -28,8 +28,9 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersService; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.PluginValidationService; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementService; import org.eclipse.papyrus.toolsmiths.validation.profile.Activator; import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants; import org.eclipse.swt.widgets.Display; @@ -55,14 +56,17 @@ public class ProfilePluginChecker { try { // Open the progress monitor dialog new ProgressMonitorDialog(shell).run(true, true, monitor -> { - final Collection<IFile> profileFiles = ProjectManagementUtils.getFilesFromProject(project, "profile.uml", true); //$NON-NLS-1$ + final Collection<IFile> profileFiles = ProjectManagementService.getFilesFromProject(project, "profile.uml", true); //$NON-NLS-1$ monitor.beginTask("Validate Profile plug-in.", 1 + (profileFiles.size() * 4)); // $NON-NLS-1$ monitor.subTask("Prepare validation."); //$NON-NLS-1$ // First of all, delete the existing markers for project - MarkersManagementUtils.deleteMarkers(project, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE); + MarkersService.deleteMarkers(project, ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE); monitor.worked(1); + // Create the plug-in validation service + final PluginValidationService pluginValidationService = new PluginValidationService(); + // For all profiles files in the plug-in for (final IFile profileFile : profileFiles) { @@ -71,29 +75,24 @@ public class ProfilePluginChecker { final Collection<Profile> profiles = loadProfiles(profileFileURI); if (!profiles.isEmpty()) { - monitor.subTask("Validate 'plugin.xml' file for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ - // First, check the extensions - ProfileExtensionsChecker.checkPluginXMLFile(project, profileFile, profiles); - monitor.worked(1); - - monitor.subTask("Validate profiles definitions for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ - // Check the profile definition (no definition must be done for static profiles) - ProfileDefinitionChecker.checkProfilesDefinition(project, profileFile, profiles); - monitor.worked(1); - - monitor.subTask("Validate dependencies for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ - // Check the dependencies depending to the external profile references - ProfileDependenciesChecker.checkDependencies(project, profileFile, profiles.iterator().next().eResource()); - monitor.worked(1); - } else { - monitor.worked(3); + // First, create the extensions checker + pluginValidationService.addPluginChecker(new ProfileExtensionsChecker(project, profileFile, profiles)); + + // Create the profile definition checker (no definition must be done for static profiles) + pluginValidationService.addPluginChecker(new ProfileDefinitionChecker(profileFile, profiles)); + + // Create the dependencies checker (depending to the external profile references) + pluginValidationService.addPluginChecker(new ProfileDependenciesChecker(project, profileFile, profiles.iterator().next().eResource())); } - monitor.subTask("Validate 'build.properties' file for profile '" + profileFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ - // Check the build for file - ProfileBuildChecker.checkBuildFile(project, profileFile); - monitor.worked(1); + // Create the build checker + pluginValidationService.addPluginChecker(new ProfileBuildChecker(project, profileFile)); } + + monitor.worked(1); + + // Call the validate + pluginValidationService.validate(monitor); }); } catch (InvocationTargetException e) { Activator.log.error(e); diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/handlers/ValidateProfilePluginHandler.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/handlers/ValidateProfilePluginHandler.java index 3a4e7bff878..a3c38e574ed 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/handlers/ValidateProfilePluginHandler.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/handlers/ValidateProfilePluginHandler.java @@ -13,7 +13,7 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.handlers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.handlers; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; @@ -21,7 +21,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.papyrus.toolsmiths.validation.profile.checkers.ProfilePluginChecker; +import org.eclipse.papyrus.toolsmiths.validation.profile.internal.checkers.ProfilePluginChecker; import org.eclipse.ui.handlers.HandlerUtil; /** diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/testers/ValidateProfilePluginTester.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/testers/ValidateProfilePluginTester.java index 1eea72dca68..1834c5dea9f 100644 --- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/testers/ValidateProfilePluginTester.java +++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/internal/testers/ValidateProfilePluginTester.java @@ -13,11 +13,11 @@ * *****************************************************************************/ -package org.eclipse.papyrus.toolsmiths.validation.profile.testers; +package org.eclipse.papyrus.toolsmiths.validation.profile.internal.testers; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.core.resources.IProject; -import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils; +import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementService; /** * This allows to test if a selected plug-in contains papyrus profile and its genmodel. @@ -36,8 +36,8 @@ public class ValidateProfilePluginTester extends PropertyTester { if (receiver instanceof IProject) { final IProject selectedProject = (IProject) receiver; - result = ProjectManagementUtils.existFileFromProject(selectedProject, "profile.uml", true) //$NON-NLS-1$ - && ProjectManagementUtils.existFileFromProject(selectedProject, "genmodel", true); //$NON-NLS-1$ + result = ProjectManagementService.existFileFromProject(selectedProject, "profile.uml", true) //$NON-NLS-1$ + && ProjectManagementService.existFileFromProject(selectedProject, "genmodel", true); //$NON-NLS-1$ } return expectedValue instanceof Boolean ? ((Boolean) expectedValue).booleanValue() == result : result; } |