1919import org .pwss .model .request .notes .RestoreNoteType ;
2020import org .pwss .model .table .MonitoredDirectoryTableModel ;
2121import org .pwss .utils .StringConstants ;
22+ import org .pwss .utils .StringUtils ;
2223import org .pwss .view .popup_menu .listener .MonitoredDirectoryPopupListener ;
2324
2425/**
25- * Factory class to create a context menu (popup menu) for monitored directories in a JTable.
26- * The menu provides options to scan the directory, reset its baseline, and edit its details.
26+ * Factory class to create a context menu (popup menu) for monitored directories
27+ * in a JTable.
28+ * The menu provides options to scan the directory, reset its baseline, and edit
29+ * its details.
2730 */
2831public class MonitoredDirectoryPopupFactory {
2932 private final MonitoredDirectoryPopupListener listener ;
@@ -39,11 +42,13 @@ public JPopupMenu create(JTable table, int viewRow) {
3942 MonitoredDirectoryTableModel model = (MonitoredDirectoryTableModel ) table .getModel ();
4043 Optional <MonitoredDirectory > dirOpt = model .getDirectoryAt (modelRow );
4144
42- if (dirOpt .isEmpty ()) return menu ;
45+ if (dirOpt .isEmpty ())
46+ return menu ;
4347 MonitoredDirectory dir = dirOpt .get ();
4448
4549 // Scan this directory
46- JMenuItem scanItem = new JMenuItem (dir .baselineEstablished () ? StringConstants .MON_DIR_POPUP_START_SCAN : StringConstants .MON_DIR_POPUP_ESTABLISH_BASELINE );
50+ JMenuItem scanItem = new JMenuItem (dir .baselineEstablished () ? StringConstants .MON_DIR_POPUP_START_SCAN
51+ : StringConstants .MON_DIR_POPUP_ESTABLISH_BASELINE );
4752 scanItem .addActionListener (e -> listener .onStartScan ());
4853
4954 // Reset baseline
@@ -87,19 +92,23 @@ public JPopupMenu create(JTable table, int viewRow) {
8792 * @return the JMenuItem for toggling the active status
8893 */
8994 private JMenuItem getToggleActiveMenuItem (MonitoredDirectory dir ) {
90- JMenuItem editItem = new JMenuItem (dir .isActive () ? StringConstants .MON_DIR_TOGGLE_ACTIVE_DISABLE : StringConstants .MON_DIR_TOGGLE_ACTIVE_ENABLE );
95+ JMenuItem editItem = new JMenuItem (dir .isActive () ? StringConstants .MON_DIR_TOGGLE_ACTIVE_DISABLE
96+ : StringConstants .MON_DIR_TOGGLE_ACTIVE_ENABLE );
9197 editItem .addActionListener (e -> listener .onToggleActiveStatus (dir ));
9298 return editItem ;
9399 }
94100
95101 /**
96- * Creates a menu item for toggling the inclusion of subdirectories in a monitored directory.
102+ * Creates a menu item for toggling the inclusion of subdirectories in a
103+ * monitored directory.
97104 *
98105 * @param dir the monitored directory for which to create the menu item
99106 * @return the JMenuItem for toggling the inclusion of subdirectories
100107 */
101108 private JMenuItem getToggleIncludeSubDirsItem (MonitoredDirectory dir ) {
102- JMenuItem editItem = new JMenuItem (dir .includeSubdirectories () ? StringConstants .MON_DIR_TOGGLE_INCLUDE_SUBDIR_DISABLE : StringConstants .MON_DIR_TOGGLE_INCLUDE_SUBDIR_ENABLE );
109+ JMenuItem editItem = new JMenuItem (
110+ dir .includeSubdirectories () ? StringConstants .MON_DIR_TOGGLE_INCLUDE_SUBDIR_DISABLE
111+ : StringConstants .MON_DIR_TOGGLE_INCLUDE_SUBDIR_ENABLE );
103112 editItem .addActionListener (e -> listener .onToggleIncludeSubdirectories (dir ));
104113 return editItem ;
105114 }
@@ -121,8 +130,7 @@ private JMenuItem getShowNoteItem(MonitoredDirectory dir) {
121130 listener .getParentComponent (),
122131 note ,
123132 StringConstants .MON_DIR_POPUP_SHOW_NOTE ,
124- JOptionPane .INFORMATION_MESSAGE
125- );
133+ JOptionPane .INFORMATION_MESSAGE );
126134 });
127135 return showNoteItem ;
128136 }
@@ -137,7 +145,8 @@ private JMenuItem getUpdateNoteItem(MonitoredDirectory dir) {
137145 JMenuItem updateNoteItem = new JMenuItem (StringConstants .MON_DIR_POPUP_UPDATE_NOTE );
138146 updateNoteItem .addActionListener (e -> {
139147 // Label for directory path
140- JLabel label = new JLabel (StringConstants .MON_DIR_POPUP_UPDATE_NOTE_POPUP_PREFIX + dir .path ());
148+ JLabel label = new JLabel (
149+ StringConstants .MON_DIR_POPUP_UPDATE_NOTE_POPUP_PREFIX + StringUtils .prependSpace (dir .path ()));
141150 label .setAlignmentX (Component .LEFT_ALIGNMENT );
142151
143152 // Text area for note input
@@ -164,8 +173,7 @@ private JMenuItem getUpdateNoteItem(MonitoredDirectory dir) {
164173 panel ,
165174 StringConstants .MON_DIR_POPUP_UPDATE_NOTE ,
166175 JOptionPane .OK_CANCEL_OPTION ,
167- JOptionPane .PLAIN_MESSAGE
168- );
176+ JOptionPane .PLAIN_MESSAGE );
169177
170178 // User cancelled
171179 if (result != JOptionPane .OK_OPTION )
@@ -200,8 +208,7 @@ private JMenuItem getRestoreNoteItem(MonitoredDirectory dir) {
200208 listener .getParentComponent (),
201209 StringConstants .MON_DIR_POPUP_RESTORE_NO_NOTE_FALLBACK + dir .path (),
202210 StringConstants .MON_DIR_POPUP_RESTORE_NOTE ,
203- JOptionPane .INFORMATION_MESSAGE
204- );
211+ JOptionPane .INFORMATION_MESSAGE );
205212 return ;
206213 }
207214
@@ -241,8 +248,7 @@ private JMenuItem getRestoreNoteItem(MonitoredDirectory dir) {
241248 JOptionPane .PLAIN_MESSAGE ,
242249 null ,
243250 options .toArray (),
244- options .get (0 )
245- );
251+ options .get (0 ));
246252
247253 // Handle result
248254 if (choice == JOptionPane .CLOSED_OPTION || choice == options .size () - 1 ) {
@@ -273,8 +279,7 @@ private JMenuItem getResetBaselineItem(MonitoredDirectory dir) {
273279 listener .getParentComponent (),
274280 StringConstants .MON_DIR_POPUP_RESET_BASELINE_POPUP_MESSAGE + dir .path (),
275281 StringConstants .MON_DIR_POPUP_RESET_BASELINE_POPUP_TITLE ,
276- JOptionPane .WARNING_MESSAGE
277- );
282+ JOptionPane .WARNING_MESSAGE );
278283
279284 try {
280285 // User cancelled
@@ -290,4 +295,3 @@ private JMenuItem getResetBaselineItem(MonitoredDirectory dir) {
290295 return resetBaselineItem ;
291296 }
292297}
293-
0 commit comments