private static void restoreState() { fgLRUWorkingSets = new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE); IDialogSettings settingsStore = getDialogStoreSection(); boolean foundLRU = false; for (int i = LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) { String[] lruWorkingSetNames = settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES + i); if (lruWorkingSetNames != null) { Set workingSets = new HashSet(2); for (int j = 0; j < lruWorkingSetNames.length; j++) { IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[j]); if (workingSet != null) { workingSets.add(workingSet); } } foundLRU = true; if (!workingSets.isEmpty()) fgLRUWorkingSets.add( (IWorkingSet[]) workingSets.toArray(new IWorkingSet[workingSets.size()])); } } if (!foundLRU) // try old preference format restoreFromOldFormat(); }
private static void restoreFromOldFormat() { fgLRUWorkingSets = new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE); IDialogSettings settingsStore = getDialogStoreSection(); boolean foundLRU = false; String[] lruWorkingSetNames = settingsStore.getArray(STORE_LRU_WORKING_SET_NAMES); if (lruWorkingSetNames != null) { for (int i = lruWorkingSetNames.length - 1; i >= 0; i--) { IWorkingSet workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[i]); if (workingSet != null) { foundLRU = true; fgLRUWorkingSets.add(new IWorkingSet[] {workingSet}); } } } if (foundLRU) // save in new format saveState(settingsStore); }