Allow to add nature and configure in one step
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / nature / AddMograsimNatureHandler.java
index f4d0357..900fc9d 100644 (file)
@@ -43,7 +43,7 @@ public class AddMograsimNatureHandler extends AbstractHandler
                                {
                                        try
                                        {
-                                               ms.add(toggleNature(project));
+                                               ms.add(addNature(project));
                                        }
                                        catch (CoreException e)
                                        {
@@ -63,7 +63,7 @@ public class AddMograsimNatureHandler extends AbstractHandler
         * @param project to have Mograsim nature
         * @return
         */
-       private IStatus toggleNature(IProject project) throws CoreException
+       public static IStatus addNature(IProject project) throws CoreException
        {
                IProjectDescription description = project.getDescription();
                String[] natures = description.getNatureIds();
@@ -85,4 +85,20 @@ public class AddMograsimNatureHandler extends AbstractHandler
 
                return status;
        }
+
+       /**
+        * Adds Mograsim nature on a project
+        *
+        * @param project to have Mograsim nature
+        * @return
+        */
+       public static IStatus addNatureAndConfigure(IProject project, String machineId) throws CoreException
+       {
+               IStatus result = addNature(project);
+               if (result.getSeverity() > IStatus.INFO)
+                       return result;
+               MachineContext mc = ProjectMachineContext.getMachineContextOf(project);
+               mc.setMachineId(machineId);
+               return result;
+       }
 }
\ No newline at end of file