Example usage for com.google.gwt.user.client.ui MenuItem setScheduledCommand

List of usage examples for com.google.gwt.user.client.ui MenuItem setScheduledCommand

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui MenuItem setScheduledCommand.

Prototype

public void setScheduledCommand(ScheduledCommand cmd) 

Source Link

Document

Sets the scheduled command associated with this item.

Usage

From source file:org.cruxframework.crux.widgets.client.disposal.topmenudisposal.TopMenuDisposalLargeController.java

License:Apache License

@Override
public void addMenuEntry(final String label, final String targetView) {
    MenuItem menuItem = new MenuItem(new SafeHtmlBuilder().appendEscaped(label).toSafeHtml());
    menuItem.addStyleName("menuEntry");
    menuItem.setScheduledCommand(new ScheduledCommand() {
        @Override//from  ww  w  . ja v  a  2 s . com
        public void execute() {
            showView(targetView, true);
        }
    });
    menuBar.addItem(menuItem);
}

From source file:org.pentaho.mantle.client.ui.PerspectiveManager.java

License:Open Source License

protected void setPluginPerspectives(final ArrayList<IPluginPerspective> perspectives) {

    this.perspectives = perspectives;

    clear();//from w  w w .  jav a 2s.  com

    // sort perspectives
    Collections.sort(perspectives, new Comparator<IPluginPerspective>() {
        public int compare(IPluginPerspective o1, IPluginPerspective o2) {
            Integer p1 = new Integer(o1.getLayoutPriority());
            Integer p2 = new Integer(o2.getLayoutPriority());
            return p1.compareTo(p2);
        }
    });

    MenuBar perspectiveMenuBar = new MenuBar(true);
    perspectiveDropDown = new CustomDropDown("", perspectiveMenuBar, MODE.MAJOR);
    setWidget(perspectiveDropDown);
    loadResourceBundle(perspectiveDropDown, perspectives.get(0));

    ScheduledCommand noopCmd = new ScheduledCommand() {
        public void execute() {
        }
    };

    for (final IPluginPerspective perspective : perspectives) {

        // if we have overlays add it to the list
        if (perspective.getOverlays() != null) {
            overlays.addAll(perspective.getOverlays());
        }

        final MenuItem menuItem = new MenuItem("", noopCmd);
        perspectiveMenuItemMap.put(perspective.getId(), menuItem);
        ScheduledCommand cmd = new ScheduledCommand() {
            public void execute() {
                showPerspective(perspective);
                perspectiveDropDown.setText(menuItem.getText());
                perspectiveDropDown.hidePopup();
            }
        };
        menuItem.setScheduledCommand(cmd);
        perspectiveMenuBar.addItem(menuItem);
        loadResourceBundle(menuItem, perspective);
    }

    // register overlays with XulMainToolbar
    MantleXul.getInstance().addOverlays(overlays);

    setPerspective(perspectives.get(0).getId());

    loaded = true;
    EventBusUtil.EVENT_BUS.fireEvent(new PerspectivesLoadedEvent());
}

From source file:org.pepstock.jem.gwt.client.editor.AbstractSyntaxHighlighter.java

License:Open Source License

private MenuItem createMenuItem(final FontSize fontsize, String preference) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant(/* ww  w.  ja va  2 s . c  om*/
            "<div style='font-size: " + fontsize.getCssValue() + ";'>" + fontsize.getName() + "</div>");
    final MenuItem item = new MenuItem(builder.toSafeHtml());
    item.setScheduledCommand(new Command() {
        @Override
        public void execute() {
            // sets preferences
            CurrentUser.getInstance().setStringPreference(PreferencesKeys.JOB_EDIT_FONTSIZE,
                    fontsize.getCssValue());
            // fires new event
            FontSizeEvent event = new FontSizeEvent(fontsize);
            EventBus.INSTANCE.fireEvent(event);
        }
    });
    if (preference.equalsIgnoreCase(fontsize.getCssValue())) {
        selectedFontItem = item;
        item.setEnabled(false);
        item.addStyleName(Styles.INSTANCE.common().editMenuItemDisabled());
        editor.setFontSize(fontsize.getCssValue());
        currentFontSize = fontsize;
    }
    return item;
}

From source file:org.rstudio.core.client.widget.ToolbarPopupMenu.java

License:Open Source License

public void addItem(MenuItem menuItem) {
    ScheduledCommand command = menuItem.getScheduledCommand();
    if (command == null && menuItem instanceof AppMenuItem)
        command = ((AppMenuItem) menuItem).getScheduledCommand(true);
    if (command != null)
        menuItem.setScheduledCommand(new ToolbarPopupMenuCommand(command));
    menuBar_.addItem(menuItem);/*  ww  w.jav  a  2 s. com*/
}

From source file:org.rstudio.core.client.widget.ToolbarPopupMenu.java

License:Open Source License

public void insertItem(MenuItem menuItem, int beforeIndex) {
    ScheduledCommand command = menuItem.getScheduledCommand();
    if (command != null)
        menuItem.setScheduledCommand(new ToolbarPopupMenuCommand(command));
    menuBar_.insertItem(menuItem, beforeIndex);
}

From source file:org.rstudio.core.client.widget.ToolbarPopupMenuButton.java

License:Open Source License

public void addMenuItem(final MenuItem item, final String value) {
    final ScheduledCommand cmd = item.getScheduledCommand();
    item.setScheduledCommand(new Command() {
        @Override//w ww.  j  a  v  a  2  s .co m
        public void execute() {
            setText(value);
            if (cmd != null)
                cmd.execute();
        }
    });
    getMenu().addItem(item);
}