Search in sources :

Example 16 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class PlotPublishMRUList method addPlotMruEntries.

public void addPlotMruEntries(ToolbarPopupMenu menu, final OperationWithInput<Entry> onSelected) {
    for (String entry : plotMruList_) {
        final Entry mruEntry = Entry.fromText(entry);
        if (entry == null)
            continue;
        // format the display name: pick title if specified, name if not
        String displayName = StringUtil.isNullOrEmpty(mruEntry.title) ? mruEntry.name : mruEntry.title;
        displayName += " (" + mruEntry.server + ")";
        menu.addItem(new MenuItem(AppCommand.formatMenuLabel(RSConnectResources.INSTANCE.republishPlot2x(), displayName, null), true, new Command() {

            @Override
            public void execute() {
                onSelected.execute(mruEntry);
            }
        }));
    }
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Example 17 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class RSConnectPublishButton method setPreviousDeployments.

private void setPreviousDeployments(JsArray<RSConnectDeploymentRecord> recs) {
    // clear existing deployment menu, if any
    publishMenu_.clearItems();
    defaultRec_ = null;
    // republish
    if (recs != null && recs.length() > 0) {
        applyCaption("Republish");
        // pass 
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            if (rec == null)
                continue;
            if (defaultRec_ == null || defaultRec_.getWhen() < rec.getWhen()) {
                defaultRec_ = rec;
            }
        }
        // build the deployment menu
        for (int i = 0; i < recs.length(); i++) {
            final RSConnectDeploymentRecord rec = recs.get(i);
            final DeploymentMenuItem menuItem = new DeploymentMenuItem(rec, rec == defaultRec_, new Command() {

                @Override
                public void execute() {
                    onPublishRecordClick(rec);
                }
            });
            publishMenu_.addItem(menuItem);
        }
        publishMenu_.addSeparator();
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Other Destination...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(null);
            }
        }));
    } else {
        // show first-time publish button caption
        applyCaption("Publish");
        // no existing deployments to redeploy to, so just offer to make a new
        // one
        publishMenu_.addItem(new MenuItem(AppCommand.formatMenuLabel(commands_.rsconnectDeploy().getImageResource(), "Publish " + RSConnect.contentTypeDesc(contentType_) + "...", null), true, new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                onPublishRecordClick(defaultRec_);
            }
        }));
    }
    // if it's a plot, show an MRU of recently deployed plot "names"
    if (contentType_ == RSConnect.CONTENT_TYPE_PLOT) {
        plotMru_.addPlotMruEntries(publishMenu_, new OperationWithInput<PlotPublishMRUList.Entry>() {

            @Override
            public void execute(Entry plot) {
                republishPlot(plot);
            }
        });
    }
    publishMenu_.addSeparator();
    publishMenu_.addItem(commands_.rsconnectManageAccounts().createMenuItem(false));
}
Also used : Entry(org.rstudio.studio.client.rsconnect.model.PlotPublishMRUList.Entry) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) MenuItem(com.google.gwt.user.client.ui.MenuItem) RSConnectDeploymentRecord(org.rstudio.studio.client.rsconnect.model.RSConnectDeploymentRecord)

Example 18 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class FilesPane method showDataImportFileChoice.

@Override
public void showDataImportFileChoice(FileSystemItem file, Command onView, Command onImport) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();
    String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "View File", null);
    String importLabel = AppCommand.formatMenuLabel(new ImageResource2x(StandardIcons.INSTANCE.import_dataset2x()), "Import Dataset...", null);
    menu.addItem(new MenuItem(editLabel, true, onView));
    menu.addItem(new MenuItem(importLabel, true, onImport));
    menu.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            Event event = Event.getCurrentEvent();
            PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Event(com.google.gwt.user.client.Event) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Example 19 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class FilesPane method showHtmlFileChoice.

@Override
public void showHtmlFileChoice(FileSystemItem file, Command onEdit, Command onBrowse) {
    final ToolbarPopupMenu menu = new ToolbarPopupMenu();
    String editLabel = AppCommand.formatMenuLabel(commands_.renameFile().getImageResource(), "Open in Editor", null);
    String openLabel = AppCommand.formatMenuLabel(commands_.openHtmlExternal().getImageResource(), "View in Web Browser", null);
    menu.addItem(new MenuItem(editLabel, true, onEdit));
    menu.addItem(new MenuItem(openLabel, true, onBrowse));
    menu.setPopupPositionAndShow(new PositionCallback() {

        @Override
        public void setPosition(int offsetWidth, int offsetHeight) {
            Event event = Event.getCurrentEvent();
            PopupPositioner.setPopupPosition(menu, event.getClientX(), event.getClientY());
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Event(com.google.gwt.user.client.Event) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Example 20 with MenuItem

use of com.google.gwt.user.client.ui.MenuItem in project rstudio by rstudio.

the class TextEditingTarget method showStatusBarPopupMenu.

private void showStatusBarPopupMenu(StatusBarPopupRequest popupRequest) {
    final StatusBarPopupMenu menu = popupRequest.getMenu();
    MenuItem defaultItem = popupRequest.getDefaultMenuItem();
    if (defaultItem != null) {
        menu.selectItem(defaultItem);
        Scheduler.get().scheduleFinally(new RepeatingCommand() {

            public boolean execute() {
                menu.ensureSelectedIsVisible();
                return false;
            }
        });
    }
    menu.showRelativeToUpward((UIObject) statusBar_.getScope(), false);
}
Also used : StatusBarPopupMenu(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Aggregations

MenuItem (com.google.gwt.user.client.ui.MenuItem)24 Command (com.google.gwt.user.client.Command)8 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)7 AppCommand (org.rstudio.core.client.command.AppCommand)7 MenuBar (com.google.gwt.user.client.ui.MenuBar)5 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 Test (org.junit.Test)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)3 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)3 StatusBarPopupMenu (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu)3 Scheduler (com.google.gwt.core.client.Scheduler)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 Event (com.google.gwt.user.client.Event)2 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)2 SlideNavigationItem (org.rstudio.studio.client.common.presentation.model.SlideNavigationItem)2 StatusBarPopupRequest (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest)2 JsArray (com.google.gwt.core.client.JsArray)1 Label (com.google.gwt.user.client.ui.Label)1 UIObject (com.google.gwt.user.client.ui.UIObject)1