1
1
package ca .weblite .jdeploy .gui .tabs ;
2
2
3
3
import ca .weblite .jdeploy .models .Platform ;
4
+ import ca .weblite .jdeploy .services .RecommendedIgnoreRulesService ;
4
5
import org .apache .commons .io .FileUtils ;
5
6
6
7
import javax .swing .*;
@@ -25,6 +26,7 @@ public class BundleFiltersPanel extends JPanel {
25
26
private final JTabbedPane tabbedPane ;
26
27
private final Map <Platform , JTextArea > textAreas ;
27
28
private final Map <Platform , JScrollPane > scrollPanes ;
29
+ private final RecommendedIgnoreRulesService recommendedRulesService ;
28
30
private DocumentListener changeListener ;
29
31
30
32
// Callback to notify parent when changes occur
@@ -40,6 +42,7 @@ public BundleFiltersPanel(File projectDirectory) {
40
42
this .tabbedPane = new JTabbedPane ();
41
43
this .textAreas = new HashMap <>();
42
44
this .scrollPanes = new HashMap <>();
45
+ this .recommendedRulesService = new RecommendedIgnoreRulesService ();
43
46
44
47
initializeUI ();
45
48
loadExistingFiles ();
@@ -189,21 +192,6 @@ private JPanel createHelpPanel() {
189
192
return helpPanel ;
190
193
}
191
194
192
- /**
193
- * Gets the display name for a platform.
194
- */
195
- private String getPlatformDisplayName (Platform platform ) {
196
- switch (platform ) {
197
- case MAC_X64 : return "macOS Intel" ;
198
- case MAC_ARM64 : return "macOS Silicon" ;
199
- case WIN_X64 : return "Windows x64" ;
200
- case WIN_ARM64 : return "Windows ARM" ;
201
- case LINUX_X64 : return "Linux x64" ;
202
- case LINUX_ARM64 : return "Linux ARM" ;
203
- default : return platform .getIdentifier ();
204
- }
205
- }
206
-
207
195
/**
208
196
* Gets example text for a platform.
209
197
*/
@@ -361,33 +349,65 @@ private void clearCurrentTab() {
361
349
}
362
350
363
351
/**
364
- * Adds common patterns to the currently selected tab.
352
+ * Adds common patterns to the currently selected tab using the RecommendedIgnoreRulesService .
365
353
*/
366
354
private void addCommonPatterns () {
367
355
int selectedTab = tabbedPane .getSelectedIndex ();
368
356
Platform platform = getPlatformForTabIndex (selectedTab );
369
357
JTextArea textArea = textAreas .get (platform );
370
358
371
359
if (textArea != null ) {
372
- String commonPatterns ;
373
- if (platform == Platform .DEFAULT ) {
374
- commonPatterns = "\n # Common ignore patterns\n " +
375
- "com.testing.mocklibs.native\n " +
376
- "com.development.debugging.native\n " +
377
- "debug\n " +
378
- "test\n \n " +
379
- "# Keep required patterns\n " +
380
- "!com.testing.mocklibs.native.required\n " ;
381
- } else {
382
- commonPatterns = "\n # Keep " + getPlatformDisplayName (platform ) + " native libraries\n " +
383
- "!ca.weblite.native." + platform .getIdentifier () + "\n " +
384
- "!com.myapp.native." + platform .getIdentifier () + "\n " ;
385
- }
360
+ // Show confirmation dialog
361
+ String platformName = getPlatformDisplayName (platform );
362
+ int result = JOptionPane .showConfirmDialog (this ,
363
+ "This will append recommended ignore patterns for " + platformName + ".\n " +
364
+ "These patterns help optimize bundle sizes for common frameworks like:\n " +
365
+ "• Compose Multiplatform (Skiko)\n " +
366
+ "• SQLite native libraries\n " +
367
+ "• JavaFX (global rules only)\n " +
368
+ "• General native library patterns\n \n " +
369
+ "Continue?" ,
370
+ "Add Common Patterns" ,
371
+ JOptionPane .YES_NO_OPTION ,
372
+ JOptionPane .QUESTION_MESSAGE );
386
373
387
- textArea .append (commonPatterns );
374
+ if (result == JOptionPane .YES_OPTION ) {
375
+ String recommendedRules = recommendedRulesService .generateRecommendedRulesText (platform );
376
+
377
+ // Add spacing if text area already has content
378
+ String existingText = textArea .getText ();
379
+ if (!existingText .trim ().isEmpty () && !existingText .endsWith ("\n " )) {
380
+ textArea .append ("\n \n " );
381
+ } else if (!existingText .trim ().isEmpty ()) {
382
+ textArea .append ("\n " );
383
+ }
384
+
385
+ // Add header comment
386
+ textArea .append ("# Common recommended patterns for " + platformName + "\n " );
387
+ textArea .append ("# Generated on " + new java .util .Date () + "\n " );
388
+ textArea .append (recommendedRules );
389
+
390
+ // Scroll to the end to show the new content
391
+ textArea .setCaretPosition (textArea .getDocument ().getLength ());
392
+ }
388
393
}
389
394
}
390
395
396
+ /**
397
+ * Gets the display name for a platform.
398
+ */
399
+ private String getPlatformDisplayName (Platform platform ) {
400
+ switch (platform ) {
401
+ case DEFAULT : return "Global" ;
402
+ case MAC_X64 : return "macOS Intel" ;
403
+ case MAC_ARM64 : return "macOS Silicon" ;
404
+ case WIN_X64 : return "Windows x64" ;
405
+ case WIN_ARM64 : return "Windows ARM" ;
406
+ case LINUX_X64 : return "Linux x64" ;
407
+ case LINUX_ARM64 : return "Linux ARM" ;
408
+ default : return platform .getIdentifier ();
409
+ }
410
+ }
391
411
392
412
/**
393
413
* Gets the root component for embedding in the main editor.
0 commit comments