mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Improvements based on code review (IDEA-CR-32474)
Add and use LocalChangeList.isBlank(), delete VcsDataKeys.CHANGES_IN_LIST, hide single default CL from scope chooser
This commit is contained in:
+11
-3
@@ -3,8 +3,11 @@ package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.ChangeList;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.psi.search.scope.packageSet.CustomScopesProviderEx;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -37,8 +40,13 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx {
|
||||
|
||||
final List<NamedScope> result = new ArrayList<>();
|
||||
result.add(new ChangeListScope(changeListManager));
|
||||
for (ChangeList list : changeListManager.getChangeListsCopy()) {
|
||||
result.add(new ChangeListScope(changeListManager, list.getName()));
|
||||
List<LocalChangeList> changeLists = changeListManager.getChangeListsCopy();
|
||||
boolean skipSingleDefaultCL = Registry.is("vcs.skip.single.default.changelist") &&
|
||||
changeLists.size() == 1 && changeLists.get(0).isBlank();
|
||||
if (!skipSingleDefaultCL) {
|
||||
for (ChangeList list : changeLists) {
|
||||
result.add(new ChangeListScope(changeListManager, list.getName()));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
@@ -54,7 +40,6 @@ public interface VcsDataKeys {
|
||||
DataKey<ListSelection<Change>> CHANGES_SELECTION = DataKey.create("vcs.ChangesSelection");
|
||||
DataKey<Change[]> CHANGES_WITH_MOVED_CHILDREN = DataKey.create("ChangeListView.ChangesWithDetails");
|
||||
DataKey<Change[]> SELECTED_CHANGES_IN_DETAILS = DataKey.create("ChangeListView.SelectedChangesWithMovedSubtrees");
|
||||
@NonNls DataKey<List<Change>> CHANGES_IN_LIST_KEY = DataKey.create("ChangeListView.ChangesInList");
|
||||
@NonNls DataKey<List<VirtualFile>> MODIFIED_WITHOUT_EDITING_DATA_KEY = DataKey.create("ChangeListView.ModifiedWithoutEditing");
|
||||
@NonNls DataKey<Boolean> HAVE_MODIFIED_WITHOUT_EDITING = DataKey.create("ChangeListView.HaveModifiedWithoutEditing");
|
||||
@NonNls DataKey<Boolean> HAVE_LOCALLY_DELETED = DataKey.create("ChangeListView.HaveLocallyDeleted");
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.openapi.vcs.changes;
|
||||
|
||||
@@ -69,6 +55,9 @@ public abstract class LocalChangeList implements Cloneable, ChangeList {
|
||||
return DEFAULT_NAME.equals(getName());
|
||||
}
|
||||
|
||||
public boolean isBlank() {
|
||||
return hasDefaultName() && getData() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@link ChangeListManager#editName}
|
||||
|
||||
@@ -203,15 +203,6 @@ public class ChangesListView extends Tree implements TypeSafeDataProvider, DnDAw
|
||||
else if (key == PlatformDataKeys.HELP_ID) {
|
||||
sink.put(PlatformDataKeys.HELP_ID, HELP_ID);
|
||||
}
|
||||
else if (key == VcsDataKeys.CHANGES_IN_LIST_KEY) {
|
||||
final TreePath selectionPath = getSelectionPath();
|
||||
if (selectionPath != null && selectionPath.getPathCount() > 1) {
|
||||
ChangesBrowserNode<?> firstNode = (ChangesBrowserNode)selectionPath.getPathComponent(1);
|
||||
if (firstNode instanceof ChangesBrowserChangeListNode) {
|
||||
sink.put(VcsDataKeys.CHANGES_IN_LIST_KEY, firstNode.getAllChangesUnder());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key == ChangesGroupingSupport.KEY) {
|
||||
sink.put(ChangesGroupingSupport.KEY, myGroupingSupport);
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public class MultipleLocalChangeListsBrowser extends CommitDialogChangesBrowser
|
||||
|
||||
if (Registry.is("vcs.skip.single.default.changelist")) {
|
||||
List<LocalChangeList> allChangeLists = ChangeListManager.getInstance(project).getChangeLists();
|
||||
if (allChangeLists.size() == 1 && LocalChangeList.DEFAULT_NAME.equals(allChangeLists.get(0).getName())) {
|
||||
if (allChangeLists.size() == 1 && allChangeLists.get(0).isBlank()) {
|
||||
myChangeListChooser.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +189,7 @@ public class TreeModelBuilder {
|
||||
@NotNull
|
||||
public TreeModelBuilder setChangeLists(@NotNull Collection<? extends ChangeList> changeLists, boolean skipSingleDefaultChangeList) {
|
||||
final RemoteRevisionsCache revisionsCache = RemoteRevisionsCache.getInstance(myProject);
|
||||
boolean skipChangeListNode = skipSingleDefaultChangeList && changeLists.size() == 1 &&
|
||||
LocalChangeList.DEFAULT_NAME.equals(changeLists.iterator().next().getName());
|
||||
boolean skipChangeListNode = skipSingleDefaultChangeList && isSingleBlankChangeList(changeLists);
|
||||
for (ChangeList list : changeLists) {
|
||||
List<Change> changes = sorted(list.getChanges(), CHANGE_COMPARATOR);
|
||||
ChangeListRemoteState listRemoteState = new ChangeListRemoteState(changes.size());
|
||||
@@ -216,6 +215,13 @@ public class TreeModelBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static boolean isSingleBlankChangeList(Collection<? extends ChangeList> lists) {
|
||||
if (lists.size() != 1) return false;
|
||||
ChangeList single = lists.iterator().next();
|
||||
if (!(single instanceof LocalChangeList)) return false;
|
||||
return ((LocalChangeList) single).isBlank();
|
||||
}
|
||||
|
||||
protected ChangesBrowserNode createChangeNode(Change change, ChangeNodeDecorator decorator) {
|
||||
return new ChangesBrowserChangeNode(myProject, change, decorator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user