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
+12
-22
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,Name,Scheherazade Taylor,SJ Taylor,Shaz Taylor
|
||||||
User,Title,Ms.,Miss
|
User,Email,strongshaz@bob.com,gmail_account@gmail.com,k2320390@kingston.ac.uk
|
||||||
User,Email,strongshaz@bob.com,gmail_account@gmail.com,k1234567@kingston.ac.uk
|
User,Title,Ms.,Miss,Unknown
|
||||||
Contact Information,Phone,07910582346,02083412275
|
Contact Information,Phone,07910582346,02083412275,Unknown
|
||||||
Contact Information,Address,11 Rita Road%%%%London SW8 1ND,Flat 4//// Obnoxious House%%%%Rude Road%%%%London KT16 4RT
|
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 {
|
public class CsvExportSettings {
|
||||||
private static CsvExportSettings instance;
|
private static CsvExportSettings instance;
|
||||||
private Map<String, Boolean> includeMap = new HashMap<>();
|
private final Map<String, Boolean> includeMap = new HashMap<>();
|
||||||
|
|
||||||
private CsvExportSettings() {
|
private CsvExportSettings() {
|
||||||
// Initialize default values for all fields to be included
|
// Initialize default values for all fields to be included
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
|||||||
public class UserGroup {
|
public class UserGroup {
|
||||||
|
|
||||||
private static UserGroup instance;
|
private static UserGroup instance;
|
||||||
private ArrayList<User> users;
|
private final ArrayList<User> users;
|
||||||
|
|
||||||
private UserGroup() {
|
private UserGroup() {
|
||||||
users = new ArrayList<>();
|
users = new ArrayList<>();
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import cvbuilder.model.UserGroup;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
|
||||||
public class MainViewer {
|
public class MainViewer {
|
||||||
|
|
||||||
private UserGroup userGroup;
|
private final UserGroup userGroup;
|
||||||
|
|
||||||
public MainViewer() {
|
public MainViewer() {
|
||||||
userGroup = UserGroup.getInstance();
|
userGroup = UserGroup.getInstance();
|
||||||
@@ -160,15 +160,10 @@ public class MainViewer {
|
|||||||
// Add some spacing
|
// Add some spacing
|
||||||
entryPanel.add(Box.createHorizontalStrut(5));
|
entryPanel.add(Box.createHorizontalStrut(5));
|
||||||
|
|
||||||
// Create Delete button
|
// Create delete button
|
||||||
JButton deleteButton = new JButton("Delete");
|
JButton deleteButton = new JButton("Delete");
|
||||||
deleteButton.addActionListener(e -> {
|
deleteButton.addActionListener(e -> {
|
||||||
int confirm = JOptionPane.showConfirmDialog(panel,
|
// Remove the user without confirmation
|
||||||
"Are you sure you want to delete this entry?",
|
|
||||||
"Confirm Delete", JOptionPane.YES_NO_OPTION);
|
|
||||||
|
|
||||||
if (confirm == JOptionPane.YES_OPTION) {
|
|
||||||
// Remove the user
|
|
||||||
userGroup.getUsers().remove(userIndex);
|
userGroup.getUsers().remove(userIndex);
|
||||||
|
|
||||||
// Refresh all panels
|
// Refresh all panels
|
||||||
@@ -177,7 +172,6 @@ public class MainViewer {
|
|||||||
populateMainPanel(frame);
|
populateMainPanel(frame);
|
||||||
frame.revalidate();
|
frame.revalidate();
|
||||||
frame.repaint();
|
frame.repaint();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
entryPanel.add(deleteButton);
|
entryPanel.add(deleteButton);
|
||||||
|
|
||||||
@@ -519,10 +513,7 @@ public class MainViewer {
|
|||||||
writer.println();
|
writer.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null,
|
// Success message removed
|
||||||
"CSV file saved successfully to " + filePath,
|
|
||||||
"Save Successful",
|
|
||||||
JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
@@ -532,5 +523,4 @@ public class MainViewer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user