@@ -0,0 +1,2999 @@
+package eu.scasefp7.eclipse.core.handlers;%0D%0A%0D%0Aimport java.util.Iterator;%0D%0A%0D%0Aimport org.eclipse.core.commands.*;%0D%0Aimport org.eclipse.core.resources.IProject;%0D%0Aimport org.eclipse.core.resources.IProjectDescription;%0D%0Aimport org.eclipse.core.runtime.CoreException;%0D%0Aimport org.eclipse.core.runtime.IAdaptable;%0D%0Aimport org.eclipse.jface.viewers.ISelection;%0D%0Aimport org.eclipse.jface.viewers.IStructuredSelection;%0D%0Aimport org.eclipse.ui.handlers.HandlerUtil;%0D%0A%0D%0Aimport eu.scasefp7.eclipse.core.builder.ScaseNature;%0D%0A%0D%0A/**%0D%0A * Adds or removes the S-CASE nature on an IProject.%0D%0A * %0D%0A * @author Leonora Ga%C5%A1par%0D%0A * @author Marin Orli%C4%87%0D%0A */%0D%0Apublic class AddRemoveScaseNatureHandler extends AbstractHandler %7B%0D%0A%0D%0A    @Override%0D%0A    public Object execute(ExecutionEvent event) throws ExecutionException %7B%0D%0A%0D%0A        ISelection selection = HandlerUtil.getCurrentSelection(event);%0D%0A       %0D%0A        if (selection instanceof IStructuredSelection) %7B%0D%0A            for (Iterator%3C?%3E it = ((IStructuredSelection) selection).iterator(); it.hasNext();) %7B%0D%0A                Object element = it.next();%0D%0A                IProject project = null;%0D%0A                if (element instanceof IProject) %7B%0D%0A                    project = (IProject) element;%0D%0A                %7D else if (element instanceof IAdaptable) %7B%0D%0A                    project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);%0D%0A                %7D%0D%0A                if (project != null) %7B%0D%0A                    try %7B%0D%0A                        toggleNature(project);%0D%0A                    %7D catch (CoreException e) %7B%0D%0A                        // TODO log something%0D%0A                        throw new ExecutionException(%22Failed to toggle nature%22, e);%0D%0A                    %7D%0D%0A                %7D%0D%0A            %7D%0D%0A        %7D%0D%0A%0D%0A        return null;%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Toggles sample nature on a project%0D%0A     *%0D%0A     * @param project to have sample nature added or removed%0D%0A     */%0D%0A    private void toggleNature(IProject project) throws CoreException %7B%0D%0A        IProjectDescription description = project.getDescription();%0D%0A        String%5B%5D natures = description.getNatureIds();%0D%0A%0D%0A        for (int i = 0; i %3C natures.length; ++i) %7B%0D%0A            if (ScaseNature.NATURE_ID.equals(natures%5Bi%5D)) %7B%0D%0A                // Remove the nature%0D%0A                String%5B%5D newNatures = new String%5Bnatures.length - 1%5D;%0D%0A                System.arraycopy(natures, 0, newNatures, 0, i);%0D%0A                System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);%0D%0A                description.setNatureIds(newNatures);%0D%0A                project.setDescription(description, null);%0D%0A                return;%0D%0A            %7D%0D%0A        %7D%0D%0A%0D%0A        // Add the nature%0D%0A        String%5B%5D newNatures = new String%5Bnatures.length + 1%5D;%0D%0A        System.arraycopy(natures, 0, newNatures, 0, natures.length);%0D%0A        newNatures%5Bnatures.length%5D = ScaseNature.NATURE_ID;%0D%0A        description.setNatureIds(newNatures);%0D%0A        project.setDescription(description, null);%0D%0A    %7D%0D%0A%0D%0A%7D

Add nature config handler