use of com.intellij.openapi.command.CommandAdapter in project intellij-community by JetBrains.
the class ActionTracker method ignoreCurrentDocumentChange.
void ignoreCurrentDocumentChange() {
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
if (commandProcessor.getCurrentCommand() == null)
return;
myIgnoreDocumentChanges = true;
commandProcessor.addCommandListener(new CommandAdapter() {
@Override
public void commandFinished(CommandEvent event) {
commandProcessor.removeCommandListener(this);
myIgnoreDocumentChanges = false;
}
});
}
use of com.intellij.openapi.command.CommandAdapter in project intellij-community by JetBrains.
the class TemplateState method initListeners.
private void initListeners() {
if (isDisposed())
return;
myEditorDocumentListener = new DocumentAdapter() {
@Override
public void beforeDocumentChange(DocumentEvent e) {
myDocumentChanged = true;
}
};
myLookupListener = new LookupAdapter() {
@Override
public void itemSelected(LookupEvent event) {
if (isCaretOutsideCurrentSegment(null)) {
if (isCaretInsideNextVariable()) {
nextTab();
} else {
gotoEnd(true);
}
}
}
};
LookupManager.getInstance(myProject).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (LookupManager.PROP_ACTIVE_LOOKUP.equals(evt.getPropertyName())) {
Lookup lookup = (Lookup) evt.getNewValue();
if (lookup != null) {
lookup.addLookupListener(myLookupListener);
}
}
}
}, this);
myCommandListener = new CommandAdapter() {
boolean started = false;
@Override
public void commandStarted(CommandEvent event) {
myDocumentChangesTerminateTemplate = isCaretOutsideCurrentSegment(event.getCommandName());
started = true;
}
@Override
public void beforeCommandFinished(CommandEvent event) {
if (started && !isDisposed()) {
Runnable runnable = () -> afterChangedUpdate();
final LookupImpl lookup = myEditor != null ? (LookupImpl) LookupManager.getActiveLookup(myEditor) : null;
if (lookup != null) {
lookup.performGuardedChange(runnable);
} else {
runnable.run();
}
}
}
};
myCaretListener = new CaretAdapter() {
@Override
public void caretAdded(CaretEvent e) {
if (isMultiCaretMode()) {
finishTemplateEditing();
}
}
@Override
public void caretRemoved(CaretEvent e) {
if (isMultiCaretMode()) {
finishTemplateEditing();
}
}
};
if (myEditor != null) {
myEditor.getCaretModel().addCaretListener(myCaretListener);
}
myDocument.addDocumentListener(myEditorDocumentListener, this);
CommandProcessor.getInstance().addCommandListener(myCommandListener, this);
}
Aggregations