Better usability for focus tracer

This commit is contained in:
Vassiliy
2014-03-24 16:59:55 +04:00
parent 8162e5a286
commit 7ee47b9132
2 changed files with 23 additions and 62 deletions
@@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.internal.focus.FocusTracesDialog">
<grid id="27dc6" binding="myRootPanel" layout-manager="GridLayoutManager" row-count="1" 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="20" y="20" width="500" height="400"/>
</constraints>
<properties>
<preferredSize width="500" height="400"/>
</properties>
<border type="none"/>
<children>
<splitpane id="227bc">
<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">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<orientation value="0"/>
</properties>
<border type="none"/>
<children>
<component id="37ff7" class="javax.swing.JTextPane" binding="myStacktrace">
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
</component>
<scrollpane id="ef29" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<splitpane position="left"/>
</constraints>
<properties>
<minimumSize width="23" height="250"/>
</properties>
<border type="none"/>
<children>
<component id="3cc44" class="com.intellij.ui.table.JBTable" binding="myRequestsTable">
<constraints/>
<properties>
<autoResizeMode value="3"/>
<autoscrolls value="false"/>
<minimumSize width="30" height="250"/>
<preferredSize width="150" height="150"/>
</properties>
</component>
</children>
</scrollpane>
</children>
</splitpane>
</children>
</grid>
</form>
@@ -20,6 +20,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.wm.impl.FocusRequestInfo;
import com.intellij.ui.JBColor;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.table.JBTable;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -39,9 +41,8 @@ import java.util.List;
* @author Konstantin Bulenkov
*/
public class FocusTracesDialog extends DialogWrapper {
private JTextPane myStacktrace;
private JBTable myRequestsTable;
private JPanel myRootPanel;
private final JTextPane myStacktrace = new JTextPane();
private final JBTable myRequestsTable;
private final List<FocusRequestInfo> myRequests;
private static final String[] COLUMNS = {"Time", "Forced", "Component"};
@@ -49,19 +50,24 @@ public class FocusTracesDialog extends DialogWrapper {
super(project);
myRequests = requests;
setTitle("Focus Traces");
init();
final String[][] data = new String[requests.size()][];
for (int i = 0; i < data.length; i++) {
final FocusRequestInfo r = requests.get(i);
data[i] = new String[]{r.getDate(), String.valueOf(r.isForced()), String.valueOf(r.getComponent())};
}
myRequestsTable.setModel(new DefaultTableModel(data, COLUMNS));
myRequestsTable = new JBTable(new DefaultTableModel(data, COLUMNS) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
});
final ListSelectionListener selectionListener = new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
final int index = myRequestsTable.getSelectedRow();
if (-1 < index && index < myRequests.size()) {
myStacktrace.setText(myRequests.get(index).getStackTrace());
myStacktrace.setCaretPosition(0);
}
else {
myStacktrace.setText("");
@@ -70,12 +76,15 @@ public class FocusTracesDialog extends DialogWrapper {
};
myRequestsTable.getSelectionModel().addListSelectionListener(selectionListener);
final TableColumnModel columnModel = myRequestsTable.getColumnModel();
columnModel.getColumn(0).setMinWidth(120);
columnModel.getColumn(0).setMaxWidth(120);
columnModel.getColumn(0).setPreferredWidth(120);
columnModel.getColumn(1).setMinWidth(60);
columnModel.getColumn(1).setMaxWidth(60);
columnModel.getSelectionModel().addListSelectionListener(selectionListener);
columnModel.setColumnSelectionAllowed(false);
columnModel.getColumn(1).setPreferredWidth(60);
myRequestsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myRequestsTable.changeSelection(0, 0, false, true);
init();
}
@Override
@@ -85,7 +94,13 @@ public class FocusTracesDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
return myRootPanel;
JPanel panel = new JPanel(new BorderLayout());
JBSplitter splitter = new JBSplitter(true, .5F, .2F, .8F);
splitter.setFirstComponent(new JBScrollPane(myRequestsTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
splitter.setSecondComponent(
new JBScrollPane(myStacktrace, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
panel.add(splitter, BorderLayout.CENTER);
return panel;
}
@Override