Search in sources :

Example 1 with AbstractTreeUpdater

use of com.intellij.ide.util.treeView.AbstractTreeUpdater in project intellij-community by JetBrains.

the class ProjectViewPsiTreeChangeListener method propertyChanged.

@Override
public void propertyChanged(@NotNull PsiTreeChangeEvent event) {
    String propertyName = event.getPropertyName();
    PsiElement element = event.getElement();
    DefaultMutableTreeNode rootNode = getRootNode();
    AbstractTreeUpdater updater = getUpdater();
    if (propertyName.equals(PsiTreeChangeEvent.PROP_ROOTS)) {
        updater.addSubtreeToUpdate(rootNode);
    } else if (propertyName.equals(PsiTreeChangeEvent.PROP_WRITABLE)) {
        if (!updater.addSubtreeToUpdateByElement(element) && element instanceof PsiFile) {
            updater.addSubtreeToUpdateByElement(((PsiFile) element).getContainingDirectory());
        }
    } else if (propertyName.equals(PsiTreeChangeEvent.PROP_FILE_NAME) || propertyName.equals(PsiTreeChangeEvent.PROP_DIRECTORY_NAME)) {
        if (element instanceof PsiDirectory && isFlattenPackages()) {
            updater.addSubtreeToUpdate(rootNode);
            return;
        }
        final PsiElement parent = element.getParent();
        if (parent == null || !updater.addSubtreeToUpdateByElement(parent)) {
            updater.addSubtreeToUpdateByElement(element);
        }
    } else if (propertyName.equals(PsiTreeChangeEvent.PROP_FILE_TYPES)) {
        updater.addSubtreeToUpdate(rootNode);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractTreeUpdater(com.intellij.ide.util.treeView.AbstractTreeUpdater)

Example 2 with AbstractTreeUpdater

use of com.intellij.ide.util.treeView.AbstractTreeUpdater in project intellij-community by JetBrains.

the class BaseProjectTreeBuilder method _select.

@NotNull
private ActionCallback _select(final Object element, final VirtualFile file, final boolean requestFocus, final Condition<AbstractTreeNode> nonStopCondition) {
    AbstractTreeUpdater updater = getUpdater();
    if (updater == null)
        return ActionCallback.REJECTED;
    final ActionCallback result = new ActionCallback();
    final FocusRequestor requestor = IdeFocusManager.getInstance(myProject).getFurtherRequestor();
    UiActivityMonitor.getInstance().addActivity(myProject, new UiActivity.AsyncBgOperation("projectViewSelect"), updater.getModalityState());
    batch(indicator -> {
        _select(element, file, requestFocus, nonStopCondition, result, indicator, null, requestor, false);
        UiActivityMonitor.getInstance().removeActivity(myProject, new UiActivity.AsyncBgOperation("projectViewSelect"));
    });
    return result;
}
Also used : FocusRequestor(com.intellij.openapi.wm.FocusRequestor) AbstractTreeUpdater(com.intellij.ide.util.treeView.AbstractTreeUpdater) UiActivity(com.intellij.ide.UiActivity) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

AbstractTreeUpdater (com.intellij.ide.util.treeView.AbstractTreeUpdater)2 UiActivity (com.intellij.ide.UiActivity)1 FocusRequestor (com.intellij.openapi.wm.FocusRequestor)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 NotNull (org.jetbrains.annotations.NotNull)1