updated code to follow brief's format better and tested save and open functionality
This commit is contained in:
1 parent
559d346c58
commit
44f5279d36
4 files changed
+19
-29
No files matched your search
+5
-5
@@ -1,6 +1,6 @@
|
||||
Section,Sub-Section,Variants
|
||||
Section,Sub-Section,Variants
|
||||
User,Name,Scheherazade Taylor,SJ Taylor,Shaz Taylor
|
||||
User,Title,Ms.,Miss
|
||||
User,Email,strongshaz@bob.com,gmail_account@gmail.com,k1234567@kingston.ac.uk
|
||||
Contact Information,Phone,07910582346,02083412275
|
||||
Contact Information,Address,11 Rita Road%%%%London SW8 1ND,Flat 4//// Obnoxious House%%%%Rude Road%%%%London KT16 4RT
|
||||
User,Email,strongshaz@bob.com,gmail_account@gmail.com,k2320390@kingston.ac.uk
|
||||
User,Title,Ms.,Miss,Unknown
|
||||
Contact Information,Phone,07910582346,02083412275,Unknown
|
||||
Contact Information,Address,11 Rita Road%%%%London SW8 1ND,Flat 4//// Obnoxious House%%%%Rude Road%%%%London KT16 4RT,Unknown
|
||||
|
@@ -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
|
||||
|
||||
@@ -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<>();
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user