mnemonic in PSI viewer

This commit is contained in:
Evgeny Zakrevsky
2011-08-03 13:37:36 +04:00
parent 96312f6a81
commit 0f86c4b104
3 changed files with 62 additions and 23 deletions
@@ -29,11 +29,9 @@ import com.intellij.refactoring.util.classMembers.MemberInfo;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TableUtil;
import com.intellij.ui.TitledBorderWithMnemonic;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -64,14 +62,15 @@ public class MemberSelectionPanel extends JPanel {
myTable.requestFocus();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_M, SystemInfo.isMac ? InputEvent.META_DOWN_MASK : InputEvent.ALT_DOWN_MASK),
JComponent.WHEN_IN_FOCUSED_WINDOW);
JComponent.WHEN_IN_FOCUSED_WINDOW);
}
private static String appendTitledBorderMnemonic(String title) {
int membersIdx = title.indexOf('M');
if (membersIdx >= 0) {
title = title.replaceFirst("M", "&M");
} else {
}
else {
membersIdx = title.indexOf('m');
if (membersIdx >= 0) {
title = title.replaceFirst("m", "&m");
@@ -87,6 +86,4 @@ public class MemberSelectionPanel extends JPanel {
public MemberSelectionTable getTable() {
return myTable;
}
}
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.internal.psiView.PsiViewerDialog">
<grid id="80cff" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="80cff" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="44" y="67" width="748" height="670"/>
<xy x="44" y="67" width="749" height="670"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<splitpane id="5944f" binding="myTextSplit">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
@@ -50,7 +50,7 @@
</properties>
<border type="none"/>
<children>
<grid id="bb268" binding="myStructureTreePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="bb268" binding="myStructureTreePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="left"/>
@@ -60,7 +60,7 @@
<children>
<scrollpane id="73bab" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -71,6 +71,14 @@
</component>
</children>
</scrollpane>
<component id="1a9fa" class="com.intellij.ui.TitledSeparatorWithMnemonic" binding="myPsiTreeSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="PSI &amp;Structure"/>
</properties>
</component>
</children>
</grid>
<splitpane id="93797" binding="myBlockRefSplitPane">
@@ -84,7 +92,7 @@
</properties>
<border type="none"/>
<children>
<grid id="47abd" binding="myReferencesPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="47abd" binding="myReferencesPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="left"/>
@@ -94,13 +102,21 @@
<children>
<component id="128ee" class="com.intellij.ui.components.JBList" binding="myRefs" custom-create="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="287f6" class="com.intellij.ui.TitledSeparatorWithMnemonic" binding="myRefsSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;References"/>
</properties>
</component>
</children>
</grid>
<grid id="35049" binding="myBlockStructurePanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="35049" binding="myBlockStructurePanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
@@ -110,7 +126,7 @@
<children>
<scrollpane id="690aa" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -121,6 +137,14 @@
</component>
</children>
</scrollpane>
<component id="62949" class="com.intellij.ui.TitledSeparatorWithMnemonic" binding="myBlockTreeSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Bloc&amp;k Structure"/>
</properties>
</component>
</children>
</grid>
</children>
@@ -224,6 +248,14 @@
</grid>
</children>
</grid>
<component id="bd033" class="com.intellij.ui.TitledSeparatorWithMnemonic" binding="myTextSeparator">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Text"/>
</properties>
</component>
</children>
</grid>
</form>
@@ -65,10 +65,7 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.search.FilenameIndex;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.ui.CollectionComboBoxModel;
import com.intellij.ui.SortedComboBoxModel;
import com.intellij.ui.TitledBorderWithMnemonic;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.*;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBList;
import com.intellij.ui.treeStructure.Tree;
@@ -122,6 +119,10 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
private Tree myBlockTree;
private JPanel myBlockStructurePanel;
private JSplitPane myBlockRefSplitPane;
private TitledSeparatorWithMnemonic myTextSeparator;
private TitledSeparatorWithMnemonic myPsiTreeSeparator;
private TitledSeparatorWithMnemonic myRefsSeparator;
private TitledSeparatorWithMnemonic myBlockTreeSeparator;
@Nullable
private BlockTreeBuilder myBlockTreeBuilder;
private RangeHighlighter myHighlighter;
@@ -242,6 +243,8 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
protected void init() {
initBorders();
initMnemonics();
initTree(myPsiTree);
final TreeCellRenderer renderer = myPsiTree.getCellRenderer();
myPsiTree.setCellRenderer(new TreeCellRenderer() {
@@ -545,10 +548,17 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider, Disp
}
private void initBorders() {
myTextPanel.setBorder(new TitledBorderWithMnemonic("&Text"));
myStructureTreePanel.setBorder(new TitledBorderWithMnemonic("PSI &Structure"));
myReferencesPanel.setBorder(new TitledBorderWithMnemonic("&References"));
myBlockStructurePanel.setBorder(new TitledBorderWithMnemonic("Bloc&k Structure"));
//myTextPanel.setBorder(new TitledBorderWithMnemonic("&Text"));
//myStructureTreePanel.setBorder(new TitledBorderWithMnemonic("PSI &Structure"));
//myReferencesPanel.setBorder(new TitledBorderWithMnemonic("&References"));
//myBlockStructurePanel.setBorder(new TitledBorderWithMnemonic("Bloc&k Structure"));
}
private void initMnemonics() {
myTextSeparator.setLabelFor(myEditor.getContentComponent());
myPsiTreeSeparator.setLabelFor(myPsiTree);
myRefsSeparator.setLabelFor(myRefs);
myBlockTreeSeparator.setLabelFor(myBlockTree);
}
private void updateIntersectHighlighter(int highlightStart, int highlightEnd) {