view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizard.java @ 124:f425cf9c32e8

Externalize strings in project wizard
author Omair Majid <omajid@redhat.com>
date Wed, 26 Mar 2014 13:06:12 -0400
parents a0c68ec37305
children eef52fe80553
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;
import com.redhat.thermostat.tools.eclipse.plugin.Messages;
import com.redhat.thermostat.tools.eclipse.plugin.wizards.ThermostatProjectCreationWizardPage.ProjectModel;

public class ThermostatProjectCreationWizard extends Wizard implements INewWizard {

    private ThermostatProjectCreationWizardPage pageOne;

    @Override
    public void init(IWorkbench workbench, IStructuredSelection selection) {
        setWindowTitle(Messages.ThermostatProjectCreationWizard_dialogTitle);
        setNeedsProgressMonitor(true);
    }

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

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

            String packagePrefix = model.getPackageName();
            String thermostatVersion = model.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)); //$NON-NLS-1$
        }
    }

}