updated code to follow brief's format better and tested save and open functionality

This commit is contained in:
bobbert committed 2025-04-02 17:09:53 +01:00
1 parent 559d346c58
commit 44f5279d36
4 files changed
+19 -29

No files matched your search

@@ -5,7 +5,7 @@ import java.util.Map;
public class CsvExportSettings {
private static CsvExportSettings instance;
private Map<String, Boolean> includeMap = new HashMap<>();
private final Map<String, Boolean> includeMap = new HashMap<>();
private CsvExportSettings() {
// Initialize default values for all fields to be included
+1 -1
View File
@@ -5,7 +5,7 @@ import java.util.ArrayList;
public class UserGroup {
private static UserGroup instance;
private ArrayList<User> users;
private final ArrayList<User> users;
private UserGroup() {
users = new ArrayList<>();
+12 -22
View File
@@ -7,12 +7,12 @@ import cvbuilder.model.UserGroup;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.*;
public class MainViewer {
private UserGroup userGroup;
private final UserGroup userGroup;
public MainViewer() {
userGroup = UserGroup.getInstance();
@@ -160,24 +160,18 @@ public class MainViewer {
// Add some spacing
entryPanel.add(Box.createHorizontalStrut(5));
// Create Delete button
// Create delete button
JButton deleteButton = new JButton("Delete");
deleteButton.addActionListener(e -> {
int confirm = JOptionPane.showConfirmDialog(panel,
"Are you sure you want to delete this entry?",
"Confirm Delete", JOptionPane.YES_NO_OPTION);
// Remove the user without confirmation
userGroup.getUsers().remove(userIndex);
if (confirm == JOptionPane.YES_OPTION) {
// Remove the user
userGroup.getUsers().remove(userIndex);
// Refresh all panels
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(panel);
frame.getContentPane().removeAll();
populateMainPanel(frame);
frame.revalidate();
frame.repaint();
}
// Refresh all panels
JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(panel);
frame.getContentPane().removeAll();
populateMainPanel(frame);
frame.revalidate();
frame.repaint();
});
entryPanel.add(deleteButton);
@@ -519,10 +513,7 @@ public class MainViewer {
writer.println();
}
JOptionPane.showMessageDialog(null,
"CSV file saved successfully to " + filePath,
"Save Successful",
JOptionPane.INFORMATION_MESSAGE);
// Success message removed
} catch (IOException e) {
JOptionPane.showMessageDialog(null,
@@ -532,5 +523,4 @@ public class MainViewer {
}
}
}