Search in sources :

Example 71 with JTabbedPane

use of javax.swing.JTabbedPane 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 72 with JTabbedPane

use of javax.swing.JTabbedPane in project otapij by FellowTraveler.

the class MainPage method jTabbedPane_MainPageStateChanged.

//GEN-LAST:event_jButton_RegisterNymActionPerformed
private void jTabbedPane_MainPageStateChanged(javax.swing.event.ChangeEvent evt) {
    //GEN-FIRST:event_jTabbedPane_MainPageStateChanged
    JTabbedPane pane = (JTabbedPane) evt.getSource();
    int sel = pane.getSelectedIndex();
    System.out.println("Mainpage tab eventState changed:" + sel);
    if (sel == 4 && Helpers.isLoadNymTrades()) {
        String serverID = "ALL";
        String nymID = "ALL";
        if (serverMap != null && serverMap.size() > 0 && jComboBox5.getSelectedIndex() > -1) {
            serverID = ((String[]) serverMap.get((Integer) jComboBox5.getSelectedIndex()))[1];
        }
        if (nymRegisteredMap != null && nymRegisteredMap.size() > 0 && jComboBox6.getSelectedIndex() > -1) {
            nymID = ((String[]) nymRegisteredMap.get((Integer) jComboBox6.getSelectedIndex()))[1];
        }
        if (!"ALL".equalsIgnoreCase(nymID)) {
            Map nymTrades = Market.getNymTrades(serverID, nymID);
            if (nymTrades != null) {
                ((MarketTradesTableModel) jTable16.getModel()).setValue(nymTrades, jTable16);
            }
            Helpers.setLoadNymTrades(false);
        }
    }
    if (sel == 3 && !isBasketInit) {
        initBasketsTab();
        isBasketInit = true;
    }
    if (sel == 4 && !isMarketInit) {
        initMarketsTab();
        isMarketInit = true;
    }
    if (sel == 5 && !isPaymentsInit) {
        initPaymentsInitTab();
        isPaymentsInit = true;
    }
}
Also used : JTabbedPane(javax.swing.JTabbedPane) MarketTradesTableModel(com.moneychanger.ui.model.MarketTradesTableModel) Map(java.util.Map) Point(java.awt.Point)

Example 73 with JTabbedPane

use of javax.swing.JTabbedPane in project sonarqube by SonarSource.

the class ScannerReportViewerApp method initialize.

/**
   * Initialize the contents of the frame.
   */
private void initialize() {
    try {
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (Exception e) {
    // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    splitPane = new JSplitPane();
    frame.getContentPane().add(splitPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setPreferredSize(new Dimension(500, 7));
    splitPane.setRightComponent(tabbedPane);
    componentDetailsTab = new JScrollPane();
    tabbedPane.addTab("Component details", null, componentDetailsTab, null);
    componentEditor = new JEditorPane();
    componentDetailsTab.setViewportView(componentEditor);
    sourceTab = new JScrollPane();
    tabbedPane.addTab("Source", null, sourceTab, null);
    sourceEditor = createSourceEditor();
    sourceEditor.setEditable(false);
    sourceTab.setViewportView(sourceEditor);
    textLineNumber = createTextLineNumber();
    sourceTab.setRowHeaderView(textLineNumber);
    highlightingTab = new JScrollPane();
    tabbedPane.addTab("Highlighting", null, highlightingTab, null);
    highlightingEditor = new JEditorPane();
    highlightingTab.setViewportView(highlightingEditor);
    symbolTab = new JScrollPane();
    tabbedPane.addTab("Symbol references", null, symbolTab, null);
    symbolEditor = new JEditorPane();
    symbolTab.setViewportView(symbolEditor);
    coverageTab = new JScrollPane();
    tabbedPane.addTab("Coverage", null, coverageTab, null);
    coverageEditor = new JEditorPane();
    coverageTab.setViewportView(coverageEditor);
    duplicationTab = new JScrollPane();
    tabbedPane.addTab("Duplications", null, duplicationTab, null);
    duplicationEditor = new JEditorPane();
    duplicationTab.setViewportView(duplicationEditor);
    testsTab = new JScrollPane();
    tabbedPane.addTab("Tests", null, testsTab, null);
    testsEditor = new JEditorPane();
    testsTab.setViewportView(testsEditor);
    issuesTab = new JScrollPane();
    tabbedPane.addTab("Issues", null, issuesTab, null);
    issuesEditor = new JEditorPane();
    issuesTab.setViewportView(issuesEditor);
    measuresTab = new JScrollPane();
    tabbedPane.addTab("Measures", null, measuresTab, null);
    measuresEditor = new JEditorPane();
    measuresTab.setViewportView(measuresEditor);
    scmTab = new JScrollPane();
    tabbedPane.addTab("SCM", null, scmTab, null);
    scmEditor = new JEditorPane();
    scmTab.setViewportView(scmEditor);
    treeScrollPane = new JScrollPane();
    treeScrollPane.setPreferredSize(new Dimension(200, 400));
    splitPane.setLeftComponent(treeScrollPane);
    componentTree = new JTree();
    componentTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode("empty") {

        {
        }
    }));
    treeScrollPane.setViewportView(componentTree);
    componentTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    componentTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) componentTree.getLastSelectedPathComponent();
            if (node == null) {
                // Nothing is selected.
                return;
            }
            frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            updateDetails((Component) node.getUserObject());
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    });
    frame.pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) LookAndFeelInfo(javax.swing.UIManager.LookAndFeelInfo) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JTabbedPane(javax.swing.JTabbedPane) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Cursor(java.awt.Cursor) IOException(java.io.IOException) JTree(javax.swing.JTree) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JSplitPane(javax.swing.JSplitPane) Component(org.sonar.scanner.protocol.output.ScannerReport.Component)

Example 74 with JTabbedPane

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

the class AbstractPanel method setTabFocus.

public void setTabFocus() {
    if (parent != null) {
        // Just in case the tab has been hidden
        parent.setVisible(this, true);
    }
    Component c = this.getParent();
    if (c instanceof JTabbedPane) {
        JTabbedPane tab = (JTabbedPane) c;
        tab.setSelectedComponent(this);
    }
}
Also used : JTabbedPane(javax.swing.JTabbedPane) Component(java.awt.Component)

Example 75 with JTabbedPane

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

the class AddOnDependencyChecker method confirmUninstallChanges.

/**
     * Asks the user for confirmation of uninstall changes.
     * <p>
     * User will also be warned about add-ons that are being uninstalled which are required by add-ons being downloaded.
     *
     * @param parent the parent component of the confirmation dialogue
     * @param result the calculation result of the uninstallation
     * @param addOnsBeingDownloaded the add-ons being downloaded to check if depend on the add-ons being uninstalled
     * @return {@code true} if the user accept the changes, {@code false} otherwise
     */
public boolean confirmUninstallChanges(Component parent, UninstallationResult result, Set<AddOn> addOnsBeingDownloaded) {
    Set<AddOn> forcedUninstallations = new HashSet<>(result.getUninstallations());
    forcedUninstallations.removeAll(result.getSelectedAddOns());
    boolean dependencyDownloadFound = false;
    for (AddOn addOnDownloading : addOnsBeingDownloaded) {
        if (containsAny(addOnDownloading.getIdsAddOnDependencies(), forcedUninstallations)) {
            dependencyDownloadFound = true;
            break;
        }
    }
    if (!dependencyDownloadFound) {
        for (AddOn addOnDownloading : addOnsBeingDownloaded) {
            if (containsAny(addOnDownloading.getIdsAddOnDependencies(), result.getSelectedAddOns())) {
                dependencyDownloadFound = true;
                break;
            }
        }
    }
    if (dependencyDownloadFound) {
        if (JOptionPane.showConfirmDialog(parent, new Object[] { Constant.messages.getString("cfu.confirmation.dialogue.message.uninstallsRequiredByAddOnsDownloading"), Constant.messages.getString("cfu.confirmation.dialogue.message.continueWithUninstallation") }, Constant.PROGRAM_NAME, JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
            return false;
        }
    }
    if (forcedUninstallations.isEmpty() && result.getExtensions().isEmpty()) {
        return JOptionPane.showConfirmDialog(parent, Constant.messages.getString("cfu.uninstall.confirm"), Constant.PROGRAM_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    }
    if (result.getExtensions().isEmpty()) {
        return JOptionPane.showConfirmDialog(parent, new Object[] { Constant.messages.getString("cfu.uninstall.dependentAddOns.confirm"), createScrollableTable(new AddOnTableModel(forcedUninstallations, false)), Constant.messages.getString("cfu.confirmation.dialogue.message.continueWithUninstallation") }, Constant.PROGRAM_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    }
    if (forcedUninstallations.isEmpty()) {
        return JOptionPane.showConfirmDialog(parent, new Object[] { Constant.messages.getString("cfu.uninstall.dependentExtensions.confirm"), createScrollableTable(new ExtensionsTableModel(result.getExtensions())), Constant.messages.getString("cfu.confirmation.dialogue.message.continueWithUninstallation") }, Constant.PROGRAM_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    }
    JPanel panel = new JPanel(new BorderLayout());
    JTabbedPane tabs = new JTabbedPane();
    panel.add(tabs);
    tabs.add(Constant.messages.getString("cfu.confirmation.dialogue.tab.header.uninstallations"), createScrollableTable(new AddOnTableModel(forcedUninstallations, false)));
    tabs.add(Constant.messages.getString("cfu.confirmation.dialogue.tab.header.extensionUnloads"), createScrollableTable(new ExtensionsTableModel(result.getExtensions())));
    List<Object> optionPaneContents = new ArrayList<>();
    optionPaneContents.add(Constant.messages.getString("cfu.uninstall.dependentAddonsAndExtensions.confirm"));
    optionPaneContents.add(panel);
    optionPaneContents.add(Constant.messages.getString("cfu.confirmation.dialogue.message.continueWithUninstallation"));
    return JOptionPane.showConfirmDialog(parent, optionPaneContents.toArray(), Constant.PROGRAM_NAME, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
}
Also used : JPanel(javax.swing.JPanel) AddOn(org.zaproxy.zap.control.AddOn) BorderLayout(java.awt.BorderLayout) JTabbedPane(javax.swing.JTabbedPane) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

JTabbedPane (javax.swing.JTabbedPane)104 JPanel (javax.swing.JPanel)51 BorderLayout (java.awt.BorderLayout)33 JLabel (javax.swing.JLabel)26 JButton (javax.swing.JButton)25 JScrollPane (javax.swing.JScrollPane)23 Dimension (java.awt.Dimension)19 ActionEvent (java.awt.event.ActionEvent)18 ActionListener (java.awt.event.ActionListener)15 JCheckBox (javax.swing.JCheckBox)14 ChangeListener (javax.swing.event.ChangeListener)13 GridBagLayout (java.awt.GridBagLayout)12 BoxLayout (javax.swing.BoxLayout)12 ChangeEvent (javax.swing.event.ChangeEvent)12 GridBagConstraints (java.awt.GridBagConstraints)11 Insets (java.awt.Insets)11 ArrayList (java.util.ArrayList)10 JFrame (javax.swing.JFrame)10 JMenuItem (javax.swing.JMenuItem)10 JSplitPane (javax.swing.JSplitPane)10