Search in sources :

Example 21 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.

the class ExplorerMenuViewImpl method asMenu.

@Override
public Menus asMenu() {
    return MenuFactory.newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() {

        @Override
        public void push(MenuFactory.CustomMenuBuilder element) {
        }

        @Override
        public MenuItem build() {
            return new BaseMenuCustom() {

                @Override
                public Widget build() {
                    return new ButtonGroup() {

                        {
                            add(new Button() {

                                {
                                    setToggleCaret(false);
                                    setDataToggle(Toggle.DROPDOWN);
                                    setIcon(IconType.COG);
                                    setSize(ButtonSize.SMALL);
                                    setTitle(ProjectExplorerConstants.INSTANCE.customizeView());
                                }
                            });
                            add(new DropDownMenu() {

                                {
                                    addStyleName("pull-right");
                                    add(businessView);
                                    add(techView);
                                    add(new Divider());
                                    add(breadcrumbExplorer);
                                    add(treeExplorer);
                                    add(new Divider());
                                    add(showTagFilter);
                                    add(new Divider());
                                    add(archiveProject);
                                }
                            });
                        }
                    };
                }
            };
        }
    }).endMenu().newTopLevelCustomMenu(new MenuFactory.CustomMenuBuilder() {

        @Override
        public void push(MenuFactory.CustomMenuBuilder element) {
        }

        @Override
        public MenuItem build() {
            return new BaseMenuCustom() {

                @Override
                public Widget build() {
                    return new Button() {

                        {
                            setIcon(IconType.REFRESH);
                            setSize(ButtonSize.SMALL);
                            setTitle(ProjectExplorerConstants.INSTANCE.refresh());
                            addClickHandler(new ClickHandler() {

                                @Override
                                public void onClick(ClickEvent event) {
                                    presenter.onRefresh();
                                }
                            });
                        }
                    };
                }
            };
        }
    }).endMenu().build();
}
Also used : MenuFactory(org.uberfire.workbench.model.menu.MenuFactory) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) Button(org.gwtbootstrap3.client.ui.Button) BaseMenuCustom(org.uberfire.workbench.model.menu.impl.BaseMenuCustom) DropDownMenu(org.gwtbootstrap3.client.ui.DropDownMenu) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Divider(org.gwtbootstrap3.client.ui.Divider)

Example 22 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.

the class NewResourcesMenu method enableMenuItemsForContext.

void enableMenuItemsForContext() {
    for (Map.Entry<NewResourceHandler, MenuItem> entry : this.newResourceHandlers.entrySet()) {
        final NewResourceHandler handler = entry.getKey();
        final MenuItem menuItem = entry.getValue();
        handler.acceptContext(getCallback(menuItem));
    }
}
Also used : MenuItem(org.uberfire.workbench.model.menu.MenuItem) HashMap(java.util.HashMap) Map(java.util.Map)

Example 23 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.

the class WorkbenchConfigurationMenu method setup.

@PostConstruct
public void setup() {
    final Collection<SyncBeanDef<WorkbenchConfigurationHandler>> handlerBeans = iocBeanManager.lookupBeans(WorkbenchConfigurationHandler.class);
    if (handlerBeans.size() > 0) {
        for (SyncBeanDef<WorkbenchConfigurationHandler> handlerBean : handlerBeans) {
            final WorkbenchConfigurationHandler activeHandler = handlerBean.getInstance();
            final String description = activeHandler.getDescription();
            final MenuItem menuItem = MenuFactory.newSimpleItem(description).respondsWith(new Command() {

                @Override
                public void execute() {
                    newResourcePresenter.show(activeHandler);
                }
            }).endMenu().build().getItems().get(0);
            workbenchConfigurationHandler.put(activeHandler, menuItem);
            items.add(menuItem);
        }
    }
    Collections.sort(items, new Comparator<MenuItem>() {

        @Override
        public int compare(final MenuItem o1, final MenuItem o2) {
            return o1.getCaption().compareToIgnoreCase(o2.getCaption());
        }
    });
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) PostConstruct(javax.annotation.PostConstruct)

Example 24 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.

the class DefaultWorkbenchFeaturesMenusHelper method buildMenuItemsFromNavGroup.

public List<MenuItem> buildMenuItemsFromNavGroup(NavGroup navGroup) {
    List<MenuItem> result = new ArrayList<>();
    for (NavItem navItem : navGroup.getChildren()) {
        // Skip dividers
        if (navItem instanceof NavDivider) {
            continue;
        }
        // Append its children
        MenuBuilder<Builder> builder = MenuFactory.newSimpleItem(navItem.getName());
        if (navItem instanceof NavGroup) {
            List<MenuItem> childItems = buildMenuItemsFromNavGroup((NavGroup) navItem);
            builder.withItems(childItems);
        }
        // Append the place request
        NavWorkbenchCtx navCtx = NavWorkbenchCtx.get(navItem);
        if (navCtx.getResourceId() != null && ActivityResourceType.PERSPECTIVE.equals(navCtx.getResourceType())) {
            PlaceRequest placeRequest = resolvePlaceRequest(navCtx.getResourceId());
            builder.place(placeRequest);
        }
        // Build the menu item & continue with the next one
        MenuItem menuItem = builder.endMenu().build().getItems().get(0);
        result.add(menuItem);
    }
    return result;
}
Also used : DefaultPlaceRequest(org.uberfire.mvp.impl.DefaultPlaceRequest) PlaceRequest(org.uberfire.mvp.PlaceRequest) WorkbenchViewModeSwitcherMenuBuilder(org.uberfire.client.menu.WorkbenchViewModeSwitcherMenuBuilder) AppLauncherMenuBuilder(org.kie.workbench.common.widgets.client.menu.AppLauncherMenuBuilder) MenuBuilder(org.uberfire.workbench.model.menu.MenuFactory.MenuBuilder) ResetPerspectivesMenuBuilder(org.kie.workbench.common.widgets.client.menu.ResetPerspectivesMenuBuilder) AdminCustomMenuBuilder(org.kie.workbench.common.workbench.client.menu.custom.AdminCustomMenuBuilder) TopLevelMenusBuilder(org.uberfire.workbench.model.menu.MenuFactory.TopLevelMenusBuilder) Builder(org.uberfire.workbench.model.menu.MenuFactory.Builder) ArrayList(java.util.ArrayList) MenuItem(org.uberfire.workbench.model.menu.MenuItem) NavWorkbenchCtx(org.dashbuilder.navigation.workbench.NavWorkbenchCtx) NavItem(org.dashbuilder.navigation.NavItem) NavDivider(org.dashbuilder.navigation.NavDivider) NavGroup(org.dashbuilder.navigation.NavGroup)

Example 25 with MenuItem

use of org.uberfire.workbench.model.menu.MenuItem in project kie-wb-common by kiegroup.

the class DefaultWorkbenchFeaturesMenusHelper method getPerspectivesMenuItems.

public List<MenuItem> getPerspectivesMenuItems() {
    final List<MenuItem> perspectives = new ArrayList<>();
    for (final PerspectiveActivity perspective : getPerspectiveActivities()) {
        final String name = perspective.getDefaultPerspectiveLayout().getName();
        final MenuItem item = newSimpleItem(name).perspective(perspective.getIdentifier()).endMenu().build().getItems().get(0);
        perspectives.add(item);
    }
    return perspectives;
}
Also used : PerspectiveActivity(org.uberfire.client.mvp.PerspectiveActivity) ArrayList(java.util.ArrayList) MenuItem(org.uberfire.workbench.model.menu.MenuItem)

Aggregations

MenuItem (org.uberfire.workbench.model.menu.MenuItem)34 Test (org.junit.Test)18 Button (org.gwtbootstrap3.client.ui.Button)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 DropDownMenu (org.gwtbootstrap3.client.ui.DropDownMenu)5 Command (org.uberfire.mvp.Command)5 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)4 ButtonSize (org.gwtbootstrap3.client.ui.constants.ButtonSize)4 IconType (org.gwtbootstrap3.client.ui.constants.IconType)4 Toggle (org.gwtbootstrap3.client.ui.constants.Toggle)4 MenuUtils (org.kie.workbench.common.stunner.client.widgets.menu.MenuUtils)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Inject (javax.inject.Inject)3 IconPosition (org.gwtbootstrap3.client.ui.constants.IconPosition)3 Pull (org.gwtbootstrap3.client.ui.constants.Pull)3 PlaceRequest (org.uberfire.mvp.PlaceRequest)3 Menus (org.uberfire.workbench.model.menu.Menus)3 BaseMenuCustom (org.uberfire.workbench.model.menu.impl.BaseMenuCustom)3