Search in sources :

Example 1 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project che by eclipse.

the class GithubImporterPageViewImpl method createRepositoriesTable.

/**
     * Creates table what contains list of available repositories.
     *
     * @param resources
     */
private void createRepositoriesTable(final Resources resources, GitHubLocalizationConstant locale) {
    repositories = new CellTable<>(15, resources);
    Column<ProjectData, ImageResource> iconColumn = new Column<ProjectData, ImageResource>(new ImageResourceCell()) {

        @Override
        public ImageResource getValue(ProjectData item) {
            return null;
        }
    };
    Column<ProjectData, SafeHtml> repositoryColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(final ProjectData item) {
            return SafeHtmlUtils.fromString(item.getName());
        }
    };
    Column<ProjectData, SafeHtml> descriptionColumn = new Column<ProjectData, SafeHtml>(new SafeHtmlCell()) {

        @Override
        public SafeHtml getValue(final ProjectData item) {
            return new SafeHtmlBuilder().appendHtmlConstant("<span>").appendEscaped(item.getDescription() == null ? "" : item.getDescription()).appendHtmlConstant("</span>").toSafeHtml();
        }
    };
    repositories.addColumn(iconColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    repositories.setColumnWidth(iconColumn, 28, Style.Unit.PX);
    repositories.addColumn(repositoryColumn, locale.samplesListRepositoryColumn());
    repositories.addColumn(descriptionColumn, locale.samplesListDescriptionColumn());
    // don't show loading indicator
    repositories.setLoadingIndicator(null);
    final SingleSelectionModel<ProjectData> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            ProjectData selectedObject = selectionModel.getSelectedObject();
            delegate.onRepositorySelected(selectedObject);
        }
    });
    repositories.setSelectionModel(selectionModel);
}
Also used : SingleSelectionModel(com.google.gwt.view.client.SingleSelectionModel) SafeHtmlCell(com.google.gwt.cell.client.SafeHtmlCell) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) ImageResource(com.google.gwt.resources.client.ImageResource) Column(com.google.gwt.user.cellview.client.Column) ImageResourceCell(com.google.gwt.cell.client.ImageResourceCell) ProjectData(org.eclipse.che.plugin.github.ide.load.ProjectData)

Example 2 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project rstudio by rstudio.

the class TextEditingTargetWidget method createCodeTransformMenuButton.

private Widget createCodeTransformMenuButton() {
    if (codeTransform_ == null) {
        ImageResource icon = new ImageResource2x(ThemeResources.INSTANCE.codeTransform2x());
        ToolbarPopupMenu menu = new ToolbarPopupMenu();
        menu.addItem(commands_.codeCompletion().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.goToHelp().createMenuItem(false));
        menu.addItem(commands_.goToFunctionDefinition().createMenuItem(false));
        menu.addItem(commands_.findUsages().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.extractFunction().createMenuItem(false));
        menu.addItem(commands_.extractLocalVariable().createMenuItem(false));
        menu.addItem(commands_.renameInScope().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.reflowComment().createMenuItem(false));
        menu.addItem(commands_.commentUncomment().createMenuItem(false));
        menu.addItem(commands_.insertRoxygenSkeleton().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.reindent().createMenuItem(false));
        menu.addItem(commands_.reformatCode().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.showDiagnosticsActiveDocument().createMenuItem(false));
        menu.addItem(commands_.showDiagnosticsProject().createMenuItem(false));
        menu.addSeparator();
        menu.addItem(commands_.profileCode().createMenuItem(false));
        codeTransform_ = new ToolbarButton("", icon, menu);
        codeTransform_.setTitle("Code Tools");
    }
    return codeTransform_;
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Example 3 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project rstudio by rstudio.

the class TextEditingTargetWidget method setFormatOptions.

@Override
public void setFormatOptions(TextFileType fileType, boolean showRmdFormatMenu, boolean canEditFormatOptions, List<String> options, List<String> values, List<String> extensions, String selectedOption) {
    if (!canEditFormatOptions) {
        setFormatText("");
    }
    setRmdFormatButtonVisible(showRmdFormatMenu);
    rmdFormatButton_.setEnabled(showRmdFormatMenu);
    rmdFormatButton_.clearMenu();
    int parenPos = selectedOption.indexOf('(');
    if (parenPos != -1)
        selectedOption = selectedOption.substring(0, parenPos).trim();
    // don't show format text (but leave the code in for now in case
    // we change our mind)
    // setFormatText(selectedOption);
    setFormatText("");
    String prefix = fileType.isPlainMarkdown() ? "Preview " : "Knit to ";
    for (int i = 0; i < Math.min(options.size(), values.size()); i++) {
        String ext = extensions.get(i);
        ImageResource img = ext != null ? fileTypeRegistry_.getIconForFilename("output." + ext) : fileTypeRegistry_.getIconForFilename("Makefile");
        final String valueName = values.get(i);
        ScheduledCommand cmd = new ScheduledCommand() {

            @Override
            public void execute() {
                handlerManager_.fireEvent(new RmdOutputFormatChangedEvent(valueName));
            }
        };
        String text = ext == ".nb.html" ? "Preview Notebook" : prefix + options.get(i);
        MenuItem item = ImageMenuItem.create(img, text, cmd, 2);
        rmdFormatButton_.addMenuItem(item, values.get(i));
    }
    if (session_.getSessionInfo().getKnitParamsAvailable()) {
        final AppCommand knitWithParams = commands_.knitWithParameters();
        rmdFormatButton_.addSeparator();
        ScheduledCommand cmd = new ScheduledCommand() {

            @Override
            public void execute() {
                knitWithParams.execute();
            }
        };
        MenuItem item = new MenuItem(knitWithParams.getMenuHTML(false), true, cmd);
        rmdFormatButton_.addMenuItem(item, knitWithParams.getMenuLabel(false));
    }
    if (session_.getSessionInfo().getKnitWorkingDirAvailable()) {
        MenuBar knitDirMenu = new MenuBar(true);
        DocPropMenuItem knitInDocDir = new DocShadowPropMenuItem("Document Directory", docUpdateSentinel_, uiPrefs_.knitWorkingDir(), RenderRmdEvent.WORKING_DIR_PROP, UIPrefsAccessor.KNIT_DIR_DEFAULT);
        knitDirMenu.addItem(knitInDocDir);
        DocPropMenuItem knitInProjectDir = new DocShadowPropMenuItem("Project Directory", docUpdateSentinel_, uiPrefs_.knitWorkingDir(), RenderRmdEvent.WORKING_DIR_PROP, UIPrefsAccessor.KNIT_DIR_PROJECT);
        knitDirMenu.addItem(knitInProjectDir);
        DocPropMenuItem knitInCurrentDir = new DocShadowPropMenuItem("Current Working Directory", docUpdateSentinel_, uiPrefs_.knitWorkingDir(), RenderRmdEvent.WORKING_DIR_PROP, UIPrefsAccessor.KNIT_DIR_CURRENT);
        knitDirMenu.addItem(knitInCurrentDir);
        rmdFormatButton_.addSeparator();
        rmdFormatButton_.addMenuItem(knitDirMenu, "Knit Directory");
    }
    addClearKnitrCacheMenu(rmdFormatButton_);
    showRmdViewerMenuItems(true, canEditFormatOptions, fileType.isRmd(), RmdOutput.TYPE_STATIC);
    if (publishButton_ != null)
        publishButton_.setIsStatic(true);
    isShiny_ = false;
}
Also used : AppCommand(org.rstudio.core.client.command.AppCommand) ImageResource(com.google.gwt.resources.client.ImageResource) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RmdOutputFormatChangedEvent(org.rstudio.studio.client.rmarkdown.events.RmdOutputFormatChangedEvent) ImageMenuItem(org.rstudio.studio.client.common.ImageMenuItem)

Example 4 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project rstudio by rstudio.

the class CompilePanel method connectToolbar.

public void connectToolbar(Toolbar toolbar) {
    Commands commands = RStudioGinjector.INSTANCE.getCommands();
    ImageResource stopImage = commands.interruptR().getImageResource();
    stopButton_ = new ToolbarButton(stopImage, null);
    stopButton_.setVisible(false);
    toolbar.addRightWidget(stopButton_);
    showOutputButton_ = new LeftRightToggleButton("Output", "Issues", false);
    showOutputButton_.setVisible(false);
    showOutputButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(false);
            showErrorsButton_.setVisible(true);
            panel_.setWidget(outputDisplay_.asWidget());
            outputDisplay_.scrollToBottom();
        }
    });
    toolbar.addRightWidget(showOutputButton_);
    showErrorsButton_ = new LeftRightToggleButton("Output", "Issues", true);
    showErrorsButton_.setVisible(false);
    showErrorsButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(true);
            showErrorsButton_.setVisible(false);
            panel_.setWidget(errorList_);
        }
    });
    toolbar.addRightWidget(showErrorsButton_);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ImageResource(com.google.gwt.resources.client.ImageResource) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Commands(org.rstudio.studio.client.workbench.commands.Commands) LeftRightToggleButton(org.rstudio.core.client.widget.LeftRightToggleButton)

Example 5 with ImageResource

use of com.google.gwt.resources.client.ImageResource in project rstudio by rstudio.

the class RSConnectDeploy method applySource.

private void applySource() {
    // show the description of what we're about to publish
    if (source_.isSelfContained() && source_.isStatic() && !source_.isWebsiteRmd()) {
        filePanel_.setVisible(false);
        descriptionPanel_.setVisible(true);
        if (contentType_ == RSConnect.CONTENT_TYPE_PLOT || contentType_ == RSConnect.CONTENT_TYPE_HTML) {
            descriptionImage_.setResource(new ImageResource2x(RSConnectResources.INSTANCE.previewPlot2x()));
        } else if (contentType_ == RSConnect.CONTENT_TYPE_PRES) {
            descriptionImage_.setResource(new ImageResource2x(RSConnectResources.INSTANCE.previewPresentation2x()));
        } else {
            descriptionImage_.setResource(new ImageResource2x(RSConnectResources.INSTANCE.previewDoc2x()));
        }
    }
    // (for apps and documents--other content types use temporary filenames)
    if (appName_.getTitle().isEmpty()) {
        if (contentType_ == RSConnect.CONTENT_TYPE_APP || contentType_ == RSConnect.CONTENT_TYPE_APP_SINGLE || contentType_ == RSConnect.CONTENT_TYPE_DOCUMENT) {
            // set the app name to the filename
            String appTitle = FilePathUtils.fileNameSansExtension(source_.getSourceFile());
            // as the content name rather than the file
            if (contentType_ == RSConnect.CONTENT_TYPE_DOCUMENT && appTitle.toLowerCase().equals("index")) {
                appTitle = FilePathUtils.fileNameSansExtension(source_.getDeployDir());
            }
            setUnsanitizedAppName(appTitle);
        } else if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE) {
            setUnsanitizedAppName(FilePathUtils.fileNameSansExtension(source_.getWebsiteDir()));
        }
    }
    ImageResource illustration = null;
    if (contentType_ == RSConnect.CONTENT_TYPE_APP)
        illustration = new ImageResource2x(RESOURCES.publishShinyIllustration2x());
    else if (contentType_ == RSConnect.CONTENT_TYPE_PLOT)
        illustration = new ImageResource2x(RESOURCES.publishPlotIllustration2x());
    else if (contentType_ == RSConnect.CONTENT_TYPE_DOCUMENT)
        illustration = new ImageResource2x(RESOURCES.publishRmdIllustration2x());
    else if (contentType_ == RSConnect.CONTENT_TYPE_HTML)
        illustration = new ImageResource2x(RESOURCES.publishHTMLIllustration2x());
    else if (contentType_ == RSConnect.CONTENT_TYPE_PRES)
        illustration = new ImageResource2x(RESOURCES.publishPresentationIllustration2x());
    if (illustration != null)
        deployIllustration_.setResource(illustration);
}
Also used : ImageResource(com.google.gwt.resources.client.ImageResource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x)

Aggregations

ImageResource (com.google.gwt.resources.client.ImageResource)62 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)24 Image (com.google.gwt.user.client.ui.Image)11 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)9 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)7 Element (com.google.gwt.dom.client.Element)6 Column (com.google.gwt.user.cellview.client.Column)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Test (org.junit.Test)4 ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)3 ArrayList (java.util.ArrayList)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)3 Context (com.google.gwt.cell.client.Cell.Context)2 JsArray (com.google.gwt.core.client.JsArray)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2