use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.
the class RSConnectPublishButton method initialize.
@Inject
public void initialize(RSConnectServerOperations server, RMarkdownServerOperations rmdServer, EventBus events, Commands commands, GlobalDisplay display, Provider<UIPrefs> pUiPrefs, Session session, PlotPublishMRUList plotMru) {
server_ = server;
rmdServer_ = rmdServer;
events_ = events;
commands_ = commands;
display_ = display;
session_ = session;
pUiPrefs_ = pUiPrefs;
plotMru_ = plotMru;
// initialize visibility if requested
if (boundCommand_ != null) {
boundCommand_.addVisibleChangedHandler(new VisibleChangedHandler() {
@Override
public void onVisibleChanged(AppCommand command) {
applyVisiblity();
}
});
boundCommand_.addEnabledChangedHandler(new EnabledChangedHandler() {
@Override
public void onEnabledChanged(AppCommand command) {
applyVisiblity();
}
});
}
events_.addHandler(RSConnectDeploymentCompletedEvent.TYPE, this);
events_.addHandler(RPubsUploadStatusEvent.TYPE, this);
events_.addHandler(RmdRenderCompletedEvent.TYPE, this);
events_.addHandler(HTMLPreviewCompletedEvent.TYPE, this);
}
use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.
the class ConnectionsPane method createMainToolbar.
@Override
protected Toolbar createMainToolbar() {
toolbar_ = new Toolbar();
searchWidget_ = new SearchWidget(new SuggestOracle() {
@Override
public void requestSuggestions(Request request, Callback callback) {
// no suggestions
callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>()));
}
});
backToConnectionsButton_ = new ToolbarButton(commands_.helpBack().getImageResource(), (ClickHandler) null);
backToConnectionsButton_.setTitle("View all connections");
// connect meuu
ToolbarPopupMenu connectMenu = new ToolbarPopupMenu();
connectMenu.addItem(connectMenuItem(commands_.historySendToConsole().getImageResource(), "R Console", ConnectionOptions.CONNECT_R_CONSOLE));
connectMenu.addSeparator();
connectMenu.addItem(connectMenuItem(commands_.newSourceDoc().getImageResource(), "New R Script", ConnectionOptions.CONNECT_NEW_R_SCRIPT));
connectMenu.addItem(connectMenuItem(commands_.newRNotebook().getImageResource(), "New R Notebook", ConnectionOptions.CONNECT_NEW_R_NOTEBOOK));
if (BrowseCap.INSTANCE.canCopyToClipboard()) {
connectMenu.addSeparator();
connectMenu.addItem(connectMenuItem(commands_.copyPlotToClipboard().getImageResource(), "Copy to Clipboard", ConnectionOptions.CONNECT_COPY_TO_CLIPBOARD));
}
connectMenuButton_ = new ToolbarButton("Connect", commands_.newConnection().getImageResource(), connectMenu);
// manage connect menu visibility
connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
commands_.disconnectConnection().addVisibleChangedHandler(new VisibleChangedHandler() {
@Override
public void onVisibleChanged(AppCommand command) {
connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible());
}
});
installConnectionsToolbar();
return toolbar_;
}
use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.
the class PaneManager method manageLayoutCommands.
private void manageLayoutCommands() {
List<AppCommand> layoutCommands = getLayoutCommands();
AppCommand activeCommand = getLayoutCommandForTab(maximizedTab_);
for (AppCommand command : layoutCommands) command.setChecked(activeCommand.equals(command));
// manage console left/right commands
boolean maximized = maximizedTab_ != null;
commands_.layoutConsoleOnLeft().setVisible(!maximized);
commands_.layoutConsoleOnRight().setVisible(!maximized);
if (!maximized) {
PaneConfig config = getCurrentConfig();
commands_.layoutConsoleOnLeft().setChecked(config.getConsoleLeft());
commands_.layoutConsoleOnRight().setChecked(config.getConsoleRight());
} else {
commands_.layoutConsoleOnLeft().setVisible(false);
commands_.layoutConsoleOnRight().setVisible(false);
}
}
use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.
the class SatelliteApplication method initialize.
public void initialize(String name, SatelliteApplicationView view, Satellite satellite, Provider<AceThemes> pAceThemes, ApplicationUncaughtExceptionHandler uncaughtExHandler, Commands commands) {
name_ = name;
view_ = view;
satellite_ = satellite;
pAceThemes_ = pAceThemes;
uncaughtExHandler_ = uncaughtExHandler;
commands.showRequestLog().addHandler(new CommandHandler() {
public void onCommand(AppCommand command) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
Window.alert(reason.toString());
}
public void onSuccess() {
final RequestLogVisualization viz = new RequestLogVisualization();
final RootLayoutPanel root = RootLayoutPanel.get();
root.add(viz);
root.setWidgetTopBottom(viz, 10, Unit.PX, 10, Unit.PX);
root.setWidgetLeftRight(viz, 10, Unit.PX, 10, Unit.PX);
viz.addCloseHandler(new CloseHandler<RequestLogVisualization>() {
public void onClose(CloseEvent<RequestLogVisualization> event) {
root.remove(viz);
}
});
}
});
}
});
}
use of org.rstudio.core.client.command.AppCommand in project rstudio by rstudio.
the class ProjectPopupMenu method rebuildMenu.
private void rebuildMenu(final JsArray<SharedProjectDetails> sharedProjects, DynamicPopupMenuCallback callback) {
// clean out existing entries
clearItems();
boolean hasSharedProjects = sharedProjects != null && sharedProjects.length() > 0;
int maxMruEntries = MAX_MRU_ENTRIES;
// shared projects are always shown, and count against the MRU limit
if (hasSharedProjects)
maxMruEntries -= Math.min(sharedProjects.length(), MAX_SHARED_PROJECTS);
addItem(commands_.newProject().createMenuItem(false));
// ensure the menu doesn't get too narrow
addSeparator(225);
addItem(commands_.openProject().createMenuItem(false));
if (Desktop.isDesktop())
addItem(commands_.openProjectInNewWindow().createMenuItem(false));
addItem(commands_.closeProject().createMenuItem(false));
addSeparator();
addItem(commands_.shareProject().createMenuItem(false));
if (hasSharedProjects)
addSeparator("Recent Projects");
else
addSeparator();
// add as many MRU items as is appropriate for our screen size and number
// of shared projects
AppCommand[] mruCommands = new AppCommand[] { commands_.projectMru0(), commands_.projectMru1(), commands_.projectMru2(), commands_.projectMru3(), commands_.projectMru4(), commands_.projectMru5(), commands_.projectMru6(), commands_.projectMru7(), commands_.projectMru8(), commands_.projectMru9(), commands_.projectMru10(), commands_.projectMru11(), commands_.projectMru12(), commands_.projectMru13(), commands_.projectMru14() };
for (int i = 0; i < Math.min(maxMruEntries, mruCommands.length); i++) {
addItem(mruCommands[i].createMenuItem(false));
}
// show shared projects if enabled
if (hasSharedProjects) {
addSeparator("Shared with Me");
for (int i = 0; i < Math.min(sharedProjects.length(), MAX_SHARED_PROJECTS); i++) {
final SharedProjectDetails details = sharedProjects.get(i);
String menuHtml = AppCommand.formatMenuLabel(null, details.getName(), false, null, commands_.openHtmlExternal().getImageResource(), ProjectMRUList.NEW_SESSION_DESC);
addItem(new MenuItem(menuHtml, true, new Scheduler.ScheduledCommand() {
@Override
public void execute() {
ProjectMRUList.openProjectFromMru(events_, details.getProjectFile());
}
}));
}
// displayed, offer a link
if (sharedProjects.length() > MAX_SHARED_PROJECTS) {
addItem(commands_.openSharedProject().createMenuItem(false));
}
}
addSeparator();
addItem(commands_.clearRecentProjects().createMenuItem(false));
addSeparator();
addItem(commands_.projectOptions().createMenuItem(false));
callback.onPopupMenu(this);
}
Aggregations