use of quick.dbtable.DBTable in project mafscaling by vimsh.
the class LogView method createLogViewPanel.
private void createLogViewPanel() {
logViewPanel = new JPanel();
GridBagLayout gbl_logViewPanel = new GridBagLayout();
gbl_logViewPanel.columnWidths = new int[] { 0 };
gbl_logViewPanel.rowHeights = new int[] { 0, 0 };
gbl_logViewPanel.columnWeights = new double[] { 1.0 };
gbl_logViewPanel.rowWeights = new double[] { 1.0, 0.0 };
logViewPanel.setLayout(gbl_logViewPanel);
try {
logDataTable = new DBTable();
logDataTable.copyColumnHeaderNames = true;
logDataTable.defaultClickCountToStartEditor = 2;
logDataTable.doNotUseDatabaseSort = true;
logDataTable.listenKeyPressEventsWholeWindow = true;
logDataTable.createControlPanel(DBTable.READ_NAVIGATION);
logDataTable.enableExcelCopyPaste();
logDataTable.setSortEnabled(false);
logDataTable.setSkin(new TableSkin());
logDataTable.refresh(new String[1][25]);
logDataTable.setComparator(new DoubleComparator());
logDataTable.getTable().setCellSelectionEnabled(true);
logDataTable.getTable().setColumnSelectionAllowed(true);
logDataTable.getTable().setRowSelectionAllowed(true);
logDataTable.getTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JTextField rowTextField = ((JTextField) logDataTable.getControlPanel().getComponent(tableRowTextFieldComponentIdx));
rowTextField.setPreferredSize(null);
rowTextField.setColumns(tableRowTextFieldSize);
GridBagConstraints gbc_logDataTable = new GridBagConstraints();
gbc_logDataTable.insets = insets0;
gbc_logDataTable.anchor = GridBagConstraints.PAGE_START;
gbc_logDataTable.fill = GridBagConstraints.BOTH;
gbc_logDataTable.gridx = 0;
gbc_logDataTable.gridy = 0;
logViewPanel.add(logDataTable, gbc_logDataTable);
listModel = new DefaultListModel<JLabel>();
selectionCombo.removeAllItems();
TreeSet<String> sortedCols = new TreeSet<String>();
JTableHeader tableHeader = logDataTable.getTableHeader();
for (int i = 0; i < logDataTable.getColumnCount(); ++i) {
Column col = logDataTable.getColumn(i);
col.setNullable(true);
col.setHeaderRenderer(new CheckboxHeaderRenderer(i + 1, tableHeader));
sortedCols.add(col.getHeaderValue().toString());
}
for (String s : sortedCols) {
selectionCombo.addItem(s);
listModel.addElement(new JLabel(s, new CheckBoxIcon(), JLabel.LEFT));
}
JList<JLabel> menuList = new JList<JLabel>(listModel);
menuList.setOpaque(false);
menuList.setCellRenderer(new ImageListCellRenderer());
menuList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
menuList.setLayoutOrientation(JList.VERTICAL_WRAP);
menuList.setFixedCellHeight(25);
menuList.setVisibleRowCount(-1);
menuList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
if (e.getClickCount() == 1 && colors.size() > 0) {
JList<?> list = (JList<?>) e.getSource();
int index = list.locationToIndex(e.getPoint());
if (index >= 0) {
JLabel label = (JLabel) list.getModel().getElementAt(index);
Column col = logDataTable.getColumnByHeaderName(label.getText());
if (col.getHeaderRenderer() instanceof CheckboxHeaderRenderer) {
CheckboxHeaderRenderer renderer = (CheckboxHeaderRenderer) col.getHeaderRenderer();
CheckBoxIcon checkIcon = (CheckBoxIcon) label.getIcon();
checkIcon.setChecked(!checkIcon.isChecked());
if (checkIcon.isChecked()) {
checkIcon.setColor(colors.pop());
JTable table = logDataTable.getTable();
TableModel model = table.getModel();
addXYSeries(model, col.getModelIndex() - 1, col.getHeaderValue().toString(), checkIcon.getColor());
} else {
colors.push(checkIcon.getColor());
checkIcon.setColor(renderer.getDefaultColor());
removeXYSeries(col.getModelIndex() - 1);
}
list.repaint();
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
headerScrollPane = new JScrollPane(menuList);
GridBagConstraints gbc_headersTree = new GridBagConstraints();
gbc_headersTree.insets = insets0;
gbc_headersTree.anchor = GridBagConstraints.PAGE_START;
gbc_headersTree.fill = GridBagConstraints.BOTH;
gbc_headersTree.gridx = 0;
gbc_headersTree.gridy = 1;
logViewPanel.add(headerScrollPane, gbc_headersTree);
headerScrollPane.setVisible(false);
} catch (Exception e) {
e.printStackTrace();
logger.error(e);
}
}
Aggregations