Project

General

Profile

Revision 26e06877

ID26e068777f74a5d5f07ac19a4ce727eecc16093d
Parent d486cbb0
Child 10d75c61

Added by Andreas Kohlbecker over 2 years ago

fix #7358 stopping navigation and showing dialog when modal dialogs are open

View differences:

src/main/java/eu/etaxonomy/vaadin/ui/navigation/NavigationUriFragmentManager.java
1 1
package eu.etaxonomy.vaadin.ui.navigation;
2 2

  
3 3
import org.springframework.beans.factory.annotation.Autowired;
4
import org.vaadin.dialogs.ConfirmDialog;
4 5
import org.vaadin.spring.events.EventBus.UIEventBus;
5 6

  
6 7
import com.vaadin.navigator.Navigator.UriFragmentManager;
......
8 9
import com.vaadin.server.Page.UriFragmentChangedEvent;
9 10
import com.vaadin.spring.annotation.SpringComponent;
10 11
import com.vaadin.spring.annotation.UIScope;
12
import com.vaadin.ui.UI;
13
import com.vaadin.ui.Window;
11 14

  
12 15
@SpringComponent
13 16
@UIScope
......
24 27

  
25 28
	@Override
26 29
	public void uriFragmentChanged(UriFragmentChangedEvent event) {
27
	    uiEventBus.publish(this, new NavigationEvent(getState()));
30

  
31
	    if(!isModalWindowShown()){
32
	        uiEventBus.publish(this, new NavigationEvent(getState()));
33
	    } else {
34
	        ConfirmDialog confirm = ConfirmDialog.getFactory().create(
35
	                "Notification",
36
	                "You can't leave this page as long as modal popup editors are open.",
37
	                "Ok", null, null);
38
	        confirm.getCancelButton().setVisible(false);
39
	        confirm.show(UI.getCurrent(), null, true);
40
	    }
41

  
28 42
	}
43

  
44
    /**
45
     *
46
     */
47
    protected boolean isModalWindowShown() {
48
        return UI.getCurrent().getWindows().stream().anyMatch(Window::isModal);
49
    }
29 50
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)