Skip to content

Commit df72456

Browse files
committed
Added button to add common ignore rules to the UI
1 parent 9d17a4a commit df72456

File tree

2 files changed

+328
-31
lines changed

2 files changed

+328
-31
lines changed

cli/src/main/java/ca/weblite/jdeploy/gui/tabs/BundleFiltersPanel.java

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ca.weblite.jdeploy.gui.tabs;
22

33
import ca.weblite.jdeploy.models.Platform;
4+
import ca.weblite.jdeploy.services.RecommendedIgnoreRulesService;
45
import org.apache.commons.io.FileUtils;
56

67
import javax.swing.*;
@@ -25,6 +26,7 @@ public class BundleFiltersPanel extends JPanel {
2526
private final JTabbedPane tabbedPane;
2627
private final Map<Platform, JTextArea> textAreas;
2728
private final Map<Platform, JScrollPane> scrollPanes;
29+
private final RecommendedIgnoreRulesService recommendedRulesService;
2830
private DocumentListener changeListener;
2931

3032
// Callback to notify parent when changes occur
@@ -40,6 +42,7 @@ public BundleFiltersPanel(File projectDirectory) {
4042
this.tabbedPane = new JTabbedPane();
4143
this.textAreas = new HashMap<>();
4244
this.scrollPanes = new HashMap<>();
45+
this.recommendedRulesService = new RecommendedIgnoreRulesService();
4346

4447
initializeUI();
4548
loadExistingFiles();
@@ -189,21 +192,6 @@ private JPanel createHelpPanel() {
189192
return helpPanel;
190193
}
191194

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-
207195
/**
208196
* Gets example text for a platform.
209197
*/
@@ -361,33 +349,65 @@ private void clearCurrentTab() {
361349
}
362350

363351
/**
364-
* Adds common patterns to the currently selected tab.
352+
* Adds common patterns to the currently selected tab using the RecommendedIgnoreRulesService.
365353
*/
366354
private void addCommonPatterns() {
367355
int selectedTab = tabbedPane.getSelectedIndex();
368356
Platform platform = getPlatformForTabIndex(selectedTab);
369357
JTextArea textArea = textAreas.get(platform);
370358

371359
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);
386373

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+
}
388393
}
389394
}
390395

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+
}
391411

392412
/**
393413
* Gets the root component for embedding in the main editor.

0 commit comments

Comments
 (0)