-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support validation and UI for DBStore annotations in the Ecore editor #…
- Loading branch information
Showing
15 changed files
with
222 additions
and
13 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
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="dbstore" nsURI="http://www.eclipse.org/CDO/DBStore" nsPrefix="dbstore"> | ||
<eClassifiers xsi:type="ecore:EClass" name="Feature"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="columnName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="columnType" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="columnLength" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="typeMapping" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="FeatureMany" eSuperTypes="#//Feature"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Class"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableNamePrefix" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableMapping" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
<eClassifiers xsi:type="ecore:EClass" name="Package"> | ||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="tableNamePrefix" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> | ||
</eClassifiers> | ||
</ecore:EPackage> |
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
51 changes: 51 additions & 0 deletions
51
...rg.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/MigratorPlugin.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,51 @@ | ||
/* | ||
* Copyright (c) 2023 Eike Stepper (Loehne, Germany) 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: | ||
* Eike Stepper - initial API and implementation | ||
*/ | ||
package org.eclipse.emf.cdo.internal.migrator; | ||
|
||
import org.eclipse.emf.common.EMFPlugin; | ||
import org.eclipse.emf.common.util.ResourceLocator; | ||
|
||
/** | ||
* @author Eike Stepper | ||
*/ | ||
public final class MigratorPlugin extends EMFPlugin | ||
{ | ||
public static final MigratorPlugin INSTANCE = new MigratorPlugin(); | ||
|
||
private static Implementation plugin; | ||
|
||
public MigratorPlugin() | ||
{ | ||
super(new ResourceLocator[] {}); | ||
} | ||
|
||
@Override | ||
public ResourceLocator getPluginResourceLocator() | ||
{ | ||
return plugin; | ||
} | ||
|
||
public static Implementation getPlugin() | ||
{ | ||
return plugin; | ||
} | ||
|
||
/** | ||
* @author Eike Stepper | ||
*/ | ||
public static class Implementation extends EclipsePlugin | ||
{ | ||
public Implementation() | ||
{ | ||
plugin = this; | ||
} | ||
} | ||
} |
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
98 changes: 98 additions & 0 deletions
98
...igrator/src/org/eclipse/emf/cdo/internal/migrator/dbstore/DBStoreAnnotationValidator.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,98 @@ | ||
/* | ||
* Copyright (c) 2023 Eike Stepper (Loehne, Germany) 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: | ||
* Eike Stepper - initial API and implementation | ||
*/ | ||
package org.eclipse.emf.cdo.internal.migrator.dbstore; | ||
|
||
import org.eclipse.emf.cdo.internal.migrator.MigratorPlugin; | ||
|
||
import org.eclipse.emf.common.util.ResourceLocator; | ||
import org.eclipse.emf.ecore.EAnnotation; | ||
import org.eclipse.emf.ecore.EClass; | ||
import org.eclipse.emf.ecore.EModelElement; | ||
import org.eclipse.emf.ecore.EPackage; | ||
import org.eclipse.emf.ecore.EStructuralFeature; | ||
import org.eclipse.emf.ecore.util.BasicEAnnotationValidator; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Eike Stepper | ||
*/ | ||
public class DBStoreAnnotationValidator extends BasicEAnnotationValidator | ||
{ | ||
public static final DBStoreAnnotationValidator INSTANCE = new DBStoreAnnotationValidator(); | ||
|
||
public static final String ANNOTATION_URI = "http://www.eclipse.org/CDO/DBStore"; | ||
|
||
public static final String DIAGNOSTIC_SOURCE = "org.eclipse.emf.cdo.server.db"; | ||
|
||
private static final List<EClass> FEATURE; | ||
|
||
private static final List<EClass> FEATURE_MANY; | ||
|
||
private static final List<EClass> CLASS; | ||
|
||
private static final List<EClass> PACKAGE; | ||
|
||
static | ||
{ | ||
EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(ANNOTATION_URI); | ||
if (ePackage == null) | ||
{ | ||
// If the package isn't registered, as well be the case in a stand alone application, try to load it dynamically. | ||
// This will ensure that the package is registered as well. | ||
ePackage = loadEPackage(MigratorPlugin.INSTANCE.getBaseURL().toString() + "model/DBStore.ecore"); | ||
} | ||
|
||
FEATURE = Collections.singletonList((EClass)ePackage.getEClassifier("Feature")); | ||
FEATURE_MANY = Collections.singletonList((EClass)ePackage.getEClassifier("FeatureMany")); | ||
CLASS = Collections.singletonList((EClass)ePackage.getEClassifier("Class")); | ||
PACKAGE = Collections.singletonList((EClass)ePackage.getEClassifier("Package")); | ||
} | ||
|
||
public DBStoreAnnotationValidator() | ||
{ | ||
super(ANNOTATION_URI, "DBStore", DIAGNOSTIC_SOURCE); | ||
} | ||
|
||
@Override | ||
protected ResourceLocator getResourceLocator() | ||
{ | ||
return MigratorPlugin.INSTANCE; | ||
} | ||
|
||
@Override | ||
protected boolean isValidLocation(EAnnotation annotation, EModelElement modelElement) | ||
{ | ||
return modelElement instanceof EStructuralFeature || modelElement instanceof EClass || modelElement instanceof EPackage; | ||
} | ||
|
||
@Override | ||
protected List<EClass> getPropertyClasses(EModelElement modelElement) | ||
{ | ||
if (modelElement instanceof EStructuralFeature) | ||
{ | ||
return ((EStructuralFeature)modelElement).isMany() ? FEATURE_MANY : FEATURE; | ||
} | ||
|
||
if (modelElement instanceof EClass) | ||
{ | ||
return CLASS; | ||
} | ||
|
||
if (modelElement instanceof EPackage) | ||
{ | ||
return PACKAGE; | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../src/org/eclipse/emf/cdo/internal/migrator/dbstore/DBStoreItemProviderAdapterFactory.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,24 @@ | ||
/* | ||
* Copyright (c) 2023 Eike Stepper (Loehne, Germany) 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: | ||
* Eike Stepper - initial API and implementation | ||
*/ | ||
package org.eclipse.emf.cdo.internal.migrator.dbstore; | ||
|
||
import org.eclipse.emf.ecore.provider.annotation.EAnnotationItemProviderAdapterFactory; | ||
|
||
/** | ||
* @author Eike Stepper | ||
*/ | ||
public class DBStoreItemProviderAdapterFactory extends EAnnotationItemProviderAdapterFactory.Reflective | ||
{ | ||
public DBStoreItemProviderAdapterFactory() | ||
{ | ||
super(DBStoreAnnotationValidator.ANNOTATION_URI); | ||
} | ||
} |
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
File renamed without changes.
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