protected void restoreState() {
    DesignerToolWindowManager toolManager = DesignerToolWindowManager.getInstance(getProject());

    if (myExpandedState != null) {
      List<RadComponent> expanded = new ArrayList<RadComponent>();
      for (int[] path : myExpandedState) {
        pathToComponent(expanded, myRootComponent, path, 0);
      }
      myExpandedComponents = expanded;
      toolManager.expandFromState();
      myExpandedState = null;
    }

    List<RadComponent> selection = new ArrayList<RadComponent>();

    int[][] selectionState = mySourceSelectionState.get(getEditorText());
    if (selectionState != null) {
      for (int[] path : selectionState) {
        pathToComponent(selection, myRootComponent, path, 0);
      }
    }

    if (selection.isEmpty()) {
      if (mySelectionState != null) {
        for (int[] path : mySelectionState) {
          pathToComponent(selection, myRootComponent, path, 0);
        }
      }
    }

    if (selection.isEmpty()) {
      toolManager.refresh(true);
    } else {
      mySurfaceArea.setSelection(selection);
    }

    mySelectionState = null;
  }
 private void storeSourceSelectionState() {
   mySourceSelectionState.put(getEditorText(), getSelectionState());
 }