view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/wizards/ThermostatProjectCreationWizardPage.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 b788a26c0d4d
children a0c68ec37305
line wrap: on
line source

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

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class ThermostatProjectCreationWizardPage extends WizardPage {

    private Text groupIdText;
    private Text artifactIdText;
    private Text versionText;

    private Text packageNameText;

    private Text thermostatVersionText;

    public ThermostatProjectCreationWizardPage() {
        super("wizardPage");
        setTitle("Thermostat Wizard");
        setDescription("This wizard creates a new Thermostat Plugin.");
    }

    @Override
    public void createControl(Composite parent) {
        Composite container = new Composite(parent, SWT.NULL);
        GridLayout layout = new GridLayout(2, false);
        container.setLayout(layout);

        Label groupIdLabel = new Label(container, SWT.NULL);
        groupIdLabel.setText("&Group Id:");

        groupIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
        groupIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label artifactIdLabel = new Label(container, SWT.NULL);
        artifactIdLabel.setText("&Artifact Id:");

        artifactIdText = new Text(container, SWT.BORDER | SWT.SINGLE);
        artifactIdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label versionLabel = new Label(container, SWT.NULL);
        versionLabel.setText("&Version:");

        versionText = new Text(container, SWT.BORDER | SWT.SINGLE);
        versionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label packageNameLabel = new Label(container, SWT.NULL);
        packageNameLabel.setText("&Package Prefix:");

        packageNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
        packageNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label thermostatVersionLabel = new Label(container, SWT.NULL);
        thermostatVersionLabel.setText("&Thermostat Version:");

        thermostatVersionText = new Text(container, SWT.BORDER | SWT.SINGLE);
        thermostatVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        checkProjectName();

        setControl(container);
    }

    private void checkProjectName() {
        String projectName = artifactIdText.getText();
        if (projectName.length() == 0) {
            updateStatus("Project name must be specified");
            return;
        }
        if (projectName.replace('\\', '/').indexOf('/', 1) > 0) {
            updateStatus("Project name must be valid");
            return;
        }
        if (projectName.contains(" ")) {
            updateStatus("Project name must be valid");
            return;
        }
        updateStatus(null);
    }

    private void dialogChanged() {
        String packageName = packageNameText.getText();
        if (packageName.length() == 0) {
            updateStatus("Package name must be specified");
            return;
        }
        if (packageName.contains(" ")) {
            updateStatus("Package name must be valid");
            return;
        }
        updateStatus(null);
    }

    private void updateStatus(String message) {
        setErrorMessage(message);
        setPageComplete(message == null);
    }

    public String getGroupId() {
        return groupIdText.getText();
    }

    public String getArtifactId() {
        return artifactIdText.getText();
    }

    public String getVersion() {
        return versionText.getText();
    }

    public String getPackagePrefix() {
        return packageNameText.getText();
        
    }

    public String getThermostatVersion() {
        return thermostatVersionText.getText();
    }

}