Skip to content

SVG icon format #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins-cmn-jmeter</artifactId>
<version>0.6</version>
<version>0.7</version>
</dependency>
<dependency>
<groupId>kg.apc</groupId>
Expand Down Expand Up @@ -95,5 +95,18 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf</artifactId>
<version>1.3.3.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.weisj</groupId>
<artifactId>darklaf</artifactId>
<version>1.3.3.4</version>
<type>pom</type>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.net.URISyntaxException;
import javax.swing.AbstractAction;

class ValidateTGAction extends AbstractAction {

public static final KeyStroke VALIDATE_TG = KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.ALT_DOWN_MASK);
private static final Logger log = LoggerFactory.getLogger(ValidateTGAction.class);

ValidateTGAction() {
ValidateTGAction() throws URISyntaxException {
super("Validate Thread Group(s)");
putValue(Action.ACTION_COMMAND_KEY, "validate_tg");
putValue(Action.ACCELERATOR_KEY, VALIDATE_TG);
putValue(Action.SMALL_ICON, ValidateTGMenuItem.getButtonIcon(12));
putValue(Action.SMALL_ICON, ValidateTGMenuItem.getButtonIcon());
}

public void actionPerformed(ActionEvent actionEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,47 @@
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.util.JMeterToolBar;
import org.apache.jmeter.gui.action.ActionRouter;
import org.apache.jmeter.util.JMeterUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Objects;

import com.github.weisj.darklaf.icons.ThemedSVGIcon;

public class ValidateTGMenuItem extends JMenuItem implements ActionListener{
private static final Logger log = LoggerFactory.getLogger(ValidateTGMenuItem.class);
private static final Action vtg = new ValidateTGAction();
private static Action vtg = null;

static {
try {
vtg = new ValidateTGAction();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}

public ValidateTGMenuItem() {
super(vtg);
addActionListener(this);
addToolbarIcon();
}

public static ImageIcon getButtonIcon(int pixelSize) {
String sizedImage = String.format("/org/qainsights/jmeter/validatetg/validate-tg-icon-%2dx%2d.png", pixelSize, pixelSize);
return new ImageIcon(Objects.requireNonNull(ValidateTGMenuItem.class.getResource(sizedImage)));
public static Icon getButtonIcon() throws URISyntaxException {
log.debug("Image");
String svgResourcePath = "/org/qainsights/jmeter/validatetg/Check-Mark.svg";
URL svgUrl = JMeterUtils.class.getResource(svgResourcePath);
URI svgUri = null;
svgUri = svgUrl.toURI();
Icon icon = new ThemedSVGIcon(svgUri, 22, 22);

return icon;
}

private void addToolbarIcon() {
Expand All @@ -49,15 +67,20 @@ public void run() {
}
int pos = getPositionForIcon(toolbar.getComponents());
log.debug("validate rootPos: " + String.valueOf(pos));
Component toolbarButton = getToolbarButton();
Component toolbarButton = null;
try {
toolbarButton = getToolbarButton();
} catch (URISyntaxException e) {
e.printStackTrace();
}
toolbarButton.setSize(toolbar.getComponent(pos).getSize());
toolbar.add(toolbarButton, pos);
}
});
}
}
private JButton getToolbarButton() {
JButton button = new JButton(getButtonIcon(22));
private JButton getToolbarButton() throws URISyntaxException {
JButton button = new JButton(getButtonIcon());
button.setToolTipText("Validate Thread Group(s)");
button.addActionListener(this);
button.setActionCommand("validate_tg");
Expand All @@ -71,7 +94,7 @@ private int getPositionForIcon(Component[] toolbarComponents) {
if(itemClassName.contains("javax.swing.JButton")) {
String actionCommandText = ((JButton) item).getModel().getActionCommand();
log.debug("Running for iteration: "+ index + ", " + actionCommandText);
if (actionCommandText != null && actionCommandText.equals("search_tree")){
if (actionCommandText != null && actionCommandText.equals("start")){
break;
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/org/qainsights/jmeter/validatetg/Check-Mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.