mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: 51caede4b10ad2891cea69ab898530b1f4e85563
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a8db72d2d5
commit
58a24eac54
+8
-25
@@ -1,19 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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-2021 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.roots.ui.configuration;
|
||||
|
||||
import com.intellij.ide.JavaUiBundle;
|
||||
@@ -24,13 +9,13 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SimpleJavaSdkType;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.JdkConfigurable;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.MasterDetailsStateService;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.ui.JBSplitter;
|
||||
@@ -44,9 +29,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.openapi.projectRoots.SimpleJavaSdkType.notSimpleJavaSdkType;
|
||||
|
||||
public class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
public final class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
private final ProjectSdksModel myProjectJdksModel;
|
||||
private final Project myProject;
|
||||
|
||||
@@ -115,7 +98,7 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
super.apply();
|
||||
boolean modifiedJdks = false;
|
||||
for (int i = 0; i < myRoot.getChildCount(); i++) {
|
||||
final NamedConfigurable configurable = ((MyNode)myRoot.getChildAt(i)).getConfigurable();
|
||||
final NamedConfigurable<?> configurable = ((MyNode)myRoot.getChildAt(i)).getConfigurable();
|
||||
if (configurable.isModified()) {
|
||||
configurable.apply();
|
||||
modifiedJdks = true;
|
||||
@@ -160,9 +143,9 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
myProjectJdksModel.createAddActions(group, myTree, projectJdk -> {
|
||||
addNode(new MyNode(new JdkConfigurable(((ProjectJdkImpl)projectJdk), myProjectJdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot);
|
||||
selectNodeInTree(findNodeByObject(myRoot, projectJdk));
|
||||
}, notSimpleJavaSdkType());
|
||||
}, SimpleJavaSdkType.notSimpleJavaSdkType());
|
||||
actions.add(new MyActionGroupWrapper(group));
|
||||
actions.add(new MyDeleteAction(Conditions.alwaysTrue()));
|
||||
actions.add(new MyDeleteAction());
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -171,7 +154,7 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
final Set<Sdk> jdks = new HashSet<>();
|
||||
for(int i = 0; i < myRoot.getChildCount(); i++){
|
||||
final DefaultMutableTreeNode node = (DefaultMutableTreeNode)myRoot.getChildAt(i);
|
||||
final NamedConfigurable namedConfigurable = (NamedConfigurable)node.getUserObject();
|
||||
final NamedConfigurable<?> namedConfigurable = (NamedConfigurable<?>)node.getUserObject();
|
||||
jdks.add(((JdkConfigurable)namedConfigurable).getEditableObject());
|
||||
}
|
||||
final HashMap<Sdk, Sdk> sdks = new HashMap<>(myProjectJdksModel.getProjectSdks());
|
||||
@@ -210,7 +193,7 @@ public class ProjectJdksConfigurable extends MasterDetailsComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NlsContexts.StatusText @Nullable String getEmptySelectionString() {
|
||||
protected @NlsContexts.StatusText @NotNull String getEmptySelectionString() {
|
||||
return JavaUiBundle.message("project.jdks.configurable.empty.selection.string");
|
||||
}
|
||||
|
||||
|
||||
+8
-16
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.ui.MasterDetailsState;
|
||||
import com.intellij.openapi.ui.MasterDetailsStateService;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.NlsActions;
|
||||
import com.intellij.ui.TreeSpeedSearch;
|
||||
@@ -37,6 +36,7 @@ import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class BaseStructureConfigurable extends MasterDetailsComponent implements SearchableConfigurable, Disposable, Place.Navigator {
|
||||
protected StructureConfigurableContext myContext;
|
||||
@@ -90,15 +90,8 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
|
||||
if (node == null && nodeByName == null) return ActionCallback.DONE;
|
||||
|
||||
final NamedConfigurable config;
|
||||
if (node != null) {
|
||||
config = node.getConfigurable();
|
||||
} else {
|
||||
config = nodeByName.getConfigurable();
|
||||
}
|
||||
|
||||
final ActionCallback result = new ActionCallback().doWhenDone(() -> myAutoScrollEnabled = true);
|
||||
|
||||
NamedConfigurable<?> config = Objects.requireNonNullElse(node, nodeByName).getConfigurable();
|
||||
ActionCallback result = new ActionCallback().doWhenDone(() -> myAutoScrollEnabled = true);
|
||||
myAutoScrollEnabled = false;
|
||||
myAutoScrollHandler.cancelAllRequests();
|
||||
final MyNode nodeToSelect = node != null ? node : nodeByName;
|
||||
@@ -311,12 +304,11 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
return null;
|
||||
}
|
||||
|
||||
protected class MyRemoveAction extends MyDeleteAction {
|
||||
public MyRemoveAction() {
|
||||
//noinspection Convert2Lambda
|
||||
super(new Condition<>() {
|
||||
final class MyRemoveAction extends MyDeleteAction {
|
||||
MyRemoveAction() {
|
||||
super(new Predicate<>() {
|
||||
@Override
|
||||
public boolean value(final Object[] objects) {
|
||||
public boolean test(final Object[] objects) {
|
||||
List<MyNode> nodes = new ArrayList<>();
|
||||
for (Object object : objects) {
|
||||
if (!(object instanceof MyNode)) return false;
|
||||
|
||||
+13
-12
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.codeInsight.generation.ui;
|
||||
|
||||
import com.intellij.codeInsight.generation.EqualsHashCodeTemplatesManager;
|
||||
@@ -13,7 +13,6 @@ import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import gnu.trove.Equality;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -26,8 +25,9 @@ import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
public class EqualsHashCodeTemplatesPanel extends NamedItemsListEditor<Couple<TemplateResource>> {
|
||||
public final class EqualsHashCodeTemplatesPanel extends NamedItemsListEditor<Couple<TemplateResource>> {
|
||||
private static final Namer<Couple<TemplateResource>> NAMER = new Namer<>() {
|
||||
|
||||
@Override
|
||||
@@ -70,16 +70,17 @@ public class EqualsHashCodeTemplatesPanel extends NamedItemsListEditor<Couple<Te
|
||||
}
|
||||
};
|
||||
|
||||
private static final Equality<Couple<TemplateResource>> COMPARER = new Equality<>() {
|
||||
@Override
|
||||
public boolean equals(Couple<TemplateResource> o1, Couple<TemplateResource> o2) {
|
||||
return equals(o1.first, o2.first) && equals(o1.second, o2.second);
|
||||
}
|
||||
private static final BiPredicate<Pair<TemplateResource, TemplateResource>, Pair<TemplateResource, TemplateResource>> COMPARER =
|
||||
new BiPredicate<>() {
|
||||
@Override
|
||||
public boolean test(Pair<TemplateResource, TemplateResource> o1, Pair<TemplateResource, TemplateResource> o2) {
|
||||
return equals(o1.first, o2.first) && equals(o1.second, o2.second);
|
||||
}
|
||||
|
||||
private boolean equals(TemplateResource r1, TemplateResource r2) {
|
||||
return Objects.equals(r1.getTemplate(), r2.getTemplate()) && Objects.equals(r1.getFileName(), r2.getFileName());
|
||||
}
|
||||
};
|
||||
private boolean equals(TemplateResource r1, TemplateResource r2) {
|
||||
return Objects.equals(r1.getTemplate(), r2.getTemplate()) && Objects.equals(r1.getFileName(), r2.getFileName());
|
||||
}
|
||||
};
|
||||
private final Project myProject;
|
||||
private final EqualsHashCodeTemplatesManager myManager;
|
||||
|
||||
|
||||
+6
-5
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.application.options.codeStyle.arrangement.match.tokens;
|
||||
|
||||
import com.intellij.application.options.codeStyle.arrangement.color.ArrangementColorsProvider;
|
||||
@@ -13,7 +13,6 @@ import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.ArrangementStandardSettingsManager;
|
||||
import com.intellij.psi.codeStyle.arrangement.std.StdArrangementRuleAliasToken;
|
||||
import gnu.trove.Equality;
|
||||
import org.jdom.Verifier;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -22,11 +21,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
/**
|
||||
* @author Svetlana.Zemlyanskaya
|
||||
*/
|
||||
public class ArrangementRuleAliasesListEditor extends NamedItemsListEditor<StdArrangementRuleAliasToken> {
|
||||
public final class ArrangementRuleAliasesListEditor extends NamedItemsListEditor<StdArrangementRuleAliasToken> {
|
||||
private static final Namer<StdArrangementRuleAliasToken> NAMER = new Namer<>() {
|
||||
@Override
|
||||
public String getName(StdArrangementRuleAliasToken token) {
|
||||
@@ -55,13 +55,14 @@ public class ArrangementRuleAliasesListEditor extends NamedItemsListEditor<StdAr
|
||||
return new StdArrangementRuleAliasToken(original.getName(), original.getDefinitionRules());
|
||||
}
|
||||
};
|
||||
private static final Equality<StdArrangementRuleAliasToken> COMPARER = (o1, o2) -> Objects.equals(o1.getId(), o2.getId());
|
||||
private static final BiPredicate<StdArrangementRuleAliasToken, StdArrangementRuleAliasToken>
|
||||
COMPARER = (o1, o2) -> Objects.equals(o1.getId(), o2.getId());
|
||||
|
||||
@NotNull private final Set<String> myUsedTokenIds;
|
||||
@NotNull private final ArrangementStandardSettingsManager mySettingsManager;
|
||||
@NotNull private final ArrangementColorsProvider myColorsProvider;
|
||||
|
||||
protected ArrangementRuleAliasesListEditor(@NotNull ArrangementStandardSettingsManager settingsManager,
|
||||
ArrangementRuleAliasesListEditor(@NotNull ArrangementStandardSettingsManager settingsManager,
|
||||
@NotNull ArrangementColorsProvider colorsProvider,
|
||||
@NotNull List<StdArrangementRuleAliasToken> items,
|
||||
@NotNull Set<String> usedTokenIds) {
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
<orderEntry type="library" name="rd-framework" level="project" />
|
||||
<orderEntry type="library" name="rd-swing" level="project" />
|
||||
<orderEntry type="library" name="fastutil-min" level="project" />
|
||||
<orderEntry type="library" name="Trove4j" level="project" />
|
||||
<orderEntry type="library" name="icu4j" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="netty-buffer" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.codeStyle" />
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.execution.ParametersListUtil;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.XMap;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -95,7 +94,7 @@ public final class ChromeSettings extends BrowserSpecificSettings {
|
||||
@Override
|
||||
public ChromeSettings clone() {
|
||||
ChromeSettings clone = (ChromeSettings)super.clone();
|
||||
clone.myEnvironmentVariables = new THashMap<>(myEnvironmentVariables);
|
||||
clone.myEnvironmentVariables = new HashMap<>(myEnvironmentVariables);
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.ide.nls;
|
||||
|
||||
import com.ibm.icu.number.FormattedNumber;
|
||||
@@ -11,8 +11,8 @@ import com.ibm.icu.util.Measure;
|
||||
import com.ibm.icu.util.MeasureUnit;
|
||||
import com.intellij.DynamicBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import gnu.trove.TLongArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,7 +43,7 @@ public class NlsMessages {
|
||||
|
||||
/**
|
||||
* @param list list of items
|
||||
* @return localized narrow string representation of all items in the list with conjunction formatting.
|
||||
* @return localized narrow string representation of all items in the list with conjunction formatting.
|
||||
* In narrow representation the conjunction could be omitted.
|
||||
* E.g. formatAndList(List.of("X", "Y", "Z")) will produce "X, Y, Z" in English locale.
|
||||
*/
|
||||
@@ -82,8 +82,8 @@ public class NlsMessages {
|
||||
*/
|
||||
public static <T> @NotNull Collector<T, ?, @Nls String> joiningOr() {
|
||||
return Collectors.collectingAndThen(Collectors.toList(), NlsMessages::formatOrList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats duration given in milliseconds as a sum of time units with at most two units
|
||||
* (example: {@code formatDuration(123456) = "2 m, 3 s"}).
|
||||
@@ -92,7 +92,7 @@ public class NlsMessages {
|
||||
public static @NotNull @Nls String formatDurationApproximate(long duration) {
|
||||
return formatDuration(duration, 2, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats duration given in milliseconds as a sum of time units with at most two units
|
||||
* (example: {@code formatDuration(123456) = "2 m 3 s"}).
|
||||
@@ -102,7 +102,7 @@ public class NlsMessages {
|
||||
return formatDuration(duration, 2, true);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Formats duration given in milliseconds as a sum of time units (example: {@code formatDuration(123456, "") = "2m 3s 456ms"}).
|
||||
* The result is localized according to the currently used language pack.
|
||||
*/
|
||||
@@ -113,8 +113,8 @@ public class NlsMessages {
|
||||
|
||||
@Contract(pure = true)
|
||||
private static @NotNull @Nls String formatDuration(long duration, int maxFragments, boolean narrow) {
|
||||
TLongArrayList unitValues = new TLongArrayList();
|
||||
TIntArrayList unitIndices = new TIntArrayList();
|
||||
LongArrayList unitValues = new LongArrayList();
|
||||
IntArrayList unitIndices = new IntArrayList();
|
||||
|
||||
long count = duration;
|
||||
int i = 1;
|
||||
@@ -124,19 +124,19 @@ public class NlsMessages {
|
||||
long remainder = count % multiplier;
|
||||
count /= multiplier;
|
||||
if (remainder != 0 || !unitValues.isEmpty()) {
|
||||
unitValues.insert(0, remainder);
|
||||
unitIndices.insert(0, i - 1);
|
||||
unitValues.add(0, remainder);
|
||||
unitIndices.add(0, i - 1);
|
||||
}
|
||||
}
|
||||
unitValues.insert(0, count);
|
||||
unitIndices.insert(0, i - 1);
|
||||
unitValues.add(0, count);
|
||||
unitIndices.add(0, i - 1);
|
||||
|
||||
if (unitValues.size() > maxFragments) {
|
||||
int lastUnitIndex = unitIndices.get(maxFragments - 1);
|
||||
int lastUnitIndex = unitIndices.getInt(maxFragments - 1);
|
||||
long lastMultiplier = TIME_MULTIPLIERS[lastUnitIndex];
|
||||
// Round up if needed
|
||||
if (unitValues.get(maxFragments) > lastMultiplier / 2) {
|
||||
long increment = lastMultiplier - unitValues.get(maxFragments);
|
||||
if (unitValues.getLong(maxFragments) > lastMultiplier / 2) {
|
||||
long increment = lastMultiplier - unitValues.getLong(maxFragments);
|
||||
for (int unit = lastUnitIndex - 1; unit > 0; unit--) {
|
||||
increment *= TIME_MULTIPLIERS[unit];
|
||||
}
|
||||
@@ -149,14 +149,14 @@ public class NlsMessages {
|
||||
List<String> fragments = new ArrayList<>();
|
||||
LocalizedNumberFormatter formatter = NumberFormatter.withLocale(DynamicBundle.getLocale()).unitWidth(NumberFormatter.UnitWidth.SHORT);
|
||||
for (i = 0; i < finalCount; i++) {
|
||||
fragments.add(formatter.unit(TIME_UNITS[unitIndices.get(i)]).format(unitValues.get(i)).toString().replace(' ', '\u2009'));
|
||||
fragments.add(formatter.unit(TIME_UNITS[unitIndices.getInt(i)]).format(unitValues.getLong(i)).toString().replace(' ', '\u2009'));
|
||||
}
|
||||
return StringUtil.join(fragments, " ");
|
||||
}
|
||||
MeasureFormat format = MeasureFormat.getInstance(DynamicBundle.getLocale(), MeasureFormat.FormatWidth.SHORT);
|
||||
Measure[] measures = new Measure[finalCount];
|
||||
for (i = 0; i < finalCount; i++) {
|
||||
measures[i] = new Measure(unitValues.get(i), TIME_UNITS[unitIndices.get(i)]);
|
||||
measures[i] = new Measure(unitValues.getLong(i), TIME_UNITS[unitIndices.getInt(i)]);
|
||||
}
|
||||
return format.formatMeasures(measures);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.keymap;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.registry.RegistryValue;
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.SmartHashSet;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,7 +29,6 @@ import static java.awt.event.InputEvent.ALT_DOWN_MASK;
|
||||
import static java.awt.event.InputEvent.CTRL_DOWN_MASK;
|
||||
|
||||
public final class KeymapUtil {
|
||||
|
||||
@NonNls private static final String CANCEL_KEY_TEXT = "Cancel";
|
||||
@NonNls private static final String BREAK_KEY_TEXT = "Break";
|
||||
@NonNls private static final String SHIFT = "shift";
|
||||
@@ -177,7 +178,7 @@ public final class KeymapUtil {
|
||||
private static boolean isNativeMacShortcuts() {
|
||||
return SystemInfo.isMac && !isSimplifiedMacShortcuts();
|
||||
}
|
||||
|
||||
|
||||
private static boolean isSimplifiedMacShortcuts() {
|
||||
return SystemInfo.isMac && Registry.is("ide.macos.disable.native.shortcut.symbols", false);
|
||||
}
|
||||
@@ -576,7 +577,7 @@ public final class KeymapUtil {
|
||||
if (shortcuts.length == 0) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<KeyStroke> result = new SmartHashSet<>();
|
||||
Set<KeyStroke> result = new HashSet<>();
|
||||
for (Shortcut shortcut : shortcuts) {
|
||||
if (!(shortcut instanceof KeyboardShortcut)) {
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.ui;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -34,6 +34,7 @@ import javax.swing.tree.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
@@ -637,14 +638,14 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
|
||||
}
|
||||
|
||||
protected final void checkForEmptyAndDuplicatedNames(String prefix, String title,
|
||||
Class<? extends NamedConfigurable> configurableClass) throws ConfigurationException {
|
||||
Class<? extends NamedConfigurable<?>> configurableClass) throws ConfigurationException {
|
||||
checkForEmptyAndDuplicatedNames(myRoot, prefix, title, configurableClass, true);
|
||||
}
|
||||
|
||||
private void checkForEmptyAndDuplicatedNames(MyNode rootNode,
|
||||
String prefix,
|
||||
String title,
|
||||
Class<? extends NamedConfigurable> configurableClass,
|
||||
Class<? extends NamedConfigurable<?>> configurableClass,
|
||||
boolean recursively) throws ConfigurationException {
|
||||
final Set<String> names = new HashSet<>();
|
||||
for (int i = 0; i < rootNode.getChildCount(); i++) {
|
||||
@@ -778,13 +779,21 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
|
||||
}
|
||||
|
||||
protected class MyDeleteAction extends AnAction implements DumbAware {
|
||||
private final Condition<Object[]> myCondition;
|
||||
private final @Nullable Predicate<Object[]> myCondition;
|
||||
|
||||
public MyDeleteAction() {
|
||||
this(Conditions.alwaysTrue());
|
||||
this((Predicate<Object[]>)null);
|
||||
}
|
||||
|
||||
public MyDeleteAction(Condition<Object[]> availableCondition) {
|
||||
/**
|
||||
* @deprecated Use {@link #MyDeleteAction(Predicate)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MyDeleteAction(@Nullable Condition<Object[]> availableCondition) {
|
||||
this(availableCondition == null ? null : (Predicate<Object[]>)availableCondition::value);
|
||||
}
|
||||
|
||||
public MyDeleteAction(@Nullable Predicate<Object[]> availableCondition) {
|
||||
super(CommonBundle.messagePointer("button.delete"), CommonBundle.messagePointer("button.delete"), PlatformIcons.DELETE_ICON);
|
||||
registerCustomShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.REMOVE), myTree);
|
||||
myCondition = availableCondition;
|
||||
@@ -792,14 +801,23 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(false);
|
||||
final TreePath[] selectionPath = myTree.getSelectionPaths();
|
||||
if (selectionPath != null) {
|
||||
Object[] nodes = ContainerUtil.map2Array(selectionPath, TreePath::getLastPathComponent);
|
||||
if (!myCondition.value(nodes)) return;
|
||||
presentation.setEnabled(true);
|
||||
if (selectionPath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (myCondition != null) {
|
||||
Object[] result = new Object[selectionPath.length];
|
||||
for (int i = 0; i < selectionPath.length; i++) {
|
||||
result[i] = selectionPath[i].getLastPathComponent();
|
||||
}
|
||||
if (!myCondition.test(result)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -808,10 +826,12 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
|
||||
}
|
||||
}
|
||||
|
||||
protected static Condition<Object[]> forAll(final Condition<Object> condition) {
|
||||
protected static Predicate<Object[]> forAll(@NotNull Predicate<Object> condition) {
|
||||
return objects -> {
|
||||
for (Object object : objects) {
|
||||
if (!condition.value(object)) return false;
|
||||
if (!condition.test(object)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// 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.
|
||||
|
||||
// Copyright 2000-2021 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.ui;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.ui;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import gnu.trove.Equality;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -25,13 +24,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
private final Namer<? super T> myNamer;
|
||||
private final Factory<? extends T> myFactory;
|
||||
private final Cloner<T> myCloner;
|
||||
private final List<T> myItems = new ArrayList<>();
|
||||
private final Equality<? super T> myComparer;
|
||||
private final BiPredicate<? super T, ? super T> myComparer;
|
||||
private List<T> myResultItems;
|
||||
private final List<T> myOriginalItems;
|
||||
private boolean myShowIcons;
|
||||
@@ -39,7 +39,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
protected NamedItemsListEditor(Namer<? super T> namer,
|
||||
Factory<? extends T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<? super T> comparer,
|
||||
BiPredicate<? super T, ? super T> comparer,
|
||||
List<T> items) {
|
||||
this(namer, factory, cloner, comparer, items, true);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
protected NamedItemsListEditor(Namer<? super T> namer,
|
||||
Factory<? extends T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<? super T> comparer,
|
||||
BiPredicate<? super T, ? super T> comparer,
|
||||
List<T> items,
|
||||
boolean initInConstructor) {
|
||||
myNamer = namer;
|
||||
@@ -147,6 +147,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
protected List<AnAction> createActions(boolean fromPopup) {
|
||||
ArrayList<AnAction> result = new ArrayList<>();
|
||||
result.add(new AddAction());
|
||||
//noinspection unchecked
|
||||
result.add(new MyDeleteAction(forAll(o -> canDelete((T)((MyNode)o).getConfigurable().getEditableObject()))));
|
||||
result.add(new CopyAction());
|
||||
return result;
|
||||
@@ -181,7 +182,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
protected UnnamedConfigurable getItemConfigurable(final T item) {
|
||||
final Ref<UnnamedConfigurable> result = new Ref<>();
|
||||
TreeUtil.traverse((TreeNode)myTree.getModel().getRoot(), node -> {
|
||||
final NamedConfigurable configurable = (NamedConfigurable)((DefaultMutableTreeNode)node).getUserObject();
|
||||
final NamedConfigurable<?> configurable = (NamedConfigurable<?>)((DefaultMutableTreeNode)node).getUserObject();
|
||||
if (configurable.getEditableObject() == item) {
|
||||
//noinspection unchecked
|
||||
result.set(((ItemConfigurable)configurable).myConfigurable);
|
||||
@@ -268,7 +269,9 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
if (myResultItems.size() != myItems.size()) return true;
|
||||
|
||||
for (int i = 0; i < myItems.size(); i++) {
|
||||
if (!myComparer.equals(myItems.get(i), myResultItems.get(i))) return true;
|
||||
if (!myComparer.test(myItems.get(i), myResultItems.get(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.isModified();
|
||||
@@ -324,7 +327,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
protected void onItemCloned(T clone) {
|
||||
}
|
||||
|
||||
private class AddAction extends DumbAwareAction {
|
||||
private final class AddAction extends DumbAwareAction {
|
||||
AddAction() {
|
||||
super(IdeBundle.messagePointer("action.NamedItemsListEditor.AddAction.text.add"),
|
||||
IdeBundle.messagePointer("action.NamedItemsListEditor.AddAction.description.add"), IconUtil.getAddIcon());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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;
|
||||
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -7,13 +7,14 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingManager;
|
||||
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.text.CaseInsensitiveStringHashingStrategy;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -53,9 +54,15 @@ public class LocalFilePath implements FilePath {
|
||||
|
||||
LocalFilePath path = (LocalFilePath)o;
|
||||
|
||||
if (myIsDirectory != path.myIsDirectory) return false;
|
||||
if (myPath.equals(path.myPath)) return true;
|
||||
if (!CaseInsensitiveStringHashingStrategy.INSTANCE.equals(myPath, path.myPath)) return false;
|
||||
if (myIsDirectory != path.myIsDirectory) {
|
||||
return false;
|
||||
}
|
||||
if (myPath.equals(path.myPath)) {
|
||||
return true;
|
||||
}
|
||||
if (!myPath.equalsIgnoreCase(path.myPath)) {
|
||||
return false;
|
||||
}
|
||||
// make sure to not query (expensive) getVirtualFile() until it's absolutely necessary, e.g. we encountered two file paths differ by case only
|
||||
VirtualFile file = getVirtualFile();
|
||||
VirtualFile oFile = path.getVirtualFile();
|
||||
@@ -65,7 +72,7 @@ public class LocalFilePath implements FilePath {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = CaseInsensitiveStringHashingStrategy.INSTANCE.computeHashCode(myPath);
|
||||
int result = Strings.stringHashCodeInsensitive(myPath);
|
||||
result = 31 * result + (myIsDirectory ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
@@ -106,7 +113,9 @@ public class LocalFilePath implements FilePath {
|
||||
@Nullable
|
||||
public VirtualFile getVirtualFile() {
|
||||
VirtualFile cachedFile = myCachedFile;
|
||||
if (cachedFile == null || !cachedFile.isValid() || !FileUtil.PATH_HASHING_STRATEGY.equals(cachedFile.getPath(), myPath)) {
|
||||
if (cachedFile == null ||
|
||||
!cachedFile.isValid() ||
|
||||
!(SystemInfoRt.isFileSystemCaseSensitive ? cachedFile.getPath().equals(myPath) : cachedFile.getPath().equalsIgnoreCase(myPath))) {
|
||||
myCachedFile = cachedFile = LocalFileSystem.getInstance().findFileByPath(myPath);
|
||||
}
|
||||
return cachedFile;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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.ui;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -9,13 +9,13 @@ import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.containers.SmartHashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
@@ -113,7 +113,7 @@ public abstract class AnActionButton extends AnAction implements ShortcutProvide
|
||||
|
||||
public final void addCustomUpdater(@NotNull AnActionButtonUpdater updater) {
|
||||
if (myUpdaters == null) {
|
||||
myUpdaters = new SmartHashSet<>();
|
||||
myUpdaters = new HashSet<>();
|
||||
}
|
||||
myUpdaters.add(updater);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2000-2019 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.
|
||||
// Copyright 2000-2021 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.ui;
|
||||
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -12,10 +12,9 @@ import java.util.List;
|
||||
/**
|
||||
* Policy which defines explicit focus component cycle.
|
||||
*/
|
||||
public class ListFocusTraversalPolicy extends LayoutFocusTraversalPolicy {
|
||||
|
||||
public final class ListFocusTraversalPolicy extends LayoutFocusTraversalPolicy {
|
||||
private final Component[] myComponents;
|
||||
private final TObjectIntHashMap<Component> myComponentToIndex;
|
||||
private final Object2IntOpenHashMap<Component> myComponentToIndex;
|
||||
|
||||
public ListFocusTraversalPolicy(@NotNull List<? extends Component> components) {
|
||||
myComponents = components.toArray(new Component[0]);
|
||||
@@ -42,7 +41,7 @@ public class ListFocusTraversalPolicy extends LayoutFocusTraversalPolicy {
|
||||
if (!myComponentToIndex.containsKey(aComponent)) {
|
||||
return null;
|
||||
}
|
||||
return getNextComponent(myComponentToIndex.get(aComponent) + 1);
|
||||
return getNextComponent(myComponentToIndex.getInt(aComponent) + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,7 +49,7 @@ public class ListFocusTraversalPolicy extends LayoutFocusTraversalPolicy {
|
||||
if (!myComponentToIndex.containsKey(aComponent)) {
|
||||
return null;
|
||||
}
|
||||
return getPreviousComponent(myComponentToIndex.get(aComponent) - 1);
|
||||
return getPreviousComponent(myComponentToIndex.getInt(aComponent) - 1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -87,15 +86,12 @@ public class ListFocusTraversalPolicy extends LayoutFocusTraversalPolicy {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <X> TObjectIntHashMap<X> indexMap(X @NotNull [] array) {
|
||||
TObjectIntHashMap<X> map = new TObjectIntHashMap<>(array.length);
|
||||
private static @NotNull <X> Object2IntOpenHashMap<X> indexMap(X @NotNull [] array) {
|
||||
Object2IntOpenHashMap<X> map = new Object2IntOpenHashMap<>(array.length);
|
||||
for (X x : array) {
|
||||
if (!map.contains(x)) {
|
||||
map.put(x, map.size());
|
||||
}
|
||||
map.putIfAbsent(x, map.size());
|
||||
}
|
||||
map.compact();
|
||||
map.trim();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2021 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 org.jetbrains.java.generate.view;
|
||||
|
||||
import com.intellij.java.JavaBundle;
|
||||
@@ -11,7 +11,6 @@ import com.intellij.openapi.util.Cloner;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import gnu.trove.Equality;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -22,6 +21,7 @@ import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
public class TemplatesPanel extends NamedItemsListEditor<TemplateResource> {
|
||||
private static final Namer<TemplateResource> NAMER = new Namer<>() {
|
||||
@@ -59,7 +59,7 @@ public class TemplatesPanel extends NamedItemsListEditor<TemplateResource> {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Equality<TemplateResource> COMPARER =
|
||||
private static final BiPredicate<TemplateResource, TemplateResource> COMPARER =
|
||||
(o1, o2) -> Objects.equals(o1.getTemplate(), o2.getTemplate()) && Objects.equals(o1.getFileName(), o2.getFileName());
|
||||
private final Project myProject;
|
||||
private final TemplatesManager myTemplatesManager;
|
||||
|
||||
Reference in New Issue
Block a user