Search in sources :

Example 1 with TextChangeListener

use of com.google.jstestdriver.idea.util.TextChangeListener in project intellij-plugins by JetBrains.

the class AllInDirectoryRunSettingsSection method createInfoComponent.

private static JComponent createInfoComponent(@NotNull final Project project, @NotNull JTextField directoryTextField) {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel("Matched configuration files (*.jstd and jsTestDriver.conf):"), BorderLayout.NORTH);
    final JBList fileList = new JBList(ArrayUtil.EMPTY_STRING_ARRAY);
    fileList.setBorder(BorderFactory.createLineBorder(JBColor.GRAY));
    fileList.setCellRenderer(new ListCellRendererWrapper<String>() {

        @Override
        public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
            setText(value);
        }
    });
    SwingUtils.addTextChangeListener(directoryTextField, new TextChangeListener() {

        @Override
        public void textChanged(String oldText, @NotNull String newText) {
            List<String> configs = getConfigsInDir(project, newText);
            fileList.setListData(configs.toArray());
        }
    });
    panel.add(fileList, BorderLayout.CENTER);
    return panel;
}
Also used : JBList(com.intellij.ui.components.JBList) JBList(com.intellij.ui.components.JBList) List(java.util.List) TextChangeListener(com.google.jstestdriver.idea.util.TextChangeListener)

Example 2 with TextChangeListener

use of com.google.jstestdriver.idea.util.TextChangeListener in project intellij-plugins by JetBrains.

the class TestCaseRunSettingsSection method trackJsTestFilePathChanges.

private void trackJsTestFilePathChanges(@NotNull final Project project) {
    SwingUtils.addTextChangeListener(myJsFileRunSettingsSection.getJsTestFileTextField(), new TextChangeListener() {

        @Override
        public void textChanged(String oldJsTestFilePath, @NotNull String newJsTestFilePath) {
            String oldValue = getTestCaseName();
            try {
                updateTestCaseVariants(project, newJsTestFilePath);
                fireStateChanged(project);
            } finally {
                myTestCaseNameComboBox.setSelectedItem(oldValue);
            }
        }
    });
    myTestCaseNameComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireStateChanged(project);
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ItemListener(java.awt.event.ItemListener) TextChangeListener(com.google.jstestdriver.idea.util.TextChangeListener)

Aggregations

TextChangeListener (com.google.jstestdriver.idea.util.TextChangeListener)2 JBList (com.intellij.ui.components.JBList)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 List (java.util.List)1