Skip to content

Commit

Permalink
Fix sizing issues on some monitors.
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreyD97 committed Jun 21, 2021
1 parent 7b83953 commit 0e5443e
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 28 deletions.
19 changes: 13 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ repositories {

dependencies {
compile 'net.portswigger.burp.extender:burp-extender-api:1.7.22'
compile 'com.github.CoreyD97:BurpExtenderUtilities:409993f'
compileOnly 'com.formdev:flatlaf:0.45'
compile 'com.formdev:flatlaf-intellij-themes:0.45'
testCompile 'com.formdev:flatlaf-extras:0.45'
testCompile files('/opt/BurpSuitePro/burpsuite_pro.jar')
compile 'com.github.CoreyD97:BurpExtenderUtilities:c03544e3'
compileOnly 'com.formdev:flatlaf:1.1.2'
compile 'com.formdev:flatlaf-intellij-themes:1.1.2'
compile 'com.formdev:flatlaf-extras:1.1.2'
runtimeOnly files('/home/corey/BurpSuitePro/burpsuite_pro.jar')
// testCompile files('/home/corey/BurpSuiteCommunity/burpsuite_community.jar')
// testRuntime files('/tmp/test.jar')
testRuntime files('/home/corey/BurpSuitePro/burpsuite_pro.deobf.jar')
}

jar {
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

task customFatJar(type: Jar) {
baseName = project.name + "-TEST"
from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}


configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/coreyd97/burpcustomizer/BurpCustomizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import burp.ITab;
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 javax.swing.*;
Expand Down Expand Up @@ -68,13 +70,8 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
compatible = false;
}

try {
Class inspector = Class.forName("com.formdev.flatlaf.extras.FlatInspector");
Method install = inspector.getMethod("install", String.class);
install.invoke(null,"ctrl shift alt X");
}catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
//Could not install inspector. Probably not in testCompile.
}
FlatInspector.install("ctrl shift alt U");
FlatUIDefaultsInspector.install("ctrl shift alt Y");

SwingUtilities.invokeLater(() -> {
if(themeSource == ThemeSource.BUILTIN && selectedBuiltIn != null){
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/coreyd97/burpcustomizer/CustomTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.formdev.flatlaf.IntelliJTheme;

import javax.swing.*;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

public class CustomTheme extends IntelliJTheme.ThemeLaf {

Expand Down
50 changes: 41 additions & 9 deletions src/main/java/com/coreyd97/burpcustomizer/CustomizerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import javax.swing.text.StyleConstants;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.image.BufferedImage;
import java.io.*;
Expand Down Expand Up @@ -197,6 +199,7 @@ public void actionPerformed(ActionEvent e) {
});
}
});
// applyThemeButton.setMinimumSize(applyThemeButton.getSize());

if(customizer.getThemeSource() == BurpCustomizer.ThemeSource.BUILTIN && customizer.getSelectedBuiltIn() != null) {
lookAndFeelSelector.setSelectedItem(customizer.getSelectedBuiltIn());
Expand All @@ -207,50 +210,79 @@ public void actionPerformed(ActionEvent e) {
selectedThemeFile = selectedFile;
}

JPanel selectorPanel = PanelBuilder.build(new Component[][]{
PanelBuilder selectorPanelBuilder = new PanelBuilder();
selectorPanelBuilder.setComponentGrid(new Component[][]{
new Component[]{themeLabel, themeLabel},
new Component[]{defaultThemeLabel, lookAndFeelSelector},
new Component[]{fileThemeLabel, selectFileButton},
new Component[]{previewPanel, previewPanel},
new Component[]{applyThemeButton, applyThemeButton},
}, new int[][]{
});
int[][] selectorPanelWeights = new int[][]{
new int[]{0, 0},
new int[]{1, 1},
new int[]{1, 1},
new int[]{3, 3},
new int[]{1, 1},
}, Alignment.FILL, 1.0, 1.0);
};
selectorPanelBuilder.setGridWeightsX(selectorPanelWeights);
selectorPanelBuilder.setGridWeightsY(selectorPanelWeights);
selectorPanelBuilder.setAlignment(Alignment.FILL);

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

Component[][] componentGrid = new Component[][]{
new Component[]{headerLabel},
new Component[]{subtitle},
new Component[]{separator},
new Component[]{contactPanel},
new Component[]{aboutContent},
new Component[]{selectorPanel},
new Component[]{customizer.isCompatible() ? new JPanel() : incompatibleWarning},
new Component[]{new JPanel()}
new Component[]{customizer.isCompatible() ? fillerPanel : incompatibleWarning},
// new Component[]{fillerPanel}
};

int[][] weightGrid = new int[][]{
int[][] weightGridY = new int[][]{
new int[]{0},
new int[]{0},
new int[]{0},
new int[]{0},
new int[]{0},
new int[]{0},
new int[]{0},
new int[]{10},
new int[]{1000},
};

JPanel contentPanel = PanelBuilder.build(componentGrid, weightGrid, Alignment.FILL, 0.8, 1.0);
PanelBuilder contentPanelBuilder = new PanelBuilder();
contentPanelBuilder.setComponentGrid(componentGrid);
// contentPanelBuilder.setGridWeightsX(weightGridY);
contentPanelBuilder.setGridWeightsY(weightGridY);
contentPanelBuilder.setScaleX(0.8);
contentPanelBuilder.setScaleY(1.0);
contentPanelBuilder.setAlignment(Alignment.FILL);

JPanel contentPanel = contentPanelBuilder.build();
contentPanel.setBorder(new EmptyBorder(30, 30, 30, 30));

this.add(contentPanel, BorderLayout.CENTER);
JScrollPane scrollPane = new JScrollPane(contentPanel);
scrollPane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
contentPanel.setPreferredSize(new Dimension(e.getComponent().getWidth(), contentPanel.getHeight()));
}
});
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

this.add(scrollPane, BorderLayout.CENTER);
}

private ImageIcon getGithubIcon(){
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/coreyd97/burpcustomizer/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public JComponent buildPreviewContent(){
JPasswordFieldDisabledNotEditable.setEditable(false);
JPasswordFieldEnabledNotEditable.setEditable(false);


JPanel basicComponents = PanelBuilder.build(new Component[][]{
PanelBuilder panelBuilder = new PanelBuilder();
panelBuilder.setComponentGrid(new Component[][]{
new Component[]{new JLabel("JLabel:"), jLabelEnabled, jLabelDisabled, null, null},
new Component[]{new JLabel("JButton:"), jbuttonEnabled, jbuttonDisabled, null, null},
new Component[]{new JLabel("JCheckBox:"), JCheckBoxEnabled, JCheckBoxDisabled, JCheckBoxEnabledSelected, JCheckBoxDisabledSelected},
Expand All @@ -111,7 +111,9 @@ public JComponent buildPreviewContent(){
new Component[]{new JLabel("JSpinner:"), JSpinnerEnabled, JSpinnerDisabled, null, null},
new Component[]{new JLabel("JTextField:"), JTextFieldEnabled, JTextFieldDisabled, JTextFieldEnabledNotEditable, JTextFieldDisabledNotEditable},
new Component[]{new JLabel("JPasswordField:"), JPasswordFieldEnabled, JPasswordFieldDisabled, JPasswordFieldEnabledNotEditable, JPasswordFieldDisabledNotEditable},
}, Alignment.FILL, 1.0, 1.0);
});
panelBuilder.setAlignment(Alignment.FILL);
JPanel basicComponents = panelBuilder.build();
basicComponents.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));

JTextArea jTextArea = new JTextArea("An editable text area");
Expand All @@ -131,23 +133,29 @@ public JComponent buildPreviewContent(){
JTree jTree = new JTree(treeNode);
JList<String> jList = new JList<>(new String[]{"Item A","Item B","Item C","Item D","Item E","Item F"});

JPanel otherComponents = PanelBuilder.build(new Component[][]{
panelBuilder = new PanelBuilder();
panelBuilder.setComponentGrid(new Component[][]{
new Component[]{new JLabel("JEditor"), null},
new Component[]{jScrollPane, jScrollPane},
new Component[]{jScrollPane, jScrollPane},
new Component[]{new JLabel("JTable"), null},
new Component[]{jTable, jTable},
new Component[]{new JLabel("JTree"), new JLabel("JList")},
new Component[]{new JScrollPane(jTree), new JScrollPane(jList)},
}, new int[][]{
});
int[][] weights = new int[][]{
new int[]{0, 0},
new int[]{1, 1},
new int[]{1, 1},
new int[]{0, 0},
new int[]{1, 1},
new int[]{0, 0},
new int[]{5, 5},
}, Alignment.FILL, 1.0, 1.0);
};
panelBuilder.setGridWeightsX(weights);
panelBuilder.setGridWeightsY(weights);
panelBuilder.setAlignment(Alignment.FILL);
JPanel otherComponents = panelBuilder.build();

JTabbedPane jTabbedPane = new JTabbedPane();
jTabbedPane.add("Basic", basicComponents);
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/TestPlugin.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;

import java.lang.reflect.Method;

public class TestPlugin {
Expand Down

0 comments on commit 0e5443e

Please sign in to comment.