Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Provide more options to configure the NotificationPopup

未关闭
#4,487 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
java
领域
desktop

调研方向

Start in the org.eclipse.jface.notifications package, reading AbstractNotificationPopup for the hardcoded MIN_HEIGHT, MAX_WIDTH and PADDING_EDGE constants and NotificationPopup for the builder. Before writing code, check the three comments for whether maintainers agree on the builder API and on making the popup follow its parent shell by default. Done means the new options are configurable and the popup repositions on parent Move and Resize, which needs SWT knowledge and likely a test in the UI test bundle.

由索引模型根据 Issue 内容生成。

描述

enhancement

Let's make sure issue is not already fixed in latest builds first.

Suggestion

The NotificationPopup (org.eclipse.jface.notifications) has some minor flaws, where some workarounds are necessary.

  • The MIN_HEIGHT, MAX_WIDTH and PADDING_EDGE of the popup cannot be configured as desired, as it is hardcoded in the AbstractNotificationPopup.

To shrink the height of the popup, I needed to create a workaround like this:

Point size = popup.getShell().getSize();
Point location = popup.getShell().getLocation();
popup.getShell().pack();
popup.getShell().setLocation(location.x, location.y + (size.y - popup.getShell().getSize().y));

It would be nice to have these options in the builder like this:

NotificationPopup.forDisplay(Display.getDefault())
    .text("A problem occurred.")
    .title("Warning", true)
    .minHeight(0)
    .maxWidth(500)
    .paddingEdge(10)
    .open();
  • The Popup does not follow its parent shell, when it is moved or resized. It would be nice to have an option for this when creating the popup (or maybe as default behavior)

The listener could look like this:

    static void attachPopupFollower(Shell parentShell, Shell popupShell, int padding) {
        Listener moveListener = e -> {
            if (parentShell == null || parentShell.isDisposed()) {
                return;
            }
            if (popupShell == null || popupShell.isDisposed()) {
                return;
            }

            Rectangle clientArea = parentShell.getClientArea();
            Point clientOriginOnDisplay = parentShell.toDisplay(clientArea.x, clientArea.y);
            Point popupSize = popupShell.getSize();

            int x = clientOriginOnDisplay.x + clientArea.width - popupSize.x - padding; //use the configured paddingEdge here
            int y = clientOriginOnDisplay.y + clientArea.height - popupSize.y - padding;

            popupShell.setLocation(x, y);
        };

        parentShell.addListener(SWT.Move, moveListener);
        parentShell.addListener(SWT.Resize, moveListener);

        popupShell.addListener(SWT.Dispose, e -> {
            if (!parentShell.isDisposed()) {
                parentShell.removeListener(SWT.Move, moveListener);
                parentShell.removeListener(SWT.Resize, moveListener);
            }
        });
    }

I attached the whole example as a file here.

Community

  • I understand suggesting an enhancement doesn't mandate anyone to implement it. Other contributors may consider this suggestion, or not, at their own convenience. The most efficient way to get it fixed is that I implement it myself and contribute it back as a good quality patch to the project.
主要语言
Java
星标
124
派生
269
平均合并
2 天 2 小时
30 天内合并 PR
70

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

eclipse-platform/eclipse.platform.ui 的其他 Issue

查看 eclipse-platform/eclipse.platform.ui 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。