示例#1
0
  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();
  }
示例#2
0
 private static void saveState(IDialogSettings settingsStore) {
   IWorkingSet[] workingSets;
   Iterator iter = fgLRUWorkingSets.iterator();
   int i = 0;
   while (iter.hasNext()) {
     workingSets = (IWorkingSet[]) iter.next();
     String[] names = new String[workingSets.length];
     for (int j = 0; j < workingSets.length; j++) names[j] = workingSets[j].getName();
     settingsStore.put(STORE_LRU_WORKING_SET_NAMES + i, names);
     i++;
   }
 }
示例#3
0
  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);
  }