Search in sources :

Example 1 with RequiredProperty

use of org.apache.maven.archetype.metadata.RequiredProperty in project sling by apache.

the class ArchetypeParametersWizardPage method initialize.

@SuppressWarnings("unchecked")
private void initialize() {
    if (propertiesTable == null) {
        return;
    }
    Archetype archetype = parent.getChooseArchetypePage().getSelectedArchetype();
    if (archetype == null) {
        return;
    }
    try {
        ArchetypeManager archetypeManager = MavenPluginActivator.getDefault().getArchetypeManager();
        ArtifactRepository remoteArchetypeRepository = archetypeManager.getArchetypeRepository(archetype);
        properties = (List<RequiredProperty>) archetypeManager.getRequiredProperties(archetype, remoteArchetypeRepository, null);
        Table table = propertiesViewer.getTable();
        table.setItemCount(properties.size());
        int i = 0;
        for (Iterator<RequiredProperty> it = properties.iterator(); it.hasNext(); ) {
            RequiredProperty rp = it.next();
            TableItem item = table.getItem(i++);
            if (!rp.getKey().equals(item.getText())) {
                // then create it - otherwise, reuse it
                item.setText(0, rp.getKey());
                item.setText(1, "");
                item.setData(item);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException("Could not process archetype: " + e.getMessage(), e);
    }
}
Also used : ArchetypeManager(org.eclipse.m2e.core.internal.archetype.ArchetypeManager) Table(org.eclipse.swt.widgets.Table) Archetype(org.apache.maven.archetype.catalog.Archetype) RequiredProperty(org.apache.maven.archetype.metadata.RequiredProperty) TableItem(org.eclipse.swt.widgets.TableItem) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository)

Aggregations

Archetype (org.apache.maven.archetype.catalog.Archetype)1 RequiredProperty (org.apache.maven.archetype.metadata.RequiredProperty)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 ArchetypeManager (org.eclipse.m2e.core.internal.archetype.ArchetypeManager)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1