Search in sources :

Example 96 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class UserActivityWatcher method unprocessComponent.

protected void unprocessComponent(final Component component) {
    if (component instanceof JTextComponent) {
        ((JTextComponent) component).getDocument().removeDocumentListener(myDocumentListener);
    } else if (component instanceof ItemSelectable) {
        ((ItemSelectable) component).removeItemListener(myItemListener);
    } else if (component instanceof JTree) {
        ((JTree) component).getModel().removeTreeModelListener(myTreeModelListener);
    } else if (component instanceof DocumentBasedComponent) {
        ((DocumentBasedComponent) component).getDocument().removeDocumentListener(myIdeaDocumentListener);
    }
    if (component instanceof JTable) {
        component.removePropertyChangeListener(myTableListener);
        TableModel model = ((JTable) component).getModel();
        if (model != null) {
            model.removeTableModelListener(myTableModelListener);
        }
        component.removePropertyChangeListener(myCellEditorChangeListener);
    }
    if (component instanceof JSlider) {
        ((JSlider) component).removeChangeListener(myChangeListener);
    }
    if (component instanceof UserActivityProviderComponent) {
        ((UserActivityProviderComponent) component).removeChangeListener(myChangeListener);
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) TableModel(javax.swing.table.TableModel)

Example 97 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class UserActivityWatcher method processComponent.

protected void processComponent(final Component parentComponent) {
    if (parentComponent instanceof JTextComponent) {
        ((JTextComponent) parentComponent).getDocument().addDocumentListener(myDocumentListener);
    } else if (parentComponent instanceof ItemSelectable) {
        ((ItemSelectable) parentComponent).addItemListener(myItemListener);
    } else if (parentComponent instanceof JList) {
        ((JList) parentComponent).getModel().addListDataListener(myListDataListener);
        ((JList) parentComponent).addListSelectionListener(myListSelectionListener);
    } else if (parentComponent instanceof JTree) {
        ((JTree) parentComponent).getModel().addTreeModelListener(myTreeModelListener);
    } else if (parentComponent instanceof DocumentBasedComponent) {
        ((DocumentBasedComponent) parentComponent).getDocument().addDocumentListener(myIdeaDocumentListener);
    }
    if (parentComponent instanceof JComboBox) {
        ComboBoxEditor editor = ((JComboBox) parentComponent).getEditor();
        if (editor != null) {
            register(editor.getEditorComponent());
        }
    }
    if (parentComponent instanceof JTable) {
        JTable table = (JTable) parentComponent;
        table.addPropertyChangeListener("model", myTableListener);
        TableModel model = table.getModel();
        if (model != null) {
            model.addTableModelListener(myTableModelListener);
        }
        table.addPropertyChangeListener(ComboBox.TABLE_CELL_EDITOR_PROPERTY, myCellEditorChangeListener);
    }
    if (parentComponent instanceof JSlider) {
        ((JSlider) parentComponent).addChangeListener(myChangeListener);
    }
    if (parentComponent instanceof UserActivityProviderComponent) {
        ((UserActivityProviderComponent) parentComponent).addChangeListener(myChangeListener);
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) TableModel(javax.swing.table.TableModel)

Example 98 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class FindInEditorMultiCaretTest method setTextToFind.

private void setTextToFind(String text) {
    EditorSearchSession editorSearchSession = getEditorSearchComponent();
    assertNotNull(editorSearchSession);
    JTextComponent searchField = editorSearchSession.getComponent().getSearchTextComponent();
    assertNotNull(searchField);
    for (int i = 0; i <= text.length(); i++) {
        // emulate typing chars one by one
        searchField.setText(text.substring(0, i));
        IdeEventQueue.getInstance().flushQueue();
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent)

Example 99 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class EduCCModuleBuilder method modifySettingsStep.

@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
    ModuleWizardStep javaSettingsStep = ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, this, Conditions.alwaysTrue());
    Function<JTextField, String> getValue = JTextComponent::getText;
    getWizardInputField("ccname", "", "Name:", myPanel.getNameField(), getValue).addToSettings(settingsStep);
    getWizardInputField("ccauthor", "", "Author:", myPanel.getAuthorField(), getValue).addToSettings(settingsStep);
    LanguageExtensionPoint[] extensions = new ExtensionPointName<LanguageExtensionPoint>(EduCourseConfigurator.EP_NAME).getExtensions();
    myLanguageComboBox.removeAllItems();
    for (LanguageExtensionPoint extension : extensions) {
        String languageId = extension.getKey();
        Language language = Language.findLanguageByID(languageId);
        if (language == null) {
            LOG.info("Language with id " + languageId + " not found");
        }
        myLanguageComboBox.addItem(new LanguageWrapper(language));
    }
    getWizardInputField("cclang", "", "Language:", myLanguageComboBox, comboBox -> (String) comboBox.getSelectedItem()).addToSettings(settingsStep);
    getWizardInputField("ccdescr", "", "Description:", myPanel.getDescriptionField(), JTextArea::getText).addToSettings(settingsStep);
    return javaSettingsStep;
}
Also used : Language(com.intellij.lang.Language) ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) InvalidDataException(com.intellij.openapi.util.InvalidDataException) Function(java.util.function.Function) WizardInputField(com.intellij.ide.util.projectWizard.WizardInputField) JDOMException(org.jdom.JDOMException) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) CCNewProjectPanel(com.jetbrains.edu.coursecreator.ui.CCNewProjectPanel) StudyProjectGenerator(com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator) EduCourseModuleBuilder(com.jetbrains.edu.learning.intellij.generation.EduCourseModuleBuilder) Project(com.intellij.openapi.project.Project) Conditions(com.intellij.openapi.util.Conditions) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ComboBox(com.intellij.openapi.ui.ComboBox) Lesson(com.jetbrains.edu.learning.courseFormat.Lesson) IOException(java.io.IOException) StudyTaskManager(com.jetbrains.edu.learning.StudyTaskManager) ProjectWizardStepFactory(com.intellij.ide.util.projectWizard.ProjectWizardStepFactory) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Task(com.jetbrains.edu.learning.courseFormat.Task) JTextComponent(javax.swing.text.JTextComponent) File(java.io.File) EduCourseConfigurator(com.jetbrains.edu.learning.intellij.EduCourseConfigurator) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) Nullable(org.jetbrains.annotations.Nullable) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) CCUtils(com.jetbrains.edu.coursecreator.CCUtils) Course(com.jetbrains.edu.learning.courseFormat.Course) javax.swing(javax.swing) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) Language(com.intellij.lang.Language) LanguageExtensionPoint(com.intellij.lang.LanguageExtensionPoint) Nullable(org.jetbrains.annotations.Nullable)

Example 100 with JTextComponent

use of javax.swing.text.JTextComponent in project intellij-community by JetBrains.

the class ClearTextAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
    if (component instanceof JTextComponent) {
        final JTextComponent textComponent = (JTextComponent) component;
        textComponent.setText("");
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) JTextComponent(javax.swing.text.JTextComponent)

Aggregations

JTextComponent (javax.swing.text.JTextComponent)181 Component (java.awt.Component)28 JComponent (javax.swing.JComponent)16 BadLocationException (javax.swing.text.BadLocationException)13 NotNull (org.jetbrains.annotations.NotNull)13 DocumentEvent (javax.swing.event.DocumentEvent)11 DocumentAdapter (com.intellij.ui.DocumentAdapter)8 Caret (javax.swing.text.Caret)8 Document (javax.swing.text.Document)8 Point (java.awt.Point)7 ActionEvent (java.awt.event.ActionEvent)7 ActionListener (java.awt.event.ActionListener)7 ArrayList (java.util.ArrayList)7 ComboBoxEditor (javax.swing.ComboBoxEditor)7 FocusEvent (java.awt.event.FocusEvent)6 Color (java.awt.Color)5 KeyEvent (java.awt.event.KeyEvent)5 MouseEvent (java.awt.event.MouseEvent)5 JButton (javax.swing.JButton)5 JComboBox (javax.swing.JComboBox)5