Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » New Modeling Project Creation Wizard (Need Help regarding new modeling Project Creation Wizard )
New Modeling Project Creation Wizard [message #1791361] Thu, 28 June 2018 11:51 Go to next message
AbuBakar Saadat is currently offline AbuBakar SaadatFriend
Messages: 1
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
Re: New Modeling Project Creation Wizard [message #1791471 is a reply to message #1791361] Sat, 30 June 2018 06:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29536
Registered: July 2009
Senior Member
It's probably better to ask on the Sirius forum.

https://www.eclipse.org/forums/index.php/f/262/

I assume you've already looked at that project's getting started information:

https://www.eclipse.org/sirius/getstarted.html

In general it's typically useful to look at how existing code accomplishes a similar task. For this purpose, the plug-in spy is useful. I.e., Alt-Shift-F1 will show you information about the current active control in the workbench window; you can use it to find out what class implements that control so you can look at its source code. And Alt-Shift-F2 lets you determine how menu items are implemented.
Re: New Modeling Project Creation Wizard [message #1792025 is a reply to message #1791471] Tue, 10 July 2018 08:32 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 439
Registered: July 2009
Senior Member
Hi,

The API you're looking for is probably org.eclipse.sirius.ui.tools.api.project.ModelingProjectManager.createNewModelingProject(String, boolean, IProgressMonitor) to create the project, and then org.eclipse.sirius.business.api.modelingproject.ModelingProject.asModelingProject(IProject) to manage it using its specific APIs.

As mentioned by Ed, this is a Sirius-specific subject, so if you have more questions see you in the Sirius forum at https://www.eclipse.org/forums/index.php/f/262/.




Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:RDF Turtle code generation template
Goto Forum:
  


Current Time: Tue Sep 18 20:00:54 GMT 2018

Powered by FUDForum. Page generated in 0.02004 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top