mirror of https://github.com/acidanthera/audk.git
1. Fix EDKT411: Need right and left scroll bar to display find results
2. Add a function in Tools.java to adjust a table's all columns' width git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1788 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
20480ea138
commit
350785ff49
|
@ -27,6 +27,7 @@ import javax.swing.DefaultListModel;
|
|||
import javax.swing.JComboBox;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
|
||||
import org.tianocore.MsaHeaderDocument.MsaHeader;
|
||||
|
@ -553,6 +554,22 @@ public class Tools {
|
|||
resizeComponentHeight(c, containerHeight, preferredHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
To adjust each column's width to meet the table's size
|
||||
|
||||
@param t the table need to be adjusted
|
||||
@param width the new width of the table
|
||||
|
||||
**/
|
||||
public static void resizeTableColumn(JTable t, int width) {
|
||||
if (t != null) {
|
||||
int columnCount = t.getColumnCount();
|
||||
for (int index = 0; index < columnCount; index++) {
|
||||
t.getColumn(t.getColumnName(index)).setPreferredWidth(width / columnCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To relocate the input component
|
||||
*
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common.find;
|
|||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.Vector;
|
||||
|
||||
|
@ -37,7 +38,7 @@ import org.tianocore.frameworkwizard.common.Log;
|
|||
import org.tianocore.frameworkwizard.common.Tools;
|
||||
import org.tianocore.frameworkwizard.common.ui.IFrame;
|
||||
|
||||
public class FindResult extends IFrame implements TableModelListener {
|
||||
public class FindResult extends IFrame implements TableModelListener, ComponentListener {
|
||||
|
||||
///
|
||||
/// Define class Serial Version UID
|
||||
|
@ -156,6 +157,10 @@ public class FindResult extends IFrame implements TableModelListener {
|
|||
if (jTable == null) {
|
||||
model = new IDefaultTableModel();
|
||||
jTable = new JTable(model);
|
||||
jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
|
||||
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
jTable.getModel().addTableModelListener(this);
|
||||
|
||||
model.addColumn("Name");
|
||||
model.addColumn("Type");
|
||||
|
@ -169,8 +174,17 @@ public class FindResult extends IFrame implements TableModelListener {
|
|||
jTable.getColumn("Consumed by").setCellRenderer(new MyTableCellRenderer());
|
||||
jTable.getColumn("Declared by").setCellRenderer(new MyTableCellRenderer());
|
||||
|
||||
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
jTable.getModel().addTableModelListener(this);
|
||||
// jTable.getColumn("Name").setPreferredWidth((this.getSize().width - 30) / 5);
|
||||
// jTable.getColumn("Type").setPreferredWidth((this.getSize().width - 30) / 5);
|
||||
// jTable.getColumn("Produced by").setPreferredWidth((this.getSize().width - 30) / 5);
|
||||
// jTable.getColumn("Consumed by").setPreferredWidth((this.getSize().width - 30) / 5);
|
||||
// jTable.getColumn("Declared by").setPreferredWidth((this.getSize().width - 30) / 5);
|
||||
int columnWidth = (this.getSize().width - 28) / 5;
|
||||
jTable.getColumn("Name").setPreferredWidth(columnWidth);
|
||||
jTable.getColumn("Type").setPreferredWidth(columnWidth);
|
||||
jTable.getColumn("Produced by").setPreferredWidth(columnWidth);
|
||||
jTable.getColumn("Consumed by").setPreferredWidth(columnWidth);
|
||||
jTable.getColumn("Declared by").setPreferredWidth(columnWidth);
|
||||
}
|
||||
return jTable;
|
||||
}
|
||||
|
@ -451,6 +465,7 @@ public class FindResult extends IFrame implements TableModelListener {
|
|||
intPreferredHeight);
|
||||
Tools.centerComponent(this.jButtonClose, intCurrentWidth, intCurrentHeight, intPreferredHeight,
|
||||
DataType.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON);
|
||||
Tools.resizeTableColumn(this.jTable, this.getSize().width - 28);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Reference in New Issue