Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Provide more options to configure the NotificationPopup

Aperta
#4,487 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
desktop

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Java
Stelle
124
Fork
269
Merge medio
2g 2h
PR unite (30g)
70

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eclipse-platform/eclipse.platform.ui

Tutte le issue di eclipse-platform/eclipse.platform.ui

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.