Search in sources :

Example 61 with ActionCallback

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;
}
Also used : DetailsComponent(com.intellij.openapi.ui.DetailsComponent) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) ActionCallback(com.intellij.openapi.util.ActionCallback) MasterDetailsComponent(com.intellij.openapi.ui.MasterDetailsComponent) Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable) ArtifactsStructureConfigurable(com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable)

Example 62 with ActionCallback

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;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 63 with ActionCallback

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;
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ActionCallback(com.intellij.openapi.util.ActionCallback) CompositeSelectInTarget(com.intellij.ide.CompositeSelectInTarget) SelectInTarget(com.intellij.ide.SelectInTarget) ProjectView(com.intellij.ide.projectView.ProjectView) FocusCommand(com.intellij.openapi.wm.FocusCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 64 with ActionCallback

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;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ActionCallback(com.intellij.openapi.util.ActionCallback) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ProjectView(com.intellij.ide.projectView.ProjectView) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane) NotNull(org.jetbrains.annotations.NotNull)

Example 65 with ActionCallback

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) {
            }
        });
    }
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager)

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