Search in sources :

Example 31 with ImageResource2x

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

the class ProjectPopupMenu method getToolbarButton.

public ToolbarButton getToolbarButton() {
    if (toolbarButton_ == null) {
        String buttonText = activeProjectFile_ != null ? mruList_.getQualifiedLabel(activeProjectFile_) : "Project: (None)";
        toolbarButton_ = new ToolbarButton(buttonText, new ImageResource2x(RESOURCES.projectMenu2x()), this, true);
        if (activeProjectFile_ != null) {
            toolbarButton_.setTitle(activeProjectFile_);
            // also set the doc title so the browser tab carries the project
            if (!Desktop.isDesktop())
                Document.get().setTitle("RStudio - " + buttonText);
        }
        if (activeProjectFile_ == null) {
            toolbarButton_.addStyleName(ThemeResources.INSTANCE.themeStyles().emptyProjectMenu());
        }
    }
    return toolbarButton_;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 32 with ImageResource2x

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

the class FullscreenPopupPanel method addCloseButton.

private void addCloseButton(NineUpBorder border) {
    Image closeIcon = new Image(new ImageResource2x(RES.close2x()));
    closeIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);
    closeIcon.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            close();
        }
    });
    LayoutPanel layoutPanel = border.getLayoutPanel();
    layoutPanel.add(closeIcon);
    layoutPanel.setWidgetTopHeight(closeIcon, 15, Unit.PX, closeIcon.getHeight(), Unit.PX);
    layoutPanel.setWidgetRightWidth(closeIcon, 27, Unit.PX, closeIcon.getWidth(), Unit.PX);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Image(com.google.gwt.user.client.ui.Image) LayoutPanel(com.google.gwt.user.client.ui.LayoutPanel)

Example 33 with ImageResource2x

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

the class WebApplicationHeader method initialize.

@Inject
public void initialize(final Commands commands, EventBus eventBus, GlobalDisplay globalDisplay, ThemeResources themeResources, final Session session, Provider<CodeSearch> pCodeSearch) {
    commands_ = commands;
    eventBus_ = eventBus;
    globalDisplay_ = globalDisplay;
    overlay_ = new WebApplicationHeaderOverlay();
    // Use the outer panel to just aggregate the menu bar/account area,
    // with the logo. The logo can't be inside the HorizontalPanel because
    // it needs to overflow out of the top of the panel, and it was much
    // easier to do this with absolute positioning.
    outerPanel_ = new FlowPanel();
    outerPanel_.getElement().getStyle().setPosition(Position.RELATIVE);
    // large logo
    logoLarge_ = new Image(new ImageResource2x(ThemeResources.INSTANCE.rstudio2x()));
    ((ImageElement) logoLarge_.getElement().cast()).setAlt("RStudio");
    logoLarge_.getElement().getStyle().setBorderWidth(0, Unit.PX);
    // small logo
    logoSmall_ = new Image(new ImageResource2x(ThemeResources.INSTANCE.rstudio_small2x()));
    ((ImageElement) logoSmall_.getElement().cast()).setAlt("RStudio");
    logoSmall_.getElement().getStyle().setBorderWidth(0, Unit.PX);
    // link target for logo
    logoAnchor_ = new Anchor();
    Style style = logoAnchor_.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTop(5, Unit.PX);
    style.setLeft(18, Unit.PX);
    style.setTextDecoration(TextDecoration.NONE);
    style.setOutlineWidth(0, Unit.PX);
    // header container
    headerBarPanel_ = new HorizontalPanel();
    headerBarPanel_.setStylePrimaryName(themeResources.themeStyles().header());
    headerBarPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    headerBarPanel_.setWidth("100%");
    if (BrowseCap.INSTANCE.suppressBrowserForwardBack())
        suppressBrowserForwardBack();
    // override Cmd+W keybaord shortcut for Chrome
    if (BrowseCap.isChrome()) {
        int modifiers = (BrowseCap.hasMetaKey() ? KeyboardShortcut.META : KeyboardShortcut.CTRL) | KeyboardShortcut.ALT;
        AppCommand closeSourceDoc = commands.closeSourceDoc();
        closeSourceDoc.setShortcut(new KeyboardShortcut(modifiers, 'W'));
        ShortcutManager.INSTANCE.register(modifiers, 'W', closeSourceDoc, "", "", "");
    }
    // main menu
    advertiseEditingShortcuts(globalDisplay, commands);
    WebMenuCallback menuCallback = new WebMenuCallback();
    commands.mainMenu(menuCallback);
    mainMenu_ = menuCallback.getMenu();
    mainMenu_.setAutoHideRedundantSeparators(false);
    fixup(mainMenu_);
    mainMenu_.addStyleName(themeResources.themeStyles().mainMenu());
    AppMenuBar.addSubMenuVisibleChangedHandler(new SubMenuVisibleChangedHandler() {

        public void onSubMenuVisibleChanged(SubMenuVisibleChangedEvent event) {
            // so that mouse clicks can make the menus disappear
            if (event.isVisible())
                eventBus_.fireEvent(new GlassVisibilityEvent(true));
            else
                eventBus_.fireEvent(new GlassVisibilityEvent(false));
        }
    });
    headerBarPanel_.add(mainMenu_);
    // commands panel (no widgets added until after session init)
    headerBarCommandsPanel_ = new HorizontalPanel();
    headerBarCommandsPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    headerBarCommandsPanel_.setWidth("100%");
    headerBarPanel_.add(headerBarCommandsPanel_);
    headerBarPanel_.setCellWidth(headerBarCommandsPanel_, "100%");
    headerBarPanel_.setCellHorizontalAlignment(headerBarCommandsPanel_, HorizontalPanel.ALIGN_RIGHT);
    eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {

        public void onSessionInit(SessionInitEvent sie) {
            SessionInfo sessionInfo = session.getSessionInfo();
            // complete toolbar initialization
            toolbar_.completeInitialization(sessionInfo);
            // add project tools to main menu
            projectMenuSeparator_ = createCommandSeparator();
            headerBarPanel_.add(projectMenuSeparator_);
            projectMenuButton_ = new ProjectPopupMenu(sessionInfo, commands).getToolbarButton();
            projectMenuButton_.addStyleName(ThemeStyles.INSTANCE.webHeaderBarCommandsProjectMenu());
            headerBarPanel_.add(projectMenuButton_);
            showProjectMenu(!toolbar_.isVisible());
            // record logo target url (if any)
            logoTargetUrl_ = sessionInfo.getUserHomePageUrl();
            if (logoTargetUrl_ != null) {
                logoAnchor_.setHref(logoTargetUrl_);
                logoAnchor_.setTitle("RStudio Server Home");
                logoLarge_.setResource(new ImageResource2x(ThemeResources.INSTANCE.rstudio_home2x()));
                logoSmall_.setResource(new ImageResource2x(ThemeResources.INSTANCE.rstudio_home_small2x()));
            } else {
                // no link, so ensure this doesn't get styled as clickable
                logoAnchor_.getElement().getStyle().setCursor(Cursor.DEFAULT);
            }
            // init commands panel in server mode
            if (!Desktop.isDesktop())
                initCommandsPanel(sessionInfo);
            // notify overlay of global toolbar state
            overlay_.setGlobalToolbarVisible(WebApplicationHeader.this, toolbar_.isVisible());
        }
    });
    // create toolbar
    toolbar_ = new GlobalToolbar(commands, eventBus, pCodeSearch);
    toolbar_.addStyleName(themeResources.themeStyles().webGlobalToolbar());
    // create host for project commands
    projectBarCommandsPanel_ = new HorizontalPanel();
    toolbar_.addRightWidget(projectBarCommandsPanel_);
    // initialize widget
    initWidget(outerPanel_);
}
Also used : SessionInitEvent(org.rstudio.studio.client.workbench.events.SessionInitEvent) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) ProjectPopupMenu(org.rstudio.studio.client.application.ui.ProjectPopupMenu) SessionInitHandler(org.rstudio.studio.client.workbench.events.SessionInitHandler) GlassVisibilityEvent(org.rstudio.core.client.widget.events.GlassVisibilityEvent) ImageElement(com.google.gwt.dom.client.ImageElement) WebMenuCallback(org.rstudio.core.client.command.impl.WebMenuCallback) GlobalToolbar(org.rstudio.studio.client.application.ui.GlobalToolbar) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Style(com.google.gwt.dom.client.Style) Inject(com.google.inject.Inject)

Example 34 with ImageResource2x

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

the class FileTypeRegistry method getIconForFilename.

public ImageResource getIconForFilename(String filename) {
    ImageResource icon = iconsByFilename_.get(filename.toLowerCase());
    if (icon != null)
        return icon;
    String ext = FileSystemItem.getExtensionFromPath(filename);
    icon = iconsByFileExtension_.get(ext.toLowerCase());
    if (icon != null)
        return icon;
    return new ImageResource2x(ICONS.iconText2x());
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 35 with ImageResource2x

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

the class RSConnect method onRSConnectDeploymentFailed.

@Override
public void onRSConnectDeploymentFailed(final RSConnectDeploymentFailedEvent event) {
    String failedPath = event.getData().getPath();
    // if this looks like an API call, process the path to get the 'bare'
    // server URL
    int pos = failedPath.indexOf("__api__");
    if (pos < 1) {
        // if not, just get the host
        pos = failedPath.indexOf("/", 10) + 1;
    }
    if (pos > 0) {
        failedPath = failedPath.substring(0, pos);
    }
    final String serverUrl = failedPath;
    new ModalDialogBase() {

        @Override
        protected Widget createMainWidget() {
            setText("Publish Failed");
            addOkButton(new ThemedButton("OK", new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    closeDialog();
                }
            }));
            HorizontalPanel panel = new HorizontalPanel();
            Image errorImage = new Image(new ImageResource2x(MessageDialogImages.INSTANCE.dialog_error2x()));
            errorImage.getElement().getStyle().setMarginTop(1, Unit.EM);
            errorImage.getElement().getStyle().setMarginRight(1, Unit.EM);
            panel.add(errorImage);
            panel.add(new HTML("<p>Your content could not be published because " + "of a problem on the server.</p>" + "<p>More information may be available on the server's home " + "page:</p>" + "<p><a href=\"" + serverUrl + "\">" + serverUrl + "</a>" + "</p>" + "<p>If the error persists, contact the server's " + "administrator.</p>" + "<p><small>Error code: " + event.getData().getHttpStatus() + "</small></p>"));
            return panel;
        }
    }.showModal();
}
Also used : ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ModalDialogBase(org.rstudio.core.client.widget.ModalDialogBase) Widget(com.google.gwt.user.client.ui.Widget) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) HTML(com.google.gwt.user.client.ui.HTML) JsArrayString(com.google.gwt.core.client.JsArrayString) Image(com.google.gwt.user.client.ui.Image)

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