use of javax.swing.ImageIcon in project zaproxy by zaproxy.
the class SiteMapTreeCellRenderer method getTreeCellRendererComponent.
/**
* Sets custom tree node logos.
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
component.removeAll();
SiteNode node = null;
if (value instanceof SiteNode) {
node = (SiteNode) value;
}
if (node != null) {
if (node.isFiltered()) {
// Hide the node
setPreferredSize(new Dimension(0, 0));
} else {
// clears the prefered size, making the node visible
setPreferredSize(null);
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
}
// folder / file icons with scope 'target' if relevant
if (node.isRoot()) {
// 'World' icon
component.add(wrap(ROOT_ICON));
} else {
OverlayIcon icon;
if (node.isDataDriven()) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(DATA_DRIVEN_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(DATA_DRIVEN_ICON);
}
} else if (leaf) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(LEAF_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(LEAF_ICON);
}
} else {
if (expanded) {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(FOLDER_OPEN_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(FOLDER_OPEN_ICON);
}
} else {
if (node.isIncludedInScope() && !node.isExcludedFromScope()) {
icon = new OverlayIcon(FOLDER_CLOSED_IN_SCOPE_ICON);
} else {
icon = new OverlayIcon(FOLDER_CLOSED_ICON);
}
}
}
if (node.getParent().isRoot() && node.getNodeName().startsWith("https://")) {
// Add lock icon to site nodes with https
icon.add(LOCK_OVERLAY_ICON);
}
component.add(wrap(DisplayUtils.getScaledIcon(icon)));
Alert alert = node.getHighestAlert();
if (alert != null) {
component.add(wrap(alert.getIcon()));
}
for (ImageIcon ci : node.getCustomIcons()) {
component.add(wrap(DisplayUtils.getScaledIcon(ci)));
}
}
if (sel) {
component.add(wrap(node.toString(), Color.WHITE));
} else {
component.add(wrap(node.toString()));
}
for (SiteMapListener listener : listeners) {
listener.onReturnNodeRendererComponent(this, leaf, node);
}
return component;
}
return this;
}
use of javax.swing.ImageIcon in project zaproxy by zaproxy.
the class ScanPanel method getPauseScanButton.
private JToggleButton getPauseScanButton() {
if (pauseScanButton == null) {
pauseScanButton = new ZapToggleButton();
pauseScanButton.setToolTipText(Constant.messages.getString(prefix + ".toolbar.button.pause"));
pauseScanButton.setSelectedToolTipText(Constant.messages.getString(prefix + ".toolbar.button.unpause"));
pauseScanButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(ScanPanel.class.getResource("/resource/icon/16/141.png"))));
pauseScanButton.setRolloverIcon(DisplayUtils.getScaledIcon(new ImageIcon(ScanPanel.class.getResource("/resource/icon/16/141.png"))));
pauseScanButton.setSelectedIcon(DisplayUtils.getScaledIcon(new ImageIcon(ScanPanel.class.getResource("/resource/icon/16/131.png"))));
pauseScanButton.setRolloverSelectedIcon(DisplayUtils.getScaledIcon(new ImageIcon(ScanPanel.class.getResource("/resource/icon/16/131.png"))));
pauseScanButton.setEnabled(false);
pauseScanButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
pauseScan(currentSite);
}
});
}
return pauseScanButton;
}
use of javax.swing.ImageIcon in project zaproxy by zaproxy.
the class MainToolbarPanel method getBtnNew.
private JButton getBtnNew() {
if (btnNew == null) {
btnNew = new JButton();
btnNew.setIcon(DisplayUtils.getScaledIcon(// 'Blank file' icon
new ImageIcon(MainToolbarPanel.class.getResource("/resource/icon/16/021.png"))));
btnNew.setToolTipText(Constant.messages.getString("menu.file.newSession"));
btnNew.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
Control.getSingleton().getMenuFileControl().newSession(true);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.newSession.error"));
}
}
});
}
return btnNew;
}
use of javax.swing.ImageIcon in project zaproxy by zaproxy.
the class MainToolbarPanel method getBtnSnapshot.
private JButton getBtnSnapshot() {
if (btnSnapshot == null) {
btnSnapshot = new JButton();
btnSnapshot.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(MainToolbarPanel.class.getResource("/resource/icon/fugue/camera.png"))));
btnSnapshot.setToolTipText(Constant.messages.getString("menu.file.snapshotSession"));
btnSnapshot.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
if (Model.getSingleton().getSession().isNewState()) {
View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.sessionNotExist.error"));
} else {
Control.getSingleton().getMenuFileControl().saveSnapshot();
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.persistSession.error"));
}
}
});
}
return btnSnapshot;
}
use of javax.swing.ImageIcon in project zaproxy by zaproxy.
the class MainToolbarPanel method getBtnSave.
private JButton getBtnSave() {
if (btnSave == null) {
btnSave = new JButton();
btnSave.setIcon(DisplayUtils.getScaledIcon(// 'diskette' icon
new ImageIcon(MainToolbarPanel.class.getResource("/resource/icon/16/096.png"))));
btnSave.setToolTipText(Constant.messages.getString("menu.file.persistSession"));
btnSave.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
if (Model.getSingleton().getSession().isNewState()) {
Control.getSingleton().getMenuFileControl().saveAsSession();
} else {
View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.sessionExists.error"));
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
View.getSingleton().showWarningDialog(Constant.messages.getString("menu.file.persistSession.error"));
}
}
});
}
return btnSave;
}
Aggregations