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