StructuredSelection selection = (StructuredSelection) currentSelection;
Iterator<?> iter = selection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof IScriptProject) {
IScriptProject p = (IScriptProject) object;
projects.add(p.getProject());
} else if (object instanceof IProject) {
projects.add((IProject) object);
}
}
}
monitor.beginTask("Updating UIMA Ruta project...", projects.size());
for (IProject each : projects) {
// update old projects
try {
IProjectDescription description = each.getDescription();
String[] natureIds = description.getNatureIds();
int counter = 0;
boolean oldProject = false;
for (String id : Arrays.asList(natureIds)) {
if (id.equals("org.apache.uima.textmarker.ide.nature")) {
natureIds[counter] = RutaNature.NATURE_ID;
oldProject = true;
}
counter++;
}
if (oldProject) {
description.setNatureIds(natureIds);
each.setDescription(description, monitor);
List<File> files = getFiles(new File(each.getLocation().toPortableString()));
for (File file : files) {
String absolutePath = file.getAbsolutePath();
if (file.getName().endsWith(".tm")) {
File newFile = new File(absolutePath.substring(0, absolutePath.length() - 3)
+ ".ruta");
file.renameTo(newFile);
}
}
IScriptProject sp = DLTKCore.create(each);
List<IFolder> scriptFolders = RutaProjectUtils.getScriptFolders(sp);
for (IFolder iFolder : scriptFolders) {
iFolder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}