Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Provide more options to configure the NotificationPopup

Đang mở
#4,487 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
desktop

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
Java
Star
124
Fork
269
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
70

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của eclipse-platform/eclipse.platform.ui

Tất cả issue của eclipse-platform/eclipse.platform.ui

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.