Search in sources :

Example 16 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.

the class ConnectionsPane method installConnectionExplorerToolbar.

private void installConnectionExplorerToolbar(final Connection connection) {
    toolbar_.removeAllWidgets();
    toolbar_.addLeftWidget(backToConnectionsButton_);
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(connectMenuButton_);
    toolbar_.addLeftSeparator();
    if (isConnected(connection.getId()) && connection.getActions() != null) {
        // if we have any actions, create a toolbar button for each one
        for (int i = 0; i < connection.getActions().length(); i++) {
            final ConnectionAction action = connection.getActions().get(i);
            // use the supplied base64 icon data if it was provided
            Image icon = StringUtil.isNullOrEmpty(action.getIconData()) ? null : new Image(action.getIconData());
            // force to 20x18
            if (icon != null) {
                icon.setWidth("20px");
                icon.setHeight("18px");
            }
            ToolbarButton button = new ToolbarButton(action.getName(), // left image
            icon, // right image
            null, // invoke the action when the button is clicked
            new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    fireEvent(new ExecuteConnectionActionEvent(connection.getId(), action.getName()));
                }
            });
            // none was supplied
            if (StringUtil.isNullOrEmpty(action.getIconData()))
                button.getElement().getStyle().setMarginTop(-5, Unit.PX);
            toolbar_.addLeftWidget(button);
            toolbar_.addLeftSeparator();
        }
    }
    toolbar_.addLeftWidget(commands_.disconnectConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.removeConnection().createToolbarButton());
    toolbar_.addRightWidget(commands_.refreshConnection().createToolbarButton());
    connectionName_.setText(connection.getDisplayName());
    setSecondaryToolbarVisible(true);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExecuteConnectionActionEvent(org.rstudio.studio.client.workbench.views.connections.events.ExecuteConnectionActionEvent) ConnectionAction(org.rstudio.studio.client.workbench.views.connections.model.ConnectionAction) Image(com.google.gwt.user.client.ui.Image)

Example 17 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.

the class WorkbenchTabPanel method add.

private void add(final WorkbenchTab tab) {
    if (tab.isSuppressed())
        return;
    tabs_.add(tab);
    final Widget widget = tab.asWidget();
    tabPanel_.add(widget, tab.getTitle(), false, !tab.closeable() ? null : new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tab.confirmClose(new Command() {

                @Override
                public void execute() {
                    tab.ensureHidden();
                }
            });
        }
    }, tab instanceof ProvidesBusy ? (ProvidesBusy) tab : null);
    tab.addEnsureVisibleHandler(new EnsureVisibleHandler() {

        public void onEnsureVisible(EnsureVisibleEvent event) {
            // First ensure that we ourselves are visible
            fireEvent(new EnsureVisibleEvent(event.getActivate()));
            if (event.getActivate())
                tabPanel_.selectTab(widget);
        }
    });
    tab.addEnsureHeightHandler(new EnsureHeightHandler() {

        @Override
        public void onEnsureHeight(EnsureHeightEvent event) {
            fireEvent(event);
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) ProvidesBusy(org.rstudio.core.client.widget.model.ProvidesBusy)

Example 18 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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 19 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.

the class RStudioAPI method showDialog.

private void showDialog(String caption, String message, final String url) {
    VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.addStyleName(RES.styles().textInfoWidget());
    SafeHtml safeMsg = DialogHtmlSanitizer.sanitizeHtml(message);
    HTML msg = new HTML(safeMsg.asString());
    msg.setWidth("100%");
    verticalPanel.add(msg);
    if (!StringUtil.isNullOrEmpty(url)) {
        HyperlinkLabel link = new HyperlinkLabel(url, new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                RStudioGinjector.INSTANCE.getGlobalDisplay().openWindow(url);
            }
        });
        link.addStyleName(RES.styles().installLink());
        verticalPanel.add(link);
    }
    MessageDialog dlg = new MessageDialog(MessageDialog.INFO, caption, verticalPanel);
    dlg.addButton("OK", new Operation() {

        @Override
        public void execute() {
            server_.showDialogCompleted(null, false, new SimpleRequestCallback<Void>());
        }
    }, true, false);
    dlg.showModal();
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HTML(com.google.gwt.user.client.ui.HTML) MessageDialog(org.rstudio.core.client.widget.MessageDialog) Operation(org.rstudio.core.client.widget.Operation) HyperlinkLabel(org.rstudio.core.client.widget.HyperlinkLabel) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Example 20 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project rstudio by rstudio.

the class RequestLogVisualization method addEntry.

private void addEntry(int i, final RequestLogEntry entry) {
    int top = totalHeight_ - (i + 1) * BAR_HEIGHT;
    int left = (int) ((entry.getRequestTime() - startTime_) * scaleMillisToPixels_);
    long endTime = entry.getResponseTime() != null ? entry.getResponseTime() : now_;
    int right = Math.max(0, (int) ((now_ - endTime) * scaleMillisToPixels_) - 1);
    boolean active = entry.getResponseType() == ResponseType.None;
    HTML html = new HTML();
    html.getElement().getStyle().setOverflow(Overflow.VISIBLE);
    html.getElement().getStyle().setProperty("whiteSpace", "nowrap");
    html.setText(entry.getRequestMethodName() + (active ? " (active)" : ""));
    if (active)
        html.getElement().getStyle().setFontWeight(FontWeight.BOLD);
    String color;
    switch(entry.getResponseType()) {
        case ResponseType.Error:
            color = "red";
            break;
        case ResponseType.None:
            color = "#f99";
            break;
        case ResponseType.Normal:
            color = "#88f";
            break;
        case ResponseType.Cancelled:
            color = "#E0E0E0";
            break;
        case ResponseType.Unknown:
        default:
            color = "yellow";
            break;
    }
    html.getElement().getStyle().setBackgroundColor(color);
    html.getElement().getStyle().setCursor(Cursor.POINTER);
    html.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            event.stopPropagation();
            detail_.clear();
            RequestLogDetail entryDetail = new RequestLogDetail(entry);
            entryDetail.setSize("100%", "100%");
            detail_.setWidget(entryDetail);
        }
    });
    overviewPanel_.add(html);
    overviewPanel_.setWidgetTopHeight(html, top, Unit.PX, BAR_HEIGHT, Unit.PX);
    overviewPanel_.setWidgetLeftRight(html, left, Unit.PX, right, Unit.PX);
    overviewPanel_.getWidgetContainerElement(html).getStyle().setOverflow(Overflow.VISIBLE);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)316 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)314 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)135 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)124 ArrayList (java.util.ArrayList)117 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)105 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)76 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)40 PerunError (cz.metacentrum.perun.webgui.model.PerunError)36 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)32 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)31 HashMap (java.util.HashMap)31 Button (com.google.gwt.user.client.ui.Button)30 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)25 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)23 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)20 Map (java.util.Map)20 User (cz.metacentrum.perun.webgui.model.User)19