New Modeling Project Creation Wizard [message #1791361] |
Thu, 28 June 2018 11:51 |
AbuBakar Saadat Messages: 2 Registered: June 2018 |
Junior Member |
|
|
Hello Friends,
Hope you all will be in best health.
Actually my aim is to make a modeling project creation wizard, that only takes the name and location of the project from the user and on clicking finish, it should create a modeling project with a root object named "Model" being instantiated from another modeling project into it.
So far i am able to create a project wizard, that opens a new modeling project , but i don't know how to create the representation.aird file for this project and how to add an external model programmically into it, need guidance and right direction from you guys, here is the code for the project creation:
package customplugin.projects;
import javax.swing.text.html.Option;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import java.net.URI;
import customplugin.natures.ProjectNature;
public class CustomProjectSupport {
public static IProject createProject(String projectName, URI location) {
Assert.isNotNull(projectName);
Assert.isTrue(projectName.trim().length() > 0);
IProject project = createBaseProject(projectName, location);
try {
addNature(project);
} catch (CoreException e) {
e.printStackTrace();
project = null;
}
return project;
}
/**
* Just do the basics: create a basic project.
*
* @param location
* @param projectName
*/
private static IProject createBaseProject(String projectName, URI location) {
// it is acceptable to use the ResourcesPlugin class
IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!newProject.exists()) {
URI projectLocation = location;
IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName());
if (location != null ) ;
{ResourcesPlugin.getWorkspace().getRoot().getLocationURI().equals(location);
projectLocation = null;
}
desc.setLocationURI(projectLocation);
try {
newProject.create(desc, null);
if (!newProject.isOpen()) {
newProject.open(null);
}
} catch (CoreException e) {
e.printStackTrace();
}
}
return newProject;
}
private static void addNature(IProject project) throws CoreException {
if (!project.hasNature(ProjectNature.NATURE_ID)) {
IProjectDescription description = project.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length] = ProjectNature.NATURE_ID;
description.setNatureIds(newNatures);
IProgressMonitor monitor = null;
project.setDescription(description, monitor);
}
}
}
>>>>how to create the representation.aird for this project and how to add an external model with its root object into this model programmically
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03965 seconds