mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add icons to ctrl-n-like dialogs
This commit is contained in:
@@ -158,6 +158,9 @@ public class AppearanceConfigurable extends BaseConfigurable implements Applicat
|
||||
update |= hide != settings.HIDE_KNOWN_EXTENSION_IN_TABS;
|
||||
settings.HIDE_KNOWN_EXTENSION_IN_TABS = hide;
|
||||
|
||||
update |= settings.SHOW_ICONS_IN_QUICK_NAVIGATION != myComponent.myHideIconsInQuickNavigation.isSelected();
|
||||
settings.SHOW_ICONS_IN_QUICK_NAVIGATION = myComponent.myHideIconsInQuickNavigation.isSelected();
|
||||
|
||||
boolean shouldRepaintUI = false;
|
||||
if (
|
||||
settings.ANTIALIASING_IN_EDITOR != myComponent.myAntialiasingInEditorCheckBox.isSelected()
|
||||
@@ -219,6 +222,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Applicat
|
||||
myComponent.myScrollTabLayoutInEditorCheckBox.setSelected(settings.SCROLL_TAB_LAYOUT_IN_EDITOR);
|
||||
myComponent.myEditorTabPlacement.setSelectedItem(new Integer(settings.EDITOR_TAB_PLACEMENT));
|
||||
myComponent.myHideKnownExtensions.setSelected(settings.HIDE_KNOWN_EXTENSION_IN_TABS);
|
||||
myComponent.myHideIconsInQuickNavigation.setSelected(settings.SHOW_ICONS_IN_QUICK_NAVIGATION);
|
||||
myComponent.myAntialiasingInEditorCheckBox.setSelected(settings.ANTIALIASING_IN_EDITOR);
|
||||
myComponent.myMoveMouseOnDefaultButtonCheckBox.setSelected(settings.MOVE_MOUSE_ON_DEFAULT_BUTTON);
|
||||
myComponent.myLafComboBox.setSelectedItem(LafManager.getInstance().getCurrentLookAndFeel());
|
||||
@@ -259,6 +263,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Applicat
|
||||
int tabPlacement = ((Integer)myComponent.myEditorTabPlacement.getSelectedItem()).intValue();
|
||||
isModified |= tabPlacement != settings.EDITOR_TAB_PLACEMENT;
|
||||
isModified |= myComponent.myHideKnownExtensions.isSelected() != settings.HIDE_KNOWN_EXTENSION_IN_TABS;
|
||||
isModified |= myComponent.myHideIconsInQuickNavigation.isSelected() != settings.SHOW_ICONS_IN_QUICK_NAVIGATION;
|
||||
|
||||
isModified |= myComponent.myAntialiasingInEditorCheckBox.isSelected() != settings.ANTIALIASING_IN_EDITOR;
|
||||
isModified |= myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected() != settings.MOVE_MOUSE_ON_DEFAULT_BUTTON;
|
||||
@@ -360,6 +365,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Applicat
|
||||
private JCheckBox myOverrideLAFFonts;
|
||||
private JLabel myIDEALafFont;
|
||||
private JCheckBox myHideKnownExtensions;
|
||||
private JCheckBox myHideIconsInQuickNavigation;
|
||||
|
||||
public MyComponent() {
|
||||
ActionListener updater = new ActionListener() {
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
<children>
|
||||
<vspacer id="64337">
|
||||
<constraints>
|
||||
<xy x="218" y="305" width="11" height="115"/>
|
||||
<xy x="218" y="332" width="11" height="88"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="937be" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="5" left="5" bottom="0" right="5"/>
|
||||
<constraints>
|
||||
<xy x="458" y="0" width="429" height="178"/>
|
||||
<xy x="458" y="0" width="429" height="191"/>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
@@ -26,7 +26,7 @@
|
||||
<children>
|
||||
<component id="9264" class="javax.swing.JCheckBox" binding="myAnimateWindowsCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="27" width="108" height="22"/>
|
||||
<xy x="11" y="28" width="108" height="22"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -37,7 +37,7 @@
|
||||
</component>
|
||||
<component id="32072" class="javax.swing.JCheckBox" binding="myWindowShortcutsCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="58" width="145" height="22"/>
|
||||
<xy x="11" y="61" width="145" height="22"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -48,7 +48,7 @@
|
||||
</component>
|
||||
<component id="e4f17" class="javax.swing.JCheckBox" binding="myShowToolStripesCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="88" width="135" height="22"/>
|
||||
<xy x="11" y="94" width="135" height="22"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -59,7 +59,7 @@
|
||||
</component>
|
||||
<component id="44b00" class="javax.swing.JCheckBox" binding="myAlwaysShowWindowButtonsCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="118" width="215" height="22"/>
|
||||
<xy x="11" y="127" width="215" height="22"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -70,7 +70,7 @@
|
||||
</component>
|
||||
<component id="42895" class="javax.swing.JCheckBox" binding="myShowMemoryIndicatorCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="148" width="136" height="22"/>
|
||||
<xy x="11" y="160" width="136" height="22"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -84,7 +84,7 @@
|
||||
<grid id="26e1c" binding="myTransparencyPanel" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="5">
|
||||
<margin top="5" left="5" bottom="5" right="5"/>
|
||||
<constraints>
|
||||
<xy x="458" y="183" width="429" height="122"/>
|
||||
<xy x="458" y="196" width="429" height="136"/>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
@@ -92,7 +92,7 @@
|
||||
<children>
|
||||
<component id="3d7be" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<xy x="11" y="61" width="55" height="14"/>
|
||||
<xy x="11" y="68" width="55" height="14"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -101,7 +101,7 @@
|
||||
</component>
|
||||
<component id="78431" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<xy x="11" y="91" width="29" height="14"/>
|
||||
<xy x="11" y="103" width="29" height="14"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -110,7 +110,7 @@
|
||||
</component>
|
||||
<component id="7d37d" class="javax.swing.JCheckBox" binding="myEnableAlphaModeCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="29" width="228" height="18"/>
|
||||
<xy x="11" y="31" width="228" height="18"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
@@ -120,14 +120,14 @@
|
||||
</component>
|
||||
<component id="afb40" class="javax.swing.JSlider" binding="myAlphaModeRatioSlider">
|
||||
<constraints>
|
||||
<xy x="76" y="90" width="342" height="16"/>
|
||||
<xy x="76" y="102" width="342" height="16"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="51eca" class="javax.swing.JTextField" binding="myAlphaModeDelayTextField">
|
||||
<constraints>
|
||||
<xy x="76" y="58" width="50" height="20"/>
|
||||
<xy x="76" y="65" width="50" height="20"/>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0">
|
||||
<preferred-size width="50" height="-1"/>
|
||||
</grid>
|
||||
@@ -140,10 +140,10 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="d992b" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="d992b" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="5" left="5" bottom="5" right="5"/>
|
||||
<constraints>
|
||||
<xy x="0" y="0" width="448" height="305"/>
|
||||
<xy x="0" y="0" width="448" height="332"/>
|
||||
<grid row="0" column="0" row-span="2" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
@@ -151,8 +151,8 @@
|
||||
<children>
|
||||
<component id="c6ad1" class="javax.swing.JCheckBox" binding="myAntialiasingInEditorCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="134" width="160" height="22"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
<xy x="11" y="161" width="160" height="22"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Use antialiased font in editor"/>
|
||||
@@ -161,8 +161,8 @@
|
||||
</component>
|
||||
<component id="33d7c" class="javax.swing.JCheckBox" binding="myMoveMouseOnDefaultButtonCheckBox">
|
||||
<constraints>
|
||||
<xy x="11" y="161" width="281" height="22"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
<xy x="11" y="188" width="281" height="22"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Automatically position mouse cursor on default button"/>
|
||||
@@ -212,8 +212,8 @@
|
||||
<grid id="4c401" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="11" y="188" width="426" height="23"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
<xy x="11" y="215" width="426" height="23"/>
|
||||
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -242,8 +242,8 @@
|
||||
<grid id="d9fb" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="11" y="243" width="426" height="51"/>
|
||||
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
<xy x="11" y="270" width="426" height="51"/>
|
||||
<grid row="9" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -308,8 +308,8 @@
|
||||
<grid id="ce348" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="11" y="216" width="426" height="22"/>
|
||||
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
<xy x="11" y="243" width="426" height="22"/>
|
||||
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -344,6 +344,16 @@
|
||||
<margin top="2" left="0" bottom="2" right="2"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a3b32" class="javax.swing.JCheckBox" binding="myHideIconsInQuickNavigation">
|
||||
<constraints>
|
||||
<xy x="11" y="134" width="162" height="22"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show icons in quick navigation"/>
|
||||
<margin top="2" left="0" bottom="2" right="2"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
|
||||
@@ -28,6 +28,7 @@ public class UISettings implements NamedJDOMExternalizable, ApplicationComponent
|
||||
public boolean SCROLL_TAB_LAYOUT_IN_EDITOR = false;
|
||||
public int EDITOR_TAB_PLACEMENT = 1;
|
||||
public boolean HIDE_KNOWN_EXTENSION_IN_TABS = false;
|
||||
public boolean SHOW_ICONS_IN_QUICK_NAVIGATION = true;
|
||||
public boolean CLOSE_NON_MODIFIED_FILES_FIRST = false;
|
||||
public boolean ANTIALIASING_IN_EDITOR;
|
||||
public boolean MOVE_MOUSE_ON_DEFAULT_BUTTON = false;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
package com.intellij.ide.util;
|
||||
|
||||
import com.intellij.ide.IconUtilEx;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.util.treeView.NodeRenderer;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
@@ -44,57 +45,89 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class NavigationItemListCellRenderer extends ColoredListCellRenderer{
|
||||
protected void customizeCellRenderer(
|
||||
public class NavigationItemListCellRenderer extends JPanel implements ListCellRenderer {
|
||||
public NavigationItemListCellRenderer() {
|
||||
super(new BorderLayout());
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus
|
||||
){
|
||||
if (value instanceof NavigationItem) {
|
||||
NavigationItem element = (NavigationItem)value;
|
||||
ItemPresentation presentation = element.getPresentation();
|
||||
String name = presentation.getPresentableText();
|
||||
Color color = list.getForeground();
|
||||
FileStatus status = element.getFileStatus();
|
||||
if (status != FileStatus.NOT_CHANGED) {
|
||||
color = status.getColor();
|
||||
}
|
||||
|
||||
final SimpleTextAttributes simpleTextAttributes = NodeRenderer.getSimpleTextAttributes(presentation);
|
||||
final TextAttributes textAttributes = simpleTextAttributes.toTextAttributes();
|
||||
textAttributes.setForegroundColor(color);
|
||||
append(name,SimpleTextAttributes.fromTextAttributes(textAttributes));
|
||||
setIcon(presentation.getIcon(false));
|
||||
|
||||
String containerText = presentation.getLocationString();
|
||||
|
||||
if (containerText != null && containerText.length() > 0){
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
}
|
||||
boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
removeAll();
|
||||
final Component leftCellRendererComponent =
|
||||
new LeftRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
add(leftCellRendererComponent, BorderLayout.WEST);
|
||||
if (UISettings.getInstance().SHOW_ICONS_IN_QUICK_NAVIGATION){
|
||||
final Component rightCellRendererComponent =
|
||||
new PsiElementModuleRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
add(rightCellRendererComponent, BorderLayout.EAST);
|
||||
final JPanel spacer = new JPanel();
|
||||
final Dimension size = rightCellRendererComponent.getSize();
|
||||
spacer.setSize(new Dimension((int)(size.width * 0.015 + leftCellRendererComponent.getSize().width * 0.015), size.height));
|
||||
spacer.setBackground(UIManager.getColor(isSelected ? "List.selectionBackground" : "List.background"));
|
||||
add(spacer, BorderLayout.CENTER);
|
||||
}
|
||||
else {
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
append(value == null ? "" : value.toString(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
|
||||
setBackground(UIManager.getColor(isSelected ? "List.selectionBackground" : "List.background"));
|
||||
return this;
|
||||
}
|
||||
|
||||
private class LeftRenderer extends ColoredListCellRenderer {
|
||||
protected void customizeCellRenderer(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus
|
||||
) {
|
||||
if (value instanceof NavigationItem) {
|
||||
NavigationItem element = (NavigationItem)value;
|
||||
ItemPresentation presentation = element.getPresentation();
|
||||
String name = presentation.getPresentableText();
|
||||
Color color = list.getForeground();
|
||||
FileStatus status = element.getFileStatus();
|
||||
if (status != FileStatus.NOT_CHANGED) {
|
||||
color = status.getColor();
|
||||
}
|
||||
|
||||
final SimpleTextAttributes simpleTextAttributes = NodeRenderer.getSimpleTextAttributes(presentation);
|
||||
final TextAttributes textAttributes = simpleTextAttributes.toTextAttributes();
|
||||
textAttributes.setForegroundColor(color);
|
||||
append(name, SimpleTextAttributes.fromTextAttributes(textAttributes));
|
||||
setIcon(presentation.getIcon(false));
|
||||
|
||||
String containerText = presentation.getLocationString();
|
||||
|
||||
if (containerText != null && containerText.length() > 0) {
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
}
|
||||
}
|
||||
else {
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
append(value == null ? "" : value.toString(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
|
||||
}
|
||||
setPaintFocusBorder(false);
|
||||
setBackground(UIManager.getColor(selected ? "List.selectionBackground" : "List.background"));
|
||||
}
|
||||
}
|
||||
|
||||
public Comparator getComparator(){
|
||||
public Comparator getComparator() {
|
||||
return new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return getText(o1).compareTo(getText(o2));
|
||||
}
|
||||
|
||||
private String getText(Object o){
|
||||
if (o instanceof NavigationItem){
|
||||
private String getText(Object o) {
|
||||
if (o instanceof NavigationItem) {
|
||||
NavigationItem element = (NavigationItem)o;
|
||||
ItemPresentation presentation = element.getPresentation();
|
||||
String elementText = presentation.getLocationString();
|
||||
String containerText = presentation.getLocationString();
|
||||
return containerText != null ? elementText + " " + containerText : elementText;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.intellij.ide.util;
|
||||
|
||||
import com.intellij.ide.IconUtilEx;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -14,40 +15,76 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Comparator;
|
||||
|
||||
public abstract class PsiElementListCellRenderer extends ColoredListCellRenderer{
|
||||
protected void customizeCellRenderer(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus
|
||||
){
|
||||
if (value instanceof PsiElement){
|
||||
PsiElement element = (PsiElement)value;
|
||||
String name = getElementText(element);
|
||||
Color color = list.getForeground();
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile != null) {
|
||||
VirtualFile vFile = psiFile.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
FileStatus status = FileStatusManager.getInstance(psiFile.getProject()).getStatus(vFile);
|
||||
color = status.getColor();
|
||||
public abstract class PsiElementListCellRenderer extends JPanel implements ListCellRenderer {
|
||||
private boolean myAddLocation = true;
|
||||
protected PsiElementListCellRenderer() {
|
||||
super(new BorderLayout());
|
||||
}
|
||||
|
||||
public void setAddLocation(final boolean addLocation) {
|
||||
myAddLocation = addLocation;
|
||||
}
|
||||
|
||||
private class LeftRenderer extends ColoredListCellRenderer {
|
||||
protected void customizeCellRenderer(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus
|
||||
) {
|
||||
if (value instanceof PsiElement) {
|
||||
PsiElement element = (PsiElement)value;
|
||||
String name = getElementText(element);
|
||||
Color color = list.getForeground();
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
if (psiFile != null) {
|
||||
VirtualFile vFile = psiFile.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
FileStatus status = FileStatusManager.getInstance(psiFile.getProject()).getStatus(vFile);
|
||||
color = status.getColor();
|
||||
}
|
||||
}
|
||||
append(name, new SimpleTextAttributes(Font.PLAIN, color));
|
||||
setIcon(element.getIcon(getIconFlags()));
|
||||
|
||||
String containerText = getContainerText(element);
|
||||
if (containerText != null) {
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
}
|
||||
}
|
||||
append(name,new SimpleTextAttributes(Font.PLAIN, color));
|
||||
setIcon(element.getIcon(getIconFlags()));
|
||||
|
||||
String containerText = getContainerText(element);
|
||||
if (containerText != null){
|
||||
append(" " + containerText, new SimpleTextAttributes(Font.PLAIN, Color.GRAY));
|
||||
else {
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
append(value == null ? "" : value.toString(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
|
||||
}
|
||||
}
|
||||
else{
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
append(value == null ? "" : value.toString(), new SimpleTextAttributes(Font.PLAIN, list.getForeground()));
|
||||
setPaintFocusBorder(false);
|
||||
setBackground(UIManager.getColor(selected ? "List.selectionBackground" : "List.background"));
|
||||
}
|
||||
}
|
||||
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
removeAll();
|
||||
final Component leftCellRendererComponent =
|
||||
new LeftRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
add(leftCellRendererComponent, BorderLayout.WEST);
|
||||
if (myAddLocation && UISettings.getInstance().SHOW_ICONS_IN_QUICK_NAVIGATION){
|
||||
final Component rightCellRendererComponent =
|
||||
new PsiElementModuleRenderer().getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
add(rightCellRendererComponent, BorderLayout.EAST);
|
||||
final JPanel spacer = new JPanel();
|
||||
final Dimension size = rightCellRendererComponent.getSize();
|
||||
spacer.setSize(new Dimension((int)(size.width * 0.015 + leftCellRendererComponent.getSize().width * 0.015), size.height));
|
||||
spacer.setBackground(UIManager.getColor(isSelected ? "List.selectionBackground" : "List.background"));
|
||||
add(spacer, BorderLayout.CENTER);
|
||||
}
|
||||
setBackground(UIManager.getColor(isSelected ? "List.selectionBackground" : "List.background"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract String getElementText(PsiElement element);
|
||||
|
||||
@@ -55,37 +92,37 @@ public abstract class PsiElementListCellRenderer extends ColoredListCellRenderer
|
||||
|
||||
protected abstract int getIconFlags();
|
||||
|
||||
protected Icon getIcon(PsiElement element){
|
||||
protected Icon getIcon(PsiElement element) {
|
||||
return element.getIcon(getIconFlags());
|
||||
}
|
||||
|
||||
public Comparator<Object> getComparator(){
|
||||
public Comparator<Object> getComparator() {
|
||||
return new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return getText(o1).compareTo(getText(o2));
|
||||
}
|
||||
|
||||
private String getText(Object o){
|
||||
if (o instanceof PsiElement){
|
||||
private String getText(Object o) {
|
||||
if (o instanceof PsiElement) {
|
||||
PsiElement element = (PsiElement)o;
|
||||
String elementText = getElementText(element);
|
||||
String containerText = getContainerText(element);
|
||||
return containerText != null ? elementText + " " + containerText : elementText;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void installSpeedSearch(JList list){
|
||||
new ListSpeedSearch(list){
|
||||
protected String getElementText(Object o){
|
||||
if (o instanceof PsiElement){
|
||||
public void installSpeedSearch(JList list) {
|
||||
new ListSpeedSearch(list) {
|
||||
protected String getElementText(Object o) {
|
||||
if (o instanceof PsiElement) {
|
||||
return PsiElementListCellRenderer.this.getElementText((PsiElement)o);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
return o.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.intellij.ide.util;
|
||||
|
||||
import com.intellij.ide.IconUtilEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.impl.ModuleUtil;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class PsiElementModuleRenderer extends DefaultListCellRenderer{
|
||||
private static final Icon TEST_ICON = IconLoader.getIcon("/nodes/testSourceFolder.png");
|
||||
private static final Icon LIB_ICON = IconLoader.getIcon("/nodes/ppLibClosed.png");
|
||||
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
final Component listCellRendererComponent = super.getListCellRendererComponent(list, value, index, isSelected,
|
||||
cellHasFocus);
|
||||
customizeCellRenderer(list, value, index, isSelected, cellHasFocus);
|
||||
return listCellRendererComponent;
|
||||
}
|
||||
|
||||
protected void customizeCellRenderer(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus
|
||||
) {
|
||||
if (value instanceof PsiElement) {
|
||||
PsiElement element = (PsiElement)value;
|
||||
PsiFile psiFile = element.getContainingFile();
|
||||
Module module = ModuleUtil.findModuleForPsiElement(element);
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
|
||||
if (module != null) {
|
||||
boolean inTestSource = false;
|
||||
if (psiFile != null) {
|
||||
VirtualFile vFile = psiFile.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
inTestSource = fileIndex.isInTestSourceContent(vFile);
|
||||
}
|
||||
}
|
||||
setText(module.getName());
|
||||
if (inTestSource) {
|
||||
setIcon(TEST_ICON);
|
||||
}
|
||||
else {
|
||||
setIcon(module.getModuleType().getNodeIcon(false));
|
||||
}
|
||||
} else {
|
||||
if (psiFile != null) {
|
||||
VirtualFile vFile = psiFile.getVirtualFile();
|
||||
if (vFile != null) {
|
||||
final boolean isInLibraries = fileIndex.isInLibrarySource(vFile) || fileIndex.isInLibraryClasses(vFile);
|
||||
if (isInLibraries){
|
||||
setIcon(LIB_ICON);
|
||||
OrderEntry[] orders = fileIndex.getOrderEntriesForFile(vFile);
|
||||
for (int i = 0; i < orders.length; i++) {
|
||||
OrderEntry order = orders[i];
|
||||
if (order instanceof LibraryOrderEntry || order instanceof JdkOrderEntry){
|
||||
setText(order.getPresentableName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
setText(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
setIcon(IconUtilEx.getEmptyIcon(false));
|
||||
setText(value == null ? "" : value.toString());
|
||||
}
|
||||
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||
setHorizontalTextPosition(SwingConstants.LEFT);
|
||||
setBackground(UIManager.getColor(selected ? "List.selectionBackground" : "List.background"));
|
||||
setFont(UIManager.getFont("List.font"));
|
||||
setForeground(selected ? UIManager.getColor("List.selectionForeground") : UIManager.getColor("textInactiveText"));
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,13 @@ import com.intellij.ide.projectView.impl.AbstractProjectTreeStructure;
|
||||
import com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase;
|
||||
import com.intellij.ide.projectView.impl.ProjectTreeBuilder;
|
||||
import com.intellij.ide.projectView.impl.nodes.ClassTreeNode;
|
||||
import com.intellij.ide.util.gotoByName.*;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePanel;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
|
||||
import com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent;
|
||||
import com.intellij.ide.util.gotoByName.GotoClassModel;
|
||||
import com.intellij.ide.util.treeView.AlphaComparator;
|
||||
import com.intellij.ide.util.treeView.NodeRenderer;
|
||||
import com.intellij.ide.actions.GotoClassAction;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -24,7 +27,6 @@ import com.intellij.ui.TreeSpeedSearch;
|
||||
import com.intellij.util.containers.FilteringIterator;
|
||||
import com.intellij.util.ui.Tree;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.navigation.NavigationItem;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -55,7 +57,7 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
private TreeClassChooser.ClassFilter myClassFilter;
|
||||
private final PsiClass myInitialClass;
|
||||
private final PsiClassChildrenSource myClassChildrens;
|
||||
|
||||
private boolean myAddLocation = true;
|
||||
|
||||
|
||||
|
||||
@@ -120,6 +122,10 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
});
|
||||
}
|
||||
|
||||
public void setAddLocation(final boolean addLocation) {
|
||||
myAddLocation = addLocation;
|
||||
}
|
||||
|
||||
protected JComponent createCenterPanel() {
|
||||
myModel = new DefaultTreeModel(new DefaultMutableTreeNode());
|
||||
myTree = new Tree(myModel);
|
||||
@@ -203,7 +209,7 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
if (myInitialClass != null) {
|
||||
name = myInitialClass.getName();
|
||||
}
|
||||
myGotoByNamePanel = new ChooseByNamePanel(myProject, new MyGotoClassModel(), name) {
|
||||
myGotoByNamePanel = new ChooseByNamePanel(myProject, new MyGotoClassModel(myAddLocation), name) {
|
||||
protected void close(boolean isOk) {
|
||||
super.close(isOk);
|
||||
|
||||
@@ -272,7 +278,7 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
}
|
||||
|
||||
public void showPopup() {
|
||||
ChooseByNamePopup popup = ChooseByNamePopup.createPopup(myProject, new MyGotoClassModel());
|
||||
ChooseByNamePopup popup = ChooseByNamePopup.createPopup(myProject, new MyGotoClassModel(myAddLocation));
|
||||
popup.invoke(new ChooseByNamePopupComponent.Callback() {
|
||||
public void onClose () {
|
||||
|
||||
@@ -342,8 +348,10 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
}
|
||||
|
||||
private class MyGotoClassModel extends GotoClassModel {
|
||||
public MyGotoClassModel() {
|
||||
private boolean myAddLocation;
|
||||
public MyGotoClassModel(final boolean addLocation) {
|
||||
super(myProject);
|
||||
myAddLocation = addLocation;
|
||||
}
|
||||
|
||||
public Object[] getElementsByName(final String name, final boolean checkBoxState) {
|
||||
@@ -362,6 +370,12 @@ public class TreeClassChooserDialog extends DialogWrapper implements TreeClassCh
|
||||
public String getPromptText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PsiElementListCellRenderer getListCellRenderer() {
|
||||
final PsiElementListCellRenderer listCellRenderer = super.getListCellRenderer();
|
||||
listCellRenderer.setAddLocation(myAddLocation);
|
||||
return listCellRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
private class MyCallback extends ChooseByNamePopupComponent.Callback {
|
||||
|
||||
Reference in New Issue
Block a user