IDEA-187611: basic icons support int the scope chooser combobox

This commit is contained in:
Sergey Malenkov
2018-03-23 15:42:51 +03:00
parent 7d666d1585
commit bf30925e3e
4 changed files with 29 additions and 60 deletions
@@ -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() {
@@ -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 + "]";
@@ -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);
@@ -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<ScopeDescriptor> {
@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();