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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations