Search in sources :

Example 71 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project flutter-intellij by flutter.

the class FlutterSmallIDEGeneratorPeer method addSettingsStateListener.

@Override
public void addSettingsStateListener(@NotNull WebProjectGenerator.SettingsStateListener stateListener) {
    final JTextComponent editorComponent = (JTextComponent) sdkPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
    editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(DocumentEvent e) {
            stateListener.stateChanged(validate() == null);
        }
    });
    if (validate() != null) {
        stateListener.stateChanged(false);
    }
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent)

Example 72 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project google-cloud-intellij by GoogleCloudPlatform.

the class SetupCloudRepositoryDialog method createUIComponents.

private void createUIComponents() {
    projectSelector = new ProjectSelector(ideProject);
    projectSelector.setMinimumSize(new Dimension(400, 0));
    repositorySelector = new RepositorySelector(projectSelector.getSelectedProject(), true);
    remoteNameSelector = new RepositoryRemotePanel(gitRepository);
    projectSelector.addProjectSelectionListener(this::updateRepositorySelector);
    repositorySelector.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent event) {
            remoteNameSelector.update(repositorySelector.getSelectedRepository());
            updateButtons();
        }
    });
    remoteNameSelector.getRemoteNameField().getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent event) {
            updateButtons();
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) ProjectSelector(com.google.cloud.tools.intellij.project.ProjectSelector)

Example 73 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project google-cloud-intellij by GoogleCloudPlatform.

the class CloneCloudRepositoryDialog method createUIComponents.

private void createUIComponents() {
    projectSelector = new ProjectSelector(project);
    projectSelector.setMinimumSize(new Dimension(400, 0));
    projectSelector.addProjectSelectionListener(this::updateRepositorySelector);
    repositorySelector = new RepositorySelector(projectSelector.getSelectedProject(), false);
    repositorySelector.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent event) {
            updateButtons();
        }
    });
}
Also used : DocumentAdapter(com.intellij.ui.DocumentAdapter) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) ProjectSelector(com.google.cloud.tools.intellij.project.ProjectSelector)

Example 74 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project google-cloud-intellij by GoogleCloudPlatform.

the class CloneCloudRepositoryDialog method initComponents.

private void initComponents() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
    fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description"));
    fcd.setHideIgnored(false);
    parentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), parentDirectory, project, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {

        @Override
        protected VirtualFile getInitialFile() {
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = project.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });
    final DocumentListener updateOkButtonListener = new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent event) {
            updateButtons();
        }
    };
    parentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    parentDirectory.setText(ProjectUtil.getBaseDir());
    directoryName.getDocument().addDocumentListener(updateOkButtonListener);
    setOKActionEnabled(false);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentListener(javax.swing.event.DocumentListener) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) ComponentWithBrowseButton(com.intellij.openapi.ui.ComponentWithBrowseButton) DocumentAdapter(com.intellij.ui.DocumentAdapter) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent)

Example 75 with DocumentAdapter

use of com.intellij.ui.DocumentAdapter in project google-cloud-intellij by GoogleCloudPlatform.

the class ProjectSelectionDialog method createUIComponents.

@VisibleForTesting
void createUIComponents() {
    addAccountButton = new JButton();
    addAccountButton.addActionListener((event) -> Services.getLoginService().logIn());
    // prepare table model and rendering.
    projectListTable = new JBTable();
    projectListTableModel = new ProjectListTableModel();
    projectListTable.setModel(projectListTableModel);
    projectListTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    projectListTable.getSelectionModel().addListSelectionListener(e -> validateProjectSelection());
    FilteredTextTableCellRenderer filterRenderer = new FilteredTextTableCellRenderer();
    projectListTable.setDefaultRenderer(Object.class, filterRenderer);
    DoubleClickListener tableDoubleClickListener = new DoubleClickListener() {

        @Override
        protected boolean onDoubleClick(MouseEvent event) {
            dialogWrapper.clickDefaultButton();
            return true;
        }
    };
    tableDoubleClickListener.installOn(projectListTable);
    // filter rows based on text field content.
    filterTextField = new JBTextField();
    TableRowSorter<TableModel> sorter = new TableRowSorter<>(projectListTableModel);
    projectListTable.setRowSorter(sorter);
    GeneralFilter filter = new GeneralFilter() {

        @Override
        protected boolean include(Entry value, int index) {
            return value.getStringValue(index).toLowerCase().contains(filterTextField.getText().toLowerCase());
        }
    };
    sorter.setRowFilter(filter);
    // on filter types, update row filter and renderer.
    filterTextField.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent e) {
            sorter.allRowsChanged();
            filterRenderer.setFilterText(filterTextField.getText());
        }
    });
    refreshAction = new RefreshAction();
    // prepare account combobox model and rendering.
    accountComboBox = new ComboBox<>();
    accountComboBox.setRenderer(new AccountComboBoxRenderer());
    accountComboBox.addActionListener((event) -> refreshProjectListUi((CredentialedUser) accountComboBox.getSelectedItem()));
    progressBar = new JBProgressBar();
    progressBar.setIndeterminate(true);
    progressBar.setVisible(false);
    // wrapper for center panel that holds either project selection or sign in screen.
    centerPanelWrapper = new JPanel(new BorderLayout());
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) DoubleClickListener(com.intellij.ui.DoubleClickListener) GeneralFilter(org.jdesktop.swingx.sort.RowFilters.GeneralFilter) JButton(javax.swing.JButton) DocumentAdapter(com.intellij.ui.DocumentAdapter) JBProgressBar(com.intellij.ui.JBProgressBar) JBTextField(com.intellij.ui.components.JBTextField) JBTable(com.intellij.ui.table.JBTable) DocumentEvent(javax.swing.event.DocumentEvent) BorderLayout(java.awt.BorderLayout) CredentialedUser(com.google.cloud.tools.intellij.login.CredentialedUser) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

DocumentAdapter (com.intellij.ui.DocumentAdapter)81 DocumentEvent (javax.swing.event.DocumentEvent)81 ActionEvent (java.awt.event.ActionEvent)15 ActionListener (java.awt.event.ActionListener)15 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)11 Document (javax.swing.text.Document)8 JTextComponent (javax.swing.text.JTextComponent)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ItemEvent (java.awt.event.ItemEvent)6 ItemListener (java.awt.event.ItemListener)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 JBTextField (com.intellij.ui.components.JBTextField)5 ChangeEvent (javax.swing.event.ChangeEvent)5 Project (com.intellij.openapi.project.Project)4 FieldPanel (com.intellij.ui.FieldPanel)4 ChangeListener (javax.swing.event.ChangeListener)4 List (java.util.List)3 DocumentListener (javax.swing.event.DocumentListener)3 ProjectSelector (com.google.cloud.tools.intellij.project.ProjectSelector)2