From 124e02588fb65182d3b600e4c6d02a53771c069a Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Tue, 20 Jun 2017 16:49:26 +0300 Subject: [PATCH] vcs: extract method --- .../openapi/vcs/changes/ui/ChangesBrowserNode.java | 8 ++++++++ .../intellij/openapi/vcs/changes/ui/ChangesTreeList.java | 4 +--- .../intellij/openapi/vcs/changes/ui/TreeModelBuilder.java | 6 ++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java index ca6ca958b1c4..dc3665a6b9ed 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesBrowserNode.java @@ -26,6 +26,7 @@ import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.containers.Convertor; import one.util.streamex.StreamEx; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.tree.DefaultMutableTreeNode; @@ -39,6 +40,8 @@ import java.util.stream.Stream; import static com.intellij.util.FontUtil.spaceAndThinSpace; public class ChangesBrowserNode extends DefaultMutableTreeNode { + @NonNls private static final String ROOT_NODE_VALUE = "root"; + public static final Object IGNORED_FILES_TAG = new Tag("changes.nodetitle.ignored.files"); public static final Object LOCKED_FOLDERS_TAG = new Tag("changes.nodetitle.locked.folders"); public static final Object LOGICALLY_LOCKED_TAG = new Tag("changes.nodetitle.logicallt.locked.folders"); @@ -72,6 +75,11 @@ public class ChangesBrowserNode extends DefaultMutableTreeNode { myAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES; } + @NotNull + public static ChangesBrowserNode createRoot(@NotNull Project project) { + return create(project, ROOT_NODE_VALUE); + } + @NotNull public static ChangesBrowserNode create(@NotNull LocallyDeletedChange change) { return new ChangesBrowserLocallyDeletedNode(change); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java index 838426a0cf96..a00af089a23e 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java @@ -82,8 +82,6 @@ public abstract class ChangesTreeList extends Tree implements TypeSafeDataPro @NotNull private final MyTreeCellRenderer myNodeRenderer; - @NonNls private static final String ROOT = "root"; - @NonNls private final static String FLATTEN_OPTION_KEY = "ChangesBrowser.SHOW_FLATTEN"; @Nullable private final Runnable myInclusionListener; @@ -98,7 +96,7 @@ public abstract class ChangesTreeList extends Tree implements TypeSafeDataPro final boolean highlightProblems, @Nullable final Runnable inclusionListener, @Nullable final ChangeNodeDecorator decorator) { - super(ChangesBrowserNode.create(project, ROOT)); + super(ChangesBrowserNode.createRoot(project)); myProject = project; myShowCheckboxes = showCheckboxes; myHighlightProblems = highlightProblems; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeModelBuilder.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeModelBuilder.java index 941e1492aa83..1c09f68912df 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeModelBuilder.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/TreeModelBuilder.java @@ -41,8 +41,6 @@ import java.util.*; @SuppressWarnings("UnusedReturnValue") public class TreeModelBuilder { - @NonNls private static final String ROOT_NODE_VALUE = "root"; - private static final int UNVERSIONED_MAX_SIZE = 50; @NotNull protected final Project myProject; @@ -74,7 +72,7 @@ public class TreeModelBuilder { public TreeModelBuilder(@NotNull Project project, boolean showFlatten) { myProject = project; myShowFlatten = showFlatten; - myRoot = ChangesBrowserNode.create(myProject, ROOT_NODE_VALUE); + myRoot = ChangesBrowserNode.createRoot(myProject); myModel = new DefaultTreeModel(myRoot); myGroupingPoliciesCache = FactoryMap.createMap(key-> { ChangesGroupingPolicyFactory factory = ChangesGroupingPolicyFactory.getInstance(myProject); @@ -86,7 +84,7 @@ public class TreeModelBuilder { @NotNull public static DefaultTreeModel buildEmpty(@NotNull Project project) { - return new DefaultTreeModel(ChangesBrowserNode.create(project, ROOT_NODE_VALUE)); + return new DefaultTreeModel(ChangesBrowserNode.createRoot(project)); } @NotNull