Search in sources :

Example 11 with IdeFrameImpl

use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.

the class TogglePresentationModeAction method tweakFrameFullScreen.

private static ActionCallback tweakFrameFullScreen(Project project, boolean inPresentation) {
    Window window = IdeFrameImpl.getActiveFrame();
    if (window instanceof IdeFrameImpl) {
        IdeFrameImpl frame = (IdeFrameImpl) window;
        PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
        if (inPresentation) {
            propertiesComponent.setValue("full.screen.before.presentation.mode", String.valueOf(frame.isInFullScreen()));
            return frame.toggleFullScreen(true);
        } else {
            if (frame.isInFullScreen()) {
                final String value = propertiesComponent.getValue("full.screen.before.presentation.mode");
                return frame.toggleFullScreen("true".equalsIgnoreCase(value));
            }
        }
    }
    return ActionCallback.DONE;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 12 with IdeFrameImpl

use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.

the class ToolWindowsWidget method mouseEntered.

public void mouseEntered() {
    final boolean active = ApplicationManager.getApplication().isActive();
    if (!active) {
        return;
    }
    if (myAlarm.getActiveRequestCount() == 0) {
        myAlarm.addRequest(() -> {
            final IdeFrameImpl frame = UIUtil.getParentOfType(IdeFrameImpl.class, this);
            if (frame == null)
                return;
            List<ToolWindow> toolWindows = new ArrayList<>();
            final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(frame.getProject());
            for (String id : toolWindowManager.getToolWindowIds()) {
                final ToolWindow tw = toolWindowManager.getToolWindow(id);
                if (tw.isAvailable() && tw.isShowStripeButton()) {
                    toolWindows.add(tw);
                }
            }
            Collections.sort(toolWindows, (o1, o2) -> StringUtil.naturalCompare(o1.getStripeTitle(), o2.getStripeTitle()));
            final JBList list = new JBList(toolWindows);
            list.setCellRenderer(new ListCellRenderer() {

                final JBLabel label = new JBLabel();

                @Override
                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                    final ToolWindow toolWindow = (ToolWindow) value;
                    label.setText(toolWindow.getStripeTitle());
                    label.setIcon(toolWindow.getIcon());
                    label.setBorder(JBUI.Borders.empty(4, 10));
                    label.setForeground(UIUtil.getListForeground(isSelected));
                    label.setBackground(UIUtil.getListBackground(isSelected));
                    final JPanel panel = new JPanel(new BorderLayout());
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(UIUtil.getListBackground(isSelected));
                    return panel;
                }
            });
            final Dimension size = list.getPreferredSize();
            final JComponent c = this;
            final Insets padding = UIUtil.getListViewportPadding();
            final RelativePoint point = new RelativePoint(c, new Point(-4, -padding.top - padding.bottom - 4 - size.height + (SystemInfo.isMac ? 2 : 0)));
            if (popup != null && popup.isVisible()) {
                return;
            }
            list.setSelectedIndex(list.getItemsCount() - 1);
            PopupChooserBuilder builder = JBPopupFactory.getInstance().createListPopupBuilder(list);
            popup = builder.setAutoselectOnMouseMove(true).setRequestFocus(false).setItemChoosenCallback(() -> {
                if (popup != null)
                    popup.closeOk(null);
                final Object value = list.getSelectedValue();
                if (value instanceof ToolWindow) {
                    ((ToolWindow) value).activate(null, true, true);
                }
            }).createPopup();
            // override default of 15 set when createPopup() is called
            list.setVisibleRowCount(30);
            popup.show(point);
        }, 300);
    }
}
Also used : IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) ArrayList(java.util.ArrayList) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBLabel(com.intellij.ui.components.JBLabel) JBList(com.intellij.ui.components.JBList) PopupChooserBuilder(com.intellij.openapi.ui.popup.PopupChooserBuilder)

Example 13 with IdeFrameImpl

use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.

the class PopupFactoryImpl method guessBestPopupLocation.

@NotNull
@Override
public RelativePoint guessBestPopupLocation(@NotNull DataContext dataContext) {
    Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
    JComponent focusOwner = component instanceof JComponent ? (JComponent) component : null;
    if (focusOwner == null) {
        Project project = CommonDataKeys.PROJECT.getData(dataContext);
        IdeFrameImpl frame = project == null ? null : ((WindowManagerEx) WindowManager.getInstance()).getFrame(project);
        focusOwner = frame == null ? null : frame.getRootPane();
        if (focusOwner == null) {
            throw new IllegalArgumentException("focusOwner cannot be null");
        }
    }
    final Point point = PlatformDataKeys.CONTEXT_MENU_POINT.getData(dataContext);
    if (point != null) {
        return new RelativePoint(focusOwner, point);
    }
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (editor != null && focusOwner == editor.getContentComponent()) {
        return guessBestPopupLocation(editor);
    } else {
        return guessBestPopupLocation(focusOwner);
    }
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with IdeFrameImpl

use of com.intellij.openapi.wm.impl.IdeFrameImpl in project intellij-community by JetBrains.

the class ActivateNavigationBarAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null && UISettings.getInstance().getShowNavigationBar()) {
        final IdeFrameImpl frame = WindowManagerEx.getInstanceEx().getFrame(project);
        final IdeRootPane ideRootPane = (IdeRootPane) frame.getRootPane();
        JComponent component = ideRootPane.findByName(NavBarRootPaneExtension.NAV_BAR).getComponent();
        if (component instanceof NavBarPanel) {
            final NavBarPanel navBarPanel = (NavBarPanel) component;
            navBarPanel.rebuildAndSelectTail(true);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrameImpl(com.intellij.openapi.wm.impl.IdeFrameImpl) IdeRootPane(com.intellij.openapi.wm.impl.IdeRootPane)

Aggregations

IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)14 Project (com.intellij.openapi.project.Project)5 RelativePoint (com.intellij.ui.awt.RelativePoint)4 IdeFrame (com.intellij.openapi.wm.IdeFrame)3 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 ComponentPopupBuilder (com.intellij.openapi.ui.popup.ComponentPopupBuilder)2 JBPopup (com.intellij.openapi.ui.popup.JBPopup)2 FloatingDecorator (com.intellij.openapi.wm.impl.FloatingDecorator)2 File (java.io.File)2 Robot (org.fest.swing.core.Robot)2 WindowFinder.findFrame (org.fest.swing.finder.WindowFinder.findFrame)2 Condition (org.fest.swing.timing.Condition)2 NotNull (org.jetbrains.annotations.NotNull)2 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 Editor (com.intellij.openapi.editor.Editor)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1 DumbService (com.intellij.openapi.project.DumbService)1 PopupChooserBuilder (com.intellij.openapi.ui.popup.PopupChooserBuilder)1