コード例 #1
0
  @Nullable
  @SuppressWarnings({"HardCodedStringLiteral"})
  private JPanel readExternalPanel(
      final Element element, @Nullable JPanel panel, Ref<EditorWindow> currentWindow) {
    final Element splitterElement = element.getChild("splitter");
    if (splitterElement != null) {
      return readSplitter(panel, splitterElement, currentWindow);
    }

    final Element leaf = element.getChild("leaf");
    if (leaf == null) {
      return null;
    }

    EditorWindow window = (panel == null) ? new EditorWindow(this) : findWindowWith(panel);
    LOG.assertTrue(window != null);

    @SuppressWarnings("unchecked")
    final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file"));
    if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) {
      Collections.reverse(children);
    }

    VirtualFile currentFile = null;
    for (final Element file : children) {
      try {
        final HistoryEntry entry =
            new HistoryEntry(getManager().getProject(), file.getChild(HistoryEntry.TAG), true);
        boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue();
        getManager().openFileImpl3(window, entry.myFile, false, entry, isCurrent);
        if (getManager().isFileOpen(entry.myFile)) {
          window.setFilePinned(
              entry.myFile, Boolean.valueOf(file.getAttributeValue("pinned")).booleanValue());
          if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) {
            currentFile = entry.myFile;
          }
        }
      } catch (InvalidDataException e) {
        // OK
      }
    }
    if (currentFile != null) {
      final EditorComposite editor = window.findFileComposite(currentFile);
      if (editor != null) {
        window.setSelectedEditor(editor, true);
      }
    }
    return window.myPanel;
  }
コード例 #2
0
  @Nullable
  @SuppressWarnings({"HardCodedStringLiteral"})
  private JPanel readExternalPanel(
      final Element element, @Nullable JPanel panel, Ref<EditorWindow> currentWindow) {
    final Element splitterElement = element.getChild("splitter");
    if (splitterElement != null) {
      return readSplitter(panel, splitterElement, currentWindow);
    }

    final Element leaf = element.getChild("leaf");
    if (leaf == null) {
      return null;
    }

    final EditorWindow window = panel == null ? new EditorWindow(this) : findWindowWith(panel);
    LOG.assertTrue(window != null);

    @SuppressWarnings("unchecked")
    final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file"));
    if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) {
      Collections.reverse(children);
    }

    // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy
    for (Iterator<Element> iterator = children.iterator();
        iterator.hasNext() && UISettings.getInstance().EDITOR_TAB_LIMIT < children.size(); ) {
      Element child = iterator.next();
      if (!Boolean.valueOf(child.getAttributeValue(PINNED)).booleanValue()) {
        iterator.remove();
      }
    }

    VirtualFile currentFile = null;
    for (int i = 0; i < children.size(); i++) {
      final Element file = children.get(i);
      try {
        final FileEditorManagerImpl fileEditorManager = getManager();
        final HistoryEntry entry =
            new HistoryEntry(fileEditorManager.getProject(), file.getChild(HistoryEntry.TAG), true);
        final boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue();
        fileEditorManager.openFileImpl4(window, entry.myFile, false, entry, isCurrent, i);
        if (fileEditorManager.isFileOpen(entry.myFile)) {
          window.setFilePinned(
              entry.myFile, Boolean.valueOf(file.getAttributeValue(PINNED)).booleanValue());
          if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) {
            currentFile = entry.myFile;
          }
        }

      } catch (InvalidDataException e) {
        if (ApplicationManager.getApplication().isUnitTestMode()) {
          LOG.error(e);
        }
      }
    }
    if (currentFile != null) {
      final EditorComposite editor = window.findFileComposite(currentFile);
      if (editor != null) {
        window.setSelectedEditor(editor, true);
      }
    }
    return window.myPanel;
  }