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: 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
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: 33141
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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: New Modeling Project Creation Wizard [message #1792025 is a reply to message #1791471] Tue, 10 July 2018 08:32 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
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
Re: New Modeling Project Creation Wizard [message #1797151 is a reply to message #1791361] Fri, 26 October 2018 10:56 Go to previous message
Michael  Plant is currently offline Michael PlantFriend
Messages: 1
Registered: October 2018
Junior Member
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: Fri Apr 26 02:59:56 GMT 2024

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

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

Back to the top