Search in sources :

Example 36 with JToggleButton

use of javax.swing.JToggleButton in project ats-framework by Axway.

the class SwingElementLocator method findFixture.

public static ComponentFixture<? extends Component> findFixture(UiElement uiElement) {
    SwingDriverInternal driver = (SwingDriverInternal) uiElement.getUiDriver();
    ContainerFixture<?> containerFixture = (ContainerFixture<?>) driver.getActiveContainerFixture();
    Class<? extends Component> componentClass = componentsMap.get(uiElement.getClass());
    try {
        if (componentClass.equals(JButton.class)) {
            return (ComponentFixture<? extends Component>) new JButtonFixture(containerFixture.robot, (JButton) findElement(uiElement));
        } else if (componentClass.equals(JTextComponent.class)) {
            return (ComponentFixture<? extends Component>) new JTextComponentFixture(containerFixture.robot, (JTextComponent) findElement(uiElement));
        } else if (componentClass.equals(JMenuItem.class)) {
            if (uiElement.getElementProperty("path") != null) {
                return containerFixture.menuItemWithPath(uiElement.getElementProperty("path").split("[\\,\\/]+"));
            } else {
                return (ComponentFixture<? extends Component>) new JMenuItemFixture(containerFixture.robot, (JMenuItem) findElement(uiElement));
            }
        } else if (componentClass.equals(JPopupMenu.class)) {
            return (ComponentFixture<? extends Component>) new JPopupMenuFixture(containerFixture.robot, (JPopupMenu) findElement(uiElement));
        } else if (componentClass.equals(JTree.class)) {
            return (ComponentFixture<? extends Component>) new JTreeFixture(containerFixture.robot, (JTree) findElement(uiElement));
        } else if (componentClass.equals(JList.class)) {
            return (ComponentFixture<? extends Component>) new JListFixture(containerFixture.robot, (JList) findElement(uiElement));
        } else if (componentClass.equals(JCheckBox.class)) {
            return (ComponentFixture<? extends Component>) new JCheckBoxFixture(containerFixture.robot, (JCheckBox) findElement(uiElement));
        } else if (componentClass.equals(JToggleButton.class)) {
            return (ComponentFixture<? extends Component>) new JToggleButtonFixture(containerFixture.robot, (JToggleButton) findElement(uiElement));
        } else if (componentClass.equals(JComboBox.class)) {
            return (ComponentFixture<? extends Component>) new JComboBoxFixture(containerFixture.robot, (JComboBox) findElement(uiElement));
        } else if (componentClass.equals(JRadioButton.class)) {
            return (ComponentFixture<? extends Component>) new JRadioButtonFixture(containerFixture.robot, (JRadioButton) findElement(uiElement));
        } else if (componentClass.equals(JTable.class)) {
            return (ComponentFixture<? extends Component>) new JTableFixture(containerFixture.robot, (JTable) findElement(uiElement));
        } else if (componentClass.equals(JSpinner.class)) {
            return (ComponentFixture<? extends Component>) new JSpinnerFixture(containerFixture.robot, (JSpinner) findElement(uiElement));
        } else if (componentClass.equals(JTabbedPane.class)) {
            return (ComponentFixture<? extends Component>) new JTabbedPaneFixture(containerFixture.robot, (JTabbedPane) findElement(uiElement));
        } else if (componentClass.equals(JOptionPane.class)) {
            return (ComponentFixture<? extends Component>) containerFixture.optionPane();
        } else if (componentClass.equals(JLabel.class)) {
            return (ComponentFixture<? extends Component>) new JLabelFixture(containerFixture.robot, (JLabel) findElement(uiElement));
        } else if (componentClass.equals(Component.class)) {
            return new ComponentFixture<Component>(containerFixture.robot, findElement(uiElement)) {
            };
        } else if (componentClass.equals(JFileChooser.class)) {
            // TODO - might be searched by name too
            return containerFixture.fileChooser(Timeout.timeout(UiEngineConfigurator.getInstance().getElementStateChangeDelay()));
        } else {
            throw new ElementNotFoundException(uiElement.toString() + " not found. No such Fixture");
        }
    } catch (ComponentLookupException cle) {
        throw new ElementNotFoundException(uiElement.toString() + " not found.", cle);
    } catch (WaitTimedOutError exc) {
        // thrown for OptionPane search, wait for Window (BasicRobot.waitForWindow), AbstractJTableCellWriter, JTreeDriver.waitForChildrenToShowUp, each Pause wait
        throw new ElementNotFoundException(uiElement.toString() + " not found.", exc);
    }
}
Also used : JTreeFixture(org.fest.swing.fixture.JTreeFixture) JRadioButton(javax.swing.JRadioButton) SwingDriverInternal(com.axway.ats.uiengine.internal.driver.SwingDriverInternal) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JTextComponent(javax.swing.text.JTextComponent) JSpinnerFixture(org.fest.swing.fixture.JSpinnerFixture) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) WaitTimedOutError(org.fest.swing.exception.WaitTimedOutError) JLabelFixture(org.fest.swing.fixture.JLabelFixture) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JButtonFixture(org.fest.swing.fixture.JButtonFixture) JToggleButtonFixture(org.fest.swing.fixture.JToggleButtonFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) JToggleButton(javax.swing.JToggleButton) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) ComponentFixture(org.fest.swing.fixture.ComponentFixture) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) Component(java.awt.Component) JTextComponent(javax.swing.text.JTextComponent) JMenuItem(javax.swing.JMenuItem) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) JRadioButtonFixture(org.fest.swing.fixture.JRadioButtonFixture) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JOptionPane(javax.swing.JOptionPane) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JPopupMenuFixture(org.fest.swing.fixture.JPopupMenuFixture) JListFixture(org.fest.swing.fixture.JListFixture) ContainerFixture(org.fest.swing.fixture.ContainerFixture) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JCheckBoxFixture(org.fest.swing.fixture.JCheckBoxFixture) JList(javax.swing.JList)

Example 37 with JToggleButton

use of javax.swing.JToggleButton in project zaproxy by zaproxy.

the class MainFrame method getExpandStatusLayoutButton.

private JToggleButton getExpandStatusLayoutButton() {
    if (expandStatusLayoutButton == null) {
        expandStatusLayoutButton = new JToggleButton(new ChangeWorkbenchLayoutAction(WorkbenchPanel.class.getResource("/resource/icon/expand_info.png"), WorkbenchPanel.Layout.EXPAND_STATUS));
        expandStatusLayoutButton.setToolTipText(Constant.messages.getString("view.toolbar.expandInfo"));
    }
    return expandStatusLayoutButton;
}
Also used : JToggleButton(javax.swing.JToggleButton)

Example 38 with JToggleButton

use of javax.swing.JToggleButton in project zaproxy by zaproxy.

the class MainFrame method getExpandSelectLayoutButton.

private JToggleButton getExpandSelectLayoutButton() {
    if (expandSelectLayoutButton == null) {
        expandSelectLayoutButton = new JToggleButton(new ChangeWorkbenchLayoutAction(WorkbenchPanel.class.getResource("/resource/icon/expand_sites.png"), WorkbenchPanel.Layout.EXPAND_SELECT));
        expandSelectLayoutButton.setToolTipText(Constant.messages.getString("view.toolbar.expandSites"));
    }
    return expandSelectLayoutButton;
}
Also used : JToggleButton(javax.swing.JToggleButton)

Example 39 with JToggleButton

use of javax.swing.JToggleButton in project zaproxy by zaproxy.

the class RequestAllComponent method initUi.

protected void initUi() {
    // Common
    buttonShowView = new JToggleButton(DisplayUtils.getScaledIcon(new ImageIcon(RequestAllComponent.class.getResource("/resource/icon/view_all.png"))));
    buttonShowView.setToolTipText(BUTTON_TOOL_TIP);
    panelOptions = new JPanel();
    panelOptions.add(views.getSelectableViewsComponent());
    initViews();
    // All
    panelMain = new JPanel(new BorderLayout());
    panelMain.add(views.getViewsPanel());
    setSelected(false);
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) JToggleButton(javax.swing.JToggleButton) BorderLayout(java.awt.BorderLayout)

Example 40 with JToggleButton

use of javax.swing.JToggleButton in project zaproxy by zaproxy.

the class HttpPanelSender method getButtonUseTrackingSessionState.

private JToggleButton getButtonUseTrackingSessionState() {
    if (useTrackingSessionState == null) {
        useTrackingSessionState = new JToggleButton(new ImageIcon(HttpPanelSender.class.getResource(// Cookie
        "/resource/icon/fugue/cookie.png")));
        useTrackingSessionState.setToolTipText(Constant.messages.getString("manReq.checkBox.useSession"));
    }
    return useTrackingSessionState;
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton)

Aggregations

JToggleButton (javax.swing.JToggleButton)59 ActionEvent (java.awt.event.ActionEvent)21 ActionListener (java.awt.event.ActionListener)21 ImageIcon (javax.swing.ImageIcon)20 JPanel (javax.swing.JPanel)19 JLabel (javax.swing.JLabel)16 Dimension (java.awt.Dimension)14 JButton (javax.swing.JButton)13 Insets (java.awt.Insets)11 JScrollPane (javax.swing.JScrollPane)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 GridBagLayout (java.awt.GridBagLayout)7 BoxLayout (javax.swing.BoxLayout)7 GridBagConstraints (java.awt.GridBagConstraints)6 JCheckBox (javax.swing.JCheckBox)6 JSlider (javax.swing.JSlider)6 JTabbedPane (javax.swing.JTabbedPane)6 Component (java.awt.Component)5 GridLayout (java.awt.GridLayout)5