From bf30925e3eed88ac53b96822ebc0654e2a47f42d Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Fri, 23 Mar 2018 15:36:54 +0300 Subject: [PATCH] IDEA-187611: basic icons support int the scope chooser combobox --- .../psi/search/GlobalSearchScopesCore.java | 23 +++++++----------- .../search/DelegatingGlobalSearchScope.java | 24 +++++++------------ .../com/intellij/psi/search/SearchScope.java | 24 +++++++------------ .../util/scopeChooser/ScopeChooserCombo.java | 18 +++----------- 4 files changed, 29 insertions(+), 60 deletions(-) diff --git a/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java index ad76e96d4d5a..18b768fe6684 100644 --- a/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java +++ b/platform/analysis-api/src/com/intellij/psi/search/GlobalSearchScopesCore.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.psi.search; import com.intellij.openapi.module.Module; @@ -35,6 +21,7 @@ import com.intellij.util.containers.ContainerUtil; import java.util.HashSet; import org.jetbrains.annotations.NotNull; +import javax.swing.Icon; import java.util.Collection; import java.util.Collections; import java.util.Objects; @@ -108,6 +95,12 @@ public class GlobalSearchScopesCore { return mySet.getName(); } + @NotNull + @Override + public Icon getDisplayIcon() { + return mySet.getIcon(); + } + @NotNull @Override public Project getProject() { diff --git a/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java b/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java index 89179044fa4b..cc869338ffaa 100644 --- a/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java +++ b/platform/core-api/src/com/intellij/psi/search/DelegatingGlobalSearchScope.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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.psi.search; import com.intellij.openapi.module.Module; @@ -20,7 +6,9 @@ import com.intellij.openapi.module.UnloadedModuleDescription; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import javax.swing.Icon; import java.util.Arrays; import java.util.Collection; @@ -82,6 +70,12 @@ public class DelegatingGlobalSearchScope extends GlobalSearchScope { return myBaseScope.getDisplayName(); } + @Nullable + @Override + public Icon getDisplayIcon() { + return myBaseScope.getDisplayIcon(); + } + @Override public String toString() { return getClass().getName() + "[" + myBaseScope + "]"; diff --git a/platform/core-api/src/com/intellij/psi/search/SearchScope.java b/platform/core-api/src/com/intellij/psi/search/SearchScope.java index 84229fdc7869..3db3178d5e13 100644 --- a/platform/core-api/src/com/intellij/psi/search/SearchScope.java +++ b/platform/core-api/src/com/intellij/psi/search/SearchScope.java @@ -1,23 +1,12 @@ -/* - * Copyright 2000-2014 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.psi.search; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiBundle; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.Icon; public abstract class SearchScope { private static int hashCodeCounter; @@ -40,6 +29,11 @@ public abstract class SearchScope { return PsiBundle.message("search.scope.unknown"); } + @Nullable + public Icon getDisplayIcon() { + return null; + } + @NotNull public abstract SearchScope intersectWith(@NotNull SearchScope scope2); @NotNull public abstract SearchScope union(@NotNull SearchScope scope); diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java index 349dda546ca8..e026bf83ab56 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserCombo.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 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.ide.util.scopeChooser; import com.intellij.ide.DataManager; @@ -289,6 +275,8 @@ public class ScopeChooserCombo extends ComboboxWithBrowseButton implements Dispo private static class ScopeDescriptionWithDelimiterRenderer extends ListCellRendererWrapper { @Override public void customize(JList list, ScopeDescriptor value, int index, boolean selected, boolean hasFocus) { + SearchScope scope = value.getScope(); + setIcon(scope == null ? null : scope.getDisplayIcon()); setText(value.getDisplay()); if (value instanceof ScopeSeparator) { setSeparator();