Example usage for javax.swing JCheckBox isSelected

List of usage examples for javax.swing JCheckBox isSelected

Introduction

In this page you can find the example usage for javax.swing JCheckBox isSelected.

Prototype

public boolean isSelected() 

Source Link

Document

Returns the state of the button.

Usage

From source file:es.uvigo.ei.sing.adops.views.TextFileViewer.java

public TextFileViewer(final File file) {
    super(new BorderLayout());

    this.file = file;

    // TEXT AREA/*  ww  w  . j a va 2s .  c  o m*/
    this.textArea = new JTextArea(TextFileViewer.loadFile(file));
    this.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, this.textArea.getFont().getSize()));
    this.textArea.setLineWrap(true);
    this.textArea.setWrapStyleWord(true);
    this.textArea.setEditable(false);

    this.highlightPatiner = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);

    // OPTIONS PANEL
    final JPanel panelOptions = new JPanel(new BorderLayout());
    final JPanel panelOptionsEast = new JPanel(new FlowLayout());
    final JPanel panelOptionsWest = new JPanel(new FlowLayout());
    final JCheckBox chkLineWrap = new JCheckBox("Line wrap", true);
    final JButton btnChangeFont = new JButton("Change Font");

    final JLabel lblSearch = new JLabel("Search");
    this.txtSearch = new JTextField();
    this.chkRegularExpression = new JCheckBox("Reg. exp.", true);
    final JButton btnSearch = new JButton("Search");
    final JButton btnClear = new JButton("Clear");
    this.txtSearch.setColumns(12);
    // this.txtSearch.setOpaque(true);

    panelOptionsEast.add(btnChangeFont);
    panelOptionsEast.add(chkLineWrap);
    panelOptionsWest.add(lblSearch);
    panelOptionsWest.add(this.txtSearch);
    panelOptionsWest.add(this.chkRegularExpression);
    panelOptionsWest.add(btnSearch);
    panelOptionsWest.add(btnClear);

    if (FastaUtils.isFasta(file)) {
        panelOptionsWest.add(new JSeparator());

        final JButton btnExport = new JButton("Export...");

        panelOptionsWest.add(btnExport);

        btnExport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new ExportDialog(file).setVisible(true);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(Workbench.getInstance().getMainFrame(),
                            "Error reading fasta file: " + e1.getMessage(), "Export Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }

    panelOptions.add(panelOptionsWest, BorderLayout.WEST);
    panelOptions.add(panelOptionsEast, BorderLayout.EAST);

    this.fontChooser = new JFontChooser();

    this.add(new JScrollPane(this.textArea), BorderLayout.CENTER);
    this.add(panelOptions, BorderLayout.NORTH);

    chkLineWrap.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            textArea.setLineWrap(chkLineWrap.isSelected());
        }
    });

    btnChangeFont.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            changeFont();
        }
    });

    this.textArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }
    });

    this.textArea.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (TextFileViewer.this.wasModified) {
                try {
                    FileUtils.write(TextFileViewer.this.file, TextFileViewer.this.textArea.getText());
                    TextFileViewer.this.wasModified = false;
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    final ActionListener alSearch = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateSearch();
        }
    };
    txtSearch.addActionListener(alSearch);
    btnSearch.addActionListener(alSearch);

    btnClear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSearch();
        }
    });
}

From source file:com.alvermont.terraj.fracplanet.ui.ControlsDialog.java

private void enableFogCheckboxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_enableFogCheckboxActionPerformed
{//GEN-HEADEREND:event_enableFogCheckboxActionPerformed

    JCheckBox source = (JCheckBox) evt.getSource();

    this.parent.getParameters().getRenderParameters().setEnableFog(source.isSelected());
}

From source file:com.mirth.connect.client.ui.SettingsPanelServer.java

public void doRestore() {
    if (getFrame().isSaveEnabled()) {
        if (!getFrame().alertOkCancel(this, "Your new settings will first be saved.  Continue?")) {
            return;
        }// www.  ja  va2s  .  co  m
        if (!doSave()) {
            return;
        }
    }

    String content = getFrame().browseForFileString("XML");

    if (content != null) {
        try {
            if (!getFrame().promptObjectMigration(content, "server configuration")) {
                return;
            }

            final ServerConfiguration configuration = ObjectXMLSerializer.getInstance().deserialize(content,
                    ServerConfiguration.class);

            final JCheckBox deployChannelsCheckBox = new JCheckBox("Deploy all channels after import");
            deployChannelsCheckBox.setSelected(true);
            String warningMessage = "Import configuration from " + configuration.getDate()
                    + "?\nWARNING: This will overwrite all current channels,\nalerts, server properties, and plugin properties.\n";
            Object[] params = { warningMessage, new JLabel(" "), deployChannelsCheckBox };
            int option = JOptionPane.showConfirmDialog(this, params, "Select an Option",
                    JOptionPane.YES_NO_OPTION);

            if (option == JOptionPane.YES_OPTION) {
                final Set<String> alertIds = new HashSet<String>();
                for (AlertStatus alertStatus : PlatformUI.MIRTH_FRAME.mirthClient.getAlertStatusList()) {
                    alertIds.add(alertStatus.getId());
                }

                final String workingId = getFrame().startWorking("Restoring server config...");

                SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

                    private boolean updateAlerts = false;

                    public Void doInBackground() {
                        try {
                            getFrame().mirthClient.setServerConfiguration(configuration,
                                    deployChannelsCheckBox.isSelected());
                            getFrame().channelPanel.clearChannelCache();
                            doRefresh();
                            getFrame().alertInformation(SettingsPanelServer.this,
                                    "Your configuration was successfully restored.");
                            updateAlerts = true;
                        } catch (ClientException e) {
                            getFrame().alertThrowable(SettingsPanelServer.this, e);
                        }
                        return null;
                    }

                    public void done() {
                        if (getFrame().alertPanel == null) {
                            getFrame().alertPanel = new DefaultAlertPanel();
                        }

                        if (updateAlerts) {
                            getFrame().alertPanel.updateAlertDetails(alertIds);
                        }
                        getFrame().stopWorking(workingId);
                    }
                };

                worker.execute();
            }
        } catch (Exception e) {
            getFrame().alertError(this, "Invalid server configuration file.");
        }
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * Checkbox hat sich verndert/*from w w  w . j  a  v a2 s.  c  om*/
 */
@Override
public void itemStateChanged(ItemEvent ev) {
    if (ignoreAction)
        return;
    // ////////////////////////////////////////////////////////////////////////
    // Checkbox Event?
    if (ev.getSource() instanceof JCheckBox) {
        JCheckBox cb = (JCheckBox) ev.getItemSelectable();
        String cmd = cb.getActionCommand();
        // //////////////////////////////////////////////////////////////////////
        // Dynamische Gradienten?
        if (cmd.equals("dyn_gradients_on")) {
            lg.debug("dynamic gradients <" + cb.isSelected() + ">");
            currentConfig.setDynGradientsEnable(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Deepstops
        else if (cmd.equals("deepstops_on")) {
            lg.debug("depstops <" + cb.isSelected() + ">");
            currentConfig.setDeepStopEnable(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Passive Semiclose Rebreather Mode?
        else if (cmd.equals("individuals_pscr_on")) {
            lg.debug("pscr mode  <" + cb.isSelected() + ">");
            currentConfig.setPscrModeEnabled(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Sensor warning on/off
        else if (cmd.equals("individual_sensors_on")) {
            lg.debug("sensors on  <" + cb.isSelected() + ">");
            currentConfig.setSensorsEnabled(cb.isSelected());
        }
        // //////////////////////////////////////////////////////////////////////
        // Warnungen an/aus
        else if (cmd.equals("individuals_warnings_on")) {
            lg.debug("warnings on  <" + cb.isSelected() + ">");
            currentConfig.setSountEnabled(cb.isSelected());
        } else {
            lg.warn("unknown item changed: <" + cb.getActionCommand() + "> <" + cb.isSelected() + ">");
        }
    }
}

From source file:it.imtech.metadata.MetaUtility.java

private String check_and_save_metadata_recursive(Map<Object, Metadata> submetadatas, boolean checkMandatory) {
    ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);
    String error = "";

    for (Map.Entry<Object, Metadata> field : submetadatas.entrySet()) {
        if (!field.getValue().datatype.equals("Node") && field.getValue().editable.equals("Y")) {
            Component element = null;
            String midp = Integer.toString(field.getValue().MID_parent);

            if (midp.equals("11") || midp.equals("13"))
                element = BookImporter.getInstance().getComponentByName(
                        "MID_" + Integer.toString(field.getValue().MID) + "---" + field.getValue().sequence);
            else {
                element = BookImporter.getInstance()
                        .getComponentByName("MID_" + Integer.toString(field.getValue().MID));
            }//from  w  w w  .  jav a2  s . co  m

            if (element != null) {
                if (field.getValue().datatype.equals("CharacterString")
                        || field.getValue().datatype.equals("LangString")
                        || field.getValue().datatype.equals("GPS")) {
                    JTextArea textTemp = (JTextArea) element;
                    field.getValue().value = textTemp.getText();

                    if (checkMandatory && field.getValue().value.length() < 1
                            && (field.getValue().mandatory.equals("Y") || field.getValue().MID == 14
                                    || field.getValue().MID == 15)) {
                        error += Utility.getBundleString("error10", bundle) + " "
                                + field.getValue().description.toString() + " "
                                + Utility.getBundleString("error11", bundle) + "!\n";
                    }
                }
                if (field.getValue().datatype.equals("LangString")) {
                    Component combobox = BookImporter.getInstance()
                            .getComponentByName("MID_" + Integer.toString(field.getValue().MID) + "_lang");
                    JComboBox tmp = (JComboBox) combobox;

                    Map.Entry tmp2 = (Map.Entry) tmp.getSelectedItem();
                    field.getValue().language = tmp2.getKey().toString();
                } else if (field.getValue().datatype.equals("DateTime")) {
                    Component combobox = BookImporter.getInstance()
                            .getComponentByName("MID_" + Integer.toString(field.getValue().MID) + "_check");
                    JCheckBox beforechrist = (JCheckBox) combobox;

                    JDateChooser datePicker = (JDateChooser) element;
                    Date data = datePicker.getDate();

                    field.getValue().value = "";

                    if (data != null) {
                        Format formatter = new SimpleDateFormat("yyyy-MM-dd");
                        String stDate = formatter.format(data);

                        if (!stDate.equals("")) {
                            if (beforechrist.isSelected()) {
                                stDate = "-" + stDate;
                            }

                            field.getValue().value = stDate;
                        }
                    }
                } else if (field.getValue().datatype.equals("Language")
                        || field.getValue().datatype.equals("Boolean")
                        || field.getValue().datatype.equals("License")
                        || field.getValue().datatype.equals("Vocabulary")) {
                    Component combobox = null;

                    if (midp.equals("11") || midp.equals("13"))
                        combobox = BookImporter.getInstance().getComponentByName("MID_"
                                + Integer.toString(field.getValue().MID) + "---" + field.getValue().sequence);
                    else
                        combobox = BookImporter.getInstance()
                                .getComponentByName("MID_" + Integer.toString(field.getValue().MID));

                    JComboBox tmp = (JComboBox) combobox;

                    Map.Entry tmp2 = (Map.Entry) tmp.getSelectedItem();

                    if (field.getValue().datatype.equals("License")
                            || field.getValue().datatype.equals("Vocabulary")) {
                        ResourceBundle tmpBundle = ResourceBundle.getBundle(Globals.RESOURCES,
                                Globals.CURRENT_LOCALE, Globals.loader);

                        if (checkMandatory
                                && tmp2.getValue().toString()
                                        .equals(Utility.getBundleString("comboselect", tmpBundle))
                                && field.getValue().mandatory.equals("Y"))
                            error += Utility.getBundleString("error10", bundle) + " "
                                    + field.getValue().description.toString() + " "
                                    + Utility.getBundleString("error11", bundle) + "!\n";
                        else if (tmp2.getValue().toString()
                                .equals(Utility.getBundleString("comboselect", tmpBundle)))
                            field.getValue().value = "";
                        else
                            field.getValue().value = tmp2.getValue().toString();
                    } else
                        field.getValue().value = tmp2.getKey().toString();
                }
            } else {
                if (midp.equals("11") || midp.equals("13")) {
                    field.getValue().value = "";
                }
            }
        }

        error += check_and_save_metadata_recursive(field.getValue().submetadatas, checkMandatory);
    }

    return error;
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

protected void showAutoSyncSettings() {
    JCheckBox checkboxAutoSyncActive;
    JTextField fieldSyncInterval;
    JPanel panel = new JPanel(new BorderLayout());
    {//from  w w w  .  ja  v  a 2s .  c om
        checkboxAutoSyncActive = new JCheckBox("Automatische Synchronisierung aktiv");
        checkboxAutoSyncActive.setSelected(iliasProperties.isAutoSyncActive());
        panel.add(checkboxAutoSyncActive, BorderLayout.NORTH);
    }
    {
        JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
        panel2.add(new JLabel("Intervall in Minuten:"));
        fieldSyncInterval = new JTextField(String.valueOf(iliasProperties.getAutoSyncIntervalInSeconds() / 60),
                20);
        panel2.add(fieldSyncInterval);
        panel.add(panel2, BorderLayout.CENTER);
    }
    {
        panel.add(new JLabel(
                "<html>Sie knnen das Programm auch ohne GUI laufen lassen.<br>Weitere Informationen hierzu erhalten Sie, wenn Sie das Programm folgendermaen starten<br>java -jar &lt;name&gt;.jar help</html>"),
                BorderLayout.SOUTH);
    }

    if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel,
            "Automatische Synchronisierung einstellen", JOptionPane.OK_CANCEL_OPTION)) {
        iliasProperties.setAutoSyncActive(checkboxAutoSyncActive.isSelected());
        iliasProperties.setAutoSyncIntervalInSeconds(Integer.parseInt(fieldSyncInterval.getText()) * 60);
        saveProperties(iliasProperties);

        startOrStopAutoSync();
    }

}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error//from  w ww .java2  s.  c o m
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java

@SuppressWarnings("unchecked")
protected void rankChanged(final FormViewObj form, final ValComboBoxFromQuery parentComboBox,
        final ValComboBox rankComboBox, final JCheckBox acceptedCheckBox,
        final ValComboBoxFromQuery acceptedParentWidget) {
    if (form.getAltView().getMode() != CreationMode.EDIT) {
        return;/*  ww  w.  java2  s  . co m*/
    }

    //log.debug("form was validated: calling adjustRankComboBoxModel()");

    Object objInForm = form.getDataObj();
    //log.debug("form data object = " + objInForm);
    if (objInForm == null) {
        return;
    }

    final T formNode = (T) objInForm;
    T parent = null;
    if (parentComboBox.getValue() instanceof String) {
        // the data is still in the VIEW mode for some reason
        log.debug("Form is in mode (" + form.getAltView().getMode() + ") but the parent data is a String");
        parentComboBox.getValue();
        parent = formNode.getParent();
    } else {
        parent = (T) parentComboBox.getValue();
    }

    final T theParent = parent;
    I rankObj = (I) rankComboBox.getValue();
    final int rank = rankObj == null ? -2 : rankObj.getRankId();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            boolean canSynonymize = false;
            if (canAccessSynonymy(formNode, rank)) {
                canSynonymize = formNode.getDefinition() != null
                        && formNode.getDefinition().getSynonymizedLevel() <= rank
                        && formNode.getDescendantCount() == 0;

            }
            if (acceptedCheckBox != null && acceptedParentWidget != null) {
                acceptedCheckBox.setEnabled(canSynonymize && theParent != null);
                if (acceptedCheckBox.isSelected() && acceptedCheckBox.isEnabled()) {
                    acceptedParentWidget.setValue(null, null);
                    acceptedParentWidget.setChanged(true); // This should be done automatically
                    acceptedParentWidget.setEnabled(false);
                }
            }
            form.getValidator().validateForm();
        }
    });
}

From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java

@Override
public void initialize(Viewable viewableArg) {
    super.initialize(viewableArg);

    GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent");
    Component comp = formViewObj.getControlByName("definitionItem");
    if (comp instanceof ValComboBox) {
        final ValComboBox rankComboBox = (ValComboBox) comp;

        final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted");
        Component apComp = formViewObj.getControlByName("acceptedParent");
        final ValComboBoxFromQuery acceptedParentWidget = apComp instanceof ValComboBoxFromQuery
                ? (ValComboBoxFromQuery) apComp
                : null;/*from   w w  w  .  j a v  a2  s  .  co m*/

        if (parentField instanceof ValComboBoxFromQuery) {
            final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField;
            if (parentCBX != null && rankComboBox != null) {
                parentCBX.addListSelectionListener(new ListSelectionListener() {
                    public void valueChanged(ListSelectionEvent e) {
                        if (e == null || !e.getValueIsAdjusting()) {
                            parentChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox,
                                    acceptedParentWidget);
                        }
                    }
                });
                rankComboBox.getComboBox().addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        rankChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox,
                                acceptedParentWidget);
                    }
                });
            }
        }

        if (acceptedCheckBox != null && acceptedParentWidget != null) {
            acceptedCheckBox.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    if (acceptedCheckBox.isSelected()) {
                        acceptedParentWidget.setValue(null, null);
                        acceptedParentWidget.setChanged(true); // This should be done automatically
                        acceptedParentWidget.setEnabled(false);
                    } else {
                        acceptedParentWidget.setEnabled(true);
                    }
                }
            });
        }
    }
}

From source file:idontwant2see.IDontWant2See.java

private AbstractAction getActionInputTitle(final Program p, final String part) {
    return new AbstractAction(mLocalizer.msg("menu.userEntered", "User entered value")) {
        public void actionPerformed(final ActionEvent e) {
            final JCheckBox caseSensitive = new JCheckBox(mLocalizer.msg("caseSensitive", "case sensitive"));
            String title = p.getTitle();
            ArrayList<String> items = new ArrayList<String>();
            if (!StringUtils.isEmpty(part)) {
                String shortTitle = title.trim().substring(0, title.length() - part.length()).trim();
                shortTitle = StringUtils.removeEnd(shortTitle, "-").trim();
                shortTitle = StringUtils.removeEnd(shortTitle, "(").trim();
                items.add(shortTitle + "*");
            }//  w w  w .  java2  s  .c om
            int index = title.indexOf(" - ");
            if (index > 0) {
                items.add(title.substring(0, index).trim() + "*");
            }
            items.add(title);
            index = title.lastIndexOf(':');
            if (index > 0) {
                items.add(title.substring(0, index).trim() + "*");
            }
            final JComboBox input = new JComboBox(items.toArray(new String[items.size()]));
            input.setEditable(true);

            input.addAncestorListener(new AncestorListener() {
                public void ancestorAdded(final AncestorEvent event) {
                    event.getComponent().requestFocus();
                }

                public void ancestorMoved(final AncestorEvent event) {
                }

                public void ancestorRemoved(final AncestorEvent event) {
                }
            });

            if (JOptionPane.showConfirmDialog(UiUtilities.getLastModalChildOf(getParentFrame()),
                    new Object[] {
                            mLocalizer.msg("exclusionText",
                                    "What should be excluded? (You can use the wildcard *)"),
                            input, caseSensitive },
                    mLocalizer.msg("exclusionTitle", "Exclusion value entering"),
                    JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
                String test = "";

                String result = (String) input.getSelectedItem();
                if (result != null) {
                    test = result.replaceAll("\\*+", "\\*").trim();

                    if (test.length() >= 0 && !test.equals("*")) {
                        mSettings.getSearchList()
                                .add(new IDontWant2SeeListEntry(result, caseSensitive.isSelected()));
                        mSettings.setLastEnteredExclusionString(result);
                        updateFilter(!mSettings.isSwitchToMyFilter());
                    }
                }

                if (test.trim().length() <= 1) {
                    JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(getParentFrame()),
                            mLocalizer.msg("notValid", "The entered text is not valid."),
                            Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    };
}