use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class WindowManagerImpl method getStatusBar.
@Override
public StatusBar getStatusBar(@NotNull Component c, @Nullable Project project) {
Component parent = UIUtil.findUltimateParent(c);
if (parent instanceof IdeFrame) {
return ((IdeFrame) parent).getStatusBar().findChild(c);
}
IdeFrame frame = findFrameFor(project);
if (frame != null) {
return frame.getStatusBar().findChild(c);
}
assert false : "Cannot find status bar for " + c;
return null;
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class PaintersHelper method newWallpaperPainter.
private static AbstractPainter newWallpaperPainter(@NotNull final String propertyName, @NotNull final JComponent rootComponent) {
return new ImagePainter() {
Image image;
float alpha;
Insets insets;
Fill fillType;
Place place;
String current;
@Override
public boolean needsRepaint() {
return ensureImageLoaded();
}
@Override
public void executePaint(Component component, Graphics2D g) {
// covered by needsRepaint()
if (image == null)
return;
executePaint(g, component, image, fillType, place, alpha, insets);
}
boolean ensureImageLoaded() {
IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, rootComponent);
Project project = frame == null ? null : frame.getProject();
String value = getBackgroundSpec(project, propertyName);
if (!Comparing.equal(value, current)) {
current = value;
loadImageAsync(value);
// keep the current image for a while
}
return image != null;
}
private void resetImage(String value, Image newImage, float newAlpha, Fill newFill, Place newPlace) {
if (!Comparing.equal(current, value))
return;
boolean prevOk = image != null;
clearImages(-1);
image = newImage;
insets = JBUI.emptyInsets();
alpha = newAlpha;
fillType = newFill;
place = newPlace;
boolean newOk = newImage != null;
if (prevOk || newOk) {
ModalityState modalityState = ModalityState.stateForComponent(rootComponent);
if (modalityState.dominates(ModalityState.NON_MODAL)) {
UIUtil.getActiveWindow().repaint();
} else {
IdeBackgroundUtil.repaintAllWindows();
}
}
}
private void loadImageAsync(final String propertyValue) {
String[] parts = (propertyValue != null ? propertyValue : propertyName + ".png").split(",");
final float newAlpha = Math.abs(Math.min(StringUtil.parseInt(parts.length > 1 ? parts[1] : "", 10) / 100f, 1f));
final Fill newFillType = StringUtil.parseEnum(parts.length > 2 ? parts[2].toUpperCase(Locale.ENGLISH) : "", Fill.SCALE, Fill.class);
final Place newPlace = StringUtil.parseEnum(parts.length > 3 ? parts[3].toUpperCase(Locale.ENGLISH) : "", Place.CENTER, Place.class);
String filePath = parts[0];
if (StringUtil.isEmpty(filePath)) {
resetImage(propertyValue, null, newAlpha, newFillType, newPlace);
return;
}
try {
URL url = filePath.contains("://") ? new URL(filePath) : (FileUtil.isAbsolutePlatformIndependent(filePath) ? new File(filePath) : new File(PathManager.getConfigPath(), filePath)).toURI().toURL();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
final Image m = ImageLoader.loadFromUrl(url);
ModalityState modalityState = ModalityState.stateForComponent(rootComponent);
ApplicationManager.getApplication().invokeLater(() -> resetImage(propertyValue, m, newAlpha, newFillType, newPlace), modalityState);
});
} catch (Exception e) {
resetImage(propertyValue, null, newAlpha, newFillType, newPlace);
}
}
};
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class IdeFrameImpl method updateBorder.
private void updateBorder() {
int state = getExtendedState();
if (!WindowManager.getInstance().isFullScreenSupportedInCurrentOS() || !SystemInfo.isWindows || myRootPane == null) {
return;
}
myRootPane.setBorder(null);
boolean isNotClassic = Boolean.parseBoolean(String.valueOf(Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive")));
if (isNotClassic && (state & MAXIMIZED_BOTH) != 0) {
IdeFrame[] projectFrames = WindowManager.getInstance().getAllProjectFrames();
GraphicsDevice device = ScreenUtil.getScreenDevice(getBounds());
for (IdeFrame frame : projectFrames) {
if (frame == this)
continue;
if (((IdeFrameImpl) frame).isInFullScreen() && ScreenUtil.getScreenDevice(((IdeFrameImpl) frame).getBounds()) == device) {
Insets insets = ScreenUtil.getScreenInsets(device.getDefaultConfiguration());
int mask = SideBorder.NONE;
if (insets.top != 0)
mask |= SideBorder.TOP;
if (insets.left != 0)
mask |= SideBorder.LEFT;
if (insets.bottom != 0)
mask |= SideBorder.BOTTOM;
if (insets.right != 0)
mask |= SideBorder.RIGHT;
myRootPane.setBorder(new SideBorder(JBColor.BLACK, mask, 3));
break;
}
}
}
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class DataManagerImpl method getFocusedComponent.
@Nullable
private Component getFocusedComponent() {
if (myWindowManager == null) {
return null;
}
Window activeWindow = myWindowManager.getMostRecentFocusedWindow();
if (activeWindow == null) {
activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
if (activeWindow == null) {
activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
if (activeWindow == null)
return null;
}
}
if (Registry.is("actionSystem.noContextComponentWhileFocusTransfer")) {
IdeFocusManager fm = IdeFocusManager.findInstanceByComponent(activeWindow);
if (fm.isFocusBeingTransferred()) {
return null;
}
}
// whereas we want to be able to type in other frames as well.
if (activeWindow instanceof FloatingDecorator) {
IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
boolean toolWindowIsNotFocused = myWindowManager.getFocusedComponent(activeWindow) == null;
if (toolWindowIsNotFocused && lastFocusedWindow != null) {
activeWindow = lastFocusedWindow;
}
}
// try to find first parent window that has focus
Window window = activeWindow;
Component focusedComponent = null;
while (window != null) {
focusedComponent = myWindowManager.getFocusedComponent(window);
if (focusedComponent != null) {
break;
}
window = window.getOwner();
}
if (focusedComponent == null) {
focusedComponent = activeWindow;
}
return focusedComponent;
}
use of com.intellij.openapi.wm.IdeFrame in project intellij-community by JetBrains.
the class ShowRunningListAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getProject();
if (project == null || project.isDisposed())
return;
final Ref<Pair<? extends JComponent, String>> stateRef = new Ref<>();
final Ref<Balloon> balloonRef = new Ref<>();
final Timer timer = UIUtil.createNamedTimer("runningLists", 250);
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
Balloon balloon = balloonRef.get();
if (project.isDisposed() || (balloon != null && balloon.isDisposed())) {
timer.stop();
return;
}
ArrayList<Project> projects = new ArrayList<>(Arrays.asList(ProjectManager.getInstance().getOpenProjects()));
//List should begin with current project
projects.remove(project);
projects.add(0, project);
Pair<? extends JComponent, String> state = getCurrentState(projects);
Pair<? extends JComponent, String> prevState = stateRef.get();
if (prevState != null && prevState.getSecond().equals(state.getSecond()))
return;
stateRef.set(state);
BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(state.getFirst());
builder.setShowCallout(false).setTitle(ExecutionBundle.message("show.running.list.balloon.title")).setBlockClicksThroughBalloon(true).setDialogMode(true).setHideOnKeyOutside(false);
IdeFrame frame = IdeFrame.KEY.getData(e.getDataContext());
if (frame == null) {
frame = WindowManagerEx.getInstanceEx().getFrame(project);
}
if (balloon != null) {
balloon.hide();
}
builder.setClickHandler(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof MouseEvent) {
MouseEvent mouseEvent = (MouseEvent) e.getSource();
Component component = mouseEvent.getComponent();
component = SwingUtilities.getDeepestComponentAt(component, mouseEvent.getX(), mouseEvent.getY());
Object value = ((JComponent) component).getClientProperty(KEY);
if (value instanceof Trinity) {
Project aProject = (Project) ((Trinity) value).first;
JFrame aFrame = WindowManager.getInstance().getFrame(aProject);
if (aFrame != null && !aFrame.isActive()) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(aFrame, true);
});
}
ExecutionManagerImpl.getInstance(aProject).getContentManager().toFrontRunContent((Executor) ((Trinity) value).second, (RunContentDescriptor) ((Trinity) value).third);
}
}
}
}, false);
balloon = builder.createBalloon();
balloonRef.set(balloon);
JComponent component = frame.getComponent();
RelativePoint point = new RelativePoint(component, new Point(component.getWidth(), 0));
balloon.show(point, Balloon.Position.below);
}
};
timer.addActionListener(actionListener);
timer.setInitialDelay(0);
timer.start();
}
Aggregations