IOfficeProgressMonitor officeProgressMonitor) {
ArrayList arrayList = new ArrayList();
if (System.getProperty("oo.application.path") != null) {
String path = new File(System.getProperty("oo.application.path"))
.getAbsolutePath();
ILazyApplicationInfo applicationInfo = findLocalApplicationInfo(path);
if (applicationInfo != null)
arrayList.add(applicationInfo);
} else if (System
.getProperty("os.name").toLowerCase().indexOf("windows") != -1) { //$NON-NLS-1$ //$NON-NLS-2$
try {
String[] possibleKeys = getPossibleKeys();
if (officeProgressMonitor != null)
officeProgressMonitor
.beginTask(
Messages
.getString("ApplicationAssistant.monitor_message_scannig_registry"), possibleKeys.length); //$NON-NLS-1$
RegistryKey[] ROOTS = new RegistryKey[] {
Registry.HKEY_CLASSES_ROOT, Registry.HKEY_CURRENT_USER,
Registry.HKEY_LOCAL_MACHINE };
for (int i = 0, n = possibleKeys.length; i < n; i++) {
if (officeProgressMonitor != null)
officeProgressMonitor
.beginSubTask(Messages
.getString(
"ApplicationAssistant.monitor_scanning_key", possibleKeys[i])); //$NON-NLS-1$
for (int j = 0; j < ROOTS.length; j++) {
RegistryKey registryKey = Registry.openSubkey(ROOTS[j],
possibleKeys[i], RegistryKey.ACCESS_READ);
if (registryKey != null) {
String path = null;
if (path == null) {
try {
path = registryKey.getStringValue("Path");
path = "\"" + path + "\"";
} catch (NoSuchValueException noSuchValueException) {
// ignore
}
}
if (path == null) {
try {
path = registryKey.getDefaultValue();
} catch (NoSuchValueException noSuchValueException) {
// ignore
}
}
if (path != null) {
int position = path
.indexOf(APPLICATION_EXECUTEABLE);
if (position != -1) {
path = path.substring(1, position - 9);
ILazyApplicationInfo applicationInfo = findLocalApplicationInfo(path);
if (applicationInfo != null) {
boolean found = false;
for (Iterator iterator = arrayList
.iterator(); iterator.hasNext();) {
ILazyApplicationInfo tmpApplicationInfo = (ILazyApplicationInfo) iterator
.next();
if (tmpApplicationInfo.getHome()
.equalsIgnoreCase(
applicationInfo
.getHome())) {
found = true;
break;
}
}
if (!found)
arrayList.add(applicationInfo);
}
}
}
}
}
if (officeProgressMonitor != null)
if (officeProgressMonitor.isCanceled())
break;
}
} catch (Throwable throwable) {
return ILazyApplicationInfo.EMPTY_LAZY_APPLICATION_INFOS_ARRAY;
}
} else {
try {
if (officeProgressMonitor != null)
officeProgressMonitor
.beginTask(
Messages
.getString("ApplicationAssistant.monitor_looking_for_office_application"), IOfficeProgressMonitor.WORK_UNKNOWN); //$NON-NLS-1$
ArrayList possibleOfficeHomes = new ArrayList();
File file = new File("/opt"); //$NON-NLS-1$
findPossibleOfficeHomes(officeProgressMonitor, file,
possibleOfficeHomes);
file = new File("/usr"); //$NON-NLS-1$
findPossibleOfficeHomes(officeProgressMonitor, file,
possibleOfficeHomes);
if (officeProgressMonitor != null)
officeProgressMonitor
.beginSubTask(Messages
.getString("ApplicationAssistant.monitor_buildung_application_infos")); //$NON-NLS-1$
String[] officeHomes = (String[]) possibleOfficeHomes
.toArray(new String[possibleOfficeHomes.size()]);
for (int i = 0, n = officeHomes.length; i < n; i++) {
ILazyApplicationInfo applicationInfo = findLocalApplicationInfo(officeHomes[i]);
if (applicationInfo != null)
arrayList.add(applicationInfo);
}
} catch (Throwable throwable) {
return ILazyApplicationInfo.EMPTY_LAZY_APPLICATION_INFOS_ARRAY;