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

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

Introduction

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

Prototype

protected MenuItem(@IsSafeHtml String text, boolean asHTML) 

Source Link

Usage

From source file:accelerator.client.view.desktop.DesktopMainMenuView.java

License:Open Source License

@UiHandler("editButton")
void onEditButtonClick(ClickEvent e) {
    final PopupPanel popup = new PopupPanel(true, false);
    MenuBar menu = new MenuBar(true);

    {/*from w ww . ja  va2s .  c  om*/
        final Project p = getSelectedProject();
        final boolean isProjectSelected = p != null;

        // 
        MenuItem edit = new MenuItem("", new Command() {
            public void execute() {
                assert (p != null);
                popup.hide();
                ProjectDialogBox dlg = new ProjectDialogBox(p);
                dlg.setHandler(new ProjectDialogBox.Handler() {
                    public void onOk(Project input) {
                        handler.updateProject(input);
                    }
                });
                dlg.center();
            }
        });
        edit.setEnabled(isProjectSelected);
        menu.addItem(edit);

        // 
        MenuItem delete = new MenuItem("", new Command() {
            public void execute() {
                assert (p != null);
                popup.hide();
                handler.deleteProject(p);
            }
        });
        delete.setEnabled(isProjectSelected);
        menu.addItem(delete);
    }

    menu.addSeparator();

    {
        final Tag t = getSelectedTag();
        final boolean isTagSelected = t != null;

        // 
        MenuItem edit = new MenuItem("", new Command() {
            public void execute() {
                assert (t != null);
                popup.hide();
                TagDialogBox dlg = new TagDialogBox(t);
                dlg.setHandler(new TagDialogBox.Handler() {
                    public void onOk(Tag input) {
                        handler.updateTag(input);
                    }
                });
                dlg.center();
            }
        });
        edit.setEnabled(isTagSelected);
        menu.addItem(edit);

        // 
        MenuItem delete = new MenuItem("", new Command() {
            public void execute() {
                assert (t != null);
                popup.hide();
                handler.deleteTag(t);
            }
        });
        delete.setEnabled(isTagSelected);
        menu.addItem(delete);
    }

    popup.setWidget(menu);
    popup.setPopupPositionAndShow(new PositionCallback() {
        public void setPosition(int offsetWidth, int offsetHeight) {
            int left = editButton.getAbsoluteLeft();
            int top = editButton.getAbsoluteTop() - offsetHeight;
            popup.setPopupPosition(left, top);
        }
    });
}

From source file:cc.kune.common.client.actions.gwtui.GwtSubMenuGui.java

License:GNU Affero Public License

@Override
public AbstractGuiItem create(final GuiActionDescrip descriptor) {
    super.descriptor = descriptor;
    super.create(descriptor);
    item = new MenuItem("", menu);
    iconLabel = new IconLabel("");
    configureItemFromProperties();/*from   ww w. jav a2  s. co  m*/
    parentMenu = ((AbstractGwtMenuGui) descriptor.getParent().getValue(PARENT_UI));
    final int position = descriptor.getPosition();
    if (position == GuiActionDescrip.NO_POSITION) {
        parentMenu.add(item);
    } else {
        parentMenu.insert(position, item);
    }
    descriptor.putValue(ParentWidget.PARENT_UI, this);
    descriptor.putValue(MenuItemDescriptor.UI, this);
    return this;
}

From source file:ch.heftix.mailxel.client.MailxelMainToolBar.java

License:Open Source License

public MailxelMainToolBar(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) {

    this.mailxelService = mailxelService;
    this.mailxelPanel = mailxelPanel;

    logo = new Image("img/mailxel.png");
    logo.setTitle("MailXel " + Version.getVersion());
    logo.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            PopupPanel pp = new PopupPanel(true);
            DisclosurePanel dp = new DisclosurePanel("MailXel " + Version.getVersion());
            dp.setWidth("400px");
            dp.setOpen(true);//w ww .j a v  a  2  s  .  co m

            HTML html = new HTML();
            StringBuffer sb = new StringBuffer();
            sb.append("(c) 2008-2010 by Simon Hefti. All rights reserved.<br/>");
            sb.append(
                    "<p>mailxel is licensed under the <a href=\"http://www.eclipse.org/legal/epl-v10.html\">EPL 1.0</a>. mailxel is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.");
            sb.append("<p>mailxel relies on the following components:");
            sb.append("<ul>");
            sb.append(
                    "<li>GWT, <a href=\"http://code.google.com/webtoolkit\">http://code.google.com/webtoolkit</a></li>");
            sb.append(
                    "<li>sqlite-jdbc, <a href=\"http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC\">http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC</a></li>");
            sb.append(
                    "<li>(and thus on sqlite itself, <a href=\"http://www.sqlite.org\">http://www.sqlite.org</a>)</li>");
            sb.append(
                    "<li>Java Mail API, <a href=\"http://java.sun.com/products/javamail\">http://java.sun.com/products/javamail</a></li>");
            sb.append(
                    "<li>jetty servlet container, <a href=\"http://www.eclipse.org/jetty/\">http://www.eclipse.org/jetty/</a></li>");
            sb.append(
                    "<li>fugue-icons, <a href=\"http://code.google.com/p/fugue-icons-src/\">http://code.google.com/p/fugue-icons-src/</a></li>");
            sb.append("<li>jsoup, <a href=\"http://jsoup.org\">http://jsoup.org</a></li>");
            sb.append("</ul>");
            html.setHTML(sb.toString());
            dp.add(html);
            dp.setOpen(true);

            pp.add(dp);
            pp.show();
        }
    });

    Image home = new Image("img/find.png");
    home.setTitle("Search");
    home.setStylePrimaryName("mailxel-toolbar-item");
    home.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            Panel panel = new MailOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(panel, "Search");
        }
    });

    final Image query = new Image("img/document-task.png");
    query.setTitle("Search (predefined query)");
    query.setStylePrimaryName("mailxel-toolbar-item");
    query.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            final StatusItem si = mailxelPanel.statusStart("retrieve stored message queries");

            mailxelService.searchQueries(MessageQueryTO.T_MESSAGE_QUERY, null,
                    new AsyncCallback<List<MessageQueryTO>>() {

                        public void onFailure(Throwable caught) {
                            si.error(caught);
                        }

                        public void onSuccess(List<MessageQueryTO> result) {
                            si.done();
                            if (null != result && result.size() > 0) {
                                PopupMenu popupMenu = new PopupMenu(query);
                                for (MessageQueryTO mqTO : result) {
                                    String name = mqTO.shortname + " (" + UIUtil.shorten(mqTO.name) + ")";
                                    MenuItem menuItem = new MenuItem(name, new MessageQueryCommand(
                                            mailxelService, mailxelPanel, popupMenu, mqTO));
                                    String url = DirectMailServiceUtil.getIconURL(mqTO.iconId);
                                    if (null != url) {
                                        String html = "<img src=\"" + url + "\"/>&nbsp;" + name;
                                        menuItem.setHTML(html);
                                    }
                                    popupMenu.addItem(menuItem);
                                }
                                popupMenu.show();
                            }
                        }
                    });
        }
    });

    Image mailnew = new Image("img/mail-new.png");
    mailnew.setTitle("New Mail");
    mailnew.setStylePrimaryName("mailxel-toolbar-item");
    mailnew.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null,
                    MailSendGrid.TYPE_NEW);
            mailxelPanel.addTab(mailSendGrid, "New Mail");
        }
    });

    Image noteToSelf = new Image("img/note.png");
    noteToSelf.setTitle("Note to myself");
    noteToSelf.setStylePrimaryName("mailxel-toolbar-item");
    noteToSelf.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null,
                    MailSendGrid.TYPE_SELF);
            mailxelPanel.addTab(mailSendGrid, "New Note");
        }
    });

    Image contacts = new Image("img/address-book.png");
    contacts.setTitle("Address Book");
    contacts.setStylePrimaryName("mailxel-toolbar-item");
    contacts.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            AddressOverviewGrid ag = new AddressOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(ag, "Contacts");
        }
    });

    /**
     * mail download menu on click, a menu with the available accounts is
     * displayed, allowing the user is asked to choose the data source.
     */
    final Image download = new Image("img/download-mail.png");
    download.setTitle("Mail download");
    download.setStylePrimaryName("mailxel-toolbar-item");
    download.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            ConfigTO configTO = mailxelPanel.getConfig();
            String[] accounts = configTO.accountNames;

            if (null != accounts && accounts.length > 0) {

                PopupMenu popupMenu = new PopupMenu(download);
                // first item: allow download from all known accounts
                MenuItem menuItem = new MenuItem("Scan all accounts",
                        new ScanMailFolderCommand(mailxelService, mailxelPanel, popupMenu, accounts));
                popupMenu.addItem(menuItem);

                // add one menu item per account
                for (int i = 0; i < accounts.length; i++) {
                    String[] selectedAccount = new String[1];
                    selectedAccount[0] = accounts[i];
                    menuItem = new MenuItem(accounts[i], new ScanMailFolderCommand(mailxelService, mailxelPanel,
                            popupMenu, selectedAccount));
                    popupMenu.addItem(menuItem);
                }
                popupMenu.show();
            }
        }
    });

    final Image reorgMailFolder = new Image("img/wand.png");
    reorgMailFolder.setTitle("reorganize mail folder");
    reorgMailFolder.setStylePrimaryName("mailxel-toolbar-item");
    reorgMailFolder.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            ConfigTO configTO = mailxelPanel.getConfig();
            String[] accounts = configTO.accountNames;

            if (null != accounts && accounts.length > 0) {

                PopupMenu popupMenu = new PopupMenu(reorgMailFolder);
                // first item: allow reorg from all known accounts
                MenuItem menuItem = new MenuItem("All accounts", new ReorgMailFolderCommand(mailxelService,
                        mailxelPanel, popupMenu, reorgMailFolder, accounts));
                popupMenu.addItem(menuItem);

                // add one menu item per account
                for (int i = 0; i < accounts.length; i++) {
                    String[] selectedAccount = new String[1];
                    selectedAccount[0] = accounts[i];
                    menuItem = new MenuItem(accounts[i], new ReorgMailFolderCommand(mailxelService,
                            mailxelPanel, popupMenu, reorgMailFolder, selectedAccount));
                    popupMenu.addItem(menuItem);
                }
                popupMenu.show();
            }
        }
    });

    final Image categories = new Image("img/tags.png");
    categories.setTitle("Manage Categories");
    categories.setStylePrimaryName("mailxel-toolbar-item");
    categories.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            CategoryOverviewGrid cog = new CategoryOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(cog, "Categories");
        }
    });

    final Image setup = new Image("img/preferences-system.png");
    setup.setTitle("System Setup");
    setup.setStylePrimaryName("mailxel-toolbar-item");
    setup.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // ConfigTabPanel cg = new ConfigTabPanel();
            ConfigGrid cg = new ConfigGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(cg, "Setup");
        }
    });

    final Image login = new Image("img/lock.png");
    login.setTitle("Login");
    login.setStylePrimaryName("mailxel-toolbar-item");
    login.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            // create login box
            LoginPanel loginPanel = new LoginPanel(mailxelService, mailxelPanel);
            int x = login.getAbsoluteLeft();
            int y = login.getAbsoluteTop();
            loginPanel.setPopupPosition(x, y);
            loginPanel.show();
        }
    });

    final Image additional = new Image("img/context-menu.png");
    additional.setTitle("Additional functions");
    additional.setStylePrimaryName("mailxel-toolbar-item");

    final PopupCommand importMboxCommand = new PopupCommand() {

        public void execute() {

            final PopupPanel pup = new PopupPanel(true);
            HorizontalPanel hp = new HorizontalPanel();
            final TextBox tb = new TextBox();
            tb.setWidth("300px");
            hp.add(tb);

            Button b = new Button();
            b.setText("import");
            b.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent sender) {
                    String name = tb.getText();
                    if (null != name) {
                        name = name.trim();
                        if (name.length() > 0) {
                            final StatusItem si = mailxelPanel.statusStart("Import from mbox: " + name);
                            mailxelService.importMboxFile(name, new AsyncCallback<Void>() {

                                public void onFailure(Throwable caught) {
                                    si.error(caught);
                                }

                                public void onSuccess(Void result) {
                                    si.done();
                                }
                            });
                            pup.hide();
                        }
                    }
                }
            });

            hp.add(b);
            pup.add(hp);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();
            pup.setPopupPosition(x, y);
            /** show input box for path to mbox file */
            pup.show();
            /** hide the list of available additional commands */
            hide();
        }
    };

    final PopupCommand addressUploadCommand = new PopupCommand() {

        public void execute() {
            AddressUploadGrid ug = new AddressUploadGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(ug, "Address Upload");
            /** hide the list of available additional commands */
            hide();
        }
    };

    final Command showWelcomePanelCommand = new Command() {

        public void execute() {
            WelcomeToMailxelPanel wp = new WelcomeToMailxelPanel(mailxelService, mailxelPanel);
            mailxelPanel.addTab(wp, "Welcome");
        }
    };

    final PopupCommand deleteConfigCommand = new PopupCommand() {

        public void execute() {

            PopupPanel pop = new PopupPanel(true, true);
            HorizontalPanel hp = new HorizontalPanel();
            Label label = new Label("Really delete all configuration?");
            hp.add(label);
            Button b = new Button();
            b.setText("Ok");
            b.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    final StatusItem si = mailxelPanel.statusStart("deleting configuration");
                    mailxelService.deleteConfig(new AsyncCallback<Void>() {

                        public void onFailure(Throwable caught) {
                            si.error(caught);
                        }

                        public void onSuccess(Void result) {
                            si.done();
                        }
                    });
                }
            });
            hp.add(b);
            pop.add(hp);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();
            pop.setPopupPosition(x, y);
            pop.show();
            /** hide the list of available additional commands */
            hide();
        }
    };

    final Command updateToMeFlagCommand = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("Update 'to me' flag");
            mailxelService.updateToMeFlag(new AsyncCallback<Void>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(Void result) {
                    si.done();
                }
            });
        }
    };

    final Command updateFromMeFlagCommand = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("Update 'from me' flag");
            mailxelService.updateFromMeFlag(new AsyncCallback<Void>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(Void result) {
                    si.done();
                }
            });
        }
    };

    final Command showStatisticsCommand = new Command() {

        public void execute() {
            StatisticsGrid sg = new StatisticsGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(sg, "Statistics");
        }
    };

    final Command showIconsCommand = new Command() {

        public void execute() {
            IconOverviewGrid og = new IconOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(og, "Icons");
        }
    };

    final Command showMessageQueriesCommand = new Command() {

        public void execute() {
            MessageQueryOverviewGrid mqog = new MessageQueryOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(mqog, "Message Queries");
        }
    };

    final Command showAttachmentGridCommand = new Command() {

        public void execute() {
            AttachmentOverviewGrid aog = new AttachmentOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(aog, "Attachment Overview");
        }
    };

    final Command closeAllTabsCommand = new Command() {

        public void execute() {
            mailxelPanel.closeAllNonEditTabs();
        }
    };

    final Command dbHousekeeping = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("DB housekeeping");
            mailxelService.housekeeping(new AsyncCallback<String>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(String result) {
                    if (result.startsWith("200 OK")) {
                        si.done();
                    } else {
                        si.error(result);
                    }
                }
            });
        }
    };

    final Command messageCount = new Command() {

        public void execute() {
            updateCounts();
        }
    };

    additional.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            MenuBar popupMenuBar = new MenuBar(true);
            PopupPanel popupPanel = new PopupPanel(true);

            MenuItem menuItem = new MenuItem("Attachment Overview", showAttachmentGridCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Close all Tabs", closeAllTabsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Message Queries", showMessageQueriesCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("DB Housekeeping", dbHousekeeping);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("update pending messages count", messageCount);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Statistics", showStatisticsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Icons", showIconsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Import mbox file", importMboxCommand);
            importMboxCommand.setPopupPanel(popupPanel);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Address upload", addressUploadCommand);
            addressUploadCommand.setPopupPanel(popupPanel);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Welcome", showWelcomePanelCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Delete existing configuration", deleteConfigCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Update 'from me' flag", updateFromMeFlagCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Update 'to me' flag", updateToMeFlagCommand);
            popupMenuBar.addItem(menuItem);

            popupMenuBar.setVisible(true);
            popupPanel.add(popupMenuBar);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();

            popupPanel.setPopupPosition(x, y);
            popupPanel.show();
        }
    });

    updateCounts();

    add(home);
    add(query);
    add(mailnew);
    add(noteToSelf);
    add(contacts);
    add(categories);
    add(download);
    add(reorgMailFolder);
    add(setup);
    add(login);
    add(additional);
    add(logo);
    add(msgCountAct);
}

From source file:com.appspot.socialinquirer.client.SocialInquirer.java

License:Apache License

/**
 * Creates the menu bar.//from   w w  w.  j a v  a  2  s.  c o  m
 *
 * @param constants the constants
 * @param user the user
 * @return the menu bar
 */
private MenuBar createMenuBar(final EverScribeConstants constants, final User user) {
    final boolean enabled = (user != null);
    final MenuBar menu = new MenuBar();
    GWT.runAsync(new RunAsyncCallback() {
        public void onFailure(Throwable caught) {
            UiUtils.showErrorDialog(constants, constants.errorCodeDownloadFailed());
        }

        public void onSuccess() {
            menu.setAutoOpen(true);
            menu.setAnimationEnabled(true);

            MenuItem homeMenuItem = new MenuItem(constants.homeMenuName(),
                    new HistoryCommand(HistoryToken.Home));
            homeMenuItem.setEnabled(enabled);
            menu.addItem(homeMenuItem);

            MenuBar networkMenuItem = new MenuBar(true);
            networkMenuItem.setAnimationEnabled(true);
            menu.addItem(new MenuItem(constants.networkMenuName(), networkMenuItem));
            MenuItem nfMenuItem = new MenuItem(constants.followersMenuName(),
                    new HistoryCommand(HistoryToken.Network_Followers));
            nfMenuItem.setEnabled(enabled);
            networkMenuItem.addItem(nfMenuItem);
            nfMenuItem = new MenuItem(constants.followingMenuName(),
                    new HistoryCommand(HistoryToken.Network_Following));
            nfMenuItem.setEnabled(enabled);
            networkMenuItem.addItem(nfMenuItem);
            nfMenuItem = new MenuItem(constants.recommendedMenuName(),
                    new HistoryCommand(HistoryToken.Network_Recommended));
            nfMenuItem.setEnabled(enabled);
            networkMenuItem.addItem(nfMenuItem);

            MenuBar activityMenuItem = new MenuBar(true);
            activityMenuItem.setAnimationEnabled(true);
            menu.addItem(new MenuItem(constants.activityMenuName(), activityMenuItem));
            MenuItem aMenuItem = new MenuItem(constants.tasksMenuName(),
                    new HistoryCommand(HistoryToken.Activity_Tasks));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.pollMenuName(), new HistoryCommand(HistoryToken.Activity_Polls));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.quizMenuName(),
                    new HistoryCommand(HistoryToken.Activity_Quizzes));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.pagesMenuName(),
                    new HistoryCommand(HistoryToken.Activity_Pages));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.messagesMenuName(),
                    new HistoryCommand(HistoryToken.Activity_Messages));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.endorsementsMenuName(),
                    new HistoryCommand(HistoryToken.Activity_Endorsements));
            aMenuItem.setEnabled(enabled);
            activityMenuItem.addItem(aMenuItem);

            //            MenuBar pagesMenuItem = new MenuBar(true);
            //            pagesMenuItem.setAnimationEnabled(true);
            //            menu.addItem(new MenuItem(constants.pagesMenuName(),
            //                  pagesMenuItem));
            //            aMenuItem = new MenuItem(constants
            //                  .followingMenuName(), new HistoryCommand(HistoryToken.Pages_Following));
            //            aMenuItem.setEnabled(enabled);
            //            pagesMenuItem.addItem(aMenuItem);
            //            aMenuItem = new MenuItem(constants
            //                  .ownedMenuName(), new HistoryCommand(HistoryToken.Pages_Created));
            //            aMenuItem.setEnabled(enabled);
            //            pagesMenuItem.addItem(aMenuItem);
            //            aMenuItem = new MenuItem(constants
            //                  .recommendedMenuName(), new HistoryCommand(HistoryToken.Pages_Recommended));
            //            aMenuItem.setEnabled(enabled);
            //            pagesMenuItem.addItem(aMenuItem);

            MenuBar questionsMenuItem = new MenuBar(true);
            questionsMenuItem.setAnimationEnabled(true);
            menu.addItem(new MenuItem(constants.questionsMenuName(), questionsMenuItem));
            aMenuItem = new MenuItem(constants.askedMenuName(),
                    new HistoryCommand(HistoryToken.Questions_Asked));
            aMenuItem.setEnabled(enabled);
            questionsMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.answeredMenuName(),
                    new HistoryCommand(HistoryToken.Questions_Answered));
            aMenuItem.setEnabled(enabled);
            questionsMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.followingMenuName(),
                    new HistoryCommand(HistoryToken.Questions_Following));
            aMenuItem.setEnabled(enabled);
            questionsMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.recommendedMenuName(),
                    new HistoryCommand(HistoryToken.Questions_Recommended));
            aMenuItem.setEnabled(enabled);
            questionsMenuItem.addItem(aMenuItem);

            MenuBar tagsMenuItem = new MenuBar(true);
            tagsMenuItem.setAnimationEnabled(true);
            menu.addItem(new MenuItem(constants.tagsMenuName(), tagsMenuItem));
            aMenuItem = new MenuItem(constants.ownedMenuName(), new HistoryCommand(HistoryToken.Topics_Active));
            aMenuItem.setEnabled(enabled);
            tagsMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.followingMenuName(),
                    new HistoryCommand(HistoryToken.Topics_Following));
            aMenuItem.setEnabled(enabled);
            tagsMenuItem.addItem(aMenuItem);
            aMenuItem = new MenuItem(constants.recommendedMenuName(),
                    new HistoryCommand(HistoryToken.Topics_Recommended));
            aMenuItem.setEnabled(enabled);
            tagsMenuItem.addItem(aMenuItem);

            MenuBar accountMenu = new MenuBar(true);
            accountMenu.setAnimationEnabled(true);
            menu.addItem(new MenuItem(constants.accountMenuName(), accountMenu));

            MenuItem loginMenuItem = new MenuItem(constants.loginMenuName(), new LoginCommand(constants));
            loginMenuItem.setEnabled(!enabled);
            accountMenu.addItem(loginMenuItem);
            MenuItem logoutMenuItem = new MenuItem(constants.logoutMenuName(), new LogoutCommand(constants));
            logoutMenuItem.setEnabled(enabled);
            accountMenu.addItem(logoutMenuItem);

            MenuItem settingsMenuItem = new MenuItem(constants.settingsMenuName(),
                    new HistoryCommand(HistoryToken.Settings));
            settingsMenuItem.setEnabled(enabled);
            accountMenu.addItem(settingsMenuItem);
        }
    });
    return menu;
}

From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java

License:Apache License

/**
 * Instantiates a new home view impl.//from  www  . ja  v  a2  s. co m
 *
 * @param constants the constants
 * @param oracle the oracle
 */
public HomeViewImpl(final EverScribeConstants constants, SingleWordSuggestOracle oracle) {
    this.constants = constants;
    questionsTable = new CellTable<Question>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    questionsPaginator.setDisplay(questionsTable);
    final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>(
            new KeyProvider<Question>());
    questionsTable.setSelectionModel(questionsSelectionModel,
            DefaultSelectionEventManager.<Question>createCheckboxManager());
    initTableColumns(questionsTable, questionsSelectionModel);
    questionsSearchBox = new SuggestBox(oracle);
    templatesTable = new CellTable<Message>();
    SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class);
    templatesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true);
    templatesPaginator.setPageSize(5);
    templatesTable.setPageSize(5);
    templatesPaginator.setDisplay(templatesTable);
    //       final SelectionModel<Message> linkedHubConnectionsSelectionModel = new MultiSelectionModel<Message>(
    //               new KeyProvider<Message>());
    //       templatesTable.setSelectionModel(linkedHubConnectionsSelectionModel,
    //               DefaultSelectionEventManager.<Message>createCheckboxManager());
    initTableColumns(templatesTable);

    initWidget(uiBinder.createAndBindUi(this));
    searchResults.setVisible(false);
    introduction.setVisible(true);
    feeds.setVisible(false);

    viewMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onViewClicked(getSelectedQuestion());
        }
    });

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(getSelectedQuestion());
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(getSelectedQuestion());
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(getSelectedQuestion());
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(getSelectedQuestion());
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(getSelectedQuestion());
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(getSelectedQuestion());
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(getSelectedQuestion());
        }
    });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(getSelectedQuestion(), language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }
}

From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java

License:Apache License

public void setClassifiers(ArrayList<Classifier> classifiers) {
    for (final Classifier item : classifiers) {
        MenuItem menuItem = new MenuItem(item.getName(), new Command() {

            @Override/*from ww  w  .  j  a va2s  .c o  m*/
            public void execute() {
                presenter.onClassifyClicked(getSelectedQuestion(), item);
            }
        });
        menuItem.setEnabled(true);
        classifierBar.addItem(menuItem);
    }

}

From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java

License:Apache License

public void setQuizzes(ArrayList<Quiz> quizzes) {
    for (final Quiz item : quizzes) {
        MenuItem menuItem = new MenuItem(item.getName(), new Command() {

            @Override//from w ww . j ava 2  s .co m
            public void execute() {
                presenter.onAddToQuizClicked(getSelectedQuestion(), item);
            }
        });
        menuItem.setEnabled(true);
        quizBar.addItem(menuItem);
    }
}

From source file:com.appspot.socialinquirer.client.view.QuestionsViewImpl.java

License:Apache License

/**
 * Instantiates a new questions view impl.
 *
 * @param constants the constants//from  ww  w .j ava  2s.  c  o  m
 */
public QuestionsViewImpl(final EverScribeConstants constants) {
    this.constants = constants;
    questionsTable = new CellTable<Question>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    questionsPaginator.setDisplay(questionsTable);
    final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>(
            new KeyProvider<Question>());
    questionsTable.setSelectionModel(questionsSelectionModel,
            DefaultSelectionEventManager.<Question>createCheckboxManager());
    initTableColumns(questionsTable, questionsSelectionModel);
    initWidget(uiBinder.createAndBindUi(this));

    // menu commands
    viewMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onViewClicked(getSelectedQuestion());
        }
    });

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(getSelectedQuestion());
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(getSelectedQuestion());
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(getSelectedQuestion());
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(getSelectedQuestion());
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(getSelectedQuestion());
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(getSelectedQuestion());
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(getSelectedQuestion());
        }
    });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(getSelectedQuestion(), language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }
}

From source file:com.appspot.socialinquirer.client.view.QuestionViewImpl.java

License:Apache License

/**
 * Instantiates a new question view impl.
 *
 * @param constants the constants// w  w  w.j a v a  2 s  . c  om
 */
public QuestionViewImpl(final EverScribeConstants constants) {
    this.constants = constants;
    answersTable = new CellTable<Answer>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    answersPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    answersPaginator.setDisplay(answersTable);
    final SelectionModel<Answer> answerSelectionModel = new SingleSelectionModel<Answer>(
            new KeyProvider<Answer>());
    answersTable.setSelectionModel(answerSelectionModel,
            DefaultSelectionEventManager.<Answer>createCheckboxManager());
    initTableColumns(answersTable, answerSelectionModel);

    initWidget(uiBinder.createAndBindUi(this));

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(question);
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(question);
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(question);
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(question);
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(question);
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(question);
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(question);
        }
    });

    followQuestionAuthorMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onFollowUserClicked(questionAuthor.getText());
        }
    });

    //       followAnswerAuthorMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowUserClicked(answerAuthor.getText());
    //         }
    //      });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(question, language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }

    answers.setAnimationEnabled(true);
}

From source file:com.appspot.socialinquirer.client.view.QuestionViewImpl.java

License:Apache License

public void setClassifiers(ArrayList<Classifier> classifiers) {
    for (final Classifier item : classifiers) {
        MenuItem menuItem = new MenuItem(item.getName(), new Command() {

            @Override/*from ww w  .  j av a  2 s. co m*/
            public void execute() {
                presenter.onClassifyClicked(question, item);
            }
        });
        menuItem.setEnabled(true);
        classifierBar.addItem(menuItem);
    }

}