use of com.jsql.view.swing.table.PanelTable in project jsql-injection by ron190.
the class ActionSaveTab method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
this.filechooser.setDialogTitle("Save Tab As");
Component component = MediatorGui.tabResults().getSelectedComponent();
if (component instanceof PanelTable) {
this.saveTablePanel();
} else if (component instanceof LightScrollPane && ((LightScrollPane) component).scrollPane.getViewport().getView() instanceof JTextComponent) {
this.saveJTextComponent();
}
}
use of com.jsql.view.swing.table.PanelTable in project jsql-injection by ron190.
the class ActionSaveTab method saveTablePanel.
private void saveTablePanel() {
JTable table = ((PanelTable) MediatorGui.tabResults().getSelectedComponent()).getTableValues();
if (table == null) {
return;
}
int returnVal = this.filechooser.showSaveDialog(MediatorGui.frame());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = this.filechooser.getSelectedFile();
PreferencesUtil.set(this.filechooser.getCurrentDirectory().toString());
try (FileWriter excel = new FileWriter(file)) {
TableModel model = table.getModel();
for (int i = 2; i < model.getColumnCount(); i++) {
excel.write(model.getColumnName(i) + "\t");
}
excel.write("\n");
for (int i = 0; i < model.getRowCount(); i++) {
for (int j = 2; j < model.getColumnCount(); j++) {
/*
* Cell empty when string was too long to be injected (columnTooLong|cellEmpty|cellEmpty).
*/
if (model.getValueAt(i, j) == null) {
excel.write("\t");
/*
* Remove line break.
*/
} else {
excel.write(model.getValueAt(i, j).toString().replaceAll("\n", "\\n").replaceAll("\t", "\\t") + "\t");
}
}
excel.write("\n");
}
} catch (IOException e) {
LOGGER.warn("Error writing to " + file.getName(), e);
}
}
}
use of com.jsql.view.swing.table.PanelTable in project jsql-injection by ron190.
the class CreateValuesTab method execute.
@Override
public void execute() {
if (MediatorGui.frame() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
}
// Report NullPointerException #1683
DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.table);
if (node != null) {
// Get the node
AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
// Update the progress value of the model, end the progress
progressingTreeNodeModel.setIndexProgress(this.table.getChildCount());
// Mark the node model as 'no stop/pause/resume button'
progressingTreeNodeModel.setRunning(false);
// Create a new table to display the values
PanelTable newTableJPanel = new PanelTable(this.data, this.columnNames);
// Create a new tab: add header and table
MediatorGui.tabResults().addTab(StringUtil.detectUtf8(this.table.toString()), newTableJPanel);
newTableJPanel.setComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
// Focus on the new tab
MediatorGui.tabResults().setSelectedComponent(newTableJPanel);
// Create a custom tab header with close button
TabHeader header = new TabHeader(StringUtil.detectUtf8Html(this.table.toString()));
MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), "<html>" + "<b>" + this.table.getParent() + "." + this.table + "</b><br>" + "<i>" + String.join("<br>", Arrays.copyOfRange(this.columnNames, 2, this.columnNames.length)) + "</i>" + "</html>");
// Apply the custom header to the tab
MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), header);
}
}
Aggregations