Search in sources :

Example 96 with ImageIcon

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) Alert(org.parosproxy.paros.core.scanner.Alert) Dimension(java.awt.Dimension) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 97 with ImageIcon

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 98 with ImageIcon

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 99 with ImageIcon

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Example 100 with ImageIcon

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;
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent)

Aggregations

ImageIcon (javax.swing.ImageIcon)372 JButton (javax.swing.JButton)94 ActionEvent (java.awt.event.ActionEvent)71 JLabel (javax.swing.JLabel)60 ActionListener (java.awt.event.ActionListener)59 Dimension (java.awt.Dimension)43 JPanel (javax.swing.JPanel)43 BufferedImage (java.awt.image.BufferedImage)36 IOException (java.io.IOException)27 BorderLayout (java.awt.BorderLayout)25 Insets (java.awt.Insets)24 JMenuItem (javax.swing.JMenuItem)23 Image (java.awt.Image)22 URL (java.net.URL)22 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)20 GridBagLayout (java.awt.GridBagLayout)20 Color (java.awt.Color)18 JScrollPane (javax.swing.JScrollPane)17 FlowLayout (java.awt.FlowLayout)16 JFrame (javax.swing.JFrame)15