From de6078a620f86e14eb4ff4be607a9032b59c6140 Mon Sep 17 00:00:00 2001 From: Corey Arthur <1339555+CoreyD97@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:10:05 +0000 Subject: [PATCH] Rework for v2024.11 --- .run/TestPlugin.run.xml | 12 + build.gradle | 36 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../burpcustomizer/BurpCustomizer.java | 178 +++++----- .../coreyd97/burpcustomizer/CustomTheme.java | 304 +++++++++--------- .../burpcustomizer/CustomizerPanel.java | 28 +- .../coreyd97/burpcustomizer/PreviewPanel.java | 48 +-- src/test/java/TestPlugin.java | 15 +- 8 files changed, 302 insertions(+), 321 deletions(-) create mode 100644 .run/TestPlugin.run.xml diff --git a/.run/TestPlugin.run.xml b/.run/TestPlugin.run.xml new file mode 100644 index 0000000..2693a49 --- /dev/null +++ b/.run/TestPlugin.run.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 59ae4ef..1b61a3b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,10 @@ -apply plugin: 'java' -apply plugin: 'maven' +plugins { + id("java") + id("io.freefair.lombok") version "8.6" +} -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 repositories { mavenCentral() @@ -12,31 +14,27 @@ repositories { } dependencies { - compile 'net.portswigger.burp.extender:burp-extender-api:1.7.22' - compile 'com.github.CoreyD97:BurpExtenderUtilities:c03544e3' - compileOnly 'com.formdev:flatlaf:2.4' - compile 'com.formdev:flatlaf-intellij-themes:2.4' - compile 'com.formdev:flatlaf-extras:2.4' -// runtimeOnly files('/home/corey/BurpSuitePro/burpsuite_pro.jar') + compileOnly 'net.portswigger.burp.extensions:montoya-api:2023.12.1' + implementation 'com.rover12421.opensource:JFontChooser:1.0.5-3' + implementation 'com.github.CoreyD97:Burp-Montoya-Utilities:2993e293' + implementation 'com.formdev:flatlaf-intellij-themes:2.4' + compileOnly 'com.formdev:flatlaf:2.4' //Already shipped in burp + compileOnly 'com.formdev:flatlaf-extras:2.4' //Already implemented in burp + implementation files('/home/corey/BurpSuitePro/burpsuite_pro.jar') // testCompile files('/home/corey/BurpSuiteCommunity/burpsuite_community.jar') } jar { - baseName = project.name - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + archiveBaseName = project.name + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } } task testJar(type: Jar) { - baseName = project.name + "-TEST" + archiveBaseName = project.name + "-TEST" from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } } with jar } - -configurations.all { - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' -} - tasks.withType(Jar) { - destinationDir = file("$rootDir/releases") + destinationDirectory = file("$rootDir/releases") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 44e7c4d..a595206 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/coreyd97/burpcustomizer/BurpCustomizer.java b/src/main/java/com/coreyd97/burpcustomizer/BurpCustomizer.java index e427028..fb853bd 100644 --- a/src/main/java/com/coreyd97/burpcustomizer/BurpCustomizer.java +++ b/src/main/java/com/coreyd97/burpcustomizer/BurpCustomizer.java @@ -1,85 +1,78 @@ package com.coreyd97.burpcustomizer; -import burp.IBurpExtender; -import burp.IBurpExtenderCallbacks; -import burp.IExtensionStateListener; -import burp.ITab; +import burp.api.montoya.BurpExtension; +import burp.api.montoya.MontoyaApi; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.IntelliJTheme; import com.formdev.flatlaf.extras.FlatInspector; import com.formdev.flatlaf.extras.FlatUIDefaultsInspector; import com.formdev.flatlaf.intellijthemes.FlatAllIJThemes; +import lombok.Getter; +import lombok.SneakyThrows; import javax.swing.*; import java.awt.*; import java.io.*; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Optional; +import java.util.stream.Collectors; -public class BurpCustomizer implements ITab, IBurpExtender, IExtensionStateListener { +public class BurpCustomizer implements BurpExtension { enum ThemeSource {BUILTIN, FILE} - private boolean compatible; + private LookAndFeel originalBurpTheme; + @Getter private ArrayList themes; + @Getter private UIManager.LookAndFeelInfo selectedBuiltIn; + @Getter private File selectedThemeFile; + @Getter private ThemeSource themeSource; private CustomizerPanel ui; - public static IBurpExtenderCallbacks callbacks; + public static MontoyaApi montoya; JMenuBar menuBar; JMenu menuItem; - public BurpCustomizer(){ - themes = new ArrayList<>(Arrays.asList(FlatAllIJThemes.INFOS)); + public BurpCustomizer() { + themes = (ArrayList) Arrays.asList(FlatAllIJThemes.INFOS).stream() + .filter(lookAndFeelInfo -> !lookAndFeelInfo.getName().equalsIgnoreCase("Xcode-Dark")) + .map(flatIJLookAndFeelInfo -> (UIManager.LookAndFeelInfo) flatIJLookAndFeelInfo) + .collect(Collectors.toList()); themes.sort(Comparator.comparing(UIManager.LookAndFeelInfo::getName)); } + @SneakyThrows @Override - public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { - BurpCustomizer.callbacks = callbacks; + public void initialize(MontoyaApi montoyaApi) { + BurpCustomizer.montoya = montoyaApi; originalBurpTheme = UIManager.getLookAndFeel(); - String sourceEnum = callbacks.loadExtensionSetting("source"); - if(sourceEnum == null || sourceEnum.equalsIgnoreCase("")){ + String sourceEnum = montoya.persistence().preferences().getString("source"); + if (sourceEnum == null || sourceEnum.equalsIgnoreCase("")) { themeSource = ThemeSource.BUILTIN; - }else { + } else { themeSource = ThemeSource.valueOf(sourceEnum); } - String builtIn = callbacks.loadExtensionSetting("theme"); + String builtIn = montoya.persistence().preferences().getString("theme"); Optional previousTheme = themes.stream().filter(lookAndFeelInfo -> lookAndFeelInfo.getClassName().equalsIgnoreCase(builtIn)).findFirst(); - if(previousTheme.isPresent()) selectedBuiltIn = previousTheme.get(); + previousTheme.ifPresent(lookAndFeelInfo -> selectedBuiltIn = lookAndFeelInfo); - String themeFilePref = callbacks.loadExtensionSetting("themeFile"); - if(themeFilePref != null && !themeFilePref.equalsIgnoreCase("")){ + String themeFilePref = montoya.persistence().preferences().getString("themeFile"); + if (themeFilePref != null && !themeFilePref.equalsIgnoreCase("")) { selectedThemeFile = new File(themeFilePref); - if(!selectedThemeFile.exists()) selectedThemeFile = null; + if (!selectedThemeFile.exists()) selectedThemeFile = null; } - - try{ - ClassLoader.getSystemClassLoader().loadClass("burp.theme.BurpDarkLaf"); - compatible = true; - } catch (ClassNotFoundException e) { - compatible = false; - } - - FlatInspector.install("ctrl shift alt U"); FlatUIDefaultsInspector.install("ctrl shift alt Y"); - - SwingUtilities.invokeLater(() -> { - if(themeSource == ThemeSource.BUILTIN && selectedBuiltIn != null){ - setTheme(selectedBuiltIn); - }else if(themeSource == ThemeSource.FILE && selectedThemeFile != null){ - setTheme(selectedThemeFile); - } - this.ui = new CustomizerPanel(this); + FlatInspector.install("ctrl shift alt U"); + patchPopupFactoryForFlatInspector(); // Arrays.stream(Frame.getFrames()).filter(frame -> frame.getTitle().startsWith("Burp Suite") && frame.isVisible() && frame.getMenuBar() != null).findFirst().ifPresent(frame -> { // menuItem = new JMenu("Customize"); @@ -95,111 +88,106 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { // } // }); - callbacks.registerExtensionStateListener(this::extensionUnloaded); - callbacks.addSuiteTab(this); - }); - } - - @Override - public String getTabCaption() { - return "Customizer"; - } - - @Override - public Component getUiComponent() { - return this.ui; - } - - public UIManager.LookAndFeelInfo getSelectedBuiltIn() { - return selectedBuiltIn; - } + this.ui = new CustomizerPanel(this); + montoya.extension().registerUnloadingHandler(this::extensionUnloaded); - public File getSelectedThemeFile() { - return selectedThemeFile; - } - - public ThemeSource getThemeSource(){ - return this.themeSource; - } + SwingUtilities.invokeLater(() -> { + if (themeSource == ThemeSource.BUILTIN && selectedBuiltIn != null) { + setTheme(selectedBuiltIn); + } else if (themeSource == ThemeSource.FILE && selectedThemeFile != null) { + setTheme(selectedThemeFile); + } - public ArrayList getThemes(){ - return this.themes; + montoya.userInterface().registerSuiteTab("Customizer", this.ui); + }); } - public boolean isCompatible() { - return compatible; + //Since Burp explicitly disables HTML in components we need to manually re-enable HTML for the inspector tooltip. + //Shouldn't reintroduce any vulnerabilities unless somehow a malicious value is used in a tooltip somewhere which is unlikely + private void patchPopupFactoryForFlatInspector() { + PopupFactory.setSharedInstance(new PopupFactory() { + @Override + public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException { + if (contents instanceof JToolTip) { + ((JToolTip) contents).putClientProperty("html.disable", false); + } + return super.getPopup(owner, contents, x, y); + } + }); } - public void setTheme(UIManager.LookAndFeelInfo lookAndFeelInfo){ - if(!compatible) return; + public void setTheme(UIManager.LookAndFeelInfo lookAndFeelInfo) { try { - LookAndFeel laf = createThemeFromDefaults(lookAndFeelInfo); - + LookAndFeel laf = createThemeFromDefaults(lookAndFeelInfo, false); UIManager.setLookAndFeel(laf); FlatLaf.updateUI(); + patchPopupFactoryForFlatInspector(); selectedBuiltIn = lookAndFeelInfo; - callbacks.saveExtensionSetting("theme", lookAndFeelInfo.getClassName()); - callbacks.saveExtensionSetting("source", ThemeSource.BUILTIN.toString()); + montoya.persistence().preferences().setString("theme", lookAndFeelInfo.getClassName()); + montoya.persistence().preferences().setString("source", ThemeSource.BUILTIN.toString()); + +// ui.reloadPreview(); } catch (Exception ex) { StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); - callbacks.printError("Could not load theme."); - callbacks.printError(sw.toString()); - JOptionPane.showMessageDialog(getUiComponent(), "Could not load the specified theme.\n" + ex.getMessage(), "Burp Customizer", JOptionPane.ERROR_MESSAGE); - try{ //Fall back to built in theme if we encounter an issue. + montoya.logging().logToError("Could not load theme."); + montoya.logging().logToError(sw.toString()); + JOptionPane.showMessageDialog(ui, "Could not load the specified theme.\n" + ex.getMessage(), "Burp Customizer", JOptionPane.ERROR_MESSAGE); + try { //Fall back to built in theme if we encounter an issue. UIManager.setLookAndFeel(originalBurpTheme); - }catch (Exception ignored){} + } catch (Exception ignored) { + } } } - public LookAndFeel createThemeFromDefaults(UIManager.LookAndFeelInfo lookAndFeelInfo) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + public LookAndFeel createThemeFromDefaults(UIManager.LookAndFeelInfo lookAndFeelInfo, boolean isPreview) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { Class themeClass = Class.forName(lookAndFeelInfo.getClassName()); IntelliJTheme.ThemeLaf theme = (IntelliJTheme.ThemeLaf) themeClass.getDeclaredConstructor().newInstance(); - return new CustomTheme(theme); + return new CustomTheme(theme, isPreview); } - public void setTheme(File themeJsonFile){ + public void setTheme(File themeJsonFile) { try { LookAndFeel lookAndFeel = createThemeFromFile(themeJsonFile); - UIManager.setLookAndFeel(lookAndFeel); FlatLaf.updateUI(); selectedThemeFile = themeJsonFile; - callbacks.saveExtensionSetting("themeFile", themeJsonFile.getAbsolutePath()); - callbacks.saveExtensionSetting("source", ThemeSource.FILE.toString()); + montoya.persistence().preferences().setString("themeFile", themeJsonFile.getAbsolutePath()); + montoya.persistence().preferences().setString("source", ThemeSource.FILE.toString()); } catch (IOException | UnsupportedLookAndFeelException ex) { StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); - callbacks.printError("Could not load theme."); - callbacks.printError(sw.toString()); - JOptionPane.showMessageDialog(getUiComponent(), "Could not load the specified theme:\n" + ex.getMessage(), "Burp Customizer", JOptionPane.ERROR_MESSAGE); - try{ //Fall back to built in theme if we encounter an issue. + montoya.logging().logToError("Could not load theme."); + montoya.logging().logToError(sw.toString()); + JOptionPane.showMessageDialog(ui, "Could not load the specified theme:\n" + ex.getMessage(), "Burp Customizer", JOptionPane.ERROR_MESSAGE); + try { //Fall back to built in theme if we encounter an issue. UIManager.setLookAndFeel(originalBurpTheme); - }catch (Exception ignored){} + } catch (Exception ignored) { + } } } public LookAndFeel createThemeFromFile(File themeJsonFile) throws IOException, UnsupportedLookAndFeelException { IntelliJTheme intelliJTheme = new IntelliJTheme(new FileInputStream(themeJsonFile)); IntelliJTheme.ThemeLaf fileTheme = new IntelliJTheme.ThemeLaf(intelliJTheme); - if(intelliJTheme.name == null && intelliJTheme.author == null){ + if (intelliJTheme.name == null && intelliJTheme.author == null) { throw new UnsupportedLookAndFeelException(themeJsonFile.getName() + " does not appear to be a valid theme file.\n" + - "If it is, make sure it has a json attribute \"name\"."); + "If it is, make sure it has json attributes \"name\" and \"author\"."); } - return new CustomTheme(fileTheme); + return new CustomTheme(fileTheme, false); } - @Override public void extensionUnloaded() { - BurpCustomizer.callbacks = null; - if(menuBar != null && menuItem != null) menuBar.remove(menuItem); + BurpCustomizer.montoya = null; + if (menuBar != null && menuItem != null) menuBar.remove(menuItem); SwingUtilities.invokeLater(() -> { try { UIManager.setLookAndFeel(originalBurpTheme); FlatLaf.updateUI(); - } catch (UnsupportedLookAndFeelException e) {} + } catch (UnsupportedLookAndFeelException e) { + } }); } } diff --git a/src/main/java/com/coreyd97/burpcustomizer/CustomTheme.java b/src/main/java/com/coreyd97/burpcustomizer/CustomTheme.java index 907dc45..b96802d 100644 --- a/src/main/java/com/coreyd97/burpcustomizer/CustomTheme.java +++ b/src/main/java/com/coreyd97/burpcustomizer/CustomTheme.java @@ -1,19 +1,23 @@ package com.coreyd97.burpcustomizer; -import com.formdev.flatlaf.FlatLaf; +import burp.theme.BurpLaf; import com.formdev.flatlaf.IntelliJTheme; +import java.awt.Color; +import java.lang.reflect.InvocationTargetException; import javax.swing.*; -import java.util.HashSet; +import java.rmi.server.UID; +import java.util.ArrayList; import java.util.Properties; -import java.util.Set; public class CustomTheme extends IntelliJTheme.ThemeLaf { Class burpLaf, burpDark, burpLight; + private final boolean isPreview; - public CustomTheme(IntelliJTheme.ThemeLaf base) { + public CustomTheme(IntelliJTheme.ThemeLaf base, boolean isPreview) { super(base.getTheme()); + this.isPreview = isPreview; try { this.burpLaf = ClassLoader.getSystemClassLoader().loadClass("burp.theme.BurpLaf"); this.burpDark = ClassLoader.getSystemClassLoader().loadClass("burp.theme.BurpDarkLaf"); @@ -25,30 +29,43 @@ public CustomTheme(IntelliJTheme.ThemeLaf base) { } @Override - public UIDefaults getDefaults() { - UIDefaults defaults; - FlatLaf burpBase; - try { - if (isDark()) { - burpBase = (FlatLaf) burpDark.getConstructor().newInstance(); - }else{ - burpBase = (FlatLaf) burpLight.getConstructor().newInstance(); - } - defaults = burpBase.getDefaults(); - - }catch (Exception e){ - defaults = super.getDefaults(); - BurpCustomizer.callbacks.printError("Could not get Burp base theme! - " + e.getMessage()); - } - - UIDefaults superDefaults = super.getDefaults(); - superDefaults.remove("SplitPaneUI"); //Do not remove Burp's UI delegates. - superDefaults.remove("TabbedPaneUI"); - defaults.putAll(superDefaults); + protected ArrayList> getLafClassesForDefaultsLoading() { + ArrayList> lafClasses = super.getLafClassesForDefaultsLoading(); + lafClasses.remove(this.getTheme().getClass()); + lafClasses.add(burpLaf); + if(isDark()) lafClasses.add(burpDark); + else lafClasses.add(burpLight); + lafClasses.add(this.getTheme().getClass()); + return lafClasses; + } - //For some reason, using lazy loading in getAdditionalDefaults for this property causes issues... - defaults.put("TabbedPane.selectedBackground", defaults.get("TabbedPane.background")); - return defaults; + @Override + public UIDefaults getDefaults() { + return super.getDefaults(); +// UIDefaults defaults; +// FlatLaf burpBase; +// try { +// if (isDark()) { +// burpBase = (FlatLaf) burpDark.getConstructor().newInstance(); +// }else{ +// burpBase = (FlatLaf) burpLight.getConstructor().newInstance(); +// } +// defaults = burpBase.getDefaults(); +// +// }catch (Exception e){ +// defaults = super.getDefaults(); +// BurpCustomizer.montoya.logging().logToError("Could not get Burp base theme! - " + e.getMessage()); +// } +// +// UIDefaults themeDefaults = super.getDefaults(); +// themeDefaults.entrySet().parallelStream() +// .filter(e -> e.getKey().toString().matches("\\w+UI$")) //Find UI delegates +// .forEach(e -> themeDefaults.remove(e.getKey())); //And remove so we don't overwrite them from burp. +// +// defaults.putAll(themeDefaults); +// //For some reason, using lazy loading in getAdditionalDefaults for this property causes issues... +// defaults.put("TabbedPane.selectedBackground", defaults.get("TabbedPane.background")); +// return defaults; } @@ -56,140 +73,107 @@ public UIDefaults getDefaults() { @Override protected Properties getAdditionalDefaults() { //Add Additional Overrides Here + //This is actually run BEFORE the theme is loaded, so we need to use lazy loading to pull values from the theme. Properties defaults = new Properties(); - defaults.put("TabbedPane.tabInsets", "2,15,4,15"); - defaults.put("TabbedPane.tabHeight", "20"); - defaults.put("Burp.selectionBackground", "lazy(Table.selectionBackground)"); - defaults.put("Burp.selectionForeground", "lazy(Table.selectionForeground)"); - defaults.put("Burp.burpOrange", "#0000FF"); - defaults.put("Burp.burpTitle", "lazy(TabbedPane.underlineColor)"); //Request response titles - defaults.put("Burp.burpError", "lazy(TabbedPane.underlineColor)"); - defaults.put("Burp.currentLineBackground", "#00FF00"); - defaults.put("Burp.selectionBorder", "lazy(Tree.selectionBackground)"); -// defaults.put("Burp.solidForeground", "#FF00FF"); - defaults.put("Burp.tabFlashColour", "lazy(TabbedPane.underlineColor)"); - defaults.put("Burp.border", "lazy(Component.borderColor)"); - defaults.put("Burp.expandableConfigPanelBorder", "lazy(Component.borderColor)"); - defaults.put("Burp.highlightPanelBackground", "lazy(TabbedPane.hoverColor)"); -// defaults.put("Burp.appLoginWarning", "lazy(TabbedPane.underlineColor)"); - defaults.put("Table.alternateRowColor", "lighten(Table.background,5%,lazy)"); - - defaults.put("Burp.suiteTabbedPaneBackground", "lazy(TabbedPane.background)"); - defaults.put("Burp.inspectorBackground", "lazy(Panel.background)"); - defaults.put("Burp.inspectorCollapsedBackground", "lazy(Panel.background)"); - defaults.put("Burp.inspectorBorder", "lazy(Component.borderColor)"); - defaults.put("Burp.inspectorTableBackground", "lazy(Table.background)"); - defaults.put("Burp.inspectorTableHeadingBackground", "lazy(TableHeader.background)"); - defaults.put("Burp.inspectorTableRowHighlightBackground", "lazy(Table.selectionBackground)"); - defaults.put("Burp.inspectorTableRowHighlightActionBackground", "lazy(Table.dropCellBackground)"); - defaults.put("Burp.inspectorTableEntryNameForeground", "lazy(Table.foreground)"); - defaults.put("Burp.inspectorTableEntryValueForeground", "lazy(Table.focusCellForeground)"); - defaults.put("Burp.inspectorTableEditableFieldBackground", "lazy(TextField.background)"); //TOFIX - defaults.put("Burp.inspectorEmptyCollapsedViewLabelForeground", "lazy(Label.foreground)"); -// defaults.put("Burp.inspectorSeeMoreHoverBackground", "#7DFF15FF"); -// defaults.put("Burp.inspectorSeeMorePressedBackground", "#1DB485FF"); - defaults.put("TabbedPane.selectedBackground", "lazy(TabbedPane.background)"); - - defaults.put("Burp.filterBarForeground", "lazy(TextField.foreground)"); - defaults.put("Burp.filterBarBackground", "lazy(TextField.background)"); - defaults.put("Burp.clueTextForeground", "lazy(TextField.placeholderForeground)"); -// defaults.put("Burp.healthcheckSuccess", new Color(7, 8, 126)); -// defaults.put("Burp.healthcheckWarning", new Color(129, 38, 81)); -// defaults.put("Burp.healthcheckFail", new Color(120, 133, 252)); - defaults.put("Burp.searchHighlightColour", "lazy(SearchMatch.startBackground)"); - defaults.put("Burp.alertHighlightColour", "lazy(Component.focusColor)"); - defaults.put("Burp.defaultFixedHighlightColour", "lazy(Component.error.focusedBorderColor)"); //Issues Panel Highlight -// defaults.put("Burp.intruderHighlight", "#F37985FF"); -// defaults.put("Burp.mapNodeEmpty", new Color(53, 214, 237)); -// defaults.put("Burp.mapNodeError", new Color(71, 133, 70)); -// defaults.put("Burp.mapNodeRequested", new Color(43, 127, 51)); -// defaults.put("Burp.mapNodeNotRequested", new Color(111, 250, 64)); - defaults.put("Burp.primaryButtonForeground", "lazy(Button.default.foreground)"); - defaults.put("Burp.primaryButtonBackground", "lazy(Button.default.startBackground)"); - defaults.put("Burp.actionPanelBackground", "lazy(Button.startBackground)"); - defaults.put("Burp.actionPanelHoverBackground", "lazy(Button.hoverBackground)"); - defaults.put("Burp.actionPanelBorder", "lazy(Button.borderColor)"); - defaults.put("Burp.standoutPanelBackground", "lazy(Button.startBackground)"); - defaults.put("Burp.standoutPanelHoverBackground", "lazy(Button.hoverBackground)"); - defaults.put("Burp.proUpsellForeground", "lazy(Button.foreground)"); - defaults.put("Burp.proUpsellBackground", "lazy(Button.background)"); - - //Repeater pretty / raw buttons - defaults.put("Burp.radioBarActiveForeground", "lazy(ToggleButton.foreground)"); - defaults.put("Burp.radioBarActiveBackground", "lazy(ToggleButton.pressedBackground)"); - defaults.put("Burp.radioBarHoverForeground", "lazy(ToggleButton.selectedForeground)"); - defaults.put("Burp.radioBarHoverBackground", "lazy(ToggleButton.toolbar.hoverBackground)"); - defaults.put("Burp.radioBarInactiveForeground", "lazy(ToggleButton.foreground)"); - defaults.put("Burp.radioBarInactiveBackground", "lazy(ToggleButton.startBackground)"); - defaults.put("Burp.radioBarDisabledForeground", "lazy(ToggleButton.disabledText)"); - defaults.put("Burp.radioBarDivider", "lazy(Component.borderColor)"); - - defaults.put("Burp.requestResponseTabBorder", "lazy(TabbedPane.underlineColor)"); - defaults.put("Burp.requestResponseTabInactiveForeground", "lazy(TabbedPane.foreground)"); - defaults.put("Burp.requestResponseTabInactiveBackground", "lazy(TabbedPane.background)"); - defaults.put("Burp.requestResponseTabHoverBackground", "lazy(TabbedPane.buttonHoverBackground)"); - defaults.put("Burp.ribbonPanelBorder", "lazy(Component.borderColor)"); - defaults.put("Burp.ribbonButtonForeground", "lazy(TabbedPane.foreground)"); - defaults.put("Burp.ribbonButtonHoverForeground", "lazy(TabbedPane.foreground)"); - defaults.put("Burp.ribbonButtonSelectedForeground", "lazy(TabbedPane.foreground)"); - defaults.put("Burp.ribbonButtonInactiveForeground", "lazy(TabbedPane.foreground)"); - defaults.put("Burp.ribbonButtonBackground", "lazy(TabbedPane.background)"); - defaults.put("Burp.ribbonButtonSelectedBackground", "lazy(TabbedPane.buttonPressedBackground)"); - defaults.put("Burp.ribbonButtonHoverBackground", "lazy(TabbedPane.buttonHoverBackground)"); - defaults.put("Burp.ribbonButtonSelectedHoverBackground", "lazy(TabbedPane.background)"); -// defaults.put("Burp.scanPhaseInactiveForeground", new Color(94, 240, 216)); -// defaults.put("Burp.scanPhaseInactiveBackground", new Color(173, 42, 120)); - defaults.put("Burp.htmlLinkForeground", "lazy(Component.linkColor)"); -// defaults.put("Burp.severityHigh", new Color(190, 50, 41)); -// defaults.put("Burp.severityMedium", new Color(240, 246, 179)); -// defaults.put("Burp.severityLow", new Color(24, 23, 46)); -// defaults.put("Burp.severityInfo", new Color(110, 146, 124)); - defaults.put("Burp.actionNormal", "lazy(Button.startBackground)"); - defaults.put("Burp.actionHover", "lazy(Button.default.focusColor)"); - defaults.put("Burp.actionPressed", "lazy(Button.endBackground)"); - defaults.put("Burp.taskActionNormal", "lazy(Button.foreground)"); - defaults.put("Burp.taskActionHover", "lazy(Button.default.focusColor)"); - defaults.put("Burp.taskActionPressed", "lazy(Button.default.focusColor)"); - defaults.put("Burp.taskListHeaderBackground", "lazy(TextField.background)"); -// defaults.put("Burp.textEditorText", new Color(199, 166, 0)); -// defaults.put("Burp.textEditorReservedWord", new Color(133, 102, 103)); -// defaults.put("Burp.textEditorReservedWord2", new Color(215, 231, 67)); -// defaults.put("Burp.textEditorAnnotation", new Color(16, 144, 176)); -// defaults.put("Burp.textEditorComment", new Color(242, 158, 157)); -// defaults.put("Burp.textEditorDataType", new Color(18, 9, 64)); -// defaults.put("Burp.textEditorFunction", new Color(44, 206, 26)); -// defaults.put("Burp.textEditorLiteralBoolean", new Color(167, 96, 58)); -// defaults.put("Burp.textEditorLiteralNumber", new Color(120, 89, 109)); -// defaults.put("Burp.textEditorLiteralQuote", new Color(19, 99, 205)); -// defaults.put("Burp.textEditorLiteralString", new Color(6, 241, 150)); -// defaults.put("Burp.textEditorTagDelimiter", new Color(74, 62, 23)); -// defaults.put("Burp.textEditorTagName", new Color(105, 141, 66)); -// defaults.put("Burp.textEditorProcessingInstruction", new Color(180, 28, 105)); -// defaults.put("Burp.textEditorCdataDelimiter", new Color(253, 122, 150)); -// defaults.put("Burp.textEditorCdata", new Color(82, 214, 219)); -// defaults.put("Burp.textEditorEntityReference", new Color(161, 177, 189)); -// defaults.put("Burp.textEditorOperator", new Color(129, 124, 174)); -// defaults.put("Burp.textEditorPreProcessor", new Color(60, 2, 213)); -// defaults.put("Burp.textEditorRegex", new Color(140, 48, 96)); -// defaults.put("Burp.textEditorSeparator", new Color(103, 136, 117)); -// defaults.put("Burp.textEditorVariable", new Color(61, 208, 91)); -// defaults.put("Burp.textEditorHttpFirstLine", new Color(81, 233, 219)); -// defaults.put("Burp.textEditorHeaderName", new Color(22, 44, 200)); -// defaults.put("Burp.textEditorHeaderValue", new Color(8, 41, 15)); -// defaults.put("Burp.textEditorParamName", new Color(108, 25, 179)); -// defaults.put("Burp.textEditorParamValue", new Color(110, 254, 101)); -// defaults.put("Burp.textEditorCookieName", new Color(55, 250, 77)); -// defaults.put("Burp.textEditorCookieValue", new Color(203, 220, 154)); - defaults.put("Burp.textEditorBackground", "lazy(TextArea.background)"); - defaults.put("Burp.textEditorCurrentLineBackground", "lazy(EditorPane.inactiveBackground)"); - defaults.put("Burp.textEditorSelectionBackground", "lazy(TextArea.selectionBackground)"); - defaults.put("Burp.textEditorSelectionForeground", "lazy(TextArea.selectionForeground)"); - defaults.put("Burp.textEditorGutterBorder", "lazy(Component.borderColor)"); - defaults.put("Burp.textEditorLineNumbers", "lazy(TextField.placeholderForeground)"); - defaults.put("Burp.textEditorLozengeBackground", "lazy(Button.default.endBackground)"); //Newline indicators - defaults.put("Burp.textEditorLozengeText", "lazy(Button.default.foreground)"); //Newline indicators -// defaults.put("Burp.warningBarForeground", "#E29408FF"); -// defaults.put("Burp.warningBarBackground", "#1255C6FF"); + + //Force the IntellijTheme class into loading the json containing defaults so we can use its values +// defaults.put("Test", "#00FF00"); + //Color Palettes. 1-8, dark needs lightening, light needs darkening + defaults.put("@accent", "lazy(Button.focusedBorderColor)"); + defaults.put("ColourPalette.mono0", "lazy(Label.background)"); + defaults.put("[dark]ColourPalette.mono1", "lighten(ColourPalette.mono0,5%,lazy)"); + defaults.put("[dark]ColourPalette.mono2", "lighten(ColourPalette.mono0,10%,lazy)"); + defaults.put("[dark]ColourPalette.mono3", "lighten(ColourPalette.mono0,15%,lazy)"); + defaults.put("[dark]ColourPalette.mono4", "lighten(ColourPalette.mono0,20%,lazy)"); + defaults.put("[dark]ColourPalette.mono5", "lighten(ColourPalette.mono0,25%,lazy)"); + defaults.put("[dark]ColourPalette.mono6", "lighten(ColourPalette.mono0,30%,lazy)"); + defaults.put("[dark]ColourPalette.mono7", "lighten(ColourPalette.mono0,35%,lazy)"); + defaults.put("[dark]ColourPalette.mono8", "lighten(ColourPalette.mono0,40%,lazy)"); + defaults.put("[light]ColourPalette.mono1", "darken(ColourPalette.mono0,5%,lazy)"); + defaults.put("[light]ColourPalette.mono2", "darken(ColourPalette.mono0,10%,lazy)"); + defaults.put("[light]ColourPalette.mono3", "darken(ColourPalette.mono0,15%,lazy)"); + defaults.put("[light]ColourPalette.mono4", "darken(ColourPalette.mono0,20%,lazy)"); + defaults.put("[light]ColourPalette.mono5", "darken(ColourPalette.mono0,25%,lazy)"); + defaults.put("[light]ColourPalette.mono6", "darken(ColourPalette.mono0,30%,lazy)"); + defaults.put("[light]ColourPalette.mono7", "darken(ColourPalette.mono0,35%,lazy)"); + defaults.put("[light]ColourPalette.mono8", "darken(ColourPalette.mono0,40%,lazy)"); + + + defaults.put("BurpPalette.mono0", "lazy(Label.background)"); + defaults.put("[dark]BurpPalette.mono1", "lighten(BurpPalette.mono0,5%,lazy)"); + defaults.put("[dark]BurpPalette.mono2", "lighten(BurpPalette.mono0,10%,lazy)"); + defaults.put("[dark]BurpPalette.mono3", "lighten(BurpPalette.mono0,15%,lazy)"); + defaults.put("[dark]BurpPalette.mono4", "lighten(BurpPalette.mono0,20%,lazy)"); + defaults.put("[dark]BurpPalette.mono5", "lighten(BurpPalette.mono0,25%,lazy)"); + defaults.put("[dark]BurpPalette.mono6", "lighten(BurpPalette.mono0,30%,lazy)"); + defaults.put("[dark]BurpPalette.mono7", "lighten(BurpPalette.mono0,35%,lazy)"); + defaults.put("[dark]BurpPalette.mono8", "lighten(BurpPalette.mono0,40%,lazy)"); + defaults.put("[dark]BurpPalette.mono9", "lighten(BurpPalette.mono0,45%,lazy)"); + defaults.put("[dark]BurpPalette.mono10", "lighten(BurpPalette.mono0,50%,lazy)"); + defaults.put("[dark]BurpPalette.mono11", "lighten(BurpPalette.mono0,55%,lazy)"); + defaults.put("[light]BurpPalette.mono1", "darken(BurpPalette.mono0,5%,lazy)"); + defaults.put("[light]BurpPalette.mono2", "darken(BurpPalette.mono0,10%,lazy)"); + defaults.put("[light]BurpPalette.mono3", "darken(BurpPalette.mono0,15%,lazy)"); + defaults.put("[light]BurpPalette.mono4", "darken(BurpPalette.mono0,20%,lazy)"); + defaults.put("[light]BurpPalette.mono5", "darken(BurpPalette.mono0,25%,lazy)"); + defaults.put("[light]BurpPalette.mono6", "darken(BurpPalette.mono0,30%,lazy)"); + defaults.put("[light]BurpPalette.mono7", "darken(BurpPalette.mono0,35%,lazy)"); + defaults.put("[light]BurpPalette.mono8", "darken(BurpPalette.mono0,40%,lazy)"); + defaults.put("[light]BurpPalette.mono9", "darken(BurpPalette.mono0,45%,lazy)"); + defaults.put("[light]BurpPalette.mono10", "darken(BurpPalette.mono0,50%,lazy)"); + defaults.put("[light]BurpPalette.mono11", "darken(BurpPalette.mono0,55%,lazy)"); +// + defaults.put("DesignSystemPalette.grey0", "lazy(Label.background)"); + defaults.put("[dark]DesignSystemPalette.grey1", "lighten(DesignSystemPalette.grey0,5%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey2", "lighten(DesignSystemPalette.grey0,10%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey3", "lighten(DesignSystemPalette.grey0,15%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey4", "lighten(DesignSystemPalette.grey0,20%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey5", "lighten(DesignSystemPalette.grey0,25%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey6", "lighten(DesignSystemPalette.grey0,30%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey7", "lighten(DesignSystemPalette.grey0,35%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey8", "lighten(DesignSystemPalette.grey0,40%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey9", "lighten(DesignSystemPalette.grey0,45%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey10", "lighten(DesignSystemPalette.grey0,50%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey11", "lighten(DesignSystemPalette.grey0,55%,lazy)"); + defaults.put("[dark]DesignSystemPalette.grey12", "lighten(DesignSystemPalette.grey0,60%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey1", "darken(DesignSystemPalette.grey0,5%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey2", "darken(DesignSystemPalette.grey0,10%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey3", "darken(DesignSystemPalette.grey0,15%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey4", "darken(DesignSystemPalette.grey0,20%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey5", "darken(DesignSystemPalette.grey0,25%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey6", "darken(DesignSystemPalette.grey0,30%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey7", "darken(DesignSystemPalette.grey0,35%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey8", "darken(DesignSystemPalette.grey0,40%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey9", "darken(DesignSystemPalette.grey0,45%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey10", "darken(DesignSystemPalette.grey0,50%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey11", "darken(DesignSystemPalette.grey0,55%,lazy)"); + defaults.put("[light]DesignSystemPalette.grey12", "darken(DesignSystemPalette.grey0,60%,lazy)"); + + defaults.put("ColourPalette.background5", "lazy(BurpPalette.mono0)"); + defaults.put("BurpPalette.blue1", "lazy(BurpPalette.mono2)"); + defaults.put("BurpPalette.blue4", "lazy(BurpPalette.mono4)"); + defaults.put("ColourPalette.blue1", "lazy(BurpPalette.mono2)"); + defaults.put("Burp.dualEmptyPanelLeftBackground", "lazy(BurpPalette.mono2)"); + defaults.put("Burp.collapsibleSidebarSelectedLabelBackground", "@accent"); + defaults.put("Burp.burpOrange", "@accent"); + defaults.put("Burp.primaryButtonBackground", "@accent"); + defaults.put("Burp.tabFlashColour", "@accent"); + defaults.put("Burp.tableFilterBarBorder", "@accent"); + defaults.put("Burp.searchBarBorder", "@accent"); + + defaults.put("[dark]Burp.backgrounder", "lighten(Label.background,2%,lazy)"); + defaults.put("[light]Burp.backgrounder", "darken(Label.background,2%,lazy)"); +// defaults.put("DesignSystemPalette.grey2", "$Burp.backgrounder"); + defaults.put("@toolBackground", "$Burp.backgrounder"); + defaults.put("Burp.taskListEntrySelectedHighlight", "lazy(Component.accentColor)"); + + defaults.put("Burp.taskListEntry", "lazy(ColourPalette.mono2)"); + defaults.put("Burp.textEditorBackground", "lazy(EditorPane.background)"); + defaults.put("Burp.textEditorCurrentLineBackground", "lazy(EditorPane.background)"); +// defaults.put("Checkbox.icon.focusedSelectedBackground", "@accent"); +// defaults.put("Checkbox.icon.hoverSelectedBackground", "@accent"); + return defaults; } + } diff --git a/src/main/java/com/coreyd97/burpcustomizer/CustomizerPanel.java b/src/main/java/com/coreyd97/burpcustomizer/CustomizerPanel.java index c25afb3..52f8bf3 100644 --- a/src/main/java/com/coreyd97/burpcustomizer/CustomizerPanel.java +++ b/src/main/java/com/coreyd97/burpcustomizer/CustomizerPanel.java @@ -3,7 +3,7 @@ import com.coreyd97.BurpExtenderUtilities.Alignment; import com.coreyd97.BurpExtenderUtilities.PanelBuilder; import com.formdev.flatlaf.FlatLaf; -import com.formdev.flatlaf.IntelliJTheme; +import lombok.SneakyThrows; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -23,10 +23,14 @@ public class CustomizerPanel extends JPanel { + private final BurpCustomizer customizer; JButton viewOnGithubButton; private File selectedThemeFile; + public final PreviewPanel previewPanel; + private final JComboBox lookAndFeelSelector; public CustomizerPanel(BurpCustomizer customizer){ + this.customizer = customizer; this.setLayout(new BorderLayout()); JLabel headerLabel = new JLabel("Burp Customizer"); @@ -128,13 +132,13 @@ public CustomizerPanel(BurpCustomizer customizer){ aboutContent.setBorder(new EmptyBorder(0, 0, 20, 0)); - PreviewPanel previewPanel = new PreviewPanel(); + previewPanel = new PreviewPanel(); previewPanel.setBorder(new EmptyBorder(10, 0, 10, 0)); JLabel themeLabel = new JLabel("Select Theme"); themeLabel.setFont(themeLabel.getFont().deriveFont(Font.BOLD)); - JComboBox lookAndFeelSelector = new JComboBox<>(); + lookAndFeelSelector = new JComboBox<>(); lookAndFeelSelector.setRenderer(new LookAndFeelRenderer()); for (UIManager.LookAndFeelInfo theme : customizer.getThemes()) { lookAndFeelSelector.addItem(theme); @@ -149,9 +153,10 @@ public CustomizerPanel(BurpCustomizer customizer){ selectedThemeFile = null; selectFileButton.setText("Select Theme File..."); try{ - LookAndFeel theme = customizer.createThemeFromDefaults((UIManager.LookAndFeelInfo) e.getItem()); - previewPanel.setTheme(theme); + LookAndFeel theme = customizer.createThemeFromDefaults((UIManager.LookAndFeelInfo) e.getItem(), true); + previewPanel.setPreviewTheme(theme); }catch (Exception ex){ + ex.printStackTrace(); previewPanel.reset(); JOptionPane.showMessageDialog(CustomizerPanel.this, "Could not load the specified theme.\n" + ex.getMessage(), "Burp Customizer", JOptionPane.ERROR_MESSAGE); } @@ -171,7 +176,7 @@ public void actionPerformed(ActionEvent e) { selectFileButton.setText(fileChooser.getSelectedFile().getName()); try { LookAndFeel theme = customizer.createThemeFromFile(fileChooser.getSelectedFile()); - previewPanel.setTheme(theme); + previewPanel.setPreviewTheme(theme); selectedThemeFile = fileChooser.getSelectedFile(); } catch (IOException | UnsupportedLookAndFeelException ex) { previewPanel.reset(); @@ -187,7 +192,7 @@ public void actionPerformed(ActionEvent e) { JButton applyThemeButton = new JButton(new AbstractAction("Apply") { @Override public void actionPerformed(ActionEvent e) { - SwingUtilities.invokeLater(() -> { +// SwingUtilities.invokeLater(() -> { if(lookAndFeelSelector.getSelectedItem() != null) { customizer.setTheme((UIManager.LookAndFeelInfo) lookAndFeelSelector.getSelectedItem()); }else if(selectedThemeFile != null){ @@ -196,7 +201,7 @@ public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(CustomizerPanel.this, "No theme selected!", "Burp Customizer", JOptionPane.ERROR_MESSAGE); } viewOnGithubButton.setIcon(getGithubIcon()); - }); +// }); } }); // applyThemeButton.setMinimumSize(applyThemeButton.getSize()); @@ -231,11 +236,6 @@ public void actionPerformed(ActionEvent e) { JPanel selectorPanel = selectorPanelBuilder.build(); - lookAndFeelSelector.setEnabled(customizer.isCompatible()); - - JLabel incompatibleWarning = new JLabel("Burp Customizer requires Burp Suite 2020.12 or above."); - incompatibleWarning.setForeground(new Color(219, 53, 53)); - JPanel fillerPanel = new JPanel(); fillerPanel.setMaximumSize(new Dimension(0,0)); @@ -246,7 +246,7 @@ public void actionPerformed(ActionEvent e) { new Component[]{contactPanel}, new Component[]{aboutContent}, new Component[]{selectorPanel}, - new Component[]{customizer.isCompatible() ? fillerPanel : incompatibleWarning}, + new Component[]{fillerPanel}, // new Component[]{fillerPanel} }; diff --git a/src/main/java/com/coreyd97/burpcustomizer/PreviewPanel.java b/src/main/java/com/coreyd97/burpcustomizer/PreviewPanel.java index 6c95a9c..2e0068e 100644 --- a/src/main/java/com/coreyd97/burpcustomizer/PreviewPanel.java +++ b/src/main/java/com/coreyd97/burpcustomizer/PreviewPanel.java @@ -2,27 +2,27 @@ import com.coreyd97.BurpExtenderUtilities.Alignment; import com.coreyd97.BurpExtenderUtilities.PanelBuilder; +import lombok.SneakyThrows; import javax.swing.*; -import javax.swing.border.BevelBorder; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.JTableHeader; import javax.swing.tree.DefaultMutableTreeNode; import java.awt.*; public class PreviewPanel extends JPanel { - PreviewPanel(){ + PreviewPanel() { this.setLayout(new BorderLayout()); this.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - try{ - setTheme(UIManager.getLookAndFeel()); - }catch (Exception e){ + try { +// setTheme(UIManager.getLookAndFeel()); + JComponent previewContent = buildPreviewContent(); + this.add(previewContent, BorderLayout.CENTER); + } catch (Exception e) { reset(); } } - public void reset(){ + public void reset() { this.removeAll(); JLabel noSelected = new JLabel("No theme selected."); noSelected.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); @@ -32,22 +32,24 @@ public void reset(){ this.repaint(); } - public void setTheme(LookAndFeel lookAndFeel) throws UnsupportedLookAndFeelException { - LookAndFeel oldLaf = UIManager.getLookAndFeel(); - UIManager.setLookAndFeel(lookAndFeel); + + public void setPreviewTheme(LookAndFeel lookAndFeel) throws UnsupportedLookAndFeelException { this.removeAll(); - JComponent previewContent = buildPreviewContent(); - this.add(previewContent, BorderLayout.CENTER); - UIManager.setLookAndFeel(oldLaf); - this.revalidate(); - this.repaint(); + //Disabled due to deadlock issues with lazy loading. +// LookAndFeel oldLaf = UIManager.getLookAndFeel(); +// this.removeAll(); +// JComponent previewContent = buildPreviewContent(); +// this.add(previewContent, BorderLayout.CENTER); +// UIManager.setLookAndFeel(oldLaf); +// this.revalidate(); +// this.repaint(); } - public JComponent buildPreviewContent(){ + public JComponent buildPreviewContent() { JLabel jLabelEnabled = new JLabel("Enabled"); JLabel jLabelDisabled = new JLabel("Disabled"); jLabelDisabled.setEnabled(false); - + JButton jbuttonEnabled = new JButton("Enabled"); JButton jbuttonDisabled = new JButton("Disabled"); jbuttonDisabled.setEnabled(false); @@ -69,7 +71,7 @@ public JComponent buildPreviewContent(){ JRadioButtonDisabledSelected.setEnabled(false); JRadioButtonEnabledSelected.setSelected(true); JRadioButtonDisabledSelected.setSelected(true); - + JComboBox JComboBoxEnabled = new JComboBox<>(new String[]{"Editable", "Item A", "Item B"}); JComboBox JComboBoxDisabled = new JComboBox<>(new String[]{"Disabled"}); JComboBox JComboBoxEnabledNotEditable = new JComboBox<>(new String[]{"Not Editable", "Item A", "Item B"}); @@ -78,7 +80,7 @@ public JComponent buildPreviewContent(){ JComboBoxDisabledNotEditable.setEnabled(false); JComboBoxDisabledNotEditable.setEditable(false); JComboBoxEnabledNotEditable.setEditable(false); - + JSpinner JSpinnerEnabled = new JSpinner(); JSpinner JSpinnerDisabled = new JSpinner(); JSpinnerDisabled.setEnabled(false); @@ -100,7 +102,7 @@ public JComponent buildPreviewContent(){ JPasswordFieldDisabledNotEditable.setEnabled(false); JPasswordFieldDisabledNotEditable.setEditable(false); JPasswordFieldEnabledNotEditable.setEditable(false); - + PanelBuilder panelBuilder = new PanelBuilder(); panelBuilder.setComponentGrid(new Component[][]{ new Component[]{new JLabel("JLabel:"), jLabelEnabled, jLabelDisabled, null, null}, @@ -120,7 +122,7 @@ public JComponent buildPreviewContent(){ jTextArea.setWrapStyleWord(true); JScrollPane jScrollPane = new JScrollPane(jTextArea); jScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - JTable jTable = new JTable(new Object[][]{new Object[]{false,"A","1", "?"}, new Object[]{true,"B","2", "!"}}, new String[]{"Boolean", "Letters", "Numbers", "Symbols"}); + JTable jTable = new JTable(new Object[][]{new Object[]{false, "A", "1", "?"}, new Object[]{true, "B", "2", "!"}}, new String[]{"Boolean", "Letters", "Numbers", "Symbols"}); DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode("Items"); treeNode.add(new DefaultMutableTreeNode("Item A")); treeNode.add(new DefaultMutableTreeNode("Item B")); @@ -131,7 +133,7 @@ public JComponent buildPreviewContent(){ treeNode.add(childNode); JTree jTree = new JTree(treeNode); - JList jList = new JList<>(new String[]{"Item A","Item B","Item C","Item D","Item E","Item F"}); + JList jList = new JList<>(new String[]{"Item A", "Item B", "Item C", "Item D", "Item E", "Item F"}); panelBuilder = new PanelBuilder(); panelBuilder.setComponentGrid(new Component[][]{ diff --git a/src/test/java/TestPlugin.java b/src/test/java/TestPlugin.java index 77cf4f0..ed5ad1a 100644 --- a/src/test/java/TestPlugin.java +++ b/src/test/java/TestPlugin.java @@ -1,15 +1,12 @@ -import com.formdev.flatlaf.extras.FlatUIDefaultsInspector; - import java.lang.reflect.Method; public class TestPlugin { public static void main(String[] args) { - //Legacy extension support has been removed from Burp, so this will no longer work. -// try { -// Method main = Class.forName("burp.StartBurp").getMethod("main", String[].class); -// main.invoke(null, (Object) args); -// }catch (Exception e){ -// System.err.println("Cannot start burp. Check the burp jar is correctly included in the classpath."); -// } + try { + Method main = Class.forName("burp.StartBurp").getMethod("main", String[].class); + main.invoke(null, (Object) args); + }catch (Exception e){ + System.err.println("Cannot start burp. Check the burp jar is correctly included in the classpath."); + } } } \ No newline at end of file