forked from External/mage
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
|
@ -48,85 +48,85 @@ import javax.swing.table.TableColumnModel;
|
|||
*/
|
||||
public class ButtonColumn extends AbstractCellEditor implements TableCellRenderer, TableCellEditor, ActionListener, MouseListener {
|
||||
|
||||
private JTable table;
|
||||
private Action action;
|
||||
private JButton renderButton;
|
||||
private JButton editButton;
|
||||
private String text;
|
||||
private boolean isButtonColumnEditor;
|
||||
private JTable table;
|
||||
private Action action;
|
||||
private JButton renderButton;
|
||||
private JButton editButton;
|
||||
private String text;
|
||||
private boolean isButtonColumnEditor;
|
||||
|
||||
public ButtonColumn(JTable table, Action action, int column) {
|
||||
super();
|
||||
this.table = table;
|
||||
this.action = action;
|
||||
renderButton = new JButton();
|
||||
public ButtonColumn(JTable table, Action action, int column) {
|
||||
super();
|
||||
this.table = table;
|
||||
this.action = action;
|
||||
renderButton = new JButton();
|
||||
|
||||
editButton = new JButton();
|
||||
editButton.setFocusPainted(false);
|
||||
editButton.addActionListener(this);
|
||||
editButton = new JButton();
|
||||
editButton.setFocusPainted(false);
|
||||
editButton.addActionListener(this);
|
||||
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
columnModel.getColumn(column).setCellRenderer(this);
|
||||
columnModel.getColumn(column).setCellEditor(this);
|
||||
table.addMouseListener(this);
|
||||
}
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
columnModel.getColumn(column).setCellRenderer(this);
|
||||
columnModel.getColumn(column).setCellEditor(this);
|
||||
table.addMouseListener(this);
|
||||
}
|
||||
|
||||
public Object getCellEditorValue() {
|
||||
return text;
|
||||
}
|
||||
public Object getCellEditorValue() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (hasFocus)
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
else if (isSelected)
|
||||
{
|
||||
renderButton.setForeground(table.getSelectionForeground());
|
||||
renderButton.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (hasFocus)
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
else if (isSelected)
|
||||
{
|
||||
renderButton.setForeground(table.getSelectionForeground());
|
||||
renderButton.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
|
||||
renderButton.setText( (value == null) ? "" : value.toString() );
|
||||
return renderButton;
|
||||
}
|
||||
renderButton.setText( (value == null) ? "" : value.toString() );
|
||||
return renderButton;
|
||||
}
|
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
text = (value == null) ? "" : value.toString();
|
||||
editButton.setText( text );
|
||||
return editButton;
|
||||
}
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
text = (value == null) ? "" : value.toString();
|
||||
editButton.setText( text );
|
||||
return editButton;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int row = table.convertRowIndexToModel( table.getEditingRow() );
|
||||
fireEditingStopped();
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
|
||||
action.actionPerformed(event);
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int row = table.convertRowIndexToModel( table.getEditingRow() );
|
||||
fireEditingStopped();
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
|
||||
action.actionPerformed(event);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
if (table.isEditing() && table.getCellEditor() == this)
|
||||
isButtonColumnEditor = true;
|
||||
}
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
if (table.isEditing() && table.getCellEditor() == this)
|
||||
isButtonColumnEditor = true;
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
if (isButtonColumnEditor && table.isEditing())
|
||||
table.getCellEditor().stopCellEditing();
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
if (isButtonColumnEditor && table.isEditing())
|
||||
table.getCellEditor().stopCellEditing();
|
||||
|
||||
isButtonColumnEditor = false;
|
||||
}
|
||||
isButtonColumnEditor = false;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent arg0) {}
|
||||
public void mouseClicked(MouseEvent arg0) {}
|
||||
|
||||
public void mouseEntered(MouseEvent arg0) {}
|
||||
public void mouseEntered(MouseEvent arg0) {}
|
||||
|
||||
public void mouseExited(MouseEvent arg0) {}
|
||||
public void mouseExited(MouseEvent arg0) {}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue