diff options
author | eneufeld | 2013-08-29 10:55:18 +0000 |
---|---|---|
committer | eneufeld | 2013-08-29 10:55:18 +0000 |
commit | cda1e2186a61f428c839d799daf342614ef9aa44 (patch) | |
tree | 654f0655385c9a7e2b0400b73fdbb7382af044fa /bundles | |
parent | bfd96406a98d9f7b8f93add11bc4630bb46b1851 (diff) | |
download | org.eclipse.emf.ecp.core-cda1e2186a61f428c839d799daf342614ef9aa44.tar.gz org.eclipse.emf.ecp.core-cda1e2186a61f428c839d799daf342614ef9aa44.tar.xz org.eclipse.emf.ecp.core-cda1e2186a61f428c839d799daf342614ef9aa44.zip |
Bug 415318 - [View Model] added validation service to build, added feature
Diffstat (limited to 'bundles')
7 files changed, 34 insertions, 263 deletions
diff --git a/bundles/org.eclipse.emf.ecp.view.validation/plugin.xml b/bundles/org.eclipse.emf.ecp.view.validation/plugin.xml index a78ccc9b63..4c0172190a 100644 --- a/bundles/org.eclipse.emf.ecp.view.validation/plugin.xml +++ b/bundles/org.eclipse.emf.ecp.view.validation/plugin.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> - <extension-point id="org.eclipse.emf.ecp.view.validation.propagator" name="Validation Propagator" schema="schema/org.eclipse.emf.ecp.view.validation.propagator.exsd"/> <extension-point id="validationSubProcessor" name="Validation Sub Processor" schema="schema/validationSubProcessor.exsd"/> <extension point="org.eclipse.emf.ecp.view.context.viewServices"> diff --git a/bundles/org.eclipse.emf.ecp.view.validation/pom.xml b/bundles/org.eclipse.emf.ecp.view.validation/pom.xml new file mode 100644 index 0000000000..f5c0840970 --- /dev/null +++ b/bundles/org.eclipse.emf.ecp.view.validation/pom.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.emf.ecp</groupId>
+ <artifactId>ecp-parent</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <relativePath>../../releng/org.eclipse.emf.ecp.releng/</relativePath>
+ </parent>
+
+ <groupId>org.eclipse.emf.ecp</groupId>
+ <artifactId>org.eclipse.emf.ecp.view.validation</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
diff --git a/bundles/org.eclipse.emf.ecp.view.validation/schema/org.eclipse.emf.ecp.view.validation.propagator.exsd b/bundles/org.eclipse.emf.ecp.view.validation/schema/org.eclipse.emf.ecp.view.validation.propagator.exsd deleted file mode 100644 index 907f16caaa..0000000000 --- a/bundles/org.eclipse.emf.ecp.view.validation/schema/org.eclipse.emf.ecp.view.validation.propagator.exsd +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.emf.ecp.view.validation" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.emf.ecp.view.validation" id="org.eclipse.emf.ecp.view.validation.propagator" name="Validation Propagator"/>
- </appinfo>
- <documentation>
- This extension point allows to change the way validation results from controls are propagated to its parent.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence minOccurs="1" maxOccurs="unbounded">
- <element ref="propagator"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="propagator">
- <complexType>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecp.view.validation.ECPValidationPropagator"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 1.1
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.<br/>
-
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/DefaultValidationPropagator.java b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/DefaultValidationPropagator.java deleted file mode 100644 index 3ff8466e9f..0000000000 --- a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/DefaultValidationPropagator.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Johannes Faltermeier - initial API and implementation - ******************************************************************************/ -package org.eclipse.emf.ecp.view.validation; - -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.emf.common.util.Diagnostic; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecp.view.model.AbstractControl; -import org.eclipse.emf.ecp.view.model.Renderable; -import org.eclipse.emf.ecp.view.model.VDiagnostic; -import org.eclipse.emf.ecp.view.model.ViewFactory; - -/** - * Default propagator for the view validation service. - * - * @author jfaltermeier - * - */ -public class DefaultValidationPropagator implements ECPValidationPropagator { - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecp.view.validation.ECPValidationPropagator#canHandle(org.eclipse.emf.ecp.view.model.Renderable) - */ - public int canHandle(Renderable renderable) { - return !(renderable instanceof AbstractControl) ? 1 : 0; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.emf.ecp.view.validation.ECPValidationPropagator#propagate(org.eclipse.emf.ecp.view.model.Renderable) - */ - public void propagate(Renderable renderable) { - final VDiagnostic vDiagnostic = ViewFactory.eINSTANCE.createVDiagnostic(); - if (isRelevantForPropagation(renderable)) { - final Set<Object> childDiagnostics = new HashSet<Object>(); - for (final EObject o : renderable.eContents()) { - if (o instanceof Renderable) { - final Renderable childRenderable = (Renderable) o; - childDiagnostics.addAll(childRenderable.getDiagnostic().getDiagnostics()); - } - } - - if (childDiagnostics.isEmpty()) { - childDiagnostics.add(Diagnostic.OK_INSTANCE); - } - - vDiagnostic.getDiagnostics().addAll(childDiagnostics); - - } else { - vDiagnostic.getDiagnostics().add(Diagnostic.OK_INSTANCE); - - } - if (!VDiagnosticHelper.isEqual(renderable.getDiagnostic(), vDiagnostic)) { - renderable.setDiagnostic(vDiagnostic); - } - } - - /** - * Check whether the validation result of given {@link Renderable} is relevant. - * - * @param renderable the Renderable to check - * @return <code>true</code> if renderable is enabled, visible and not read only, <code>false</code> otherwise - */ - private boolean isRelevantForPropagation(Renderable renderable) { - return true; - } - -} diff --git a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ECPValidationPropagator.java b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ECPValidationPropagator.java deleted file mode 100644 index 89608a7d8b..0000000000 --- a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ECPValidationPropagator.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Johannes Faltermeier - initial API and implementation - ******************************************************************************/ -package org.eclipse.emf.ecp.view.validation; - -import org.eclipse.emf.ecp.view.model.Renderable; - -/** - * This interface is used to compute and propagate validation results in the view model. - * - * @author jfaltermeier - * - */ -public interface ECPValidationPropagator { - - /** - * Checks whether this propagator can handle the propagation for the type of the given Renderable. - * - * @param renderable the Renderable for which the validation result is to be computed - * @return <code>true</code> if this class can handle the propagation, <code>false</code> if the default propagation - * should be used. - */ - int canHandle(Renderable renderable); - - /** - * Computes the validation result for the given {@link Renderable} from its child results. - * - * @param renderable the Renderable for which the validation result is to be computed - */ - void propagate(Renderable renderable); -} diff --git a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/VDiagnosticHelper.java b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/VDiagnosticHelper.java index b41ddf82bd..e0cef9f95f 100644 --- a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/VDiagnosticHelper.java +++ b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/VDiagnosticHelper.java @@ -14,11 +14,24 @@ package org.eclipse.emf.ecp.view.validation; import org.eclipse.emf.ecp.view.model.VDiagnostic; /** + * This class compares to {@link VDiagnostic} elements for equality. + * * @author Eugen Neufeld * */ -public class VDiagnosticHelper { +public final class VDiagnosticHelper { + + private VDiagnosticHelper() { + + } + /** + * Compares two {@link VDiagnostic VDiagnostics} with each other. + * + * @param vDiagnostic1 the first {@link VDiagnostic} to compare + * @param vDiagnostic2 the second {@link VDiagnostic} to compare + * @return true if both {@link VDiagnostic VDiagnostics} are equal + */ public static boolean isEqual(VDiagnostic vDiagnostic1, VDiagnostic vDiagnostic2) { if (vDiagnostic1 == null && vDiagnostic2 != null) { return false; diff --git a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ViewValidationCachedTree.java b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ViewValidationCachedTree.java index 955583afac..c7411182e7 100644 --- a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ViewValidationCachedTree.java +++ b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/validation/ViewValidationCachedTree.java @@ -12,14 +12,9 @@ package org.eclipse.emf.ecp.view.validation; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Set; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.ecore.EObject; @@ -44,7 +39,6 @@ import org.eclipse.emf.ecp.view.model.ViewFactory; public class ViewValidationCachedTree extends AbstractCachedTree<VDiagnostic> { private final ValidationRegistry validationRegistry; - private final Set<ECPValidationPropagator> propagators; /** * Default constructor. @@ -55,26 +49,8 @@ public class ViewValidationCachedTree extends AbstractCachedTree<VDiagnostic> { public ViewValidationCachedTree(IExcludedObjectsCallback callback, ValidationRegistry validationRegistry) { super(callback); this.validationRegistry = validationRegistry; - propagators = new HashSet<ECPValidationPropagator>(); - readPropagators(); - } - private void readPropagators() { - final IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( - "org.eclipse.emf.ecp.view.validation.propagator"); - for (final IConfigurationElement e : config) { - try { - final Object o = - e.createExecutableExtension("class"); - if (o instanceof ECPValidationPropagator) { - propagators.add((ECPValidationPropagator) o); - } - } catch (final CoreException ex) { - Activator.logException(ex); - continue; - } - } - propagators.add(new DefaultValidationPropagator()); + // readPropagators(); } /** |