GitOrigin-RevId: 0a2b12dbfb17ca030b36fc4525227d87720b7951
This commit is contained in:
Vladimir Krivosheev
2019-12-11 07:34:16 +00:00
committed by intellij-monorepo-bot
parent 96f70f1828
commit c7f4dd5637
5 changed files with 15 additions and 28 deletions
@@ -1,19 +1,13 @@
// 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-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.
package com.intellij.openapi.extensions;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
* @author peter
*/
public abstract class SimpleSmartExtensionPoint<T> extends SmartExtensionPoint<T,T>{
public SimpleSmartExtensionPoint(@NotNull final Collection<T> explicitExtensions) {
super(explicitExtensions);
}
public SimpleSmartExtensionPoint() {
super(new SmartList<>());
}
@@ -1,5 +1,4 @@
// 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.
package com.intellij.ide.actions;
import com.intellij.featureStatistics.FeatureUsageTracker;
@@ -21,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.*;
public class SelectInAction extends AnAction implements DumbAware {
public final class SelectInAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.select.in");
@@ -52,7 +51,7 @@ public class SelectInAction extends AnAction implements DumbAware {
}
private static void invoke(@NotNull DataContext dataContext, @NotNull SelectInContext context) {
final List<SelectInTarget> targetVector = Arrays.asList(getSelectInManager(context.getProject()).getTargets());
final List<SelectInTarget> targetVector = Arrays.asList(SelectInManager.getInstance(context.getProject()).getTargets());
ListPopup popup;
if (targetVector.isEmpty()) {
DefaultActionGroup group = new DefaultActionGroup();
@@ -67,11 +66,11 @@ public class SelectInAction extends AnAction implements DumbAware {
popup.showInBestPositionFor(dataContext);
}
private static class SelectInActionsStep extends BaseListPopupStep<SelectInTarget> {
private static final class SelectInActionsStep extends BaseListPopupStep<SelectInTarget> {
private final SelectInContext mySelectInContext;
private final List<SelectInTarget> myVisibleTargets;
SelectInActionsStep(@NotNull final Collection<SelectInTarget> targetVector, @NotNull SelectInContext selectInContext) {
SelectInActionsStep(@NotNull Collection<SelectInTarget> targetVector, @NotNull SelectInContext selectInContext) {
mySelectInContext = selectInContext;
myVisibleTargets = new ArrayList<>(targetVector);
List<Icon> icons = fillInIcons(targetVector, selectInContext);
@@ -154,11 +153,7 @@ public class SelectInAction extends AnAction implements DumbAware {
return text;
}
private static SelectInManager getSelectInManager(Project project) {
return SelectInManager.getInstance(project);
}
private static class NoTargetsAction extends AnAction {
private static final class NoTargetsAction extends AnAction {
NoTargetsAction() {
super(IdeBundle.message("message.no.targets.available"));
}
@@ -1,7 +1,6 @@
// 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.
package com.intellij.ide;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.extensions.SimpleSmartExtensionPoint;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
@@ -13,7 +12,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Objects;
public class SelectInManager {
public final class SelectInManager {
private final Project myProject;
private final SimpleSmartExtensionPoint<SelectInTarget> myTargets;
@NonNls public static final String PROJECT = IdeBundle.message("select.in.project");
@@ -23,7 +22,7 @@ public class SelectInManager {
@NonNls public static final String NAV_BAR = IdeBundle.message("select.in.nav.bar");
@NonNls public static final String SCOPE = IdeBundle.message("select.in.scope");
public SelectInManager(final Project project) {
public SelectInManager(@NotNull Project project) {
myProject = project;
myTargets = SimpleSmartExtensionPoint.create(myProject.getExtensionArea(), SelectInTarget.EP_NAME);
}
@@ -48,12 +47,12 @@ public class SelectInManager {
return ContainerUtil.sorted(targets, SelectInTargetComparator.INSTANCE).toArray(new SelectInTarget[0]);
}
public static SelectInManager getInstance(Project project) {
return ServiceManager.getService(project, SelectInManager.class);
public static SelectInManager getInstance(@NotNull Project project) {
return project.getService(SelectInManager.class);
}
public static SelectInTarget findSelectInTarget(@NotNull String id, Project project) {
SelectInManager manager = project == null || project.isDisposed() ? null : SelectInManager.getInstance(project);
SelectInManager manager = project == null || project.isDisposed() ? null : getInstance(project);
SelectInTarget[] targets = manager == null ? null : manager.getTargets();
if (targets != null) {
for (SelectInTarget target : targets) {
@@ -171,10 +171,9 @@ public final class InternalDecorator extends JPanel implements Queryable, DataPr
validate();
repaint();
// Push "apply" request forward
// push "apply" request forward
if (myInfo.isFloating() && myInfo.isVisible()) {
final FloatingDecorator floatingDecorator = (FloatingDecorator)SwingUtilities.getAncestorOfClass(FloatingDecorator.class, this);
FloatingDecorator floatingDecorator = (FloatingDecorator)SwingUtilities.getAncestorOfClass(FloatingDecorator.class, this);
if (floatingDecorator != null) {
floatingDecorator.apply(myInfo);
}
@@ -887,7 +887,7 @@ open class ToolWindowManagerImpl(val project: Project) : ToolWindowManagerEx(),
val decorator = InternalDecorator(project, info.copy(), toolWindow, task.canWorkInDumbMode, disposable, internalDecoratorListener)
// create and show tool button
val button = StripeButton(decorator, (toolWindowPane)!!)
val button = StripeButton(decorator, toolWindowPane!!)
val commands = mutableListOf<FinalizableCommand>()
appendAddButtonCmd(button, info, commands)
@@ -1989,7 +1989,7 @@ open class ToolWindowManagerImpl(val project: Project) : ToolWindowManagerEx(),
}
val violations = mutableListOf<String>()
idToEntry.forEach { id, entry ->
idToEntry.forEach { (id, entry) ->
val info = layout.getInfo(id) ?: return@forEach
if (info.isVisible) {
if (info.isFloating) {