package org.drools.guvnor.client;

import com.google.gwt.animation.client.Animation;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.RootPanel;
import org.drools.guvnor.client.configurations.ConfigurationsLoader;
import org.jboss.errai.bus.client.api.RemoteCallback;
import org.jboss.errai.ioc.client.api.Caller;
import org.uberfire.backend.FileExplorerRootService;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.util.Collection;

@ApplicationScoped
public class Bootstapper {

    @PostConstruct
    public void init() {
        ConfigurationsLoader.loadPreferences(new Command() {
            public void execute() {
//                loadUserCapabilities("userName");
            }
        });
        ConfigurationsLoader.loadUserCapabilities(new Command() {
            public void execute() {
//                setUpMain(userName);
            }
        });

        hideLoadingPopup();
    }

    /*
     * Fade out the "Loading application" pop-up
     */
    private void hideLoadingPopup() {
        final Element loadingElement = RootPanel.get("loading").getElement();

        Animation animation = new Animation() {

            @Override
            protected void onUpdate(double progress) {
                loadingElement.getStyle().setOpacity(1.0 - progress);
            }

            @Override
            protected void onComplete() {
                loadingElement.getStyle().setVisibility(Style.Visibility.HIDDEN);
            }

        };

        animation.run(500);

    }
}

@@ -472,16 +472,172 @@
 Service;
+%0Aimport org.uberfire.client.workbench.widgets.menu.WorkbenchMenuBarPresenter;%0Aimport org.uberfire.client.workbench.widgets.menu.impl.DefaultMenuItemCommand;
 %0A%0Aimport
@@ -821,24 +821,88 @@
 tstapper %7B%0A%0A
+    @Inject%0A    private WorkbenchMenuBarPresenter menubar;%0A    %0A
     @PostCon
@@ -1272,24 +1272,222 @@
        %7D);%0A%0A
+        menubar. addMenuItem(new DefaultMenuItemCommand(%22Test%22,new org.uberfire.client.mvp.Command() %7B%0A            @Override%0A            public void execute() %7B%0A%0A            %7D%0A        %7D));%0A        %0A
         hide

test menu item