use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class ProjectStructureConfigurable method navigateTo.
@Override
public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
final Configurable toSelect = (Configurable) place.getPath(CATEGORY);
JComponent detailsContent = myDetails.getTargetComponent();
if (mySelectedConfigurable != toSelect) {
if (mySelectedConfigurable instanceof BaseStructureConfigurable) {
((BaseStructureConfigurable) mySelectedConfigurable).onStructureUnselected();
}
saveSideProportion();
removeSelected();
if (toSelect != null) {
detailsContent = toSelect.createComponent();
myDetails.setContent(detailsContent);
}
mySelectedConfigurable = toSelect;
if (mySelectedConfigurable != null) {
myUiState.lastEditedConfigurable = mySelectedConfigurable.getDisplayName();
}
if (toSelect instanceof MasterDetailsComponent) {
final MasterDetailsComponent masterDetails = (MasterDetailsComponent) toSelect;
if (myUiState.sideProportion > 0) {
masterDetails.getSplitter().setProportion(myUiState.sideProportion);
}
masterDetails.setHistory(myHistory);
}
if (toSelect instanceof DetailsComponent.Facade) {
((DetailsComponent.Facade) toSelect).getDetailsComponent().setBannerMinHeight(myToolbarComponent.getPreferredSize().height);
}
if (toSelect instanceof BaseStructureConfigurable) {
((BaseStructureConfigurable) toSelect).onStructureSelected();
}
}
if (detailsContent != null) {
JComponent toFocus = IdeFocusTraversalPolicy.getPreferredFocusedComponent(detailsContent);
if (toFocus == null) {
toFocus = detailsContent;
}
if (requestFocus) {
myToFocus = toFocus;
UIUtil.requestFocus(toFocus);
}
}
final ActionCallback result = new ActionCallback();
Place.goFurther(toSelect, place, requestFocus).notifyWhenDone(result);
myDetails.revalidate();
myDetails.repaint();
if (toSelect != null) {
mySidePanel.select(createPlaceFor(toSelect));
}
if (!myHistory.isNavigatingNow() && mySelectedConfigurable != null) {
myHistory.pushQueryPlace();
}
return result;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class EditorTabbedContainer method removeTabAt.
public ActionCallback removeTabAt(final int componentIndex, int indexToSelect, boolean transferFocus) {
TabInfo toSelect = indexToSelect >= 0 && indexToSelect < myTabs.getTabCount() ? myTabs.getTabAt(indexToSelect) : null;
final TabInfo info = myTabs.getTabAt(componentIndex);
// removing hidden tab happens on end of drag-out, we've already selected the correct tab for this case in dragOutStarted
if (info.isHidden() || !myProject.isOpen()) {
toSelect = null;
}
final ActionCallback callback = myTabs.removeTab(info, toSelect, transferFocus);
return myProject.isOpen() ? callback : ActionCallback.DONE;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class ProjectViewSelectInGroupTarget method selectIn.
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
ProjectView projectView = ProjectView.getInstance(context.getProject());
Collection<SelectInTarget> targets = projectView.getSelectInTargets();
Collection<SelectInTarget> targetsToCheck = new LinkedHashSet<>();
String currentId = projectView.getCurrentViewId();
for (SelectInTarget projectViewTarget : targets) {
if (Comparing.equal(currentId, projectViewTarget.getMinorViewId())) {
targetsToCheck.add(projectViewTarget);
break;
}
}
targetsToCheck.addAll(targets);
for (final SelectInTarget target : targetsToCheck) {
if (target.canSelect(context)) {
if (requestFocus) {
IdeFocusManager.getInstance(context.getProject()).requestFocus(new FocusCommand() {
@NotNull
@Override
public ActionCallback run() {
target.selectIn(context, requestFocus);
return ActionCallback.DONE;
}
}, true);
} else {
target.selectIn(context, requestFocus);
}
break;
}
}
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class ProjectViewSelectInTarget method select.
@NotNull
public static ActionCallback select(@NotNull Project project, final Object toSelect, @Nullable final String viewId, @Nullable final String subviewId, final VirtualFile virtualFile, final boolean requestFocus) {
final ActionCallback result = new ActionCallback();
final ProjectView projectView = ProjectView.getInstance(project);
if (ApplicationManager.getApplication().isUnitTestMode()) {
AbstractProjectViewPane pane = projectView.getProjectViewPaneById(ProjectViewPane.ID);
pane.select(toSelect, virtualFile, requestFocus);
return result;
}
ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
final ToolWindow projectViewToolWindow = windowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
final Runnable runnable = () -> {
Runnable r = () -> projectView.selectCB(toSelect, virtualFile, requestFocus).notify(result);
projectView.changeViewCB(ObjectUtils.chooseNotNull(viewId, ProjectViewPane.ID), subviewId).doWhenProcessed(r);
};
if (requestFocus) {
projectViewToolWindow.activate(runnable, true);
} else {
projectViewToolWindow.show(runnable);
}
return result;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class NavBarListener method keyPressed.
@Override
public void keyPressed(final KeyEvent e) {
if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) {
if (!Character.isLetter(e.getKeyChar())) {
return;
}
final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject());
final ActionCallback firstCharTyped = new ActionCallback();
focusManager.typeAheadUntil(firstCharTyped);
myPanel.moveDown();
//noinspection SSBasedInspection
SwingUtilities.invokeLater(() -> {
try {
final Robot robot = new Robot();
final boolean shiftOn = e.isShiftDown();
final int code = e.getKeyCode();
if (shiftOn) {
robot.keyPress(KeyEvent.VK_SHIFT);
}
robot.keyPress(code);
robot.keyRelease(code);
//don't release Shift
firstCharTyped.setDone();
} catch (AWTException ignored) {
}
});
}
}
Aggregations