view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java @ 122:3a5d1c6148ed

Generate multi-module maven/m2e plugin Generate a multi-module maven project and add a maven nature so it works under m2e. Generate pom files and bundle activators with correct groupId, artifactId, version and package names.
author Omair Majid <omajid@redhat.com>
date Tue, 25 Mar 2014 12:25:58 -0400
parents 4c549b4c6fb3
children a0c68ec37305
line wrap: on
line source

package com.redhat.thermostat.tools.eclipse.plugin.wizards;

import java.io.IOException;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

import com.redhat.thermostat.tools.eclipse.plugin.Activator;

public class ThermostatProjectCreationWizard extends Wizard implements INewWizard {

    private ThermostatProjectCreationWizardPage pageOne;

    @Override
    public void init(IWorkbench workbench, IStructuredSelection selection) {
        setWindowTitle("Create New Thermostat Plugin");
        setNeedsProgressMonitor(true);
    }

    @Override
    public void addPages() {
        pageOne = new ThermostatProjectCreationWizardPage();
        addPage(pageOne);
    }

    @Override
    public boolean performFinish() {
        try {
            String groupId = pageOne.getGroupId();
            String artifactId = pageOne.getArtifactId();
            String version = pageOne.getVersion();

            String packagePrefix = pageOne.getPackagePrefix();
            String thermostatVersion = pageOne.getThermostatVersion();

            createProject(groupId, artifactId, version, packagePrefix, thermostatVersion);
        } catch (CoreException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return true;
    }

    private void createProject(String groupId, String artifactId, String version, String packagePrefix, String thermostatVersion) throws CoreException {
        ProjectCreator creator = new ProjectCreator(groupId, artifactId, version, packagePrefix, thermostatVersion);
        try {
            creator.create();
        } catch (IOException e) {
            throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Error creating project", e));
        }
    }

}