Search in sources :

Example 1 with TreeChangeEventImpl

use of com.intellij.pom.tree.events.impl.TreeChangeEventImpl in project intellij-community by JetBrains.

the class ChangeUtil method prepareAndRunChangeAction.

public static void prepareAndRunChangeAction(final ChangeAction action, final TreeElement changedElement) {
    final FileElement changedFile = TreeUtil.getFileElement(changedElement);
    final PsiManager manager = changedFile.getManager();
    final PomModel model = PomManager.getModel(manager.getProject());
    final TreeAspect treeAspect = model.getModelAspect(TreeAspect.class);
    model.runTransaction(new PomTransactionBase(changedElement.getPsi(), treeAspect) {

        @Override
        public PomModelEvent runInner() {
            final PomModelEvent event = new PomModelEvent(model);
            final TreeChangeEvent destinationTreeChange = new TreeChangeEventImpl(treeAspect, changedFile);
            event.registerChangeSet(treeAspect, destinationTreeChange);
            action.makeChange(destinationTreeChange);
            changedElement.clearCaches();
            if (changedElement instanceof CompositeElement) {
                ((CompositeElement) changedElement).subtreeChanged();
            }
            return event;
        }
    });
}
Also used : TreeAspect(com.intellij.pom.tree.TreeAspect) TreeChangeEvent(com.intellij.pom.tree.events.TreeChangeEvent) TreeChangeEventImpl(com.intellij.pom.tree.events.impl.TreeChangeEventImpl) PsiManager(com.intellij.psi.PsiManager) PomModel(com.intellij.pom.PomModel) PomTransactionBase(com.intellij.pom.impl.PomTransactionBase) PomModelEvent(com.intellij.pom.event.PomModelEvent)

Aggregations

PomModel (com.intellij.pom.PomModel)1 PomModelEvent (com.intellij.pom.event.PomModelEvent)1 PomTransactionBase (com.intellij.pom.impl.PomTransactionBase)1 TreeAspect (com.intellij.pom.tree.TreeAspect)1 TreeChangeEvent (com.intellij.pom.tree.events.TreeChangeEvent)1 TreeChangeEventImpl (com.intellij.pom.tree.events.impl.TreeChangeEventImpl)1 PsiManager (com.intellij.psi.PsiManager)1