Skip to content

Commit

Permalink
Support validation and UI for DBStore annotations in the Ecore editor #…
Browse files Browse the repository at this point in the history
  • Loading branch information
estepper committed Aug 29, 2023
1 parent e496f5c commit c8ce883
Show file tree
Hide file tree
Showing 15 changed files with 222 additions and 13 deletions.
8 changes: 6 additions & 2 deletions plugins/org.eclipse.emf.cdo.migrator/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.emf.ecore.edit;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)",
org.eclipse.emf.importer;bundle-version="[2.5.0,3.0.0)",
org.eclipse.net4j.util.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.ant.core;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.apache.ant;bundle-version="[1.0.0,2.0.0)";resolution:=optional
Export-Package: org.eclipse.emf.cdo.internal.messages;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator;version="3.3.0";x-internal:=true,
Export-Package: org.eclipse.emf.cdo.internal.migrator;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator.actions;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator.dbstore;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator.messages;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator.tasks;version="3.3.0";x-internal:=true,
org.eclipse.emf.cdo.internal.migrator.wizards;version="3.3.0";x-internal:=true
Automatic-Module-Name: org.eclipse.emf.cdo.migrator
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.emf.cdo.internal.migrator.MigratorPlugin$Implementation
6 changes: 2 additions & 4 deletions plugins/org.eclipse.emf.cdo.migrator/build-ant-tasks.ant
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
<target name="build-ant-tasks">
<jar destfile="ant_tasks/cdo.ant.tasks.jar">
<fileset dir="bin">
<include name="**/*.class" />
<exclude name="**/actions/*.class" />
<exclude name="**/wizards/*.class" />
<exclude name="**/CDOImporter*.class" />
<include name="org/eclipse/emf/cdo/internal/migrator/tasks/*.class" />
<include name="org/eclipse/emf/cdo/internal/migrator/CDOMigratorUtil.class" />
</fileset>
</jar>
</target>
Expand Down
3 changes: 2 additions & 1 deletion plugins/org.eclipse.emf.cdo.migrator/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ bin.includes = .,\
about.mappings,\
about.properties,\
modeling32.png,\
ant_tasks/cdo.ant.tasks.jar
ant_tasks/cdo.ant.tasks.jar,\
model/

src.includes = about.html,\
pom.xml,\
Expand Down
21 changes: 21 additions & 0 deletions plugins/org.eclipse.emf.cdo.migrator/model/DBStore.ecore
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>
12 changes: 12 additions & 0 deletions plugins/org.eclipse.emf.cdo.migrator/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,17 @@
<antType library="ant_tasks/cdo.ant.tasks.jar" name="sourcefield" class="org.eclipse.emf.cdo.internal.migrator.tasks.TransferMembersTask$SourceClass$SourceField" />
<antType library="ant_tasks/cdo.ant.tasks.jar" name="sourcemethod" class="org.eclipse.emf.cdo.internal.migrator.tasks.TransferMembersTask$SourceClass$SourceMethod" />
</extension>

<extension point="org.eclipse.emf.ecore.annotation_validator">
<validator
class="org.eclipse.emf.cdo.internal.migrator.dbstore.DBStoreAnnotationValidator"
uri="http://www.eclipse.org/CDO/DBStore" />
</extension>

<extension point="org.eclipse.emf.ecore.edit.annotation_item_provider_adapter_factory">
<factory
class="org.eclipse.emf.cdo.internal.migrator.dbstore.DBStoreItemProviderAdapterFactory"
uri="http://www.eclipse.org/CDO/DBStore" />
</extension>

</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
package org.eclipse.emf.cdo.internal.migrator;

import org.eclipse.emf.cdo.internal.messages.Messages;
import org.eclipse.emf.cdo.internal.migrator.messages.Messages;

import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
package org.eclipse.emf.cdo.internal.migrator;

import org.eclipse.emf.cdo.internal.messages.Messages;
import org.eclipse.emf.cdo.internal.migrator.messages.Messages;

import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
Expand Down
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
package org.eclipse.emf.cdo.internal.migrator.actions;

import org.eclipse.emf.cdo.internal.messages.Messages;
import org.eclipse.emf.cdo.internal.migrator.CDOMigratorUtil;
import org.eclipse.emf.cdo.internal.migrator.messages.Messages;

import org.eclipse.net4j.util.ui.UIUtil;

Expand Down
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();
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Victor Roldan Betancort - initial API and implementation
* Eike Stepper - maintenance
*/
package org.eclipse.emf.cdo.internal.messages;
package org.eclipse.emf.cdo.internal.migrator.messages;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
package org.eclipse.emf.cdo.internal.migrator.tasks;

import org.eclipse.emf.cdo.internal.messages.Messages;
import org.eclipse.emf.cdo.internal.migrator.CDOMigratorUtil;
import org.eclipse.emf.cdo.internal.migrator.messages.Messages;

import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/
package org.eclipse.emf.cdo.internal.migrator.wizards;

import org.eclipse.emf.cdo.internal.messages.Messages;
import org.eclipse.emf.cdo.internal.migrator.CDOImporter;
import org.eclipse.emf.cdo.internal.migrator.messages.Messages;

import org.eclipse.emf.converter.ModelConverter;
import org.eclipse.emf.importer.ui.contribution.base.ModelImporterDetailPage;
Expand Down

0 comments on commit c8ce883

Please sign in to comment.