use of com.intellij.openapi.command.CommandEvent in project intellij-community by JetBrains.
the class CoreCommandProcessor method fireCommandStarted.
private void fireCommandStarted() {
ApplicationManager.getApplication().assertIsDispatchThread();
CommandDescriptor currentCommand = myCurrentCommand;
CommandEvent event = new CommandEvent(this, currentCommand.myCommand, currentCommand.myName, currentCommand.myGroupId, currentCommand.myProject, currentCommand.myUndoConfirmationPolicy, currentCommand.myShouldRecordActionForActiveDocument, currentCommand.myDocument);
for (CommandListener listener : myListeners) {
try {
listener.commandStarted(event);
} catch (Throwable e) {
CommandLog.LOG.error(e);
}
}
}
use of com.intellij.openapi.command.CommandEvent 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.CommandEvent 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);
}
use of com.intellij.openapi.command.CommandEvent in project intellij-community by JetBrains.
the class CoreCommandProcessor method fireCommandFinished.
protected void fireCommandFinished() {
ApplicationManager.getApplication().assertIsDispatchThread();
CommandDescriptor currentCommand = myCurrentCommand;
CommandEvent event = new CommandEvent(this, currentCommand.myCommand, currentCommand.myName, currentCommand.myGroupId, currentCommand.myProject, currentCommand.myUndoConfirmationPolicy, currentCommand.myShouldRecordActionForActiveDocument, currentCommand.myDocument);
try {
for (CommandListener listener : myListeners) {
try {
listener.beforeCommandFinished(event);
} catch (Throwable e) {
CommandLog.LOG.error(e);
}
}
} finally {
myCurrentCommand = null;
for (CommandListener listener : myListeners) {
try {
listener.commandFinished(event);
} catch (Throwable e) {
CommandLog.LOG.error(e);
}
}
}
}
Aggregations