use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class JavaChangeSignatureDialog method createAdditionalPanels.
@NotNull
protected List<Pair<String, JPanel>> createAdditionalPanels() {
// this method is invoked before constructor body
myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList());
myExceptionsModel.setTypeInfos(myMethod.getMethod());
final JBTable table = new JBTable(myExceptionsModel);
table.setStriped(true);
table.setRowHeight(20);
table.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject));
final JavaCodeFragmentTableCellEditor cellEditor = new JavaCodeFragmentTableCellEditor(myProject);
cellEditor.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
final int row = table.getSelectedRow();
final int col = table.getSelectedColumn();
myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col);
updateSignature();
}
});
table.getColumnModel().getColumn(0).setCellEditor(cellEditor);
table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.getSelectionModel().setSelectionInterval(0, 0);
table.setSurrendersFocusOnKeystroke(true);
myPropExceptionsButton = new AnActionButton(RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, AllIcons.Hierarchy.Caller) {
@Override
public void actionPerformed(AnActionEvent e) {
final Ref<JavaCallerChooser> chooser = new Ref<>();
Consumer<Set<PsiMethod>> callback = psiMethods -> {
myMethodsToPropagateExceptions = psiMethods;
myExceptionPropagationTree = chooser.get().getTree();
};
chooser.set(new JavaCallerChooser(myMethod.getMethod(), myProject, RefactoringBundle.message("changeSignature.exception.caller.chooser"), myExceptionPropagationTree, callback));
chooser.get().show();
}
};
myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X"));
final JPanel panel = ToolbarDecorator.createDecorator(table).addExtraAction(myPropExceptionsButton).createPanel();
panel.setBorder(IdeBorderFactory.createEmptyBorder());
myExceptionsModel.addTableModelListener(mySignatureUpdater);
final ArrayList<Pair<String, JPanel>> result = new ArrayList<>();
final String message = RefactoringBundle.message("changeSignature.exceptions.panel.border.title");
result.add(Pair.create(message, panel));
return result;
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-plugins by JetBrains.
the class FlashRunConfigurationForm method initMainClassRelatedControls.
private void initMainClassRelatedControls() {
myOverrideMainClassCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (myOverrideMainClassCheckBox.isSelected()) {
updateOutputFileName(myOutputFileNameTextField, false);
}
updateControls();
if (myMainClassComponent.isEnabled()) {
IdeFocusManager.getInstance(myProject).requestFocus(myMainClassComponent.getChildComponent(), true);
}
}
});
myMainClassComponent.addDocumentListener(new DocumentListener() {
@Override
public void documentChanged(final DocumentEvent e) {
final String shortName = StringUtil.getShortName(myMainClassComponent.getText().trim());
if (!shortName.isEmpty()) {
myOutputFileNameTextField.setText(shortName + ".swf");
}
}
});
myOutputFileNameTextField.getDocument().addDocumentListener(new com.intellij.ui.DocumentAdapter() {
@Override
protected void textChanged(final javax.swing.event.DocumentEvent e) {
final FlexBuildConfiguration bc = myBCCombo.getBC();
if (bc != null && bc.getTargetPlatform() == TargetPlatform.Web) {
updateBCOutputLabel(bc);
}
}
});
}
use of com.intellij.openapi.editor.event.DocumentEvent in project kotlin by JetBrains.
the class PluginStartupComponent method initComponent.
@Override
public void initComponent() {
registerPathVariable();
if (ApplicationManager.getApplication().isUnitTestMode()) {
ThreadTrackerPatcherForTeamCityTesting.INSTANCE.patchThreadTracker();
}
JarUserDataManager.INSTANCE.register(KotlinJavaScriptLibraryDetectionUtil.HasKotlinJSMetadataInJar.INSTANCE);
DebuggerFiltersUtilKt.addKotlinStdlibDebugFilterIfNeeded();
try {
// API added in 15.0.2
UpdateChecker.INSTANCE.getExcludedFromUpdateCheckPlugins().add("org.jetbrains.kotlin");
} catch (Throwable throwable) {
LOG.debug("Excluding Kotlin plugin updates using old API", throwable);
UpdateChecker.getDisabledToUpdatePlugins().add("org.jetbrains.kotlin");
}
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(e.getDocument());
if (virtualFile != null && virtualFile.getFileType() == KotlinFileType.INSTANCE) {
KotlinPluginUpdater.Companion.getInstance().kotlinFileEdited();
}
}
});
}
use of com.intellij.openapi.editor.event.DocumentEvent in project intellij-community by JetBrains.
the class CheckRegExpForm method createUIComponents.
private void createUIComponents() {
myProject = myRegexpFile.getProject();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(myRegexpFile);
final Language language = myRegexpFile.getLanguage();
final LanguageFileType fileType;
if (language instanceof RegExpLanguage) {
fileType = RegExpLanguage.INSTANCE.getAssociatedFileType();
} else {
// for correct syntax highlighting
fileType = new RegExpFileType(language);
}
myRegExp = new EditorTextField(document, myProject, fileType);
final String sampleText = PropertiesComponent.getInstance(myProject).getValue(LAST_EDITED_REGEXP, "Sample Text");
mySampleText = new EditorTextField(sampleText, myProject, PlainTextFileType.INSTANCE) {
@Override
protected void updateBorder(@NotNull EditorEx editor) {
setupBorder(editor);
}
};
mySampleText.setOneLineMode(false);
int preferredWidth = Math.max(JBUI.scale(250), myRegExp.getPreferredSize().width);
myRegExp.setPreferredWidth(preferredWidth);
mySampleText.setPreferredWidth(preferredWidth);
myRootPanel = new JPanel(new BorderLayout()) {
Disposable disposable;
Alarm updater;
@Override
public void addNotify() {
super.addNotify();
disposable = Disposer.newDisposable();
IdeFocusManager.getGlobalInstance().requestFocus(mySampleText, true);
new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
IdeFocusManager.findInstance().requestFocus(myRegExp.getFocusTarget(), true);
}
}.registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), mySampleText);
updater = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, disposable);
DocumentAdapter documentListener = new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
update();
}
};
myRegExp.addDocumentListener(documentListener);
mySampleText.addDocumentListener(documentListener);
update();
mySampleText.selectAll();
}
public void update() {
final TransactionId transactionId = TransactionGuard.getInstance().getContextTransaction();
updater.cancelAllRequests();
if (!updater.isDisposed()) {
updater.addRequest(() -> {
final RegExpMatchResult result = isMatchingText(myRegexpFile, mySampleText.getText());
TransactionGuard.getInstance().submitTransaction(myProject, transactionId, () -> setBalloonState(result));
}, 200);
}
}
@Override
public void removeNotify() {
super.removeNotify();
Disposer.dispose(disposable);
PropertiesComponent.getInstance(myProject).setValue(LAST_EDITED_REGEXP, mySampleText.getText());
}
};
myRootPanel.setBorder(JBUI.Borders.empty(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
}
use of com.intellij.openapi.editor.event.DocumentEvent in project android by JetBrains.
the class EditLogFilterDialog method createEditorFields.
private void createEditorFields() {
myNameFieldLabel.setLabelFor(myFilterNameField);
myLogMessageField = new RegexFilterComponent(LOG_FILTER_MESSAGE_HISTORY, FILTER_HISTORY_SIZE);
myLogMessageFieldWrapper.add(myLogMessageField);
myLogMessageLabel.setLabelFor(myLogMessageField);
myTagField = new RegexFilterComponent(LOG_FILTER_TAG_HISTORY, FILTER_HISTORY_SIZE);
myTagFieldWrapper.add(myTagField);
myLogTagLabel.setLabelFor(myTagField);
myPidField = new TextFieldWithAutoCompletion<>(myProject, new TextFieldWithAutoCompletion.StringsCompletionProvider(null, null) {
@NotNull
@Override
public Collection<String> getItems(String prefix, boolean cached, CompletionParameters parameters) {
parseExistingMessagesIfNecessary();
setItems(myUsedPids);
return super.getItems(prefix, cached, parameters);
}
@Override
public int compare(String item1, String item2) {
final int pid1 = Integer.parseInt(item1);
final int pid2 = Integer.parseInt(item2);
return Comparing.compare(pid1, pid2);
}
}, true, null);
myPidFieldWrapper.add(myPidField);
myPidLabel.setLabelFor(myPidField);
myPackageNameField = new RegexFilterComponent(LOG_FILTER_PACKAGE_NAME_HISTORY, FILTER_HISTORY_SIZE);
myPackageNameFieldWrapper.add(myPackageNameField);
myPackageNameLabel.setLabelFor(myPackageNameField);
myLogLevelCombo.setModel(new EnumComboBoxModel<>(Log.LogLevel.class));
myLogLevelCombo.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value != null) {
setText(StringUtil.capitalize(((Log.LogLevel) value).getStringValue().toLowerCase()));
}
}
});
myLogLevelCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (myActiveFilter == null) {
return;
}
Log.LogLevel selectedItem = (Log.LogLevel) myLogLevelCombo.getSelectedItem();
myActiveFilter.setLogLevel(selectedItem.getStringValue());
}
});
final Key<JComponent> componentKey = new Key<>("myComponent");
myFilterNameField.getDocument().putUserData(componentKey, myFilterNameField);
myPidField.getDocument().putUserData(componentKey, myPidField);
DocumentListener l = new DocumentListener() {
@Override
public void documentChanged(DocumentEvent e) {
if (myActiveFilter == null) {
return;
}
String text = e.getDocument().getText().trim();
JComponent src = e.getDocument().getUserData(componentKey);
if (src == myPidField) {
myActiveFilter.setPid(text);
} else if (src == myFilterNameField) {
int index = myFiltersList.getSelectedIndex();
if (index != -1) {
myFiltersListModel.setElementAt(text, index);
}
myActiveFilter.setName(text);
}
}
};
myFilterNameField.getDocument().addDocumentListener(l);
myPidField.getDocument().addDocumentListener(l);
RegexFilterComponent.Listener rl = new RegexFilterComponent.Listener() {
@Override
public void filterChanged(RegexFilterComponent filter) {
if (myActiveFilter == null) {
return;
}
if (filter == myTagField) {
myActiveFilter.setLogTagPattern(filter.getFilter());
myActiveFilter.setLogTagIsRegex(filter.isRegex());
} else if (filter == myLogMessageField) {
myActiveFilter.setLogMessagePattern(filter.getFilter());
myActiveFilter.setLogMessageIsRegex(filter.isRegex());
} else if (filter == myPackageNameField) {
myActiveFilter.setPackageNamePattern(filter.getFilter());
myActiveFilter.setPackageNameIsRegex(filter.isRegex());
}
}
};
myTagField.addRegexListener(rl);
myLogMessageField.addRegexListener(rl);
myPackageNameField.addRegexListener(rl);
}
Aggregations