Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-04-15 08:26:07 -0400
committerPatrick Tessier2019-04-16 04:37:30 -0400
commitd413be84de3925644f8782db7da308209e0c2d5c (patch)
tree29b9143dac1df4ff4684b4cbe2b38610a62aebc5 /plugins/toolsmiths
parent007d48b9362ba0f7f6dd9e032b2a58ddea4af478 (diff)
downloadorg.eclipse.papyrus-d413be84de3925644f8782db7da308209e0c2d5c.tar.gz
org.eclipse.papyrus-d413be84de3925644f8782db7da308209e0c2d5c.tar.xz
org.eclipse.papyrus-d413be84de3925644f8782db7da308209e0c2d5c.zip
Bug 546406: [Toolsmiths][Validation] Plug-ins to validate element types
plug-in must be implemented - Validate the extension point Change-Id: Ied35f66c3377b19f5d80f7f10a64dda93f6c61c1 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/toolsmiths')
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/constants/ElementTypesPluginValidationConstants.java4
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesExtensionsChecker.java114
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginChecker.java2
3 files changed, 120 insertions, 0 deletions
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/constants/ElementTypesPluginValidationConstants.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/constants/ElementTypesPluginValidationConstants.java
index 4c567884f6c..6513293a7ed 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/constants/ElementTypesPluginValidationConstants.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/constants/ElementTypesPluginValidationConstants.java
@@ -25,4 +25,8 @@ public class ElementTypesPluginValidationConstants {
*/
public static final String ELEMENTTYPES_PLUGIN_VALIDATION_TYPE = "org.eclipse.papyrus.toolsmiths.validation.elementtypes.diagnostic"; //$NON-NLS-1$
+ /**
+ * The extension point identifier for element types configurations files.
+ */
+ public static final String ELEMENTTYPES_EXTENSION_POINT_IDENTIFIER = "org.eclipse.papyrus.infra.types.core.elementTypeSetConfiguration"; //$NON-NLS-1$
}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesExtensionsChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesExtensionsChecker.java
new file mode 100644
index 00000000000..b326edf506d
--- /dev/null
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesExtensionsChecker.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * 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.elementtypes.internal.checkers;
+
+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.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.elementtypes.constants.ElementTypesPluginValidationConstants;
+import org.eclipse.pde.core.plugin.IPluginAttribute;
+import org.eclipse.pde.core.plugin.IPluginElement;
+import org.eclipse.pde.core.plugin.IPluginExtension;
+import org.eclipse.pde.core.plugin.IPluginObject;
+
+/**
+ * This class allows to check the extensions of the 'plugin.xml' needed for the element types file.
+ */
+public class ElementTypesExtensionsChecker implements IPluginChecker {
+
+ /**
+ * The current project resource.
+ */
+ private final IProject project;
+
+ /**
+ * The file defining the element types.
+ */
+ private final IFile elementTypesFile;
+
+ /**
+ * Constructor.
+ *
+ * @param project
+ * The current project to check.
+ * @param elementTypesFile
+ * The file defining the element types.
+ */
+ public ElementTypesExtensionsChecker(final IProject project, final IFile elementTypesFile) {
+ this.project = project;
+ this.elementTypesFile = elementTypesFile;
+ }
+
+ /**
+ * This allows to check the extensions of the element types file.
+ * {@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 '" + elementTypesFile.getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Create the conditions:
+ // - Boolean to check if the extension point of element types configuration file exists
+ boolean foundExtension = false;
+
+ // Get all the extensions of the plug-in to check
+ final Iterator<IPluginExtension> extensions = ProjectManagementService.getPluginExtensions(project).iterator();
+ while (extensions.hasNext() && !foundExtension) {
+ final IPluginExtension extension = extensions.next();
+ // Check if the extension point of element types configurations file is available
+ if (ElementTypesPluginValidationConstants.ELEMENTTYPES_EXTENSION_POINT_IDENTIFIER.equals(extension.getPoint())) {
+ for (final IPluginObject pluginObject : extension.getChildren()) {
+ if (pluginObject instanceof IPluginElement && "elementTypeSet".equals(pluginObject.getName())) { //$NON-NLS-1$
+ for (final IPluginAttribute pluginAtttribute : ((IPluginElement) pluginObject).getAttributes()) {
+ if ("path".equals(pluginAtttribute.getName())) { //$NON-NLS-1$
+ final String locationValue = pluginAtttribute.getValue();
+ foundExtension = locationValue.endsWith(elementTypesFile.getName());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // If there is a problem, get the plugin.xml file to mark the correct file for problems
+ if (!foundExtension) {
+ final IFile pluginXMLFile = ProjectManagementService.getPluginXMLFile(project);
+
+ // Create marker for extension point if needed
+ MarkersService.createMarker(
+ pluginXMLFile,
+ ElementTypesPluginValidationConstants.ELEMENTTYPES_PLUGIN_VALIDATION_TYPE,
+ "The extension point '" + ElementTypesPluginValidationConstants.ELEMENTTYPES_EXTENSION_POINT_IDENTIFIER + "' should be created for profile '" + elementTypesFile.getName() + "'", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ IMarker.SEVERITY_ERROR);
+ }
+
+ if (null != monitor) {
+ monitor.worked(1);
+ }
+ }
+
+}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginChecker.java
index b932622bd12..ac515690563 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginChecker.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.elementtypes/src/org/eclipse/papyrus/toolsmiths/validation/elementtypes/internal/checkers/ElementTypesPluginChecker.java
@@ -64,6 +64,8 @@ public class ElementTypesPluginChecker {
// First, check the validation of the element types file
pluginValidationService.addPluginChecker(new ElementTypesFileChecker(elementTypesFile));
+ // Check the extension point
+ pluginValidationService.addPluginChecker(new ElementTypesExtensionsChecker(project, elementTypesFile));
}
monitor.worked(1);

Back to the top