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);
}
}
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);
}
}
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();
}
}
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;
}
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("");
}
}
Aggregations