Search in sources :

Example 41 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class ConfigurableEditor method select.

final ActionCallback select(final Configurable configurable) {
    assert !myDisposed : "Already disposed";
    ActionCallback callback = myCardPanel.select(configurable, false);
    callback.doWhenDone(() -> {
        myConfigurable = configurable;
        updateCurrent(configurable, false);
    });
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 42 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class OptionsEditorContext method fireSelected.

ActionCallback fireSelected(@Nullable final Configurable configurable, @NotNull OptionsEditorColleague requestor) {
    if (myCurrentConfigurable == configurable)
        return ActionCallback.REJECTED;
    final Configurable old = myCurrentConfigurable;
    myCurrentConfigurable = configurable;
    return notify(new ColleagueAction() {

        public ActionCallback process(final OptionsEditorColleague colleague) {
            return colleague.onSelected(configurable, old);
        }
    }, requestor);
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) Configurable(com.intellij.openapi.options.Configurable)

Example 43 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class SettingsFilter method update.

private ActionCallback update(@NotNull DocumentEvent.EventType type, boolean adjustSelection, boolean now) {
    if (myUpdateRejected) {
        return ActionCallback.REJECTED;
    }
    String text = getFilterText();
    if (text.isEmpty()) {
        myContext.setHoldingFilter(false);
        myFiltered = null;
    } else {
        myContext.setHoldingFilter(true);
        myHits = myRegistrar.getConfigurables(myGroups, type, myFiltered, text, myProject);
        myFiltered = myHits.getAll();
    }
    mySearch.getTextEditor().setBackground(myFiltered != null && myFiltered.isEmpty() ? LightColors.RED : UIUtil.getTextFieldBackground());
    Configurable current = myContext.getCurrentConfigurable();
    boolean shouldMoveSelection = myHits == null || (!myHits.getNameFullHits().contains(current) && !myHits.getContentHits().contains(current));
    if (shouldMoveSelection && type != DocumentEvent.EventType.INSERT && (myFiltered == null || myFiltered.contains(current))) {
        shouldMoveSelection = false;
    }
    Configurable candidate = adjustSelection ? current : null;
    if (shouldMoveSelection && myHits != null) {
        if (!myHits.getNameHits().isEmpty()) {
            candidate = findConfigurable(myHits.getNameHits(), myHits.getNameFullHits());
        } else if (!myHits.getContentHits().isEmpty()) {
            candidate = findConfigurable(myHits.getContentHits(), null);
        }
    }
    updateSpotlight(false);
    if ((myFiltered == null || !myFiltered.isEmpty()) && candidate == null && myLastSelected != null) {
        candidate = myLastSelected;
        myLastSelected = null;
    }
    if (candidate == null && current != null) {
        myLastSelected = current;
    }
    SimpleNode node = !adjustSelection ? null : findNode(candidate);
    ActionCallback callback = fireUpdate(node, adjustSelection, now);
    myDocumentWasChanged = true;
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 44 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class UpdaterTreeState method processAjusted.

private ActionCallback processAjusted(final Map<Object, Condition> adjusted, final Set<Object> originallySelected) {
    final ActionCallback result = new ActionCallback();
    final Set<Object> allSelected = myUi.getSelectedElements();
    Set<Object> toSelect = new HashSet<>();
    for (Map.Entry<Object, Condition> entry : adjusted.entrySet()) {
        if (entry.getValue().value(entry.getKey()))
            continue;
        for (final Object eachSelected : allSelected) {
            if (isParentOrSame(entry.getKey(), eachSelected))
                continue;
            toSelect.add(entry.getKey());
        }
        if (allSelected.isEmpty()) {
            toSelect.add(entry.getKey());
        }
    }
    final Object[] newSelection = ArrayUtil.toObjectArray(toSelect);
    if (newSelection.length > 0) {
        myUi._select(newSelection, new TreeRunnable("UpdaterTreeState.processAjusted") {

            @Override
            public void perform() {
                final Set<Object> hangByParent = new HashSet<>();
                processUnsuccessfulSelections(newSelection, o -> {
                    if (myUi.isInStructure(o) && !adjusted.get(o).value(o)) {
                        hangByParent.add(o);
                    } else {
                        addAdjustedSelection(o, adjusted.get(o), null);
                    }
                    return null;
                }, originallySelected);
                processHangByParent(hangByParent).notify(result);
            }
        }, false, true, true);
    } else {
        result.setDone();
    }
    return result;
}
Also used : Condition(com.intellij.openapi.util.Condition) java.util(java.util) ArrayUtil(com.intellij.util.ArrayUtil) TreePath(javax.swing.tree.TreePath) ActionCallback(com.intellij.openapi.util.ActionCallback) NonNls(org.jetbrains.annotations.NonNls) ContainerUtil(com.intellij.util.containers.ContainerUtil) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Nullable(org.jetbrains.annotations.Nullable) Function(com.intellij.util.Function) Conditions(com.intellij.openapi.util.Conditions) NotNull(org.jetbrains.annotations.NotNull) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 45 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class AbstractTreeBuilder method queueUpdateFrom.

@NotNull
public ActionCallback queueUpdateFrom(final Object element, final boolean forceResort, final boolean updateStructure) {
    if (getUi() == null)
        return ActionCallback.REJECTED;
    final ActionCallback result = new ActionCallback();
    getUi().invokeLaterIfNeeded(false, new TreeRunnable("AbstractTreeBuilder.queueUpdateFrom") {

        @Override
        public void perform() {
            if (updateStructure && forceResort) {
                getUi().incComparatorStamp();
            }
            getUi().queueUpdate(element, updateStructure).notify(result);
        }
    });
    return result;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ActionCallback (com.intellij.openapi.util.ActionCallback)70 NotNull (org.jetbrains.annotations.NotNull)16 IOException (java.io.IOException)5 Notification (com.intellij.notification.Notification)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 ProjectView (com.intellij.ide.projectView.ProjectView)3 Configurable (com.intellij.openapi.options.Configurable)3 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)3 AsyncResult (com.intellij.openapi.util.AsyncResult)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 DocumentInfo (com.intellij.flex.uiDesigner.DocumentFactoryManager.DocumentInfo)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 Project (com.intellij.openapi.project.Project)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)2 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)2 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)2 TypingTarget (com.intellij.openapi.ui.TypingTarget)2 FocusCommand (com.intellij.openapi.wm.FocusCommand)2