Skip to main content



      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 07:51 Go to next message
Eclipse UserFriend
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 02:25 Go to previous messageGo to next message
Eclipse UserFriend
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 04:32 Go to previous messageGo to next message
Eclipse UserFriend
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/.


Re: New Modeling Project Creation Wizard [message #1797151 is a reply to message #1791361] Fri, 26 October 2018 06:56 Go to previous message
Eclipse UserFriend
Hi, I want to know on what model or layout is Musconv
Previous Topic:RDF Turtle code generation template
Next Topic:Issues with Eclipse Modeling [Mars] - regarding marketplace and installation details
Goto Forum:
  


Current Time: Wed Jul 23 17:59:35 EDT 2025

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

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

Back to the top