Search in sources :

Example 11 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class PresentationPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    boolean isTutorial = session_.getSessionInfo().getPresentationState().isTutorial();
    Toolbar toolbar = new Toolbar();
    slideNavigationMenu_ = new SlideNavigationToolbarMenu(toolbar);
    slideNavigationMenu_.setEditButtonVisible(!isTutorial);
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(commands_.presentationFullscreen().createToolbarButton());
    // More
    if (!isTutorial) {
        ToolbarPopupMenu moreMenu = new ToolbarPopupMenu();
        moreMenu.addItem(commands_.clearPresentationCache().createMenuItem(false));
        moreMenu.addSeparator();
        moreMenu.addItem(commands_.presentationViewInBrowser().createMenuItem(false));
        moreMenu.addItem(commands_.presentationSaveAsStandalone().createMenuItem(false));
        ToolbarButton moreButton = new ToolbarButton("More", new ImageResource2x(StandardIcons.INSTANCE.more_actions2x()), moreMenu);
        toolbar.addRightWidget(moreButton);
        // Create the publish button and wire it to our HTML generator
        publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_PRES, false, null);
        publishButton_.setPublishHtmlSource(new PublishHtmlSource() {

            @Override
            public void generatePublishHtml(final CommandWithArg<String> onCompleted) {
                server_.createPresentationRPubsSource(new SimpleRequestCallback<PresentationRPubsSource>() {

                    @Override
                    public void onResponseReceived(PresentationRPubsSource source) {
                        onCompleted.execute(source.getSourceFilePath());
                    }

                    @Override
                    public void onError(ServerError error) {
                        display_.showErrorMessage("Error Saving Presentation", Presentation.getErrorMessage(error));
                    }
                });
            }

            @Override
            public String getTitle() {
                return "Presentation:\n" + getPresentationTitle();
            }
        });
        toolbar.addRightSeparator();
        toolbar.addRightWidget(publishButton_);
    } else {
        toolbar.addRightWidget(commands_.tutorialFeedback().createToolbarButton());
    }
    toolbar.addRightSeparator();
    toolbar.addRightWidget(refreshButton_ = commands_.refreshPresentation().createToolbarButton());
    progressButton_ = new ToolbarButton(CoreResources.INSTANCE.progress_gray(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent e) {
        }
    });
    toolbar.addRightWidget(progressButton_);
    progressButton_.setVisible(false);
    return toolbar;
}
Also used : ServerError(org.rstudio.studio.client.server.ServerError) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RSConnectPublishButton(org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton) PublishHtmlSource(org.rstudio.studio.client.rsconnect.model.PublishHtmlSource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) SlideNavigationToolbarMenu(org.rstudio.studio.client.common.presentation.SlideNavigationToolbarMenu) PresentationRPubsSource(org.rstudio.studio.client.workbench.views.presentation.model.PresentationRPubsSource) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 12 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class MessageDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    // add image
    MessageDialogImages images = MessageDialogImages.INSTANCE;
    Image image = null;
    switch(type_) {
        case INFO:
            image = new Image(new ImageResource2x(images.dialog_info2x()));
            break;
        case WARNING:
            image = new Image(new ImageResource2x(images.dialog_warning2x()));
            break;
        case ERROR:
            image = new Image(new ImageResource2x(images.dialog_error2x()));
            break;
        case QUESTION:
            image = new Image(new ImageResource2x(images.dialog_question2x()));
            break;
        case POPUP_BLOCKED:
            image = new Image(new ImageResource2x(images.dialog_popup_blocked2x()));
            break;
    }
    horizontalPanel.add(image);
    // add message widget
    horizontalPanel.add(messageWidget_);
    return horizontalPanel;
}
Also used : MessageDialogImages(org.rstudio.core.client.widget.images.MessageDialogImages) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 13 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class RPubsUploadDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    Styles styles = RESOURCES.styles();
    SimplePanel mainPanel = new SimplePanel();
    mainPanel.addStyleName(styles.mainWidget());
    VerticalPanel verticalPanel = new VerticalPanel();
    HorizontalPanel headerPanel = new HorizontalPanel();
    headerPanel.addStyleName(styles.headerPanel());
    headerPanel.add(new Image(new ImageResource2x(RESOURCES.publishLarge2x())));
    Label headerLabel = new Label("Publish to RPubs");
    headerLabel.addStyleName(styles.headerLabel());
    headerPanel.add(headerLabel);
    headerPanel.setCellVerticalAlignment(headerLabel, HasVerticalAlignment.ALIGN_MIDDLE);
    verticalPanel.add(headerPanel);
    String msg;
    if (!isPublished_ && uploadId_.isEmpty()) {
        msg = "RPubs is a free service from RStudio for sharing " + "documents on the web. Click Publish to get " + "started.";
    } else {
        msg = "This document has already been published on RPubs. You can " + "choose to either update the existing RPubs document, or " + "create a new one.";
    }
    Label descLabel = new Label(msg);
    descLabel.addStyleName(styles.descLabel());
    verticalPanel.add(descLabel);
    // if we have a generator then show title and comment UI
    if (htmlGenerator_ != null) {
        Label titleLabel = new Label("Title (optional):");
        titleLabel.addStyleName(styles.fieldLabel());
        verticalPanel.add(titleLabel);
        titleTextBox_ = new TextBox();
        titleTextBox_.addStyleName(styles.titleTextBox());
        titleTextBox_.getElement().setAttribute("spellcheck", "false");
        verticalPanel.add(titleTextBox_);
        Label commentLabel = new Label("Comment (optional):");
        commentLabel.addStyleName(styles.fieldLabel());
        verticalPanel.add(commentLabel);
        commentTextArea_ = new FixedTextArea(6);
        commentTextArea_.addStyleName(styles.commentTextArea());
        verticalPanel.add(commentTextArea_);
        // not using either for now
        titleLabel.setVisible(false);
        titleTextBox_.setVisible(false);
        commentLabel.setVisible(false);
        commentTextArea_.setVisible(false);
        previewButton_ = new ThemedButton("Preview");
        previewButton_.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                htmlGenerator_.generateStaticHtml(titleTextBox_.getText().trim(), commentTextArea_.getText().trim(), new CommandWithArg<String>() {

                    @Override
                    public void execute(String rpubsFile) {
                        globalDisplay_.showHtmlFile(rpubsFile);
                    }
                });
            }
        });
        addLeftButton(previewButton_);
    }
    HTML warningLabel = new HTML("<strong>IMPORTANT: All documents published to RPubs are " + "publicly visible.</strong> You should " + "only publish documents that you wish to share publicly.");
    warningLabel.addStyleName(styles.warningLabel());
    verticalPanel.add(warningLabel);
    ThemedButton cancelButton = createCancelButton(new Operation() {

        @Override
        public void execute() {
            // if an upload is in progress then terminate it
            if (uploader_.isUploadInProgress()) {
                uploader_.terminateUpload();
            }
        }
    });
    continueButton_ = new ThemedButton("Publish", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(false);
        }
    });
    updateButton_ = new ThemedButton("Update Existing", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(true);
        }
    });
    createButton_ = new ThemedButton("Create New", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            performUpload(false);
        }
    });
    if (!isPublished_ && uploadId_.isEmpty()) {
        addOkButton(continueButton_);
        addCancelButton(cancelButton);
    } else {
        addOkButton(updateButton_);
        addButton(createButton_);
        addCancelButton(cancelButton);
    }
    mainPanel.setWidget(verticalPanel);
    return mainPanel;
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) TextBox(com.google.gwt.user.client.ui.TextBox) CommandWithArg(org.rstudio.core.client.CommandWithArg) Operation(org.rstudio.core.client.widget.Operation) Image(com.google.gwt.user.client.ui.Image) ProgressImage(org.rstudio.core.client.widget.ProgressImage) ThemedButton(org.rstudio.core.client.widget.ThemedButton) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) FixedTextArea(org.rstudio.core.client.widget.FixedTextArea) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 14 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class WebApplicationHeader method initCommandsPanel.

private void initCommandsPanel(final SessionInfo sessionInfo) {
    // add username 
    if (sessionInfo.getShowIdentity()) {
        ToolbarLabel usernameLabel = new ToolbarLabel();
        usernameLabel.getElement().getStyle().setMarginRight(2, Unit.PX);
        if (!BrowseCap.isFirefox())
            usernameLabel.getElement().getStyle().setMarginTop(2, Unit.PX);
        String userIdentity = sessionInfo.getUserIdentity();
        usernameLabel.setTitle(userIdentity);
        userIdentity = userIdentity.split("@")[0];
        usernameLabel.setText(userIdentity);
        headerBarCommandsPanel_.add(usernameLabel);
        ToolbarButton signOutButton = new ToolbarButton(new ImageResource2x(RESOURCES.signOut2x()), new ClickHandler() {

            public void onClick(ClickEvent event) {
                eventBus_.fireEvent(new LogoutRequestedEvent());
            }
        });
        signOutButton.setTitle("Sign out");
        headerBarCommandsPanel_.add(signOutButton);
        headerBarCommandsPanel_.add(signOutSeparator_ = createCommandSeparator());
    }
    overlay_.addCommands(this);
    headerBarCommandsPanel_.add(commands_.quitSession().createToolbarButton());
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) LogoutRequestedEvent(org.rstudio.studio.client.application.events.LogoutRequestedEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ToolbarLabel(org.rstudio.core.client.widget.ToolbarLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 15 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class PackagesPane method initPackagesTable.

private void initPackagesTable() {
    packagesTable_.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    packagesTable_.setSelectionModel(new NoSelectionModel<PackageInfo>());
    LoadedColumn loadedColumn = new LoadedColumn();
    NameColumn nameColumn = new NameColumn();
    Column<PackageInfo, PackageInfo> descColumn = new Column<PackageInfo, PackageInfo>(new DescriptionCell()) {

        @Override
        public PackageInfo getValue(PackageInfo object) {
            return object;
        }
    };
    Column<PackageInfo, PackageInfo> versionColumn = new Column<PackageInfo, PackageInfo>(new VersionCell(false)) {

        @Override
        public PackageInfo getValue(PackageInfo object) {
            return object;
        }
    };
    ImageButtonColumn<PackageInfo> removeColumn = new ImageButtonColumn<PackageInfo>(new ImageResource2x(ThemeResources.INSTANCE.removePackage2x()), new OperationWithInput<PackageInfo>() {

        @Override
        public void execute(PackageInfo packageInfo) {
            observer_.removePackage(packageInfo);
        }
    }, "Remove package");
    // add common columns
    packagesTable_.addColumn(loadedColumn, new TextHeader(""));
    packagesTable_.addColumn(nameColumn, new TextHeader("Name"));
    packagesTable_.addColumn(descColumn, new TextHeader("Description"));
    packagesTable_.addColumn(versionColumn, new TextHeader("Version"));
    packagesTable_.setColumnWidth(loadedColumn, 30, Unit.PX);
    // set up Packrat-specific columns
    if (packratContext_ != null && packratContext_.isModeOn()) {
        Column<PackageInfo, PackageInfo> packratVersionColumn = new Column<PackageInfo, PackageInfo>(new VersionCell(true)) {

            @Override
            public PackageInfo getValue(PackageInfo object) {
                return object;
            }
        };
        TextColumn<PackageInfo> packratSourceColumn = new TextColumn<PackageInfo>() {

            @Override
            public String getValue(PackageInfo pkgInfo) {
                if (pkgInfo.getInPackratLibary()) {
                    String source = pkgInfo.getPackratSource();
                    if (source.equals("github"))
                        return "GitHub";
                    else if (source.equals("Bioconductor"))
                        return "BioC";
                    else if (source.equals("source"))
                        return "Source";
                    else
                        return source;
                } else
                    return "";
            }
        };
        packagesTable_.addColumn(packratVersionColumn, new TextHeader("Packrat"));
        packagesTable_.addColumn(packratSourceColumn, new TextHeader("Source"));
        // distribute columns for extended package information
        packagesTable_.setColumnWidth(nameColumn, 20, Unit.PCT);
        packagesTable_.setColumnWidth(descColumn, 40, Unit.PCT);
        packagesTable_.setColumnWidth(versionColumn, 15, Unit.PCT);
        packagesTable_.setColumnWidth(packratVersionColumn, 15, Unit.PCT);
        packagesTable_.setColumnWidth(packratSourceColumn, 10, Unit.PCT);
        // highlight rows that are out of sync in packrat
        packagesTable_.setRowStyles(new PackageRowStyles());
    } else {
        // distribute columns for non-extended package information
        packagesTable_.setColumnWidth(nameColumn, 25, Unit.PCT);
        packagesTable_.setColumnWidth(descColumn, 60, Unit.PCT);
        packagesTable_.setColumnWidth(versionColumn, 15, Unit.PCT);
    }
    // remove column is common
    packagesTable_.addColumn(removeColumn, new TextHeader(""));
    packagesTable_.setColumnWidth(removeColumn, 35, Unit.PX);
    packagesTable_.setTableBuilder(new PackageTableBuilder(packagesTable_));
    packagesTable_.setSkipRowHoverCheck(true);
    packagesTableContainer_.add(packagesTable_);
    layoutPackagesTable();
    packagesDataProvider_.addDataDisplay(packagesTable_);
}
Also used : PackageInfo(org.rstudio.studio.client.workbench.views.packages.model.PackageInfo) TextHeader(com.google.gwt.user.cellview.client.TextHeader) ImageButtonColumn(org.rstudio.core.client.cellview.ImageButtonColumn) ImageButtonColumn(org.rstudio.core.client.cellview.ImageButtonColumn) LinkColumn(org.rstudio.core.client.cellview.LinkColumn) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)13 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)13 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)11 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)10 ImageResource (com.google.gwt.resources.client.ImageResource)9 Image (com.google.gwt.user.client.ui.Image)7 Toolbar (org.rstudio.core.client.widget.Toolbar)6 Style (com.google.gwt.dom.client.Style)4 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Element (com.google.gwt.dom.client.Element)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 TextColumn (com.google.gwt.user.cellview.client.TextColumn)3 Event (com.google.gwt.user.client.Event)3 HTML (com.google.gwt.user.client.ui.HTML)3 Label (com.google.gwt.user.client.ui.Label)3 MessageDialogImages (org.rstudio.core.client.widget.images.MessageDialogImages)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)2 Column (com.google.gwt.user.cellview.client.Column)2