本文整理匯總了Java中org.netbeans.modules.maven.api.archetype.ArchetypeProvider類的典型用法代碼示例。如果您正苦於以下問題:Java ArchetypeProvider類的具體用法?Java ArchetypeProvider怎麽用?Java ArchetypeProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ArchetypeProvider類屬於org.netbeans.modules.maven.api.archetype包,在下文中一共展示了ArchetypeProvider類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addNotify
import org.netbeans.modules.maven.api.archetype.ArchetypeProvider; //導入依賴的package包/類
@Override
public void addNotify() {
super.addNotify();
if (archetypes.isEmpty()) {
listArtifact.setCursor(Utilities.createProgressCursor(listArtifact));
RP.post(new Runnable() {
@Override public void run() {
for (ArchetypeProvider provider : Lookup.getDefault().lookupAll(ArchetypeProvider.class)) {
final List<Archetype> added = provider.getArchetypes();
LOG.log(Level.FINE, "{0} -> {1}", new Object[] {provider, added});
Collections.sort(added, new Comparator<Archetype>() {
@Override
public int compare(Archetype o1, Archetype o2) {
int c = o1.getArtifactId().compareTo(o2.getArtifactId());
if(c != 0) {
return c;
}
String v1 = o1.getVersion();
String v2 = o2.getVersion();
if(v1 == null && v2 == null) {
return 0;
} else if(v1 == null) {
return 1;
} else if(v2 == null) {
return -1;
}
return new DefaultArtifactVersion(v1).compareTo(new DefaultArtifactVersion(v2)) * -1;
}
});
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
archetypes.addAll(added);
updateList();
}
});
}
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
listArtifact.setCursor(null);
if (listArtifact.getSelectedIndex() == -1 && listArtifact.getModel().getSize() > 0) {
listArtifact.setSelectedIndex(0);
}
}
});
}
});
}
}
示例2: getLatestArchetype
import org.netbeans.modules.maven.api.archetype.ArchetypeProvider; //導入依賴的package包/類
private static Archetype getLatestArchetype( String artifactId,
int minVersion, List<String> versions )
{
Archetype result = null;
for (ArchetypeProvider provider : Lookup.getDefault().lookupAll(
ArchetypeProvider.class))
{
final List<Archetype> archetypes = provider.getArchetypes();
for (Archetype archetype : archetypes) {
if (GROUP_ID.equals(archetype.getGroupId())
&& artifactId.equals(archetype.getArtifactId()))
{
String archVersion = archetype.getVersion();
String version = archVersion;
LOG.log(Level.FINE,
"Found archetype with appropriate group id "
+ "and artifactId: {0}. It''s version : {1}",
new Object[] { artifactId, archVersion });
int index = archVersion.indexOf('.');
int majorVersion = 0;
try {
if (index > -1) {
version = archVersion.substring(0, index);
}
majorVersion = Integer.parseInt(version);
}
catch (NumberFormatException ignore) {
LOG.log(Level.WARNING, "Unable to parse version :{0}",
version);
}
if (majorVersion >= minVersion) {
if (versions != null) {
versions.add(archVersion);
}
if (result == null) {
result = archetype;
}
else if (version.compareTo(result.getVersion()) > 0) {
result = archetype;
}
}
else {
LOG.log(Level.FINE,
"Found archetype version {0} is skipped. "
+ "It''s less than default version {1}",
new Object[] { version, minVersion });
}
}
}
}
return result;
}