diff --git a/org.moflon.core.build/src/org/moflon/core/build/MoflonProjectCreator.java b/org.moflon.core.build/src/org/moflon/core/build/MoflonProjectCreator.java index d2d6a389..388dfb42 100644 --- a/org.moflon.core.build/src/org/moflon/core/build/MoflonProjectCreator.java +++ b/org.moflon.core.build/src/org/moflon/core/build/MoflonProjectCreator.java @@ -305,12 +305,7 @@ public void createFoldersIfNecessary(final IProject project, final IProgressMoni * the progress monitor */ protected void addGitKeepFiles(final IProject project, final IProgressMonitor monitor) { - final SubMonitor subMon = SubMonitor.convert(monitor, "Creating .keep* files for Git within project " + project, - 3); - - WorkspaceHelper.createKeepFile(WorkspaceHelper.getSourceFolder(project), subMon.split(1)); - WorkspaceHelper.createKeepFile(WorkspaceHelper.getGenFolder(project), subMon.split(1)); - WorkspaceHelper.createKeepFile(WorkspaceHelper.getModelFolder(project), subMon.split(1)); + // Nothing to do in this class } @Override diff --git a/org.moflon.core.feature/feature.xml b/org.moflon.core.feature/feature.xml index 8db07e55..376948d1 100644 --- a/org.moflon.core.feature/feature.xml +++ b/org.moflon.core.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/org.moflon.core.preferences/src/org/moflon/core/preferences/EMoflonPreferencesStorage.java b/org.moflon.core.preferences/src/org/moflon/core/preferences/EMoflonPreferencesStorage.java index ef371593..b170fe87 100644 --- a/org.moflon.core.preferences/src/org/moflon/core/preferences/EMoflonPreferencesStorage.java +++ b/org.moflon.core.preferences/src/org/moflon/core/preferences/EMoflonPreferencesStorage.java @@ -6,10 +6,10 @@ * @author Roland Kluge - Initial implementation */ public class EMoflonPreferencesStorage { - - /** - * Indicates unbounded adornment size for {@link #getMaximumAdornmentSize()} - */ + + /** + * Indicates unbounded adornment size for {@link #getMaximumAdornmentSize()} + */ public static final int REACHABILITY_MAX_ADORNMENT_SIZE_INFINITY = 0; /** @@ -26,11 +26,6 @@ public class EMoflonPreferencesStorage { * Default value for {@link #getReachabilityEnabled()} */ public static final boolean DEFAULT_REACHABILITIY_IS_ENABLED = true; - - /** - * Default value for {@link #getPreferredGenModelPlatformUriType()} - */ - public static final PlatformUriType DEFAULT_PLATFORM_URI_TYPE = PlatformUriType.RESOURCE; /** * Stores the configured validation timeout in milliseconds. 'null' if not set. @@ -47,11 +42,6 @@ public class EMoflonPreferencesStorage { */ private boolean reachabilityEnabled; - /** - * Stores the preferred {@link PlatformUriType} - */ - private PlatformUriType preferredPlatformUriType = DEFAULT_PLATFORM_URI_TYPE; - /** * Sets the validation timeout in milliseconds * @@ -64,6 +54,7 @@ public void setValidationTimeout(final int validationTimeout) { /** * Returns the timeout for the reachability validation (in milliseconds) + * * @return the validation timeout */ public int getValidationTimeout() { @@ -101,32 +92,10 @@ public void setReachabilityEnabled(final boolean reachabilityEnabled) { } /** - * @return true if the reachability analysis shall be enabled, false - * otherwise + * @return true if the reachability analysis shall be enabled, false otherwise * @see #setReachabilityEnabled(boolean) */ public boolean getReachabilityEnabled() { return reachabilityEnabled; } - - /** - * Configures the preferred {@link PlatformUriType} - * @param preferredPlatformUriType the preferred {@link PlatformUriType}. Must not be null. - */ - public void setPreferredPlatformUriType(final PlatformUriType preferredPlatformUriType) - { - if (preferredPlatformUriType == null) - throw new IllegalArgumentException("Only non-null values allowed for preferred platform URI type."); - - this.preferredPlatformUriType = preferredPlatformUriType; - } - - /** - * Returns the {@link PlatformUriType} that shall be used by the build process to represent resources in workspace projects. - * @return the preferred URI type - */ - public PlatformUriType getPreferredGenModelPlatformUriType() - { - return this.preferredPlatformUriType; - } } diff --git a/org.moflon.core.preferences/src/org/moflon/core/preferences/PlatformUriType.java b/org.moflon.core.preferences/src/org/moflon/core/preferences/PlatformUriType.java index 78285e7c..4ce8a292 100644 --- a/org.moflon.core.preferences/src/org/moflon/core/preferences/PlatformUriType.java +++ b/org.moflon.core.preferences/src/org/moflon/core/preferences/PlatformUriType.java @@ -2,15 +2,21 @@ /** * Lists all types of Ecore URIs. + * * @author Roland Kluge - Initial implementation */ public enum PlatformUriType { - /** - * Placeholder for platform:/resource URIs - */ - RESOURCE, - /** - * Placeholder for platform:/plugin URIs - */ - PLUGIN; + /** + * Placeholder for platform:/resource URIs + */ + RESOURCE, + /** + * Placeholder for platform:/plugin URIs + */ + PLUGIN; + + /** + * The default URI type to use + */ + public static final PlatformUriType DEFAULT = PLUGIN; } diff --git a/org.moflon.core.releng.updatesite/category.xml b/org.moflon.core.releng.updatesite/category.xml index 2fa202e6..1391d423 100644 --- a/org.moflon.core.releng.updatesite/category.xml +++ b/org.moflon.core.releng.updatesite/category.xml @@ -1,6 +1,6 @@ - + diff --git a/org.moflon.core.releng.updatesite/changelog.txt b/org.moflon.core.releng.updatesite/changelog.txt index 57870de2..e33f30a3 100644 --- a/org.moflon.core.releng.updatesite/changelog.txt +++ b/org.moflon.core.releng.updatesite/changelog.txt @@ -1,10 +1,18 @@ -2018-03-22 eMoflon 1.1.1 released +2018-04-10 eMoflon Core 1.2.0 released -Default URI type switched to platform:/reesource instead of platform:/plugin +Minor improvements: +* Default URI type switched back to platform:/plugin for backward compatibility + * Preferred URI type is now configurable via an extension point. +* More concise .gitignore files +* See also https://github.com/eMoflon/emoflon-core/issues?utf8=✓&q=is%3Aissue closed%3A2018-03-22..2018-04-10 + +2018-03-22 eMoflon Core 1.1.1 released + +Default URI type switched to platform:/resource instead of platform:/plugin Issue https://github.com/eMoflon/emoflon-core/issues/50 -2018-03-21 eMoflon 1.1.0 released +2018-03-21 eMoflon Core 1.1.0 released This is a minor bugfix release diff --git a/org.moflon.core.releng.updatesite/site.xml b/org.moflon.core.releng.updatesite/site.xml index 354948e6..038b3f67 100644 --- a/org.moflon.core.releng.updatesite/site.xml +++ b/org.moflon.core.releng.updatesite/site.xml @@ -1,6 +1,6 @@ - + diff --git a/org.moflon.emf.codegen/src/org/moflon/emf/codegen/MoflonGenModelBuilder.java b/org.moflon.emf.codegen/src/org/moflon/emf/codegen/MoflonGenModelBuilder.java index 9209dd3b..b006dbe4 100644 --- a/org.moflon.emf.codegen/src/org/moflon/emf/codegen/MoflonGenModelBuilder.java +++ b/org.moflon.emf.codegen/src/org/moflon/emf/codegen/MoflonGenModelBuilder.java @@ -17,7 +17,6 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.moflon.core.preferences.EMoflonPreferencesStorage; import org.moflon.core.preferences.PlatformUriType; import org.moflon.core.propertycontainer.AdditionalDependencies; import org.moflon.core.propertycontainer.AdditionalUsedGenPackages; @@ -115,9 +114,9 @@ public List getGenModelResourceDependencies() { } /** - * Returns a platform:/ {@link URI} for the given project based on the - * corresponding preferences in {@link EMoflonPreferencesStorage} + * Returns a platform:/ {@link URI} for the given project based on the visible {@link URIPreferenceExtension}s * + * If multiple extensions exist, the preference of one extension is taken nondeterministically. * @param project * the project * @return the corresponding {@link URI} @@ -126,7 +125,7 @@ public static URI determineProjectUriBasedOnPreferences(final IProject project) final PlatformUriType preferredGenModelPlatformUriType = uriPreferenceExtension.stream()// .map(URIPreferenceExtension::getPlatformURIType)// .findAny()// - .orElse(PlatformUriType.PLUGIN); + .orElse(PlatformUriType.DEFAULT); final URI projectURI = determineProjectUriBasedOnPlatformUriType(project, preferredGenModelPlatformUriType); return projectURI; } diff --git a/org.moflon.emf.codegen/src/org/moflon/emf/codegen/URIPreferenceExtension.java b/org.moflon.emf.codegen/src/org/moflon/emf/codegen/URIPreferenceExtension.java index 7573322f..e46062a7 100644 --- a/org.moflon.emf.codegen/src/org/moflon/emf/codegen/URIPreferenceExtension.java +++ b/org.moflon.emf.codegen/src/org/moflon/emf/codegen/URIPreferenceExtension.java @@ -1,7 +1,19 @@ package org.moflon.emf.codegen; +import org.eclipse.emf.common.util.URI; import org.moflon.core.preferences.PlatformUriType; +/** + * Interface that allows extensions to declare their preferred platform:/ {@link URI} type + * + * @author Anthony Anjorin - Initial implementation + * @author Roland Kluge - Docu + */ public interface URIPreferenceExtension { + + /** + * Returns the preferred platform:/ {@link URI} type to be used inside the eMoflon build process + * @return the {@link URI} type + */ public PlatformUriType getPlatformURIType(); } diff --git a/org.moflon.emf.ui/.classpath b/org.moflon.emf.ui/.classpath index 22f30643..213e409f 100644 --- a/org.moflon.emf.ui/.classpath +++ b/org.moflon.emf.ui/.classpath @@ -1,6 +1,7 @@ + diff --git a/org.moflon.emf.ui/.gitignore b/org.moflon.emf.ui/.gitignore index 3d1f6cf4..707afdb0 100644 --- a/org.moflon.emf.ui/.gitignore +++ b/org.moflon.emf.ui/.gitignore @@ -1,3 +1,4 @@ /.settings/ /bin -/target \ No newline at end of file +/target +/xtend-gen/ \ No newline at end of file diff --git a/org.moflon.emf.ui/.project b/org.moflon.emf.ui/.project index 70ff8632..099f0660 100644 --- a/org.moflon.emf.ui/.project +++ b/org.moflon.emf.ui/.project @@ -5,6 +5,11 @@ + + org.eclipse.xtext.ui.shared.xtextBuilder + + + org.eclipse.jdt.core.javabuilder @@ -24,5 +29,6 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.xtext.ui.shared.xtextNature diff --git a/org.moflon.emf.ui/META-INF/MANIFEST.MF b/org.moflon.emf.ui/META-INF/MANIFEST.MF index 92125e7b..a6a4139b 100644 --- a/org.moflon.emf.ui/META-INF/MANIFEST.MF +++ b/org.moflon.emf.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: IDE/UI components for EMF code generation Bundle-SymbolicName: org.moflon.emf.ui;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.ui.workbench;bundle-version="3.0.0", org.eclipse.core.runtime;bundle-version="3.0.0", @@ -16,5 +16,11 @@ Require-Bundle: org.eclipse.ui.workbench;bundle-version="3.0.0", org.moflon.core.utilities;bundle-version="2.0.0", org.moflon.core.plugins;bundle-version="2.2.0", org.moflon.core.build;bundle-version="1.0.0", - org.moflon.emf.build;bundle-version="1.0.0" + org.moflon.emf.build;bundle-version="1.0.0", + com.google.guava, + org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib, + org.eclipse.xtend.lib.macro, + org.moflon.emf.codegen Export-Package: org.moflon.emf.ui.wizard + diff --git a/org.moflon.emf.ui/build.properties b/org.moflon.emf.ui/build.properties index ff74ed68..b7a538a2 100644 --- a/org.moflon.emf.ui/build.properties +++ b/org.moflon.emf.ui/build.properties @@ -1,4 +1,5 @@ -source.. = src/ +source.. = src/,\ + xtend-gen/ output.. = bin/ bin.includes = META-INF/,\ .,\ diff --git a/org.moflon.emf.ui/pom.xml b/org.moflon.emf.ui/pom.xml new file mode 100644 index 00000000..2471141a --- /dev/null +++ b/org.moflon.emf.ui/pom.xml @@ -0,0 +1,22 @@ + + 4.0.0 + + org.moflon.core + tycho-parent + 1.0.0-SNAPSHOT + .. + + org.moflon.emf.ui + eclipse-plugin + 1.1.0-SNAPSHOT + + + + + org.eclipse.xtend + xtend-maven-plugin + + + + diff --git a/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/DefaultEPackageContentGenerator.xtend b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/DefaultEPackageContentGenerator.xtend new file mode 100644 index 00000000..a34a2de4 --- /dev/null +++ b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/DefaultEPackageContentGenerator.xtend @@ -0,0 +1,33 @@ +package org.moflon.emf.ui.wizard + +/** + * This class provides the default content of generated Ecore files + */ +class DefaultEPackageContentGenerator { + + /** + * Generates an XMI representation of the EPackage corresponding to the given + * project name + * + * @param projectName the name of the containing project + * @param packageName the name of the EPackage + * @param packageUri the NS URI of the EPackage + * @return the raw XMI file content + */ + public static def String generateDefaultEPackageForProject(String projectName, String packageName, String packageUri) { + ''' + + + +
+ + + ''' + } +} \ No newline at end of file diff --git a/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/MoflonEmfProjectCreator.java b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/MoflonEmfProjectCreator.java index df921de5..c636c418 100644 --- a/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/MoflonEmfProjectCreator.java +++ b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/MoflonEmfProjectCreator.java @@ -20,9 +20,8 @@ public class MoflonEmfProjectCreator extends MoflonProjectCreator { private static final List GITIGNORE_LINES = Arrays.asList(// "/bin", // - "/target", // - "/gen/*", // - "!/**/.keep*"); + "/gen", // + "/model/*.genmodel"); /** * Pass-through constructor to {@link MoflonProjectCreator} diff --git a/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/NewMoflonEmfProjectWizard.java b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/NewMoflonEmfProjectWizard.java index d3c86d1f..a7ade4e0 100644 --- a/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/NewMoflonEmfProjectWizard.java +++ b/org.moflon.emf.ui/src/org/moflon/emf/ui/wizard/NewMoflonEmfProjectWizard.java @@ -1,9 +1,5 @@ package org.moflon.emf.ui.wizard; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; @@ -23,94 +19,107 @@ import org.moflon.core.utilities.MoflonUtil; import org.moflon.core.utilities.WorkspaceHelper; import org.moflon.emf.build.MoflonEmfNature; - -public class NewMoflonEmfProjectWizard extends AbstractMoflonWizard { - private static final Logger logger = Logger.getLogger(NewMoflonEmfProjectWizard.class); - - public static final String NEW_REPOSITORY_PROJECT_WIZARD_ID = "org.moflon.emf.ui.wizard.NewMoflonEmfProjectWizard"; - - protected AbstractMoflonProjectInfoPage projectInfo; - - @Override - public void addPages() { - projectInfo = new NewMoflonEmfProjectInfoPage(); - addPage(projectInfo); - } - - @Override - protected void doFinish(final IProgressMonitor monitor) throws CoreException { - try { - final SubMonitor subMon = SubMonitor.convert(monitor, "Creating eMoflon EMF project", 8); - - final String projectName = projectInfo.getProjectName(); - - final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - final PluginProperties pluginProperties = new PluginProperties(); - pluginProperties.put(PluginProperties.NAME_KEY, projectName); - pluginProperties.put(PluginProperties.PLUGIN_ID_KEY, projectName); - createProject(subMon, project, pluginProperties); - subMon.worked(3); - - generateDefaultFiles(subMon, project); - subMon.worked(3); - - ResourcesPlugin.getWorkspace().run(new PluginProducerWorkspaceRunnable(project, pluginProperties), - subMon.split(1)); - subMon.worked(2); - - // Add to most recent working set - final IWorkingSet[] recentWorkingSet = WorkingSetUtilities.getSelectedWorkingSet(getSelection(), - getActivePart()); - if (recentWorkingSet.length != 0) { - WorkingSetUtilities.addProjectToWorkingSet(project, recentWorkingSet[0]); - } - - } catch (final Exception e) { - LogUtils.error(logger, e); - } - } - - protected void generateDefaultFiles(final IProgressMonitor monitor, IProject project) throws CoreException { - final SubMonitor subMon = SubMonitor.convert(monitor, "Creating default files", 1); - String defaultEcoreFile = generateDefaultEPackageForProject(project.getName()); - WorkspaceHelper.addFile(project, MoflonConventions.getDefaultPathToEcoreFileInProject(project.getName()), - defaultEcoreFile, subMon.split(1)); - } - - protected void createProject(IProgressMonitor monitor, IProject project, PluginProperties pluginProperties) - throws CoreException { - final SubMonitor subMon = SubMonitor.convert(monitor, "Creating project", 1); - final MoflonProjectCreator createMoflonProject = new MoflonEmfProjectCreator(project, pluginProperties, - new MoflonEmfNature()); - ResourcesPlugin.getWorkspace().run(createMoflonProject, subMon.split(1)); - } - - /** - * Generates an XMI representation of the EPackage corresponding to the given - * project name - * - * @param projectName - * the project name from which the conventional EPackage name etc. - * are derived - * @return the raw XMI file content - */ - private static String generateDefaultEPackageForProject(final String projectName) { - final String packageName = MoflonUtil.lastSegmentOf(projectName); - final URI packageUri = MoflonConventions.getDefaultResourceDependencyUri(projectName); - final List lines = new ArrayList<>(); - lines.add(""); - lines.add(""); - lines.add(" "); - lines.add("
"); - lines.add(" "); - lines.add(""); - return StringUtils.join(lines, WorkspaceHelper.DEFAULT_RESOURCE_LINE_DELIMITER); - } +import org.moflon.emf.codegen.MoflonGenModelBuilder; + +/** + * This wizard creates a new eMoflon EMF project + * + * @author Roland Kluge - Initial implementation + * + * @see #doFinish(IProgressMonitor) + */ +public class NewMoflonEmfProjectWizard extends AbstractMoflonWizard +{ + private static final Logger logger = Logger.getLogger(NewMoflonEmfProjectWizard.class); + + /** + * This is the ID that is also used in plugin.xml + */ + public static final String NEW_REPOSITORY_PROJECT_WIZARD_ID = "org.moflon.emf.ui.wizard.NewMoflonEmfProjectWizard"; + + protected AbstractMoflonProjectInfoPage projectInfo; + + /** + * Configures this wizard to use the {@link NewMoflonEmfProjectInfoPage} + */ + @Override + public void addPages() + { + projectInfo = new NewMoflonEmfProjectInfoPage(); + addPage(projectInfo); + } + + @Override + protected void doFinish(final IProgressMonitor monitor) throws CoreException + { + try + { + final SubMonitor subMon = SubMonitor.convert(monitor, "Creating eMoflon EMF project", 8); + + final String projectName = projectInfo.getProjectName(); + + final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + final PluginProperties pluginProperties = new PluginProperties(); + pluginProperties.put(PluginProperties.NAME_KEY, projectName); + pluginProperties.put(PluginProperties.PLUGIN_ID_KEY, projectName); + createProject(subMon, project, pluginProperties); + subMon.worked(3); + + generateDefaultFiles(subMon, project); + subMon.worked(3); + + ResourcesPlugin.getWorkspace().run(new PluginProducerWorkspaceRunnable(project, pluginProperties), subMon.split(1)); + subMon.worked(2); + + addToWorkingSet(project); + + } catch (final Exception e) + { + LogUtils.error(logger, e); + } + } + + /** + * Initializes and runs the {@link MoflonProjectCreator} for the current project + * @param monitor the progress monitor + * @param project the project being created + * @param pluginProperties the metadata of the project + * @throws CoreException if setting up the project fails + */ + protected void createProject(final IProgressMonitor monitor, final IProject project, final PluginProperties pluginProperties) throws CoreException + { + final SubMonitor subMon = SubMonitor.convert(monitor, "Creating project", 1); + final MoflonProjectCreator createMoflonProject = new MoflonEmfProjectCreator(project, pluginProperties, new MoflonEmfNature()); + ResourcesPlugin.getWorkspace().run(createMoflonProject, subMon.split(1)); + } + + /** + * Stores the default Ecore file in the proper location + * @param monitor the progress monitor + * @param project the project being created currently + * @throws CoreException if storing the file fails + */ + protected void generateDefaultFiles(final IProgressMonitor monitor, final IProject project) throws CoreException + { + final SubMonitor subMon = SubMonitor.convert(monitor, "Creating default files", 1); + final String projectName = project.getName(); + final String packageName = MoflonUtil.lastSegmentOf(projectName); + final URI projectUri = MoflonGenModelBuilder.determineProjectUriBasedOnPreferences(project); + final URI packageUri = URI.createURI(projectUri.toString() + MoflonConventions.getDefaultPathToEcoreFileInProject(projectName)); + final String defaultEcoreFile = DefaultEPackageContentGenerator.generateDefaultEPackageForProject(projectName, packageName, packageUri.toString()); + WorkspaceHelper.addFile(project, MoflonConventions.getDefaultPathToEcoreFileInProject(projectName), defaultEcoreFile, subMon.split(1)); + } + + /** + * Adds the given project to the selected working set (if exists) + * @param project the project being creatd + */ + private void addToWorkingSet(final IProject project) + { + final IWorkingSet[] recentWorkingSet = WorkingSetUtilities.getSelectedWorkingSet(getSelection(), getActivePart()); + if (recentWorkingSet.length != 0) + { + WorkingSetUtilities.addProjectToWorkingSet(project, recentWorkingSet[0]); + } + } }