package org.ovirt.engine.ui.common.system;

import org.ovirt.engine.ui.common.presenter.popup.ErrorPopupPresenterWidget;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent;

/**
 * Convenience class used to reveal {@link ErrorPopupPresenterWidget} as a global popup.
 */
public class ErrorPopupManager implements HasHandlers {

    private final EventBus eventBus;
    private final ErrorPopupPresenterWidget errorPopup;

    private boolean showPopups;

    @Inject
    public ErrorPopupManager(EventBus eventBus, ErrorPopupPresenterWidget errorPopup) {
        this.eventBus = eventBus;
        this.errorPopup = errorPopup;
        this.showPopups = true;
    }

    public void setShowPopups(boolean showPopups) {
        this.showPopups = showPopups;
    }

    @Override
    public void fireEvent(GwtEvent<?> event) {
        eventBus.fireEvent(event);
    }

    public void show(String errorMessage) {
        if (showPopups) {
            errorPopup.prepare(errorMessage);
            RevealRootPopupContentEvent.fire(this, errorPopup);
        }
    }

    public void hide(){
        errorPopup.hide();
    }

}

@@ -608,41 +608,8 @@
 p;%0A%0A
-    private boolean showPopups;%0A%0A
     
@@ -780,137 +780,8 @@
 up;%0A
-        this.showPopups = true;%0A    %7D%0A%0A    public void setShowPopups(boolean showPopups) %7B%0A        this.showPopups = showPopups;%0A
     
@@ -934,38 +934,8 @@
 ) %7B%0A
-        if (showPopups) %7B%0A    
     
@@ -972,20 +972,16 @@
 ssage);%0A
-    
         
@@ -1036,18 +1036,8 @@
 p);%0A
-        %7D%0A
     
@@ -1061,16 +1061,17 @@
 d hide()
+ 
 %7B%0A      

remove hide popup feature.