public void updateModel(
      List<? extends ChangeList> changeLists,
      Trinity<List<VirtualFile>, Integer, Integer> unversionedFiles,
      final List<LocallyDeletedChange> locallyDeletedFiles,
      List<VirtualFile> modifiedWithoutEditing,
      MultiMap<String, VirtualFile> switchedFiles,
      @Nullable Map<VirtualFile, String> switchedRoots,
      @Nullable List<VirtualFile> ignoredFiles,
      final List<VirtualFile> lockedFolders,
      @Nullable final Map<VirtualFile, LogicalLock> logicallyLockedFiles) {
    TreeModelBuilder builder = new TreeModelBuilder(myProject, isShowFlatten());
    final DefaultTreeModel model =
        builder.buildModel(
            changeLists,
            unversionedFiles,
            locallyDeletedFiles,
            modifiedWithoutEditing,
            switchedFiles,
            switchedRoots,
            ignoredFiles,
            lockedFolders,
            logicallyLockedFiles);

    storeState();
    DefaultTreeModel oldModel = getModel();
    setModel(model);
    setCellRenderer(new ChangesBrowserNodeRenderer(myProject, isShowFlatten(), true));
    ChangesBrowserNode root = (ChangesBrowserNode) model.getRoot();
    expandPath(new TreePath(root.getPath()));
    restoreState();
    expandDefaultChangeList(oldModel, root);
  }
 public void selectOptionByName(@NotNull final String optionName) {
   selectPath(
       findOption(
           myTreeModel.getRoot(),
           new DescriptorMatcher() {
             @Override
             public boolean matches(@NotNull Object data) {
               return !optionName.isEmpty()
                   && StringUtil.containsIgnoreCase(data.toString(), optionName);
             }
           }));
 }
 public void selectOptionByType(@NotNull final String attributeType) {
   selectPath(
       findOption(
           myTreeModel.getRoot(),
           new DescriptorMatcher() {
             @Override
             public boolean matches(@NotNull Object data) {
               if (data instanceof EditorSchemeAttributeDescriptor) {
                 return attributeType.equals(((EditorSchemeAttributeDescriptor) data).getType());
               }
               return false;
             }
           }));
 }
  private void expandDefaultChangeList(DefaultTreeModel oldModel, ChangesBrowserNode root) {
    if (((ChangesBrowserNode) oldModel.getRoot()).getCount() == 0
        && TreeUtil.collectExpandedPaths(this).size() == 1) {
      TreeNode toExpand = null;
      for (int i = 0; i < root.getChildCount(); i++) {
        TreeNode node = root.getChildAt(i);
        if (node instanceof ChangesBrowserChangeListNode && node.getChildCount() > 0) {
          ChangeList object = ((ChangesBrowserChangeListNode) node).getUserObject();
          if (object instanceof LocalChangeList) {
            if (((LocalChangeList) object).isDefault()) {
              toExpand = node;
              break;
            }
          }
        }
      }

      if (toExpand != null) {
        expandPath(new TreePath(new Object[] {root, toExpand}));
      }
    }
  }
 protected DefaultMutableTreeNode getRootNode() {
   return (DefaultMutableTreeNode) myTreeModel.getRoot();
 }
Beispiel #6
0
 public static void sort(final DefaultTreeModel model, final Comparator comparator) {
   sort((DefaultMutableTreeNode) model.getRoot(), comparator);
 }