use of com.intellij.openapi.editor.event.DocumentAdapter in project intellij-community by JetBrains.
the class GrChangeSignatureDialog method createAdditionalPanels.
@NotNull
@Override
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( //todo propagate parameters
RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, PlatformIcons.NEW_EXCEPTION) {
@Override
public void actionPerformed(AnActionEvent e) {
final Ref<JavaCallerChooser> chooser = new Ref<JavaCallerChooser>();
Consumer<Set<PsiMethod>> callback = new Consumer<Set<PsiMethod>>() {
@Override
public void consume(Set<PsiMethod> 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).createPanel();
//.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.DocumentAdapter in project kotlin by JetBrains.
the class MoveKotlinTopLevelDeclarationsDialog method createPackageChooser.
private ReferenceEditorComboWithBrowseButton createPackageChooser() {
ReferenceEditorComboWithBrowseButton packageChooser = new PackageNameReferenceEditorCombo("", myProject, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"));
Document document = packageChooser.getChildComponent().getDocument();
document.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
validateButtons();
}
});
return packageChooser;
}
use of com.intellij.openapi.editor.event.DocumentAdapter 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.DocumentAdapter in project intellij-community by JetBrains.
the class GeneratedSourceFileChangeTrackerImpl method projectOpened.
@Override
public void projectOpened() {
final Update check = new Update("check for changes in generated files") {
@Override
public void run() {
checkFiles();
}
};
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
VirtualFile file = myDocumentManager.getFile(e.getDocument());
if (file != null) {
myFilesToCheck.add(file);
myCheckingQueue.queue(check);
}
}
}, myProject);
MessageBusConnection connection = myProject.getMessageBus().connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(@NotNull VirtualFile file, @NotNull Document document) {
myFilesToCheck.remove(file);
if (myEditedGeneratedFiles.remove(file)) {
myEditorNotifications.updateNotifications(file);
}
}
});
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
@Override
public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
myEditedGeneratedFiles.remove(file);
}
});
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
@Override
public void rootsChanged(ModuleRootEvent event) {
myFilesToCheck.addAll(myEditedGeneratedFiles);
myEditedGeneratedFiles.clear();
myCheckingQueue.queue(check);
}
});
myCheckingQueue.activate();
}
use of com.intellij.openapi.editor.event.DocumentAdapter in project intellij-community by JetBrains.
the class LiveTemplateSettingsEditor method createComponents.
private void createComponents(boolean allowNoContexts) {
JPanel panel = new JPanel(new GridBagLayout());
GridBag gb = new GridBag().setDefaultInsets(4, 4, 4, 4).setDefaultWeightY(1).setDefaultFill(GridBagConstraints.BOTH);
JPanel editorPanel = new JPanel(new BorderLayout(4, 4));
editorPanel.setPreferredSize(JBUI.size(250, 100));
editorPanel.setMinimumSize(editorPanel.getPreferredSize());
editorPanel.add(myTemplateEditor.getComponent(), BorderLayout.CENTER);
JLabel templateTextLabel = new JLabel(CodeInsightBundle.message("dialog.edit.template.template.text.title"));
templateTextLabel.setLabelFor(myTemplateEditor.getContentComponent());
editorPanel.add(templateTextLabel, BorderLayout.NORTH);
editorPanel.setFocusable(false);
panel.add(editorPanel, gb.nextLine().next().weighty(1).weightx(1).coverColumn(2));
myEditVariablesButton = new JButton(CodeInsightBundle.message("dialog.edit.template.button.edit.variables"));
myEditVariablesButton.setDefaultCapable(false);
myEditVariablesButton.setMaximumSize(myEditVariablesButton.getPreferredSize());
panel.add(myEditVariablesButton, gb.next().weighty(0));
myTemplateOptionsPanel = new JPanel(new BorderLayout());
myTemplateOptionsPanel.add(createTemplateOptionsPanel());
panel.add(myTemplateOptionsPanel, gb.nextLine().next().next().coverColumn(2).weighty(1));
panel.add(createShortContextPanel(allowNoContexts), gb.nextLine().next().weighty(0).fillCellNone().anchor(GridBagConstraints.WEST));
myTemplateEditor.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
validateEditVariablesButton();
myTemplate.setString(myTemplateEditor.getDocument().getText());
applyVariables(updateVariablesByTemplateText());
myNodeChanged.run();
}
});
myEditVariablesButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
editVariables();
}
});
add(createNorthPanel(), BorderLayout.NORTH);
add(panel, BorderLayout.CENTER);
}
Aggregations