Skip to content

Commit

Permalink
Fixed #294 (color picker in attribute manager) and a bug in the docum…
Browse files Browse the repository at this point in the history
…ent batch importer GUI
  • Loading branch information
leifeld committed Aug 26, 2024
1 parent 8fb93d2 commit eaef4e8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dna/src/main/java/dna/Dna.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class Dna {
public static Dna dna;
public static Logger logger;
public static Sql sql;
public static final String date = "2024-08-20";
public static final String version = "3.0.11";
public static final String date = "2024-08-26";
public static final String version = "3.0.12.1";
public static final String operatingSystem = System.getProperty("os.name");
public static File workingDirectory = null;
public static Gui gui;
Expand Down
6 changes: 3 additions & 3 deletions dna/src/main/java/gui/AttributeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ public void setValueAt(Object aValue, int row, int col) {
}
} else if (col == 2) { // color
try {
Dna.sql.setEntityColor(this.rows.get(row).getId(), (model.Color) aValue);
this.rows.get(row).setColor((model.Color) aValue);
Dna.sql.setEntityColor(this.rows.get(row).getId(), new model.Color(((Color) aValue).getRed(), ((Color) aValue).getGreen(), ((Color) aValue).getBlue()));
this.rows.get(row).setColor(new model.Color(((Color) aValue).getRed(), ((Color) aValue).getGreen(), ((Color) aValue).getBlue()));
} catch (SQLException ex) {
LogEvent l = new LogEvent(Logger.ERROR,
"[SQL] Entity color could not be updated in the database.",
Expand Down Expand Up @@ -921,7 +921,7 @@ private void changeColor(Color color) {
* @param column The column index of the cell.
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
changeColor((Color) value);
changeColor(((model.Color) value).toAWTColor());
panel.setBackground(UIManager.getColor("Table.selectionBackground"));
return panel;
}
Expand Down
37 changes: 26 additions & 11 deletions dna/src/main/java/gui/DocumentBatchImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,32 @@ public void actionPerformed(ActionEvent e) {
JButton browseButton = new JButton("Select text files", folderIcon);
browseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileChooser fc = new FileChooser(DocumentBatchImporter.this, "Select directory", false, "", "Import directory", true);
if (fc.getFiles() != null) {
files = fc.getFiles();
listModel.clear();
Arrays.stream(fc.getFiles())
.filter(f -> f.isFile())
.map(f -> f.getName())
.forEachOrdered(f -> listModel.addElement(f));
fileList.updateUI();
if (files.length > 0) {
fileList.setSelectedIndex(0);
FileChooser fc = null;
try {
fc = new FileChooser(DocumentBatchImporter.this, "Select text files", false, "", "Import files", true);
} catch (NullPointerException npe) {
LogEvent l = new LogEvent(Logger.MESSAGE,
"[GUI] Cancelled file selection in batch import window.",
"Cancelled file selection in batch import window. No files were selected.");
Dna.logger.log(l);
} finally {
if (fc != null && fc.getFiles() != null) {
files = fc.getFiles();
listModel.clear();
Arrays.stream(fc.getFiles())
.filter(f -> f.isFile())
.map(f -> f.getName())
.forEachOrdered(f -> listModel.addElement(f));
fileList.updateUI();
if (files.length > 0) {
fileList.setSelectedIndex(0);
}
} else {
// no files were selected or FileChooser was cancelled
LogEvent l = new LogEvent(Logger.MESSAGE,
"[GUI] No files were selected in the batch import window.",
"File selection was cancelled or no files were selected.");
Dna.logger.log(l);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rDNA/rDNA/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rDNA
Version: 3.0.11
Date: 2024-08-20
Version: 3.0.12.1
Date: 2024-08-26
Title: Discourse Network Analysis in R
Authors@R:
c(person(given = "Philip",
Expand Down

0 comments on commit eaef4e8

Please sign in to comment.